修改app权限功能
This commit is contained in:
parent
b3203b6ccc
commit
9d9cfd5c72
|
|
@ -37,7 +37,7 @@ public class EmployessApi {
|
|||
if (StringUtils.isBlank(employessId)){
|
||||
return Result.error("参数错误");
|
||||
}
|
||||
List<Map<String ,String>> result = employeesInfoApi.getPermissionList(employessId);
|
||||
List<Map<String ,Object>> result = employeesInfoApi.getPermissionList(employessId);
|
||||
return Result.ok(result);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,5 +4,5 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
public interface IEmployeesInfoApi {
|
||||
List<Map<String ,String>> getPermissionList(String employessId);
|
||||
List<Map<String ,Object>> getPermissionList(String employessId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ import java.util.ArrayList;
|
|||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Description: 员工信息
|
||||
|
|
@ -32,15 +33,40 @@ public class BizEmployeesInfoServiceImpl extends ServiceImpl<BizEmployeesInfoMap
|
|||
private INuAppEmployessPermissionService nuAppEmployessPermissionService;
|
||||
|
||||
@Override
|
||||
public List<Map<String ,String>> getPermissionList(String employessId) {
|
||||
List<Map<String ,String>> mapList = new ArrayList<>();
|
||||
public List<Map<String ,Object>> getPermissionList(String employessId) {
|
||||
List<NuAppEmployessPermission> permissionList = nuAppEmployessPermissionService.listByEmployessId(employessId);
|
||||
List<Map<String, String>> originalData = new ArrayList<>();
|
||||
for(NuAppEmployessPermission par:permissionList){
|
||||
Map<String,String> map = new HashMap<>();
|
||||
map.put("nuId", par.getNuId());
|
||||
map.put("menuName", par.getMenuName());
|
||||
map.put("menuCode", par.getMenuCode());
|
||||
mapList.add(map);
|
||||
originalData.add(map);
|
||||
}
|
||||
List<Map<String ,Object>> mapList = new ArrayList<>();
|
||||
mapList = convertSimple(originalData);
|
||||
return mapList;
|
||||
}
|
||||
|
||||
public static List<Map<String, Object>> convertSimple(List<Map<String, String>> data) {
|
||||
Map<String, List<Map<String, String>>> grouped = new HashMap<>();
|
||||
|
||||
for (Map<String, String> item : data) {
|
||||
Map<String, String> menuItem = new HashMap<>();
|
||||
menuItem.put("menuCode", item.get("menuCode"));
|
||||
menuItem.put("menuName", item.get("menuName"));
|
||||
|
||||
grouped.computeIfAbsent(item.get("nuId"), k -> new ArrayList<>())
|
||||
.add(menuItem);
|
||||
}
|
||||
|
||||
return grouped.entrySet().stream()
|
||||
.map(entry -> {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("nuId", entry.getKey());
|
||||
result.put("dataList", entry.getValue());
|
||||
return result;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import java.net.URLDecoder;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.nu.modules.appConfig.entity.NuAppPermission;
|
||||
|
|
@ -271,7 +272,7 @@ public class NuAppEmployessPermissionController extends JeecgController<NuAppEmp
|
|||
String roleId = json.getString("roleId");
|
||||
String permissionIds = json.getString("permissionIds");
|
||||
String lastPermissionIds = json.getString("lastpermissionIds");
|
||||
this.nuAppEmployessPermissionService.saveRolePermission(roleId, permissionIds, lastPermissionIds);
|
||||
this.nuAppEmployessPermissionService.saveRolePermission(roleId, permissionIds, lastPermissionIds,null);
|
||||
//update-begin---author:wangshuai ---date:20220316 for:[VUEN-234]用户管理角色授权添加敏感日志------------
|
||||
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
baseCommonService.addLog("修改角色ID: "+roleId+" 的权限配置,操作人: " +loginUser.getUsername() ,CommonConstant.LOG_TYPE_2, 2);
|
||||
|
|
@ -285,4 +286,60 @@ public class NuAppEmployessPermissionController extends JeecgController<NuAppEmp
|
|||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/saveRolePermissionList", method = RequestMethod.POST)
|
||||
// @RequiresPermissions("system:permission:saveRole")
|
||||
public Result<String> saveRolePermissionList(@RequestBody JSONArray jsonList) {
|
||||
long start = System.currentTimeMillis();
|
||||
Result<String> result = new Result<>();
|
||||
try {
|
||||
for (int i = 0; i < jsonList.size(); i++) {
|
||||
JSONObject obj = jsonList.getJSONObject(i);
|
||||
|
||||
// 获取字段值
|
||||
JSONArray active = obj.getJSONArray("permissionId");
|
||||
if(active!=null && active.size()>0){
|
||||
String permissionIds = "";
|
||||
String roleId = obj.getString("roleId");
|
||||
String nuId = obj.getString("nuId");
|
||||
String lastPermissionIds = obj.getString("lastpermissionIds");
|
||||
for (int j = 0; j < active.size(); j++){
|
||||
permissionIds = permissionIds+active.getString(j)+",";
|
||||
}
|
||||
this.nuAppEmployessPermissionService.saveRolePermission(roleId, permissionIds,lastPermissionIds, nuId);
|
||||
|
||||
}
|
||||
|
||||
// System.out.println("第 " + i + " 个对象:");
|
||||
// System.out.println(" name: " + name);
|
||||
// System.out.println(" age: " + age);
|
||||
// System.out.println(" active: " + active);
|
||||
|
||||
// 遍历对象的所有字段
|
||||
// for (String key : obj.keySet()) {
|
||||
// Object value = obj.get(key);
|
||||
// System.out.println(" " + key + ": " + value);
|
||||
// }
|
||||
}
|
||||
// for (JSONObject json : jsonList){
|
||||
// String roleId = json.getString("roleId");
|
||||
// String permissionIds = json.getString("permissionIds");
|
||||
// String lastPermissionIds = json.getString("lastpermissionIds");
|
||||
// this.nuAppEmployessPermissionService.saveRolePermission(roleId, permissionIds, lastPermissionIds);
|
||||
// //update-begin---author:wangshuai ---date:20220316 for:[VUEN-234]用户管理角色授权添加敏感日志------------
|
||||
// LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
// baseCommonService.addLog("修改角色ID: "+roleId+" 的权限配置,操作人: " +loginUser.getUsername() ,CommonConstant.LOG_TYPE_2, 2);
|
||||
// //update-end---author:wangshuai ---date:20220316 for:[VUEN-234]用户管理角色授权添加敏感日志------------
|
||||
// result.success("保存成功!");
|
||||
// log.info("======角色授权成功=====耗时:" + (System.currentTimeMillis() - start) + "毫秒");
|
||||
// }
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
result.error500("授权失败!");
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,8 +69,9 @@ public class NuAppEmployessPermission implements Serializable {
|
|||
private String menuCode;
|
||||
|
||||
|
||||
public NuAppEmployessPermission(String roleId, String permissionId) {
|
||||
public NuAppEmployessPermission(String roleId, String permissionId,String nuId) {
|
||||
this.roleId = roleId;
|
||||
this.permissionId = permissionId;
|
||||
this.nuId = nuId;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import java.util.List;
|
|||
*/
|
||||
public interface INuAppEmployessPermissionService extends IService<NuAppEmployessPermission> {
|
||||
|
||||
void saveRolePermission(String roleId, String permissionIds, String lastPermissionIds);
|
||||
void saveRolePermission(String roleId, String permissionIds, String lastPermissionIds,String nuId);
|
||||
|
||||
List<NuAppEmployessPermission> listByEmployessId(String employessId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ import java.util.*;
|
|||
public class NuAppEmployessPermissionServiceImpl extends ServiceImpl<NuAppEmployessPermissionMapper, NuAppEmployessPermission> implements INuAppEmployessPermissionService {
|
||||
|
||||
@Override
|
||||
public void saveRolePermission(String roleId, String permissionIds, String lastPermissionIds) {
|
||||
public void saveRolePermission(String roleId, String permissionIds,String lastPermissionIds, String nuId) {
|
||||
String ip = "";
|
||||
try {
|
||||
//获取request
|
||||
|
|
@ -35,26 +35,41 @@ public class NuAppEmployessPermissionServiceImpl extends ServiceImpl<NuAppEmploy
|
|||
} catch (Exception e) {
|
||||
ip = "127.0.0.1";
|
||||
}
|
||||
List<String> add = getDiff(lastPermissionIds,permissionIds);
|
||||
if(add!=null && add.size()>0) {
|
||||
this.remove(new QueryWrapper<NuAppEmployessPermission>().lambda().eq(NuAppEmployessPermission::getRoleId, roleId).eq(NuAppEmployessPermission::getNuId, nuId));
|
||||
|
||||
if (oConvertUtils.isNotEmpty(permissionIds)){
|
||||
List<NuAppEmployessPermission> list = new ArrayList<NuAppEmployessPermission>();
|
||||
for (String p : add) {
|
||||
if(oConvertUtils.isNotEmpty(p)) {
|
||||
NuAppEmployessPermission rolepms = new NuAppEmployessPermission(roleId, p);
|
||||
rolepms.setOperateDate(new Date());
|
||||
rolepms.setOperateIp(ip);
|
||||
list.add(rolepms);
|
||||
}
|
||||
for (String permissionId : permissionIds.split(",")){
|
||||
NuAppEmployessPermission rolepms = new NuAppEmployessPermission(roleId, permissionId,nuId);
|
||||
rolepms.setOperateDate(new Date());
|
||||
rolepms.setOperateIp(ip);
|
||||
list.add(rolepms);
|
||||
}
|
||||
this.saveBatch(list);
|
||||
}
|
||||
|
||||
List<String> delete = getDiff(permissionIds,lastPermissionIds);
|
||||
if(delete!=null && delete.size()>0) {
|
||||
for (String permissionId : delete) {
|
||||
this.remove(new QueryWrapper<NuAppEmployessPermission>().lambda().eq(NuAppEmployessPermission::getRoleId, roleId).eq(NuAppEmployessPermission::getPermissionId, permissionId));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// List<String> add = getDiff(lastPermissionIds,permissionIds,nuId);
|
||||
// if(add!=null && add.size()>0) {
|
||||
// List<NuAppEmployessPermission> list = new ArrayList<NuAppEmployessPermission>();
|
||||
// for (String p : add) {
|
||||
// if(oConvertUtils.isNotEmpty(p)) {
|
||||
// NuAppEmployessPermission rolepms = new NuAppEmployessPermission(roleId, p);
|
||||
// rolepms.setOperateDate(new Date());
|
||||
// rolepms.setOperateIp(ip);
|
||||
// list.add(rolepms);
|
||||
// }
|
||||
// }
|
||||
// this.saveBatch(list);
|
||||
// }
|
||||
//
|
||||
// List<String> delete = getDiff(permissionIds,lastPermissionIds,nuId);
|
||||
// if(delete!=null && delete.size()>0) {
|
||||
// for (String permissionId : delete) {
|
||||
// this.remove(new QueryWrapper<NuAppEmployessPermission>().lambda().eq(NuAppEmployessPermission::getRoleId, roleId).eq(NuAppEmployessPermission::getPermissionId, permissionId).eq(NuAppEmployessPermission::getNuId, nuId));
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -68,13 +83,16 @@ public class NuAppEmployessPermissionServiceImpl extends ServiceImpl<NuAppEmploy
|
|||
* @param diff
|
||||
* @return
|
||||
*/
|
||||
private List<String> getDiff(String main,String diff){
|
||||
private List<String> getDiff(String main,String diff,String nuId){
|
||||
if(oConvertUtils.isEmpty(diff)) {
|
||||
return null;
|
||||
}
|
||||
if(oConvertUtils.isEmpty(main)) {
|
||||
return Arrays.asList(diff.split(","));
|
||||
}
|
||||
if(oConvertUtils.isEmpty(nuId)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String[] mainArr = main.split(",");
|
||||
String[] diffArr = diff.split(",");
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ public class NuBaseInfoController extends JeecgController<NuBaseInfo, INuBaseInf
|
|||
@GetMapping(value = "/qyList")
|
||||
public Result<IPage<NuBaseInfo>> qyList(NuBaseInfo nuBaseInfo,
|
||||
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "15") Integer pageSize,
|
||||
@RequestParam(name = "pageSize", defaultValue = "100") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
Map<String, QueryRuleEnum> customeRuleMap = new HashMap<>();
|
||||
QueryWrapper<NuBaseInfo> queryWrapper = QueryGenerator.initQueryWrapper(nuBaseInfo, req.getParameterMap(), customeRuleMap);
|
||||
|
|
@ -80,6 +80,21 @@ public class NuBaseInfoController extends JeecgController<NuBaseInfo, INuBaseInf
|
|||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "护理单元(按区域查询列表)-包含区域功能权限分页列表查询", notes = "护理单元(按区域查询列表)-包含区域功能权限分页列表查询")
|
||||
@GetMapping(value = "/qyPemissionList")
|
||||
public Result<IPage<NuBaseInfo>> qyPemissionList(NuBaseInfo nuBaseInfo,
|
||||
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "100") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
Map<String, QueryRuleEnum> customeRuleMap = new HashMap<>();
|
||||
QueryWrapper<NuBaseInfo> queryWrapper = QueryGenerator.initQueryWrapper(nuBaseInfo, req.getParameterMap(), customeRuleMap);
|
||||
queryWrapper.like(StringUtils.isNotBlank(nuBaseInfo.getNuNameParams()),"a.nu_name",nuBaseInfo.getNuNameParams());
|
||||
// queryWrapper.isNotNull("b.id");
|
||||
Page<NuBaseInfo> page = new Page<NuBaseInfo>(pageNo, pageSize);
|
||||
IPage<NuBaseInfo> pageList = nuBaseInfoService.qyPemissionList(page, queryWrapper, nuBaseInfo.getEmployessId());
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 护理单元-入住信息分页列表查询
|
||||
*
|
||||
|
|
|
|||
|
|
@ -179,5 +179,11 @@ public class NuBaseInfo implements Serializable {
|
|||
//单元对应外挂
|
||||
@TableField(exist = false)
|
||||
private List<NuAppNuidPermission> permissionList;
|
||||
//单元对应外挂
|
||||
@TableField(exist = false)
|
||||
private String permissionIds;
|
||||
//护理员id
|
||||
@TableField(exist = false)
|
||||
private String employessId;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,4 +30,6 @@ public interface NuBaseInfoMapper extends BaseMapper<NuBaseInfo> {
|
|||
int updateWarningByNuId(NuBaseInfoEntity nuBaseInfoApiDto);
|
||||
|
||||
List<NuBaseInfoEntity> queryNuAndCameraInfo(@Param("dto") NuBaseInfoEntity dto);
|
||||
|
||||
List<NuBaseInfo> getPermissionList(@Param("employessId") String employessId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,4 +74,9 @@
|
|||
</where>
|
||||
order by nuInfo.nu_id asc
|
||||
</select>
|
||||
|
||||
|
||||
<select id="getPermissionList" resultType="com.nu.modules.nubaseinfo.entity.NuBaseInfo">
|
||||
select GROUP_CONCAT(permission_id) as permissionIds,nu_id from nu_app_employess_permission where role_id = #{employessId} GROUP BY nu_id
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
|||
|
|
@ -23,4 +23,6 @@ public interface INuBaseInfoService extends IService<NuBaseInfo> {
|
|||
void batchInsert(List<NuBaseInfo> syncList);
|
||||
|
||||
IPage<NuBaseInfo> qyList(Page<NuBaseInfo> page, QueryWrapper<NuBaseInfo> queryWrapper);
|
||||
|
||||
IPage<NuBaseInfo> qyPemissionList(Page<NuBaseInfo> page, QueryWrapper<NuBaseInfo> queryWrapper,String employessId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,6 +60,7 @@ public class NuBaseInfoServiceImpl extends ServiceImpl<NuBaseInfoMapper, NuBaseI
|
|||
@Autowired
|
||||
private INuAppNuidPermissionService nuAppNuidPermissionService;
|
||||
|
||||
|
||||
@Override
|
||||
public void setNuId(NuBaseInfo nuBaseInfo) {
|
||||
JSONObject deptInfo = sysBaseAPI.getDeptInfo();
|
||||
|
|
@ -111,6 +112,23 @@ public class NuBaseInfoServiceImpl extends ServiceImpl<NuBaseInfoMapper, NuBaseI
|
|||
return baseMapper.qyList(page, queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<NuBaseInfo> qyPemissionList(Page<NuBaseInfo> page, QueryWrapper<NuBaseInfo> queryWrapper,String employessId) {
|
||||
IPage<NuBaseInfo> listPage = baseMapper.qyList(page, queryWrapper);
|
||||
|
||||
List<NuBaseInfo> perList = baseMapper.getPermissionList(employessId);
|
||||
|
||||
listPage.getRecords().forEach(nuBaseInfo -> {
|
||||
perList.forEach(per -> {
|
||||
if (per.getNuId().equals(nuBaseInfo.getNuId())) {
|
||||
nuBaseInfo.setPermissionIds(per.getPermissionIds());
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
return listPage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(NuBaseInfoEntity dto) {
|
||||
NuBaseInfo nuBaseInfo = new NuBaseInfo();
|
||||
|
|
|
|||
Loading…
Reference in New Issue