浏览代码

单查更变为openid

lrf 2 年之前
父节点
当前提交
3f80f41b90
共有 5 个文件被更改,包括 14 次插入34 次删除
  1. 3 31
      README.md
  2. 1 1
      app/controller/config/.user.js
  3. 1 1
      app/model/user.js
  4. 8 0
      app/service/user.js
  5. 1 1
      app/z_router/user.js

+ 3 - 31
README.md

@@ -1,33 +1,5 @@
-# server-user
+# server-new
 
-服务-用户管理
+## 与用户有关联的全用 openid进行查询
 
-## QuickStart
-
-<!-- add docs here for user -->
-
-see [egg docs][egg] for more detail.
-
-### Development
-
-```bash
-$ npm i
-$ npm run dev
-$ open http://localhost:7001/
-```
-
-### Deploy
-
-```bash
-$ npm start
-$ npm stop
-```
-
-### npm scripts
-
-- Use `npm run lint` to check code style.
-- Use `npm test` to run unit test.
-- Use `npm run autod` to auto detect dependencies upgrade, see [autod](https://www.npmjs.com/package/autod) for more detail.
-
-
-[egg]: https://eggjs.org
+## 数据修改仍然用数据id:_id

+ 1 - 1
app/controller/config/.user.js

@@ -12,7 +12,7 @@ module.exports = {
   },
   show: {
     parameters: {
-      params: ['!id'],
+      params: ['!openid'],
     },
     service: 'fetch',
   },

+ 1 - 1
app/model/user.js

@@ -12,7 +12,7 @@ const user = {
   gender: { type: String, required: false, zh: '性别' }, // 性别
   phone: { type: String, required: false, zh: '手机号' }, // 手机号
   email: { type: String, required: false, zh: '邮箱' }, // 邮箱
-  type: { type: String, required: false, default: '0', zh: '用户类别。0:普通用户,1:裁判用户' }, // 用户类别。0:普通用户,1:裁判用户
+  type: { type: String, required: false, default: '0', zh: '用户类别' }, // 用户类别。0:普通用户,1:裁判用户; -1:管理员
   icon: { type: Array, required: false, zh: '用户头像' }, // 用户头像
 };
 const schema = new Schema(user, { toJSON: { virtuals: true } });

+ 8 - 0
app/service/user.js

@@ -9,6 +9,14 @@ class UserService extends CrudService {
     this.model = this.ctx.model.User;
   }
 
+  async fetch({ openid }) {
+    const res = await this.model.findOne({ openid });
+    return res;
+  }
+
+  /**
+   * 检查数据重复
+   */
   async createCheck() {
     const data = this.ctx.request.body;
     const { card, phone, openid } = data;

+ 1 - 1
app/z_router/user.js

@@ -7,7 +7,7 @@ const keyZh = '用户';
 const routes = [
   { method: 'post', path: `${rkey}/wxAppLogin`, controller: `${ckey}.wxAppLogin`, name: `${ckey}WxAppLogin`, zh: `${keyZh}-小程序登录` },
   { method: 'get', path: `${rkey}`, controller: `${ckey}.index`, name: `${ckey}Query`, zh: `${keyZh}列表查询` },
-  { method: 'get', path: `${rkey}/:id`, controller: `${ckey}.show`, name: `${ckey}Show`, zh: `${keyZh}查询` },
+  { method: 'get', path: `${rkey}/:openid`, controller: `${ckey}.show`, name: `${ckey}Show`, zh: `${keyZh}查询` },
   { method: 'post', path: `${rkey}`, controller: `${ckey}.create`, middleware: [ 'password', 'userCreateCheck' ], name: `${ckey}Create`, zh: `创建${keyZh}` },
   { method: 'post', path: `${rkey}/:id`, controller: `${ckey}.update`, name: `${ckey}Update`, zh: `修改${keyZh}` },
   { method: 'delete', path: `${rkey}/:id`, controller: `${ckey}.destroy`, name: `${ckey}Delete`, zh: `删除${keyZh}` },