Browse Source

增加查询

liuyu 5 năm trước cách đây
mục cha
commit
9652fce6fb
3 tập tin đã thay đổi với 10 bổ sung0 xóa
  1. 4 0
      app/controller/productpact.js
  2. 1 0
      app/router.js
  3. 5 0
      app/service/productpact.js

+ 4 - 0
app/controller/productpact.js

@@ -13,6 +13,10 @@ class ProductpactController extends Controller {
     this.service = this.ctx.service.productpact;
   }
 
+  async findpact() {
+    const data = await this.service.findpact(this.ctx.params);
+    this.ctx.ok({ data });
+  }
 
 }
 

+ 1 - 0
app/router.js

@@ -43,6 +43,7 @@ module.exports = app => {
   router.post('tranaudit', '/api/market/tranaudit/update/:id', controller.tranaudit.update);
 
   // 合同记录表设置路由
+  router.get('/api/market/productpact/findpact/:id', controller.productpact.findpact);
   router.resources('productpact', '/api/market/productpact', controller.productpact); // index、create、show、destroy
   router.post('productpact', '/api/market/productpact/update/:id', controller.productpact.update);
 

+ 5 - 0
app/service/productpact.js

@@ -13,6 +13,11 @@ class ProductpactService extends CrudService {
     this.model = this.ctx.model.Productpact;
   }
 
+  async findpact({ id }) {
+    const res = await this.model.findOne({ transaction_id: id });
+    return res;
+  }
+
 }
 
 module.exports = ProductpactService;