guhongwei 4 years ago
parent
commit
8d5cc42eab
2 changed files with 12 additions and 11 deletions
  1. 3 10
      app/controller/.company.js
  2. 9 1
      app/model/company.js

+ 3 - 10
app/controller/.company.js

@@ -1,10 +1,6 @@
 module.exports = {
   create: {
-    requestBody: [
-      "!company",
-      "mobile",
-
-    ],
+    requestBody: ["!company", "mobile"],
   },
   destroy: {
     params: ["!id"],
@@ -12,10 +8,7 @@ module.exports = {
   },
   update: {
     params: ["!id"],
-    requestBody: [
-      "!company",
-      "mobile",
-    ],
+    requestBody: ["!company", "mobile", "type", "file", "video", "image"],
   },
   show: {
     parameters: {
@@ -28,7 +21,7 @@ module.exports = {
       query: {
         company: "company",
         mobile: "mobile",
-
+        type: "type",
       },
     },
     service: "query",

+ 9 - 1
app/model/company.js

@@ -1,11 +1,19 @@
 '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, maxLength: 500 }, // 图片路径
+  name: { type: String, required: true, maxLength: 500 }, // 图片名称
+});
 // 企业信息
 const CompanySchema = {
   company: { type: String, required: true, maxLength: 200 }, // 名称
   mobile: { type: String, required: false, maxLength: 500 }, // 电话
+  type: { type: String, required: false, maxLength: 500, default: 0 }, // 视频
+  file: { type: String, required: false, maxLength: 500 }, // 单张图片
+  video: { type: String, required: false, maxLength: 500 }, // 视频
+  image: { type: [ images ], select: true }, // 图片
 };
 
 const schema = new Schema(CompanySchema, { toJSON: { virtuals: true } });