Parcourir la source

修改保存角色修改

gao.qiang il y a 1 an
Parent
commit
23a4efd1e5

+ 18 - 0
hazard-admin/src/main/java/com/ozs/web/controller/system/SysUserController.java

@@ -29,6 +29,8 @@ import com.ozs.service.entity.MsgAlarm;
 import com.ozs.service.entity.vo.CameraTreeVo;
 import com.ozs.service.entity.vo.MsgAlarmVo;
 import com.ozs.service.service.BaseUserService;
+import com.ozs.system.domain.SysUserRole;
+import com.ozs.system.mapper.SysUserRoleMapper;
 import com.ozs.system.service.DataScoreUtil;
 import com.ozs.system.service.ISysDictTypeService;
 import io.swagger.annotations.ApiOperation;
@@ -92,6 +94,8 @@ public class SysUserController extends BaseController {
     private ISysDictTypeService dictTypeService;
     @Value("${base.defaultPassword:yn5aq5Mt.106.tky}")
     private String defaultPassword;
+    @Autowired
+    private SysUserRoleMapper sysUserRoleMapper;
 //    /**
 //     * 获取用户列表
 //     */
@@ -357,6 +361,20 @@ public class SysUserController extends BaseController {
     @Log(title = "用户管理", businessType = BusinessType.UPDATE)
     @GetMapping("/resetPwd/{id}")
     public AjaxResult resetPwd(@PathVariable(value = "id") Long id) {
+        boolean stop=false;
+        LambdaQueryWrapper<SysUserRole> wrapper=new LambdaQueryWrapper<>();
+        wrapper.eq(SysUserRole::getUserId,id);
+        List<SysUserRole> sysUserRoles = sysUserRoleMapper.selectList(wrapper);
+        for (SysUserRole sysUserRole : sysUserRoles) {
+            String roleKey = roleService.getRoleKey(sysUserRole.getRoleId());
+            if ("admin".equals(roleKey)){
+                stop=true;
+                break;
+            }
+        }
+        if (!stop){
+            return error("只有超级管理员才能重置密码!!");
+        }
         String password = null;
         SysUser user = new SysUser();
         user.setId(id);