|
|
|
@ -65,7 +65,7 @@ export class CoreDictService { |
|
|
|
|
* */ |
|
|
|
|
public async create(createCoreDictDto: CreateCoreDictDto, guardInfo: GuardInfo) { |
|
|
|
|
// ! 判断是否是root账户,非root账户无法设置为root
|
|
|
|
|
if (this.config.get<number>('masterId') !== guardInfo.userId && isTrueEnum(createCoreDictDto.root)) { |
|
|
|
|
if (this.config.get<number>('masterId') != guardInfo.userId && isTrueEnum(createCoreDictDto.root)) { |
|
|
|
|
throw new HttpException('没有权限创建原始字典!', HttpStatus.UNAUTHORIZED); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -147,7 +147,7 @@ export class CoreDictService { |
|
|
|
|
* */ |
|
|
|
|
public async update(dictId: string, updateCoreDictDto: UpdateCoreDictDto, guardInfo: GuardInfo) { |
|
|
|
|
// ! 判断是否是root账户,非root账户无法设置为root
|
|
|
|
|
if (this.config.get<number>('masterId') !== guardInfo.userId && updateCoreDictDto.root !== undefined) { |
|
|
|
|
if (this.config.get<number>('masterId') != guardInfo.userId && updateCoreDictDto.root !== undefined) { |
|
|
|
|
throw new HttpException('没有权限修改原始字典!', HttpStatus.UNAUTHORIZED); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -156,7 +156,7 @@ export class CoreDictService { |
|
|
|
|
if (oldDict.length == 0) throw new HttpException('未找到目标字典,无法修改!', HttpStatus.BAD_REQUEST); |
|
|
|
|
|
|
|
|
|
// ! root数据,非root用户不允许修改
|
|
|
|
|
if (oldDict[0].root && this.config.get<number>('masterId') !== guardInfo.userId) { |
|
|
|
|
if (oldDict[0].root && this.config.get<number>('masterId') != guardInfo.userId) { |
|
|
|
|
throw new HttpException('原始字典,权限不足无法修改!', HttpStatus.BAD_REQUEST); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -208,7 +208,7 @@ export class CoreDictService { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// ! root数据,非root用户不允许删除
|
|
|
|
|
if (result[0].root && this.config.get<number>('masterId') !== guardInfo.userId) { |
|
|
|
|
if (result[0].root && this.config.get<number>('masterId') != guardInfo.userId) { |
|
|
|
|
throw new HttpException('原始字典,权限不足无法删除!', HttpStatus.BAD_REQUEST); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|