feat(expert): 大神服务包自助维护(新增/编辑/删除/上下架)+ 去掉演示服务包
- 后端:新增 POST/PUT/DELETE /api/companions/:id/services[...](仅本人大神或管理员),含名称/单价区间(平台定价规范)/长度/内容安全/每人20个上限校验 - 仓储:createExpertService/updateExpertService/deleteExpertService/countExpertServices/getCompanionByUserId;移除"首次读取自动生成 3 个演示服务包",并在建表后一次性清理历史演示数据 - 新增 GET /api/expert/me:工作台按登录用户解析真实大神档案(不再固定演示 id 101) - 小程序:api.js 增加 getMyExpertProfile/createExpertService/updateExpertService/deleteExpertService;工作台新增「新增服务」入口、每项「编辑/删除」按钮与服务包表单弹窗,收益/服务统计改用真实大神 id - 新增回归护栏 expert-service-crud.spec.ts(93 套件/662 用例全绿);冒烟 9/9(含跨大神越权 403、低价 400)
这个提交包含在:
@@ -1034,6 +1034,44 @@ export async function updateExpertServiceStatus(expertId = 101, serviceId, statu
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前登录用户的大神档案(大神工作台使用)
|
||||
*/
|
||||
export async function getMyExpertProfile(userId) {
|
||||
const uid = normalizeUserId(userId);
|
||||
try {
|
||||
const res = await http.get(`/expert/me?userId=${uid}`);
|
||||
return res || null;
|
||||
} catch (err) {
|
||||
console.warn('[API] 获取大神档案异常:', err.message);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增服务包(仅本人大神)
|
||||
*/
|
||||
export async function createExpertService(expertId, payload = {}) {
|
||||
const res = await http.post(`/companions/${Number(expertId)}/services`, { ...payload, userId: normalizeUserId(payload.userId) });
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑服务包(整体覆盖,仅本人大神)
|
||||
*/
|
||||
export async function updateExpertService(expertId, serviceId, payload = {}) {
|
||||
const res = await http.put(`/companions/${Number(expertId)}/services/${serviceId}`, { ...payload, userId: normalizeUserId(payload.userId) });
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除服务包(仅本人大神)
|
||||
*/
|
||||
export async function deleteExpertService(expertId, serviceId) {
|
||||
const res = await http.delete(`/companions/${Number(expertId)}/services/${serviceId}`);
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户收藏的陪玩列表
|
||||
*/
|
||||
|
||||
在新工单中引用
屏蔽一个用户