import { ApiCall } from "tsrpc";
import { ReqOpen, ResOpen } from "../../../shared/protocols/event/yibaichou/PtlOpen";
import { PublicShared } from "../../../shared/public/public";

export default async function (call: ApiCall<ReqOpen, ResOpen>) {

    let [isOpen, tips] = PublicShared.getOpenCond(call, "yibaichou")
    if (!isOpen) return call.error('', { code: -1, message: tips });

    let db = await G.mongodb.cEvent('yibaichou').findOne({ uid: call.uid, type: 'yibaichou' });

    call.succ({
        loginRec: db?.loginRec || [],
        onlineRec: db?.onlineRec || []
    });
}