import {ApiCall} from "tsrpc";
import {ReqUpdateHbzbCrossUser, ResUpdateHbzbCrossUser} from "../../cross/protocols/hbzb/PtlUpdateHbzbCrossUser";

/**更新跨服数据库里，黑帮争霸的玩家数据 */
export default async function (call: ApiCall<ReqUpdateHbzbCrossUser, ResUpdateHbzbCrossUser>) {
    let setData: any = {
        "data": {
            player: call.req.user.player,
            roles: call.req.user.roles,
            uid: call.req.uid
        },
    };
    if (call.req.isNew) {
        setData = {
            ...setData,
            "jifen": -999999,
            "rank": -999999,
            "zbsgroup": ""
        }
    }
    G.mongodb.collection('hbzb_user_cross').updateOne({uid: setData.data.uid}, {$set: setData}, {upsert: true});
    call.succ({});
}