Align Sidebar & BottomNav menus, remove "Search", add user profile mock data, implement /api/users, add FilterDrawer, complete Section, ProfileHeader, MetricsRFM components Co-authored-by: null <4804959+fnvtk@users.noreply.github.com>
27 lines
732 B
TypeScript
27 lines
732 B
TypeScript
import { NextResponse } from "next/server"
|
|
import { getWeights, setWeights } from "@/services/rfm-engine"
|
|
|
|
export async function GET() {
|
|
return NextResponse.json({ success: true, data: getWeights() })
|
|
}
|
|
|
|
export async function POST(req: Request) {
|
|
try {
|
|
const body = await req.json()
|
|
let R = Number(body.R ?? 0.5)
|
|
let F = Number(body.F ?? 0.3)
|
|
let M = Number(body.M ?? 0.2)
|
|
|
|
// 归一化
|
|
const sum = Math.max(0.000001, R + F + M)
|
|
R = R / sum
|
|
F = F / sum
|
|
M = M / sum
|
|
|
|
setWeights({ R, F, M })
|
|
return NextResponse.json({ success: true, data: { R, F, M } })
|
|
} catch (e: any) {
|
|
return NextResponse.json({ success: false, error: e?.message || "Invalid input" }, { status: 400 })
|
|
}
|
|
}
|