echoFan 4 rokov pred
rodič
commit
cd23f719b4

+ 10 - 10
app/controller/.business.js

@@ -1,11 +1,11 @@
 module.exports = {
   create: {
     requestBody: [
-      "company",
-      "engCompany",
-      "brief",
-      "image",
-      "mobile",
+      "!company",
+      "!engCompany",
+      "!brief",
+      "!image",
+      "!mobile",
       "address",
       "weixin",
       "gzh",
@@ -20,11 +20,11 @@ module.exports = {
   update: {
     params: ["!id"],
     requestBody: [
-      "company",
-      "engCompany",
-      "brief",
-      "image",
-      "mobile",
+      "!company",
+      "!engCompany",
+      "!brief",
+      "!image",
+      "!mobile",
       "address",
       "weixin",
       "gzh",

+ 16 - 2
app/controller/.caseapply.js

@@ -1,6 +1,13 @@
 module.exports = {
   create: {
-    requestBody: ["name", "address", "area", "create_time", "image", "content"],
+    requestBody: [
+      "!name",
+      "!address",
+      "!area",
+      "!create_time",
+      "!image",
+      "!content",
+    ],
   },
   destroy: {
     params: ["!id"],
@@ -8,7 +15,14 @@ module.exports = {
   },
   update: {
     params: ["!id"],
-    requestBody: ["name", "address", "area", "create_time", "image", "content"],
+    requestBody: [
+      "!name",
+      "!address",
+      "!area",
+      "!create_time",
+      "!image",
+      "!content",
+    ],
   },
   show: {
     parameters: {

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

@@ -1,6 +1,6 @@
 module.exports = {
   create: {
-    requestBody: ["company", "engCompany", "brief", "imagearray"],
+    requestBody: ["!company", "!engCompany", "brief", "imagearray"],
   },
   destroy: {
     params: ["!id"],
@@ -8,7 +8,7 @@ module.exports = {
   },
   update: {
     params: ["!id"],
-    requestBody: ["company", "engCompany", "brief", "imagearray"],
+    requestBody: ["!company", "!engCompany", "brief", "imagearray"],
   },
   show: {
     parameters: {

+ 10 - 10
app/controller/.hotspot.js

@@ -1,11 +1,11 @@
 module.exports = {
   create: {
     requestBody: [
-      "name",
-      "brief",
-      "content",
-      "filepath",
-      "create_time",
+      "!name",
+      "!brief",
+      "!content",
+      "!filepath",
+      "!create_time",
       "type",
     ],
   },
@@ -16,11 +16,11 @@ module.exports = {
   update: {
     params: ["!id"],
     requestBody: [
-      "name",
-      "brief",
-      "content",
-      "filepath",
-      "create_time",
+      "!name",
+      "!brief",
+      "!content",
+      "!filepath",
+      "!create_time",
       "type",
     ],
   },

+ 3 - 4
app/controller/.lunbo.js

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

+ 5 - 5
app/controller/business.js

@@ -1,9 +1,9 @@
-"use strict";
+'use strict';
 
-const _ = require("lodash");
-const meta = require("./.job.js");
-const Controller = require("egg").Controller;
-const { CrudController } = require("naf-framework-mongoose/lib/controller");
+const _ = require('lodash');
+const meta = require('./.business.js');
+const Controller = require('egg').Controller;
+const { CrudController } = require('naf-framework-mongoose/lib/controller');
 
 // 企业信息表
 class BusinessController extends Controller {

+ 6 - 6
app/controller/caseapply.js

@@ -1,11 +1,11 @@
-"use strict";
+'use strict';
 
-const _ = require("lodash");
-const meta = require("./.job.js");
-const Controller = require("egg").Controller;
-const { CrudController } = require("naf-framework-mongoose/lib/controller");
+const _ = require('lodash');
+const meta = require('./.caseapply.js');
+const Controller = require('egg').Controller;
+const { CrudController } = require('naf-framework-mongoose/lib/controller');
 
-// 企业信息
+// 案例应用
 class CaseapplyController extends Controller {
   constructor(ctx) {
     super(ctx);

+ 5 - 5
app/controller/company.js

@@ -1,9 +1,9 @@
-"use strict";
+'use strict';
 
-const _ = require("lodash");
-const meta = require("./.job.js");
-const Controller = require("egg").Controller;
-const { CrudController } = require("naf-framework-mongoose/lib/controller");
+const _ = require('lodash');
+const meta = require('./.company.js');
+const Controller = require('egg').Controller;
+const { CrudController } = require('naf-framework-mongoose/lib/controller');
 
 // 企业信息表
 class CompanyController extends Controller {

+ 11 - 0
app/controller/home.js

@@ -0,0 +1,11 @@
+'use strict';
+
+const Controller = require('egg').Controller;
+
+class HomeController extends Controller {
+  async index() {
+    this.ctx.body = 'Hello world';
+  }
+}
+
+module.exports = HomeController;

+ 1 - 1
app/controller/hotspot.js

@@ -1,7 +1,7 @@
 "use strict";
 
 const _ = require("lodash");
-const meta = require("./.job.js");
+const meta = require("./.hotspot.js");
 const Controller = require("egg").Controller;
 const { CrudController } = require("naf-framework-mongoose/lib/controller");
 

+ 1 - 1
app/controller/links.js

@@ -1,7 +1,7 @@
 "use strict";
 
 const _ = require("lodash");
-const meta = require("./.job.js");
+const meta = require("./.links.js");
 const Controller = require("egg").Controller;
 const { CrudController } = require("naf-framework-mongoose/lib/controller");
 

+ 8 - 6
app/controller/lunbo.js

@@ -1,16 +1,18 @@
-"use strict";
+'use strict';
 
-const _ = require("lodash");
-const meta = require("./.lunbo.js");
-const Controller = require("egg").Controller;
-const { CrudController } = require("naf-framework-mongoose/lib/controller");
+const _ = require('lodash');
+const meta = require('./.lunbo.js');
+const Controller = require('egg').Controller;
+const { CrudController } = require('naf-framework-mongoose/lib/controller');
 
-// 轮播
+// 教师申请讲课表管理
 class LunboController extends Controller {
+
   constructor(ctx) {
     super(ctx);
     this.service = this.ctx.service.lunbo;
   }
+
 }
 
 module.exports = CrudController(LunboController, meta);

+ 1 - 1
app/controller/product.js

@@ -1,7 +1,7 @@
 "use strict";
 
 const _ = require("lodash");
-const meta = require("./.lunbo.js");
+const meta = require("./.product.js");
 const Controller = require("egg").Controller;
 const { CrudController } = require("naf-framework-mongoose/lib/controller");
 

+ 1 - 1
app/controller/video.js

@@ -1,7 +1,7 @@
 "use strict";
 
 const _ = require("lodash");
-const meta = require("./.job.js");
+const meta = require("./.video.js");
 const Controller = require("egg").Controller;
 const { CrudController } = require("naf-framework-mongoose/lib/controller");
 

+ 20 - 22
app/model/business.js

@@ -1,33 +1,31 @@
-"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 imageArray = new Schema({
+// 图片路径
+const image = new Schema({
   url: { type: String, required: false, maxLength: 500 }, // 图片路径
-  // 1: { type: String, required: false, maxLength: 500 }, // 行业新闻
-  // 2: { type: String, required: false, maxLength: 500 }, // 展会资讯
 });
 
-// 友情链接表
-const business = {
-  company: { type: String, required: true, maxLength: 200 }, // 企业名称
-  engCompany: { type: String, required: false, maxLength: 200 }, // 英文名称
-  brief: { type: String, required: false, maxLength: 200 }, // 简介
-  mobile: { type: String, required: false, maxLength: 500 }, // 统一热线
-  address: { type: String, required: false, maxLength: 500 }, //地址
-  weixin: { type: String, required: true, maxLength: 200 }, //微信
-  gzh: { type: String, required: false, maxLength: 200 }, //公众号
-  weibo: { type: String, required: false, maxLength: 200 }, //微博
-  beian: { type: String, required: false, maxLength: 2000 }, // 备案
-  image: { type: [imageArray], select: true }, // 图片
+// 轮播图
+const BusinessSchema = {
+  company: { type: String, required: true, maxLength: 200 }, // 名称
+  engCompany: { type: String, required: true, maxLength: 200 }, // 文件路径
+  brief: { type: String, required: true, maxLength: 200 }, // 创建时间
+  imagearray: { type: [ image ], select: true, maxLength: 500 }, // 图片(数组)
+  mobile: { type: String, required: true, maxLength: 500 }, // 创建时间
+  address: { type: String, required: true, maxLength: 500 }, // 创建时间
+  weixin: { type: String, required: true, maxLength: 500 }, // 创建时间
+  gzh: { type: String, required: true, maxLength: 500 }, // 创建时间
+  weibo: { type: String, required: true, maxLength: 500 }, // 创建时间
+  beian: { type: String, required: true, maxLength: 500 }, // 创建时间
 };
 
-const schema = new Schema(business, { toJSON: { virtuals: true } });
+const schema = new Schema(BusinessSchema, { toJSON: { virtuals: true } });
 schema.index({ id: 1 });
 schema.plugin(metaPlugin);
 
-module.exports = (app) => {
+module.exports = app => {
   const { mongoose } = app;
-  return mongoose.model("Business", schema, "business");
+  return mongoose.model('Business', schema, 'business');
 };

+ 8 - 20
app/model/caseapply.js

@@ -1,33 +1,21 @@
-"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 answerInfo = new Schema({
-//   questionid: { type: String, required: false, maxLength: 200 }, // 问题id
-//   answer: { type: String, required: false, maxLength: 200 }, // 答案
-//   questionscore: { type: String, required: false, maxLength: 200 }, // 分数
-// });
-
-// 案例应用表
-const caseapply = {
+// 轮播图
+const CaseapplySchema = {
   name: { type: String, required: true, maxLength: 200 }, // 名称
   filepath: { type: String, required: false, maxLength: 200 }, // 图片路径
   create_time: { type: String, required: false, maxLength: 200 }, // 发布时间
   content: { type: String, required: false, maxLength: 500 }, // 内容
   brief: { type: String, required: false, maxLength: 500 }, // 简介
-  // studentid: { type: String, required: true, maxLength: 200 }, // 学生id
-  // picrul: { type: String, required: false, maxLength: 200 }, // 上传图片地址
-  // taskid: { type: String, required: false, maxLength: 200 }, // 作业id
-  // score: { type: String, required: false, maxLength: 2000 }, // 分数
-  // answers: { type: [answerInfo], select: true }, // 回答详情
 };
 
-const schema = new Schema(caseapply, { toJSON: { virtuals: true } });
+const schema = new Schema(CaseapplySchema, { toJSON: { virtuals: true } });
 schema.index({ id: 1 });
 schema.plugin(metaPlugin);
 
-module.exports = (app) => {
+module.exports = app => {
   const { mongoose } = app;
-  return mongoose.model("Caseapply", schema, "caseapply");
+  return mongoose.model('Caseapply', schema, 'caseapply');
 };

+ 0 - 4
app/model/company.js

@@ -13,10 +13,6 @@ const company = {
   engCompany: { type: String, required: true, maxLength: 200 }, // 英文名称
   brief: { type: String, required: true, maxLength: 200 }, // 简介
   imagearray: { type: [ image ], select: true, maxLength: 500 }, // 图片(数组)
-  // picrul: { type: String, required: false, maxLength: 200 }, // 上传图片地址
-  // taskid: { type: String, required: false, maxLength: 200 }, // 作业id
-  // score: { type: String, required: false, maxLength: 2000 }, // 分数
-  // answers: { type: [answerInfo], select: true }, // 回答详情
 };
 
 const schema = new Schema(company, { toJSON: { virtuals: true } });

+ 4 - 8
app/model/hotspot.js

@@ -1,6 +1,6 @@
-"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 typeInfo = new Schema({
@@ -16,10 +16,6 @@ const hotspot = {
   create_time: { type: String, required: false, maxLength: 200 }, // 发布时间
   content: { type: String, required: false, maxLength: 500 }, // 内容
   brief: { type: String, required: false, maxLength: 500 }, // 简介
-  // studentid: { type: String, required: true, maxLength: 200 }, // 学生id
-  // picrul: { type: String, required: false, maxLength: 200 }, // 上传图片地址
-  // taskid: { type: String, required: false, maxLength: 200 }, // 作业id
-  // score: { type: String, required: false, maxLength: 2000 }, // 分数
   type: { type: [ typeInfo ], select: true }, // 回答详情
 };
 
@@ -29,5 +25,5 @@ schema.plugin(metaPlugin);
 
 module.exports = (app) => {
   const { mongoose } = app;
-  return mongoose.model("Hotspot", schema, "hotspot");
+  return mongoose.model('Hotspot', schema, 'hotspot');
 };

+ 0 - 14
app/model/links.js

@@ -2,25 +2,11 @@
 const Schema = require("mongoose").Schema;
 const metaPlugin = require("naf-framework-mongoose/lib/model/meta-plugin");
 
-// 类型
-// const imageArray = new Schema({
-//   url: { type: String, required: false, maxLength: 500 }, // 图片路径
-//   // 1: { type: String, required: false, maxLength: 500 }, // 行业新闻
-//   // 2: { type: String, required: false, maxLength: 500 }, // 展会资讯
-// });
-
 // 热点资讯表
 const links = {
   name: { type: String, required: true, maxLength: 200 }, // 名称
   linkurl: { type: String, required: false, maxLength: 200 }, // 链接地址
   create_time: { type: String, required: false, maxLength: 200 }, // 发布时间
-  // mobile: { type: String, required: false, maxLength: 500 }, // 统一热线
-  // address: { type: String, required: false, maxLength: 500 }, //地址
-  // weixin: { type: String, required: true, maxLength: 200 }, //微信
-  // gzh: { type: String, required: false, maxLength: 200 }, //公众号
-  // weibo: { type: String, required: false, maxLength: 200 }, //微博
-  // beian: { type: String, required: false, maxLength: 2000 }, // 备案
-  // image: { type: [imageArray], select: true }, // 图片
 };
 
 const schema = new Schema(links, { toJSON: { virtuals: true } });

+ 5 - 19
app/model/lunbo.js

@@ -2,28 +2,14 @@
 const Schema = require('mongoose').Schema;
 const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
 
-// // 答案详情
-// const answerInfo = new Schema({
-//   questionid: { type: String, required: false, maxLength: 200 }, // 问题id
-//   answer: { type: String, required: false, maxLength: 200 }, // 答案
-//   questionscore: { type: String, required: false, maxLength: 200 }, // 分数
-// });
-
-// 轮播
-const lunbo = {
+// 轮播图
+const LunboSchema = {
   name: { type: String, required: true, maxLength: 200 }, // 名称
-  filepath: { type: String, required: false, maxLength: 200 }, // 图片路径
-  create_time: { type: String, required: false, maxLength: 200 }, // 发布时间
-  // lessonid: { type: String, required: true, maxLength: 200 }, // 课程信息id
-  // lessonname: { type: String, required: false, maxLength: 200 }, // 课程信息名称
-  // studentid: { type: String, required: true, maxLength: 200 }, // 学生id
-  // picrul: { type: String, required: false, maxLength: 200 }, // 上传图片地址
-  // taskid: { type: String, required: false, maxLength: 200 }, // 作业id
-  // score: { type: String, required: false, maxLength: 2000 }, // 分数
-  // answers: { type: [answerInfo], select: true }, // 回答详情
+  filepath: { type: String, required: true, maxLength: 200 }, // 文件路径
+  create_time: { type: String, required: true, maxLength: 200 }, // 创建时间
 };
 
-const schema = new Schema(lunbo, { toJSON: { virtuals: true } });
+const schema = new Schema(LunboSchema, { toJSON: { virtuals: true } });
 schema.index({ id: 1 });
 schema.plugin(metaPlugin);
 

+ 0 - 12
app/model/product.js

@@ -2,13 +2,6 @@
 const Schema = require('mongoose').Schema;
 const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
 
-// // 答案详情
-// const answerInfo = new Schema({
-//   questionid: { type: String, required: false, maxLength: 200 }, // 问题id
-//   answer: { type: String, required: false, maxLength: 200 }, // 答案
-//   questionscore: { type: String, required: false, maxLength: 200 }, // 分数
-// });
-
 // 产品表
 const product = {
   name: { type: String, required: true, maxLength: 200 }, // 名称
@@ -16,11 +9,6 @@ const product = {
   create_time: { type: String, required: false, maxLength: 200 }, // 发布时间
   content: { type: String, required: false, maxLength: 500 }, // 内容
   brief: { type: String, required: false, maxLength: 500 }, // 简介
-  // studentid: { type: String, required: true, maxLength: 200 }, // 学生id
-  // picrul: { type: String, required: false, maxLength: 200 }, // 上传图片地址
-  // taskid: { type: String, required: false, maxLength: 200 }, // 作业id
-  // score: { type: String, required: false, maxLength: 2000 }, // 分数
-  // answers: { type: [answerInfo], select: true }, // 回答详情
 };
 
 const schema = new Schema(product, { toJSON: { virtuals: true } });

+ 7 - 21
app/model/video.js

@@ -1,33 +1,19 @@
-"use strict";
-const Schema = require("mongoose").Schema;
-const metaPlugin = require("naf-framework-mongoose/lib/model/meta-plugin");
-
-// // 类型
-// const typeInfo = new Schema({
-//   0: { type: String, required: false, maxLength: 500 }, // 公司新闻
-//   1: { type: String, required: false, maxLength: 500 }, // 行业新闻
-//   2: { type: String, required: false, maxLength: 500 }, // 展会资讯
-// });
+'use strict';
+const Schema = require('mongoose').Schema;
+const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
 
 // 宣传视频表
-const video = {
+const videoSchema = {
   name: { type: String, required: true, maxLength: 200 }, // 名称
   videopath: { type: String, required: false, maxLength: 200 }, // 视频
   create_time: { type: String, required: false, maxLength: 200 }, // 发布时间
-  // content: { type: String, required: false, maxLength: 500 }, // 内容
-  // brief: { type: String, required: false, maxLength: 500 }, // 简介
-  // studentid: { type: String, required: true, maxLength: 200 }, // 学生id
-  // picrul: { type: String, required: false, maxLength: 200 }, // 上传图片地址
-  // taskid: { type: String, required: false, maxLength: 200 }, // 作业id
-  // score: { type: String, required: false, maxLength: 2000 }, // 分数
-  // type: { type: [typeInfo], select: true }, // 回答详情
 };
 
-const schema = new Schema(video, { toJSON: { virtuals: true } });
+const schema = new Schema(videoSchema, { toJSON: { virtuals: true } });
 schema.index({ id: 1 });
 schema.plugin(metaPlugin);
 
-module.exports = (app) => {
+module.exports = app => {
   const { mongoose } = app;
-  return mongoose.model("Video", schema, "video");
+  return mongoose.model('Video', schema, 'video');
 };

+ 15 - 544
app/router.js

@@ -8,554 +8,25 @@ module.exports = app => {
   router.get('/', controller.home.index);
 
   // 轮播图设置
-  router.resources('lunbo', '/api/huanqi/lunbo ', controller.lunbo); // index、create、show、destroy
-  router.post(
-    'lunbo',
-    '/api/huanqi/lunbo/update/:id',
-    controller.lunbo.update // update
-  );
-  // 企业信息表设置
-  router.resources('company', '/api/huanqi/company ', controller.company); // index、create、show、destroy
-  router.post(
-    'company',
-    '/api/huanqi/company/update/:id',
-    controller.company.update // update
-  );
-  // 产品表设置
-  router.resources('product', '/api/huanqi/product ', controller.product); // index、create、show、destroy
-  router.post(
-    'product',
-    '/api/huanqi/product/update/:id',
-    controller.product.update // update
-  );
-  // 案例应用表设置
-  router.resources('caseapply', '/api/huanqi/caseapply ', controller.caseapply); // index、create、show、destroy
-  router.post(
-    'caseapply',
-    '/api/huanqi/caseapply/update/:id',
-    controller.caseapply.update // update
-  );
-  // 热点资讯表设置
-  router.resources('hotspot', '/api/huanqi/hotspot ', controller.hotspot); // index、create、show、destroy
-  router.post(
-    'hotspot',
-    '/api/huanqi/hotspot/update/:id',
-    controller.hotspot.update // update
-  );
-  // 宣传视频表设置
-  router.resources('video', '/api/huanqi/video ', controller.video); // index、create、show、destroy
-  router.post(
-    'video',
-    '/api/huanqi/video/update/:id',
-    controller.video.update // update
-  );
-  // 企业信息表设置
-  router.resources('business', '/api/huanqi/hotspot ', controller.business); // index、create、show、destroy
-  router.post(
-    'business',
-    '/api/huanqi/business/update/:id',
-    controller.business.update // update
-  );
-  // 友情链接表设置
-  router.resources('links', '/api/huanqi/links ', controller.links); // index、create、show、destroy
-  router.post(
-    'links',
-    '/api/huanqi/links/update/:id',
-    controller.links.update // update
-  );
-};
-//   // 共通查询单条记录方法
-//   router.get('/api/train/common/findone/:modelname', controller.common.findone);
-//   // 共通批量查询方法
-//   router.post(
-//     '/api/train/common/findbyids/:modelname',
-//     controller.common.findbyids
-//   );
-//   // 共通查询表
-//   router.get('/api/train/common/findbymodel', controller.common.findbymodel);
-//   router.get('/api/train/common/findyear', controller.common.findyear);
-//   // 基础设置表路由
-//   router.get('/api/train/setting/findone', controller.setting.findone);
-//   router.resources('setting', '/api/train/setting', controller.setting); // index、create、show、destroy
-//   router.post(
-//     'setting',
-//     '/api/train/setting/update/:id',
-//     controller.setting.update
-//   );
-//   // 住宿人数路由设置
-//   router.resources('dormcount', '/api/live/dormcount', controller.dormcount); // index、create、show、destroy
-//   router.post('dormcount', '/api/live/dormcount/:id', controller.dormcount.update);
-
-//   // 科目表设置路由
-//   router.resources('subject', '/api/train/subject', controller.subject); // index、create、show、destroy
-//   router.post(
-//     'subject',
-//     '/api/train/subject/update/:id',
-//     controller.subject.update
-//   );
-
-//   // 教师表设置路由
-//   router.get('teacher', '/api/train/teacher/show/:id', controller.teacher.show);
-//   router.resources('teacher', '/api/train/teacher', controller.teacher); // index、create、show、destroy
-//   router.post(
-//     'teacher',
-//     '/api/train/teacher/update/:id',
-//     controller.teacher.update
-//   );
-//   router.post(
-//     'teacher',
-//     '/api/train/teacher/status',
-//     controller.teacher.status
-//   );
-//   router.post('/api/train/teacher/teaimport', controller.teacher.teaimport);
-
-//   // 作业表配置路由
-//   router.resources('task', '/api/train/task', controller.task); // index、create、show、destroy
-//   router.post('task', '/api/train/task/update/:id', controller.task.update);
-
-//   // 问卷题库表配置路由
-//   router.resources('question', '/api/train/question', controller.question); // index、create、show、destroy
-//   router.post(
-//     'question',
-//     '/api/train/question/update/:id',
-//     controller.question.update
-//   );
-
-//   // 问卷表配置路由
-//   router.post(
-//     'questionnaire',
-//     '/api/train/questionnaire',
-//     controller.questionnaire.create
-//   );
-//   router.delete(
-//     'questionnaire',
-//     '/api/train/questionnaire/:id',
-//     controller.questionnaire.delete
-//   );
-//   router.post(
-//     'questionnaire',
-//     '/api/train/questionnaire/update/:id',
-//     controller.questionnaire.update
-//   );
-//   router.get(
-//     'questionnaire',
-//     '/api/train/questionnaire',
-//     controller.questionnaire.query
-//   );
-//   router.get(
-//     'questionnaire',
-//     '/api/train/questionnaire/show/:id',
-//     controller.questionnaire.show
-//   );
-
-//   // 学生表设置路由
-//   router.get(
-//     'sutdent',
-//     '/api/train/student/findscore',
-//     controller.student.findscore
-//   );
-//   router.get(
-//     'sutdent',
-//     '/api/train/student/findbedroom',
-//     controller.student.findbedroom
-//   );
-//   router.get('sutdent', '/api/train/student/seek', controller.student.seek);
-//   router.resources('student', '/api/train/student', controller.student); // index、create、show、destroy
-//   router.post(
-//     'student',
-//     '/api/train/student/update/:id',
-//     controller.student.update
-//   );
-//   router.post('student', '/api/train/student/upjob', controller.student.upjob);
-//   router.post(
-//     'student',
-//     '/api/train/student/deleteclass',
-//     controller.student.deleteclass
-//   ); // 删除学生班级
-//   router.post(
-//     'student',
-//     '/api/train/student/findbystuids',
-//     controller.student.findbystuids
-//   );
-//   router.post(
-//     'student',
-//     '/api/train/student/deletestus',
-//     controller.student.deletestus
-//   ); // 删除学生多条
-//   router.post(
-//     'student',
-//     '/api/train/student/updatabedroom',
-//     controller.student.updatabedroom
-//   ); // 批量学生寝室号
-
-//   // 班主任表设置路由
-//   router.resources(
-//     'headteacher', '/api/train/headteacher',
-//     controller.headteacher
-//   ); // index、create、show、destroy
-//   router.post(
-//     'headteacher', '/api/train/headteacher/update/:id',
-//     controller.headteacher.update
-//   );
-
-//   // 维修表设置
-//   router.resources('maintain', '/api/vehicle/maintain', controller.maintain); // index、create、show、destroy
-//   router.post(
-//     'maintain', '/api/vehicle/maintain/update/:id', controller.maintain.update // update
-//   );
-
-//   // 寝室表设置路由
-//   router.get('/api/train/bedroom/student/:id', controller.bedroom.roomstu); // 根据班级id查询寝室信息
-//   router.resources('bedroom', '/api/train/bedroom', controller.bedroom); // index、create、show、destroy
-//   router.post(
-//     'bedroom',
-//     '/api/train/bedroom/update/:id',
-//     controller.bedroom.update
-//   );
-//   router.post('bedroom', '/api/train/bedroom/apart', controller.bedroom.apart);
-//   router.post(
-//     'bedroom',
-//     '/api/train/bedroom/ibeacon',
-//     controller.bedroom.ibeacon
-//   );
-
-//   // 班级表设置路由
-//   router.get(
-//     'class',
-//     '/api/train/class/classinfo/:id',
-//     controller.class.classinfo
-//   );
-//   router.post(
-//     'class',
-//     '/api/train/class/upclasses',
-//     controller.class.upclasses
-//   );
-//   router.post('class', '/api/train/class/notice', controller.class.notice);
-//   router.resources('class', '/api/train/class', controller.class); // index、create、show、destroy
-//   router.post('class', '/api/train/class/update/:id', controller.class.update);
-//   router.post('class', '/api/train/class/divide', controller.class.divide);
-//   router.post('class', '/api/train/class/uptea', controller.class.uptea);
-//   router.post(
-//     'class',
-//     '/api/train/class/upstuclass/:id',
-//     controller.class.studentupclass
-//   ); // 学生修改班级
-
-//   // 部门表设置路由
-//   router.resources(
-//     'department',
-//     '/api/train/department',
-//     controller.department
-//   ); // index、create、show、destroy
-//   router.post(
-//     'department',
-//     '/api/train/department/update/:id',
-//     controller.department.update
-//   );
-
-//   // 位置表设置路由
-//   router.resources('location', '/api/train/location', controller.location); // index、create、show、destroy
-//   router.post(
-//     'location',
-//     '/api/train/location/update/:id',
-//     controller.location.update
-//   );
-
-//   // 培训计划表设置路由
-//   router.resources('trainplan', '/api/train/trainplan', controller.trainplan); // index、create、show、destroy
-//   router.post('trainplan','/api/train/trainplan/update/:id',controller.trainplan.update);
-//   router.post('/api/train/trainplan/exportExcel', controller.trainplan.exportExcel); // 导出
-//   router.post('/api/train/trainplan/exportSchool', controller.trainplan.exportSchool); // 导出计划学校
-//   router.post('/api/train/trainplan/exportPlan', controller.trainplan.exportPlan); // 导出计划日历
-//   router.post('/api/train/trainplan/updateclass', controller.trainplan.updateclass);
-//   router.post('/api/train/trainplan/updatereteacher', controller.trainplan.updatereteacher);
-
-//   // 培训计划年度批次表设置路由
-//   router.resources('trainplanyear', '/api/train/trainplanyear', controller.trainplanyear); // index、create、show、destroy
-//   router.post('trainplanyear', '/api/train/trainplanyear/update/:id', controller.trainplanyear.update);
-
-//   // 节假日表设置路由
-//   router.resources('festival', '/api/train/festival', controller.festival); // index、create、show、destroy
-//   router.post(
-//     'festival',
-//     '/api/train/festival/update/:id',
-//     controller.festival.update
-//   );
-
-//   // 课程表设置路由
-//   router.get('/api/train/lesson/teaclass', controller.lesson.teaclass);
-//   router.post(
-//     'lesson',
-//     '/api/train/lesson/uplessones',
-//     controller.lesson.uplessones
-//   );
-//   router.get('/api/train/lesson/classbyteaid', controller.lesson.classbyteaid); // 根据计划id与教师id查询班级信息
-//   router.resources('lesson', '/api/train/lesson', controller.lesson); // index、create、show、destroy
-//   router.post(
-//     'lesson',
-//     '/api/train/lesson/update/:id',
-//     controller.lesson.update
-//   );
-//   router.post(
-//     'lesson',
-//     '/api/train/lesson/autolesson/:id',
-//     controller.lesson.autolesson
-//   ); // 自动排课
-
-//   // 培训计划学校上报时间表设置路由
-//   router.resources('schtime', '/api/train/schtime', controller.schtime); // index、create、show、destroy
-//   router.post(
-//     'schtime',
-//     '/api/train/schtime/update/:id',
-//     controller.schtime.update
-//   );
-//   router.post(
-//     'schtime',
-//     '/api/train/schtime/updateschtimes',
-//     controller.schtime.updateschtimes
-//   );
-
-//   // 班主任全年计划表设置路由
-//   router.get('teaplan', '/api/train/teaplan/divide', controller.teaplan.divide);
-//   router.get(
-//     'teaplan',
-//     '/api/train/teaplan/findteacher',
-//     controller.teaplan.findteacher
-//   );
-//   router.resources('teaplan', '/api/train/teaplan', controller.teaplan); // index、create、show、destroy
-//   router.post(
-//     'teaplan',
-//     '/api/train/teaplan/update/:id',
-//     controller.teaplan.update
-//   );
+  router.resources('lunbo', '/api/huanqi/lunbo', controller.lunbo); // index、create、show、destroy
 
-//   // 教师申请讲课表设置路由
-//   router.get(
-//     'apply',
-//     '/api/train/apply/queryteacher',
-//     controller.apply.queryteacher
-//   );
-//   router.resources('apply', '/api/train/apply', controller.apply); // index、create、show、destroy
-//   router.post('apply', '/api/train/apply/update/:id', controller.apply.update);
-
-//   // 请假表设置路由
-//   router.resources('leave', '/api/train/leave', controller.leave); // index、create、show、destroy
-//   router.post('leave', '/api/train/leave/update/:id', controller.leave.update);
-
-//   // 分组表设置路由
-//   router.resources('group', '/api/train/group', controller.group); // index、create、show、destroy
-//   router.post('group', '/api/train/group/update/:id', controller.group.update);
-//   router.post('group', '/api/train/group/insert', controller.group.insert);
-//   router.post('group', '/api/train/group/exit', controller.group.exit);
-//   router.post('group', '/api/train/group/sethead', controller.group.sethead);
-//   router.post(
-//     'group',
-//     '/api/train/group/findbystuid',
-//     controller.group.findbystuid
-//   );
-
-//   // 职责说明表设置路由
-//   router.resources('duty', '/api/train/duty', controller.duty); // index、create、show、destroy
-//   router.post('duty', '/api/train/duty/update/:id', controller.duty.update);
-
-//   // 学生上传作业表设置路由
-//   router.resources(
-//     'uploadtask',
-//     '/api/train/uploadtask',
-//     controller.uploadtask
-//   ); // index、create、show、destroy
-//   router.post(
-//     'uploadtask',
-//     '/api/train/uploadtask/update/:id',
-//     controller.uploadtask.update
-//   );
-
-//   // 学生上传问卷表设置路由
-//   router.get(
-//     '/api/train/uploadquestion/completion',
-//     controller.uploadquestion.completion
-//   ); // 统计完成度
-//   router.resources(
-//     'uploadquestion',
-//     '/api/train/uploadquestion',
-//     controller.uploadquestion
-//   ); // index、create、show、destroy
-//   router.post(
-//     'uploadquestion',
-//     '/api/train/uploadquestion/update/:id',
-//     controller.uploadquestion.update
-//   );
-
-//   // 考勤表设置路由
-//   router.get('/api/train/attendance/wxauth', controller.attendance.wxauth); // 统计完成度
-//   router.resources(
-//     'attendance',
-//     '/api/train/attendance',
-//     controller.attendance
-//   ); // index、create、show、destroy
-//   router.post(
-//     'attendance',
-//     '/api/train/attendance/update/:id',
-//     controller.attendance.update
-//   );
-//   router.post(
-//     'attendance',
-//     '/api/train/attendance/attendancecreate',
-//     controller.attendance.attendancecreate
-//   );
-//   router.post(
-//     'attendance',
-//     '/api/train/attendance/attendancecreateList',
-//     controller.attendance.attendancecreateList
-//   );
-//   // 学校上传学生名单
-//   router.resources('school', '/api/train/school', controller.school); // index、create、show、destroy
-//   router.post(
-//     'school',
-//     '/api/train/school/update/:id',
-//     controller.school.update
-//   );
-//   router.post('/api/train/school/import', controller.school.stuimport); // 名单上传
-
-//   // 民族表设置路由
-//   router.resources('nation', '/api/train/nation', controller.nation); // index、create、show、destroy
-//   router.post(
-//     'nation',
-//     '/api/train/nation/update/:id',
-//     controller.nation.update
-//   );
-
-//   // 行政区划表设置路由
-//   router.resources('region', '/api/train/region', controller.region); // index、create、show、destroy
-//   router.post(
-//     'region',
-//     '/api/train/region/update/:id',
-//     controller.region.update
-//   );
-
-//   // 用户表设置路由
-//   router.get('/api/train/user/schoolregister', controller.user.schoolregister); // 学校账号一键生成
-//   router.resources('user', '/api/train/user', controller.user); // index、create、show、destroy
-//   router.post('user', '/api/train/user/update/:id', controller.user.update);
-//   router.post('user', '/api/train/user/register', controller.user.register); // 学校注册
-//   router.post('user', '/api/train/user/bind', controller.user.bind); // 学生微信绑定
-//   router.post('user', '/api/train/user/userbind', controller.user.userbind); // 其他用户微信绑定
-
-//   // 行政区划表设置路由
-//   router.resources('termquest', '/api/train/termquest', controller.termquest); // index、create、show、destroy
-//   router.post(
-//     'termquest',
-//     '/api/train/termquest/update/:id',
-//     controller.termquest.update
-//   );
-
-//   // 微信端访问地址
-//   router.get('/api/train/auth', controller.weixin.auth); // 微信登录
-//   // 微信端访问地址
-//   router.get('/api/train/authtest', controller.weixin.authTest); // 微信登录测试
-
-//   // pc端登录
-//   router.post('/api/train/login', controller.login.login); // 登录
-//   // 微信端登录
-//   router.get('/api/train/qrcode', controller.login.qrcode); // 登录
-//   router.post('/api/train/wxcheck', controller.login.wxcheck); // 微信检查登录
-//   router.post('/api/train/wxlogin', controller.login.wxlogin); // 登录
-
-//   // 评分表设置路由
-//   router.resources('score', '/api/train/score', controller.score); // index、create、show、destroy
-//   router.post('score', '/api/train/score/update/:id', controller.score.update);
-
-//   // 上传资料表设置路由
-//   router.resources('material', '/api/train/material', controller.material); // index、create、show、destroy
-//   router.post(
-//     'material',
-//     '/api/train/material/update/:id',
-//     controller.material.update
-//   );
-
-//   // 资料评分表设置路由
-//   router.resources(
-//     'materialscore',
-//     '/api/train/materialscore',
-//     controller.materialscore
-//   ); // index、create、show、destroy
-//   router.post(
-//     'materialscore',
-//     '/api/train/materialscore/update/:id',
-//     controller.materialscore.update
-//   );
-
-//   // 教师在线表设置路由
-//   router.resources('online', '/api/train/online', controller.online); // index、create、show、destroy
-//   router.post(
-//     'online',
-//     '/api/train/online/update/:id',
-//     controller.online.update
-//   );
-
-//   // 聊天房间表设置路由
-//   router.resources('room', '/api/train/room', controller.room); // index、create、show、destroy
-//   router.post('room', '/api/train/room/update/:id', controller.room.update);
-
-//   // 聊天记录表设置路由
-//   router.resources('record', '/api/train/record', controller.record); // index、create、show、destroy
-//   router.post(
-//     'record',
-//     '/api/train/record/update/:id',
-//     controller.record.update
-//   );
-
-//   // 通知表设置路由
-//   router.resources('notice', '/api/train/notice', controller.notice); // index、create、show、destroy
-//   router.post(
-//     'notice',
-//     '/api/train/notice/update/:id',
-//     controller.notice.update
-//   );
-//   router.post('notice', '/api/train/notice/look', controller.notice.look);
+  // 企业信息表设置
+  router.resources('company', '/api/huanqi/company', controller.company); // index、create、show、destroy
 
-//   // 课程模板表设置路由
-//   router.resources(
-//     'lessonmode',
-//     '/api/train/lessonmode',
-//     controller.lessonmode
-//   ); // index、create、show、destroy
-//   router.post(
-//     'lessonmode',
-//     '/api/train/lessonmode/update/:id',
-//     controller.lessonmode.update
-//   );
+  // 产品表设置
+  router.resources('product', '/api/huanqi/product', controller.product); // index、create、show、destroy
 
-//   // 全年计划模板表设置路由
-//   router.resources(
-//     'trainmodel',
-//     '/api/train/trainmodel',
-//     controller.trainmodel
-//   ); // index、create、show、destroy
-//   router.post(
-//     'trainmodel',
-//     '/api/train/trainmodel/update/:id',
-//     controller.trainmodel.update
-//   );
+  // 案例应用表设置
+  router.resources('caseapply', '/api/huanqi/caseapply', controller.caseapply); // index、create、show、destroy
 
-//   // 统计查询设置路由
-//   router.get('/api/train/count/countstudent', controller.count.countstudent);
-//   // 按学校统计查询设置路由
-//   router.get('/api/train/count/countschstu/:id', controller.count.countschstu);
+  // 热点资讯表设置
+  router.resources('hotspot', '/api/huanqi/hotspot', controller.hotspot); // index、create、show、destroy
 
-//   // 班级类型表配置路由
-//   router.resources('classtype', '/api/train/classtype', controller.classtype); // index、create、show、destroy
-//   router.post(
-//     'classtype',
-//     '/api/train/classtype/update/:id',
-//     controller.classtype.update
-//   );
+  // 宣传视频表设置
+  router.resources('video', '/api/huanqi/video', controller.video); // index、create、show、destroy
 
-//   // 学校上传任务表设置路由
-//   router.resources('job', '/api/train/job', controller.job); // index、create、show、destroy
-//   router.post('job', '/api/train/job/update/:id', controller.job.update);
+  // 友情链接表设置
+  router.resources('links', '/api/huanqi/links', controller.links); // index、create、show、destroy
 
-//   // 消息表设置路由
-//   router.resources('message', '/api/train/message', controller.message); // index、create、show、destroy
-//   router.post('message', '/api/train/message/update/:id', controller.message.update);
-// };
+  router.resources('company', '/api/huanqi/business', controller.business); // index、create、show、destroy
+};

+ 7 - 84
app/service/business.js

@@ -1,92 +1,15 @@
-"use strict";
+'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;
+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 BusinessService extends CrudService {
   constructor(ctx) {
-    super(ctx, "business");
+    super(ctx, 'business');
     this.model = this.ctx.model.Business;
-    // this.umodel = this.ctx.model.User;
-  }
-
-  async create(data) {
-    const { company } = data;
-    assert(company, "名称不能为空");
-    // assert(filepath, "路径不能为空");
-    // assert(create_time, "时间不能为空");
-    const user = [];
-    for (const elm of company) {
-      const n = await this.model.findById(elm);
-      if (n) {
-        user.push(n);
-      }
-    }
-    data.company = user;
-    return await this.model.create(data);
-  }
-
-  async delete({ company }) {
-    await this.model.findByIdAndDelete(company);
-    return "deleted";
-  }
-
-  async update({ company }, data) {
-    const {
-      endCompany,
-      brief,
-      image,
-      mobile,
-      address,
-      weixin,
-      gzh,
-      weibo,
-      beian,
-    } = data;
-    const res = await this.model.findById(company);
-    // const res = await this.model.update({ _id: ObjectId(id) }, data);
-    if (company) {
-      res.company = company;
-    }
-    if (endCompany) {
-      res.endCompany = endCompany;
-    }
-    if (brief) {
-      res.brief = brief;
-    }
-    if (image) {
-      res.image = image;
-    }
-    if (brief) {
-      res.brief = brief;
-    }
-    if (mobile) {
-      res.mobile = mobile;
-    }
-    if (address) {
-      res.address = address;
-    }
-    if (weixin) {
-      res.weixin = weixin;
-    }
-    if (gzh) {
-      res.gzh = gzh;
-    }
-    if (weibo) {
-      res.weibo = weibo;
-    }
-    if (beian) {
-      res.beian = beian;
-    }
-    return await res.save();
-  }
-
-  async query({ company }) {
-    const res = await this.model.findByIdAndDelete(company);
-    return res;
   }
 }
 

+ 7 - 56
app/service/caseapply.js

@@ -1,64 +1,15 @@
-"use strict";
+'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;
+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 CaseapplyService extends CrudService {
   constructor(ctx) {
-    super(ctx, "caseapply");
+    super(ctx, 'caseapply');
     this.model = this.ctx.model.Caseapply;
-    // this.umodel = this.ctx.model.User;
-  }
-
-  async create(data) {
-    const { name } = data;
-    assert(name, "名称不能为空");
-    // assert(filepath, "路径不能为空");
-    // assert(create_time, "时间不能为空");
-    const user = [];
-    for (const elm of name) {
-      const n = await this.model.findById(elm);
-      if (n) {
-        user.push(n);
-      }
-    }
-    data.name = user;
-    return await this.model.create(data);
-  }
-
-  async delete({ name }) {
-    await this.model.findByIdAndDelete(name);
-    return "deleted";
-  }
-
-  async update({ name }, data) {
-    const { filepath, create_time, content, brief } = data;
-    const res = await this.model.findById(name);
-    // const res = await this.model.update({ _id: ObjectId(id) }, data);
-    if (name) {
-      res.name = name;
-    }
-    if (filepath) {
-      res.filepath = filepath;
-    }
-    if (create_time) {
-      res.create_time = create_time;
-    }
-    if (content) {
-      res.content = content;
-    }
-    if (brief) {
-      res.brief = brief;
-    }
-    return await res.save();
-  }
-
-  async query({ name }) {
-    const res = await this.model.findByIdAndDelete(name);
-    return res;
   }
 }
 

+ 0 - 47
app/service/company.js

@@ -4,7 +4,6 @@ const assert = require('assert');
 const _ = require('lodash');
 const { ObjectId } = require('mongoose').Types;
 const { CrudService } = require('naf-framework-mongoose/lib/service');
-const company = require('../model/company');
 const { BusinessError, ErrorCode } = require('naf-core').Error;
 
 class CompanyService extends CrudService {
@@ -13,52 +12,6 @@ class CompanyService extends CrudService {
     this.model = this.ctx.model.Company;
     // this.umodel = this.ctx.model.User;
   }
-
-  async create(data) {
-    const { company, engCompany, brief, imagearray } = data;
-    assert(company, '企业名称不能为空');
-    assert(engCompany, '英文名称不能为空');
-    assert(brief, '简介不能为空');
-    const user = [];
-    for (const elm of company) {
-      const n = await this.model.findById(elm);
-      if (n) {
-        user.push(n);
-      }
-    }
-    data.name = user;
-    return await this.model.create(data);
-  }
-
-  async delete({ company }) {
-    await this.model.findByIdAndDelete(company);
-    return 'deleted';
-  }
-
-  async update({ company }, data) {
-    const { engCompany, brief, imagearray } = data;
-    const res = await this.model.findById(company);
-    // const res = await this.model.update({ _id: ObjectId(id) }, data);
-    if (company) {
-      res.name = company;
-    }
-    if (engCompany) {
-      res.engCompany = engCompany;
-    }
-    if (brief) {
-      res.brief = brief;
-    }
-    if (imagearray) {
-      res.imagearray = imagearray;
-    }
-    return await res.save();
-  }
-
-  // 查询
-  async query({ name }) {
-    const res = await this.model.findByIdAndDelete(name);
-    return res;
-  }
 }
 
 module.exports = CompanyService;

+ 7 - 57
app/service/hotspot.js

@@ -1,68 +1,18 @@
-"use strict";
+'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;
+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 HotspotService extends CrudService {
   constructor(ctx) {
-    super(ctx, "hotspot");
+    super(ctx, 'hotspot');
     this.model = this.ctx.model.Hotspot;
     // this.umodel = this.ctx.model.User;
   }
 
-  async create(data) {
-    const { name } = data;
-    assert(name, "名称不能为空");
-    // assert(filepath, "路径不能为空");
-    // assert(create_time, "时间不能为空");
-    const user = [];
-    for (const elm of name) {
-      const n = await this.model.findById(elm);
-      if (n) {
-        user.push(n);
-      }
-    }
-    data.name = user;
-    return await this.model.create(data);
-  }
-
-  async delete({ name }) {
-    await this.model.findByIdAndDelete(name);
-    return "deleted";
-  }
-
-  async update({ name }, data) {
-    const { filepath, create_time, content, brief, type} = data;
-    const res = await this.model.findById(name);
-    // const res = await this.model.update({ _id: ObjectId(id) }, data);
-    if (name) {
-      res.name = name;
-    }
-    if (filepath) {
-      res.filepath = filepath;
-    }
-    if (create_time) {
-      res.create_time = create_time;
-    }
-    if (content) {
-      res.content = content;
-    }
-    if (brief) {
-      res.brief = brief;
-    }
-    if (type) {
-      res.type = type;
-    }
-    return await res.save();
-  }
-
-  async query({ name }) {
-    const res = await this.model.findByIdAndDelete(name);
-    return res;
-  }
 }
 
 module.exports = HotspotService;

+ 7 - 59
app/service/links.js

@@ -1,67 +1,15 @@
-"use strict";
+'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;
+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 LinksService extends CrudService {
   constructor(ctx) {
-    super(ctx, "links");
+    super(ctx, 'links');
     this.model = this.ctx.model.links;
-    // this.umodel = this.ctx.model.User;
-  }
-
-  async create(data) {
-    const { name } = data;
-    assert(name, "名称不能为空");
-    // assert(filepath, "路径不能为空");
-    // assert(create_time, "时间不能为空");
-    const user = [];
-    for (const elm of name) {
-      const n = await this.model.findById(elm);
-      if (n) {
-        user.push(n);
-      }
-    }
-    data.name = user;
-    return await this.model.create(data);
-  }
-
-  async delete({ name }) {
-    await this.model.findByIdAndDelete(name);
-    return "deleted";
-  }
-
-  async update({ name }, data) {
-    const { linkurl, create_time } = data;
-    const res = await this.model.findById(name);
-    // const res = await this.model.update({ _id: ObjectId(id) }, data);
-    if (name) {
-      res.name = name;
-    }
-    if (linkurl) {
-      res.linkurl = linkurl;
-    }
-    if (create_time) {
-      res.create_time = create_time;
-    }
-    // if (content) {
-    //   res.content = content;
-    // }
-    // if (brief) {
-    //   res.brief = brief;
-    // }
-    // if (type) {
-    //   res.type = type;
-    // }
-    return await res.save();
-  }
-
-  async query({ name }) {
-    const res = await this.model.findByIdAndDelete(name);
-    return res;
   }
 }
 

+ 4 - 42
app/service/lunbo.js

@@ -2,6 +2,7 @@
 
 const assert = require('assert');
 const _ = require('lodash');
+const moment = require('moment');
 const { ObjectId } = require('mongoose').Types;
 const { CrudService } = require('naf-framework-mongoose/lib/service');
 const { BusinessError, ErrorCode } = require('naf-core').Error;
@@ -10,49 +11,10 @@ class LunboService extends CrudService {
   constructor(ctx) {
     super(ctx, 'lunbo');
     this.model = this.ctx.model.Lunbo;
-    // this.umodel = this.ctx.model.User;
   }
-
-  async create(data) {
-    const { name, filepath, create_time } = data;
-    assert(name, '名称不能为空');
-    assert(filepath, '路径不能为空');
-    assert(create_time, '时间不能为空');
-    const user = [];
-    for (const elm of name) {
-      const n = await this.model.findById(elm);
-      if (n) {
-        user.push(n);
-      }
-    }
-    data.name = user;
-    return await this.model.create(data);
-  }
-
-
-  async delete({ name }) {
-    await this.model.findByIdAndDelete(name);
-    return 'deleted';
-  }
-
-  async update({ name }, data) {
-    const { filepath, create_time } = data;
-    const res = await this.model.findById(name);
-    // const res = await this.model.update({ _id: ObjectId(id) }, data);
-    if (name) {
-      res.name = name;
-    }
-    if (filepath) {
-      res.filepath = filepath;
-    }
-    if (create_time) {
-      res.create_time = create_time;
-    }
-    return await res.save();
-  }
-
-  async query({ name }) {
-    const res = await this.model.findByIdAndDelete(name);
+  async index(data) {
+    const create_time = moment().format('YYYY-MM-DD');
+    const res = await this.model.create({ ...data, create_time });
     return res;
   }
 }

+ 1 - 49
app/service/product.js

@@ -9,57 +9,9 @@ const { BusinessError, ErrorCode } = require('naf-core').Error;
 class ProductService extends CrudService {
   constructor(ctx) {
     super(ctx, 'product');
-    this.model = this.ctx.model.Lunbo;
-    // this.umodel = this.ctx.model.User;
+    this.model = this.ctx.model.Product;
   }
 
-  async create(data) {
-    const { name } = data;
-    assert(name, '名称不能为空');
-    // assert(filepath, "路径不能为空");
-    // assert(create_time, "时间不能为空");
-    const user = [];
-    for (const elm of name) {
-      const n = await this.model.findById(elm);
-      if (n) {
-        user.push(n);
-      }
-    }
-    data.name = user;
-    return await this.model.create(data);
-  }
-
-  async delete({ name }) {
-    await this.model.findByIdAndDelete(name);
-    return 'deleted';
-  }
-
-  async update({ name }, data) {
-    const { filepath, create_time, content, brief } = data;
-    const res = await this.model.findById(name);
-    // const res = await this.model.update({ _id: ObjectId(id) }, data);
-    if (name) {
-      res.name = name;
-    }
-    if (filepath) {
-      res.filepath = filepath;
-    }
-    if (create_time) {
-      res.create_time = create_time;
-    }
-    if (content) {
-      res.content = content;
-    }
-    if (brief) {
-      res.brief = brief;
-    }
-    return await res.save();
-  }
-
-  async query({ name }) {
-    const res = await this.model.findByIdAndDelete(name);
-    return res;
-  }
 }
 
 module.exports = ProductService;

+ 7 - 58
app/service/video.js

@@ -1,68 +1,17 @@
-"use strict";
+'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;
+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 VideoService extends CrudService {
   constructor(ctx) {
-    super(ctx, "video");
+    super(ctx, 'video');
     this.model = this.ctx.model.Video;
     // this.umodel = this.ctx.model.User;
   }
-
-  async create(data) {
-    const { name } = data;
-    assert(name, "名称不能为空");
-    // assert(filepath, "路径不能为空");
-    // assert(create_time, "时间不能为空");
-    const user = [];
-    for (const elm of name) {
-      const n = await this.model.findById(elm);
-      if (n) {
-        user.push(n);
-      }
-    }
-    data.name = user;
-    return await this.model.create(data);
-  }
-
-  async delete({ name }) {
-    await this.model.findByIdAndDelete(name);
-    return "deleted";
-  }
-
-  async update({ name }, data) {
-    const { videopath, create_time } = data;
-    const res = await this.model.findById(name);
-    // const res = await this.model.update({ _id: ObjectId(id) }, data);
-    if (name) {
-      res.name = name;
-    }
-    if (videopath) {
-      res.filepath = videopath;
-    }
-    if (create_time) {
-      res.create_time = create_time;
-    }
-    // if (content) {
-    //   res.content = content;
-    // }
-    // if (brief) {
-    //   res.brief = brief;
-    // }
-    // if (type) {
-    //   res.type = type;
-    // }
-    return await res.save();
-  }
-
-  async query({ name }) {
-    const res = await this.model.findByIdAndDelete(name);
-    return res;
-  }
 }
 
 module.exports = VideoService;