Browse Source

增加字段

asd123a20 3 years ago
parent
commit
555d9d2dd4
2 changed files with 8 additions and 6 deletions
  1. 2 0
      service-market/app/model/market.js
  2. 6 6
      service-market/app/service/market.js

+ 2 - 0
service-market/app/model/market.js

@@ -11,6 +11,8 @@ const SchemaDefine = {
   status: { type: String, required: true },
   // 价格
   money: { type: Number, required: true },
+  // 积分
+  integral: { type: Number, required: true },
 };
 const schema = new Schema(SchemaDefine);
 module.exports = app => {

+ 6 - 6
service-market/app/service/market.js

@@ -7,23 +7,23 @@ class MarketService extends Service {
     super(ctx);
     this.model = this.ctx.model.Market;
   }
-  async create({ name, type, bindId, status, money }) {
+  async create({ name, type, bindId, status, money, integral }) {
     assert(name, '商品名称不存在');
     assert(type, '商品类型不存在');
     assert(bindId, '货品ID不存在');
     assert(status, '商品状态不存在');
     assert(money, '价格不存在');
     try {
-      const res = await this.model.create({ name, type, bindId, status, money });
+      const res = await this.model.create({ name, type, bindId, status, money, integral });
       return { errcode: 0, errmsg: 'ok', data: res };
     } catch (error) {
       throw error;
     }
   }
-  async update({ id, name, type, bindId, status, money }) {
+  async update({ id, name, type, bindId, status, money, integral }) {
     assert(id, 'id不存在');
     try {
-      await this.model.updateOne({ _id: id }, { name, type, bindId, status, money });
+      await this.model.updateOne({ _id: id }, { name, type, bindId, status, money, integral });
       return { errcode: 0, errmsg: 'ok', data: '' };
     } catch (error) {
       throw error;
@@ -38,9 +38,9 @@ class MarketService extends Service {
       throw error;
     }
   }
-  async query({ skip, limit, name, type, bindId, status, money }) {
+  async query({ skip, limit, name, type, bindId, status, money, integral }) {
     const filter = {};
-    const arr = { name, type, bindId, status, money };
+    const arr = { name, type, bindId, status, money, integral };
     for (const e in arr) {
       const data = `{ "${e}": { "$regex": "${arr[e]}" } }`;
       if (arr[e]) {