chore: establish V1.1 recovery baseline
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
/**
|
||||
* 活动服务(API_INVENTORY 行 92-96, 98)
|
||||
*
|
||||
* 封装:活动列表 / 详情 / 报名 / 我的活动 / 反馈 / 互选意向提交。
|
||||
* 关键不变量(AGENTS.md):
|
||||
* - 第 6 条:活动单向意向保密——A 选 B 但 B 没选 → B 不知道。
|
||||
* 前端调用 interests 提交后,结果接口只返回"匹配成功"的双向交集,
|
||||
* 不返回对方是否单独选了我。
|
||||
* - 第 1 条:用户永久免费——feeType=paid 仅作为后端字段,前端展示以"公益免费"为主标识。
|
||||
* 报名与互选均走幂等键防重(AGENTS 第 12 条:参数配置化)。
|
||||
*/
|
||||
const api = require('../utils/api');
|
||||
|
||||
/**
|
||||
* 活动列表(API_INVENTORY 行 92)
|
||||
* @param {{ status?: string, cursor?: string, pageSize?: number }} params
|
||||
* @returns {Promise<{ items: Array<import('../types').Activity>, nextCursor: string|null }>}
|
||||
*/
|
||||
function getActivities(params = {}) {
|
||||
return api.get('/activities', params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 活动详情(API_INVENTORY 行 93)
|
||||
* @param {string} activityId
|
||||
* @returns {Promise<import('../types').Activity & { registrationStatus: import('../types').RegistrationStatus }>}
|
||||
*/
|
||||
function getActivityDetail(activityId) {
|
||||
return api.get(`/activities/${encodeURIComponent(activityId)}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* 报名活动(API_INVENTORY 行 94)
|
||||
* @param {string} activityId
|
||||
* @param {{ remark?: string }} [payload]
|
||||
* @returns {Promise<{ registrationStatus: 'pending', registrationId: string }>}
|
||||
*/
|
||||
function register(activityId, payload = {}) {
|
||||
const idempotencyKey = `activity-register:${activityId}:${Date.now()}`;
|
||||
return api.post(`/activities/${encodeURIComponent(activityId)}/register`, payload, undefined, idempotencyKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* 我的活动(API_INVENTORY 行 95)
|
||||
* @param {{ status?: string, cursor?: string, pageSize?: number }} params
|
||||
* @returns {Promise<{ items: Array<import('../types').Activity & { registrationStatus: import('../types').RegistrationStatus }>, nextCursor: string|null }>}
|
||||
*/
|
||||
function getMyActivities(params = {}) {
|
||||
return api.get('/my-activities', params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交活动反馈(API_INVENTORY 行 96)
|
||||
* @param {string} activityId
|
||||
* @param {{ rating: number, content: string }} payload
|
||||
* @returns {Promise<{ submitted: true }>}
|
||||
*/
|
||||
function submitFeedback(activityId, payload) {
|
||||
const idempotencyKey = `activity-feedback:${activityId}:${Date.now()}`;
|
||||
return api.post(`/activities/${encodeURIComponent(activityId)}/feedback`, payload, undefined, idempotencyKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交活动互选意向(API_INVENTORY 行 98,AGENTS 第 6 条:单向意向保密)
|
||||
* @param {string} activityId
|
||||
* @param {{ likedUserIds: string[] }} payload
|
||||
* @returns {Promise<{ submitted: true, matchedUserIds: string[] }>}
|
||||
* matchedUserIds 仅包含双向匹配成功的人;未匹配的人不会泄露是否被对方选择。
|
||||
*/
|
||||
function submitInterests(activityId, payload) {
|
||||
const idempotencyKey = `activity-interests:${activityId}:${Date.now()}`;
|
||||
return api.post(`/activities/${encodeURIComponent(activityId)}/interests`, payload, undefined, idempotencyKey);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getActivities,
|
||||
getActivityDetail,
|
||||
register,
|
||||
getMyActivities,
|
||||
submitFeedback,
|
||||
submitInterests,
|
||||
};
|
||||
Reference in New Issue
Block a user