import { ApiCall } from "tsrpc";
import { ReqApplyList, ResApplyList } from "../../shared/protocols/gonghui/PtlApplyList";

export default async function (call: ApiCall<ReqApplyList, ResApplyList>) {
    let GHdata = await call.conn.gonghui

    if (GHdata.data.applyList?.length > 0) {
        let uids = GHdata.data.applyList.map((i)=>i.uid);
        let players = (await G.mongodb.find('user',{uid:{$in: uids}})) as any;

        call.succ(players.map((p, i) => {
            return {
                player: p,
                time: GHdata.data.applyList[i].time
            };
        }));
    } else {
        call.succ([]);
    }
}