import { ApiCall } from "tsrpc";
import { ReqApplyAll, ResApplyAll } from "../../shared/protocols/gonghui/PtlApplyAll";

export default async function (call: ApiCall<ReqApplyAll, ResApplyAll>) {
    let GHdata = await call.conn.gonghui
    if (call.conn.gud.ghLevel == 3) return call.error(globalThis.lng.gonghui_1);
    if (GHdata.data.applyList.length < 1) return call.error(globalThis.lng.gonghui_3);

    if (call.req) {
        GHdata.apply(...GHdata.data.applyList.map(a => a.uid));
    } else {
        GHdata.data.applyList = [];
        GHdata.updateDb({ $set: { applyList: [] } });
    }

    call.succ({});
}