cheny 5 năm trước cách đây
mục cha
commit
cf1c0d2f07

+ 55 - 0
app/controller/.operationlog.js

@@ -0,0 +1,55 @@
+module.exports = {
+  create: {
+    requestBody: [
+      "dock_id",
+      "login_role",
+      "login_name",
+      "operation_edit",
+      "operation_result",
+      "type",
+      "remark",
+    ],
+  },
+  destroy: {
+    params: ["!id"],
+    service: "delete",
+  },
+  update: {
+    params: ["!id"],
+    requestBody: [
+      "dock_id",
+      "login_role",
+      "login_name",
+      "operation_edit",
+      "operation_result",
+      "type",
+      "remark",
+    ],
+  },
+  show: {
+    parameters: {
+      params: ["!id"],
+    },
+    service: "fetch",
+  },
+  index: {
+    parameters: {
+      query: [
+      "dock_id",
+      "login_role",
+      "login_name",
+      "operation_edit",
+      "operation_result",
+      "type",
+      "remark",
+      ],
+    },
+    service: "query",
+    options: {
+      query: ["skip", "limit"],
+      sort: ["meta.createdAt"],
+      desc: true,
+      count: true,
+    },
+  },
+};

+ 17 - 0
app/controller/operationlog.js

@@ -0,0 +1,17 @@
+'use strict';
+
+const _ = require('lodash');
+const meta = require('./.operationlog.js');
+const Controller = require('egg').Controller;
+const { CrudController } = require('naf-framework-mongoose/lib/controller');
+
+// 交易记录表管理
+class OperationlogController extends Controller {
+
+  constructor(ctx) {
+    super(ctx);
+    this.service = this.ctx.service.operationlog;
+  }
+}
+
+module.exports = CrudController(OperationlogController, meta);

+ 22 - 0
app/model/operationlog.js

@@ -0,0 +1,22 @@
+'use strict';
+const Schema = require('mongoose').Schema;
+const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
+
+// 交易记录表
+const OperationlogSchema = {
+  // login_id: { type: String, required: false, maxLength: 100 }, // 登陆者id
+  login_role: { type: String, required: false, maxLength: 5 }, // 登陆者角色(如:展会申请用户)
+  login_name: { type: String, required: false, maxLength: 20 }, // 登陆者名字
+  operation_edit: { type: String, required: false, maxLength: 50 }, // 操作者动作
+  operation_result: { type: String, required: false, maxLength: 5 }, // 0成功 1失败
+  type: { type: String, required: false, maxLength: 5, default: '0' }, // 0登录者信息、1操作信息、2.。。
+  remark: { type: String, required: false, maxLength: 500 }, // 说明
+};
+const schema = new Schema(OperationlogSchema, { toJSON: { virtuals: true } });
+schema.index({ id: 1 });
+schema.plugin(metaPlugin);
+
+module.exports = app => {
+  const { mongoose } = app;
+  return mongoose.model('Operationlog', schema, 'operation_log');
+};

+ 3 - 0
app/router.js

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

+ 17 - 0
app/service/operationlog.js

@@ -0,0 +1,17 @@
+'use strict';
+
+// const assert = require('assert');
+// const { ObjectId } = require('mongoose').Types;
+const { CrudService } = require('naf-framework-mongoose/lib/service');
+// const { BusinessError } = require('naf-core').Error;
+// const moment = require('moment');
+
+class OperationlogService extends CrudService {
+  constructor(ctx) {
+    super(ctx, 'operationlog');
+    this.model = this.ctx.model.Operationlog;
+  }
+
+}
+
+module.exports = OperationlogService;

+ 3 - 0
app/service/transaction.js

@@ -13,6 +13,7 @@ class TransactionService extends CrudService {
     this.model = this.ctx.model.Transaction;
     this.umodel = this.ctx.model.User;
     this.pmodel = this.ctx.model.Product;
+    this.omodel = this.ctx.model.Operationlog;
   }
 
   async create(data) {
@@ -30,6 +31,8 @@ class TransactionService extends CrudService {
       market_username = market_user.name;
     }
     const newdata = { ...data, username, product_name, market_username };
+    const operationlogdata = { dock_id: data.dockid, type: '1' };
+    this.oodel.create(operationlogdata);
     return await this.model.create(newdata);
   }
   async findTransactionList({ product_id }) {