guhongwei 4 years ago
parent
commit
ea8e528281
6 changed files with 131 additions and 8 deletions
  1. 61 0
      app/controller/.channel.js
  2. 16 0
      app/controller/channel.js
  3. 28 0
      app/model/channel.js
  4. 4 4
      app/model/dock.js
  5. 5 4
      app/router.js
  6. 17 0
      app/service/channel.js

+ 61 - 0
app/controller/.channel.js

@@ -0,0 +1,61 @@
+module.exports = {
+  create: {
+    requestBody: [
+      "!user_id",
+      "title",
+      "desc",
+      "province",
+      "place",
+      "sponsor",
+      "organizer",
+      "image_path",
+      "video_path",
+    ],
+  },
+  destroy: {
+    params: ["!id"],
+    service: "delete",
+  },
+  update: {
+    params: ["!id"],
+    requestBody: [
+      "!user_id",
+      "title",
+      "desc",
+      "province",
+      "place",
+      "sponsor",
+      "organizer",
+      "image_path",
+      "video_path",
+    ],
+  },
+  show: {
+    parameters: {
+      params: ["!id"],
+    },
+    service: "fetch",
+  },
+  index: {
+    parameters: {
+      query: {
+        user_id: "user_id",
+        title: "title",
+        desc: "desc",
+        province: "province",
+        place: "place",
+        sponsor: "sponsor",
+        organizer: "organizer",
+        image_path: "image_path",
+        video_path: "video_path",
+      },
+    },
+    service: "query",
+    options: {
+      query: ["skip", "limit"],
+      sort: ["meta.createdAt"],
+      desc: true,
+      count: true,
+    },
+  },
+};

+ 16 - 0
app/controller/channel.js

@@ -0,0 +1,16 @@
+'use strict';
+
+const _ = require('lodash');
+const meta = require('./.channel.js');
+const Controller = require('egg').Controller;
+const { CrudController } = require('naf-framework-mongoose/lib/controller');
+
+// 科技频道
+class ChannelController extends Controller {
+  constructor(ctx) {
+    super(ctx);
+    this.service = this.ctx.service.channel;
+  }
+}
+
+module.exports = CrudController(ChannelController, meta);

+ 28 - 0
app/model/channel.js

@@ -0,0 +1,28 @@
+'use strict';
+const Schema = require('mongoose').Schema;
+const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
+const { Secret } = require('naf-framework-mongoose/lib/model/schema');
+// // 产品图片表
+// const images = new Schema({
+//   url: { type: String, required: true, maxLength: 500 }, // 图片路径
+// });
+
+const Channel = {
+  user_id: { type: String, required: false, maxLength: 200 }, // 创建人id
+  title: { type: String, required: false, maxLength: 200 }, // 标题
+  desc: { type: String, maxLength: 1000 }, // 简介
+  province: { type: String, required: false }, // 省
+  place: { type: String, required: false }, // 市
+  sponsor: { type: String, required: false, maxLength: 200 }, // 主办方
+  organizer: { type: String, required: false, maxLength: 200 }, // 承办方
+  image_path: { type: String, required: false }, // 图片路径
+  video_path: { type: String, required: false }, // 视频路径
+};
+const schema = new Schema(Channel, { toJSON: { virtuals: true } });
+schema.index({ id: 1 });
+schema.plugin(metaPlugin);
+
+module.exports = app => {
+  const { mongoose } = app;
+  return mongoose.model('channel', schema, 'channel');
+};

+ 4 - 4
app/model/dock.js

@@ -55,7 +55,7 @@ const goods = new Schema({
   companyweb: { type: String, required: false, maxLength: 2000 }, // 企业网站
   condition: { type: String, required: false, maxLength: 300 }, // 合作条件及要求
   // image: { type: [ String ], required: false, maxLength: 200 }, // 图片
-  image: { type: [images], select: true }, // 图片
+  image: { type: [ images ], select: true }, // 图片
   // 商务方面字段
   messattribute: { type: String, required: false, maxLength: 200 }, // 信息属性
   demand: { type: String, required: false, maxLength: 200 }, // 需求程度
@@ -63,7 +63,7 @@ const goods = new Schema({
   coreelements: { type: String, required: false, maxLength: 200 }, // 核心要素
   priceinfo: { type: String, required: false, maxLength: 200 }, // 价格信息
   businessexpect: { type: String, required: false, maxLength: 200 }, // 商务预期
-  dockStatus: { type: String, default: "0", maxLength: 5 }, // 0未审核,1已通过,2已拒绝
+  dockStatus: { type: String, default: '0', maxLength: 5 }, // 0未审核,1已通过,2已拒绝
 });
 goods.index({ id: 1 });
 // 申请用户
@@ -102,8 +102,8 @@ const Dock = {
   province: { type: String, required: false }, // 省
   place: { type: String, required: false }, // 市
   file_path: { type: String, required: false }, // 视频路径
-  videointro: { type: String, required: false, maxLength: 200 },//视频文件标题
-  videointroinfo: { type: String, required: false, maxLength: 200 },//视频文件简介
+  videointro: { type: String, required: false, maxLength: 200 }, // 视频文件标题
+  videointroinfo: { type: String, required: false, maxLength: 200 }, // 视频文件简介
   adminuser: { type: String, required: false, maxLength: 200 }, // 用户姓名
   phone: { type: String, required: false, maxLength: 200 }, // 电话
   vipuser: { type: [ vipuser ], default: [] }, // vip用户

+ 5 - 4
app/router.js

@@ -68,10 +68,7 @@ module.exports = app => {
 
   // 栏目表设置路由
   router.resources('column', '/api/live/column', controller.column); // index、create、show、destroy
-  router.post(
-    'column',
-    '/api/live/column/update/:id',
-    controller.column.update
+  router.post('column', '/api/live/column/update/:id', controller.column.update
   );
 
   // 信息表设置路由
@@ -101,4 +98,8 @@ module.exports = app => {
 
   router.delete('/api/live/personroomtalk/:id', controller.personroomtalk.delete);
   router.get('/api/live/personroomtalk/countroom', controller.personroomtalk.countroom);
+  // 科技在线频道
+  router.resources('channel', '/api/live/channel', controller.channel); // index、create、show、destroy
+  router.post('channel', '/api/live/channel/update/:id', controller.channel.update);
+
 };

+ 17 - 0
app/service/channel.js

@@ -0,0 +1,17 @@
+'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 ChannelService extends CrudService {
+  constructor(ctx) {
+    super(ctx, 'channel');
+    this.model = this.ctx.model.Channel;
+  }
+}
+
+module.exports = ChannelService;