import { Application, BackendSession } from "pinus"; import { resResult, getRandEelm } from "../../../pubUtils/util"; import { STATUS, ROLE } from "../../../consts"; import { RoleModel } from "../../../db/Role"; import { getBeforeDaySeconds } from "../../../pubUtils/timeUtil"; export default function (app: Application) { return new FriendHandler(app); } export class FriendHandler { constructor(private app: Application) { } // 获取推荐好友列表 public async getRecommend(msg: { }, session: BackendSession) { let roleId: string = session.get('roleId'); const day = getBeforeDaySeconds(1); const { lv } = await RoleModel.findByRoleId(roleId, ROLE.GET_LV); const allList = await RoleModel.getRecommedList(lv - 5, lv + 5, day); let list = getRandEelm(allList, 10); if(!list.length) list = allList; return resResult(STATUS.SUCCESS, { list }); } }