lrf %!s(int64=2) %!d(string=hai) anos
pai
achega
82032aa9fe
Modificáronse 3 ficheiros con 25 adicións e 11 borrados
  1. 2 1
      app/model/system/platformAct.js
  2. 9 9
      app/model/user/user.js
  3. 14 1
      app/service/system/platformAct.js

+ 2 - 1
app/model/system/platformAct.js

@@ -16,11 +16,12 @@ const platformAct = {
   content: { type: Object, required: false, zh: '活动说明' }, // 富文本;value:值;is_use:字典(is_use)是否启用,title:活动标题
   is_use: { type: String, required: false, default: '1', zh: '是否开启' }, // 字典:is_use,默认不开启
   show_index: { type: String, required: false, default: '0', zh: '是否在首页显示' }, // 字典:is_use
+  sort: { type: Number, required: false, default: 0, zh: '排序' }, //
 };
 const schema = new Schema(platformAct, { toJSON: { getters: true, virtuals: true } });
 schema.index({ id: 1 });
 schema.index({ 'meta.createdAt': 1 });
-// schema.index({ title: 1 });
+schema.index({ sort: 1 });
 schema.index({ is_use: 1 });
 schema.index({ show_index: 1 });
 

+ 9 - 9
app/model/user/user.js

@@ -6,15 +6,15 @@ const { Secret } = require('naf-framework-mongoose-free/lib/model/schema');
 
 // 顾客
 const user = {
-  name: { type: String, required: false, zh: "用户名" }, //
-  phone: { type: String, required: false, zh: "手机号" }, //
-  password: { type: Secret, required: false, select: false, zh: "密码" }, //
-  icon: { type: Array, required: false, zh: "头像" }, //
-  birth: { type: String, required: false, zh: "生日" }, //
-  gender: { type: String, required: false, zh: "性别" }, // 字典:gender
-  email: { type: String, required: false, zh: "电子邮箱" }, //
-  openid: { type: String, required: false, zh: "微信小程序" }, //
-  status: { type: String, required: false, default: "0", zh: "状态" }, // 字典statusr_status
+  name: { type: String, required: false, zh: '用户名' }, //
+  phone: { type: String, required: false, zh: '手机号' }, //
+  password: { type: Secret, required: false, select: false, zh: '密码' }, //
+  icon: { type: Array, required: false, zh: '头像' }, //
+  birth: { type: String, required: false, zh: '生日' }, //
+  gender: { type: String, required: false, zh: '性别' }, // 字典:gender
+  email: { type: String, required: false, zh: '电子邮箱' }, //
+  openid: { type: String, required: false, zh: '微信小程序' }, //
+  status: { type: String, required: false, default: '0', zh: '状态' }, // 字典statusr_status
 };
 const schema = new Schema(user, { toJSON: { getters: true, virtuals: true } });
 schema.index({ id: 1 });

+ 14 - 1
app/service/system/platformAct.js

@@ -4,12 +4,25 @@ const { BusinessError, ErrorCode } = require('naf-core').Error;
 const _ = require('lodash');
 const assert = require('assert');
 
-// 
+//
 class PlatformActService extends CrudService {
   constructor(ctx) {
     super(ctx, 'platformact');
     this.model = this.ctx.model.System.PlatformAct;
   }
+  async query(filter, { skip = 0, limit, projection } = {}) {
+    let condition = _.cloneDeep(filter);
+    condition = await this.beforeQuery(condition);
+    condition = this.dealFilter(condition);
+    // 过滤出ref字段
+    const { populate } = this.getRefMods();
+    // 带ref查询
+    let rs = await this.model.find(condition, projection, { skip, limit, sort: { sort: 1, 'meta.createdAt': -1 } }).populate(populate).exec();
+    rs = JSON.parse(JSON.stringify(rs));
+    // 整理ref数据
+    rs = await this.afterQuery(filter, rs);
+    return rs;
+  }
 }
 
 module.exports = PlatformActService;