Merge pull request '人员卡片按钮权限' (#51) from feature/dxf into develop

Reviewed-on: #51
pull/55/head
dxfeng 2 years ago
commit 76081c3213

@ -0,0 +1,39 @@
package com.engine.organization.entity.personnelcard.po;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
/**
* @author:dxfeng
* @createTime: 2022/11/10
* @version: 1.0
*/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class CardButtonPO {
private Integer id;
private String name;
private Integer status;
private String url;
private String roles;
private String sysDefault;
private Long creator;
private int deleteType;
private Date createTime;
private Date updateTime;
}

@ -0,0 +1,16 @@
package com.engine.organization.mapper.personnelcard;
import com.engine.organization.entity.personnelcard.po.CardButtonPO;
import java.util.List;
/**
* @Author weaver_cl
* @Description:
* @Date 2022/10/24
* @Version V1.0
**/
public interface CardButtonMapper {
List<CardButtonPO> listAll();
}

@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.engine.organization.mapper.personnelcard.CardButtonMapper">
<resultMap id="BaseResultMap" type="com.engine.organization.entity.personnelcard.po.CardButtonPO">
<result column="id" property="id"/>
<result column="name" property="name"/>
<result column="status" property="status"/>
<result column="url" property="url"/>
<result column="roles" property="roles"/>
<result column="sys_default" property="sysDefault"/>
<result column="creator" property="creator"/>
<result column="delete_type" property="deleteType"/>
<result column="create_time" property="createTime"/>
<result column="update_time" property="updateTime"/>
</resultMap>
<!-- 表字段 -->
<sql id="baseColumns">
t
.
id
, t.name
, t.status
, t.url
, t.roles
, t.sys_default
, t.creator
, t.delete_type
, t.create_time
, t.update_time
</sql>
<select id="listAll" resultType="com.engine.organization.entity.personnelcard.po.CardButtonPO">
select
<include refid="baseColumns"/>
from jcl_org_cardbutton where delete_type = 0
</select>
</mapper>

@ -55,4 +55,16 @@ public interface CardAccessService {
*/
int updateTabName(String name,Integer id);
/**
*
* @return
*/
Map<String, Object> getCardButtonFrom();
/**
*
* @param params
* @return
*/
int saveCardButton(Map<String, Object> params);
}

@ -3,17 +3,21 @@ package com.engine.organization.service.impl;
import com.cloudstore.eccom.result.WeaResultMsg;
import com.engine.core.impl.Service;
import com.engine.organization.component.OrganizationWeaTable;
import com.engine.organization.entity.detach.vo.ManagerDetachVO;
import com.engine.organization.entity.extend.bo.ExtendInfoBO;
import com.engine.organization.entity.extend.po.ExtendInfoPO;
import com.engine.organization.entity.personnelcard.po.CardAccessPO;
import com.engine.organization.entity.personnelcard.po.CardButtonPO;
import com.engine.organization.entity.personnelcard.vo.CardAccessVO;
import com.engine.organization.mapper.personnelcard.CardAccessMapper;
import com.engine.organization.mapper.personnelcard.CardButtonMapper;
import com.engine.organization.service.CardAccessService;
import com.engine.organization.transmethod.SystemTransMethod;
import com.engine.organization.util.HasRightUtil;
import com.engine.organization.util.db.MapperProxyFactory;
import weaver.general.Util;
import java.util.*;
import java.util.stream.Collectors;
/**
* @Author weaver_cl
@ -29,6 +33,10 @@ public class CardAccessServiceImpl extends Service implements CardAccessService
return MapperProxyFactory.getProxy(CardAccessMapper.class);
}
private CardButtonMapper getCardButtonMapper() {
return MapperProxyFactory.getProxy(CardButtonMapper.class);
}
@Override
public Map<String, Object> tablePage() {
Map<String, Object> resultMap = new HashMap<>();
@ -85,5 +93,44 @@ public class CardAccessServiceImpl extends Service implements CardAccessService
return getCardAccessMapper().updateTabName(name,id);
}
@Override
public Map<String, Object> getCardButtonFrom() {
// 区分主表明细表
String tableName = "JCL_ORG_CARDBUTTON";
List<ExtendInfoPO> infoPOList = new ArrayList<>();
infoPOList.add(ExtendInfoPO.builder().id(null).tableName(tableName).fieldName("name").fieldNameDesc("按钮名称").fieldType("varchar(50)").controlType(1).browserType("1").customValue("[\"input\",\"text\",\"50\"]").showOrder(1).isSystemDefault(0).build());
infoPOList.add(ExtendInfoPO.builder().id(null).tableName(tableName).fieldName("status").fieldNameDesc("启用").fieldType("char(1)").controlType(1).browserType("1").customValue("[\"check\"]").showOrder(2).isSystemDefault(0).build());
infoPOList.add(ExtendInfoPO.builder().id(null).tableName(tableName).fieldName("url").fieldNameDesc("跳转地址").fieldType("varchar(1000)").controlType(1).browserType("1").customValue("[\"input\",\"text\",\"1000\"]").showOrder(3).isSystemDefault(0).build());
infoPOList.add(ExtendInfoPO.builder().id(null).tableName(tableName).fieldName("roles").fieldNameDesc("角色").fieldType("text").controlType(1).browserType("65").customValue("[\"browser\",{\"valueSpan\":\"多角色\",\"replaceDatas\":[{\"itemorderid\":\"65\",\"name\":\"多角色\",\"id\":\"65\",\"parenttitle\":\"人员\",\"title\":\"人员-多角色\"}],\"value\":\"65\"}]").showOrder(4).isSystemDefault(0).build());
Map<String, Object> tabinfoMap = new HashMap<>();
tabinfoMap.put("columns", ExtendInfoBO.convertInfoListToTable(user, infoPOList, 2, false));
// 去除null 元素
List<CardButtonPO> cardButtonPOS = getCardButtonMapper().listAll();
// 兼容Oracle,map的key转换为小写
List<Map<String, Object>> collect = cardButtonPOS.stream().map(item -> {
Map<String, Object> resultMap = new HashMap<>();
resultMap.put("id", item.getId());
resultMap.put("name", item.getName());
resultMap.put("status", item.getStatus());
resultMap.put("url", item.getUrl());
resultMap.put("roles", item.getRoles());
resultMap.put("rolesspan", SystemTransMethod.getRoleName(item.getRoles()));
return resultMap;
}).collect(Collectors.toList());
tabinfoMap.put("datas", collect);
tabinfoMap.put("api_status", true);
return tabinfoMap;
}
@Override
public int saveCardButton(Map<String, Object> params) {
return 0;
}
}

@ -13,6 +13,7 @@ import com.engine.organization.entity.extend.po.ExtendTitlePO;
import com.engine.organization.enums.ModuleTypeEnum;
import com.engine.organization.mapper.codesetting.CodeRuleMapper;
import com.engine.organization.mapper.extend.*;
import com.engine.organization.mapper.hrmresource.HrmResourceMapper;
import com.engine.organization.service.ExtService;
import com.engine.organization.util.OrganizationAssert;
import com.engine.organization.util.db.DBType;
@ -67,9 +68,22 @@ public class ExtServiceImpl extends Service implements ExtService {
if (StringUtils.isEmpty(fields)) {
return conditionItems;
}
List<String> readOnlyFieldList = new ArrayList<>(Arrays.asList(readOnlyFields));
//TODO 细化权限
if ("4".equals(extendType) && !user.isAdmin()) {
String ecResourceId = MapperProxyFactory.getProxy(HrmResourceMapper.class).getEcResourceId(String.valueOf(id));
if (Util.null2String(user.getUID()).equals(ecResourceId)) {
List<String> readOnlyList = infoPOList.stream().filter(item -> !"1".equals(Util.null2String(item.getIsModify()))).map(ExtendInfoPO::getFieldName).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(readOnlyList)) {
readOnlyFieldList.addAll(readOnlyList);
}
} else {
viewAttr = 1;
}
}
ExtendInfoParams infoParams = ExtendInfoParams.builder().tableName(tableName).fields(fields).params(null).id(id).build();
Map<String, Object> compExtMap = getExtMapper().listExt(infoParams);
List<String> readOnlyFieldList = Arrays.asList(readOnlyFields);
// 组装拓展页内容
for (ExtendInfoPO extendInfoPO : infoPOList) {
SearchConditionItem item = ExtendInfoBO.getSearchConditionItem(user, viewAttr, extendInfoPO, null == compExtMap ? null : compExtMap.get(DBType.isOracle() ? extendInfoPO.getFieldName().toUpperCase() : extendInfoPO.getFieldName()));
@ -136,8 +150,19 @@ public class ExtServiceImpl extends Service implements ExtService {
// 查询明细表
List<ExtendGroupPO> extendGroupList = getExtendGroupMapper().listGroupByPid(groupId, "1");
for (ExtendGroupPO extendGroup : extendGroupList) {
infoPOList.addAll(getExtendInfoMapper().listFields(extendType, extendGroup.getId() + "", tableName, "", "1"));
List<ExtendInfoPO> extendInfoPOS = getExtendInfoMapper().listFields(extendType, extendGroup.getId() + "", tableName, "", "1");
if (CollectionUtils.isNotEmpty(extendInfoPOS)) {
infoPOList.addAll(extendInfoPOS);
}
}
Map<Long, List<ExtendInfoPO>> allFields = infoPOList.stream().collect(Collectors.groupingBy(ExtendInfoPO::getExtendGroupId));
//TODO 控制展示权限
boolean checkRight = true;
if ("4".equals(extendType) && !user.isAdmin()) {
checkRight = false;
infoPOList.removeIf(item -> !"1".equals(Util.null2String(item.getIsModify())));
}
// 查询所有分布模块,拓展明细表信息
Map<Long, List<ExtendInfoPO>> groupMap = infoPOList.stream().collect(Collectors.groupingBy(ExtendInfoPO::getExtendGroupId));
// 遍历Map,组装数据
@ -146,11 +171,12 @@ public class ExtServiceImpl extends Service implements ExtService {
tableMap.put("hide", false);
tableMap.put("tabname", getExtendGroupMapper().getGroupNameById(Util.null2String(entry.getKey())));
Map<String, Object> tabinfoMap = new HashMap<>();
//TODO 需优化
tabinfoMap.put("columns", ExtendInfoBO.convertInfoListToTable(user, entry.getValue(), viewAttr, showLabel));
tabinfoMap.put("rownum", "rownum" + entry.getKey());
// 浏览按钮添加filespan字段
String fields = entry.getValue().stream().map(item -> {
String fields = allFields.get(entry.getKey()).stream().map(item -> {
if (BROWSER_TYPE.equals(item.getControlType())) {
return item.getFieldName() + "," + item.getFieldName() + "span";
}
@ -160,12 +186,14 @@ public class ExtServiceImpl extends Service implements ExtService {
List<Map<String, Object>> maps = getExtDTMapper().listCompExtDT(tableName, id, fields);
maps.removeIf(Objects::isNull);
// 兼容Oracle,map的key转换为小写
boolean finalCheckRight = checkRight;
List<Map<String, Object>> collect = maps.stream().map(item -> {
Map<String, Object> resultMap = new HashMap<>();
Set<String> keys = item.keySet();
for (String key : keys) {
resultMap.put(key.toLowerCase(), item.get(key));
}
resultMap.put("viewAttr", finalCheckRight ? 2 : 1);
return resultMap;
}).collect(Collectors.toList());
tabinfoMap.put("datas", collect);

@ -229,7 +229,9 @@ public class HrmPersonnelCardServiceImpl extends Service implements HrmPersonnel
boolean hasAccess = false;
CardAccessPO cardAccessPO = MapperProxyFactory.getProxy(CardAccessMapper.class).selectById(typeId);
OrganizationAssert.notNull(cardAccessPO, "未查询到对应卡片权限,");
if(null==cardAccessPO){
return false;
}
// 所有人返回true
if (1 == cardAccessPO.getAllPeople()) {
return true;
@ -259,9 +261,9 @@ public class HrmPersonnelCardServiceImpl extends Service implements HrmPersonnel
List<Object> roleInfo = hrmCommonService.getRoleInfo(user.getUID());
for (Object o : roleInfo) {
Map<String, String> roleDetailMap = (Map<String, String>) o;
int roleid = Util.getIntValue(roleDetailMap.get("roleid"), -1);
int roleId = Util.getIntValue(roleDetailMap.get("roleid"), -1);
// 判断角色是否满足,角色等级是否满足
hasAccess = hasAccess || accessRoleIds.contains(Util.null2String(roleid));
hasAccess = hasAccess || accessRoleIds.contains(Util.null2String(roleId));
if (hasAccess) {
break;
}

@ -597,10 +597,12 @@ public class ResourceSyncUtil {
public static Map<String, Object> editResourceBase(User user, Map<String, Object> params) {
Map<String, Object> retMap = new HashMap<>();
try {
String id = Util.null2String(params.get("id"));
// 判断是否为本人操作
boolean canEdit = HrmUserVarify.checkUserRight("HrmResourceEdit:Edit", user);
if (!canEdit) {
if (!canEdit && !Util.null2String(user.getUID()).equals(id)) {
retMap.put("status", "-1");
retMap.put("message", ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(22620,weaver.general.ThreadVarLanguage.getLang())+"");
retMap.put("message", "" + weaver.systeminfo.SystemEnv.getHtmlLabelName(22620, weaver.general.ThreadVarLanguage.getLang()) + "");
return retMap;
}
RecordSet rs = new RecordSet();
@ -610,7 +612,7 @@ public class ResourceSyncUtil {
CrmShareBase CrmShareBase = new CrmShareBase();
StringBuilder para;
String id = Util.null2String(params.get("id"));
if (id.length()==0) {
retMap.put("status", "-1");
retMap.put("message", ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(22620,weaver.general.ThreadVarLanguage.getLang())+"");

@ -2,10 +2,8 @@ package com.engine.organization.web;
import com.engine.common.util.ParamUtil;
import com.engine.common.util.ServiceUtil;
import com.engine.organization.entity.detach.param.ManagerDetachParam;
import com.engine.organization.util.response.ReturnResult;
import com.engine.organization.wrapper.CardAccessWrapper;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;
@ -29,7 +27,7 @@ import java.util.Map;
public class CardAccessController {
public CardAccessWrapper getCardAccessWrapper(User user) {
return ServiceUtil.getService(CardAccessWrapper.class,user);
return ServiceUtil.getService(CardAccessWrapper.class, user);
}
@ -69,4 +67,16 @@ public class CardAccessController {
return ReturnResult.exceptionHandle(e);
}
}
@GET
@Path("/getCardButtonFrom")
@Produces(MediaType.APPLICATION_JSON)
public ReturnResult getCardButtonFrom(@Context HttpServletRequest request, @Context HttpServletResponse response) {
try {
User user = HrmUserVarify.getUser(request, response);
return ReturnResult.successed(getCardAccessWrapper(user).getCardButtonFrom());
} catch (Exception e) {
return ReturnResult.exceptionHandle(e);
}
}
}

@ -17,7 +17,7 @@ import java.util.Map;
public class CardAccessWrapper extends OrganizationWrapper {
public CardAccessService getCardAccessService(User user) {
return ServiceUtil.getService(CardAccessServiceImpl.class,user);
return ServiceUtil.getService(CardAccessServiceImpl.class, user);
}
public Map<String, Object> listPage() {
@ -31,4 +31,8 @@ public class CardAccessWrapper extends OrganizationWrapper {
public int save(Map<String, Object> params) {
return getCardAccessService(user).save(params);
}
public Map<String, Object> getCardButtonFrom() {
return getCardAccessService(user).getCardButtonFrom();
}
}

Loading…
Cancel
Save