12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- 'use strict';
- /**
- * Created by LanJianRong on 2020/7/6.
- * 项目设置->显示设置表数据模型
- * @author LanJianRong
- * @date 2020/07/06
- * @version
- */
- const BaseService = require('../base/base_service');
- module.exports = app => {
- class settingShow extends BaseService {
- /**
- * 构造函数
- *
- * @param {Object} ctx - egg全局变量
- * @return {void}
- */
- constructor(ctx) {
- super(ctx);
- this.tableName = 'setting_show';
- }
- /**
- * 获取设置表所有记录
- * @return {Promise<void>} 查询结果集
- */
- async getList() {
- return await this.db.select(this.tableName);
- }
- /**
- * 设置默认显示字段
- * @param {Number} id 标签id
- * @return {Promise<void>} 查询结果集
- */
- async setDefaultLabel(id) {
- const record = await this.getDataByCondition({ is_default: 1 });
- if (!record) throw '该标签不存在';
- await this.update({ is_default: 0 }, { id: record.id });
- await this.update({ is_default: 1 }, { id });
- return await this.db.select(this.tableName);
- }
- /**
- * 返回项目默认打开的url
- * @return {String} path 默认url
- */
- async getDefaultPath() {
- return await this.getDataByCondition({ is_default: 1 });
- }
- }
- return settingShow;
- };
|