echoFan před 4 roky
rodič
revize
e9a2f07b0a

+ 2 - 2
app/controller/.links.js

@@ -1,6 +1,6 @@
 module.exports = {
   create: {
-    requestBody: ["name", "linkurl", "create_time"],
+    requestBody: ["!name", "!linkurl", "!create_time"],
   },
   destroy: {
     params: ["!id"],
@@ -8,7 +8,7 @@ module.exports = {
   },
   update: {
     params: ["!id"],
-    requestBody: ["name", "linkurl", "create_time"],
+    requestBody: ["!name", "!linkurl", "!create_time"],
   },
   show: {
     parameters: {

+ 6 - 6
app/controller/links.js

@@ -1,11 +1,11 @@
-"use strict";
+'use strict';
 
-const _ = require("lodash");
-const meta = require("./.links.js");
-const Controller = require("egg").Controller;
-const { CrudController } = require("naf-framework-mongoose/lib/controller");
+const _ = require('lodash');
+const meta = require('./.links.js');
+const Controller = require('egg').Controller;
+const { CrudController } = require('naf-framework-mongoose/lib/controller');
 
-// 任务表管理
+// 友情链接表
 class LinksController extends Controller {
   constructor(ctx) {
     super(ctx);

+ 5 - 5
app/controller/video.js

@@ -1,9 +1,9 @@
-"use strict";
+'use strict';
 
-const _ = require("lodash");
-const meta = require("./.video.js");
-const Controller = require("egg").Controller;
-const { CrudController } = require("naf-framework-mongoose/lib/controller");
+const _ = require('lodash');
+const meta = require('./.video.js');
+const Controller = require('egg').Controller;
+const { CrudController } = require('naf-framework-mongoose/lib/controller');
 
 // 宣传视频表
 class VideoController extends Controller {

+ 9 - 9
app/model/links.js

@@ -1,19 +1,19 @@
-"use strict";
-const Schema = require("mongoose").Schema;
-const metaPlugin = require("naf-framework-mongoose/lib/model/meta-plugin");
+'use strict';
+const Schema = require('mongoose').Schema;
+const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
 
 // 热点资讯表
-const links = {
+const linksSchema = {
   name: { type: String, required: true, maxLength: 200 }, // 名称
-  linkurl: { type: String, required: false, maxLength: 200 }, // 链接地址
-  create_time: { type: String, required: false, maxLength: 200 }, // 发布时间
+  linkurl: { type: String, required: true, maxLength: 800 }, // 链接地址
+  create_time: { type: String, required: true, maxLength: 200 }, // 发布时间
 };
 
-const schema = new Schema(links, { toJSON: { virtuals: true } });
+const schema = new Schema(linksSchema, { toJSON: { virtuals: true } });
 schema.index({ id: 1 });
 schema.plugin(metaPlugin);
 
-module.exports = (app) => {
+module.exports = app => {
   const { mongoose } = app;
-  return mongoose.model("Links", schema, "links");
+  return mongoose.model('Links', schema, 'links');
 };

+ 1 - 1
app/router.js

@@ -28,5 +28,5 @@ module.exports = app => {
   // 友情链接表设置
   router.resources('links', '/api/huanqi/links', controller.links); // index、create、show、destroy
 
-  router.resources('company', '/api/huanqi/business', controller.business); // index、create、show、destroy
+  router.resources('business', '/api/huanqi/business', controller.business); // index、create、show、destroy
 };

+ 1 - 1
app/service/links.js

@@ -9,7 +9,7 @@ const { BusinessError, ErrorCode } = require('naf-core').Error;
 class LinksService extends CrudService {
   constructor(ctx) {
     super(ctx, 'links');
-    this.model = this.ctx.model.links;
+    this.model = this.ctx.model.Links;
   }
 }