Explorar el Código

增加首页标题配置

zhy hace 1 semana
padre
commit
a72bd429e4
Se han modificado 2 ficheros con 17 adiciones y 4 borrados
  1. 13 0
      app/model/Configuration.js
  2. 4 4
      app/service/configuration.js

+ 13 - 0
app/model/Configuration.js

@@ -47,6 +47,19 @@ module.exports = app => {
     isname: {
       type: String,
     },
+    // 是否显示首页标题
+    isShowTitle: {
+      type: Boolean,
+      default: false,
+    },
+    // 首页标题文字
+    homeTitle: {
+      type: String,
+    },
+    // 首页标题地址
+    homeUrl: {
+      type: String,
+    },
   });
   return mongoose.model('Configuration', ConfigurationSchema);
 };

+ 4 - 4
app/service/configuration.js

@@ -4,21 +4,21 @@ const Service = require('egg').Service;
 const assert = require('assert');
 const moment = require('moment');
 class ConfigurationService extends Service {
-  async create({ name, describe, company, phone, address, mail, postcode, record, path, isshow, isname }) {
+  async create({ name, describe, company, phone, address, mail, postcode, record, path, isshow, isname, isShowTitle, homeTitle, homeUrl }) {
     const { Configuration: model } = this.ctx.model;
     const createAt = moment().format('x');
     try {
-      await model.create({ name, describe, company, phone, address, mail, postcode, record, createAt, path, isshow, isname });
+      await model.create({ name, describe, company, phone, address, mail, postcode, record, createAt, path, isshow, isname, isShowTitle, homeTitle, homeUrl });
       return { errmsg: '', errcode: 0 };
     } catch (error) {
       throw new Error('添加失败');
     }
   }
-  async update({ name, describe, company, phone, address, mail, postcode, record, _id, path, isshow, isname }) {
+  async update({ name, describe, company, phone, address, mail, postcode, record, _id, path, isshow, isname, isShowTitle, homeTitle, homeUrl }) {
     assert(_id, 'id不存在');
     const { Configuration: model } = this.ctx.model;
     try {
-      await model.findById(_id).update({ name, describe, company, phone, address, mail, postcode, record, path, isshow, isname });
+      await model.findById(_id).update({ name, describe, company, phone, address, mail, postcode, record, path, isshow, isname, isShowTitle, homeTitle, homeUrl });
       return { errmsg: '', errcode: 0 };
     } catch (error) {
       throw new Error('修改失败');