Przeglądaj źródła

办卡/登陆 表

lrf402788946 4 lat temu
rodzic
commit
ea2b65b1c7
5 zmienionych plików z 76 dodań i 14 usunięć
  1. 37 0
      app/controller/.card.js
  2. 13 0
      app/controller/card.js
  3. 13 13
      app/model/card.js
  4. 12 0
      app/service/card.js
  5. 1 1
      config/config.default.js

+ 37 - 0
app/controller/.card.js

@@ -0,0 +1,37 @@
+module.exports = {
+  create: {
+    requestBody: []
+  },
+  destory: {
+    params: ["id"],
+    service: "delete"
+  },
+  update: {
+    params: ["id"],
+    requestBody:[]
+  },
+  show: {
+    parameters: {
+      params: ["id"]
+    },
+    service: "fetch"
+  },
+  index: {
+    parameters: {
+      query: {
+        "create_time@start": "create_time@start",
+        "create_time@end": "create_time@end",
+      },
+      options: {
+        "meta.status": 0 // 默认条件
+      },
+    },
+   service: "query",
+   options: {
+     query: ["skip", "limit"],
+     sort: ["meta.createdAt"],
+     desc: true,
+     count: true,
+   },
+  },
+}

+ 13 - 0
app/controller/card.js

@@ -0,0 +1,13 @@
+'use strict';
+const meta = require('./.card.js');
+const Controller = require('egg').Controller;
+const { CrudController } = require('naf-framework-mongoose/lib/controller');
+
+// card
+class CardController extends Controller {
+  constructor(ctx) {
+    super(ctx);
+    this.service = this.ctx.service.card;
+  }
+}
+module.exports = CrudController(CardController, meta);

+ 13 - 13
app/model/card.js

@@ -13,22 +13,22 @@ const zf = new Schema({
 
 //  办卡表
 const card = {
-  mobile: { type: String, required: true, maxLength: 11, unique: true }, //
-  password: { type: Secret, required: true, select: false }, //
-  province: { type: String, required: true }, //
-  set: { type: String, required: true }, // 169/129
-  pay_type: { type: String }, //
-  name: { type: String, required: true }, //
-  id_card: { type: String, required: true }, //
-  level: { type: String, required: true }, //
-  points: { type: String, required: true }, //
-  recommend: { type: String, required: true }, //
-  r_mobile: { type: String, required: true }, //
-  zf: { type: zf },
+  mobile: { type: String, required: true, maxLength: 11, unique: true }, // 电话
+  password: { type: Secret, required: true, select: false }, // 密码
+  province: { type: String, required: true }, // 省份
+  set: { type: String, required: true }, // 169/129 套餐
+  pay_type: { type: String }, // 支付方式
+  name: { type: String, required: true }, // 姓名
+  id_card: { type: String, required: true }, // 身份证
+  level: { type: String, required: true }, // 等级
+  points: { type: String, required: true }, // 积分
+  recommend: { type: String, required: true }, // 推荐人
+  r_mobile: { type: String, required: true }, // 推荐人电话
+  zf: { type: zf }, // 支付设置
   create_time: {
     type: String,
     default: moment().format('YYYY-MM-DD HH:mm:ss'),
-  }, // chuangjian/banka
+  }, // 创建/办卡 时间
 };
 const schema = new Schema(card, { toJSON: { virtuals: true } });
 schema.index({ id: 1 });

+ 12 - 0
app/service/card.js

@@ -0,0 +1,12 @@
+'use strict';
+const { CrudService } = require('naf-framework-mongoose/lib/service');
+
+class CardService extends CrudService {
+  constructor(ctx) {
+    super(ctx, 'card');
+    this.model = this.ctx.model.Card;
+  }
+
+}
+
+module.exports = CardService;

+ 1 - 1
config/config.default.js

@@ -18,7 +18,7 @@ module.exports = appInfo => {
     },
   };
   config.mongoose = {
-    url: "mongodb://localhost:27017/htyd",
+    url: 'mongodb://localhost:27017/htyd',
     options: {
       // user: 'admin',
       // pass: 'admin',