|
@@ -1,12 +1,11 @@
|
|
package com.gis.admin.service.impl;
|
|
package com.gis.admin.service.impl;
|
|
|
|
|
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.gis.admin.entity.dto.RoleAuthDto;
|
|
import com.gis.admin.entity.dto.RoleAuthDto;
|
|
-import com.gis.admin.entity.po.SysRolePermEntity;
|
|
|
|
-import com.gis.admin.mapper.SysRolePermMapper;
|
|
|
|
import com.gis.common.base.entity.dto.PageDto;
|
|
import com.gis.common.base.entity.dto.PageDto;
|
|
import com.gis.common.base.exception.BaseRuntimeException;
|
|
import com.gis.common.base.exception.BaseRuntimeException;
|
|
import com.gis.common.constant.ErrorEnum;
|
|
import com.gis.common.constant.ErrorEnum;
|
|
@@ -38,18 +37,18 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRoleEntity
|
|
@Autowired
|
|
@Autowired
|
|
SysRoleMapper entityMapper;
|
|
SysRoleMapper entityMapper;
|
|
|
|
|
|
- @Autowired
|
|
|
|
- SysRolePermMapper rolePermMapper;
|
|
|
|
|
|
+// @Autowired
|
|
|
|
+// SysRolePermMapper rolePermMapper;
|
|
|
|
|
|
- @Override
|
|
|
|
- public void saveRoleResource(Long roleId, Long resourceId) {
|
|
|
|
- entityMapper.saveRoleResource(roleId, resourceId);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public void deleteRoleResource(Long roleId) {
|
|
|
|
- entityMapper.deleteRoleResource(roleId);
|
|
|
|
- }
|
|
|
|
|
|
+// @Override
|
|
|
|
+// public void saveRoleResource(Long roleId, Long resourceId) {
|
|
|
|
+// entityMapper.saveRoleResource(roleId, resourceId);
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// @Override
|
|
|
|
+// public void deleteRoleResource(Long roleId) {
|
|
|
|
+// entityMapper.deleteRoleResource(roleId);
|
|
|
|
+// }
|
|
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -98,15 +97,15 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRoleEntity
|
|
return Result.success();
|
|
return Result.success();
|
|
}
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
|
- public void deleteUserRoleByUserId(Long userId) {
|
|
|
|
- entityMapper.deleteUserRoleByUserId(userId);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public void saveUserRole(Long userId, Long roleId) {
|
|
|
|
- entityMapper.saveUserRole(userId, roleId);
|
|
|
|
- }
|
|
|
|
|
|
+// @Override
|
|
|
|
+// public void deleteUserRoleByUserId(Long userId) {
|
|
|
|
+// entityMapper.deleteUserRoleByUserId(userId);
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// @Override
|
|
|
|
+// public void saveUserRole(Long userId, Long roleId) {
|
|
|
|
+// entityMapper.saveUserRole(userId, roleId);
|
|
|
|
+// }
|
|
|
|
|
|
/**
|
|
/**
|
|
* 删除角色
|
|
* 删除角色
|
|
@@ -139,22 +138,22 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRoleEntity
|
|
public Result detail(Long roleId) {
|
|
public Result detail(Long roleId) {
|
|
SysRoleEntity roleEntity = this.getById(roleId);
|
|
SysRoleEntity roleEntity = this.getById(roleId);
|
|
|
|
|
|
- HashMap<Object, Object> resultMap = new HashMap<>();
|
|
|
|
- resultMap.put("role", roleEntity);
|
|
|
|
- resultMap.put("permission", getPermByRoleId(roleId));
|
|
|
|
|
|
+// HashMap<Object, Object> resultMap = new HashMap<>();
|
|
|
|
+// resultMap.put("role", roleEntity);
|
|
|
|
+// resultMap.put("permission", getPermByRoleId(roleId));
|
|
|
|
|
|
- return Result.success(resultMap);
|
|
|
|
|
|
+ return Result.success(roleEntity);
|
|
}
|
|
}
|
|
|
|
|
|
- private List<SysRolePermEntity> getPermByRoleId(Long roleId){
|
|
|
|
- List<SysRolePermEntity> list = rolePermMapper.getPermByRoleId(roleId);
|
|
|
|
- return list;
|
|
|
|
- }
|
|
|
|
|
|
+// private List<SysRolePermEntity> getPermByRoleId(Long roleId){
|
|
|
|
+// List<SysRolePermEntity> list = rolePermMapper.getPermByRoleId(roleId);
|
|
|
|
+// return list;
|
|
|
|
+// }
|
|
|
|
|
|
- @Override
|
|
|
|
- public List<Long> getPermIdByRoleId(Long roleId){
|
|
|
|
- return rolePermMapper.getPermIdByRoleId(roleId);
|
|
|
|
- }
|
|
|
|
|
|
+// @Override
|
|
|
|
+// public List<Long> getPermIdByRoleId(Long roleId){
|
|
|
|
+// return rolePermMapper.getPermIdByRoleId(roleId);
|
|
|
|
+// }
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public Result editStatus(Long id, Integer isDisable) {
|
|
public Result editStatus(Long id, Integer isDisable) {
|
|
@@ -183,28 +182,49 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRoleEntity
|
|
@Override
|
|
@Override
|
|
public Result authorize(RoleAuthDto param) {
|
|
public Result authorize(RoleAuthDto param) {
|
|
// 先删除旧权限, 再重新添加
|
|
// 先删除旧权限, 再重新添加
|
|
- Long roleId = param.getRoleId();
|
|
|
|
- deleteRoleResource(roleId);
|
|
|
|
|
|
+// Long roleId = param.getRoleId();
|
|
|
|
+// deleteRoleResource(roleId);
|
|
|
|
|
|
// 保存数据
|
|
// 保存数据
|
|
- Map<String, String> auth = param.getAuth();
|
|
|
|
- SysRolePermEntity entity;
|
|
|
|
- for (Map.Entry<String, String> mp : auth.entrySet()) {
|
|
|
|
- entity = new SysRolePermEntity();
|
|
|
|
- entity.setRoleId(roleId);
|
|
|
|
- entity.setPermId(Long.valueOf(mp.getKey()));
|
|
|
|
- entity.setScope(mp.getValue());
|
|
|
|
- rolePermMapper.insert(entity);
|
|
|
|
- }
|
|
|
|
|
|
+// Map<String, String> auth = param.getAuth();
|
|
|
|
+// SysRolePermEntity entity;
|
|
|
|
+// for (Map.Entry<String, String> mp : auth.entrySet()) {
|
|
|
|
+// entity = new SysRolePermEntity();
|
|
|
|
+// entity.setRoleId(roleId);
|
|
|
|
+// entity.setPermId(Long.valueOf(mp.getKey()));
|
|
|
|
+// entity.setScope(mp.getValue());
|
|
|
|
+// rolePermMapper.insert(entity);
|
|
|
|
+// }
|
|
|
|
+
|
|
|
|
+// SysRolePermEntity entity = new SysRolePermEntity();
|
|
|
|
+// BeanUtils.copyProperties(param, entity);
|
|
|
|
+// rolePermMapper.insert(entity);
|
|
|
|
+
|
|
|
|
+ SysRoleEntity entity = this.getById(param.getId());
|
|
|
|
+ BaseRuntimeException.isNull(entity, ErrorEnum.FAILURE_SYS_2001);
|
|
|
|
+
|
|
|
|
+ BeanUtils.copyProperties(param, entity);
|
|
|
|
+
|
|
|
|
+ this.updateById(entity);
|
|
|
|
+
|
|
return Result.success();
|
|
return Result.success();
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public Result getPerm() {
|
|
|
|
- List<Map> list = rolePermMapper.getPerm();
|
|
|
|
|
|
+ public Result getHotel() {
|
|
|
|
+ List<Map> list = entityMapper.getHotel();
|
|
return Result.success(list);
|
|
return Result.success(list);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public List<String> getScopeById(Long roleId) {
|
|
|
|
+ String hotelIds = entityMapper.getScopeById(roleId);
|
|
|
|
+ BaseRuntimeException.isBlank(hotelIds, ErrorEnum.FAILURE_SYS_2001);
|
|
|
|
+ String[] split = hotelIds.split(",");
|
|
|
|
+ return Arrays.asList(split);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
/**
|
|
/**
|
|
* 检查角色名称
|
|
* 检查角色名称
|