module.exports = { /** * 修改数据 * @url admin/kong/sys/update 前端调用的url参数地址 * data 请求参数 说明 * 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: 'ok' }; // 业务逻辑开始----------------------------------------------------------- let { _id, title, thumb, dynamicTags, free_roles, charge, charge_original, common_problem, short_description, render_desc, published_at, is_show, is_rec, comment_status, category_ids, center_info, before_exam, validity_period, teacher_ids } = data; // 这里需要把 params1 params2 params3 改成你数据库里允许用户添加的字段 if (vk.pubfn.isNullOne(_id)) { return { code: -1, msg: '参数错误' }; } let category_id = null let category_parent_id = null if (category_ids.length == 2) { category_id = category_ids[1] category_parent_id = category_ids[0] } else { category_id = category_ids[0] category_parent_id = category_ids[0] } let dbName = "live_course"; await vk.baseDao.updateById({ dbName, id: _id, dataJson: { title, thumb, dynamicTags, free_roles, charge, charge_original, common_problem, short_description, render_desc, published_at, is_show, is_rec, comment_status, category_id, category_parent_id, center_info, before_exam, teacher_ids, validity_period } }); // 业务逻辑结束----------------------------------------------------------- return res; } }