asd123a20 3 jaren geleden
bovenliggende
commit
5d1451c8dd

+ 3 - 0
app/model/Banner.js

@@ -23,6 +23,9 @@ module.exports = app => {
     annex: {
     annex: {
       type: String,
       type: String,
     },
     },
+    annexname: {
+      type: String,
+    },
     // 内容
     // 内容
     content: {
     content: {
       type: String,
       type: String,

+ 3 - 0
app/model/Content.js

@@ -23,6 +23,9 @@ module.exports = app => {
     annex: {
     annex: {
       type: String,
       type: String,
     },
     },
+    annexname: {
+      type: String,
+    },
     // 内容
     // 内容
     content: {
     content: {
       type: String,
       type: String,

+ 4 - 0
app/model/Files.js

@@ -19,6 +19,10 @@ module.exports = app => {
     id: {
     id: {
       type: String,
       type: String,
     },
     },
+    // 创建时间
+    createAt: {
+      type: String,
+    },
   });
   });
   return mongoose.model('Files', FilesSchema);
   return mongoose.model('Files', FilesSchema);
 };
 };

+ 3 - 0
app/model/Page.js

@@ -19,6 +19,9 @@ module.exports = app => {
     annex: {
     annex: {
       type: String,
       type: String,
     },
     },
+    annexname: {
+      type: String,
+    },
     // 内容
     // 内容
     content: {
     content: {
       type: String,
       type: String,

+ 4 - 4
app/service/banner.js

@@ -4,7 +4,7 @@ const Service = require('egg').Service;
 const assert = require('assert');
 const assert = require('assert');
 const moment = require('moment');
 const moment = require('moment');
 class ContentService extends Service {
 class ContentService extends Service {
-  async create({ title, shortTitle, slug, path, annex, content }) {
+  async create({ title, shortTitle, slug, path, annex, content, annexname }) {
     assert(title, '标题不存在');
     assert(title, '标题不存在');
     assert(shortTitle, '短标题不存在');
     assert(shortTitle, '短标题不存在');
     assert(slug, '摘要不存在');
     assert(slug, '摘要不存在');
@@ -13,18 +13,18 @@ class ContentService extends Service {
     const { Banner: model } = this.ctx.model;
     const { Banner: model } = this.ctx.model;
     const createAt = moment().format('x');
     const createAt = moment().format('x');
     try {
     try {
-      await model.create({ title, shortTitle, slug, path, annex, content, createAt });
+      await model.create({ title, shortTitle, slug, path, annex, content, createAt, annexname });
       return { errmsg: '', errcode: 0 };
       return { errmsg: '', errcode: 0 };
     } catch (error) {
     } catch (error) {
       console.log(error);
       console.log(error);
       throw new Error({ errcode: -2001, errmsg: '添加失败' });
       throw new Error({ errcode: -2001, errmsg: '添加失败' });
     }
     }
   }
   }
-  async update({ title, shortTitle, slug, path, annex, content, istop, _id }) {
+  async update({ title, shortTitle, slug, path, annex, content, istop, _id, annexname }) {
     assert(_id, 'id不存在');
     assert(_id, 'id不存在');
     const { Banner: model } = this.ctx.model;
     const { Banner: model } = this.ctx.model;
     try {
     try {
-      await model.findById(_id).update({ title, shortTitle, slug, path, annex, content, istop });
+      await model.findById(_id).update({ title, shortTitle, slug, path, annex, content, istop, annexname });
       return { errmsg: '', errcode: 0 };
       return { errmsg: '', errcode: 0 };
     } catch (error) {
     } catch (error) {
       throw new Error({ errcode: -2001, errmsg: '修改失败' });
       throw new Error({ errcode: -2001, errmsg: '修改失败' });

+ 2 - 0
app/service/column.js

@@ -11,6 +11,8 @@ class ColumnService extends Service {
     const { Column: model } = this.ctx.model;
     const { Column: model } = this.ctx.model;
     const createAt = moment().format('x');
     const createAt = moment().format('x');
     try {
     try {
+      const isdata = model.find(code);
+      if (isdata.length > 0) return { errmsg: '编码已存在', errcode: -2001 };
       await model.create({ name, code, menuList, createAt });
       await model.create({ name, code, menuList, createAt });
       return { errmsg: '', errcode: 0 };
       return { errmsg: '', errcode: 0 };
     } catch (error) {
     } catch (error) {

+ 4 - 4
app/service/content.js

@@ -4,7 +4,7 @@ const Service = require('egg').Service;
 const assert = require('assert');
 const assert = require('assert');
 const moment = require('moment');
 const moment = require('moment');
 class ContentService extends Service {
 class ContentService extends Service {
-  async create({ title, shortTitle, slug, thumbnail, annex, content, istop, columnList, year, datte }) {
+  async create({ title, shortTitle, slug, thumbnail, annex, content, istop, columnList, year, datte, annexname }) {
     assert(title, '标题不存在');
     assert(title, '标题不存在');
     assert(shortTitle, '短标题不存在');
     assert(shortTitle, '短标题不存在');
     assert(slug, '摘要不存在');
     assert(slug, '摘要不存在');
@@ -13,17 +13,17 @@ class ContentService extends Service {
     const { Content: model } = this.ctx.model;
     const { Content: model } = this.ctx.model;
     const createAt = moment().format('x');
     const createAt = moment().format('x');
     try {
     try {
-      await model.create({ title, shortTitle, slug, thumbnail, annex, content, istop, columnList, createAt, year, datte });
+      await model.create({ title, shortTitle, slug, thumbnail, annex, content, istop, columnList, createAt, year, datte, annexname });
       return { errmsg: '', errcode: 0 };
       return { errmsg: '', errcode: 0 };
     } catch (error) {
     } catch (error) {
       throw new Error({ errcode: -2001, errmsg: '添加失败' });
       throw new Error({ errcode: -2001, errmsg: '添加失败' });
     }
     }
   }
   }
-  async update({ title, shortTitle, slug, thumbnail, annex, content, istop, columnList, _id, year, datte }) {
+  async update({ title, shortTitle, slug, thumbnail, annex, content, istop, columnList, _id, year, datte, annexname }) {
     assert(_id, 'id不存在');
     assert(_id, 'id不存在');
     const { Content: model } = this.ctx.model;
     const { Content: model } = this.ctx.model;
     try {
     try {
-      await model.findById(_id).update({ title, shortTitle, slug, thumbnail, annex, content, istop, columnList, year, datte });
+      await model.findById(_id).update({ title, shortTitle, slug, thumbnail, annex, content, istop, columnList, year, datte, annexname });
       return { errmsg: '', errcode: 0 };
       return { errmsg: '', errcode: 0 };
     } catch (error) {
     } catch (error) {
       throw new Error({ errcode: -2001, errmsg: '修改失败' });
       throw new Error({ errcode: -2001, errmsg: '修改失败' });

+ 1 - 1
app/service/files.js

@@ -13,7 +13,7 @@ class FilesService extends Service {
     assert(path, '路径不存在');
     assert(path, '路径不存在');
     assert(type, '类型不存在');
     assert(type, '类型不存在');
     const { Files: model } = this.ctx.model;
     const { Files: model } = this.ctx.model;
-    const createAt = moment().format('x');
+    const createAt = moment().format('YYYY-MM-DD HH:mm:ss');
     try {
     try {
       await model.create({ name, path, type, createAt });
       await model.create({ name, path, type, createAt });
       return { errmsg: '', errcode: 0 };
       return { errmsg: '', errcode: 0 };

+ 2 - 0
app/service/menu.js

@@ -13,6 +13,8 @@ class MenuService extends Service {
     const { Menu: model } = this.ctx.model;
     const { Menu: model } = this.ctx.model;
     const createAt = moment().format('x');
     const createAt = moment().format('x');
     try {
     try {
+      const isdata = model.find(code);
+      if (isdata.length > 0) return { errmsg: '编码已存在', errcode: -2001 };
       await model.create({ name, code, createAt, state, type, uri, en });
       await model.create({ name, code, createAt, state, type, uri, en });
       return { errmsg: '', errcode: 0 };
       return { errmsg: '', errcode: 0 };
     } catch (error) {
     } catch (error) {

+ 4 - 4
app/service/page.js

@@ -4,7 +4,7 @@ const Service = require('egg').Service;
 const assert = require('assert');
 const assert = require('assert');
 const moment = require('moment');
 const moment = require('moment');
 class PageService extends Service {
 class PageService extends Service {
-  async create({ title, shortTitle, slug, annex, content, istop, menu }) {
+  async create({ title, shortTitle, slug, annex, content, istop, menu, annexname }) {
     assert(title, '标题不存在');
     assert(title, '标题不存在');
     assert(shortTitle, '短标题不存在');
     assert(shortTitle, '短标题不存在');
     assert(slug, '摘要不存在');
     assert(slug, '摘要不存在');
@@ -13,17 +13,17 @@ class PageService extends Service {
     const { Page: model } = this.ctx.model;
     const { Page: model } = this.ctx.model;
     const createAt = moment().format('x');
     const createAt = moment().format('x');
     try {
     try {
-      await model.create({ title, shortTitle, slug, annex, content, istop, menu, createAt });
+      await model.create({ title, shortTitle, slug, annex, content, istop, menu, createAt, annexname });
       return { errmsg: '', errcode: 0 };
       return { errmsg: '', errcode: 0 };
     } catch (error) {
     } catch (error) {
       throw new Error({ errcode: -2001, errmsg: '添加失败' });
       throw new Error({ errcode: -2001, errmsg: '添加失败' });
     }
     }
   }
   }
-  async update({ title, shortTitle, slug, annex, content, istop, menu, _id }) {
+  async update({ title, shortTitle, slug, annex, content, istop, menu, _id, annexname }) {
     assert(_id, 'id不存在');
     assert(_id, 'id不存在');
     const { Page: model } = this.ctx.model;
     const { Page: model } = this.ctx.model;
     try {
     try {
-      await model.findById(_id).update({ title, shortTitle, slug, annex, content, istop, menu });
+      await model.findById(_id).update({ title, shortTitle, slug, annex, content, istop, menu, annexname });
       return { errmsg: '', errcode: 0 };
       return { errmsg: '', errcode: 0 };
     } catch (error) {
     } catch (error) {
       throw new Error({ errcode: -2001, errmsg: '修改失败' });
       throw new Error({ errcode: -2001, errmsg: '修改失败' });