Selaa lähdekoodia

提交修改路径,new新增site

nihao 5 vuotta sitten
vanhempi
commit
dd67c9abf7
5 muutettua tiedostoa jossa 17 lisäystä ja 9 poistoa
  1. 3 3
      app/controller/.news.js
  2. 1 1
      app/model/column.js
  3. 1 0
      app/model/news.js
  4. 8 3
      app/router.js
  5. 4 2
      app/service/news.js

+ 3 - 3
app/controller/.news.js

@@ -2,7 +2,7 @@ module.exports = {
   // 起草新闻
   "create": {
     "parameters": {
-      "query": ["!column"],
+      "query": ["!column", "site"],
     },
     "requestBody": ["!title", "!content", "picurl", "top", "tags", "attachment", "issuer"],
   },
@@ -40,7 +40,7 @@ module.exports = {
   // 后台查询新闻列表
   "query": {
     "parameters": {
-      "query": ["!column"],
+      "query": ["column","site"],
       "options": {
         "meta.state": 0, // 只显示未删除数据
       },
@@ -59,7 +59,7 @@ module.exports = {
   // 前台加载新闻列表
   "list": {
     "parameters": {
-      "query": ["!column"],
+      "query": ["column", "site"],
       "options": {
         "meta.state": 0, // 只显示未删除数据
       },

+ 1 - 1
app/model/column.js

@@ -15,7 +15,7 @@ const Attachment = new Schema({
 const SchemaDefine = {
   site: { type: String, required: true, maxLength: 64 }, // 归属站点
   moudle: { type: String, required: true, maxLength: 20 }, // 栏目模块
-  columnname: { type: String, required: true, maxLength: 100 }, // 栏目名称
+  columnname: { type: String, required: false, maxLength: 100 }, // 栏目名称
   picurl: { type: String, required: false, maxLength: 256 }, // 栏目图片URL
   description: { type: String, required: false, maxLength: 256 }, // 栏目描述
   inMenu: { type: String, required: false, maxLength: 5 }, // 是否在菜单中显示

+ 1 - 0
app/model/news.js

@@ -14,6 +14,7 @@ const Attachment = new Schema({
 // 新闻信息
 const SchemaDefine = {
   column: { type: String, required: true, maxLength: 64 }, // 栏目
+  site: { type: String, required: true, maxLength: 64 }, // 分站
   title: { type: String, required: true, maxLength: 128 }, // 标题
   content: { type: String, required: true, maxLength: 102400, select: false }, // 内容详情
   picurl: { type: String, required: false, maxLength: 256 }, // 标题图片URL

+ 8 - 3
app/router.js

@@ -9,14 +9,14 @@ module.exports = app => {
 
   // 网站数据接口
   router.get('/api/news/list', controller.news.list); // 新闻信息列表,隐藏删除信息,按照置顶和时间排序
-  router.get('/api/news/fetch', controller.news.fetch); // 获取新闻详情
+  router.get('/api/news/fetch/:id', controller.news.fetch); // 获取新闻详情
   router.get('/api/site/config', controller.site.config_get); // 获取站点基本信息
   router.get('/api/site/content', controller.site.content); // 获取站点详细信息(关于我们、联系方式)
   router.get('/api/site/list', controller.site.list); // 获取分站列表
   router.get('/api/column/list', controller.column.list); // 栏目列表,隐藏删除信息,按照置顶和时间排序
-  router.get('/api/column/fetch', controller.column.fetch); // 获取栏目详情
+  router.get('/api/column/fetch/:id', controller.column.fetch); // 获取栏目详情
   router.get('/api/menu/list', controller.menu.list); // 菜单列表,隐藏删除信息,按照置顶和时间排序
-  router.get('/api/menu/fetch', controller.menu.fetch); // 获取菜单详情
+  router.get('/api/menu/fetch/:id', controller.menu.fetch); // 获取菜单详情
 
   // 管理接口
   // 【分站】新闻接口
@@ -54,4 +54,9 @@ module.exports = app => {
   router.post('/adminapi/site/create', controller.site.create); // 发布分站信息
   router.post('/adminapi/site/update/:site', controller.site.update); // 修改分站信息
   router.post('/adminapi/site/delete/:site', controller.site.delete); // 删除分站信息
+
+  // 暂定为验证码测试接口
+  router.get('/adminapi/verify/verify', controller.verify.verify); // 生成验证码并保存
+  router.get('/adminapi/verify/sendmessage', controller.verify.sendmessage); // 生成验证码并保存
+
 };

+ 4 - 2
app/service/news.js

@@ -12,9 +12,10 @@ class NewsService extends CrudService {
     this.model = this.ctx.model.News;
   }
 
-  async create({ column }, { title, content, picurl, top, tags, attachment, issuer }) {
+  async create({ column, site }, { title,  content, picurl, top, tags, attachment, issuer }) {
     // 检查数据
     assert(_.isString(column), 'column不能为空');
+    assert(_.isString(site), 'site不能为空');
     assert(_.isString(title), 'title不能为空');
     assert(_.isString(content), 'content不能为空');
     assert(!picurl || _.isString(picurl), 'picurl必须为字符串');
@@ -29,7 +30,7 @@ class NewsService extends CrudService {
 
     // TODO:保存数据
     const data = {
-      column, title, content, picurl, top, tags, attachment, issuer,
+      site,column, title, content, picurl, top, tags, attachment, issuer,
       meta: { createdBy: userid },
     };
 
@@ -42,6 +43,7 @@ class NewsService extends CrudService {
     const { title, content, picurl, top, tags, attachment, issuer } = payload;
     assert(id, 'id不能为空');
     assert(!title || _.isString(title), 'title必须为字符串');
+    // assert(_.isString(site), 'site不能为空');
     assert(!content || _.isString(content), 'content必须为字符串');
     assert(!picurl || _.isString(picurl), 'picurl必须为字符串');
     assert(_.isUndefined(top) || _.isNumber(top), 'top必须为数字');