| | |
| | | package com.vci.frameworkcore.compatibility.impl; |
| | | |
| | | import com.vci.constant.FrameWorkBtmTypeConstant; |
| | | import com.vci.corba.common.PLException; |
| | | import com.vci.corba.common.data.UserEntityInfo; |
| | | import com.vci.corba.framework.data.RoleInfo; |
| | | import com.vci.corba.omd.data.BusinessObject; |
| | | import com.vci.frameworkcore.compatibility.SmRoleQueryServiceI; |
| | | import com.vci.frameworkcore.constant.FrameWorkBtmTypeConstant; |
| | | import com.vci.frameworkcore.dto.SmRoleDTO; |
| | | import com.vci.constant.FrameWorkBtmTypeConstant; |
| | | import com.vci.dto.SmRoleDTO; |
| | | import com.vci.frameworkcore.compatibility.SmUserQueryServiceI; |
| | | import com.vci.frameworkcore.enumpck.RoleClassifyEnum; |
| | | import com.vci.frameworkcore.enumpck.RoleControlAreaEnum; |
| | | import com.vci.frameworkcore.model.SmRoleForPlatform1; |
| | | import com.vci.frameworkcore.model.dto.SmUserDTO; |
| | | import com.vci.frameworkcore.model.po.SmRolePO; |
| | | import com.vci.frameworkcore.model.po.SmUserPO; |
| | | import com.vci.frameworkcore.pagemodel.OrgDepartmentVO; |
| | | import com.vci.frameworkcore.pagemodel.SmRoleVO; |
| | | import com.vci.frameworkcore.pagemodel.SmUserVO; |
| | | import com.vci.frameworkcore.properties.ConfigReader; |
| | | import com.vci.model.SmRoleForPlatform1; |
| | | import com.vci.pagemodel.SmUserVO; |
| | | import com.vci.po.SmRolePO; |
| | | import com.vci.pagemodel.SmRoleVO; |
| | | import com.vci.omd.utils.ObjectTool; |
| | | import com.vci.starter.poi.bo.ReadExcelOption; |
| | | import com.vci.starter.poi.constant.ExcelLangCodeConstant; |
| | | import com.vci.starter.poi.util.ExcelUtil; |
| | | import com.vci.starter.web.constant.QueryOptionConstant; |
| | | import com.vci.starter.web.enumpck.UserSecretEnum; |
| | | import com.vci.starter.web.exception.VciBaseException; |
| | | import com.vci.starter.web.pagemodel.*; |
| | | import com.vci.starter.web.util.LangBaseUtil; |
| | |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | |
| | | */ |
| | | @Autowired |
| | | private WebBoServiceI boService; |
| | | |
| | | /** |
| | | * 用户查询服务 |
| | | */ |
| | | @Autowired |
| | | @Lazy |
| | | private SmUserQueryServiceI smUserQueryServiceI; |
| | | |
| | | /** |
| | | * 平台调用客户端 |
| | |
| | | if(Func.isEmpty(conditionMap)){ |
| | | return null; |
| | | } |
| | | VciQueryWrapperForDO queryWrapper = new VciQueryWrapperForDO(conditionMap,SmRoleForPlatform1.class); |
| | | VciQueryWrapperForDO queryWrapper = new VciQueryWrapperForDO(conditionMap, SmRoleForPlatform1.class); |
| | | List<SmRoleForPlatform1> smRoleForPlatform1s = boService.selectByQueryWrapper(queryWrapper, SmRoleForPlatform1.class); |
| | | if(Func.isNotEmpty(smRoleForPlatform1s) && Func.isNotBlank(smRoleForPlatform1s.get(0).getPluid())){ |
| | | //角色名不能重复所以直接取第一个元素 |
| | |
| | | VciBaseUtil.alertNotNull( |
| | | smRoleDTO,"添加的角色对象", |
| | | smRoleDTO.getName(),"角色名"); |
| | | //查询数据库中的,根据角色名查 |
| | | //根据角色主键查询,确保修改的角色存在 |
| | | Map<String, String> conditionMap = new HashMap<>(); |
| | | conditionMap.put("plname",smRoleDTO.getName()); |
| | | conditionMap.put("pluid",smRoleDTO.getOid()); |
| | | SmRoleVO dbSmRoleVO = getRoleByConditionMap(conditionMap); |
| | | //根据主键没查询到了用户 |
| | | if(Func.isEmpty(dbSmRoleVO) || Func.isBlank(dbSmRoleVO.getOid())){ |
| | | throw new PLException("500", new String[] { "当前修改的角色不存在!"}); |
| | | } |
| | | //角色名相等,但是主键不相等,说明修改为的角色名已存在,不能重复 |
| | | if(dbSmRoleVO.getName().equals(smRoleDTO.getName()) && !dbSmRoleVO.getOid().equals(smRoleDTO.getOid())){ |
| | | //查询数据库中的,根据角色名查重 |
| | | conditionMap.clear(); |
| | | conditionMap.put("plname",smRoleDTO.getName()); |
| | | //排除掉当前修改的用户 |
| | | conditionMap.put("pluid",QueryOptionConstant.NOTEQUAL + smRoleDTO.getName()); |
| | | SmRoleVO reapeatSmRoleVO = getRoleByConditionMap(conditionMap); |
| | | //说明修改为的角色名已存在,不能重复 |
| | | if(Func.isNotEmpty(reapeatSmRoleVO) && smRoleDTO.getName().equals(reapeatSmRoleVO)){ |
| | | throw new PLException("500", new String[] { "该角色名称已经存在,请修改!"}); |
| | | } |
| | | SmRoleDTO smRoleDTO1 = new SmRoleDTO(); |
| | |
| | | @Override |
| | | public boolean deleteRole(String[] ids) throws PLException { |
| | | VciBaseUtil.alertNotNull(ids,"要删除的角色主键"); |
| | | //使用主键判断角色是否被用户引用 |
| | | for (int i = 0; i < ids.length; i++) { |
| | | String roleName = this.checkIsUsed(ids[i]); |
| | | if(Func.isNotBlank(roleName)){ |
| | | throw new PLException("500",new String[]{"当前选中要删除的角色中存在【"+roleName+"】被引用!"}); |
| | | } |
| | | } |
| | | //具备连带删除的功能,如角色菜单授权表里面的授权信息 |
| | | return platformClientUtil.getFrameworkService().deleteRole( |
| | | ids, |
| | | new UserEntityInfo(WebThreadLocalUtil.getCurrentUserSessionInfoInThread().getUserId(), null) |
| | | ); |
| | | } |
| | | |
| | | /** |
| | | * 检查角色是否有在引用 |
| | | * @param roleOid |
| | | * @return |
| | | */ |
| | | private String checkIsUsed(String roleOid){ |
| | | List<SmUserVO> smUserVOS = smUserQueryServiceI.listUserByRoleOid(roleOid, null); |
| | | if (Func.isNotEmpty(smUserVOS)) { |
| | | return this.getRoleNameByRoleOid(roleOid); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | |
| | | * @throws VciBaseException |
| | | */ |
| | | @Override |
| | | public BaseResult importRole(File file) throws VciBaseException { |
| | | public BaseResult importRole(File file) throws Exception { |
| | | VciBaseUtil.alertNotNull(file,"excel文件"); |
| | | if(!file.exists()){ |
| | | throw new VciBaseException("导入的excel文件不存在,{0}",new String[]{file.getPath()}); |
| | |
| | | try { |
| | | SmRoleDTO smRoleDTO = new SmRoleDTO(); |
| | | BeanUtil.copy(smRolePO,smRoleDTO); |
| | | //SessionInfo loginUser = WebThreadLocalUtil.getCurrentUserSessionInfoInThread(); |
| | | String userId = "developer";//loginUser.getUserId(); |
| | | SessionInfo loginUser = WebThreadLocalUtil.getCurrentUserSessionInfoInThread(); |
| | | String userId = loginUser.getUserId(); |
| | | //角色类型,这里设置了会在changeRoleObjectToRoleInfo中转换 |
| | | if(UserTypeEnum.SUPPER_ADMIN.getValue().equals("0")){ |
| | | smRoleDTO.setRoleClassify(RoleClassifyEnum.MANAGE.getValue()); |