增加feifei履约配置界面
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
import { Router } from "express";
|
||||
|
||||
import {
|
||||
getAdminKuaishouFeifeiConfig,
|
||||
matchAdminKuaishouFeifeiProduct,
|
||||
updateAdminKuaishouFeifeiConfig,
|
||||
} from "../../../services/admin/platform-config/kuaishou-feifei-service.js";
|
||||
import { createJsonHandler } from "../session.js";
|
||||
import type { JsonRecord } from "../../../types/json.js";
|
||||
|
||||
const router = Router();
|
||||
|
||||
router.get(
|
||||
"/kuaishou-feifei",
|
||||
createJsonHandler(() => getAdminKuaishouFeifeiConfig(), {
|
||||
successMessage: "ok",
|
||||
errorMessage: "读取 kuaishou-feifei 配置失败",
|
||||
scope: "[admin/platform-config/kuaishou-feifei]",
|
||||
})
|
||||
);
|
||||
|
||||
router.post(
|
||||
"/kuaishou-feifei",
|
||||
createJsonHandler(
|
||||
(req) => updateAdminKuaishouFeifeiConfig(req.body as JsonRecord),
|
||||
{
|
||||
successMessage: "kuaishou-feifei 配置已保存",
|
||||
errorMessage: "保存 kuaishou-feifei 配置失败",
|
||||
scope: "[admin/platform-config/kuaishou-feifei]",
|
||||
audit: (_req, data) => {
|
||||
const result = data as JsonRecord;
|
||||
const source = result.source as JsonRecord | undefined;
|
||||
return {
|
||||
action: "platform_kuaishou_feifei_config_updated",
|
||||
targetType: "platform_config",
|
||||
targetId: "kuaishou_feifei",
|
||||
data: {
|
||||
filePath: String(result.filePath || "").trim(),
|
||||
enabled: source?.enabled !== false,
|
||||
ruleCount: Array.isArray(source?.productRules)
|
||||
? source.productRules.length
|
||||
: 0,
|
||||
},
|
||||
};
|
||||
},
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
router.post(
|
||||
"/kuaishou-feifei/match",
|
||||
createJsonHandler(
|
||||
(req) => matchAdminKuaishouFeifeiProduct(req.body as JsonRecord),
|
||||
{
|
||||
successMessage: "ok",
|
||||
errorMessage: "匹配 kuaishou-feifei 商品失败",
|
||||
scope: "[admin/platform-config/kuaishou-feifei/match]",
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
export default router;
|
||||
Reference in New Issue
Block a user