guhongwei 4 년 전
부모
커밋
de34dd0dfe
4개의 변경된 파일78개의 추가작업 그리고 0개의 파일을 삭제
  1. 34 0
      app/controller/.imgtxtdock.js
  2. 16 0
      app/controller/imgtxtdock.js
  3. 24 0
      app/model/imgtxtdock.js
  4. 4 0
      app/router.js

+ 34 - 0
app/controller/.imgtxtdock.js

@@ -0,0 +1,34 @@
+module.exports = {
+  create: {
+    requestBody: ["!dock_id", "user_name", "brief", "image"],
+  },
+  destroy: {
+    params: ["!id"],
+    service: "delete",
+  },
+  update: {
+    params: ["!id"],
+    requestBody: ["!dock_id", "user_name", "brief", "image"],
+  },
+  show: {
+    parameters: {
+      params: ["!id"],
+    },
+    service: "fetch",
+  },
+  index: {
+    parameters: {
+      query: {
+        dock_id: "dock_id",
+        user_name: "user_name",
+      },
+    },
+    service: "query",
+    options: {
+      query: ["skip", "limit"],
+      sort: ["meta.createdAt"],
+      desc: true,
+      count: true,
+    },
+  },
+};

+ 16 - 0
app/controller/imgtxtdock.js

@@ -0,0 +1,16 @@
+'use strict';
+
+const _ = require('lodash');
+const meta = require('./.imgtxtdock.js');
+const Controller = require('egg').Controller;
+const { CrudController } = require('naf-framework-mongoose/lib/controller');
+
+// 展会图文直播
+class ImgtxtdockController extends Controller {
+  constructor(ctx) {
+    super(ctx);
+    this.service = this.ctx.service.imgtxtdock;
+  }
+}
+
+module.exports = CrudController(ImgtxtdockController, meta);

+ 24 - 0
app/model/imgtxtdock.js

@@ -0,0 +1,24 @@
+'use strict';
+const Schema = require('mongoose').Schema;
+const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
+// 图片数组
+const images = new Schema({
+  url: { type: String, required: true }, // 图片路径
+});
+// 栏目表
+const imgtxtdockSchema = {
+  dock_id: { type: String, required: true, maxLength: 500 }, // 展会id
+  user_name: { type: String, required: false, maxLength: 500 }, // 发言人
+  brief: { type: String, required: false, maxLength: 500 }, // 发言文字内容
+  image: { type: [ images ], select: true }, // 图片
+};
+
+
+const schema = new Schema(imgtxtdockSchema, { toJSON: { virtuals: true } });
+schema.index({ id: 1 });
+schema.plugin(metaPlugin);
+
+module.exports = app => {
+  const { mongoose } = app;
+  return mongoose.model('imgtxtdock', schema, 'imgtxt_dock');
+};

+ 4 - 0
app/router.js

@@ -110,4 +110,8 @@ module.exports = app => {
   router.resources('flower', '/api/live/flower', controller.flower); // index、create、show、destroy
   router.resources('flower', '/api/live/flower', controller.flower); // index、create、show、destroy
   router.post('flower', '/api/live/flower/update/:id', controller.flower.update);
   router.post('flower', '/api/live/flower/update/:id', controller.flower.update);
 
 
+  // 展会图文直播表
+  router.resources('imgtxtdock', '/api/live/imgtxtdock', controller.imgtxtdock); // index、create、show、destroy
+  router.post('imgtxtdock', '/api/live/imgtxtdock/update/:id', controller.imgtxtdock.update);
+
 };
 };