瀏覽代碼

添加作者字段

asd123a20 2 年之前
父節點
當前提交
9bb452da41

+ 2 - 0
service-cms/app/model/content.js

@@ -37,6 +37,8 @@ const SchemaDefine = {
   keywords: { type: Array, required: false, default: [] },
   // 副标题
   curtTitle: { type: String, required: false },
+  // 作者
+  author: { type: String, required: false },
 };
 const schema = new Schema(SchemaDefine);
 module.exports = app => {

+ 6 - 7
service-cms/app/service/content.js

@@ -9,7 +9,7 @@ class ContentService extends Service {
     this.model = this.ctx.model.Content;
     this.menuModel = this.ctx.model.Menu;
   }
-  async create({ title, describe, source, content, bind, istop, date, thumbnail, recommend, annex, keywords, svip, isShow, status, curtTitle }) {
+  async create({ title, describe, source, content, bind, istop, date, thumbnail, recommend, annex, keywords, svip, isShow, status, curtTitle, author }) {
     assert(title, '标题不存在');
     // assert(describe, '描述不存在');
     assert(content, '内容不存在');
@@ -17,19 +17,19 @@ class ContentService extends Service {
     try {
       const createAt = moment().format('x');
       const updateAt = moment().format('x');
-      const item = await this.model.create({ title, describe, source, content, bind, istop, date, thumbnail, recommend, annex, createAt, updateAt, keywords, svip, isShow, status, curtTitle });
+      const item = await this.model.create({ title, describe, author, source, content, bind, istop, date, thumbnail, recommend, annex, createAt, updateAt, keywords, svip, isShow, status, curtTitle });
       return { errcode: 0, errmsg: '', data: item };
     } catch (error) {
       throw error;
     }
   }
-  async update({ id, title, describe, source, content, bind, istop, date, thumbnail, recommend, annex, keywords, svip, isShow, status, curtTitle }) {
+  async update({ id, title, describe, author, source, content, bind, istop, date, thumbnail, recommend, annex, keywords, svip, isShow, status, curtTitle }) {
     assert(id, 'id不存在');
     try {
       const res = await this.model.findOne({ _id: id });
       if (!res) return { errcode: -1001, errmsg: '数据不存在', data: '' };
       const updateAt = moment().format('x');
-      await this.model.updateOne({ _id: id }, { title, describe, source, content, bind, istop, date, thumbnail, recommend, annex, updateAt, keywords, svip, isShow, status, curtTitle });
+      await this.model.updateOne({ _id: id }, { title, describe, author, source, content, bind, istop, date, thumbnail, recommend, annex, updateAt, keywords, svip, isShow, status, curtTitle });
       return { errcode: 0, errmsg: '', data: 'update' };
     } catch (error) {
       throw error;
@@ -47,15 +47,14 @@ class ContentService extends Service {
     }
   }
   async query({ skip, limit, title, date, bind, keywords, svip, isShow, status, istop, parentCode }) {
-
     if (parentCode) {
       const menus = await this.service.menu.menuList({ code: parentCode });
       const filter = { bind: { $in: menus } };
       const total = await this.model.find({ ...filter }, { content: false });
       const res = await this.model.find({ ...filter }, { content: false })
+        .sort({ istop: -1, date: -1 })
         .skip(Number(skip) * Number(limit))
-        .limit(Number(limit))
-        .sort({ istop: -1, date: -1 });
+        .limit(Number(limit));
       return { errcode: 0, errmsg: '', data: res, total: total.length };
     }
 

+ 6 - 5
service-cms/config/config.default.js

@@ -37,12 +37,13 @@ module.exports = appInfo => {
   // 数据库配置
   config.mongoose = {
     url: 'mongodb://127.0.0.1/Microservices',
+    // url: 'mongodb://172.17.116.7/Microservices',
     options: {
-      user: 'root',
-      pass: 'Ziyouyanfa#@!',
-      authSource: 'admin',
-      useNewUrlParser: true,
-      useCreateIndex: true,
+      // user: 'root',
+      // pass: 'Ziyouyanfa#@!',
+      // authSource: 'admin',
+      // useNewUrlParser: true,
+      // useCreateIndex: true,
     },
   };
   return {

+ 1 - 1
service-code/config/config.default.js

@@ -35,7 +35,7 @@ module.exports = appInfo => {
   };
   // 数据库配置
   config.mongoose = {
-    url: 'mongodb://127.0.0.1/Microservices',
+    url: 'mongodb://172.17.116.7/Microservices',
     options: {
       user: 'root',
       pass: 'Ziyouyanfa#@!',

+ 1 - 1
service-files/config/config.default.js

@@ -37,7 +37,7 @@ module.exports = appInfo => {
   };
   // 数据库配置
   config.mongoose = {
-    url: 'mongodb://127.0.0.1/Microservices',
+    url: 'mongodb://172.17.116.7/Microservices',
     options: {
       user: 'root',
       pass: 'Ziyouyanfa#@!',

+ 1 - 1
service-log/config/config.default.js

@@ -36,7 +36,7 @@ module.exports = appInfo => {
   };
   // 数据库配置
   config.mongoose = {
-    url: 'mongodb://127.0.0.1/Microservices',
+    url: 'mongodb://172.17.116.7/Microservices',
     options: {
       user: 'root',
       pass: 'Ziyouyanfa#@!',

+ 1 - 1
service-login/config/config.default.js

@@ -36,7 +36,7 @@ module.exports = appInfo => {
   };
   // 数据库配置
   config.mongoose = {
-    url: 'mongodb://127.0.0.1/Microservices',
+    url: 'mongodb://172.17.116.7/Microservices',
     options: {
       user: 'root',
       pass: 'Ziyouyanfa#@!',

+ 1 - 1
service-naf/config/config.default.js

@@ -36,7 +36,7 @@ module.exports = appInfo => {
   };
   // 数据库配置
   config.mongoose = {
-    url: 'mongodb://127.0.0.1/Microservices',
+    url: 'mongodb://172.17.116.7/Microservices',
     options: {
       user: 'root',
       pass: 'Ziyouyanfa#@!',