From 136f6a346cb78bb81db22a8b20c4573baee0650e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E9=B9=8F?= Date: Mon, 18 Jul 2022 16:56:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AD=97=E5=85=B8=E5=88=A0=E9=99=A4=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E5=A4=9A=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/demo/entity/goods.ts | 2 +- src/modules/dict/controller/admin/type.ts | 2 ++ src/modules/dict/service/type.ts | 25 +++++++++++++++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 src/modules/dict/service/type.ts diff --git a/src/modules/demo/entity/goods.ts b/src/modules/demo/entity/goods.ts index d00f7dc..30632ee 100644 --- a/src/modules/demo/entity/goods.ts +++ b/src/modules/demo/entity/goods.ts @@ -16,6 +16,6 @@ export class DemoGoodsEntity extends BaseEntity { @Column({ comment: '价格', type: 'decimal', precision: 5, scale: 2 }) price: number; - @Column({ comment: '分类', type: 'tinyint', default: 0 }) + @Column({ comment: '分类 0-衣服 1-鞋子 2-裤子', type: 'tinyint', default: 0 }) type: number; } diff --git a/src/modules/dict/controller/admin/type.ts b/src/modules/dict/controller/admin/type.ts index 04cd61a..e31cdd8 100644 --- a/src/modules/dict/controller/admin/type.ts +++ b/src/modules/dict/controller/admin/type.ts @@ -1,6 +1,7 @@ import { DictTypeEntity } from './../../entity/type'; import { Provide } from '@midwayjs/decorator'; import { CoolController, BaseController } from '@cool-midway/core'; +import { DictTypeService } from '../../service/type'; /** * 字典类型 @@ -9,6 +10,7 @@ import { CoolController, BaseController } from '@cool-midway/core'; @CoolController({ api: ['add', 'delete', 'update', 'info', 'list', 'page'], entity: DictTypeEntity, + service: DictTypeService, listQueryOp: { keyWordLikeFields: ['name'], }, diff --git a/src/modules/dict/service/type.ts b/src/modules/dict/service/type.ts new file mode 100644 index 0000000..5f5c8d7 --- /dev/null +++ b/src/modules/dict/service/type.ts @@ -0,0 +1,25 @@ +import { DictInfoEntity } from './../entity/info'; +import { Provide } from '@midwayjs/decorator'; +import { BaseService } from '@cool-midway/core'; +import { InjectEntityModel } from '@midwayjs/orm'; +import { Repository, In } from 'typeorm'; + +/** + * 描述 + */ +@Provide() +export class DictTypeService extends BaseService { + @InjectEntityModel(DictInfoEntity) + dictInfoEntity: Repository; + + /** + * 删除 + * @param ids + */ + async delete(ids) { + super.delete(ids); + await this.dictInfoEntity.delete({ + typeId: In(ids), + }); + } +}