cshenfu
2024-05-21 09d8c671d5e6e6045677bfb5218a5fb78c26aa0f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
module.exports = {
    /**
     * 查询用户列表(可登录后台的)
     * @url admin/system/user/sys/getList 前端调用的url参数地址
     * data 请求参数 说明
     * @param {Number}         pageIndex 当前页码
     * @param {Number}         pageSize  每页显示数量
     * @param {Array<Object>}  sortRule  排序规则
     * @param {object}         formData  查询条件数据源
     * @param {Array<Object>}  columns   查询条件规则
     * res 返回参数说明
     * @param {Number}         code      错误码,0表示成功
     * @param {String}         msg       详细信息
     */
    main: async (event) => {
        let { data = {}, userInfo, util, filterResponse, originalParam } = event;
        let { customUtil, uniID, config, pubFun, vk, db, _ } = util;
        let { uid } = data;
        let res = { code: 0, msg: '' };
        // 业务逻辑开始-----------------------------------------------------------
        let { dcloud_appid, appids } = data.formData || {};
        let whereJson = {
            role:'teacher'
        };
        if (dcloud_appid) {
            if (dcloud_appid === "___empty-array___") {
                whereJson["dcloud_appid"] = [];
            } else if (dcloud_appid === "___error___") {
                whereJson["dcloud_appid"] = _.and(_.exists(true), _.nin(appids));
            } else if (dcloud_appid === "___non-existent___") {
                whereJson["dcloud_appid"] = _.exists(false);
            } else {
                whereJson["dcloud_appid"] = _.or(_.eq(dcloud_appid), _.exists(false));
            }
        }
        let dbName = "uni-id-users";
        res = await vk.baseDao.getTableData({
            dbName,
            data,
            whereJson,
            sortArr: [{ "name": "register_date", "type": "desc" }],
            // 副表列表
            foreignDB: [{
                dbName: "opendb-app-list",
                localKey: "dcloud_appid",
                foreignKey: "appid",
                localKeyType: "array",
                as: "appList",
                limit: 500
            }],
        });
        // 业务逻辑结束-----------------------------------------------------------
        return res;
    }
 
}