瀏覽代碼

修改接口

zs 1 年之前
父節點
當前提交
1a3ff99748

+ 7 - 0
src/controller/Cart.controller.ts

@@ -85,6 +85,13 @@ export class CartController extends BaseController {
     return result;
   }
 
+  @Del('/deleteMany')
+  @Validate()
+  async deleteSome(@Body() data: any) {
+    const result = await this.service.deleteSome(data);
+    return result;
+  }
+
   @Del('/:id')
   @Validate()
   async delete(@Param('id') id: string) {

+ 0 - 89
src/controller/Supplier.controller.ts

@@ -1,89 +0,0 @@
-import {
-  Body,
-  Controller,
-  Del,
-  Get,
-  Inject,
-  Param,
-  Post,
-  Query,
-} from '@midwayjs/decorator';
-import { BaseController } from 'free-midway-component';
-import { SupplierService } from '../service/Supplier.service';
-import {
-  CDTO_Supplier,
-  CVO_Supplier,
-  FVO_Supplier,
-  QDTO_Supplier,
-  QVO_Supplier,
-  UDTO_Supplier,
-  UVAO_Supplier,
-} from '../interface/Supplier.interface';
-import { ApiResponse, ApiTags, ApiQuery } from '@midwayjs/swagger';
-import { Validate } from '@midwayjs/validate';
-@ApiTags(['供应商'])
-@Controller('/Supplier')
-export class SupplierController extends BaseController {
-  @Inject()
-  service: SupplierService;
-
-  @Post('/')
-  @Validate()
-  @ApiResponse({ type: CVO_Supplier })
-  async create(@Body() data: CDTO_Supplier) {
-    const dbData = await this.service.create(data);
-    const result = new CVO_Supplier(dbData);
-    return result;
-  }
-  @Get('/')
-  @ApiQuery({ name: 'query' })
-  @ApiResponse({ type: QVO_Supplier })
-  async query(
-    @Query() filter: QDTO_Supplier,
-    @Query('skip') skip: number,
-    @Query('limit') limit: number
-  ) {
-    const list = await this.service.query(filter, { skip, limit });
-    const data = [];
-    for (const i of list) {
-      const newData = new QVO_Supplier(i);
-      data.push(newData);
-    }
-    const total = await this.service.count(filter);
-    return { data, total };
-  }
-
-  @Get('/:id')
-  @ApiResponse({ type: FVO_Supplier })
-  async fetch(@Param('id') id: string) {
-    const data = await this.service.fetch(id);
-    const result = new FVO_Supplier(data);
-    return result;
-  }
-
-  @Post('/:id')
-  @Validate()
-  @ApiResponse({ type: UVAO_Supplier })
-  async update(@Param('id') id: string, @Body() body: UDTO_Supplier) {
-    const result = await this.service.updateOne(id, body);
-    return result;
-  }
-
-  @Del('/:id')
-  @Validate()
-  async delete(@Param('id') id: string) {
-    await this.service.delete(id);
-    return 'ok';
-  }
-  async createMany(...args: any[]) {
-    throw new Error('Method not implemented.');
-  }
-
-  async updateMany(...args: any[]) {
-    throw new Error('Method not implemented.');
-  }
-
-  async deleteMany(...args: any[]) {
-    throw new Error('Method not implemented.');
-  }
-}

+ 0 - 15
src/entity/Supplier.entity.ts

@@ -1,15 +0,0 @@
-import { modelOptions, prop } from '@typegoose/typegoose';
-import { BaseModel } from 'free-midway-component';
-@modelOptions({
-  schemaOptions: { collection: 'Supplier' },
-})
-export class Supplier extends BaseModel {
-  @prop({ required: false, index: false, zh: '供应商名称' })
-  name: string;
-  @prop({ required: false, index: false, zh: '联系电话' })
-  tel: string;
-  @prop({ required: false, index: false, zh: '负责人' })
-  head: string;
-  @prop({ required: false, index: false, zh: '负责人电话' })
-  head_tel: string;
-}

+ 0 - 76
src/interface/Supplier.interface.ts

@@ -1,76 +0,0 @@
-import { Rule, RuleType } from '@midwayjs/validate';
-import { ApiProperty } from '@midwayjs/swagger';
-import { SearchBase } from 'free-midway-component';
-import get = require('lodash/get');
-const dealVO = (cla, data) => {
-  for (const key in cla) {
-    const val = get(data, key);
-    if (val || val === 0) cla[key] = val;
-  }
-};
-export class FVO_Supplier {
-  constructor(data: object) {
-    dealVO(this, data);
-  }
-  @ApiProperty({ description: '数据id' })
-  _id: string = undefined;
-  @ApiProperty({ description: '供应商名称' })
-  'name': string = undefined;
-  @ApiProperty({ description: '联系电话' })
-  'tel': string = undefined;
-  @ApiProperty({ description: '负责人' })
-  'head': string = undefined;
-  @ApiProperty({ description: '负责人电话' })
-  'head_tel': string = undefined;
-}
-
-export class QDTO_Supplier extends SearchBase {
-  constructor() {
-    const like_prop = [];
-    const props = [];
-    const mapping = [];
-    super({ like_prop, props, mapping });
-  }
-}
-
-export class QVO_Supplier extends FVO_Supplier {
-  constructor(data: object) {
-    super(data);
-    dealVO(this, data);
-  }
-}
-
-export class CDTO_Supplier {
-  @ApiProperty({ description: '供应商名称' })
-  @Rule(RuleType['string']().empty(''))
-  'name': string = undefined;
-  @ApiProperty({ description: '联系电话' })
-  @Rule(RuleType['string']().empty(''))
-  'tel': string = undefined;
-  @ApiProperty({ description: '负责人' })
-  @Rule(RuleType['string']().empty(''))
-  'head': string = undefined;
-  @ApiProperty({ description: '负责人电话' })
-  @Rule(RuleType['string']().empty(''))
-  'head_tel': string = undefined;
-}
-
-export class CVO_Supplier extends FVO_Supplier {
-  constructor(data: object) {
-    super(data);
-    dealVO(this, data);
-  }
-}
-
-export class UDTO_Supplier extends CDTO_Supplier {
-  @ApiProperty({ description: '数据id' })
-  @Rule(RuleType['string']().empty(''))
-  _id: string = undefined;
-}
-
-export class UVAO_Supplier extends FVO_Supplier {
-  constructor(data: object) {
-    super(data);
-    dealVO(this, data);
-  }
-}

+ 10 - 0
src/service/Cart.service.ts

@@ -186,4 +186,14 @@ export class CartService extends BaseService<modelType> {
     }
     return order;
   }
+
+  // 部分删除购物车数据
+  async deleteSome(data): Promise<string> {
+    assert(data.cartIds, '缺少选中删除信息');
+    // 删除购物车
+    for (const val of data.cartIds) {
+      await this.model.deleteOne({ _id: val }).lean();
+    }
+    return 'ok';
+  }
 }

+ 0 - 11
src/service/Supplier.service.ts

@@ -1,11 +0,0 @@
-import { Provide } from '@midwayjs/decorator';
-import { InjectEntityModel } from '@midwayjs/typegoose';
-import { ReturnModelType } from '@typegoose/typegoose';
-import { BaseService } from 'free-midway-component';
-import { Supplier } from '../entity/Supplier.entity';
-type modelType = ReturnModelType<typeof Supplier>;
-@Provide()
-export class SupplierService extends BaseService<modelType> {
-  @InjectEntityModel(Supplier)
-  model: modelType;
-}

+ 9 - 7
src/service/user.service.ts

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