Files
danyang-match/miniapp/services/matchmakerService.js
T

55 lines
1.9 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* 红娘服务(API_INVENTORY 行 102-105)
*
* 封装:申请红娘服务 / 我的服务列表 / 服务详情 / 红娘推荐列表。
* 关键不变量(AGENTS.md):
* - 第 5 条:红娘不可替用户 Like——红娘只产出推荐,最终 Like/Pass 由用户本人操作。
* 本层不提供任何"代用户操作"的接口;推荐操作走 matchService.like/pass。
* - 第 7 条:普通工作人员不能查看私人聊天——本层无聊天接入入口。
*/
const api = require('../utils/api');
/**
* 申请红娘服务(API_INVENTORY 行 102)
* @param {{ requirement: string }} payload 用户对自己择偶需求的进一步描述
* @returns {Promise<{ serviceId: string, status: 'submitted' }>}
*/
function applyService(payload) {
const idempotencyKey = `matchmaker-apply:${Date.now()}`;
return api.post('/matchmaker/services', payload, undefined, idempotencyKey);
}
/**
* 我的服务列表(API_INVENTORY 行 103)
* @param {{ cursor?: string, pageSize?: number }} params
* @returns {Promise<{ items: Array<import('../types').MatchmakerService>, nextCursor: string|null }>}
*/
function getMyServices(params = {}) {
return api.get('/matchmaker/services', params);
}
/**
* 服务详情(API_INVENTORY 行 104)
* @param {string} serviceId
* @returns {Promise<import('../types').MatchmakerService>}
*/
function getServiceDetail(serviceId) {
return api.get(`/matchmaker/services/${encodeURIComponent(serviceId)}`);
}
/**
* 红娘推荐列表(API_INVENTORY 行 105)
* @param {{ serviceId?: string, cursor?: string, pageSize?: number }} params
* @returns {Promise<{ items: Array<import('../types').MatchmakerRecommendation>, nextCursor: string|null }>}
*/
function getRecommendations(params = {}) {
return api.get('/matchmaker/recommendations', params);
}
module.exports = {
applyService,
getMyServices,
getServiceDetail,
getRecommendations,
};