增加系统管理员校验

This commit is contained in:
TinyAnts 2022-11-17 17:31:13 +08:00
parent 728a0f6ec5
commit 830c10ea73
3 changed files with 11 additions and 3 deletions

View File

@ -95,7 +95,8 @@ public class SystemAuthAdminController {
@Log(title = "管理员编辑")
@PostMapping("/edit")
public AjaxResult<Object> edit(@Validated @RequestBody SystemAdminUpdateValidate updateValidate) {
iSystemAuthAdminService.edit(updateValidate);
Integer adminId = LikeAdminThreadLocal.getAdminId();
iSystemAuthAdminService.edit(updateValidate, adminId);
return AjaxResult.success();
}

View File

@ -56,8 +56,9 @@ public interface ISystemAuthAdminService {
*
* @author fzr
* @param updateValidate 参数
* @param adminId 管理员ID
*/
void edit(SystemAdminUpdateValidate updateValidate);
void edit(SystemAdminUpdateValidate updateValidate, Integer adminId);
/**
* 当前管理员更新

View File

@ -21,6 +21,7 @@ import com.mdd.common.config.GlobalConfig;
import com.mdd.common.core.PageResult;
import com.mdd.common.entity.system.SystemAuthAdmin;
import com.mdd.common.entity.system.SystemAuthMenu;
import com.mdd.common.exception.OperateException;
import com.mdd.common.mapper.system.SystemAuthAdminMapper;
import com.mdd.common.mapper.system.SystemAuthMenuMapper;
import com.mdd.common.utils.*;
@ -245,9 +246,14 @@ public class SystemAuthAdminServiceImpl implements ISystemAuthAdminService {
*
* @author fzr
* @param updateValidate 参数
* @param adminId 管理员ID
*/
@Override
public void edit(SystemAdminUpdateValidate updateValidate) {
public void edit(SystemAdminUpdateValidate updateValidate, Integer adminId) {
if (adminId.equals(1) && !adminId.equals(updateValidate.getId())) {
throw new OperateException("您无权限编辑系统管理员!");
}
String[] field = {"id", "username", "nickname"};
Assert.notNull(systemAuthAdminMapper.selectOne(new QueryWrapper<SystemAuthAdmin>()
.select(field)