字典删除支持多级

This commit is contained in:
小鹏 2022-07-18 16:56:28 +08:00
parent eb97a0b79c
commit 136f6a346c
3 changed files with 28 additions and 1 deletions

View File

@ -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;
}

View File

@ -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'],
},

View File

@ -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<DictInfoEntity>;
/**
*
* @param ids
*/
async delete(ids) {
super.delete(ids);
await this.dictInfoEntity.delete({
typeId: In(ids),
});
}
}