mirror of
https://github.com/cool-team-official/cool-admin-midway.git
synced 2025-12-14 19:22:50 +00:00
字典支持多级
This commit is contained in:
parent
9710751c19
commit
f96d980254
@ -10,6 +10,7 @@ import { DictInfoService } from '../../service/info';
|
||||
@CoolController({
|
||||
api: ['add', 'delete', 'update', 'info', 'list', 'page'],
|
||||
entity: DictInfoEntity,
|
||||
service: DictInfoService,
|
||||
listQueryOp: {
|
||||
fieldEq: ['typeId'],
|
||||
keyWordLikeFields: ['name'],
|
||||
|
||||
@ -69,4 +69,35 @@ export class DictInfoService extends BaseService {
|
||||
return e.name;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改之后
|
||||
* @param data
|
||||
* @param type
|
||||
*/
|
||||
async modifyAfter(data: any, type: 'delete' | 'update' | 'add') {
|
||||
if (type === 'delete') {
|
||||
for (const id of data) {
|
||||
await this.delChildDict(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除子字典
|
||||
* @param id
|
||||
*/
|
||||
private async delChildDict(id) {
|
||||
const delDict = await this.dictInfoEntity.find({ parentId: id });
|
||||
if (_.isEmpty(delDict)) {
|
||||
return;
|
||||
}
|
||||
const delDictIds = delDict.map(e => {
|
||||
return e.id;
|
||||
});
|
||||
await this.dictInfoEntity.delete(delDictIds);
|
||||
for (const dictId of delDictIds) {
|
||||
await this.delChildDict(dictId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user