zs 1 năm trước cách đây
mục cha
commit
9162f794a1

+ 0 - 9
src/controller/User.controller.ts

@@ -109,15 +109,6 @@ export class UserController extends BaseController {
     return { data, total };
   }
 
-  @Get('/queryInfo')
-  @ApiQuery({ name: 'queryInfo' })
-  async queryInfo(@Query() filter: any) {
-    const list: any = await this.service.queryInfo(filter);
-    const data = list.list;
-    const total = list.total;
-    return { data, total };
-  }
-
   @Get('/openid')
   @ApiResponse({ type: FVO_User })
   async wxLogin(@Query('openid') openid: string) {

+ 8 - 36
src/interface/User.interface.ts

@@ -1,10 +1,6 @@
 import { Rule, RuleType } from '@midwayjs/validate';
 import { ApiProperty } from '@midwayjs/swagger';
-import {
-  FrameworkErrorEnum,
-  SearchBase,
-  ServiceError,
-} from 'free-midway-component';
+import { SearchBase } from 'free-midway-component';
 import get = require('lodash/get');
 const dealVO = (cla, data) => {
   for (const key in cla) {
@@ -40,7 +36,7 @@ export class FVO_User {
 
 export class QDTO_User extends SearchBase {
   constructor() {
-    const like_prop = [];
+    const like_prop = ['name'];
     const props = [
       'name',
       'tel',
@@ -81,35 +77,19 @@ export class QVO_User extends FVO_User {
 
 export class CDTO_User {
   @ApiProperty({ description: '姓名' })
-  @Rule(
-    RuleType['string']()
-      .required()
-      .error(new ServiceError('缺少姓名', FrameworkErrorEnum.NEED_BODY))
-  )
+  @Rule(RuleType['string']().empty(''))
   'name': string = undefined;
   @ApiProperty({ description: '联系电话' })
-  @Rule(
-    RuleType['string']()
-      .required()
-      .error(new ServiceError('缺少联系电话', FrameworkErrorEnum.NEED_BODY))
-  )
+  @Rule(RuleType['string']().empty(''))
   'tel': string = undefined;
   @ApiProperty({ description: '密码' })
   @Rule(RuleType['string']().empty(''))
   'password': string = undefined;
   @ApiProperty({ description: '性别' })
-  @Rule(
-    RuleType['string']()
-      .required()
-      .error(new ServiceError('缺少性别', FrameworkErrorEnum.NEED_BODY))
-  )
+  @Rule(RuleType['string']().empty(''))
   'gender': string = undefined;
   @ApiProperty({ description: '角色' })
-  @Rule(
-    RuleType['string']()
-      .required()
-      .error(new ServiceError('缺少角色', FrameworkErrorEnum.NEED_BODY))
-  )
+  @Rule(RuleType['string']().empty(''))
   'role': string = undefined;
   @ApiProperty({ description: '所属街道' })
   @Rule(RuleType['string']().empty(''))
@@ -118,18 +98,10 @@ export class CDTO_User {
   @Rule(RuleType['string']().empty(''))
   'community': string = undefined;
   @ApiProperty({ description: '微信id' })
-  @Rule(
-    RuleType['string']()
-      .required()
-      .error(new ServiceError('缺少微信id', FrameworkErrorEnum.NEED_BODY))
-  )
+  @Rule(RuleType['string']().empty(''))
   'openid': string = undefined;
   @ApiProperty({ description: '状态' })
-  @Rule(
-    RuleType['string']()
-      .required()
-      .error(new ServiceError('缺少状态', FrameworkErrorEnum.NEED_BODY))
-  )
+  @Rule(RuleType['string']().empty(''))
   'status': string = undefined;
 }
 

+ 6 - 14
src/service/Cart.service.ts

@@ -151,27 +151,19 @@ export class CartService extends BaseService<modelType> {
       if (result) {
         let res;
         obj.user = result._id;
-        if (result.community) {
-          ShopSetting = await this.shopModel.findOne({
-            office: result.community,
-            is_use: '0',
-          });
-          Collection = await this.collModel.findOne({
-            office: result.community,
-            is_use: '0',
-          });
-          res = await this.offModel.findById(result.community).lean();
-        } else if (result.street) {
+        if (result.street) {
           ShopSetting = await this.shopModel.findOne({
             office: result.street,
             is_use: '0',
           });
           Collection = await this.collModel.findOne({
-            office: result.community,
+            office: result.street,
             is_use: '0',
           });
-          res = await this.offModel.findById(result.street).lean();
-        } else assert(result.street, '缺少街道信息或社区信息!');
+          if (result.community) {
+            res = await this.offModel.findById(result.community).lean();
+          } else res = await this.offModel.findById(result.street).lean();
+        } else assert(result.street, '缺少街道信息!');
         if (res) obj.address = res.address;
         if (!ShopSetting) obj.status = '4';
         if (!Collection) obj.status = '8';

+ 4 - 4
src/service/OrderDetail.service.ts

@@ -179,7 +179,7 @@ export class OrderDetailService extends BaseService<modelType> {
       const sleader = [];
       for (const val of res.s_leader) {
         arr = await this.userModel.findById(val._id).lean();
-        sleader.push(arr.name);
+        if (arr) sleader.push(arr.name || '暂无');
       }
       info.sleader_name = sleader.toString();
     }
@@ -187,7 +187,7 @@ export class OrderDetailService extends BaseService<modelType> {
       const saccounting = [];
       for (const val of res.s_accounting) {
         arr = await this.userModel.findById(val._id).lean();
-        saccounting.push(arr.name);
+        if (arr) saccounting.push(arr.name || '暂无');
       }
       info.saccounting_name = saccounting.toString();
     }
@@ -195,7 +195,7 @@ export class OrderDetailService extends BaseService<modelType> {
       const cleader = [];
       for (const val of res.c_leader) {
         arr = await this.userModel.findById(val._id).lean();
-        cleader.push(arr.name);
+        if (arr) cleader.push(arr.name || '暂无');
       }
       info.cleader_name = cleader.toString();
     }
@@ -203,7 +203,7 @@ export class OrderDetailService extends BaseService<modelType> {
       const caccounting = [];
       for (const val of res.c_accounting) {
         arr = await this.userModel.findById(val._id).lean();
-        caccounting.push(arr.name);
+        if (arr) caccounting.push(arr.name || '暂无');
       }
       info.caccounting_name = caccounting.toString();
     }

+ 0 - 35
src/service/user.service.ts

@@ -60,39 +60,4 @@ export class UserService extends BaseService<modelType> {
       );
     return user;
   }
-  // 查询该街道的街道人员或社区人员;
-  async queryInfo(filter): Promise<object> {
-    const { skip = 0, limit, street, name, ...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 = [
-        { $or: [{ role: 'jdry' }, { role: 'sqry' }] },
-        { $or: [{ street: street }] },
-      ];
-      const commonList = [];
-      for (const val of res) {
-        const info = { community: val._id };
-        commonList.push(info);
-      }
-      belongList.push({ $or: commonList });
-      info.$and = belongList;
-    }
-    if (name) info.name = { $regex: name };
-    list = await this.model.find(info).skip(skip).limit(limit).lean();
-    total = await this.model.count(info);
-    return { list, total };
-  }
 }

+ 1 - 1
src/service/util/user.util.ts

@@ -93,7 +93,7 @@ export class UserUtilService {
       });
       if (openidan > 0) {
         throw new ServiceError(
-          '注册成功 管理员审核中!',
+          '该微信号 已有账号,如有疑问请联系管理员!',
           FrameworkErrorEnum.BAD_BODY
         );
       }