This commit is contained in:
parent
fad1402b06
commit
87a5eb59c6
|
|
@ -0,0 +1,26 @@
|
|||
package com.engine.salary.entity.auth.dto;
|
||||
|
||||
import com.engine.salary.annotation.TableTitle;
|
||||
import com.engine.salary.enums.auth.DataTargetTypeEnum;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class AuthDataDTO {
|
||||
|
||||
private Long id;
|
||||
|
||||
@TableTitle(title = "对象类型",dataIndex = "targetType",key = "targetType")
|
||||
private String targetTypeName;
|
||||
private DataTargetTypeEnum targetType;
|
||||
|
||||
@TableTitle(title = "对象",dataIndex = "targetName",key = "targetName")
|
||||
private String targetName;
|
||||
private String target;
|
||||
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
package com.engine.salary.entity.auth.dto;
|
||||
|
||||
import com.engine.salary.annotation.TableTitle;
|
||||
import com.engine.salary.enums.auth.MemberTargetTypeEnum;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
|
@ -15,9 +16,11 @@ public class AuthMemberDTO {
|
|||
private Long id;
|
||||
|
||||
@TableTitle(title = "对象类型",dataIndex = "targetType",key = "targetType")
|
||||
private String targetType;
|
||||
private String targetTypeName;
|
||||
private MemberTargetTypeEnum targetType;
|
||||
|
||||
@TableTitle(title = "对象",dataIndex = "targetName",key = "targetName")
|
||||
private String targetName;
|
||||
private String target;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
package com.engine.salary.entity.auth.param;
|
||||
|
||||
import com.engine.salary.common.BaseQueryParam;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class AuthDataQueryParam extends BaseQueryParam {
|
||||
|
||||
private Long roleId;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
package com.engine.salary.entity.auth.param;
|
||||
|
||||
|
||||
import com.engine.salary.enums.auth.DataLinkEnum;
|
||||
import com.engine.salary.enums.auth.DataTargetTypeEnum;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 数据
|
||||
* <p>Copyright: Copyright (c) 2024</p>
|
||||
* <p>Company: 泛微软件</p>
|
||||
*
|
||||
* @author qiantao
|
||||
* @version 1.0
|
||||
**/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class AuthDataSaveParam {
|
||||
|
||||
private Long roleId;
|
||||
|
||||
private DataLinkEnum link;
|
||||
|
||||
private DataTargetTypeEnum targetType;
|
||||
|
||||
private String target;
|
||||
|
||||
private String targetName;
|
||||
|
||||
private Integer sortedIndex;
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
package com.engine.salary.entity.auth.param;
|
||||
|
||||
|
||||
import com.engine.salary.enums.auth.MemberTargetTypeEnum;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
|
@ -14,7 +15,7 @@ public class AuthMemberSaveParam {
|
|||
|
||||
private Long roleId;
|
||||
|
||||
private Integer targetType;
|
||||
private MemberTargetTypeEnum targetType;
|
||||
|
||||
private String target;
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,90 @@
|
|||
package com.engine.salary.entity.auth.po;
|
||||
|
||||
import com.engine.hrmelog.annotation.ElogTransform;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 数据
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class AuthDataPO {
|
||||
@ElogTransform(name = "id")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 角色id
|
||||
*/
|
||||
@ElogTransform(name = "角色id")
|
||||
private Long roleId;
|
||||
|
||||
/**
|
||||
* 连接符,交、并、补
|
||||
*/
|
||||
@ElogTransform(name = "连接符,交、并、补")
|
||||
private Integer link;
|
||||
|
||||
/**
|
||||
* 数据类型,1:人员、2:部门、3:岗位、4:分部、5:角色、6:安全级别 、7:所有人 、8:登录人、9:账套、10:sql
|
||||
*/
|
||||
@ElogTransform(name = "数据类型")
|
||||
private Integer targetType;
|
||||
|
||||
/**
|
||||
* 对象id
|
||||
*/
|
||||
@ElogTransform(name = "对象id")
|
||||
private String target;
|
||||
|
||||
/**
|
||||
* 对象名称
|
||||
*/
|
||||
@ElogTransform(name = "对象名称")
|
||||
private String targetName;
|
||||
|
||||
@ElogTransform(name = "排序")
|
||||
private Integer sortedIndex;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@ElogTransform(name = "创建人")
|
||||
private Long creator;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@ElogTransform(name = "创建时间")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@ElogTransform(name = "更新时间")
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 是否已删除。0:未删除、1:已删除
|
||||
*/
|
||||
@ElogTransform(name = "是否已删除。0:未删除、1:已删除")
|
||||
private Integer deleteType;
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
@ElogTransform(name = "租户ID")
|
||||
private String tenantKey;
|
||||
|
||||
|
||||
//主键id集合
|
||||
private Collection<Long> ids;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
package com.engine.salary.entity.auth.po;
|
||||
|
||||
import com.engine.hrmelog.annotation.ElogTransform;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 角色数据明细
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class AuthRoleDataPO {
|
||||
@ElogTransform(name = "id")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 角色id
|
||||
*/
|
||||
@ElogTransform(name = "角色id")
|
||||
private Long roleId;
|
||||
|
||||
/**
|
||||
* 人员id
|
||||
*/
|
||||
@ElogTransform(name = "人员id")
|
||||
private Long employeeId;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@ElogTransform(name = "创建人")
|
||||
private Long creator;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@ElogTransform(name = "创建时间")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@ElogTransform(name = "更新时间")
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 是否已删除。0:未删除、1:已删除
|
||||
*/
|
||||
@ElogTransform(name = "是否已删除。0:未删除、1:已删除")
|
||||
private Integer deleteType;
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
@ElogTransform(name = "租户ID")
|
||||
private String tenantKey;
|
||||
|
||||
|
||||
//主键id集合
|
||||
private Collection<Long> ids;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,79 @@
|
|||
package com.engine.salary.enums.auth;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.engine.salary.enums.BaseEnum;
|
||||
import com.engine.salary.exception.SalaryRunTimeException;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 或者、并且、排除
|
||||
* <p>Copyright: Copyright (c) 2024</p>
|
||||
* <p>Company: 泛微软件</p>
|
||||
*
|
||||
* @author qiantao
|
||||
* @version 1.0
|
||||
**/
|
||||
public enum DataLinkEnum implements BaseEnum<Integer> {
|
||||
|
||||
|
||||
OR(1, "并", 87627) {
|
||||
@Override
|
||||
public Set<Long> calculation(Collection<Long> coll1, Collection<Long> coll2) {
|
||||
return new HashSet<>(CollectionUtil.union(coll1, coll2));
|
||||
}
|
||||
},
|
||||
AND(2, "交", 87626) {
|
||||
@Override
|
||||
public Set<Long> calculation(Collection<Long> coll1, Collection<Long> coll2) {
|
||||
return new HashSet<>(CollectionUtil.intersection(coll1, coll2));
|
||||
}
|
||||
},
|
||||
NOT_IN(3, "补", 87626) {
|
||||
@Override
|
||||
public Set<Long> calculation(Collection<Long> coll1, Collection<Long> coll2) {
|
||||
return new HashSet<>(CollectionUtil.disjunction(coll1, coll2));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
private Integer value;
|
||||
private String defaultLabel;
|
||||
private int labelId;
|
||||
|
||||
DataLinkEnum(Integer value, String defaultLabel, int labelId) {
|
||||
this.value = value;
|
||||
this.defaultLabel = defaultLabel;
|
||||
this.labelId = labelId;
|
||||
}
|
||||
|
||||
public abstract Set<Long> calculation(Collection<Long> coll1, Collection<Long> coll2);
|
||||
|
||||
|
||||
@Override
|
||||
public Integer getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultLabel() {
|
||||
return defaultLabel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getLabelId() {
|
||||
return labelId;
|
||||
}
|
||||
|
||||
public static DataLinkEnum parseByValue(int value) {
|
||||
for (DataLinkEnum typeEnum : DataLinkEnum.values()) {
|
||||
if (Objects.equals(typeEnum.getValue(), value)) {
|
||||
return typeEnum;
|
||||
}
|
||||
}
|
||||
throw new SalaryRunTimeException("未找到对应的枚举");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,164 @@
|
|||
package com.engine.salary.enums.auth;
|
||||
|
||||
import com.engine.common.service.HrmCommonService;
|
||||
import com.engine.common.service.impl.HrmCommonServiceImpl;
|
||||
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
|
||||
import com.engine.salary.enums.BaseEnum;
|
||||
import com.engine.salary.exception.SalaryRunTimeException;
|
||||
import com.engine.salary.service.impl.SalaryEmployeeServiceImpl;
|
||||
import com.engine.salary.util.SalaryEntityUtil;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.Util;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 对象类型,1:人员、2:部门、3:岗位、4:分部、5:角色、6:安全级别 、7:所有人 、8:登录人、9:账套、10:sql
|
||||
* <p>Copyright: Copyright (c) 2024</p>
|
||||
* <p>Company: 泛微软件</p>
|
||||
*
|
||||
* @author qiantao
|
||||
* @version 1.0
|
||||
**/
|
||||
public enum DataTargetTypeEnum implements BaseEnum<Integer> {
|
||||
|
||||
|
||||
EMP(1, "人员", 87627) {
|
||||
@Override
|
||||
public Set<Long> getEmpIds(String target, Object... param) {
|
||||
Set<Long> list = new HashSet<>();
|
||||
list.add(Long.valueOf(target));
|
||||
return list;
|
||||
}
|
||||
},
|
||||
DEPARTMENT(2, "部门", 87626) {
|
||||
@Override
|
||||
public Set<Long> getEmpIds(String target, Object... param) {
|
||||
SalaryEmployeeServiceImpl salaryEmployeeService = new SalaryEmployeeServiceImpl();
|
||||
return new HashSet<>(salaryEmployeeService.listByDepartment(Collections.singletonList(Long.valueOf(target))));
|
||||
}
|
||||
},
|
||||
JOB(3, "岗位", 87626) {
|
||||
@Override
|
||||
public Set<Long> getEmpIds(String target, Object... param) {
|
||||
SalaryEmployeeServiceImpl salaryEmployeeService = new SalaryEmployeeServiceImpl();
|
||||
return new HashSet<>(salaryEmployeeService.listByJob(Collections.singletonList(Long.valueOf(target))));
|
||||
}
|
||||
},
|
||||
SUB_COMPANY(4, "分部", 87626) {
|
||||
@Override
|
||||
public Set<Long> getEmpIds(String target, Object... param) {
|
||||
SalaryEmployeeServiceImpl salaryEmployeeService = new SalaryEmployeeServiceImpl();
|
||||
return new HashSet<>(salaryEmployeeService.listBySubCompany(Collections.singletonList(Long.valueOf(target))));
|
||||
}
|
||||
},
|
||||
ROLE(5, "角色", 87626) {
|
||||
@Override
|
||||
public Set<Long> getEmpIds(String target, Object... param) {
|
||||
HrmCommonService hrmCommonService = new HrmCommonServiceImpl();
|
||||
Set<Long> memberList = new HashSet<>();
|
||||
List<Object> ids = hrmCommonService.getRoleMembers(target, "2");
|
||||
ids.forEach(id -> memberList.add(Long.parseLong(id.toString())));
|
||||
return memberList;
|
||||
}
|
||||
},
|
||||
LEVEL(6, "安全级别", 87626) {
|
||||
@Override
|
||||
public Set<Long> getEmpIds(String target, Object... param) {
|
||||
String[] split = target.split("-");
|
||||
int minLevel = split[0] == null ? 0 : Integer.parseInt(split[0]);
|
||||
int maxLevel = split[1] == null ? 100 : Integer.parseInt(split[1]);
|
||||
Set<Long> memberList = new HashSet<>();
|
||||
RecordSet rs = new RecordSet();
|
||||
if (rs.execute("select id from hrmresource where level between " + minLevel + " and " + maxLevel + " and status not in (7) and (accounttype is null or accounttype = 0) ")) {
|
||||
while (rs.next()) {
|
||||
memberList.add(Long.parseLong(rs.getString("id")));
|
||||
}
|
||||
}
|
||||
return memberList;
|
||||
}
|
||||
},
|
||||
ALL(7, "所有人", 87626) {
|
||||
@Override
|
||||
public Set<Long> getEmpIds(String target, Object... param) {
|
||||
Set<Long> memberList = new HashSet<>();
|
||||
RecordSet rs = new RecordSet();
|
||||
if (rs.execute("select id from hrmresource where status not in (7) and (accounttype is null or accounttype = 0) ")) {
|
||||
while (rs.next()) {
|
||||
memberList.add(Long.parseLong(rs.getString("id")));
|
||||
}
|
||||
}
|
||||
return memberList;
|
||||
}
|
||||
},
|
||||
LOGIN_PERSON(8, "登录人", 87626) {
|
||||
//参数1,登录人信息
|
||||
@Override
|
||||
public Set<Long> getEmpIds(String target, Object... param) {
|
||||
LoginPersonTargetTypeEnum loginPersonTargetTypeEnum = LoginPersonTargetTypeEnum.parseByValue(Integer.parseInt(target));
|
||||
return loginPersonTargetTypeEnum.getEmpIds((DataCollectionEmployee) param[0]);
|
||||
}
|
||||
},
|
||||
SOB(9, "账套", 87626) {
|
||||
@Override
|
||||
public Set<Long> getEmpIds(String target, Object... param) {
|
||||
SalaryEmployeeServiceImpl salaryEmployeeService = new SalaryEmployeeServiceImpl();
|
||||
List<DataCollectionEmployee> employeeList = salaryEmployeeService.listBySalarySobId(Long.valueOf(target));
|
||||
return SalaryEntityUtil.properties(employeeList, DataCollectionEmployee::getEmployeeId);
|
||||
}
|
||||
},
|
||||
SQL(10, "sql", 87626) {
|
||||
@Override
|
||||
public Set<Long> getEmpIds(String target, Object... param) {
|
||||
//参数1,登录人信息
|
||||
DataCollectionEmployee employee = (DataCollectionEmployee) param[0];
|
||||
Set<Long> memberList = new HashSet<>();
|
||||
target = target.replaceAll("$uid$", Util.null2String(employee.getEmployeeId()));
|
||||
RecordSet rs = new RecordSet();
|
||||
if (rs.execute(target)) {
|
||||
while (rs.next()) {
|
||||
memberList.add(Long.parseLong(rs.getString("id")));
|
||||
}
|
||||
}
|
||||
return memberList;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
private Integer value;
|
||||
private String defaultLabel;
|
||||
private int labelId;
|
||||
|
||||
DataTargetTypeEnum(Integer value, String defaultLabel, int labelId) {
|
||||
this.value = value;
|
||||
this.defaultLabel = defaultLabel;
|
||||
this.labelId = labelId;
|
||||
}
|
||||
|
||||
public abstract Set<Long> getEmpIds(String target, Object... param);
|
||||
|
||||
|
||||
@Override
|
||||
public Integer getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultLabel() {
|
||||
return defaultLabel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getLabelId() {
|
||||
return labelId;
|
||||
}
|
||||
|
||||
public static DataTargetTypeEnum parseByValue(int value) {
|
||||
for (DataTargetTypeEnum typeEnum : DataTargetTypeEnum.values()) {
|
||||
if (Objects.equals(typeEnum.getValue(), value)) {
|
||||
return typeEnum;
|
||||
}
|
||||
}
|
||||
throw new SalaryRunTimeException("未找到对应的枚举");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,123 @@
|
|||
package com.engine.salary.enums.auth;
|
||||
|
||||
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
|
||||
import com.engine.salary.enums.BaseEnum;
|
||||
import com.engine.salary.exception.SalaryRunTimeException;
|
||||
import weaver.conn.RecordSet;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 登录人信息类型
|
||||
* <p>Copyright: Copyright (c) 2024</p>
|
||||
* <p>Company: 泛微软件</p>
|
||||
*
|
||||
* @author qiantao
|
||||
* @version 1.0
|
||||
**/
|
||||
public enum LoginPersonTargetTypeEnum implements BaseEnum<Integer> {
|
||||
|
||||
|
||||
self(1, "本人", 87627) {
|
||||
@Override
|
||||
public Set<Long> getEmpIds(DataCollectionEmployee employee) {
|
||||
Set<Long> memberList = new HashSet<>();
|
||||
memberList.add(employee.getEmployeeId());
|
||||
return memberList;
|
||||
}
|
||||
},
|
||||
SUBORDINATE(2, "下属", 87626) {
|
||||
@Override
|
||||
public Set<Long> getEmpIds(DataCollectionEmployee employee) {
|
||||
String sql = "select id from hrmresource where status not in (7) and (accounttype is null or accounttype = 0) and managerstr like '%," + employee.getEmployeeId() + ",%' and ";
|
||||
Set<Long> memberList = new HashSet<>();
|
||||
RecordSet rs = new RecordSet();
|
||||
if (rs.execute(sql)) {
|
||||
while (rs.next()) {
|
||||
memberList.add(Long.parseLong(rs.getString("id")));
|
||||
}
|
||||
}
|
||||
return memberList;
|
||||
}
|
||||
},
|
||||
DEPARTMENT(3, "本部门", 87626) {
|
||||
@Override
|
||||
public Set<Long> getEmpIds(DataCollectionEmployee employee) {
|
||||
String sql = "select id from hrmresource where status not in (7) and (accounttype is null or accounttype = 0) and departmentid =" + employee.getDepartmentId();
|
||||
Set<Long> memberList = new HashSet<>();
|
||||
RecordSet rs = new RecordSet();
|
||||
if (rs.execute(sql)) {
|
||||
while (rs.next()) {
|
||||
memberList.add(Long.parseLong(rs.getString("id")));
|
||||
}
|
||||
}
|
||||
return memberList;
|
||||
}
|
||||
},
|
||||
SUB_COMPANY(4, "本分部", 87626) {
|
||||
@Override
|
||||
public Set<Long> getEmpIds(DataCollectionEmployee employee) {
|
||||
String sql = "select id from hrmresource where status not in (7) and (accounttype is null or accounttype = 0) and subcompanyid1 =" + employee.getSubcompanyid();
|
||||
Set<Long> memberList = new HashSet<>();
|
||||
RecordSet rs = new RecordSet();
|
||||
if (rs.execute(sql)) {
|
||||
while (rs.next()) {
|
||||
memberList.add(Long.parseLong(rs.getString("id")));
|
||||
}
|
||||
}
|
||||
return memberList;
|
||||
}
|
||||
},
|
||||
JOB(5, "本岗位", 87626) {
|
||||
@Override
|
||||
public Set<Long> getEmpIds(DataCollectionEmployee employee) {
|
||||
String sql = "select id from hrmresource where status not in (7) and (accounttype is null or accounttype = 0) and jobtitle =" + employee.getJobtitleId();
|
||||
Set<Long> memberList = new HashSet<>();
|
||||
RecordSet rs = new RecordSet();
|
||||
if (rs.execute(sql)) {
|
||||
while (rs.next()) {
|
||||
memberList.add(Long.parseLong(rs.getString("id")));
|
||||
}
|
||||
}
|
||||
return memberList;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
private Integer value;
|
||||
private String defaultLabel;
|
||||
private int labelId;
|
||||
|
||||
LoginPersonTargetTypeEnum(Integer value, String defaultLabel, int labelId) {
|
||||
this.value = value;
|
||||
this.defaultLabel = defaultLabel;
|
||||
this.labelId = labelId;
|
||||
}
|
||||
|
||||
public abstract Set<Long> getEmpIds(DataCollectionEmployee employee);
|
||||
|
||||
|
||||
@Override
|
||||
public Integer getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultLabel() {
|
||||
return defaultLabel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getLabelId() {
|
||||
return labelId;
|
||||
}
|
||||
|
||||
public static LoginPersonTargetTypeEnum parseByValue(int value) {
|
||||
for (LoginPersonTargetTypeEnum typeEnum : LoginPersonTargetTypeEnum.values()) {
|
||||
if (Objects.equals(typeEnum.getValue(), value)) {
|
||||
return typeEnum;
|
||||
}
|
||||
}
|
||||
throw new SalaryRunTimeException("未找到对应的枚举");
|
||||
}
|
||||
}
|
||||
|
|
@ -14,14 +14,14 @@ import java.util.Set;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 对象类型,1:人员、2:部门、3:岗位、4:分部、5:角色、6:sql
|
||||
* 成员类型,1:人员、2:部门、3:岗位、4:分部、5:角色、6:sql
|
||||
* <p>Copyright: Copyright (c) 2024</p>
|
||||
* <p>Company: 泛微软件</p>
|
||||
*
|
||||
* @author qiantao
|
||||
* @version 1.0
|
||||
**/
|
||||
public enum TargetTypeEnum implements BaseEnum<Integer> {
|
||||
public enum MemberTargetTypeEnum implements BaseEnum<Integer> {
|
||||
|
||||
|
||||
EMP(1, "人员", 87627) {
|
||||
|
|
@ -46,7 +46,7 @@ public enum TargetTypeEnum implements BaseEnum<Integer> {
|
|||
return salaryEmployeeService.listByJob(ids);
|
||||
}
|
||||
},
|
||||
SUBCOMPANY(4, "分部", 87626) {
|
||||
SUB_COMPANY(4, "分部", 87626) {
|
||||
@Override
|
||||
public List<Long> getEmpIds(Set<String> targets) {
|
||||
List<Long> ids = targets.stream().map(Long::valueOf).collect(Collectors.toList());
|
||||
|
|
@ -62,7 +62,7 @@ public enum TargetTypeEnum implements BaseEnum<Integer> {
|
|||
targets.forEach(roleId -> {
|
||||
memberList.addAll(hrmCommonService.getRoleMembers(roleId, "2"));
|
||||
});
|
||||
return memberList.stream().map(id -> Long.parseLong(id.toString()) ).collect(Collectors.toList());
|
||||
return memberList.stream().map(id -> Long.parseLong(id.toString())).collect(Collectors.toList());
|
||||
}
|
||||
},
|
||||
SQL(6, "sql", 87626) {
|
||||
|
|
@ -86,7 +86,7 @@ public enum TargetTypeEnum implements BaseEnum<Integer> {
|
|||
private String defaultLabel;
|
||||
private int labelId;
|
||||
|
||||
TargetTypeEnum(Integer value, String defaultLabel, int labelId) {
|
||||
MemberTargetTypeEnum(Integer value, String defaultLabel, int labelId) {
|
||||
this.value = value;
|
||||
this.defaultLabel = defaultLabel;
|
||||
this.labelId = labelId;
|
||||
|
|
@ -110,8 +110,8 @@ public enum TargetTypeEnum implements BaseEnum<Integer> {
|
|||
return labelId;
|
||||
}
|
||||
|
||||
public static TargetTypeEnum parseByValue(int value) {
|
||||
for (TargetTypeEnum typeEnum : TargetTypeEnum.values()) {
|
||||
public static MemberTargetTypeEnum parseByValue(int value) {
|
||||
for (MemberTargetTypeEnum typeEnum : MemberTargetTypeEnum.values()) {
|
||||
if (Objects.equals(typeEnum.getValue(), value)) {
|
||||
return typeEnum;
|
||||
}
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
package com.engine.salary.mapper.auth;
|
||||
|
||||
import com.engine.salary.entity.auth.po.AuthDataPO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public interface AuthDataMapper {
|
||||
|
||||
/**
|
||||
* 查询所有记录
|
||||
*
|
||||
* @return 返回集合,没有返回空List
|
||||
*/
|
||||
List<AuthDataPO> listAll();
|
||||
|
||||
/**
|
||||
* 条件查询
|
||||
*
|
||||
* @return 返回集合,没有返回空List
|
||||
*/
|
||||
List<AuthDataPO> listSome(AuthDataPO authData);
|
||||
|
||||
|
||||
/**
|
||||
* 根据主键查询
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 返回记录,没有返回null
|
||||
*/
|
||||
AuthDataPO getById(Long id);
|
||||
|
||||
/**
|
||||
* 新增,忽略null字段
|
||||
*
|
||||
* @param authData 新增的记录
|
||||
* @return 返回影响行数
|
||||
*/
|
||||
int insertIgnoreNull(AuthDataPO authData);
|
||||
|
||||
/**
|
||||
* 修改,修改所有字段
|
||||
*
|
||||
* @param authData 修改的记录
|
||||
* @return 返回影响行数
|
||||
*/
|
||||
int update(AuthDataPO authData);
|
||||
|
||||
/**
|
||||
* 修改,忽略null字段
|
||||
*
|
||||
* @param authData 修改的记录
|
||||
* @return 返回影响行数
|
||||
*/
|
||||
int updateIgnoreNull(AuthDataPO authData);
|
||||
|
||||
/**
|
||||
* 删除记录
|
||||
*
|
||||
* @param authData 待删除的记录
|
||||
* @return 返回影响行数
|
||||
*/
|
||||
int delete(AuthDataPO authData);
|
||||
|
||||
/**
|
||||
* 批量删除记录
|
||||
*
|
||||
* @param ids 主键id集合
|
||||
*/
|
||||
void deleteByIds(@Param("ids") Collection<Long> ids);
|
||||
}
|
||||
|
|
@ -0,0 +1,269 @@
|
|||
<?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.salary.mapper.auth.AuthDataMapper">
|
||||
<resultMap id="BaseResultMap" type="com.engine.salary.entity.auth.po.AuthDataPO">
|
||||
<result column="id" property="id"/>
|
||||
<result column="role_id" property="roleId"/>
|
||||
<result column="link" property="link"/>
|
||||
<result column="target_type" property="targetType"/>
|
||||
<result column="target" property="target"/>
|
||||
<result column="target_name" property="targetName"/>
|
||||
<result column="sorted_index" property="sortedIndex"/>
|
||||
<result column="creator" property="creator"/>
|
||||
<result column="create_time" property="createTime"/>
|
||||
<result column="update_time" property="updateTime"/>
|
||||
<result column="delete_type" property="deleteType"/>
|
||||
<result column="tenant_key" property="tenantKey"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 表字段 -->
|
||||
<sql id="baseColumns">
|
||||
t
|
||||
.
|
||||
id
|
||||
, t.role_id
|
||||
, t.link
|
||||
, t.target_type
|
||||
, t.target
|
||||
, t.target_name
|
||||
, t.sorted_index
|
||||
, t.creator
|
||||
, t.create_time
|
||||
, t.update_time
|
||||
, t.delete_type
|
||||
, t.tenant_key
|
||||
</sql>
|
||||
|
||||
<!-- 查询全部 -->
|
||||
<select id="listAll" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="baseColumns"/>
|
||||
FROM hrsa_auth_data t
|
||||
WHERE delete_type = 0
|
||||
ORDER BY sorted_index
|
||||
</select>
|
||||
|
||||
<!-- 根据主键获取单条记录 -->
|
||||
<select id="getById" resultMap="BaseResultMap" parameterType="Long">
|
||||
SELECT
|
||||
<include refid="baseColumns"/>
|
||||
FROM hrsa_auth_data t
|
||||
WHERE id = #{id} AND delete_type = 0
|
||||
</select>
|
||||
|
||||
<!-- 条件查询 -->
|
||||
<select id="listSome" resultMap="BaseResultMap" parameterType="com.engine.salary.entity.auth.po.AuthDataPO">
|
||||
SELECT
|
||||
<include refid="baseColumns"/>
|
||||
FROM hrsa_auth_data t
|
||||
WHERE delete_type = 0
|
||||
<if test="id != null">
|
||||
AND id = #{id}
|
||||
</if>
|
||||
<if test="roleId != null">
|
||||
AND role_id = #{roleId}
|
||||
</if>
|
||||
<if test="link != null">
|
||||
AND link = #{link}
|
||||
</if>
|
||||
<if test="targetType != null">
|
||||
AND target_type = #{targetType}
|
||||
</if>
|
||||
<if test="target != null">
|
||||
AND target = #{target}
|
||||
</if>
|
||||
<if test="targetName != null">
|
||||
AND target_name = #{targetName}
|
||||
</if>
|
||||
<if test="sortedIndex != null">
|
||||
AND sorted_index = #{sortedIndex}
|
||||
</if>
|
||||
<if test="creator != null">
|
||||
AND creator = #{creator}
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
AND create_time = #{createTime}
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
AND update_time = #{updateTime}
|
||||
</if>
|
||||
<if test="deleteType != null">
|
||||
AND delete_type = #{deleteType}
|
||||
</if>
|
||||
<if test="tenantKey != null">
|
||||
AND tenant_key = #{tenantKey}
|
||||
</if>
|
||||
<if test="ids != null and ids.size()>0">
|
||||
AND id IN
|
||||
<foreach collection="ids" open="(" item="id" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
ORDER BY sorted_index
|
||||
</select>
|
||||
|
||||
|
||||
<!-- 插入不为NULL的字段 -->
|
||||
<insert id="insertIgnoreNull" parameterType="com.engine.salary.entity.auth.po.AuthDataPO">
|
||||
INSERT INTO hrsa_auth_data
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
|
||||
<if test="id != null">
|
||||
id,
|
||||
</if>
|
||||
<if test="roleId != null">
|
||||
role_id,
|
||||
</if>
|
||||
<if test="link != null">
|
||||
link,
|
||||
</if>
|
||||
<if test="targetType != null">
|
||||
target_type,
|
||||
</if>
|
||||
<if test="target != null">
|
||||
target,
|
||||
</if>
|
||||
<if test="targetName != null">
|
||||
target_name,
|
||||
</if>
|
||||
<if test="sortedIndex != null">
|
||||
sorted_index,
|
||||
</if>
|
||||
<if test="creator != null">
|
||||
creator,
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
create_time,
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
update_time,
|
||||
</if>
|
||||
<if test="deleteType != null">
|
||||
delete_type,
|
||||
</if>
|
||||
<if test="tenantKey != null">
|
||||
tenant_key,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
#{id},
|
||||
</if>
|
||||
<if test="roleId != null">
|
||||
#{roleId},
|
||||
</if>
|
||||
<if test="link != null">
|
||||
#{link},
|
||||
</if>
|
||||
<if test="targetType != null">
|
||||
#{targetType},
|
||||
</if>
|
||||
<if test="target != null">
|
||||
#{target},
|
||||
</if>
|
||||
<if test="targetName != null">
|
||||
#{targetName},
|
||||
</if>
|
||||
<if test="sortedIndex != null">
|
||||
#{sortedIndex},
|
||||
</if>
|
||||
<if test="creator != null">
|
||||
#{creator},
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
#{createTime},
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
#{updateTime},
|
||||
</if>
|
||||
<if test="deleteType != null">
|
||||
#{deleteType},
|
||||
</if>
|
||||
<if test="tenantKey != null">
|
||||
#{tenantKey},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<!-- 更新,更新全部字段 -->
|
||||
<update id="update" parameterType="com.engine.salary.entity.auth.po.AuthDataPO">
|
||||
UPDATE hrsa_auth_data
|
||||
<set>
|
||||
role_id=#{roleId},
|
||||
link=#{link},
|
||||
target_type=#{targetType},
|
||||
target=#{target},
|
||||
target_name=#{targetName},
|
||||
sorted_index=#{sortedIndex},
|
||||
creator=#{creator},
|
||||
create_time=#{createTime},
|
||||
update_time=#{updateTime},
|
||||
delete_type=#{deleteType},
|
||||
tenant_key=#{tenantKey},
|
||||
</set>
|
||||
WHERE id = #{id} AND delete_type = 0
|
||||
</update>
|
||||
|
||||
|
||||
<!-- 更新不为NULL的字段 -->
|
||||
<update id="updateIgnoreNull" parameterType="com.engine.salary.entity.auth.po.AuthDataPO">
|
||||
UPDATE hrsa_auth_data
|
||||
<set>
|
||||
<if test="roleId != null">
|
||||
role_id=#{roleId},
|
||||
</if>
|
||||
<if test="link != null">
|
||||
link=#{link},
|
||||
</if>
|
||||
<if test="targetType != null">
|
||||
target_type=#{targetType},
|
||||
</if>
|
||||
<if test="target != null">
|
||||
target=#{target},
|
||||
</if>
|
||||
<if test="targetName != null">
|
||||
target_name=#{targetName},
|
||||
</if>
|
||||
<if test="sortedIndex != null">
|
||||
sorted_index=#{sortedIndex},
|
||||
</if>
|
||||
<if test="creator != null">
|
||||
creator=#{creator},
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
create_time=#{createTime},
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
update_time=#{updateTime},
|
||||
</if>
|
||||
<if test="deleteType != null">
|
||||
delete_type=#{deleteType},
|
||||
</if>
|
||||
<if test="tenantKey != null">
|
||||
tenant_key=#{tenantKey},
|
||||
</if>
|
||||
</set>
|
||||
WHERE id = #{id} AND delete_type = 0
|
||||
</update>
|
||||
|
||||
|
||||
<!-- 根据主键删除记录 -->
|
||||
<delete id="delete">
|
||||
UPDATE hrsa_auth_data
|
||||
SET delete_type=1
|
||||
WHERE id = #{id}
|
||||
AND delete_type = 0
|
||||
</delete>
|
||||
|
||||
<delete id="deleteByIds">
|
||||
UPDATE hrsa_auth_data
|
||||
SET delete_type = 1
|
||||
WHERE delete_type = 0
|
||||
AND id IN
|
||||
<foreach collection="ids" open="(" item="id" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
|
||||
</mapper>
|
||||
|
|
@ -0,0 +1,79 @@
|
|||
package com.engine.salary.mapper.auth;
|
||||
|
||||
import com.engine.salary.entity.auth.po.AuthRoleDataPO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public interface AuthRoleDataMapper {
|
||||
|
||||
/**
|
||||
* 查询所有记录
|
||||
*
|
||||
* @return 返回集合,没有返回空List
|
||||
*/
|
||||
List<AuthRoleDataPO> listAll();
|
||||
|
||||
/**
|
||||
* 条件查询
|
||||
*
|
||||
* @return 返回集合,没有返回空List
|
||||
*/
|
||||
List<AuthRoleDataPO> listSome(AuthRoleDataPO authRoleData);
|
||||
|
||||
|
||||
/**
|
||||
* 根据主键查询
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 返回记录,没有返回null
|
||||
*/
|
||||
AuthRoleDataPO getById(Long id);
|
||||
|
||||
/**
|
||||
* 新增,忽略null字段
|
||||
*
|
||||
* @param authRoleData 新增的记录
|
||||
* @return 返回影响行数
|
||||
*/
|
||||
int insertIgnoreNull(AuthRoleDataPO authRoleData);
|
||||
|
||||
/**
|
||||
* 批量插入
|
||||
*
|
||||
* @param authRoleData
|
||||
*/
|
||||
void batchInsert(@Param("collection") List<AuthRoleDataPO> authRoleData);
|
||||
|
||||
/**
|
||||
* 修改,修改所有字段
|
||||
*
|
||||
* @param authRoleData 修改的记录
|
||||
* @return 返回影响行数
|
||||
*/
|
||||
int update(AuthRoleDataPO authRoleData);
|
||||
|
||||
/**
|
||||
* 修改,忽略null字段
|
||||
*
|
||||
* @param authRoleData 修改的记录
|
||||
* @return 返回影响行数
|
||||
*/
|
||||
int updateIgnoreNull(AuthRoleDataPO authRoleData);
|
||||
|
||||
/**
|
||||
* 删除记录
|
||||
*
|
||||
* @param authRoleData 待删除的记录
|
||||
* @return 返回影响行数
|
||||
*/
|
||||
int delete(AuthRoleDataPO authRoleData);
|
||||
|
||||
/**
|
||||
* 批量删除记录
|
||||
* @param ids 主键id集合
|
||||
*/
|
||||
void deleteByIds(@Param("ids") Collection<Long> ids);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
package com.engine.salary.service.auth;
|
||||
|
||||
import com.engine.salary.entity.auth.param.AuthDataSaveParam;
|
||||
import com.engine.salary.entity.auth.po.AuthDataPO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 数据
|
||||
* <p>Copyright: Copyright (c) 2024</p>
|
||||
* <p>Company: 泛微软件</p>
|
||||
*
|
||||
* @author qiantao
|
||||
* @version 1.0
|
||||
**/
|
||||
public interface AuthDataService {
|
||||
|
||||
/**
|
||||
* 列表
|
||||
* @param roleId
|
||||
* @return
|
||||
*/
|
||||
List<AuthDataPO> list(Long roleId);
|
||||
|
||||
/**
|
||||
* 保存数据
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
void save(AuthDataSaveParam param);
|
||||
|
||||
/**
|
||||
* 同步
|
||||
* @param roleId
|
||||
*/
|
||||
void sync(Long roleId);
|
||||
}
|
||||
|
|
@ -0,0 +1,154 @@
|
|||
package com.engine.salary.service.auth;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.engine.core.impl.Service;
|
||||
import com.engine.salary.constant.SalaryDefaultTenantConstant;
|
||||
import com.engine.salary.entity.auth.param.AuthDataSaveParam;
|
||||
import com.engine.salary.entity.auth.po.*;
|
||||
import com.engine.salary.enums.auth.DataLinkEnum;
|
||||
import com.engine.salary.enums.auth.DataTargetTypeEnum;
|
||||
import com.engine.salary.enums.auth.MemberTargetTypeEnum;
|
||||
import com.engine.salary.exception.SalaryRunTimeException;
|
||||
import com.engine.salary.mapper.auth.AuthDataMapper;
|
||||
import com.engine.salary.mapper.auth.AuthRoleDataMapper;
|
||||
import com.engine.salary.mapper.auth.AuthRoleEmpMapper;
|
||||
import com.engine.salary.mapper.auth.AuthRoleMapper;
|
||||
import com.engine.salary.util.SalaryEntityUtil;
|
||||
import com.engine.salary.util.db.IdGenerator;
|
||||
import com.engine.salary.util.db.MapperProxyFactory;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class AuthDataServiceImpl extends Service implements AuthDataService {
|
||||
|
||||
|
||||
private AuthDataMapper getAuthDataMapper() {
|
||||
return MapperProxyFactory.getProxy(AuthDataMapper.class);
|
||||
}
|
||||
|
||||
private AuthRoleMapper getAuthRoleMapper() {
|
||||
return MapperProxyFactory.getProxy(AuthRoleMapper.class);
|
||||
}
|
||||
|
||||
private AuthRoleEmpMapper getAuthRoleEmpMapper() {
|
||||
return MapperProxyFactory.getProxy(AuthRoleEmpMapper.class);
|
||||
}
|
||||
private AuthRoleDataMapper getAuthRoleDataMapper() {
|
||||
return MapperProxyFactory.getProxy(AuthRoleDataMapper.class);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<AuthDataPO> list(Long roleId) {
|
||||
AuthRolePO rolePO = getAuthRoleMapper().getById(roleId);
|
||||
if (rolePO == null) {
|
||||
throw new SalaryRunTimeException("角色不存在!");
|
||||
}
|
||||
return getAuthDataMapper().listSome(AuthDataPO.builder().roleId(roleId).build());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(AuthDataSaveParam param) {
|
||||
Date now = new Date();
|
||||
Long roleId = param.getRoleId();
|
||||
AuthRolePO rolePO = getAuthRoleMapper().getById(roleId);
|
||||
if (rolePO == null) {
|
||||
throw new SalaryRunTimeException("角色不存在!");
|
||||
}
|
||||
|
||||
AuthDataPO dataPO = AuthDataPO.builder()
|
||||
.id(IdGenerator.generate())
|
||||
.roleId(param.getRoleId())
|
||||
.link(param.getLink().getValue())
|
||||
.targetType(param.getTargetType().getValue())
|
||||
.target(param.getTarget())
|
||||
.targetName(param.getTargetName())
|
||||
.sortedIndex(param.getSortedIndex())
|
||||
.creator((long) user.getUID())
|
||||
.createTime(now)
|
||||
.updateTime(now)
|
||||
.deleteType(0)
|
||||
.tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
|
||||
.build();
|
||||
|
||||
getAuthDataMapper().insertIgnoreNull(dataPO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sync(Long roleId) {
|
||||
|
||||
|
||||
AuthRolePO rolePO = getAuthRoleMapper().getById(roleId);
|
||||
if (rolePO == null) {
|
||||
throw new SalaryRunTimeException("角色不存在!");
|
||||
}
|
||||
|
||||
//1、获取成员
|
||||
List<AuthMemberPO> members = getAuthMemberMapper().listSome(AuthMemberPO.builder().roleId(roleId).build());
|
||||
Map<Integer, Set<String>> targetTypeMap = SalaryEntityUtil.group2Map(members, AuthMemberPO::getTargetType, AuthMemberPO::getTarget);
|
||||
|
||||
//2、获取人员
|
||||
Set<Long> empIds = new HashSet<>();
|
||||
for (Integer targetType : targetTypeMap.keySet()) {
|
||||
Set<String> targetIds = targetTypeMap.get(targetType);
|
||||
List<Long> ids = MemberTargetTypeEnum.parseByValue(targetType).getEmpIds(targetIds);
|
||||
empIds.addAll(ids);
|
||||
}
|
||||
|
||||
//3、更新成员关系
|
||||
getAuthRoleEmpMapper().deleteByRoleId(roleId);
|
||||
Date now = new Date();
|
||||
List<AuthRoleEmpPO> roleEmpPOS = empIds.stream()
|
||||
.map(empId -> AuthRoleEmpPO.builder()
|
||||
.id(IdGenerator.generate())
|
||||
.employeeId(empId)
|
||||
.roleId(roleId)
|
||||
.creator((long) user.getUID())
|
||||
.createTime(now)
|
||||
.updateTime(now)
|
||||
.deleteType(0)
|
||||
.tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
|
||||
.build())
|
||||
.collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(roleEmpPOS)) {
|
||||
List<List<AuthRoleEmpPO>> partition = Lists.partition(roleEmpPOS, 100);
|
||||
partition.forEach(list -> getAuthRoleEmpMapper().batchInsert(list));
|
||||
}
|
||||
|
||||
|
||||
List<AuthDataPO> list = list(roleId);
|
||||
|
||||
Set<Long> ids = null;
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
AuthDataPO dataPO = list.get(i);
|
||||
DataTargetTypeEnum dataTargetTypeEnum = DataTargetTypeEnum.parseByValue(dataPO.getTargetType());
|
||||
DataLinkEnum dataLinkEnum = DataLinkEnum.parseByValue(dataPO.getLink());
|
||||
Set<Long> empResult = dataTargetTypeEnum.getEmpIds(dataPO.getTarget());
|
||||
if (i == 0) {
|
||||
ids = empResult;
|
||||
} else {
|
||||
ids = dataLinkEnum.calculation(ids, empResult);
|
||||
}
|
||||
}
|
||||
|
||||
getAuthDataMapper().deleteByRoleId(roleId);
|
||||
|
||||
List<AuthRoleDataPO> collect = ids.stream().map(empId -> AuthRoleDataPO.builder()
|
||||
.id(IdGenerator.generate())
|
||||
.employeeId(empId)
|
||||
.roleId(roleId)
|
||||
.creator((long) user.getUID())
|
||||
.createTime(now)
|
||||
.updateTime(now)
|
||||
.deleteType(0)
|
||||
.tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
|
||||
.build())
|
||||
.collect(Collectors.toList());
|
||||
|
||||
List<List<AuthRoleDataPO>> partition = Lists.partition(collect, 100);
|
||||
partition.forEach(list -> getAuthRoleDataMapper().batchInsert(list));
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -19,25 +19,25 @@ public interface AuthMemberService {
|
|||
* @param roleId
|
||||
* @return
|
||||
*/
|
||||
List<AuthMemberPO> memberList(Long roleId);
|
||||
List<AuthMemberPO> list(Long roleId);
|
||||
|
||||
/**
|
||||
* 添加成员
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
Long saveMember(AuthMemberSaveParam param);
|
||||
Long save(AuthMemberSaveParam param);
|
||||
|
||||
/**
|
||||
* 删除成员
|
||||
* @param id
|
||||
*/
|
||||
void deleteMember(Long id);
|
||||
void delete(Long id);
|
||||
|
||||
/**
|
||||
* 同步成员
|
||||
* @param roleId
|
||||
*/
|
||||
void syncMember(Long roleId);
|
||||
void sync(Long roleId);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import com.engine.salary.entity.auth.po.AuthRoleEmpPO;
|
|||
import com.engine.salary.entity.auth.po.AuthRolePO;
|
||||
import com.engine.salary.entity.taxagent.po.TaxAgentPO;
|
||||
import com.engine.salary.enums.OperateTypeEnum;
|
||||
import com.engine.salary.enums.auth.TargetTypeEnum;
|
||||
import com.engine.salary.enums.auth.MemberTargetTypeEnum;
|
||||
import com.engine.salary.exception.SalaryRunTimeException;
|
||||
import com.engine.salary.mapper.auth.AuthMemberMapper;
|
||||
import com.engine.salary.mapper.auth.AuthRoleEmpMapper;
|
||||
|
|
@ -51,12 +51,12 @@ public class AuthMemberServiceImpl extends Service implements AuthMemberService
|
|||
|
||||
|
||||
@Override
|
||||
public List<AuthMemberPO> memberList(Long roleId) {
|
||||
public List<AuthMemberPO> list(Long roleId) {
|
||||
return getAuthMemberMapper().listSome(AuthMemberPO.builder().roleId(roleId).build());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long saveMember(AuthMemberSaveParam param) {
|
||||
public Long save(AuthMemberSaveParam param) {
|
||||
|
||||
AuthRolePO rolePO = getAuthRoleMapper().getById(param.getRoleId());
|
||||
if (rolePO == null) {
|
||||
|
|
@ -68,7 +68,7 @@ public class AuthMemberServiceImpl extends Service implements AuthMemberService
|
|||
.id(IdGenerator.generate())
|
||||
.roleId(param.getRoleId())
|
||||
.target(param.getTarget())
|
||||
.targetType(param.getTargetType())
|
||||
.targetType(param.getTargetType().getValue())
|
||||
.targetName(param.getTargetName())
|
||||
.creator((long) user.getUID())
|
||||
.createTime(now)
|
||||
|
|
@ -93,7 +93,7 @@ public class AuthMemberServiceImpl extends Service implements AuthMemberService
|
|||
}
|
||||
|
||||
@Override
|
||||
public void deleteMember(Long id) {
|
||||
public void delete(Long id) {
|
||||
AuthMemberPO po = getAuthMemberMapper().getById(id);
|
||||
if (po == null) {
|
||||
throw new SalaryRunTimeException("成员不存在!");
|
||||
|
|
@ -114,7 +114,7 @@ public class AuthMemberServiceImpl extends Service implements AuthMemberService
|
|||
}
|
||||
|
||||
@Override
|
||||
public void syncMember(Long roleId) {
|
||||
public void sync(Long roleId) {
|
||||
AuthRolePO rolePO = getAuthRoleMapper().getById(roleId);
|
||||
if (rolePO == null) {
|
||||
throw new SalaryRunTimeException("角色不存在!");
|
||||
|
|
@ -128,7 +128,7 @@ public class AuthMemberServiceImpl extends Service implements AuthMemberService
|
|||
Set<Long> empIds = new HashSet<>();
|
||||
for (Integer targetType : targetTypeMap.keySet()) {
|
||||
Set<String> targetIds = targetTypeMap.get(targetType);
|
||||
List<Long> ids = TargetTypeEnum.parseByValue(targetType).getEmpIds(targetIds);
|
||||
List<Long> ids = MemberTargetTypeEnum.parseByValue(targetType).getEmpIds(targetIds);
|
||||
empIds.addAll(ids);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,10 @@
|
|||
package com.engine.salary.web;
|
||||
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.salary.entity.auth.dto.AuthDataDTO;
|
||||
import com.engine.salary.entity.auth.dto.AuthMemberDTO;
|
||||
import com.engine.salary.entity.auth.dto.AuthOptDTO;
|
||||
import com.engine.salary.entity.auth.param.AuthMemberQueryParam;
|
||||
import com.engine.salary.entity.auth.param.AuthMemberSaveParam;
|
||||
import com.engine.salary.entity.auth.param.AuthOptSaveParam;
|
||||
import com.engine.salary.entity.auth.param.AuthRoleSaveParam;
|
||||
import com.engine.salary.entity.auth.param.*;
|
||||
import com.engine.salary.util.ResponseResult;
|
||||
import com.engine.salary.util.page.PageInfo;
|
||||
import com.engine.salary.wrapper.AuthWrapper;
|
||||
|
|
@ -101,5 +99,29 @@ public class AuthController {
|
|||
return new ResponseResult<AuthOptSaveParam, AuthOptDTO>(user).run(getAuthWrapper(user)::saveOpt, opt);
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/data/list")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public String memberList(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AuthDataQueryParam param) {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
return new ResponseResult<AuthDataQueryParam, PageInfo<AuthDataDTO>>(user).run(getAuthWrapper(user)::dataList, param);
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/data/save")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public String saveData(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody AuthDataSaveParam param) {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
return new ResponseResult<AuthDataSaveParam, Long>(user).run(getAuthWrapper(user)::saveData, param);
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/data/sync")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public String syncData(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Long roleId) {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
return new ResponseResult<Long, AuthOptDTO>(user).run(getAuthWrapper(user)::syncData, roleId);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,14 +2,14 @@ package com.engine.salary.wrapper;
|
|||
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.core.impl.Service;
|
||||
import com.engine.salary.entity.auth.dto.AuthDataDTO;
|
||||
import com.engine.salary.entity.auth.dto.AuthMemberDTO;
|
||||
import com.engine.salary.entity.auth.dto.AuthOptDTO;
|
||||
import com.engine.salary.entity.auth.param.AuthMemberQueryParam;
|
||||
import com.engine.salary.entity.auth.param.AuthMemberSaveParam;
|
||||
import com.engine.salary.entity.auth.param.AuthOptSaveParam;
|
||||
import com.engine.salary.entity.auth.param.AuthRoleSaveParam;
|
||||
import com.engine.salary.entity.auth.param.*;
|
||||
import com.engine.salary.entity.auth.po.AuthDataPO;
|
||||
import com.engine.salary.entity.auth.po.AuthMemberPO;
|
||||
import com.engine.salary.enums.auth.TargetTypeEnum;
|
||||
import com.engine.salary.enums.auth.DataTargetTypeEnum;
|
||||
import com.engine.salary.enums.auth.MemberTargetTypeEnum;
|
||||
import com.engine.salary.service.auth.*;
|
||||
import com.engine.salary.util.page.PageInfo;
|
||||
import com.engine.salary.util.page.SalaryPageUtil;
|
||||
|
|
@ -35,6 +35,10 @@ public class AuthWrapper extends Service {
|
|||
return ServiceUtil.getService(AuthOptServiceImpl.class, user);
|
||||
}
|
||||
|
||||
private AuthDataService getAuthDataService(User user) {
|
||||
return ServiceUtil.getService(AuthDataServiceImpl.class, user);
|
||||
}
|
||||
|
||||
public Long saveRole(AuthRoleSaveParam param) {
|
||||
ValidUtil.doValidator(param);
|
||||
return getAuthRoleService(user).saveRole(param);
|
||||
|
|
@ -46,27 +50,34 @@ public class AuthWrapper extends Service {
|
|||
}
|
||||
|
||||
public PageInfo<AuthMemberDTO> memberList(AuthMemberQueryParam param) {
|
||||
List<AuthMemberPO> authMemberPOS = getAuthMemberService(user).memberList(param.getRoleId());
|
||||
List<AuthMemberDTO> dtos = authMemberPOS.stream().map(po -> AuthMemberDTO.builder()
|
||||
.id(po.getId())
|
||||
.targetType(TargetTypeEnum.parseByValue(po.getTargetType()).getDefaultLabel())
|
||||
.targetName(po.getTargetName())
|
||||
.build())
|
||||
List<AuthMemberPO> authMemberPOS = getAuthMemberService(user).list(param.getRoleId());
|
||||
int total = authMemberPOS.size();
|
||||
authMemberPOS = SalaryPageUtil.subList(param.getCurrent(), param.getPageSize(), authMemberPOS);
|
||||
List<AuthMemberDTO> dtos = authMemberPOS.stream()
|
||||
.map(po -> AuthMemberDTO.builder()
|
||||
.id(po.getId())
|
||||
.targetTypeName(MemberTargetTypeEnum.parseByValue(po.getTargetType()).getDefaultLabel())
|
||||
.targetType(MemberTargetTypeEnum.parseByValue(po.getTargetType()))
|
||||
.targetName(po.getTargetName())
|
||||
.target(po.getTarget())
|
||||
.build())
|
||||
.collect(Collectors.toList());
|
||||
return SalaryPageUtil.buildPage(param.getCurrent(), param.getPageSize(), dtos, AuthMemberDTO.class);
|
||||
PageInfo<AuthMemberDTO> authMemberDTOPageInfo = SalaryPageUtil.buildPage(param.getCurrent(), param.getPageSize(), dtos, AuthMemberDTO.class);
|
||||
authMemberDTOPageInfo.setTotal(total);
|
||||
return authMemberDTOPageInfo;
|
||||
}
|
||||
|
||||
public Long saveMember(AuthMemberSaveParam param) {
|
||||
ValidUtil.doValidator(param);
|
||||
return getAuthMemberService(user).saveMember(param);
|
||||
return getAuthMemberService(user).save(param);
|
||||
}
|
||||
|
||||
public void deleteMember(Long id) {
|
||||
getAuthMemberService(user).deleteMember(id);
|
||||
getAuthMemberService(user).delete(id);
|
||||
}
|
||||
|
||||
public void syncMember(Long roleId) {
|
||||
getAuthMemberService(user).syncMember(roleId);
|
||||
getAuthMemberService(user).sync(roleId);
|
||||
}
|
||||
|
||||
public AuthOptDTO optTree(Long roleId) {
|
||||
|
|
@ -76,4 +87,32 @@ public class AuthWrapper extends Service {
|
|||
public void saveOpt(AuthOptSaveParam opt) {
|
||||
getAuthOptService(user).save(opt);
|
||||
}
|
||||
|
||||
public PageInfo<AuthDataDTO> dataList(AuthDataQueryParam param) {
|
||||
List<AuthDataPO> list = getAuthDataService(user).list(param.getRoleId());
|
||||
int total = list.size();
|
||||
list = SalaryPageUtil.subList(param.getCurrent(), param.getPageSize(), list);
|
||||
List<AuthDataDTO> dtos = list.stream().map(po -> AuthDataDTO.builder()
|
||||
.id(po.getId())
|
||||
.targetTypeName(DataTargetTypeEnum.parseByValue(po.getTargetType()).getDefaultLabel())
|
||||
.targetType(DataTargetTypeEnum.parseByValue(po.getTargetType()))
|
||||
.targetName(po.getTargetName())
|
||||
.target(po.getTarget())
|
||||
.build())
|
||||
.collect(Collectors.toList());
|
||||
|
||||
PageInfo<AuthDataDTO> page = SalaryPageUtil.buildPage(param.getCurrent(), param.getPageSize(), dtos, AuthDataDTO.class);
|
||||
page.setTotal(total);
|
||||
return page;
|
||||
|
||||
}
|
||||
|
||||
public void saveData(AuthDataSaveParam authDataSaveParam) {
|
||||
getAuthDataService(user).save(authDataSaveParam);
|
||||
}
|
||||
|
||||
|
||||
public void syncData(Long roleId) {
|
||||
getAuthDataService(user).sync(roleId);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue