Browse Source

增加大批次表

liuyu 5 years ago
parent
commit
fc67af591c
3 changed files with 79 additions and 0 deletions
  1. 43 0
      app/controller/.trainplanyear.js
  2. 18 0
      app/controller/trainplanyear.js
  3. 18 0
      app/service/trainplanyear.js

+ 43 - 0
app/controller/.trainplanyear.js

@@ -0,0 +1,43 @@
+module.exports = {
+  create: {
+    requestBody: [
+      '!year',
+      '!title',
+      'remark'
+    ]
+  },
+  destroy: {
+    params: ['!id'],
+    service: 'delete'
+  },
+  update: {
+    params: ['!id'],
+    requestBody: [
+      'year',
+      'title',
+      'remark'
+    ]
+  },
+  show: {
+    parameters: {
+      params: ['!id']
+    },
+    service: 'fetch'
+  },
+  index: {
+    parameters: {
+      query: {
+        year :'year',
+        title :'title',
+        remark :'remark'
+      }
+    },
+    service: 'query',
+    options: {
+      query: ['skip', 'limit'],
+      sort: ['meta.createdAt'],
+      desc: true,
+      count: true
+    }
+  },
+};

+ 18 - 0
app/controller/trainplanyear.js

@@ -0,0 +1,18 @@
+'use strict';
+
+const _ = require('lodash');
+const Controller = require('egg').Controller;
+const meta = require('./.trainplanyear.js');
+const { CrudController } = require('naf-framework-mongoose/lib/controller');
+
+// 计划大批次管理
+class TrainplanyearController extends Controller {
+
+  constructor(ctx) {
+    super(ctx);
+    this.service = this.ctx.service.trainplanyear;
+  }
+
+}
+
+module.exports = CrudController(TrainplanyearController, meta);

+ 18 - 0
app/service/trainplanyear.js

@@ -0,0 +1,18 @@
+'use strict';
+
+
+const assert = require('assert');
+const _ = require('lodash');
+const { ObjectId } = require('mongoose').Types;
+const { CrudService } = require('naf-framework-mongoose/lib/service');
+const { BusinessError, ErrorCode } = require('naf-core').Error;
+
+class TrainplanyearService extends CrudService {
+  constructor(ctx) {
+    super(ctx, 'trainplan_year');
+    this.model = this.ctx.model.Trainplanyear;
+  }
+
+}
+
+module.exports = TrainplanyearService;