申报权限按钮限制
This commit is contained in:
parent
920b0e31c4
commit
4d9f1e6ff4
|
|
@ -0,0 +1,19 @@
|
|||
package com.engine.salary.entity.auth.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class SobOptAuth {
|
||||
private Long sobId;
|
||||
|
||||
private Set<String> opts;
|
||||
}
|
||||
|
||||
|
|
@ -11,7 +11,7 @@ import java.util.List;
|
|||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class AuthDTO {
|
||||
public class TaxEmpOptAuth {
|
||||
private Long taxAgentId;
|
||||
|
||||
private List<EmpOpt> emps;
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
package com.engine.salary.entity.auth.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class TaxOptAuth {
|
||||
private Long taxAgentId;
|
||||
|
||||
private Set<String> opts;
|
||||
}
|
||||
|
||||
|
|
@ -1,13 +1,19 @@
|
|||
package com.engine.salary.mapper.auth;
|
||||
|
||||
import com.engine.salary.entity.auth.dto.AuthDTO;
|
||||
import com.engine.salary.entity.auth.dto.SobOptAuth;
|
||||
import com.engine.salary.entity.auth.dto.TaxEmpOptAuth;
|
||||
import com.engine.salary.entity.auth.dto.TaxOptAuth;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface AuthMapper {
|
||||
|
||||
List<AuthDTO> getAuth(@Param("uid") Long uid, @Param("page") String page);
|
||||
List<TaxEmpOptAuth> getTaxEmpOptAuth(@Param("uid") Long uid, @Param("page") String page);
|
||||
|
||||
List<TaxOptAuth> getTaxOptAuth(@Param("uid") Long uid, @Param("page") String page);
|
||||
|
||||
List<SobOptAuth> getSobOptAuth(@Param("uid") Long uid, @Param("page") String page);
|
||||
|
||||
List<Long> getLimitSobs(@Param("uid") Long uid);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<?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.AuthMapper">
|
||||
<resultMap id="BaseResultMap" type="com.engine.salary.entity.auth.dto.AuthDTO">
|
||||
<resultMap id="getTaxEmpOptAuthMap" type="com.engine.salary.entity.auth.dto.TaxEmpOptAuth">
|
||||
<id column="tax_agent_id" property="taxAgentId"/>
|
||||
<collection property="emps" ofType="com.engine.salary.entity.auth.dto.EmpOpt">
|
||||
<id column="employee_id" property="employeeId"/>
|
||||
|
|
@ -13,30 +13,76 @@
|
|||
</collection>
|
||||
</resultMap>
|
||||
|
||||
<select id="getAuth" resultMap="BaseResultMap">
|
||||
select resource.target as tax_agent_id, d.employee_id, o.id as optId,o.page,o.opt
|
||||
<select id="getTaxEmpOptAuth" resultMap="getTaxEmpOptAuthMap">
|
||||
select resource.target as tax_agent_id, d.employee_id, o.opt
|
||||
from hrsa_auth_role_emp emp
|
||||
left join hrsa_auth_role role on emp.role_id = role.id and emp.delete_type = 0 and role.delete_type = 0
|
||||
left join hrsa_auth_resource resource on resource.role_id = role.id and resource.target_type=1 and resource.delete_type = 0
|
||||
left join hrsa_auth_role_data d on emp.role_id = d.role_id and d.delete_type = 0
|
||||
left join hrsa_auth_opt o on d.role_id = o.role_id and o.delete_type = 0
|
||||
where emp.employee_id = #{uid} and o.page = #{page}
|
||||
left join hrsa_auth_role role on emp.role_id = role.id and emp.delete_type = 0 and role.delete_type = 0
|
||||
left join hrsa_auth_resource resource
|
||||
on resource.role_id = role.id and resource.target_type = 1 and resource.delete_type = 0
|
||||
left join hrsa_auth_role_data d on emp.role_id = d.role_id and d.delete_type = 0
|
||||
left join hrsa_auth_opt o on d.role_id = o.role_id and o.delete_type = 0
|
||||
where emp.employee_id = #{uid}
|
||||
and o.page = #{page}
|
||||
</select>
|
||||
|
||||
|
||||
<resultMap id="getTaxOptAuthMap" type="com.engine.salary.entity.auth.dto.TaxOptAuth">
|
||||
<id column="tax_agent_id" property="taxAgentId"/>
|
||||
<collection property="opts" ofType="string">
|
||||
<constructor>
|
||||
<arg column="opt"/>
|
||||
</constructor>
|
||||
</collection>
|
||||
</resultMap>
|
||||
|
||||
<select id="getTaxOptAuth" resultMap="getTaxOptAuthMap">
|
||||
select resource.target as tax_agent_id, o.opt
|
||||
from hrsa_auth_role_emp emp
|
||||
left join hrsa_auth_role role on emp.role_id = role.id and emp.delete_type = 0 and role.delete_type = 0
|
||||
left join hrsa_auth_resource resource
|
||||
on resource.role_id = role.id and resource.target_type = 1 and resource.delete_type = 0
|
||||
left join hrsa_auth_opt o on role.id = o.role_id and o.delete_type = 0
|
||||
where emp.employee_id = #{uid}
|
||||
and o.page = #{page}
|
||||
</select>
|
||||
|
||||
|
||||
<resultMap id="getSobOptAuthMap" type="com.engine.salary.entity.auth.dto.SobOptAuth">
|
||||
<id column="sob_id" property="sobId"/>
|
||||
<collection property="opts" ofType="string">
|
||||
<constructor>
|
||||
<arg column="opt"/>
|
||||
</constructor>
|
||||
</collection>
|
||||
</resultMap>
|
||||
|
||||
<select id="getSobOptAuth" resultMap="getSobOptAuthMap">
|
||||
select resource.target as sob_id, o.opt
|
||||
from hrsa_auth_role_emp emp
|
||||
left join hrsa_auth_role role on emp.role_id = role.id and emp.delete_type = 0 and role.delete_type = 0
|
||||
left join hrsa_auth_resource resource
|
||||
on resource.role_id = role.id and resource.target_type = 2 and resource.delete_type = 0
|
||||
left join hrsa_auth_opt o on role.id = o.role_id and o.delete_type = 0
|
||||
where emp.employee_id = #{uid}
|
||||
and o.page = #{page}
|
||||
</select>
|
||||
|
||||
|
||||
<select id="getLimitSobs" resultType="long">
|
||||
select resource.target
|
||||
from hrsa_auth_role_emp emp
|
||||
left join hrsa_auth_role role on emp.role_id = role.id and emp.delete_type = 0 and role.delete_type = 0
|
||||
left join hrsa_auth_resource resource on resource.role_id = role.id and resource.target_type=2 and resource.delete_type = 0
|
||||
left join hrsa_auth_role role on emp.role_id = role.id and emp.delete_type = 0 and role.delete_type = 0
|
||||
left join hrsa_auth_resource resource
|
||||
on resource.role_id = role.id and resource.target_type = 2 and resource.delete_type = 0
|
||||
where emp.employee_id = #{uid}
|
||||
</select>
|
||||
|
||||
<select id="getLimitTaxAgents" resultType="long">
|
||||
select resource.target
|
||||
from hrsa_auth_role_emp emp
|
||||
left join hrsa_auth_role role on emp.role_id = role.id and emp.delete_type = 0 and role.delete_type = 0
|
||||
left join hrsa_auth_resource resource on resource.role_id = role.id and resource.target_type=1 and resource.delete_type = 0
|
||||
left join hrsa_auth_role role on emp.role_id = role.id and emp.delete_type = 0 and role.delete_type = 0
|
||||
left join hrsa_auth_resource resource
|
||||
on resource.role_id = role.id and resource.target_type = 1 and resource.delete_type = 0
|
||||
where emp.employee_id = #{uid}
|
||||
</select>
|
||||
|
||||
|
|
@ -45,9 +91,12 @@
|
|||
select o.opt
|
||||
from hrsa_auth_role_emp emp
|
||||
left join hrsa_auth_role role on emp.role_id = role.id
|
||||
left join hrsa_auth_opt o on role.id = o.role_id
|
||||
where emp.delete_type = 0 and role.delete_type = 0 and o.delete_type = 0
|
||||
and emp.employee_id = #{uid} and o.page = #{page}
|
||||
left join hrsa_auth_opt o on role.id = o.role_id
|
||||
where emp.delete_type = 0
|
||||
and role.delete_type = 0
|
||||
and o.delete_type = 0
|
||||
and emp.employee_id = #{uid}
|
||||
and o.page = #{page}
|
||||
</select>
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package com.engine.salary.service.auth;
|
||||
|
||||
import com.engine.salary.entity.auth.dto.AuthDTO;
|
||||
import com.engine.salary.entity.auth.vo.Permission;
|
||||
import com.engine.salary.enums.auth.AuthFilterTypeEnum;
|
||||
|
||||
|
|
@ -18,7 +17,5 @@ public interface AuthService {
|
|||
|
||||
<T> List<T> auth(List<T> list, AuthFilterTypeEnum filterType, Class<T> clazz);
|
||||
|
||||
List<AuthDTO> auth(String page);
|
||||
|
||||
Permission permission(String page);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,8 +4,10 @@ import cn.hutool.core.collection.CollectionUtil;
|
|||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.core.impl.Service;
|
||||
import com.engine.salary.annotation.Auth;
|
||||
import com.engine.salary.entity.auth.dto.AuthDTO;
|
||||
import com.engine.salary.entity.auth.dto.EmpOpt;
|
||||
import com.engine.salary.entity.auth.dto.SobOptAuth;
|
||||
import com.engine.salary.entity.auth.dto.TaxEmpOptAuth;
|
||||
import com.engine.salary.entity.auth.dto.TaxOptAuth;
|
||||
import com.engine.salary.entity.auth.vo.Permission;
|
||||
import com.engine.salary.entity.salarysob.po.SalarySobPO;
|
||||
import com.engine.salary.enums.auth.AuthCheckTypeEnum;
|
||||
|
|
@ -155,13 +157,13 @@ public class AuthServiceImpl extends Service implements AuthService {
|
|||
list.removeAll(resultList);
|
||||
|
||||
//给各角色赋权
|
||||
List<AuthDTO> authDTOS = getAuthMapper().getAuth((long) user.getUID(), page);
|
||||
Map<Long, List<EmpOpt>> authMap = SalaryEntityUtil.convert2Map(authDTOS, AuthDTO::getTaxAgentId, AuthDTO::getEmps);
|
||||
|
||||
try {
|
||||
Iterator<T> iterator = list.iterator();
|
||||
if (checkType == AuthCheckTypeEnum.TAX_EMP) {
|
||||
|
||||
List<TaxEmpOptAuth> authDTOS = getAuthMapper().getTaxEmpOptAuth((long) user.getUID(), page);
|
||||
Map<Long, List<EmpOpt>> authMap = SalaryEntityUtil.convert2Map(authDTOS, TaxEmpOptAuth::getTaxAgentId, TaxEmpOptAuth::getEmps);
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
T t = iterator.next();
|
||||
//混合验证
|
||||
|
|
@ -191,30 +193,50 @@ public class AuthServiceImpl extends Service implements AuthService {
|
|||
}
|
||||
}
|
||||
} else if (checkType == AuthCheckTypeEnum.SOB) {
|
||||
List<Long> limits = getAuthMapper().getLimitSobs((long) user.getUID());
|
||||
|
||||
List<SobOptAuth> sobOptAuth = getAuthMapper().getSobOptAuth((long) user.getUID(), page);
|
||||
Map<Long, Set<String>> sobOpts = SalaryEntityUtil.convert2Map(sobOptAuth, SobOptAuth::getSobId, SobOptAuth::getOpts);
|
||||
while (iterator.hasNext()) {
|
||||
T t = iterator.next();
|
||||
Method sobIdFieldGetterMethod = t.getClass().getMethod(sobIdFieldGetter);
|
||||
Long sobId = (Long) sobIdFieldGetterMethod.invoke(t);
|
||||
|
||||
if (limits.contains(sobId)) {
|
||||
if (sobOpts.containsKey(sobId)) {
|
||||
if (filterType == AuthFilterTypeEnum.DATA_OPT) {
|
||||
Set<String> optSets = sobOpts.getOrDefault(sobId, new HashSet<>());
|
||||
Method optsFieldGetterMethod = t.getClass().getMethod(optsFieldGetter);
|
||||
Set<String> opts = (Set<String>) optsFieldGetterMethod.invoke(t);
|
||||
if (opts == null) {
|
||||
opts = new HashSet<>();
|
||||
}
|
||||
opts.addAll(optSets);
|
||||
|
||||
Method optsFieldSetterMethod = t.getClass().getMethod(optsFieldSetter, Set.class);
|
||||
optsFieldSetterMethod.invoke(t, opts);
|
||||
}
|
||||
resultList.add(t);
|
||||
}
|
||||
}
|
||||
} else if (checkType == AuthCheckTypeEnum.TAX) {
|
||||
List<Long> limits = getAuthMapper().getLimitTaxAgents((long) user.getUID());
|
||||
List<TaxOptAuth> authDTOS = getAuthMapper().getTaxOptAuth((long) user.getUID(), page);
|
||||
Map<Long, Set<String>> taxOpts = SalaryEntityUtil.convert2Map(authDTOS, TaxOptAuth::getTaxAgentId, TaxOptAuth::getOpts);
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
T t = iterator.next();
|
||||
Method taxAgentIdFieldGetterMethod = t.getClass().getMethod(taxAgentIdFieldGetter);
|
||||
Long taxAgentId = (Long) taxAgentIdFieldGetterMethod.invoke(t);
|
||||
|
||||
if (limits.contains(taxAgentId)) {
|
||||
if (taxOpts.containsKey(taxAgentId)) {
|
||||
if (filterType == AuthFilterTypeEnum.DATA_OPT) {
|
||||
Set<String> optSets = taxOpts.getOrDefault(taxAgentId, new HashSet<>());
|
||||
Method optsFieldGetterMethod = t.getClass().getMethod(optsFieldGetter);
|
||||
Set<String> opts = (Set<String>) optsFieldGetterMethod.invoke(t);
|
||||
if (opts == null) {
|
||||
opts = new HashSet<>();
|
||||
}
|
||||
opts.addAll(optSets);
|
||||
|
||||
Method optsFieldSetterMethod = t.getClass().getMethod(optsFieldSetter, Set.class);
|
||||
optsFieldSetterMethod.invoke(t, opts);
|
||||
|
||||
}
|
||||
resultList.add(t);
|
||||
|
|
@ -227,11 +249,6 @@ public class AuthServiceImpl extends Service implements AuthService {
|
|||
return resultList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AuthDTO> auth(String page) {
|
||||
return getAuthMapper().getAuth((long) user.getUID(), page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Permission permission(String page) {
|
||||
long uid = user.getUID();
|
||||
|
|
|
|||
|
|
@ -147,7 +147,7 @@ public class AuthWrapper extends Service {
|
|||
}
|
||||
|
||||
public Object auth(String page) {
|
||||
return getAuthMapper().getAuth((long) user.getUID(), page);
|
||||
return getAuthMapper().getTaxEmpOptAuth((long) user.getUID(), page);
|
||||
}
|
||||
|
||||
public Permission permission(String page) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue