mirror of
https://github.com/cool-team-official/cool-admin-midway.git
synced 2024-11-01 06:02:39 +08:00
字典删除支持多级
This commit is contained in:
parent
eb97a0b79c
commit
67aa25fc41
@ -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;
|
||||
}
|
||||
|
@ -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'],
|
||||
},
|
||||
|
25
src/modules/dict/service/type.ts
Normal file
25
src/modules/dict/service/type.ts
Normal 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),
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user