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), + }); + } +}