修改防止回路

main
expressgy 3 months ago
parent 0b3880ec43
commit 6f30410123
  1. 3
      src/application/auth-dept/auth-dept.service.ts
  2. 4
      src/application/auth-role/auth-role.service.ts
  3. 3
      src/application/auth-user/auth-user.service.ts
  4. 4
      src/application/core-dict/core-dict.service.ts
  5. 3
      src/application/core-env/core-env.service.ts
  6. 5
      src/application/core-menu/core-menu.service.ts

@ -446,6 +446,9 @@ export class AuthDeptService {
// DB 修改 // DB 修改
private updateDept(id, updateAuthDeptDto: UpdateAuthDeptDto, userId) { private updateDept(id, updateAuthDeptDto: UpdateAuthDeptDto, userId) {
if (id == updateAuthDeptDto.pid) {
throw new HttpException('数据成环,无法设置!', HttpStatus.BAD_REQUEST);
}
return this.mysqlService.db return this.mysqlService.db
.update(pacAuthDept) .update(pacAuthDept)
.set({ .set({

@ -173,6 +173,10 @@ export class AuthRoleService {
} }
public async update(roleId: string, updateAuthRoleDto: UpdateAuthRoleDto, guardInfo: GuardInfo) { public async update(roleId: string, updateAuthRoleDto: UpdateAuthRoleDto, guardInfo: GuardInfo) {
if (roleId == updateAuthRoleDto.pid) {
throw new HttpException('数据成环,无法设置!', HttpStatus.BAD_REQUEST);
}
// ! 查找角色信息 // ! 查找角色信息
const roleData = await this.getRoleForRoleId(roleId); const roleData = await this.getRoleForRoleId(roleId);

@ -576,6 +576,9 @@ export class AuthUserService {
// DB 更新账户 // DB 更新账户
private async updateUser(id: string, updateAuthUserDto: UpdateAuthUserDto, guardInfo: GuardInfo) { private async updateUser(id: string, updateAuthUserDto: UpdateAuthUserDto, guardInfo: GuardInfo) {
if (id == updateAuthUserDto.pid) {
throw new HttpException('数据成环,无法设置!', HttpStatus.BAD_REQUEST);
}
const user = await this.mysqlService.db const user = await this.mysqlService.db
.select({ id: pacAuthUser.userId, pid: pacAuthUser.pid }) .select({ id: pacAuthUser.userId, pid: pacAuthUser.pid })
.from(pacAuthUser) .from(pacAuthUser)

@ -152,6 +152,10 @@ export class CoreDictService {
throw new HttpException('没有权限修改原始字典!', HttpStatus.UNAUTHORIZED); throw new HttpException('没有权限修改原始字典!', HttpStatus.UNAUTHORIZED);
} }
if (dictId == updateCoreDictDto.pid) {
throw new HttpException('数据成环,无法设置!', HttpStatus.BAD_REQUEST);
}
// ! 产看目标字典是否存在 // ! 产看目标字典是否存在
const oldDict = await this.getMore(dictId); const oldDict = await this.getMore(dictId);
if (oldDict.length == 0) throw new HttpException('未找到目标字典,无法修改!', HttpStatus.BAD_REQUEST); if (oldDict.length == 0) throw new HttpException('未找到目标字典,无法修改!', HttpStatus.BAD_REQUEST);

@ -150,6 +150,9 @@ export class CoreEnvService {
if (this.config.get<number>('masterId') != guardInfo.userId && updateCoreEnvDto.root !== undefined) { if (this.config.get<number>('masterId') != guardInfo.userId && updateCoreEnvDto.root !== undefined) {
throw new HttpException('没有权限修改原始字典!', HttpStatus.UNAUTHORIZED); throw new HttpException('没有权限修改原始字典!', HttpStatus.UNAUTHORIZED);
} }
if (envId == updateCoreEnvDto.pid) {
throw new HttpException('数据成环,无法设置!', HttpStatus.BAD_REQUEST);
}
// ! 查变量是否存在 // ! 查变量是否存在
const oldEnv = await this.getMore(envId); const oldEnv = await this.getMore(envId);

@ -115,7 +115,12 @@ export class CoreMenuService {
throw new HttpException('没有权限删除菜单!', HttpStatus.UNAUTHORIZED); throw new HttpException('没有权限删除菜单!', HttpStatus.UNAUTHORIZED);
} }
if (id == updateCoreMenuDto.pid) {
throw new HttpException('数据成环,无法设置!', HttpStatus.BAD_REQUEST);
}
// ! 写入数据 // ! 写入数据
return this.updateMenuData(id, updateCoreMenuDto, guardInfo);
} }
public async remove(id: string, guardInfo: GuardInfo) { public async remove(id: string, guardInfo: GuardInfo) {

Loading…
Cancel
Save