Files
cozsweet-frontend-nextjs/docs/backend/profile.md
T

144 lines
3.5 KiB
Markdown
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.
告诉前端这次只改了 GET /api/user/profile 的响应,新增每日免费额度信息,原有字段不变。
接口:GET https://api.cozsweet.com/api/user/profile
新增字段:
{
"dailyFreeChatLimit": 10,
"dailyFreeChatUsed": 0,
"dailyFreeChatRemaining": 10,
"dailyFreePrivateLimit": 0,
"dailyFreePrivateUsed": 0,
"dailyFreePrivateRemaining": 0,
"dailyQuotas": {
"chat": {
"limit": 10,
"used": 0,
"remaining": 10
},
"privateMessage": {
"limit": 0,
"used": 0,
"remaining": 0
}
}
}
含义:
dailyFreeChatLimit:今天免费聊天总次数
dailyFreeChatUsed:今天已用免费聊天次数
dailyFreeChatRemaining:今天剩余免费聊天次数
dailyFreePrivateLimit:今天免费私密消息总次数
dailyFreePrivateUsed:今天已用免费私密消息次数
dailyFreePrivateRemaining:今天剩余免费私密消息次数
dailyQuotas:同样数据的结构化版本,前端想用对象也可以直接用它
当前额度规则:
游客/未注册:聊天 10,私密 0
注册用户:聊天 30,私密 2
注意:
聊天优先消耗 dailyFreeChatRemaining
私密消息优先消耗 dailyFreePrivateRemaining
聊天剩余为 0 时,前端应阻止继续聊天或展示后端返回的额度用完提示
私密剩余为 0 时,前端不要展示私密内容,按锁定私密消息处理。
16:19
profile完整字段发给前端
16:20
发给前端这版:
GET https://api.cozsweet.com/api/user/profile
Authorization: Bearer <token>
完整响应结构:
interface ProfileResponse {
code: number;
message: string;
success: boolean;
data: UserProfile;
}
interface UserProfile {
id: string;
username: string;
email: string | null;
platform: string;
intimacy: number;
dolBalance: number;
creditBalance: number;
isTestAccount: boolean;
personalityTraits: Record<string, number> | null;
preferredLanguage: string | null;
createdAt: string | null;
lastMessageAt: string | null;
country: string | null;
countryCode: string | null;
dailyFreeChatLimit: number;
dailyFreeChatUsed: number;
dailyFreeChatRemaining: number;
dailyFreePrivateLimit: number;
dailyFreePrivateUsed: number;
dailyFreePrivateRemaining: number;
dailyQuotas: {
chat: {
limit: number;
used: number;
remaining: number;
};
privateMessage: {
limit: number;
used: number;
remaining: number;
};
};
}
示例:
{
"code": 200,
"message": "success",
"success": true,
"data": {
"id": "user-id",
"username": "guest_codex",
"email": "device_xxx@guest.local",
"platform": "web",
"intimacy": 0,
"dolBalance": 0,
"creditBalance": 0,
"isTestAccount": false,
"personalityTraits": {
"caring": 0.5,
"playful": 0.5,
"serious": 0.5,
"cheerful": 0.5,
"romantic": 0.5
},
"preferredLanguage": "ja",
"createdAt": "2026-07-03T16:12:01.591264+08:00",
"lastMessageAt": null,
"country": "Japan",
"countryCode": "JP",
"dailyFreeChatLimit": 10,
"dailyFreeChatUsed": 0,
"dailyFreeChatRemaining": 10,
"dailyFreePrivateLimit": 0,
"dailyFreePrivateUsed": 0,
"dailyFreePrivateRemaining": 0,
"dailyQuotas": {
"chat": {
"limit": 10,
"used": 0,
"remaining": 10
},
"privateMessage": {
"limit": 0,
"used": 0,
"remaining": 0
}
}
}
}
额度规则:
游客:dailyFreeChatLimit = 10dailyFreePrivateLimit = 0
注册用户:dailyFreeChatLimit = 30dailyFreePrivateLimit = 2