|
@@ -9,12 +9,16 @@ import {
|
|
|
import { User } from '../entity/User.entity';
|
|
|
import isEqual = require('lodash/isEqual');
|
|
|
import { LoginDTO } from '../interface/User.interface';
|
|
|
+import { Office } from '../entity/Office.entity';
|
|
|
type modelType = ReturnModelType<typeof User>;
|
|
|
@Provide()
|
|
|
export class UserService extends BaseService<modelType> {
|
|
|
@InjectEntityModel(User)
|
|
|
model: modelType;
|
|
|
|
|
|
+ @InjectEntityModel(Office)
|
|
|
+ offModel: ReturnModelType<typeof Office>;
|
|
|
+
|
|
|
async findUserToLogin(data: LoginDTO): Promise<object> {
|
|
|
const { tel, password } = data;
|
|
|
const user = await this.model.findOne({ tel }, '+password').lean();
|
|
@@ -56,4 +60,37 @@ export class UserService extends BaseService<modelType> {
|
|
|
);
|
|
|
return user;
|
|
|
}
|
|
|
+
|
|
|
+ async queryInfo(filter): Promise<object> {
|
|
|
+ const { skip = 0, limit, street, ...info } = filter;
|
|
|
+ let list: any = [];
|
|
|
+ let total: any = 0;
|
|
|
+ if (street) {
|
|
|
+ const res = await this.offModel.aggregate([
|
|
|
+ {
|
|
|
+ $match: { belong: street },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ $project: {
|
|
|
+ _id: {
|
|
|
+ $toString: '$_id',
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ ]);
|
|
|
+ const belongList: any = [
|
|
|
+ { street: street },
|
|
|
+ { role: 'jdry' },
|
|
|
+ { role: 'sqry' },
|
|
|
+ ];
|
|
|
+ for (const val of res) {
|
|
|
+ const info = { community: val._id };
|
|
|
+ belongList.push(info);
|
|
|
+ }
|
|
|
+ info.$or = belongList;
|
|
|
+ }
|
|
|
+ list = await this.model.find(info).skip(skip).limit(limit).lean();
|
|
|
+ total = await this.model.count(info);
|
|
|
+ return { list, total };
|
|
|
+ }
|
|
|
}
|