config.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
  4. const configProp = {
  5. logo: { type: Array, zh: 'logo' },
  6. share: { type: Array, zh: '分享图片' },
  7. buyPoint: { type: Number, zh: '购物赠送积分' }, // 金额 / buyPoint 为实际获得积分
  8. pointPlan: { type: Array, zh: '积分计划' }, // 后续有待制作,目前全靠新写
  9. autoCloseOrder: { type: Number, zh: '自动关闭订单时间' }, // <=0时不自动关闭
  10. };
  11. const bottom_menu = {
  12. list: { type: Array, zh: '菜单列表' },
  13. is_use: { type: String, zh: '是否使用' },
  14. };
  15. // 系统设置
  16. const config = {
  17. title: { type: String, required: false, zh: '系统名称' }, //
  18. config: { type: Object, required: false, zh: '设置' }, //
  19. agree: { type: String, required: false, zh: '用户协议' }, // 富文本
  20. bottom_title: { type: String, required: false, zh: '底部加载数据结束的文字提示' }, //
  21. bottom_menu: { type: Object, zh: '底部菜单' },
  22. reward_day: { type: Number, zh: '提现日期', default: 14 },
  23. leader: { type: Object, required: false , zh: '团长规则' }, // explain,rule
  24. };
  25. const schema = new Schema(config, { toJSON: { getters: true, virtuals: true } });
  26. schema.index({ id: 1 });
  27. schema.index({ 'meta.createdAt': 1 });
  28. schema.plugin(metaPlugin);
  29. module.exports = app => {
  30. const { mongoose } = app;
  31. return mongoose.model('Config', schema, 'config');
  32. };