Commit f564cc3c authored by tangwei's avatar tangwei

修改注解

parent db1d5bae
......@@ -31,8 +31,9 @@ public class UserEmpowerInterceptor implements Interceptor {
@Override
public Object intercept(Invocation invocation) throws Throwable {
StdUserEmpower orgCode = UserEmpowerThreadLocal.getDataAuthRule();
if(orgCode.isFlag()){
try {
StatementHandler statementHandler = PluginUtils.realTarget(invocation.getTarget());
MetaObject metaObject = SystemMetaObject.forObject(statementHandler);
......@@ -43,6 +44,8 @@ public class UserEmpowerInterceptor implements Interceptor {
if(userEmpower==null){
return invocation.proceed();
}
StdUserEmpower orgCode = UserEmpowerThreadLocal.getDataAuthRule();
if(orgCode!=null&&orgCode.isFlag()){
//获取字段
String[] filed= userEmpower.field();
//获取字段条件表达式
......@@ -97,7 +100,9 @@ public class UserEmpowerInterceptor implements Interceptor {
}
System.out.println(selectBody.toString());
metaObject.setValue("delegate.boundSql.sql", selectBody.toString());
}else{
return invocation.proceed();
}
}catch (Exception e){
e.printStackTrace();
throw new BadRequest("权限认证失败!");
......@@ -105,9 +110,7 @@ public class UserEmpowerInterceptor implements Interceptor {
UserEmpowerThreadLocal.clean();
}
return invocation.proceed();
}else{
return invocation.proceed();
}
}
@Override
......@@ -130,11 +133,12 @@ public class UserEmpowerInterceptor implements Interceptor {
if(specific){
List<String> data= stdUserEmpower.getAmosOrgCode();
List<String> notdata= stdUserEmpower.getEliminateAmosOrgCode();
List<String> wnotdata= stdUserEmpower.getNOeliminateAmosOrgCode();
if( filed!=null&&filed.length>0){
for (int i = 0; i < filed.length; i++) {
String sq=" ";
sq= getConditiontd(filed[i],fileCondition[i],data,notdata);
sq= getConditiontd(filed[i],fileCondition[i],data,notdata,wnotdata);
sql.add(sq);
}
}
......@@ -156,13 +160,55 @@ public class UserEmpowerInterceptor implements Interceptor {
}
//特定管理端条件
private String getConditiontd(String filed,String type, List<String> data, List<String> notdata){
private String getConditiontd(String filed,String type, List<String> data, List<String> wdata, List<String> wnotdata){
String sql=" ";
if(data!=null&&!data.isEmpty()){
if(data.contains("all")){
sql = sql+getnotInData( filed,notdata);
if(data==null||data.size()==0){
//内部不选 外部不选
if(wdata==null||wdata.size()==0){
//返回空不处理
sql=" ";
}
//内部不选 外部全部
//内部不选 外部选一部分
if(wdata!=null&&wdata.size()>0){
sql = sql+getInData( filed,wdata);
}
}else if(data.contains("all")){
//内部全选, 外部不选
if(wdata==null||wdata.size()==0){
sql = sql+ getnotInData( filed,wnotdata);
}
//内部全选, 外度全选
if(wdata!=null&&wdata.size()!=0&&wnotdata==null){
//返回恒等看所有
sql= sql+" 1=1 ";
}
//内部全选, 外部选一部分
if(wdata!=null&&wdata.size()!=0&&wnotdata!=null){
//返回恒等看所有
sql = sql+getnotInData( filed,wnotdata);
}
}else{
sql = sql+getInData( filed,data) + "and"+ getnotInData( filed,notdata);
//内部选一部分, 外度全选
if(wdata!=null&&wdata.size()!=0&&wnotdata==null){
sql = sql+getInData( filed,data);
}
//内部选一部分 外部选一部分
if(wdata!=null&&wdata.size()!=0&&wnotdata!=null){
data.addAll(wdata);
sql = sql+getInData( filed,data);
}
//内部选一部分 外部不选
if(wdata==null||wdata.size()==0){
sql = sql+getInData( filed,data);
}
}
return sql;
......
......@@ -23,6 +23,9 @@ import org.typroject.tyboot.core.foundation.context.RequestContext;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @description:
......@@ -37,8 +40,8 @@ public class UserLimitsAdvice {
@Autowired
private UserEmpowerMapper userEmpowerMapper;
@Autowired
PersonnelBusinessMapper personnelBusinessMapper;
// @Autowired
//// PersonnelBusinessMapper personnelBusinessMapper;
@Autowired
private RedisUtils redisUtils;
......@@ -60,10 +63,11 @@ public class UserLimitsAdvice {
//判断是否经销商,经销商跟管理端互斥
String org= reginParams.getUserModel().getOrgNames();
if(org.contains(ROLEFLAG)){
UserUnitInformationDto userUnitInformationDto=personnelBusinessMapper.getUserUnitInformationDto(userid);
// UserUnitInformationDto userUnitInformationDto=personnelBusinessMapper.getUserUnitInformationDto(userid);
UserUnitInformationDto userUnitInformationDto=null;
stdUserEmpower.setFlag(false);
stdUserEmpower.setDeveloperId(userUnitInformationDto.getAmosUnitInfoId());
stdUserEmpower.setRegionalCompaniesCode(userUnitInformationDto.getRegionalCompaniesCode());
stdUserEmpower.setDeveloperId(userUnitInformationDto!=null?userUnitInformationDto.getAmosUnitInfoId():null);
stdUserEmpower.setRegionalCompaniesCode(userUnitInformationDto!=null?userUnitInformationDto.getRegionalCompaniesCode():null);
stdUserEmpower.setUserId(userid);
}else{
LambdaQueryWrapper<StdUserEmpower> qu=new LambdaQueryWrapper();
......@@ -71,6 +75,9 @@ public class UserLimitsAdvice {
qu.eq(StdUserEmpower::getPermissionType,"HYGF");
stdUserEmpower= userEmpowerMapper.selectOne(qu);
stdUserEmpower.setFlag(true);
//获取外部不选数据
List<Map<String,String>> lis=userEmpowerMapper.georgcodelist(stdUserEmpower.getEliminateAmosOrgCode());
stdUserEmpower.setNOeliminateAmosOrgCode(lis!=null?lis.stream().map(t -> t.get("orgCode").toString()).collect(Collectors.toList()):null);
}
UserEmpowerThreadLocal.setDataAuthRule(stdUserEmpower!=null?stdUserEmpower:null);
//正常往后执行
......
......@@ -39,8 +39,7 @@ public class UserUnitInformationDto {
@ApiModelProperty(value = "经销商单位id")
private Long amosUnitInfoId;
@ApiModelProperty(value = "role")
private String role;
}
......@@ -39,12 +39,20 @@ public class StdUserEmpower extends BaseEntity {
private String permissionType;
/**
* 单位orgcode
* 外部选中单位orgcode
*/
@TableField(value = "eliminate_amos_org_code",typeHandler = FastjsonTypeHandler.class)
private List<String> eliminateAmosOrgCode;
/**
* 外部 不选中单位orgcode
*/
@TableField(exist = false)
private List<String> NOeliminateAmosOrgCode;
//登录人id
@TableField(exist = false)
private String userId;
......
......@@ -2,6 +2,10 @@ package com.yeejoin.amos.boot.module.hygf.api.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.hygf.api.entity.StdUserEmpower;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* @description:
......@@ -10,4 +14,7 @@ import com.yeejoin.amos.boot.module.hygf.api.entity.StdUserEmpower;
*/
public interface UserEmpowerMapper extends BaseMapper<StdUserEmpower> {
List<Map<String,String>> georgcodelist(@Param("orgs") List<String> orgs );
}
......@@ -68,7 +68,6 @@ select ORG_CODE orgCode from privilege_company where privilege_company.SEQUEN
hygf_personnel_business.amos_dealer_id amosDealerId ,
privilege_company.COMPANY_NAME amosDealerName ,
privilege_company.ORG_CODE amosDealerOrgCode,
std_user_biz.role role,
(select sequence_nbr from hygf_unit_info h where h.amos_company_seq= hygf_personnel_business.amos_dealer_id )amosUnitInfoId
......
<?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.yeejoin.amos.boot.module.hygf.api.mapper.UserEmpowerMapper">
<select id="georgcodelist" resultType="Map">
select ORG_CODE orgCode from privilege_company where COMPANY_TYPE='region' and LEVEL='outer_company'
<if test="orgs != null and orgs.size() >0">
and ORG_CODE not in
<foreach collection="orgs" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
</select>
</mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment