guhongwei 4 years ago
parent
commit
20bcdad9ce

+ 4 - 7
app/controller/.test.js

@@ -1,6 +1,6 @@
 module.exports = {
   create: {
-    requestBody: ["!name", "mobile", "qqwx", "email", "address"],
+    requestBody: ["!title", "site"],
   },
   destroy: {
     params: ["!id"],
@@ -8,7 +8,7 @@ module.exports = {
   },
   update: {
     params: ["!id"],
-    requestBody: ["!name", "mobile", "qqwx", "email", "address"],
+    requestBody: ["title", "site"],
   },
   show: {
     parameters: {
@@ -19,11 +19,8 @@ module.exports = {
   index: {
     parameters: {
       query: {
-        name: "name",
-        mobile: "mobile",
-        qqwx: "qqwx",
-        email: "email",
-        address: "address",
+        title: "title",
+        site: "site",
       },
     },
     service: "query",

+ 58 - 0
app/controller/.connews.js

@@ -0,0 +1,58 @@
+module.exports = {
+  create: {
+    requestBody: [
+      "!column_id",
+      "column_name",
+      "!title",
+      "brief",
+      "orgin",
+      "create_time",
+      "picture",
+      "content",
+    ],
+  },
+  destroy: {
+    params: ["!id"],
+    service: "delete",
+  },
+  update: {
+    params: ["!id"],
+    requestBody: [
+      "column_id",
+      "column_name",
+      "!title",
+      "brief",
+      "orgin",
+      "create_time",
+      "picture",
+      "content",
+    ],
+  },
+  show: {
+    parameters: {
+      params: ["!id"],
+    },
+    service: "fetch",
+  },
+  index: {
+    parameters: {
+      query: {
+        column_id: "column_id",
+        column_name: "column_name",
+        title: "title",
+        brief: "brief",
+        orgin: "orgin",
+        create_time: "create_time",
+        picture: "picture",
+        content: "content",
+      },
+    },
+    service: "query",
+    options: {
+      query: ["skip", "limit"],
+      sort: ["meta.createdAt"],
+      desc: true,
+      count: true,
+    },
+  },
+};

+ 35 - 0
app/controller/.links.js

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

+ 35 - 0
app/controller/.siteinfo.js

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

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

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

+ 58 - 0
app/controller/.trainnews.js

@@ -0,0 +1,58 @@
+module.exports = {
+  create: {
+    requestBody: [
+      "!column_id",
+      "column_name",
+      "!title",
+      "brief",
+      "orgin",
+      "create_time",
+      "picture",
+      "content",
+    ],
+  },
+  destroy: {
+    params: ["!id"],
+    service: "delete",
+  },
+  update: {
+    params: ["!id"],
+    requestBody: [
+      "column_id",
+      "column_name",
+      "!title",
+      "brief",
+      "orgin",
+      "create_time",
+      "picture",
+      "content",
+    ],
+  },
+  show: {
+    parameters: {
+      params: ["!id"],
+    },
+    service: "fetch",
+  },
+  index: {
+    parameters: {
+      query: {
+        column_id: "column_id",
+        column_name: "column_name",
+        title: "title",
+        brief: "brief",
+        orgin: "orgin",
+        create_time: "create_time",
+        picture: "picture",
+        content: "content",
+      },
+    },
+    service: "query",
+    options: {
+      query: ["skip", "limit"],
+      sort: ["meta.createdAt"],
+      desc: true,
+      count: true,
+    },
+  },
+};

+ 16 - 0
app/controller/concolumn.js

@@ -0,0 +1,16 @@
+'use strict';
+
+// const _ = require('lodash');
+const meta = require('./.concolumn.js');
+const Controller = require('egg').Controller;
+const { CrudController } = require('naf-framework-mongoose/lib/controller');
+
+// 站点信息表
+class ConcolumnController extends Controller {
+  constructor(ctx) {
+    super(ctx);
+    this.service = this.ctx.service.concolumn;
+  }
+}
+
+module.exports = CrudController(ConcolumnController, meta);

+ 16 - 0
app/controller/connews.js

@@ -0,0 +1,16 @@
+'use strict';
+
+// const _ = require('lodash');
+const meta = require('./.connews.js');
+const Controller = require('egg').Controller;
+const { CrudController } = require('naf-framework-mongoose/lib/controller');
+
+// 科技咨询信息表
+class ConnewsController extends Controller {
+  constructor(ctx) {
+    super(ctx);
+    this.service = this.ctx.service.connews;
+  }
+}
+
+module.exports = CrudController(ConnewsController, meta);

+ 5 - 5
app/controller/test.js

@@ -1,16 +1,16 @@
 'use strict';
 
 // const _ = require('lodash');
-const meta = require('./.test.js');
+const meta = require('./.links.js');
 const Controller = require('egg').Controller;
 const { CrudController } = require('naf-framework-mongoose/lib/controller');
 
-// 测试
-class TestController extends Controller {
+// 站点信息
+class LinksController extends Controller {
   constructor(ctx) {
     super(ctx);
-    this.service = this.ctx.service.test;
+    this.service = this.ctx.service.links;
   }
 }
 
-module.exports = CrudController(TestController, meta);
+module.exports = CrudController(LinksController, meta);

+ 16 - 0
app/controller/siteinfo.js

@@ -0,0 +1,16 @@
+'use strict';
+
+// const _ = require('lodash');
+const meta = require('./.siteinfo.js');
+const Controller = require('egg').Controller;
+const { CrudController } = require('naf-framework-mongoose/lib/controller');
+
+// 站点信息表
+class SiteinfoController extends Controller {
+  constructor(ctx) {
+    super(ctx);
+    this.service = this.ctx.service.siteinfo;
+  }
+}
+
+module.exports = CrudController(SiteinfoController, meta);

+ 16 - 0
app/controller/traincolumn.js

@@ -0,0 +1,16 @@
+'use strict';
+
+// const _ = require('lodash');
+const meta = require('./.traincolumn.js');
+const Controller = require('egg').Controller;
+const { CrudController } = require('naf-framework-mongoose/lib/controller');
+
+// 站点信息表
+class TraincolumnController extends Controller {
+  constructor(ctx) {
+    super(ctx);
+    this.service = this.ctx.service.traincolumn;
+  }
+}
+
+module.exports = CrudController(TraincolumnController, meta);

+ 16 - 0
app/controller/trainnews.js

@@ -0,0 +1,16 @@
+'use strict';
+
+// const _ = require('lodash');
+const meta = require('./.trainnews.js');
+const Controller = require('egg').Controller;
+const { CrudController } = require('naf-framework-mongoose/lib/controller');
+
+// 科技培训信息表
+class TrainnewsController extends Controller {
+  constructor(ctx) {
+    super(ctx);
+    this.service = this.ctx.service.trainnews;
+  }
+}
+
+module.exports = CrudController(TrainnewsController, meta);

+ 17 - 0
app/model/concolumn.js

@@ -0,0 +1,17 @@
+'use strict';
+const Schema = require('mongoose').Schema;
+const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
+// 科技咨询栏目表
+const ConcolumnSchema = {
+  title: { type: String, required: true, maxLength: 300 }, // 标题
+  site: { type: String, required: false, maxLength: 300 }, // 位置
+};
+
+const schema = new Schema(ConcolumnSchema, { toJSON: { virtuals: true } });
+schema.index({ id: 1 });
+schema.plugin(metaPlugin);
+
+module.exports = app => {
+  const { mongoose } = app;
+  return mongoose.model('Concolumn', schema, 'concolumn');
+};

+ 23 - 0
app/model/connews.js

@@ -0,0 +1,23 @@
+'use strict';
+const Schema = require('mongoose').Schema;
+const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
+// 科技培训信息表
+const TrainnewsSchema = {
+  column_id: { type: String, required: false, maxLength: 200 }, // 栏目id
+  column_name: { type: String, required: false, maxLength: 200 }, // 栏目名称
+  title: { type: String, required: true, maxLength: 500 }, // 标题
+  brief: { type: String, required: false, maxLength: 500 }, // 标题简介
+  orgin: { type: String, required: false, maxLength: 200 }, // 来源
+  create_time: { type: String, required: false, maxLength: 200 }, // 发布时间
+  picture: { type: String, required: false }, // 图片路径
+  content: { type: String, required: false }, // 正文
+};
+
+const schema = new Schema(TrainnewsSchema, { toJSON: { virtuals: true } });
+schema.index({ id: 1 });
+schema.plugin(metaPlugin);
+
+module.exports = app => {
+  const { mongoose } = app;
+  return mongoose.model('Trainnews', schema, 'trainnews');
+};

+ 18 - 0
app/model/links.js

@@ -0,0 +1,18 @@
+'use strict';
+const Schema = require('mongoose').Schema;
+const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
+// 友情链接表
+const LinksSchema = {
+  title: { type: String, required: true, maxLength: 200 }, // 名称
+  pic: { type: String, required: false, maxLength: 200 }, // 图片
+  url: { type: String, required: false, maxLength: 200 }, // 地址
+};
+
+const schema = new Schema(LinksSchema, { toJSON: { virtuals: true } });
+schema.index({ id: 1 });
+schema.plugin(metaPlugin);
+
+module.exports = app => {
+  const { mongoose } = app;
+  return mongoose.model('Links', schema, 'links');
+};

+ 18 - 0
app/model/siteinfo.js

@@ -0,0 +1,18 @@
+'use strict';
+const Schema = require('mongoose').Schema;
+const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
+// 站点信息表
+const SiteinfoSchema = {
+  title: { type: String, required: true, maxLength: 300 }, // 标题
+  engtitle: { type: String, required: false, maxLength: 300 }, // 英文名称
+  footinfo: { type: String, required: false, maxLength: 500 }, // 底部信息
+};
+
+const schema = new Schema(SiteinfoSchema, { toJSON: { virtuals: true } });
+schema.index({ id: 1 });
+schema.plugin(metaPlugin);
+
+module.exports = app => {
+  const { mongoose } = app;
+  return mongoose.model('Siteinfo', schema, 'siteinfo');
+};

+ 0 - 20
app/model/test.js

@@ -1,20 +0,0 @@
-'use strict';
-const Schema = require('mongoose').Schema;
-const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
-// 测试接口
-const TestSchema = {
-  name: { type: String, required: true, maxLength: 200 }, // 姓名
-  mobile: { type: String, required: true, maxLength: 200 }, // 电话
-  qqwx: { type: String, required: true, maxLength: 200 }, // qq/微信
-  email: { type: String, required: true, maxLength: 200 }, // 电子邮箱
-  address: { type: String, required: true, maxLength: 200 }, // 联系地址
-};
-
-const schema = new Schema(TestSchema, { toJSON: { virtuals: true } });
-schema.index({ id: 1 });
-schema.plugin(metaPlugin);
-
-module.exports = app => {
-  const { mongoose } = app;
-  return mongoose.model('Test', schema, 'test');
-};

+ 17 - 0
app/model/traincolumn.js

@@ -0,0 +1,17 @@
+'use strict';
+const Schema = require('mongoose').Schema;
+const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
+// 科技培训栏目表
+const TraincolumnSchema = {
+  title: { type: String, required: true, maxLength: 300 }, // 标题
+  site: { type: String, required: false, maxLength: 300 }, // 位置
+};
+
+const schema = new Schema(TraincolumnSchema, { toJSON: { virtuals: true } });
+schema.index({ id: 1 });
+schema.plugin(metaPlugin);
+
+module.exports = app => {
+  const { mongoose } = app;
+  return mongoose.model('Traincolumn', schema, 'traincolumn');
+};

+ 23 - 0
app/model/trainnews.js

@@ -0,0 +1,23 @@
+'use strict';
+const Schema = require('mongoose').Schema;
+const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
+// 科技咨询信息表
+const ConnewsSchema = {
+  column_id: { type: String, required: false, maxLength: 200 }, // 栏目id
+  column_name: { type: String, required: false, maxLength: 200 }, // 栏目名称
+  title: { type: String, required: true, maxLength: 500 }, // 标题
+  brief: { type: String, required: false, maxLength: 500 }, // 标题简介
+  orgin: { type: String, required: false, maxLength: 200 }, // 来源
+  create_time: { type: String, required: false, maxLength: 200 }, // 发布时间
+  picture: { type: String, required: false }, // 图片路径
+  content: { type: String, required: false }, // 正文
+};
+
+const schema = new Schema(ConnewsSchema, { toJSON: { virtuals: true } });
+schema.index({ id: 1 });
+schema.plugin(metaPlugin);
+
+module.exports = app => {
+  const { mongoose } = app;
+  return mongoose.model('Connews', schema, 'connews');
+};

+ 18 - 3
app/router.js

@@ -5,7 +5,22 @@
  */
 module.exports = app => {
   const { router, controller } = app;
-  // 測試
-  router.resources('test', '/api/study/test', controller.test); // index、create、show、destroy
-  router.post('test', '/api/study/test/update/:id', controller.test.update);
+  // 站点信息表
+  router.resources('siteinfo', '/api/servicealtai/siteinfo', controller.siteinfo); // index、create、show、destroy
+  router.post('siteinfo', '/api/servicealtai/siteinfo/update/:id', controller.siteinfo.update);
+  // 友情链接表
+  router.resources('links', '/api/servicealtai/links', controller.links); // index、create、show、destroy
+  router.post('links', '/api/servicealtai/links/update/:id', controller.links.update);
+  // 科技咨询栏目表
+  router.resources('concolumn', '/api/servicealtai/concolumn', controller.concolumn); // index、create、show、destroy
+  router.post('concolumn', '/api/servicealtai/concolumn/update/:id', controller.concolumn.update);
+  // 科技咨询信息表
+  router.resources('connews', '/api/servicealtai/connews', controller.connews); // index、create、show、destroy
+  router.post('connews', '/api/servicealtai/connews/update/:id', controller.connews.update);
+  // 科技培训栏目表
+  router.resources('traincolumn', '/api/servicealtai/traincolumn', controller.traincolumn); // index、create、show、destroy
+  router.post('traincolumn', '/api/servicealtai/traincolumn/update/:id', controller.traincolumn.update);
+  // 科技培训信息表
+  router.resources('trainnews', '/api/servicealtai/trainnews', controller.trainnews); // index、create、show、destroy
+  router.post('trainnews', '/api/servicealtai/trainnews/update/:id', controller.trainnews.update);
 };

+ 5 - 5
app/service/test.js

@@ -4,13 +4,13 @@ const assert = require('assert');
 const _ = require('lodash');
 const { ObjectId } = require('mongoose').Types;
 const { CrudService } = require('naf-framework-mongoose/lib/service');
-const { TestError, ErrorCode } = require('naf-core').Error;
+const { SiteinfoError, ErrorCode } = require('naf-core').Error;
 
-class TestService extends CrudService {
+class SiteinfoService extends CrudService {
   constructor(ctx) {
-    super(ctx, 'test');
-    this.model = this.ctx.model.Test;
+    super(ctx, 'siteinfo');
+    this.model = this.ctx.model.Siteinfo;
   }
 }
 
-module.exports = TestService;
+module.exports = SiteinfoService;

+ 4 - 4
config/config.default.js

@@ -26,11 +26,11 @@ module.exports = appInfo => {
   // add your config here
   config.cluster = {
     listen: {
-      port: 9091,
+      port: 8090,
     },
   };
   config.mongoose = {
-    url: 'mongodb://localhost:27017/study',
+    url: 'mongodb://localhost:27017/servicealtai',
     options: {
       // user: 'admin',
       // pass: 'admin',
@@ -42,8 +42,8 @@ module.exports = appInfo => {
 
   config.jwt = {
     ...jwt,
-    expiresIn: '1d',
-    issuer: 'study',
+    expiresIn: "1d",
+    issuer: "servicealtai",
   };
 
   // config.amqp = {

+ 1 - 1
config/config.local.js

@@ -9,7 +9,7 @@ module.exports = () => {
   };
 
   config.mongoose = {
-    url: 'mongodb://localhost:27017/study',
+    url: 'mongodb://localhost:27017/servicealtai',
     options: {
       // user: 'demo',
       // pass: 'demo',

+ 1 - 1
config/config.prod.js

@@ -10,7 +10,7 @@ module.exports = () => {
 
   // mongoose config
   config.mongoose = {
-    url: 'mongodb://localhost:27017/study',
+    url: 'mongodb://localhost:27017/servicealtai',
     options: {
       // user: "admin",
       // pass: "admin",