浏览代码

管理表添加狀態字段

guhongwei 3 年之前
父节点
当前提交
5373b2ebc7
共有 2 个文件被更改,包括 29 次插入19 次删除
  1. 28 19
      app/controller/config/.admin.js
  2. 1 0
      app/model/admin.js

+ 28 - 19
app/controller/config/.admin.js

@@ -1,48 +1,57 @@
 module.exports = {
 module.exports = {
   create: {
   create: {
-    requestBody: ['name', 'phone', 'password', 'card', 'email', 'addr'],
+    requestBody: [
+      "name",
+      "phone",
+      "password",
+      "card",
+      "email",
+      "addr",
+      "status",
+    ],
   },
   },
   destroy: {
   destroy: {
-    params: ['!id'],
-    service: 'delete',
+    params: ["!id"],
+    service: "delete",
   },
   },
   update: {
   update: {
-    params: ['!id'],
-    requestBody: ['name', 'phone', 'card', 'email', 'addr'],
+    params: ["!id"],
+    requestBody: ["name", "phone", "card", "email", "addr", "status"],
   },
   },
   show: {
   show: {
     parameters: {
     parameters: {
-      params: ['!id'],
+      params: ["!id"],
     },
     },
-    service: 'fetch',
+    service: "fetch",
   },
   },
   index: {
   index: {
     parameters: {
     parameters: {
       query: {
       query: {
-        phone: 'phone',
-        name: 'name',
-        card: 'card',
-        addr: '%addr%',
-        'meta.createdAt@start': 'meta.createdAt@start',
-        'meta.createdAt@end': 'meta.createdAt@end',
+        phone: "phone",
+        name: "name",
+        card: "card",
+        addr: "%addr%",
+        status:'status',
+        "meta.createdAt@start": "meta.createdAt@start",
+        "meta.createdAt@end": "meta.createdAt@end",
       },
       },
       // options: {
       // options: {
       //   "meta.state": 0 // 默认条件
       //   "meta.state": 0 // 默认条件
       // },
       // },
     },
     },
-    service: 'query',
+    service: "query",
     options: {
     options: {
-      query: ['skip', 'limit'],
-      sort: ['meta.createdAt'],
+      query: ["skip", "limit"],
+      sort: ["meta.createdAt"],
       desc: true,
       desc: true,
       count: true,
       count: true,
     },
     },
   },
   },
   login: {
   login: {
-    requestBody: ['!phone', '!password'],
+    requestBody: ["!phone", "!password"],
   },
   },
   updatePwd: {
   updatePwd: {
-    params: ['!id'],
-    requestBody: ['!password'],
+    params: ["!id"],
+    requestBody: ["!password"],
   },
   },
 };
 };

+ 1 - 0
app/model/admin.js

@@ -10,6 +10,7 @@ const admin = {
   card: { type: String, required: false, maxLength: 200 }, // 身份证号
   card: { type: String, required: false, maxLength: 200 }, // 身份证号
   email: { type: String, required: false, maxLength: 200 }, // 邮箱
   email: { type: String, required: false, maxLength: 200 }, // 邮箱
   addr: { type: String, required: false, maxLength: 500 }, // 地址
   addr: { type: String, required: false, maxLength: 500 }, // 地址
+  status: { type: String, required: false, default: '0' }, // 状态
   remark: { type: String, maxLength: 200 },
   remark: { type: String, maxLength: 200 },
 };
 };
 const schema = new Schema(admin, { toJSON: { virtuals: true } });
 const schema = new Schema(admin, { toJSON: { virtuals: true } });