import { ApiCall } from "tsrpc";
import { RedisCollections2 } from '../../module/redis';
import { ReqGetList, ResGetList } from "../../shared/protocols/shiwu/PtlGetList";

export default async function (call: ApiCall<ReqGetList, ResGetList>) {
    let list: ResGetList['list'] = {};
    // let kvList: k_v<RedisCollections2['shiwu']> = {};
    let arrList = await G.mongodb.collection('shiwu').find({ uid: call.uid }).toArray();

    arrList.forEach(v => {
        let d = G.mongodb.conversionIdObj(v);
        // kvList[G.formatRedisKey(d._id)] = d;
        list[d._id] = d;
    });

    call.succ({
        list: list
    });
}