Browse Source

初始化租户固定角色

tags/v1.0.0^2
chengwang 1 year ago
parent
commit
aa72e73119
3 changed files with 34 additions and 0 deletions
  1. +11
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/RoleController.java
  2. +2
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/role/IRoleService.java
  3. +21
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/role/RoleServiceImpl.java

+ 11
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/RoleController.java View File

return roleService.savePermission(roleMenuDto); return roleService.savePermission(roleMenuDto);
} }


/**
* 初始化租户固定角色
* @param ids
* @return
*/
@GetMapping("/test/{ids}")
public JsonResult test(@PathVariable("ids") Integer[] ids){
return roleService.roleToTenant(ids);
}




} }

+ 2
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/role/IRoleService.java View File

JsonResult updateStatus(Role entity); JsonResult updateStatus(Role entity);


JsonResult savePermission(RoleMenuDto roleMenuDto); JsonResult savePermission(RoleMenuDto roleMenuDto);

JsonResult roleToTenant(Integer[] ids);
} }

+ 21
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/role/RoleServiceImpl.java View File

return JsonResult.success("权限保存成功"); return JsonResult.success("权限保存成功");
} }


/**
* 初始化租户固定角色
* @param ids
* @return
*/
@Override
public JsonResult roleToTenant(Integer[] ids) {
for (Integer id : ids) {
//批量初始化租户对应角色配置
List<Role> roles = roleMapper.selectList(Wrappers.<Role>lambdaQuery()
.eq(Role::getMark, 1).eq(Role::getStatus, 1)
.eq(Role::getTenantId, 1)
.ne(Role::getCode, "super"));
for (Role role : roles) {
role.setTenantId(id.toString());
roleMapper.insert(role);
}
}
return JsonResult.success();
}



} }

Loading…
Cancel
Save