diff --git a/alpha/admin/uniCloud-aliyun/cloudfunctions/fe-my/fe-my.param.js b/alpha/admin/uniCloud-aliyun/cloudfunctions/fe-my/fe-my.param.js new file mode 100644 index 0000000000000000000000000000000000000000..0e3ba9e03f04887d7a2284c10c1318ddf0a7915a --- /dev/null +++ b/alpha/admin/uniCloud-aliyun/cloudfunctions/fe-my/fe-my.param.js @@ -0,0 +1,8 @@ +const clientInfo = { // 模拟clientInfo + uniPlatform: 'web', + source: 'client', // 调用来源,不传时默认为 client + // 客户端ip,不传时默认为 127.0.0.1 + userAgent: 'xx MicroMessenger/xxx', // 客户端ua,不传时默认为 HBuilderX + uniIdToken: 'xxx' +} +information('645cd81228064a7587bd2abb') // 调用login方法传入参数'name-demo'和'password-demo' \ No newline at end of file diff --git a/alpha/admin/uniCloud-aliyun/cloudfunctions/fe-my/index.obj.js b/alpha/admin/uniCloud-aliyun/cloudfunctions/fe-my/index.obj.js new file mode 100644 index 0000000000000000000000000000000000000000..98949b2fd5c47a869b87c0b7cee8a04b483267de --- /dev/null +++ b/alpha/admin/uniCloud-aliyun/cloudfunctions/fe-my/index.obj.js @@ -0,0 +1,65 @@ +// 云对象教程: https://uniapp.dcloud.net.cn/uniCloud/cloud-obj +// jsdoc语法提示教程:https://ask.dcloud.net.cn/docs/#//ask.dcloud.net.cn/article/129 +module.exports = { + _before: function () { // 通用预处理器 + + }, + /** + * method1方法描述 + * @param {string} param1 参数1描述 + * @returns {object} 返回值描述 + */ + /* + method1(param1) { + // 参数校验,如无参数则不需要 + if (!param1) { + return { + errCode: 'PARAM_IS_NULL', + errMsg: '参数不能为空' + } + } + // 业务逻辑 + + // 返回结果 + return { + param1 //请根据实际需要返回值 + } + } + */ + information(userId){ + const db = uniCloud.database(); + const user_table = db.collection('mustgo-user') + const team_table = db.collection('mustgo-team') + let res = await user_table.where({ + _id:userId + }).get() + var team = "" + if (res.affectedDocs == 1) { + var team_id = res.data[0]["team_id"] + if(team_id != null){ + let res2 = await team_table.where({ + _id: res.data[0]["team_id"] + }).get() + if(res2.affectedDocs == 1){ + team = res2.data[0]["name"] + } + } + + return { + code: 200, + message: "成功返回用户信息", + data: { + "icon": res.data[0]["icon"], + "username": res.data[0]["name"], + "school": res.data[0]["school"], + "team": team + } + } + } + return { + "code": 400, + "message": "返回用户信息失败", + "data": {} + } + }, +} diff --git a/alpha/admin/uniCloud-aliyun/cloudfunctions/fe-my/package.json b/alpha/admin/uniCloud-aliyun/cloudfunctions/fe-my/package.json new file mode 100644 index 0000000000000000000000000000000000000000..db236cebe96280db4591ecf498d30704f0b057ef --- /dev/null +++ b/alpha/admin/uniCloud-aliyun/cloudfunctions/fe-my/package.json @@ -0,0 +1,7 @@ +{ + "name": "fe-my", + "dependencies": {}, + "extensions": { + "uni-cloud-jql": {} + } +} \ No newline at end of file