cheny 5 년 전
부모
커밋
95595dcf6d
7개의 변경된 파일34개의 추가작업 그리고 8개의 파일을 삭제
  1. 14 0
      app/controller/.transaction.js
  2. 4 0
      app/controller/buff.js
  3. 4 1
      app/controller/transaction.js
  4. 3 1
      app/router.js
  5. 5 2
      app/service/transaction.js
  6. 2 2
      config/config.default.js
  7. 2 2
      config/config.local.js

+ 14 - 0
app/controller/.transaction.js

@@ -64,4 +64,18 @@ module.exports = {
       count: true,
     },
   },
+  findTransactionList:{
+    parameters: {
+      query: {
+        product_id: "product_id",
+      },
+    },
+    service: "query",
+    options: {
+      query: ["skip", "limit"],
+      sort: ["meta.createdAt"],
+      desc: true,
+      count: true,
+    },
+  },
 };

+ 4 - 0
app/controller/buff.js

@@ -16,6 +16,10 @@ class BuffController extends Controller {
     const res = await this.service.userlist(this.ctx.query);
     this.ctx.ok({ ...res });
   }
+  async userCodeList() {
+    const res = await this.service.userlist(this.ctx.query);
+    this.ctx.ok({ ...res });
+  }
 
 }
 

+ 4 - 1
app/controller/transaction.js

@@ -13,7 +13,10 @@ class TransactionController extends Controller {
     this.service = this.ctx.service.transaction;
   }
 
-
+  async findTransactionList() {
+    const res = await this.service.findTransactionList(this.ctx.request.body);
+    this.ctx.ok({ ...res });
+  }
 }
 
 module.exports = CrudController(TransactionController, meta);

+ 3 - 1
app/router.js

@@ -7,7 +7,8 @@ module.exports = app => {
   const { router, controller } = app;
   router.get('/', controller.home.index);
 
-  router.get('/api/market/user/hwsxg', controller.buff.userlist);
+  // router.get('/api/market/user/hwsxg', controller.buff.userlist);
+  router.get('/api/market/user/hwsxg', controller.buff.userCodeList);
   // 科技超市用户表设置路由
   router.post('user', '/api/market/user/uppasswd', controller.user.uppasswd);
   router.resources('user', '/api/market/user', controller.user); // index、create、show、destroy
@@ -40,6 +41,7 @@ module.exports = app => {
   // 交易记录表设置路由
   router.resources('transaction', '/api/market/transaction', controller.transaction); // index、create、show、destroy
   router.post('transaction', '/api/market/transaction/update/:id', controller.transaction.update);
+  router.post('transaction', '/api/market/transaction/findTransactionList', controller.transaction.findTransactionList); // index、create、show、destroy
 
   // 交易审核表设置路由
   router.resources('tranaudit', '/api/market/tranaudit', controller.tranaudit); // index、create、show、destroy

+ 5 - 2
app/service/transaction.js

@@ -17,7 +17,7 @@ class TransactionService extends CrudService {
 
   async create(data) {
     const { userid, product_id, market_userid, description, status, username, product_name, market_username } = data;
-    if(!username){
+    if (!username) {
       const user = await this.umodel.findById(userid);
       username = user.name;
     }
@@ -32,7 +32,10 @@ class TransactionService extends CrudService {
     const newdata = { ...data, username, product_name, market_username };
     return await this.model.create(newdata);
   }
-
+  async findTransactionList({ product_id }) {
+    const product = await this.model.find({ product_id });
+    return product;
+  }
 }
 
 module.exports = TransactionService;

+ 2 - 2
config/config.default.js

@@ -40,8 +40,8 @@ module.exports = appInfo => {
   config.mongoose = {
     url: 'mongodb://localhost:27017/platform',
     options: {
-      user: 'admin',
-      pass: 'admin',
+      user: 'platform',
+      pass: 'platform2020',
       authSource: 'admin',
       useNewUrlParser: true,
       useCreateIndex: true,

+ 2 - 2
config/config.local.js

@@ -11,8 +11,8 @@ module.exports = () => {
   config.mongoose = {
     url: 'mongodb://localhost:27017/platform',
     options: {
-      user: 'demo',
-      pass: 'demo',
+      user: 'platform',
+      pass: 'platform2020',
       authSource: 'admin',
       useNewUrlParser: true,
       useCreateIndex: true,