|
|
|
@ -8,17 +8,23 @@ |
|
|
|
|
|
|
|
package com.elink.esua.epdc.service.impl; |
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.elink.esua.epdc.commons.mybatis.enums.DelFlagEnum; |
|
|
|
import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
|
import com.elink.esua.epdc.commons.tools.constant.Constant; |
|
|
|
import com.elink.esua.epdc.commons.tools.constant.NumConstant; |
|
|
|
import com.elink.esua.epdc.commons.tools.enums.SuperAdminEnum; |
|
|
|
import com.elink.esua.epdc.commons.tools.exception.RenException; |
|
|
|
import com.elink.esua.epdc.commons.tools.page.PageData; |
|
|
|
import com.elink.esua.epdc.commons.tools.security.user.SecurityUser; |
|
|
|
import com.elink.esua.epdc.commons.tools.security.user.UserDetail; |
|
|
|
import com.elink.esua.epdc.commons.tools.utils.ConvertUtils; |
|
|
|
import com.elink.esua.epdc.commons.tools.utils.Result; |
|
|
|
import com.elink.esua.epdc.constant.TypeKeyConstant; |
|
|
|
import com.elink.esua.epdc.dao.SysRoleDao; |
|
|
|
import com.elink.esua.epdc.dto.ParentAndAllDeptDTO; |
|
|
|
import com.elink.esua.epdc.dto.SysRoleDTO; |
|
|
|
import com.elink.esua.epdc.entity.SysRoleEntity; |
|
|
|
import com.elink.esua.epdc.service.*; |
|
|
|
@ -97,6 +103,8 @@ public class SysRoleServiceImpl extends BaseServiceImpl<SysRoleDao, SysRoleEntit |
|
|
|
public void save(SysRoleDTO dto) { |
|
|
|
SysRoleEntity entity = ConvertUtils.sourceToTarget(dto, SysRoleEntity.class); |
|
|
|
|
|
|
|
checkDeptRoleAmount(dto.getTypeKey(), dto.getDeptIdList()); |
|
|
|
|
|
|
|
//保存角色
|
|
|
|
insert(entity); |
|
|
|
|
|
|
|
@ -110,6 +118,42 @@ public class SysRoleServiceImpl extends BaseServiceImpl<SysRoleDao, SysRoleEntit |
|
|
|
appRoleMenuService.saveOrUpdate(entity.getId(), dto.getAppMenuIdList()); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 根据角色类型,获取机构的此类角色数量 |
|
|
|
* |
|
|
|
* @param roleType 角色类型 |
|
|
|
* @param deptidList 机构id列表 |
|
|
|
* @return void |
|
|
|
* @author work@yujt.net.cn |
|
|
|
* @date 2019/12/18 10:14 |
|
|
|
*/ |
|
|
|
private void checkDeptRoleAmount(String roleType, List<Long> deptidList) { |
|
|
|
if (TypeKeyConstant.ROLE_GRID_LEADER.equals(roleType)) { |
|
|
|
List<Map<String, Object>> resultList = baseDao.selectAmountByRoleTpye(roleType, deptidList); |
|
|
|
if (CollUtil.isEmpty(resultList)) { |
|
|
|
return; |
|
|
|
} |
|
|
|
Map<String, Object> map; |
|
|
|
String mapValue; |
|
|
|
for (int i = 0; i < resultList.size(); i++) { |
|
|
|
map = resultList.get(i); |
|
|
|
|
|
|
|
mapValue = map.get("typeKey").toString(); |
|
|
|
if (!mapValue.equals(TypeKeyConstant.DEPT_GRID_PARTY)) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
mapValue = map.get("amount").toString(); |
|
|
|
if (Integer.parseInt(mapValue) <= NumConstant.THREE) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
mapValue = map.get("id").toString(); |
|
|
|
ParentAndAllDeptDTO parentAndAllDept = sysDeptService.getParentAndAllDept(mapValue); |
|
|
|
throw new RenException("保存失败:" + parentAndAllDept.getAllDeptNames() + ",网格长多于3人"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void update(SysRoleDTO dto) { |
|
|
|
|