| | |
| | | package com.vci.frameworkcore.compatibility.impl; |
| | | |
| | | import com.vci.corba.common.PLException; |
| | | import com.vci.corba.common.data.UserEntityInfo; |
| | | import com.vci.corba.omd.data.BusinessObject; |
| | | import com.vci.frameworkcore.compatibility.SmRoleQueryServiceI; |
| | | import com.vci.frameworkcore.constant.FrameWorkBtmTypeConstant; |
| | |
| | | import com.vci.starter.web.wrapper.VciQueryWrapperForDO; |
| | | import com.vci.web.properties.WebProperties; |
| | | import com.vci.web.service.WebBoServiceI; |
| | | import com.vci.web.util.Func; |
| | | import com.vci.web.util.PlatformClientUtil; |
| | | import com.vci.web.util.WebUtil; |
| | | import org.apache.commons.lang3.StringUtils; |
| | |
| | | */ |
| | | @Autowired |
| | | private WebBoServiceI boService; |
| | | |
| | | /** |
| | | * 平台调用客户端 |
| | | */ |
| | | @Autowired |
| | | private PlatformClientUtil platformClientUtil; |
| | | |
| | | /** |
| | | * 根据角色主键获取角色的信息 |
| | |
| | | } |
| | | |
| | | /** |
| | | * 该方法只支持一次只允许单个用户分配多个角色,一对多 |
| | | * @param userOid |
| | | * @param roleIds |
| | | * @return |
| | | */ |
| | | @Override |
| | | public boolean saveRights(String userOid, String[] roleIds) throws PLException { |
| | | VciBaseUtil.alertNotNull(userOid,"用户主键"); |
| | | //roleIds允许为空,为空时清空当前用户的权限 |
| | | //先查重 |
| | | if(Func.isNotEmpty(roleIds)){ |
| | | List<String> repeatRoleOidList = new ArrayList<>(); |
| | | //循环进行查重,避免in大于1000 |
| | | WebUtil.switchCollectionForOracleIn(Arrays.asList(roleIds)).stream().forEach(deptoids->{ |
| | | String sql = "select pluseruid,plroleuid from pluserrole where pluseruid = '" + userOid |
| | | + "' and " + "plroleuid in ("+WebUtil.toInSql(deptoids.toArray(new String[0]))+")"; |
| | | List<BusinessObject> cbos = boService.queryBySql(sql, null); |
| | | if(!CollectionUtils.isEmpty(cbos)){ |
| | | cbos.stream().forEach(cbo->{ |
| | | repeatRoleOidList.add(ObjectTool.getNewBOAttributeValue(cbo,"plroleuid")); |
| | | }); |
| | | } |
| | | }); |
| | | //移除重复的 |
| | | List<String> tempList = new ArrayList<>(Arrays.asList(roleIds)); |
| | | tempList.removeAll(repeatRoleOidList); |
| | | roleIds = tempList.toArray(new String[tempList.size()]); |
| | | } |
| | | return platformClientUtil.getFrameworkService().saveRights(roleIds,new String[]{userOid},new UserEntityInfo()); |
| | | } |
| | | |
| | | /** |
| | | * 角色的转换,默认全部是bs控制的角色 |
| | | * @param roleForPlatform1List 原平台的角色 |
| | | * @return 角色的显示对象 |