"use strict"; /* * 喝酒了么 - 后端接口 API * 小程序:喝酒了么(uni-app 微信小程序) * 基础URL: /api/v1 * * 主要功能模块: * 1. 用户模块 - 微信登录、用户信息管理 * 2. 打卡记录模块 - 饮酒记录创建、查询、日历数据 * 3. 照片上传模块 - 单张/批量照片上传 * 4. 统计模块 - 用户统计、月度统计、酒类分布 * 5. 成就模块 - 成就列表和进度 * 6. 社交模块 - 朋友圈动态、点赞 */ export class Enum { constructor(value) { this.v = value; } toString() { return this.v; } toJSON() { return this.v; } valueOf() { return this.v; }; } /** * 成就条件类型 */ export class AchievementConditionType { /** * 总记录数 */ static TotalRecords = "total_records"; /** * 累计标准杯 */ static TotalStandardCups = "total_standard_cups"; /** * 连续打卡天数 */ static StreakDays = "streak_days"; /** * 某酒类打卡次数 */ static CategoryRecords = "category_records"; /** * 尝试酒类品种数 */ static CategoryVariety = "category_variety"; static entries() { return [ { value: AchievementConditionType.TotalRecords, label: '总记录数' }, { value: AchievementConditionType.TotalStandardCups, label: '累计标准杯' }, { value: AchievementConditionType.StreakDays, label: '连续打卡天数' }, { value: AchievementConditionType.CategoryRecords, label: '某酒类打卡次数' }, { value: AchievementConditionType.CategoryVariety, label: '尝试酒类品种数' }, ]; } static getLabel(v) { switch(v) { case AchievementConditionType.TotalRecords: return '总记录数'; case AchievementConditionType.TotalStandardCups: return '累计标准杯'; case AchievementConditionType.StreakDays: return '连续打卡天数'; case AchievementConditionType.CategoryRecords: return '某酒类打卡次数'; case AchievementConditionType.CategoryVariety: return '尝试酒类品种数'; } } } /** * 酒类分类 */ export class Category { /** * 白酒 */ static Baijiu = "baijiu"; /** * 啤酒 */ static Beer = "beer"; /** * 红酒 */ static Wine = "wine"; /** * 洋酒 */ static Whisky = "whisky"; /** * 黄酒 */ static Huangjiu = "huangjiu"; /** * 清酒 */ static Sake = "sake"; /** * 果酒 */ static Fruit = "fruit"; /** * 调酒 */ static Cocktail = "cocktail"; /** * 其他 */ static Other = "other"; static entries() { return [ { value: Category.Baijiu, label: '白酒' }, { value: Category.Beer, label: '啤酒' }, { value: Category.Wine, label: '红酒' }, { value: Category.Whisky, label: '洋酒' }, { value: Category.Huangjiu, label: '黄酒' }, { value: Category.Sake, label: '清酒' }, { value: Category.Fruit, label: '果酒' }, { value: Category.Cocktail, label: '调酒' }, { value: Category.Other, label: '其他' }, ]; } static getLabel(v) { switch(v) { case Category.Baijiu: return '白酒'; case Category.Beer: return '啤酒'; case Category.Wine: return '红酒'; case Category.Whisky: return '洋酒'; case Category.Huangjiu: return '黄酒'; case Category.Sake: return '清酒'; case Category.Fruit: return '果酒'; case Category.Cocktail: return '调酒'; case Category.Other: return '其他'; } } } /** * 饮用量单位 */ export class Unit { /** * 毫升 */ static Ml = "ml"; /** * 两 */ static Liang = "liang"; /** * 瓶 */ static Bottle = "bottle"; /** * 杯 */ static Cup = "cup"; /** * 听 */ static Can = "can"; /** * shot */ static Shot = "shot"; static entries() { return [ { value: Unit.Ml, label: '毫升' }, { value: Unit.Liang, label: '两' }, { value: Unit.Bottle, label: '瓶' }, { value: Unit.Cup, label: '杯' }, { value: Unit.Can, label: '听' }, { value: Unit.Shot, label: 'shot' }, ]; } static getLabel(v) { switch(v) { case Unit.Ml: return '毫升'; case Unit.Liang: return '两'; case Unit.Bottle: return '瓶'; case Unit.Cup: return '杯'; case Unit.Can: return '听'; case Unit.Shot: return 'shot'; } } } /** * 配餐分类 */ export class FoodCategory { /** * 火锅 */ static Hotpot = "hotpot"; /** * 烧烤 */ static Bbq = "bbq"; /** * 炒菜 */ static Stirfry = "stirfry"; /** * 海鲜 */ static Seafood = "seafood"; /** * 日料 */ static Japanese = "japanese"; /** * 西餐 */ static Western = "western"; /** * 小吃卤味 */ static Snack = "snack"; /** * 零食 */ static Junk = "junk"; /** * 无配餐 */ static None = "none"; static entries() { return [ { value: FoodCategory.Hotpot, label: '火锅' }, { value: FoodCategory.Bbq, label: '烧烤' }, { value: FoodCategory.Stirfry, label: '炒菜' }, { value: FoodCategory.Seafood, label: '海鲜' }, { value: FoodCategory.Japanese, label: '日料' }, { value: FoodCategory.Western, label: '西餐' }, { value: FoodCategory.Snack, label: '小吃卤味' }, { value: FoodCategory.Junk, label: '零食' }, { value: FoodCategory.None, label: '无配餐' }, ]; } static getLabel(v) { switch(v) { case FoodCategory.Hotpot: return '火锅'; case FoodCategory.Bbq: return '烧烤'; case FoodCategory.Stirfry: return '炒菜'; case FoodCategory.Seafood: return '海鲜'; case FoodCategory.Japanese: return '日料'; case FoodCategory.Western: return '西餐'; case FoodCategory.Snack: return '小吃卤味'; case FoodCategory.Junk: return '零食'; case FoodCategory.None: return '无配餐'; } } } /** * 饮用感受 */ export class Feeling { /** * 微醺 */ static Tipsy = "tipsy"; /** * 到位 */ static Buzzed = "buzzed"; /** * 醉了 */ static Drunk = "drunk"; /** * 断片 */ static Blackout = "blackout"; static entries() { return [ { value: Feeling.Tipsy, label: '微醺' }, { value: Feeling.Buzzed, label: '到位' }, { value: Feeling.Drunk, label: '醉了' }, { value: Feeling.Blackout, label: '断片' }, ]; } static getLabel(v) { switch(v) { case Feeling.Tipsy: return '微醺'; case Feeling.Buzzed: return '到位'; case Feeling.Drunk: return '醉了'; case Feeling.Blackout: return '断片'; } } } /** * 可见范围 */ export class Visibility { /** * 公开 */ static Public = "public"; /** * 仅好友 */ static Friends = "friends"; /** * 仅自己 */ static Private = "private"; static entries() { return [ { value: Visibility.Public, label: '公开' }, { value: Visibility.Friends, label: '仅好友' }, { value: Visibility.Private, label: '仅自己' }, ]; } static getLabel(v) { switch(v) { case Visibility.Public: return '公开'; case Visibility.Friends: return '仅好友'; case Visibility.Private: return '仅自己'; } } } /** * 打卡模式 */ export class Mode { /** * 今日喝了 */ static Drank = "drank"; /** * 今日未喝 */ static Abstain = "abstain"; static entries() { return [ { value: Mode.Drank, label: '今日喝了' }, { value: Mode.Abstain, label: '今日未喝' }, ]; } static getLabel(v) { switch(v) { case Mode.Drank: return '今日喝了'; case Mode.Abstain: return '今日未喝'; } } } /** * 饮酒频率 */ export class Frequency { /** * 很少 */ static Rarely = "rarely"; /** * 有时 */ static Sometimes = "sometimes"; /** * 经常 */ static Often = "often"; static entries() { return [ { value: Frequency.Rarely, label: '很少' }, { value: Frequency.Sometimes, label: '有时' }, { value: Frequency.Often, label: '经常' }, ]; } static getLabel(v) { switch(v) { case Frequency.Rarely: return '很少'; case Frequency.Sometimes: return '有时'; case Frequency.Often: return '经常'; } } } /** * 酒局状态 */ export class EventStatus { /** * 开放报名 */ static Open = 1; /** * 待开始 */ static Upcoming = 2; /** * 进行中 */ static Ongoing = 3; /** * 已结束 */ static Ended = 4; static entries() { return [ { value: EventStatus.Open, label: '开放报名' }, { value: EventStatus.Upcoming, label: '待开始' }, { value: EventStatus.Ongoing, label: '进行中' }, { value: EventStatus.Ended, label: '已结束' }, ]; } static getLabel(v) { switch(v) { case EventStatus.Open: return '开放报名'; case EventStatus.Upcoming: return '待开始'; case EventStatus.Ongoing: return '进行中'; case EventStatus.Ended: return '已结束'; } } } /** * 消息类型(文本/图片) */ export class MessageType { /** * 文本消息 */ static Text = "text"; /** * 图片消息 */ static Image = "image"; static entries() { return [ { value: MessageType.Text, label: '文本消息' }, { value: MessageType.Image, label: '图片消息' }, ]; } static getLabel(v) { switch(v) { case MessageType.Text: return '文本消息'; case MessageType.Image: return '图片消息'; } } } /** * 消息状态(发送、送达、已读) */ export class MessageStatus { /** * 发送中 */ static Sending = "sending"; /** * 已发送 */ static Sent = "sent"; /** * 已送达 */ static Delivered = "delivered"; /** * 已读 */ static Read = "read"; static entries() { return [ { value: MessageStatus.Sending, label: '发送中' }, { value: MessageStatus.Sent, label: '已发送' }, { value: MessageStatus.Delivered, label: '已送达' }, { value: MessageStatus.Read, label: '已读' }, ]; } static getLabel(v) { switch(v) { case MessageStatus.Sending: return '发送中'; case MessageStatus.Sent: return '已发送'; case MessageStatus.Delivered: return '已送达'; case MessageStatus.Read: return '已读'; } } } /** * 客户端 WebSocket 消息类型 */ export class ClientMesgType { /** * 发送消息 */ static Chat = "chat"; /** * 输入状态 */ static Typing = "typing"; /** * 已读回执 */ static Read = "read"; /** * 心跳 */ static Ping = "ping"; static entries() { return [ { value: ClientMesgType.Chat, label: '发送消息' }, { value: ClientMesgType.Typing, label: '输入状态' }, { value: ClientMesgType.Read, label: '已读回执' }, { value: ClientMesgType.Ping, label: '心跳' }, ]; } static getLabel(v) { switch(v) { case ClientMesgType.Chat: return '发送消息'; case ClientMesgType.Typing: return '输入状态'; case ClientMesgType.Read: return '已读回执'; case ClientMesgType.Ping: return '心跳'; } } } /** * 服务端 WebSocket 消息类型 */ export class ServerMesgType { /** * 推送新消息 */ static Chat = "chat"; /** * 对方输入状态 */ static Typing = "typing"; /** * 对方已读回执 */ static Read = "read"; /** * 消息送达确认 */ static Ack = "ack"; /** * 心跳响应 */ static Pong = "pong"; /** * 连接成功 */ static Connected = "connected"; /** * 被踢下线 */ static Kicked = "kicked"; static entries() { return [ { value: ServerMesgType.Chat, label: '推送新消息' }, { value: ServerMesgType.Typing, label: '对方输入状态' }, { value: ServerMesgType.Read, label: '对方已读回执' }, { value: ServerMesgType.Ack, label: '消息送达确认' }, { value: ServerMesgType.Pong, label: '心跳响应' }, { value: ServerMesgType.Connected, label: '连接成功' }, { value: ServerMesgType.Kicked, label: '被踢下线' }, ]; } static getLabel(v) { switch(v) { case ServerMesgType.Chat: return '推送新消息'; case ServerMesgType.Typing: return '对方输入状态'; case ServerMesgType.Read: return '对方已读回执'; case ServerMesgType.Ack: return '消息送达确认'; case ServerMesgType.Pong: return '心跳响应'; case ServerMesgType.Connected: return '连接成功'; case ServerMesgType.Kicked: return '被踢下线'; } } } /** * 手机号 */ export class Phone { /** * @param regin string * @param number string */ constructor(regin, number) { this.regin = regin; this.number = number; } } /** * 分页请求参数 */ export class PageReq { /** * @param page: number 页码 * @param pageSize: number 每页数量,默认1-100 */ constructor(page,pageSize,) { this.page = page; this.pageSize = pageSize; } static fromObject(o) { return new PageReq(o.page,o.pageSize,); } } /** * 分页响应结构 */ export class PageResp { /** * @param total: number 总数 * @param page: number 当前页码 * @param pageSize: number 每页数量 */ constructor(total,page,pageSize,) { this.total = total; this.page = page; this.pageSize = pageSize; } static fromObject(o) { return new PageResp(o.total,o.page,o.pageSize,); } } /** * */ export class Ok { /** * @param ok: boolean 是否成功 */ constructor(ok,) { this.ok = ok; } static fromObject(o) { return new Ok(o.ok,); } } /** * 用于表示无数据 */ export class None { /** */ constructor() { } static fromObject(o) { return new None(); } } /** * 微信登录请求参数 */ export class WechatLoginReq { /** * @param code: string 登录时获取的 code, 可通过 wx.login 获取 * @param nickName: string 用户昵称 * @param avatarUrl: string 头像URL */ constructor(code,nickName,avatarUrl,) { this.code = code; this.nickName = nickName; this.avatarUrl = avatarUrl; } static fromObject(o) { return new WechatLoginReq(o.code,o.nickName,o.avatarUrl,); } } /** * 微信登录返回值 */ export class WechatLoginResp { /** * @param token: string JWT Token * @param user: User 用户信息 * @param isNew: boolean 是否新用户 * @param session_key: string 会话密钥 * @param open_id: string 用户唯一标识 * @param union_id: string 用户在开放平台的唯一标识符,若当前小程序已绑定到微信开放平台账号下会返回,详见 UnionID 机制说明。 * @param errcode: number 错误码 * @param errmsg: string 错误信息 * @param refresh_token: string 刷新token */ constructor(token,user,isNew,session_key,open_id,union_id,errcode,errmsg,refresh_token,) { this.token = token; this.user = user; this.isNew = isNew; this.session_key = session_key; this.open_id = open_id; this.union_id = union_id; this.errcode = errcode; this.errmsg = errmsg; this.refresh_token = refresh_token; } static fromObject(o) { return new WechatLoginResp(o.token,o.user,o.isNew,o.session_key,o.open_id,o.union_id,o.errcode,o.errmsg,o.refresh_token,); } } /** * 获取微信手机号 */ export class WechatGetPhoneNumberReq { /** * @param code: string 手机号获取凭证 */ constructor(code,) { this.code = code; } static fromObject(o) { return new WechatGetPhoneNumberReq(o.code,); } } /** * 获取微信手机号返回值 */ export class WechatGetPhoneNumberResp { /** * @param errcode: number 错误码 * @param errmsg: string 错误信息 * @param token: string token:api使用 * @param expires_in: number token 超时时间,单位(秒) * @param refresh_token: string refresh_token:刷新token */ constructor(errcode,errmsg,token,expires_in,refresh_token,) { this.errcode = errcode; this.errmsg = errmsg; this.token = token; this.expires_in = expires_in; this.refresh_token = refresh_token; } static fromObject(o) { return new WechatGetPhoneNumberResp(o.errcode,o.errmsg,o.token,o.expires_in,o.refresh_token,); } } /** * 刷新token请求参数 */ export class RefreshTokenReq { /** * @param refresh_token: string 签发 token 时生成的 refresh_token */ constructor(refresh_token,) { this.refresh_token = refresh_token; } static fromObject(o) { return new RefreshTokenReq(o.refresh_token,); } } /** * 刷新 token 返回值 */ export class RefreshTokenResp { /** * @param token: string 生成的新token * @param expire_in: number token 超时时间,单位(秒) * @param refresh_token: string refresh_token:刷新token */ constructor(token,expire_in,refresh_token,) { this.token = token; this.expire_in = expire_in; this.refresh_token = refresh_token; } static fromObject(o) { return new RefreshTokenResp(o.token,o.expire_in,o.refresh_token,); } } /** * 成就条件 */ export class AchievementCondition { /** * @param type: AchievementConditionType 条件类型 * @param value: number 目标值 */ constructor(type,value,) { this.type = type; this.value = value; } static fromObject(o) { return new AchievementCondition(o.type,o.value,); } } /** * 成就信息 */ export class Achievement { /** * @param id: string 成就ID * @param name: string 成就名称 * @param desc: string 成就描述 * @param icon: string 成就图标 * @param unlocked: boolean 是否已解锁 * @param unlockedAt: string 解锁时间 * @param condition: AchievementCondition 成就条件 * @param progress: number 进度(0-1) */ constructor(id,name,desc,icon,unlocked,unlockedAt,condition,progress,) { this.id = id; this.name = name; this.desc = desc; this.icon = icon; this.unlocked = unlocked; this.unlockedAt = unlockedAt; this.condition = condition; this.progress = progress; } static fromObject(o) { return new Achievement(o.id,o.name,o.desc,o.icon,o.unlocked,o.unlockedAt,o.condition,o.progress,); } } /** * */ export class GetAchievementsReq { /** */ constructor() { } static fromObject(o) { return new GetAchievementsReq(); } } /** * 获取成就列表响应 */ export class GetAchievementsResp { /** * @param data: AchievementsData 成就列表数据 */ constructor(data,) { this.data = data; } static fromObject(o) { return new GetAchievementsResp(o.data,); } } /** * 成就列表数据 */ export class AchievementsData { /** * @param achievements: Array 成就列表 */ constructor(achievements,) { this.achievements = achievements; } static fromObject(o) { return new AchievementsData(o.achievements,); } } /** * 朋友圈动态项 */ export class FeedItem { /** * @param id: string|number 记录ID * @param user: FeedUser 用户信息 * @param date: string 日期 * @param mode: Mode 打卡模式 * @param drinks: Array 酒水列表 * @param food: FoodInfo 配餐信息 * @param feeling: Feeling 感受 * @param photos: Array 照片URL数组 * @param standardCupsTotal: number 标准杯总数 * @param quote: string 酒言酒语 * @param likeCount: number 点赞数 * @param commentCount: number 评论数 * @param liked: boolean 当前用户是否已点赞 * @param createdAt: string 创建时间 */ constructor(id,user,date,mode,drinks,food,feeling,photos,standardCupsTotal,quote,likeCount,commentCount,liked,createdAt,) { this.id = id; this.user = user; this.date = date; this.mode = mode; this.drinks = drinks; this.food = food; this.feeling = feeling; this.photos = photos; this.standardCupsTotal = standardCupsTotal; this.quote = quote; this.likeCount = likeCount; this.commentCount = commentCount; this.liked = liked; this.createdAt = createdAt; } static fromObject(o) { return new FeedItem(o.id,o.user,o.date,o.mode,o.drinks,o.food,o.feeling,o.photos,o.standardCupsTotal,o.quote,o.likeCount,o.commentCount,o.liked,o.createdAt,); } } /** * 朋友圈用户信息 */ export class FeedUser { /** * @param id: string|number 用户ID * @param nickname: string 用户昵称 * @param avatar: string 头像URL */ constructor(id,nickname,avatar,) { this.id = id; this.nickname = nickname; this.avatar = avatar; } static fromObject(o) { return new FeedUser(o.id,o.nickname,o.avatar,); } } /** * 获取朋友圈动态请求 */ export class GetFeedReq { /** * @param lastId: string|number 游标分页,上一页最后一条ID */ constructor(lastId,) { this.lastId = lastId; } static fromObject(o) { return new GetFeedReq(o.lastId,); } } /** * 获取朋友圈动态响应 */ export class GetFeedResp { /** * @param data: FeedPageData 朋友圈动态分页数据 */ constructor(data,) { this.data = data; } static fromObject(o) { return new GetFeedResp(o.data,); } } /** * 朋友圈动态分页数据 */ export class FeedPageData { /** * @param list: Array 动态列表 */ constructor(list,) { this.list = list; } static fromObject(o) { return new FeedPageData(o.list,); } } /** * 上传照片请求 */ export class UploadPhotoReq { /** * @param url: string 图片Url * @param recordId: string|number 关联记录ID */ constructor(url,recordId,) { this.url = url; this.recordId = recordId; } static fromObject(o) { return new UploadPhotoReq(o.url,o.recordId,); } } /** * 上传照片响应 */ export class UploadPhotoResp { /** */ constructor() { } static fromObject(o) { return new UploadPhotoResp(); } } /** * 批量上传照片请求 */ export class UploadPhotosReq { /** * @param urls: Array 图片URL数组(最多9张) * @param recordId: string|number 关联记录ID */ constructor(urls,recordId,) { this.urls = urls; this.recordId = recordId; } static fromObject(o) { return new UploadPhotosReq(o.urls,o.recordId,); } } /** * 批量上传照片响应 */ export class UploadPhotosResp { /** */ constructor() { } static fromObject(o) { return new UploadPhotosResp(); } } /** * 酒水项 */ export class DrinkItem { /** * @param category: Category 酒类分类ID * @param brand: string 品牌名称 * @param product: string 产品名 * @param amount: number 饮用量数值 * @param unit: Unit 单位 * @param degree: number 酒精度数(%) * @param standardCups: number 标准杯数(前端计算,后端应校验) * @param customAmount: number 自定义饮酒数量 * @param customUnit: Unit 自定义饮酒单位 */ constructor(category,brand,product,amount,unit,degree,standardCups,customAmount,customUnit,) { this.category = category; this.brand = brand; this.product = product; this.amount = amount; this.unit = unit; this.degree = degree; this.standardCups = standardCups; this.customAmount = customAmount; this.customUnit = customUnit; } static fromObject(o) { return new DrinkItem(o.category,o.brand,o.product,o.amount,o.unit,o.degree,o.standardCups,o.customAmount,o.customUnit,); } } /** * 配餐信息 */ export class FoodInfo { /** * @param category: FoodCategory 配餐分类ID * @param name: string 具体菜名 */ constructor(category,name,) { this.category = category; this.name = name; } static fromObject(o) { return new FoodInfo(o.category,o.name,); } } /** * 创建打卡记录请求 */ export class CreateRecordReq { /** * @param date: string 日期 YYYY-MM-DD * @param mode: Mode 打卡模式 * @param drinks: Array 酒水列表(mode=abstain时为空数组) * @param food: FoodInfo 配餐信息 * @param feeling: Feeling 感受ID * @param photos: Array 照片URL数组(最多9张) * @param visibility: Visibility 可见范围 * @param quote: string 酒言酒语 */ constructor(date,mode,drinks,food,feeling,photos,visibility,quote,) { this.date = date; this.mode = mode; this.drinks = drinks; this.food = food; this.feeling = feeling; this.photos = photos; this.visibility = visibility; this.quote = quote; } static fromObject(o) { return new CreateRecordReq(o.date,o.mode,o.drinks,o.food,o.feeling,o.photos,o.visibility,o.quote,); } } /** * 打卡记录详情 */ export class Record { /** * @param id: string|number 记录ID * @param date: string 日期 * @param mode: Mode 打卡模式 * @param drinks: Array 酒水列表 * @param food: FoodInfo 配餐信息 * @param feeling: Feeling 感受 * @param photos: Array 照片URL数组 * @param visibility: Visibility 可见范围 * @param quote: string 酒言酒语 * @param standardCupsTotal: number 标准杯总数 * @param createdAt: string 创建时间 */ constructor(id,date,mode,drinks,food,feeling,photos,visibility,quote,standardCupsTotal,createdAt,) { this.id = id; this.date = date; this.mode = mode; this.drinks = drinks; this.food = food; this.feeling = feeling; this.photos = photos; this.visibility = visibility; this.quote = quote; this.standardCupsTotal = standardCupsTotal; this.createdAt = createdAt; } static fromObject(o) { return new Record(o.id,o.date,o.mode,o.drinks,o.food,o.feeling,o.photos,o.visibility,o.quote,o.standardCupsTotal,o.createdAt,); } } /** * 创建打卡记录响应 */ export class CreateRecordResp { /** * @param data: Record 创建的记录详情 */ constructor(data,) { this.data = data; } static fromObject(o) { return new CreateRecordResp(o.data,); } } /** * 获取记录列表请求 */ export class GetRecordsReq { /** * @param page: number 页码 * @param pageSize: number 每页数量,默认1-100 * @param month: string 月份筛选 YYYY-MM * @param mode: Mode 打卡模式筛选 */ constructor(page,pageSize,month,mode,) { this.page = page; this.pageSize = pageSize; this.month = month; this.mode = mode; } static fromObject(o) { return new GetRecordsReq(o.page,o.pageSize,o.month,o.mode,); } } /** * 获取记录列表响应 */ export class GetRecordsResp { /** * @param list: Array 分页数据 */ constructor(list,) { this.list = list; } static fromObject(o) { return new GetRecordsResp(o.list,); } } /** * 获取单条记录详情请求 */ export class GetRecordDetailReq { /** * @param id: string|number 记录ID */ constructor(id,) { this.id = id; } static fromObject(o) { return new GetRecordDetailReq(o.id,); } } /** * 获取单条记录详情响应 */ export class GetRecordDetailResp { /** * @param data: Record 记录详情 */ constructor(data,) { this.data = data; } static fromObject(o) { return new GetRecordDetailResp(o.data,); } } /** * 删除记录请求 */ export class DeleteRecordReq { /** * @param id: string|number 记录ID */ constructor(id,) { this.id = id; } static fromObject(o) { return new DeleteRecordReq(o.id,); } } /** * 删除记录响应 */ export class DeleteRecordResp { /** */ constructor() { } static fromObject(o) { return new DeleteRecordResp(); } } /** * 获取日历打卡数据请求 */ export class GetCalendarReq { /** * @param year: number 年份 * @param month: number 月份(1-12) */ constructor(year,month,) { this.year = year; this.month = month; } static fromObject(o) { return new GetCalendarReq(o.year,o.month,); } } /** * 日历打卡数据 */ export class CalendarData { /** * @param year: number 年份 * @param month: number 月份 * @param days: Array 每天的打卡数据,null表示当天无记录 */ constructor(year,month,days,) { this.year = year; this.month = month; this.days = days; } static fromObject(o) { return new CalendarData(o.year,o.month,o.days,); } } /** * 日历单日打卡数据 */ export class CalendarDayData { /** * @param date: string 日期YYYY-MM-DD * @param hasRecord: boolean 是否有记录 * @param mode: Mode 打卡模式 * @param standardCupsTotal: number 标准杯总数 * @param id: string|number 记录ID * @param drinks: Array 酒水列表 * @param food: FoodInfo 配餐信息 * @param feeling: Feeling 感受 * @param photos: Array 照片URL数组 * @param visibility: Visibility 可见范围 * @param quote: string 酒言酒语 * @param createdAt: string 创建时间 */ constructor(date,hasRecord,mode,standardCupsTotal,id,drinks,food,feeling,photos,visibility,quote,createdAt,) { this.date = date; this.hasRecord = hasRecord; this.mode = mode; this.standardCupsTotal = standardCupsTotal; this.id = id; this.drinks = drinks; this.food = food; this.feeling = feeling; this.photos = photos; this.visibility = visibility; this.quote = quote; this.createdAt = createdAt; } static fromObject(o) { return new CalendarDayData(o.date,o.hasRecord,o.mode,o.standardCupsTotal,o.id,o.drinks,o.food,o.feeling,o.photos,o.visibility,o.quote,o.createdAt,); } } /** * 获取日历打卡数据响应 */ export class GetCalendarResp { /** * @param year: number 年份 * @param month: number 月份 * @param days: Array 每天的打卡数据,null表示当天无记录 */ constructor(year,month,days,) { this.year = year; this.month = month; this.days = days; } static fromObject(o) { return new GetCalendarResp(o.year,o.month,o.days,); } } /** * 用户统计概览数据 */ export class StatsOverview { /** * @param weekDrinkCount: number 本周饮酒天数 * @param weekCups: number 本周标准杯总数 * @param monthDrinkCount: number 本月饮酒天数 * @param monthCups: number 本月标准杯总数 * @param streak: number 当前连续打卡天数 * @param streakType: Mode 连续类型 * @param totalDays: number 总饮酒天数(去重) * @param totalRecords: number 总记录数 * @param totalCups: number 历史累计标准杯 * @param favCategory: Category 最爱酒类ID * @param categoryVariety: number 尝试过的酒类品种数 */ constructor(weekDrinkCount,weekCups,monthDrinkCount,monthCups,streak,streakType,totalDays,totalRecords,totalCups,favCategory,categoryVariety,) { this.weekDrinkCount = weekDrinkCount; this.weekCups = weekCups; this.monthDrinkCount = monthDrinkCount; this.monthCups = monthCups; this.streak = streak; this.streakType = streakType; this.totalDays = totalDays; this.totalRecords = totalRecords; this.totalCups = totalCups; this.favCategory = favCategory; this.categoryVariety = categoryVariety; } static fromObject(o) { return new StatsOverview(o.weekDrinkCount,o.weekCups,o.monthDrinkCount,o.monthCups,o.streak,o.streakType,o.totalDays,o.totalRecords,o.totalCups,o.favCategory,o.categoryVariety,); } } /** * 获取用户统计概览响应 */ export class GetStatsOverviewResp { /** * @param data: StatsOverview 统计概览数据 */ constructor(data,) { this.data = data; } static fromObject(o) { return new GetStatsOverviewResp(o.data,); } } /** * 获取月度统计请求 */ export class GetMonthlyStatsReq { /** * @param year: number 年份,默认当前年 * @param month: number 月份,默认当前月 */ constructor(year,month,) { this.year = year; this.month = month; } static fromObject(o) { return new GetMonthlyStatsReq(o.year,o.month,); } } /** * 月度统计数据 */ export class MonthlyStats { /** * @param year: number 年份 * @param month: number 月份 * @param drinkDays: number 饮酒天数 * @param abstainDays: number 戒酒天数 * @param totalCups: number 总标准杯数 * @param avgCupsPerDay: number 日均标准杯数 * @param categoryBreakdown: Array 酒类分布 * @param feelingBreakdown: Array 感受分布 * @param foodBreakdown: Array 配餐分布 */ constructor(year,month,drinkDays,abstainDays,totalCups,avgCupsPerDay,categoryBreakdown,feelingBreakdown,foodBreakdown,) { this.year = year; this.month = month; this.drinkDays = drinkDays; this.abstainDays = abstainDays; this.totalCups = totalCups; this.avgCupsPerDay = avgCupsPerDay; this.categoryBreakdown = categoryBreakdown; this.feelingBreakdown = feelingBreakdown; this.foodBreakdown = foodBreakdown; } static fromObject(o) { return new MonthlyStats(o.year,o.month,o.drinkDays,o.abstainDays,o.totalCups,o.avgCupsPerDay,o.categoryBreakdown,o.feelingBreakdown,o.foodBreakdown,); } } /** * 酒类分布统计项 */ export class CategoryBreakdown { /** * @param category: Category 酒类分类 * @param count: number 次数 * @param cups: number 标准杯数 */ constructor(category,count,cups,) { this.category = category; this.count = count; this.cups = cups; } static fromObject(o) { return new CategoryBreakdown(o.category,o.count,o.cups,); } } /** * 感受分布统计项 */ export class FeelingBreakdown { /** * @param feeling: Feeling 感受类型 * @param count: number 次数 */ constructor(feeling,count,) { this.feeling = feeling; this.count = count; } static fromObject(o) { return new FeelingBreakdown(o.feeling,o.count,); } } /** * 配餐分布统计项 */ export class FoodBreakdown { /** * @param category: FoodCategory 配餐分类 * @param count: number 次数 */ constructor(category,count,) { this.category = category; this.count = count; } static fromObject(o) { return new FoodBreakdown(o.category,o.count,); } } /** * 获取月度统计响应 */ export class GetMonthlyStatsResp { /** * @param data: MonthlyStats 月度统计数据 */ constructor(data,) { this.data = data; } static fromObject(o) { return new GetMonthlyStatsResp(o.data,); } } /** * 酒类分布统计项 */ export class CategoryStats { /** * @param id: Category 酒类分类ID * @param name: string 酒类名称 * @param recordCount: number 记录次数 * @param totalCups: number 总标准杯数 * @param percentage: number 占比(百分比) */ constructor(id,name,recordCount,totalCups,percentage,) { this.id = id; this.name = name; this.recordCount = recordCount; this.totalCups = totalCups; this.percentage = percentage; } static fromObject(o) { return new CategoryStats(o.id,o.name,o.recordCount,o.totalCups,o.percentage,); } } /** * */ export class GetStatsOverviewReq { /** */ constructor() { } static fromObject(o) { return new GetStatsOverviewReq(); } } /** * */ export class GetCategoryStatsReq { /** */ constructor() { } static fromObject(o) { return new GetCategoryStatsReq(); } } /** * 获取酒类分布统计响应 */ export class GetCategoryStatsResp { /** * @param data: CategoryStatsData 酒类分布统计数据 */ constructor(data,) { this.data = data; } static fromObject(o) { return new GetCategoryStatsResp(o.data,); } } /** * 酒类分布统计数据 */ export class CategoryStatsData { /** * @param categories: Array 酒类分布列表 */ constructor(categories,) { this.categories = categories; } static fromObject(o) { return new CategoryStatsData(o.categories,); } } /** * 用户信息 */ export class User { /** * @param id: string|number 用户ID * @param nickname: string 用户昵称 * @param avatar: string 头像URL * @param joinedAt: string 加入时间 * @param preferences: UserPreferences 用户偏好 */ constructor(id,nickname,avatar,joinedAt,preferences,) { this.id = id; this.nickname = nickname; this.avatar = avatar; this.joinedAt = joinedAt; this.preferences = preferences; } static fromObject(o) { return new User(o.id,o.nickname,o.avatar,o.joinedAt,o.preferences,); } } /** * 用户偏好设置 */ export class UserPreferences { /** * @param favoriteCategories: Array 偏好酒类ID列表 * @param frequency: Frequency 饮酒频率 */ constructor(favoriteCategories,frequency,) { this.favoriteCategories = favoriteCategories; this.frequency = frequency; } static fromObject(o) { return new UserPreferences(o.favoriteCategories,o.frequency,); } } /** * 获取用户信息请求 */ export class GetUserProfileReq { /** */ constructor() { } static fromObject(o) { return new GetUserProfileReq(); } } /** * 获取用户信息响应 */ export class GetUserProfileResp { /** * @param id: string|number 用户ID * @param nickname: string 用户昵称 * @param avatar: string 头像URL * @param joinedAt: string 加入时间 * @param preferences: UserPreferences 用户偏好 */ constructor(id,nickname,avatar,joinedAt,preferences,) { this.id = id; this.nickname = nickname; this.avatar = avatar; this.joinedAt = joinedAt; this.preferences = preferences; } static fromObject(o) { return new GetUserProfileResp(o.id,o.nickname,o.avatar,o.joinedAt,o.preferences,); } } /** * 更新用户偏好请求 */ export class UpdatePreferencesReq { /** * @param favoriteCategories: Array 偏好酒类ID列表 * @param frequency: Frequency 饮酒频率 */ constructor(favoriteCategories,frequency,) { this.favoriteCategories = favoriteCategories; this.frequency = frequency; } static fromObject(o) { return new UpdatePreferencesReq(o.favoriteCategories,o.frequency,); } } /** * 更新用户偏好响应 */ export class UpdatePreferencesResp { /** * @param favoriteCategories: Array 偏好酒类ID列表 * @param frequency: Frequency 饮酒频率 */ constructor(favoriteCategories,frequency,) { this.favoriteCategories = favoriteCategories; this.frequency = frequency; } static fromObject(o) { return new UpdatePreferencesResp(o.favoriteCategories,o.frequency,); } } /** * 上传图片参数 */ export class UploadImageReq { /** * @param image: any 图片 */ constructor(image,) { this.image = image; } static fromObject(o) { return new UploadImageReq(o.image,); } } /** * 上传图片返回 */ export class UploadImageResp { /** * @param id: string|number 图片 id * @param url: string 图片 url */ constructor(id,url,) { this.id = id; this.url = url; } static fromObject(o) { return new UploadImageResp(o.id,o.url,); } } /** * 引用文件参数 */ export class ReferenceFileReq { /** * @param module: string 模块名称 * @param data: number 数据 id * @param urls: Array 文件 urls */ constructor(module,data,urls,) { this.module = module; this.data = data; this.urls = urls; } static fromObject(o) { return new ReferenceFileReq(o.module,o.data,o.urls,); } } /** * 引用文件返回 */ export class ReferenceFileResp { /** * @param ok: boolean 是否成功 */ constructor(ok,) { this.ok = ok; } static fromObject(o) { return new ReferenceFileResp(o.ok,); } } /** * 取消引用文件参数 */ export class DereferenceFileReq { /** * @param module: string 模块 * @param data: number 数据 id * @param urls: Array 文件 urls */ constructor(module,data,urls,) { this.module = module; this.data = data; this.urls = urls; } static fromObject(o) { return new DereferenceFileReq(o.module,o.data,o.urls,); } } /** * 取消引用文件返回 */ export class DereferenceFileResp { /** * @param ok: boolean 是否成功 */ constructor(ok,) { this.ok = ok; } static fromObject(o) { return new DereferenceFileResp(o.ok,); } } /** * 删除数据参数 */ export class DeleteDataReq { /** * @param module: string 模块 * @param data: number 数据 id */ constructor(module,data,) { this.module = module; this.data = data; } static fromObject(o) { return new DeleteDataReq(o.module,o.data,); } } /** * 删除数据返回 */ export class DeleteDataResp { /** * @param ok: boolean 是否成功 */ constructor(ok,) { this.ok = ok; } static fromObject(o) { return new DeleteDataResp(o.ok,); } } /** * 酒水标签 */ export class DrinkTag { /** * @param category: Category 酒类分类 * @param name: string 酒类名称 * @param amount: number 酒类数量 */ constructor(category,name,amount,) { this.category = category; this.name = name; this.amount = amount; } static fromObject(o) { return new DrinkTag(o.category,o.name,o.amount,); } } /** * 获取酒友圈动态请求 */ export class GetFeedsReq { /** * @param lastId: string|number 最后一条动态ID,用于分页 * @param pageSize: number 每页数量 */ constructor(lastId,pageSize,) { this.lastId = lastId; this.pageSize = pageSize; } static fromObject(o) { return new GetFeedsReq(o.lastId,o.pageSize,); } } /** * 动态信息 */ export class Feed { /** * @param id: string|number 动态ID * @param userId: string|number 用户ID * @param nickname: string 昵称 * @param avatar: string 头像 * @param time: string 发布时间 * @param text: string 动态文本 * @param drinks: Array 酒水标签 * @param feeling: Feeling 自我感觉 * @param images: Array 图片列表 * @param likes: number 点赞数 * @param liked: boolean 是否点赞 * @param comments: number 评论数 */ constructor(id,userId,nickname,avatar,time,text,drinks,feeling,images,likes,liked,comments,) { this.id = id; this.userId = userId; this.nickname = nickname; this.avatar = avatar; this.time = time; this.text = text; this.drinks = drinks; this.feeling = feeling; this.images = images; this.likes = likes; this.liked = liked; this.comments = comments; } static fromObject(o) { return new Feed(o.id,o.userId,o.nickname,o.avatar,o.time,o.text,o.drinks,o.feeling,o.images,o.likes,o.liked,o.comments,); } } /** * 动态列表响应 */ export class GetFeedsResp { /** * @param list: Array 动态列表 * @param hasMore: boolean 是否还有更多动态 */ constructor(list,hasMore,) { this.list = list; this.hasMore = hasMore; } static fromObject(o) { return new GetFeedsResp(o.list,o.hasMore,); } } /** * 发布动态请求 */ export class PublishFeedReq { /** * @param text: string 动态文本 * @param images: Array 图片列表 * @param recordId: string|number 关联的记录ID * @param visibility: Visibility 可见性 */ constructor(text,images,recordId,visibility,) { this.text = text; this.images = images; this.recordId = recordId; this.visibility = visibility; } static fromObject(o) { return new PublishFeedReq(o.text,o.images,o.recordId,o.visibility,); } } /** * 发布动态响应 */ export class PublishFeedResp { /** * @param success: boolean 是否成功 * @param feedId: string|number 动态ID */ constructor(success,feedId,) { this.success = success; this.feedId = feedId; } static fromObject(o) { return new PublishFeedResp(o.success,o.feedId,); } } /** * 点赞/取消点赞请求(路径参数) */ export class LikeFeedReq { /** * @param id: string|number 动态ID */ constructor(id,) { this.id = id; } static fromObject(o) { return new LikeFeedReq(o.id,); } } /** * 点赞响应 */ export class LikeFeedResp { /** * @param ok: boolean 是否成功 */ constructor(ok,) { this.ok = ok; } static fromObject(o) { return new LikeFeedResp(o.ok,); } } /** * */ export class UnlikeFeedReq { /** * @param id: string|number 动态ID */ constructor(id,) { this.id = id; } static fromObject(o) { return new UnlikeFeedReq(o.id,); } } /** * 取消点赞响应 */ export class UnlikeFeedResp { /** * @param ok: boolean 是否成功 */ constructor(ok,) { this.ok = ok; } static fromObject(o) { return new UnlikeFeedResp(o.ok,); } } /** * 评论信息 */ export class Comment { /** * @param id: string|number 评论ID * @param userId: string|number 用户ID * @param nickname: string 昵称 * @param avatar: string 头像 * @param content: string 评论内容 * @param time: string 评论时间 */ constructor(id,userId,nickname,avatar,content,time,) { this.id = id; this.userId = userId; this.nickname = nickname; this.avatar = avatar; this.content = content; this.time = time; } static fromObject(o) { return new Comment(o.id,o.userId,o.nickname,o.avatar,o.content,o.time,); } } /** * 评论列表响应 */ export class CommentListData { /** * @param list: Array 评论列表 */ constructor(list,) { this.list = list; } static fromObject(o) { return new CommentListData(o.list,); } } /** * 获取评论请求(路径参数) */ export class GetFeedCommentsReq { /** * @param id: string|number 动态ID */ constructor(id,) { this.id = id; } static fromObject(o) { return new GetFeedCommentsReq(o.id,); } } /** * 发表评论请求(含路径参数) */ export class AddCommentFullReq { /** * @param id: string|number 动态ID * @param content: string 评论内容 */ constructor(id,content,) { this.id = id; this.content = content; } static fromObject(o) { return new AddCommentFullReq(o.id,o.content,); } } /** * 发表评论响应 */ export class AddCommentResp { /** * @param id: string|number 评论ID * @param userId: string|number 用户ID * @param nickname: string 昵称 * @param avatar: string 头像 * @param content: string 评论内容 * @param time: string 评论时间 */ constructor(id,userId,nickname,avatar,content,time,) { this.id = id; this.userId = userId; this.nickname = nickname; this.avatar = avatar; this.content = content; this.time = time; } static fromObject(o) { return new AddCommentResp(o.id,o.userId,o.nickname,o.avatar,o.content,o.time,); } } /** * 酒友信息 */ export class Friend { /** * @param id: string|number 酒友ID * @param nickname: string 昵称 * @param avatar: string 头像 * @param lastDrink: string|number 最近一次喝的酒 * @param lastDrinkTime: string 最近一次喝的酒时间 * @param online: boolean 是否在线 */ constructor(id,nickname,avatar,lastDrink,lastDrinkTime,online,) { this.id = id; this.nickname = nickname; this.avatar = avatar; this.lastDrink = lastDrink; this.lastDrinkTime = lastDrinkTime; this.online = online; } static fromObject(o) { return new Friend(o.id,o.nickname,o.avatar,o.lastDrink,o.lastDrinkTime,o.online,); } } /** * 获取好友请求列表请求 */ export class GetFriendRequestsReq { /** */ constructor() { } static fromObject(o) { return new GetFriendRequestsReq(); } } /** * 酒友列表响应 */ export class GetFriendRequestsResp { /** * @param list: Array 分页数据 */ constructor(list,) { this.list = list; } static fromObject(o) { return new GetFriendRequestsResp(o.list,); } } /** * 获取酒友列表请求 */ export class GetFriendsReq { /** * @param keyword: string 搜索关键词 */ constructor(keyword,) { this.keyword = keyword; } static fromObject(o) { return new GetFriendsReq(o.keyword,); } } /** * 好友请求信息 */ export class FriendRequest { /** * @param id: string|number 好友请求ID * @param userId: string|number 酒友ID * @param nickname: string 昵称 * @param avatar: string 头像 * @param message: string 消息 * @param time: string 创建时间 */ constructor(id,userId,nickname,avatar,message,time,) { this.id = id; this.userId = userId; this.nickname = nickname; this.avatar = avatar; this.message = message; this.time = time; } static fromObject(o) { return new FriendRequest(o.id,o.userId,o.nickname,o.avatar,o.message,o.time,); } } /** * 好友请求列表响应 */ export class FriendRequestListData { /** * @param list: Array 分页数据 */ constructor(list,) { this.list = list; } static fromObject(o) { return new FriendRequestListData(o.list,); } } /** * 发送好友请求 */ export class SendFriendRequestReq { /** * @param userId: string|number 酒友ID * @param message: string 消息 */ constructor(userId,message,) { this.userId = userId; this.message = message; } static fromObject(o) { return new SendFriendRequestReq(o.userId,o.message,); } } /** * 发送好友请求响应 */ export class SendFriendRequestResp { /** */ constructor() { } static fromObject(o) { return new SendFriendRequestResp(); } } /** * 接受好友请求(路径参数) */ export class AcceptFriendRequestReq { /** * @param id: string|number 好友请求ID */ constructor(id,) { this.id = id; } static fromObject(o) { return new AcceptFriendRequestReq(o.id,); } } /** * 接受好友请求响应 */ export class AcceptFriendRequestResp { /** */ constructor() { } static fromObject(o) { return new AcceptFriendRequestResp(); } } /** * 删除酒友请求(路径参数) */ export class RemoveFriendReq { /** * @param userId: string|number 酒友ID */ constructor(userId,) { this.userId = userId; } static fromObject(o) { return new RemoveFriendReq(o.userId,); } } /** * 删除酒友响应 */ export class RemoveFriendResp { /** */ constructor() { } static fromObject(o) { return new RemoveFriendResp(); } } /** * 酒局信息 */ export class Event { /** * @param id: string|number 酒局ID * @param title: string 酒局标题 * @param organizer: User 酒局组织者 * @param time: string 酒局时间 * @param location: string 酒局地点 * @param maxPeople: number 最大人数 * @param joined: number 已报名人数 * @param participants: Array 已报名用户 * @param status: EventStatus 酒局状态 * @param note: string 酒局备注 * @param isJoined: boolean 是否已报名 * @param isOrganizer: boolean 是否为组织者 */ constructor(id,title,organizer,time,location,maxPeople,joined,participants,status,note,isJoined,isOrganizer,) { this.id = id; this.title = title; this.organizer = organizer; this.time = time; this.location = location; this.maxPeople = maxPeople; this.joined = joined; this.participants = participants; this.status = status; this.note = note; this.isJoined = isJoined; this.isOrganizer = isOrganizer; } static fromObject(o) { return new Event(o.id,o.title,o.organizer,o.time,o.location,o.maxPeople,o.joined,o.participants,o.status,o.note,o.isJoined,o.isOrganizer,); } } /** * 酒局列表响应 */ export class EventListData { /** * @param list: Array 分页数据 */ constructor(list,) { this.list = list; } static fromObject(o) { return new EventListData(o.list,); } } /** * 获取酒局列表请求 */ export class GetEventsReq { /** * @param status: EventStatus 状态筛选 */ constructor(status,) { this.status = status; } static fromObject(o) { return new GetEventsReq(o.status,); } } /** * 获取酒局详情请求(路径参数) */ export class GetEventDetailReq { /** * @param id: string|number 酒局ID */ constructor(id,) { this.id = id; } static fromObject(o) { return new GetEventDetailReq(o.id,); } } /** * 坐标信息 */ export class GeoPoint { /** * @param latitude: number 纬度 * @param longitude: number 经度 */ constructor(latitude,longitude,) { this.latitude = latitude; this.longitude = longitude; } static fromObject(o) { return new GeoPoint(o.latitude,o.longitude,); } } /** * 发起酒局请求 */ export class CreateEventReq { /** * @param title: string 酒局标题 * @param time: string 酒局时间 * @param location: string 酒局地点 * @param maxPeople: number 最大人数 * @param geo: GeoPoint 坐标信息 * @param note: string 酒局备注 */ constructor(title,time,location,maxPeople,geo,note,) { this.title = title; this.time = time; this.location = location; this.maxPeople = maxPeople; this.geo = geo; this.note = note; } static fromObject(o) { return new CreateEventReq(o.title,o.time,o.location,o.maxPeople,o.geo,o.note,); } } /** * 发起酒局响应 */ export class CreateEventResp { /** * @param eventId: string|number 酒局ID */ constructor(eventId,) { this.eventId = eventId; } static fromObject(o) { return new CreateEventResp(o.eventId,); } } /** * 报名/取消/签到请求(路径参数) */ export class JoinEventReq { /** * @param id: string|number 酒局ID */ constructor(id,) { this.id = id; } static fromObject(o) { return new JoinEventReq(o.id,); } } /** * */ export class JoinEventResp { /** * @param ok: boolean 是否成功 */ constructor(ok,) { this.ok = ok; } static fromObject(o) { return new JoinEventResp(o.ok,); } } /** * */ export class QuitEventReq { /** * @param id: string|number 酒局ID */ constructor(id,) { this.id = id; } static fromObject(o) { return new QuitEventReq(o.id,); } } /** * */ export class QuitEventResp { /** * @param ok: boolean 是否成功 */ constructor(ok,) { this.ok = ok; } static fromObject(o) { return new QuitEventResp(o.ok,); } } /** * */ export class CheckInEventReq { /** * @param id: string|number 酒局ID */ constructor(id,) { this.id = id; } static fromObject(o) { return new CheckInEventReq(o.id,); } } /** * */ export class CheckInEventResp { /** * @param ok: boolean 是否成功 */ constructor(ok,) { this.ok = ok; } static fromObject(o) { return new CheckInEventResp(o.ok,); } } /** * 会话信息 */ export class Conversation { /** * @param id: string 会话ID * @param friendId: string|number 对方用户ID * @param nickname: string 对方昵称 * @param avatar: string 对方头像URL(可为空) * @param lastMessage: string 最后一条消息摘要 * @param lastTime: string 最后消息时间(ISO 8601) * @param unread: number 未读消息数 * @param online: boolean 对方是否在线 */ constructor(id,friendId,nickname,avatar,lastMessage,lastTime,unread,online,) { this.id = id; this.friendId = friendId; this.nickname = nickname; this.avatar = avatar; this.lastMessage = lastMessage; this.lastTime = lastTime; this.unread = unread; this.online = online; } static fromObject(o) { return new Conversation(o.id,o.friendId,o.nickname,o.avatar,o.lastMessage,o.lastTime,o.unread,o.online,); } } /** * */ export class GetConversationsReq { /** */ constructor() { } static fromObject(o) { return new GetConversationsReq(); } } /** * 获取会话列表响应 */ export class GetConversationsResp { /** * @param list: Array 会话列表 */ constructor(list,) { this.list = list; } static fromObject(o) { return new GetConversationsResp(o.list,); } } /** * 获取历史消息请求 */ export class GetMessagesReq { /** * @param conversationId: string 会话ID * @param lastID: string|number 游标分页 * @param pageSize: number 每页数量,默认20 */ constructor(conversationId,lastID,pageSize,) { this.conversationId = conversationId; this.lastID = lastID; this.pageSize = pageSize; } static fromObject(o) { return new GetMessagesReq(o.conversationId,o.lastID,o.pageSize,); } } /** * 消息记录 */ export class Message { /** * @param id: string|number 消息ID * @param conversationId: string 会话ID * @param senderId: string|number 发送者ID * @param receiverId: string|number 接收者ID * @param type: MessageType 消息类型 * @param content: string 消息内容 * @param timestamp: number 发送时间(毫秒时间戳) * @param status: MessageStatus 消息状态 */ constructor(id,conversationId,senderId,receiverId,type,content,timestamp,status,) { this.id = id; this.conversationId = conversationId; this.senderId = senderId; this.receiverId = receiverId; this.type = type; this.content = content; this.timestamp = timestamp; this.status = status; } static fromObject(o) { return new Message(o.id,o.conversationId,o.senderId,o.receiverId,o.type,o.content,o.timestamp,o.status,); } } /** * 获取历史消息响应 */ export class GetMessagesResp { /** * @param list: Array 消息列表 * @param hasMore: boolean 是否还有更多消息 */ constructor(list,hasMore,) { this.list = list; this.hasMore = hasMore; } static fromObject(o) { return new GetMessagesResp(o.list,o.hasMore,); } } /** * 标记已读请求(路径参数) */ export class MarkReadReq { /** * @param id: string 会话ID(路径参数) */ constructor(id,) { this.id = id; } static fromObject(o) { return new MarkReadReq(o.id,); } } /** * 标记已读响应 */ export class MarkReadResp { /** * @param success: boolean 是否成功 */ constructor(success,) { this.success = success; } static fromObject(o) { return new MarkReadResp(o.success,); } } /** * */ export class GetUnreadCountReq { /** */ constructor() { } static fromObject(o) { return new GetUnreadCountReq(); } } /** * 获取未读总数响应 */ export class GetUnreadCountResp { /** * @param total: number 未读总数 */ constructor(total,) { this.total = total; } static fromObject(o) { return new GetUnreadCountResp(o.total,); } } /** * 客户端 - 发送聊天数据 */ export class ClientChatData { /** * @param receiverId: string|number 接收者ID * @param content: string 消息内容 * @param msgType: MessageType 消息类型 * @param clientMesgId: string|number 客户端消息ID */ constructor(receiverId,content,msgType,clientMesgId,) { this.receiverId = receiverId; this.content = content; this.msgType = msgType; this.clientMesgId = clientMesgId; } static fromObject(o) { return new ClientChatData(o.receiverId,o.content,o.msgType,o.clientMesgId,); } } /** * 客户端 - 输入状态数据 */ export class ClientTypingData { /** * @param receiverId: string|number 接收者ID */ constructor(receiverId,) { this.receiverId = receiverId; } static fromObject(o) { return new ClientTypingData(o.receiverId,); } } /** * 客户端 - 已读回执数据 */ export class ClientReadData { /** * @param conversationId: string 会话ID * @param lastMsgId: string|number 最后一条消息ID */ constructor(conversationId,lastMsgId,) { this.conversationId = conversationId; this.lastMsgId = lastMsgId; } static fromObject(o) { return new ClientReadData(o.conversationId,o.lastMsgId,); } } /** * 客户端 - ping 数据(空) */ export class ClientPingData { /** */ constructor() { } static fromObject(o) { return new ClientPingData(); } } /** * 服务端 - 推送聊天数据 */ export class ServerChatData { /** * @param msgId: string|number 消息ID * @param senderId: string|number 发送者ID * @param receiverId: string|number 接收者ID * @param conversationId: string 会话ID * @param content: string 消息内容 * @param msgType: MessageType 消息类型 * @param timestamp: number 发送时间(毫秒时间戳) */ constructor(msgId,senderId,receiverId,conversationId,content,msgType,timestamp,) { this.msgId = msgId; this.senderId = senderId; this.receiverId = receiverId; this.conversationId = conversationId; this.content = content; this.msgType = msgType; this.timestamp = timestamp; } static fromObject(o) { return new ServerChatData(o.msgId,o.senderId,o.receiverId,o.conversationId,o.content,o.msgType,o.timestamp,); } } /** * 服务端 - 推送输入状态数据 */ export class ServerTypingData { /** * @param senderId: string|number 发送者ID */ constructor(senderId,) { this.senderId = senderId; } static fromObject(o) { return new ServerTypingData(o.senderId,); } } /** * 服务端 - 推送已读回执数据 */ export class ServerReadData { /** * @param conversationId: string 会话ID * @param readerId: string|number 读取者ID */ constructor(conversationId,readerId,) { this.conversationId = conversationId; this.readerId = readerId; } static fromObject(o) { return new ServerReadData(o.conversationId,o.readerId,); } } /** * 服务端 - ACK 数据 */ export class ServerAckData { /** * @param clientMsgId: string|number 客户端消息ID * @param msgId: string|number 消息ID * @param status: MessageStatus 消息状态 */ constructor(clientMsgId,msgId,status,) { this.clientMsgId = clientMsgId; this.msgId = msgId; this.status = status; } static fromObject(o) { return new ServerAckData(o.clientMsgId,o.msgId,o.status,); } } /** * 服务端 - pong 数据(空) */ export class ServerPongData { /** */ constructor() { } static fromObject(o) { return new ServerPongData(); } } /** * 服务端 - 连接成功数据 */ export class ServerConnectedData { /** * @param userId: string|number 用户ID */ constructor(userId,) { this.userId = userId; } static fromObject(o) { return new ServerConnectedData(o.userId,); } } /** * 服务端 - 被踢下线数据(空) */ export class ServerKickedData { /** */ constructor() { } static fromObject(o) { return new ServerKickedData(); } } /** * */ export class ChatWebSocket { /** * @param mesgType: ClientMesgType 消息类型 * @param data: ClientMessage 消息数据 */ constructor(mesgType,data,) { this.mesgType = mesgType; this.data = data; } static fromObject(o) { return new ChatWebSocket(o.mesgType,o.data,); } } /** * WebSocket 响应 */ export class ChatWebSocketResp { /** * @param mesgType: ServerMesgType 消息类型 * @param data: ServerMessage 消息数据 */ constructor(mesgType,data,) { this.mesgType = mesgType; this.data = data; } static fromObject(o) { return new ChatWebSocketResp(o.mesgType,o.data,); } } export class ChatWebSocketConn { /** * 构造函数 * * @param host string 主机名 */ constructor(host) { this.host = host; this.reconnect = true; this.reconnectDelay = 1000; this.maxReconnectDelay = 5000; this.randomizationFactor = 0.5; this.attempt = 0; this.connect(); } backoff(attempt) { let delay = this.reconnectDelay * Math.pow(2, attempt); if (delay > this.maxReconnectDelay) { delay = this.maxReconnectDelay; } const jitter = this.randomizationFactor * (2 * Math.random() - 1); let delayWithJitter = delay * (1 + jitter); if (delayWithJitter < 0) { delayWithJitter = 0; } return delayWithJitter; } connect() { let socket = new WebSocket(`ws://${this.host}/api/have_a_drink/v1/chat/chat`); socket.onopen = (event) => { this.onopen(event); }; socket.onerror = (err) => { this.onerror(err); }; socket.onclose = (event) => { this.onclose(event); if (this.reconnect) { setTimeout(() => { this.connect(); }, this.backoff(this.attempt++)); } }; socket.onmessage = (event) => { this.onmessage(event); const data = JSON.parse(event.data); switch (data.mesgType) { case ServerMesgType.Chat: if (this.onServerChatData) { this.onServerChatData(data.data); } break; case ServerMesgType.Typing: if (this.onServerTypingData) { this.onServerTypingData(data.data); } break; case ServerMesgType.Read: if (this.onServerReadData) { this.onServerReadData(data.data); } break; case ServerMesgType.Ack: if (this.onServerAckData) { this.onServerAckData(data.data); } break; case ServerMesgType.Pong: if (this.onServerPongData) { this.onServerPongData(data.data); } break; case ServerMesgType.Connected: if (this.onServerConnectedData) { this.onServerConnectedData(data.data); } break; case ServerMesgType.Kicked: if (this.onServerKickedData) { this.onServerKickedData(data.data); } break; } }; this.socket = socket; } /** * 当连接打开时调用 * * @param {Event} event - 打开事件 */ onopen(event) {} /** * 当收到消息时调用 * * @param {MessageEvent} event - 消息事件 */ onmessage(event) {} /** * 当收到 ServerChatData 消息时调用 * * @param {ServerChatData} data - 消息数据 */ onServerChatData(data) {} /** * 当收到 ServerTypingData 消息时调用 * * @param {ServerTypingData} data - 消息数据 */ onServerTypingData(data) {} /** * 当收到 ServerReadData 消息时调用 * * @param {ServerReadData} data - 消息数据 */ onServerReadData(data) {} /** * 当收到 ServerAckData 消息时调用 * * @param {ServerAckData} data - 消息数据 */ onServerAckData(data) {} /** * 当收到 ServerPongData 消息时调用 * * @param {ServerPongData} data - 消息数据 */ onServerPongData(data) {} /** * 当收到 ServerConnectedData 消息时调用 * * @param {ServerConnectedData} data - 消息数据 */ onServerConnectedData(data) {} /** * 当收到 ServerKickedData 消息时调用 * * @param {ServerKickedData} data - 消息数据 */ onServerKickedData(data) {} writeClientChatData(data) { this.socket.send(JSON.stringify({ mesgType: ClientMesgType.Chat, data: data, })); } writeClientTypingData(data) { this.socket.send(JSON.stringify({ mesgType: ClientMesgType.Typing, data: data, })); } writeClientReadData(data) { this.socket.send(JSON.stringify({ mesgType: ClientMesgType.Read, data: data, })); } writeClientPingData(data) { this.socket.send(JSON.stringify({ mesgType: ClientMesgType.Ping, data: data, })); } /** * 当连接关闭时调用 * * @param {CloseEvent} event - 关闭事件 */ onclose(event) {} /** * 当发生错误时调用 * * @param {ErrorEvent} event - 错误事件 */ onerror(event) {} /** * 关闭连接 */ close() { this.reconnect = false; this.socket.close(); } } /** * * 喝酒了么 - 后端接口 API * 小程序:喝酒了么(uni-app 微信小程序) * 基础URL: /api/v1 * * 主要功能模块: * 1. 用户模块 - 微信登录、用户信息管理 * 2. 打卡记录模块 - 饮酒记录创建、查询、日历数据 * 3. 照片上传模块 - 单张/批量照片上传 * 4. 统计模块 - 用户统计、月度统计、酒类分布 * 5. 成就模块 - 成就列表和进度 * 6. 社交模块 - 朋友圈动态、点赞 */ export default class HaveADrink { constructor(conf) { this.host = conf.host; this.http_request = conf.http_request; this.upload = conf.upload; this.token = conf.token; } /** * 设置 token */ setToken(token) { this.token = token; } /** * 微信登录, 获取openid、unionid、token */ WechatLogin(req) { return new Promise((reslove, reject)=>{ let data = req; let url = `${this.host}/api/have_a_drink/v1/auth/wechat/login`; this.http_request(url, { uri: '/api/have_a_drink/v1/auth/wechat/login', method: 'POST', data: data, responseType: 'json', headers: { 'Content-Type': 'application/json', }, }).then((data)=>{ if (data.hasOwnProperty("fail")) { if (data.fail) { reject(data.msg); } else { reslove(data.data); } } else { reslove(data); } }).catch((err)=>reject(err)); }); } /** * 获取微信手机号 */ WechatGetPhoneNumber(req) { return new Promise((reslove, reject)=>{ let data = req; let url = `${this.host}/api/have_a_drink/v1/auth/wechat/get_phone_number`; this.http_request(url, { uri: '/api/have_a_drink/v1/auth/wechat/get_phone_number', method: 'POST', data: data, responseType: 'json', headers: { 'Content-Type': 'application/json', }, }).then((data)=>{ if (data.hasOwnProperty("fail")) { if (data.fail) { reject(data.msg); } else { reslove(data.data); } } else { reslove(data); } }).catch((err)=>reject(err)); }); } /** * 刷新 token 接口 */ RefreshToken(req) { return new Promise((reslove, reject)=>{ let data = req; let url = `${this.host}/api/have_a_drink/v1/auth/refresh_token`; this.http_request(url, { uri: '/api/have_a_drink/v1/auth/refresh_token', method: 'POST', data: data, responseType: 'json', headers: { 'Content-Type': 'application/json', }, }).then((data)=>{ if (data.hasOwnProperty("fail")) { if (data.fail) { reject(data.msg); } else { reslove(data.data); } } else { reslove(data); } }).catch((err)=>reject(err)); }); } /** * 获取成就列表 */ GetAchievements(req) { return new Promise((reslove, reject)=>{ let data = req; let url = `${this.host}/api/have_a_drink/v1/achievements/list`; const query = Object.keys(data).map((x)=>(`${x}=${data[x]}`)).join('&'); this.http_request(url, { uri: '/api/have_a_drink/v1/achievements/list', method: 'GET', query: query, data: data, responseType: 'json', headers: { }, }).then((data)=>{ if (data.hasOwnProperty("fail")) { if (data.fail) { reject(data.msg); } else { reslove(data.data); } } else { reslove(data); } }).catch((err)=>reject(err)); }); } /** * 获取朋友圈动态 */ GetFeed(req) { return new Promise((reslove, reject)=>{ let data = req; let url = `${this.host}/api/have_a_drink/v1/communication/feed`; const query = Object.keys(data).map((x)=>(`${x}=${data[x]}`)).join('&'); this.http_request(url, { uri: '/api/have_a_drink/v1/communication/feed', method: 'GET', query: query, data: data, responseType: 'json', headers: { }, }).then((data)=>{ if (data.hasOwnProperty("fail")) { if (data.fail) { reject(data.msg); } else { reslove(data.data); } } else { reslove(data); } }).catch((err)=>reject(err)); }); } /** * 上传照片 */ UploadPhoto(req) { return new Promise((reslove, reject)=>{ let data = req; let url = `${this.host}/api/have_a_drink/v1/photo/upload/photo`; this.http_request(url, { uri: '/api/have_a_drink/v1/photo/upload/photo', method: 'POST', data: data, responseType: 'json', headers: { 'Content-Type': 'application/json', }, }).then((data)=>{ if (data.hasOwnProperty("fail")) { if (data.fail) { reject(data.msg); } else { reslove(data.data); } } else { reslove(data); } }).catch((err)=>reject(err)); }); } /** * 批量上传照片 */ UploadPhotos(req) { return new Promise((reslove, reject)=>{ let data = req; let url = `${this.host}/api/have_a_drink/v1/photo/upload/photos`; this.http_request(url, { uri: '/api/have_a_drink/v1/photo/upload/photos', method: 'POST', data: data, responseType: 'json', headers: { 'Content-Type': 'application/json', }, }).then((data)=>{ if (data.hasOwnProperty("fail")) { if (data.fail) { reject(data.msg); } else { reslove(data.data); } } else { reslove(data); } }).catch((err)=>reject(err)); }); } /** * 创建打卡记录 */ CreateRecord(req) { return new Promise((reslove, reject)=>{ let data = req; let url = `${this.host}/api/have_a_drink/v1/record/records`; this.http_request(url, { uri: '/api/have_a_drink/v1/record/records', method: 'POST', data: data, responseType: 'json', headers: { 'Content-Type': 'application/json', }, }).then((data)=>{ if (data.hasOwnProperty("fail")) { if (data.fail) { reject(data.msg); } else { reslove(data.data); } } else { reslove(data); } }).catch((err)=>reject(err)); }); } /** * 获取记录列表 */ GetRecords(req) { return new Promise((reslove, reject)=>{ let data = req; let url = `${this.host}/api/have_a_drink/v1/record/records`; const query = Object.keys(data).map((x)=>(`${x}=${data[x]}`)).join('&'); this.http_request(url, { uri: '/api/have_a_drink/v1/record/records', method: 'GET', query: query, data: data, responseType: 'json', headers: { }, }).then((data)=>{ if (data.hasOwnProperty("fail")) { if (data.fail) { reject(data.msg); } else { reslove(data.data); } } else { reslove(data); } }).catch((err)=>reject(err)); }); } /** * 获取单条记录详情 */ GetRecordDetail(req) { return new Promise((reslove, reject)=>{ let data = req; let url = `${this.host}/api/have_a_drink/v1/record/records/detail`; const query = Object.keys(data).map((x)=>(`${x}=${data[x]}`)).join('&'); this.http_request(url, { uri: '/api/have_a_drink/v1/record/records/detail', method: 'GET', query: query, data: data, responseType: 'json', headers: { }, }).then((data)=>{ if (data.hasOwnProperty("fail")) { if (data.fail) { reject(data.msg); } else { reslove(data.data); } } else { reslove(data); } }).catch((err)=>reject(err)); }); } /** * 删除记录 */ DeleteRecord(req) { return new Promise((reslove, reject)=>{ let data = req; let url = `${this.host}/api/have_a_drink/v1/record/records`; this.http_request(url, { uri: '/api/have_a_drink/v1/record/records', method: 'DELETE', data: data, responseType: 'json', headers: { 'Content-Type': 'application/json', }, }).then((data)=>{ if (data.hasOwnProperty("fail")) { if (data.fail) { reject(data.msg); } else { reslove(data.data); } } else { reslove(data); } }).catch((err)=>reject(err)); }); } /** * 获取日历打卡数据 */ GetCalendar(req) { return new Promise((reslove, reject)=>{ let data = req; let url = `${this.host}/api/have_a_drink/v1/record/records/calendar`; const query = Object.keys(data).map((x)=>(`${x}=${data[x]}`)).join('&'); this.http_request(url, { uri: '/api/have_a_drink/v1/record/records/calendar', method: 'GET', query: query, data: data, responseType: 'json', headers: { }, }).then((data)=>{ if (data.hasOwnProperty("fail")) { if (data.fail) { reject(data.msg); } else { reslove(data.data); } } else { reslove(data); } }).catch((err)=>reject(err)); }); } /** * 获取用户统计概览 */ GetStatsOverview(req) { return new Promise((reslove, reject)=>{ let data = req; let url = `${this.host}/api/have_a_drink/v1/statistics/overview`; const query = Object.keys(data).map((x)=>(`${x}=${data[x]}`)).join('&'); this.http_request(url, { uri: '/api/have_a_drink/v1/statistics/overview', method: 'GET', query: query, data: data, responseType: 'json', headers: { }, }).then((data)=>{ if (data.hasOwnProperty("fail")) { if (data.fail) { reject(data.msg); } else { reslove(data.data); } } else { reslove(data); } }).catch((err)=>reject(err)); }); } /** * 获取月度统计 */ GetMonthlyStats(req) { return new Promise((reslove, reject)=>{ let data = req; let url = `${this.host}/api/have_a_drink/v1/statistics/monthly`; const query = Object.keys(data).map((x)=>(`${x}=${data[x]}`)).join('&'); this.http_request(url, { uri: '/api/have_a_drink/v1/statistics/monthly', method: 'GET', query: query, data: data, responseType: 'json', headers: { }, }).then((data)=>{ if (data.hasOwnProperty("fail")) { if (data.fail) { reject(data.msg); } else { reslove(data.data); } } else { reslove(data); } }).catch((err)=>reject(err)); }); } /** * 获取酒类分布统计 */ GetCategoryStats(req) { return new Promise((reslove, reject)=>{ let data = req; let url = `${this.host}/api/have_a_drink/v1/statistics/categories`; const query = Object.keys(data).map((x)=>(`${x}=${data[x]}`)).join('&'); this.http_request(url, { uri: '/api/have_a_drink/v1/statistics/categories', method: 'GET', query: query, data: data, responseType: 'json', headers: { }, }).then((data)=>{ if (data.hasOwnProperty("fail")) { if (data.fail) { reject(data.msg); } else { reslove(data.data); } } else { reslove(data); } }).catch((err)=>reject(err)); }); } /** * 获取用户信息 */ GetUserProfile(req) { return new Promise((reslove, reject)=>{ let data = req; let url = `${this.host}/api/have_a_drink/v1/user/user/profile`; const query = Object.keys(data).map((x)=>(`${x}=${data[x]}`)).join('&'); this.http_request(url, { uri: '/api/have_a_drink/v1/user/user/profile', method: 'GET', query: query, data: data, responseType: 'json', headers: { }, }).then((data)=>{ if (data.hasOwnProperty("fail")) { if (data.fail) { reject(data.msg); } else { reslove(data.data); } } else { reslove(data); } }).catch((err)=>reject(err)); }); } /** * 更新用户偏好 */ UpdatePreferences(req) { return new Promise((reslove, reject)=>{ let data = req; let url = `${this.host}/api/have_a_drink/v1/user/user/preferences`; this.http_request(url, { uri: '/api/have_a_drink/v1/user/user/preferences', method: 'PUT', data: data, responseType: 'json', headers: { 'Content-Type': 'application/json', }, }).then((data)=>{ if (data.hasOwnProperty("fail")) { if (data.fail) { reject(data.msg); } else { reslove(data.data); } } else { reslove(data); } }).catch((err)=>reject(err)); }); } /** * 上传文件 */ UploadImage(req) { return new Promise((reslove, reject)=>{ let data = req; let url = `${this.host}/api/have_a_drink/v1/upload/image`; this.upload(url, { uri: '/api/have_a_drink/v1/upload/image', method: 'POST', data: data, }).then((data)=>{ if (data.hasOwnProperty("fail")) { if (data.fail) { reject(data.msg); } else { reslove(data.data); } } else { reslove(data.data); } }).catch((err)=>reject(err)); }); } /** * 动态信息流 */ GetFeeds(req) { return new Promise((reslove, reject)=>{ let data = req; let url = `${this.host}/api/have_a_drink/v1/moments/feeds`; const query = Object.keys(data).map((x)=>(`${x}=${data[x]}`)).join('&'); this.http_request(url, { uri: '/api/have_a_drink/v1/moments/feeds', method: 'GET', query: query, data: data, responseType: 'json', headers: { }, }).then((data)=>{ if (data.hasOwnProperty("fail")) { if (data.fail) { reject(data.msg); } else { reslove(data.data); } } else { reslove(data); } }).catch((err)=>reject(err)); }); } /** * 发布动态 */ PublishFeed(req) { return new Promise((reslove, reject)=>{ let data = req; let url = `${this.host}/api/have_a_drink/v1/moments/feeds`; this.http_request(url, { uri: '/api/have_a_drink/v1/moments/feeds', method: 'POST', data: data, responseType: 'json', headers: { 'Content-Type': 'application/json', }, }).then((data)=>{ if (data.hasOwnProperty("fail")) { if (data.fail) { reject(data.msg); } else { reslove(data.data); } } else { reslove(data); } }).catch((err)=>reject(err)); }); } /** * 点赞 */ LikeFeed(req) { return new Promise((reslove, reject)=>{ let data = req; let url = `${this.host}/api/have_a_drink/v1/moments/feeds/like`; this.http_request(url, { uri: '/api/have_a_drink/v1/moments/feeds/like', method: 'POST', data: data, responseType: 'json', headers: { 'Content-Type': 'application/json', }, }).then((data)=>{ if (data.hasOwnProperty("fail")) { if (data.fail) { reject(data.msg); } else { reslove(data.data); } } else { reslove(data); } }).catch((err)=>reject(err)); }); } /** * 取消点赞 */ UnlikeFeed(req) { return new Promise((reslove, reject)=>{ let data = req; let url = `${this.host}/api/have_a_drink/v1/moments/feeds/unlike`; this.http_request(url, { uri: '/api/have_a_drink/v1/moments/feeds/unlike', method: 'POST', data: data, responseType: 'json', headers: { 'Content-Type': 'application/json', }, }).then((data)=>{ if (data.hasOwnProperty("fail")) { if (data.fail) { reject(data.msg); } else { reslove(data.data); } } else { reslove(data); } }).catch((err)=>reject(err)); }); } /** * 获取评论 */ GetFeedComments(req) { return new Promise((reslove, reject)=>{ let data = req; let url = `${this.host}/api/have_a_drink/v1/moments/feeds/comments`; const query = Object.keys(data).map((x)=>(`${x}=${data[x]}`)).join('&'); this.http_request(url, { uri: '/api/have_a_drink/v1/moments/feeds/comments', method: 'GET', query: query, data: data, responseType: 'json', headers: { }, }).then((data)=>{ if (data.hasOwnProperty("fail")) { if (data.fail) { reject(data.msg); } else { reslove(data.data); } } else { reslove(data); } }).catch((err)=>reject(err)); }); } /** * 发表评论 */ AddComment(req) { return new Promise((reslove, reject)=>{ let data = req; let url = `${this.host}/api/have_a_drink/v1/moments/feeds/comments`; this.http_request(url, { uri: '/api/have_a_drink/v1/moments/feeds/comments', method: 'POST', data: data, responseType: 'json', headers: { 'Content-Type': 'application/json', }, }).then((data)=>{ if (data.hasOwnProperty("fail")) { if (data.fail) { reject(data.msg); } else { reslove(data.data); } } else { reslove(data); } }).catch((err)=>reject(err)); }); } /** * 酒友管理 */ GetFriends(req) { return new Promise((reslove, reject)=>{ let data = req; let url = `${this.host}/api/have_a_drink/v1/friends/friends`; const query = Object.keys(data).map((x)=>(`${x}=${data[x]}`)).join('&'); this.http_request(url, { uri: '/api/have_a_drink/v1/friends/friends', method: 'GET', query: query, data: data, responseType: 'json', headers: { }, }).then((data)=>{ if (data.hasOwnProperty("fail")) { if (data.fail) { reject(data.msg); } else { reslove(data.data); } } else { reslove(data); } }).catch((err)=>reject(err)); }); } /** * 好友请求管理 */ GetFriendRequests(req) { return new Promise((reslove, reject)=>{ let data = req; let url = `${this.host}/api/have_a_drink/v1/friends/friend-requests`; const query = Object.keys(data).map((x)=>(`${x}=${data[x]}`)).join('&'); this.http_request(url, { uri: '/api/have_a_drink/v1/friends/friend-requests', method: 'GET', query: query, data: data, responseType: 'json', headers: { }, }).then((data)=>{ if (data.hasOwnProperty("fail")) { if (data.fail) { reject(data.msg); } else { reslove(data.data); } } else { reslove(data); } }).catch((err)=>reject(err)); }); } /** * 发送好友请求 */ SendFriendRequest(req) { return new Promise((reslove, reject)=>{ let data = req; let url = `${this.host}/api/have_a_drink/v1/friends/friend-requests`; this.http_request(url, { uri: '/api/have_a_drink/v1/friends/friend-requests', method: 'POST', data: data, responseType: 'json', headers: { 'Content-Type': 'application/json', }, }).then((data)=>{ if (data.hasOwnProperty("fail")) { if (data.fail) { reject(data.msg); } else { reslove(data.data); } } else { reslove(data); } }).catch((err)=>reject(err)); }); } /** * 接受好友请求 */ AcceptFriendRequest(req) { return new Promise((reslove, reject)=>{ let data = req; let url = `${this.host}/api/have_a_drink/v1/friends/friend-requests/accept`; this.http_request(url, { uri: '/api/have_a_drink/v1/friends/friend-requests/accept', method: 'POST', data: data, responseType: 'json', headers: { 'Content-Type': 'application/json', }, }).then((data)=>{ if (data.hasOwnProperty("fail")) { if (data.fail) { reject(data.msg); } else { reslove(data.data); } } else { reslove(data); } }).catch((err)=>reject(err)); }); } /** * 删除酒友 */ RemoveFriend(req) { return new Promise((reslove, reject)=>{ let data = req; let url = `${this.host}/api/have_a_drink/v1/friends/friends`; this.http_request(url, { uri: '/api/have_a_drink/v1/friends/friends', method: 'DELETE', data: data, responseType: 'json', headers: { 'Content-Type': 'application/json', }, }).then((data)=>{ if (data.hasOwnProperty("fail")) { if (data.fail) { reject(data.msg); } else { reslove(data.data); } } else { reslove(data); } }).catch((err)=>reject(err)); }); } /** * 约酒活动 */ GetEvents(req) { return new Promise((reslove, reject)=>{ let data = req; let url = `${this.host}/api/have_a_drink/v1/events/events`; const query = Object.keys(data).map((x)=>(`${x}=${data[x]}`)).join('&'); this.http_request(url, { uri: '/api/have_a_drink/v1/events/events', method: 'GET', query: query, data: data, responseType: 'json', headers: { }, }).then((data)=>{ if (data.hasOwnProperty("fail")) { if (data.fail) { reject(data.msg); } else { reslove(data.data); } } else { reslove(data); } }).catch((err)=>reject(err)); }); } /** * 获取酒局详情 */ GetEventDetail(req) { return new Promise((reslove, reject)=>{ let data = req; let url = `${this.host}/api/have_a_drink/v1/events/events/detail`; const query = Object.keys(data).map((x)=>(`${x}=${data[x]}`)).join('&'); this.http_request(url, { uri: '/api/have_a_drink/v1/events/events/detail', method: 'GET', query: query, data: data, responseType: 'json', headers: { }, }).then((data)=>{ if (data.hasOwnProperty("fail")) { if (data.fail) { reject(data.msg); } else { reslove(data.data); } } else { reslove(data); } }).catch((err)=>reject(err)); }); } /** * 发起酒局 */ CreateEvent(req) { return new Promise((reslove, reject)=>{ let data = req; let url = `${this.host}/api/have_a_drink/v1/events/events`; this.http_request(url, { uri: '/api/have_a_drink/v1/events/events', method: 'POST', data: data, responseType: 'json', headers: { 'Content-Type': 'application/json', }, }).then((data)=>{ if (data.hasOwnProperty("fail")) { if (data.fail) { reject(data.msg); } else { reslove(data.data); } } else { reslove(data); } }).catch((err)=>reject(err)); }); } /** * 报名酒局 */ JoinEvent(req) { return new Promise((reslove, reject)=>{ let data = req; let url = `${this.host}/api/have_a_drink/v1/events/events/join`; this.http_request(url, { uri: '/api/have_a_drink/v1/events/events/join', method: 'POST', data: data, responseType: 'json', headers: { 'Content-Type': 'application/json', }, }).then((data)=>{ if (data.hasOwnProperty("fail")) { if (data.fail) { reject(data.msg); } else { reslove(data.data); } } else { reslove(data); } }).catch((err)=>reject(err)); }); } /** * 取消报名酒局 */ QuitEvent(req) { return new Promise((reslove, reject)=>{ let data = req; let url = `${this.host}/api/have_a_drink/v1/events/events/quit`; this.http_request(url, { uri: '/api/have_a_drink/v1/events/events/quit', method: 'POST', data: data, responseType: 'json', headers: { 'Content-Type': 'application/json', }, }).then((data)=>{ if (data.hasOwnProperty("fail")) { if (data.fail) { reject(data.msg); } else { reslove(data.data); } } else { reslove(data); } }).catch((err)=>reject(err)); }); } /** * 签到酒局 */ CheckInEvent(req) { return new Promise((reslove, reject)=>{ let data = req; let url = `${this.host}/api/have_a_drink/v1/events/events/checkin`; this.http_request(url, { uri: '/api/have_a_drink/v1/events/events/checkin', method: 'POST', data: data, responseType: 'json', headers: { 'Content-Type': 'application/json', }, }).then((data)=>{ if (data.hasOwnProperty("fail")) { if (data.fail) { reject(data.msg); } else { reslove(data.data); } } else { reslove(data); } }).catch((err)=>reject(err)); }); } /** * 获取会话列表 */ GetConversations(req) { return new Promise((reslove, reject)=>{ let data = req; let url = `${this.host}/api/have_a_drink/v1/chat/conversations`; const query = Object.keys(data).map((x)=>(`${x}=${data[x]}`)).join('&'); this.http_request(url, { uri: '/api/have_a_drink/v1/chat/conversations', method: 'GET', query: query, data: data, responseType: 'json', headers: { }, }).then((data)=>{ if (data.hasOwnProperty("fail")) { if (data.fail) { reject(data.msg); } else { reslove(data.data); } } else { reslove(data); } }).catch((err)=>reject(err)); }); } /** * 获取历史消息 */ GetMessages(req) { return new Promise((reslove, reject)=>{ let data = req; let url = `${this.host}/api/have_a_drink/v1/chat/messages`; const query = Object.keys(data).map((x)=>(`${x}=${data[x]}`)).join('&'); this.http_request(url, { uri: '/api/have_a_drink/v1/chat/messages', method: 'GET', query: query, data: data, responseType: 'json', headers: { }, }).then((data)=>{ if (data.hasOwnProperty("fail")) { if (data.fail) { reject(data.msg); } else { reslove(data.data); } } else { reslove(data); } }).catch((err)=>reject(err)); }); } /** * 标记会话已读 */ MarkRead(req) { return new Promise((reslove, reject)=>{ let data = req; let url = `${this.host}/api/have_a_drink/v1/chat/conversations/read`; this.http_request(url, { uri: '/api/have_a_drink/v1/chat/conversations/read', method: 'POST', data: data, responseType: 'json', headers: { 'Content-Type': 'application/json', }, }).then((data)=>{ if (data.hasOwnProperty("fail")) { if (data.fail) { reject(data.msg); } else { reslove(data.data); } } else { reslove(data); } }).catch((err)=>reject(err)); }); } /** * 获取未读消息总数 */ GetUnreadCount(req) { return new Promise((reslove, reject)=>{ let data = req; let url = `${this.host}/api/have_a_drink/v1/chat/unread-count`; const query = Object.keys(data).map((x)=>(`${x}=${data[x]}`)).join('&'); this.http_request(url, { uri: '/api/have_a_drink/v1/chat/unread-count', method: 'GET', query: query, data: data, responseType: 'json', headers: { }, }).then((data)=>{ if (data.hasOwnProperty("fail")) { if (data.fail) { reject(data.msg); } else { reslove(data.data); } } else { reslove(data); } }).catch((err)=>reject(err)); }); } /** * 注意:连接建立后,服务端会先验证 token,然后推送 connected 事件 */ ChatWebSocket() { const url = new URL(this.host); return new ChatWebSocketConn(url.host); } }