Commit f564cc3c authored by tangwei's avatar tangwei

修改注解

parent db1d5bae
...@@ -31,8 +31,9 @@ public class UserEmpowerInterceptor implements Interceptor { ...@@ -31,8 +31,9 @@ public class UserEmpowerInterceptor implements Interceptor {
@Override @Override
public Object intercept(Invocation invocation) throws Throwable { public Object intercept(Invocation invocation) throws Throwable {
StdUserEmpower orgCode = UserEmpowerThreadLocal.getDataAuthRule();
if(orgCode.isFlag()){
try { try {
StatementHandler statementHandler = PluginUtils.realTarget(invocation.getTarget()); StatementHandler statementHandler = PluginUtils.realTarget(invocation.getTarget());
MetaObject metaObject = SystemMetaObject.forObject(statementHandler); MetaObject metaObject = SystemMetaObject.forObject(statementHandler);
...@@ -43,6 +44,8 @@ public class UserEmpowerInterceptor implements Interceptor { ...@@ -43,6 +44,8 @@ public class UserEmpowerInterceptor implements Interceptor {
if(userEmpower==null){ if(userEmpower==null){
return invocation.proceed(); return invocation.proceed();
} }
StdUserEmpower orgCode = UserEmpowerThreadLocal.getDataAuthRule();
if(orgCode!=null&&orgCode.isFlag()){
//获取字段 //获取字段
String[] filed= userEmpower.field(); String[] filed= userEmpower.field();
//获取字段条件表达式 //获取字段条件表达式
...@@ -97,7 +100,9 @@ public class UserEmpowerInterceptor implements Interceptor { ...@@ -97,7 +100,9 @@ public class UserEmpowerInterceptor implements Interceptor {
} }
System.out.println(selectBody.toString()); System.out.println(selectBody.toString());
metaObject.setValue("delegate.boundSql.sql", selectBody.toString()); metaObject.setValue("delegate.boundSql.sql", selectBody.toString());
}else{
return invocation.proceed();
}
}catch (Exception e){ }catch (Exception e){
e.printStackTrace(); e.printStackTrace();
throw new BadRequest("权限认证失败!"); throw new BadRequest("权限认证失败!");
...@@ -105,9 +110,7 @@ public class UserEmpowerInterceptor implements Interceptor { ...@@ -105,9 +110,7 @@ public class UserEmpowerInterceptor implements Interceptor {
UserEmpowerThreadLocal.clean(); UserEmpowerThreadLocal.clean();
} }
return invocation.proceed(); return invocation.proceed();
}else{
return invocation.proceed();
}
} }
@Override @Override
...@@ -130,11 +133,12 @@ public class UserEmpowerInterceptor implements Interceptor { ...@@ -130,11 +133,12 @@ public class UserEmpowerInterceptor implements Interceptor {
if(specific){ if(specific){
List<String> data= stdUserEmpower.getAmosOrgCode(); List<String> data= stdUserEmpower.getAmosOrgCode();
List<String> notdata= stdUserEmpower.getEliminateAmosOrgCode(); List<String> notdata= stdUserEmpower.getEliminateAmosOrgCode();
List<String> wnotdata= stdUserEmpower.getNOeliminateAmosOrgCode();
if( filed!=null&&filed.length>0){ if( filed!=null&&filed.length>0){
for (int i = 0; i < filed.length; i++) { for (int i = 0; i < filed.length; i++) {
String sq=" "; String sq=" ";
sq= getConditiontd(filed[i],fileCondition[i],data,notdata); sq= getConditiontd(filed[i],fileCondition[i],data,notdata,wnotdata);
sql.add(sq); sql.add(sq);
} }
} }
...@@ -156,13 +160,55 @@ public class UserEmpowerInterceptor implements Interceptor { ...@@ -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=" "; String sql=" ";
if(data!=null&&!data.isEmpty()){
if(data.contains("all")){ if(data==null||data.size()==0){
sql = sql+getnotInData( filed,notdata);
}else{ //内部不选 外部不选
sql = sql+getInData( filed,data) + "and"+ getnotInData( filed,notdata); 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{
//内部选一部分, 外度全选
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; return sql;
......
...@@ -23,6 +23,9 @@ import org.typroject.tyboot.core.foundation.context.RequestContext; ...@@ -23,6 +23,9 @@ import org.typroject.tyboot.core.foundation.context.RequestContext;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/** /**
* @description: * @description:
...@@ -37,8 +40,8 @@ public class UserLimitsAdvice { ...@@ -37,8 +40,8 @@ public class UserLimitsAdvice {
@Autowired @Autowired
private UserEmpowerMapper userEmpowerMapper; private UserEmpowerMapper userEmpowerMapper;
@Autowired // @Autowired
PersonnelBusinessMapper personnelBusinessMapper; //// PersonnelBusinessMapper personnelBusinessMapper;
@Autowired @Autowired
private RedisUtils redisUtils; private RedisUtils redisUtils;
...@@ -60,10 +63,11 @@ public class UserLimitsAdvice { ...@@ -60,10 +63,11 @@ public class UserLimitsAdvice {
//判断是否经销商,经销商跟管理端互斥 //判断是否经销商,经销商跟管理端互斥
String org= reginParams.getUserModel().getOrgNames(); String org= reginParams.getUserModel().getOrgNames();
if(org.contains(ROLEFLAG)){ if(org.contains(ROLEFLAG)){
UserUnitInformationDto userUnitInformationDto=personnelBusinessMapper.getUserUnitInformationDto(userid); // UserUnitInformationDto userUnitInformationDto=personnelBusinessMapper.getUserUnitInformationDto(userid);
UserUnitInformationDto userUnitInformationDto=null;
stdUserEmpower.setFlag(false); stdUserEmpower.setFlag(false);
stdUserEmpower.setDeveloperId(userUnitInformationDto.getAmosUnitInfoId()); stdUserEmpower.setDeveloperId(userUnitInformationDto!=null?userUnitInformationDto.getAmosUnitInfoId():null);
stdUserEmpower.setRegionalCompaniesCode(userUnitInformationDto.getRegionalCompaniesCode()); stdUserEmpower.setRegionalCompaniesCode(userUnitInformationDto!=null?userUnitInformationDto.getRegionalCompaniesCode():null);
stdUserEmpower.setUserId(userid); stdUserEmpower.setUserId(userid);
}else{ }else{
LambdaQueryWrapper<StdUserEmpower> qu=new LambdaQueryWrapper(); LambdaQueryWrapper<StdUserEmpower> qu=new LambdaQueryWrapper();
...@@ -71,6 +75,9 @@ public class UserLimitsAdvice { ...@@ -71,6 +75,9 @@ public class UserLimitsAdvice {
qu.eq(StdUserEmpower::getPermissionType,"HYGF"); qu.eq(StdUserEmpower::getPermissionType,"HYGF");
stdUserEmpower= userEmpowerMapper.selectOne(qu); stdUserEmpower= userEmpowerMapper.selectOne(qu);
stdUserEmpower.setFlag(true); 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); UserEmpowerThreadLocal.setDataAuthRule(stdUserEmpower!=null?stdUserEmpower:null);
//正常往后执行 //正常往后执行
......
...@@ -39,8 +39,7 @@ public class UserUnitInformationDto { ...@@ -39,8 +39,7 @@ public class UserUnitInformationDto {
@ApiModelProperty(value = "经销商单位id") @ApiModelProperty(value = "经销商单位id")
private Long amosUnitInfoId; private Long amosUnitInfoId;
@ApiModelProperty(value = "role")
private String role;
} }
...@@ -39,12 +39,20 @@ public class StdUserEmpower extends BaseEntity { ...@@ -39,12 +39,20 @@ public class StdUserEmpower extends BaseEntity {
private String permissionType; private String permissionType;
/** /**
* 单位orgcode * 外部选中单位orgcode
*/ */
@TableField(value = "eliminate_amos_org_code",typeHandler = FastjsonTypeHandler.class) @TableField(value = "eliminate_amos_org_code",typeHandler = FastjsonTypeHandler.class)
private List<String> eliminateAmosOrgCode; private List<String> eliminateAmosOrgCode;
/**
* 外部 不选中单位orgcode
*/
@TableField(exist = false)
private List<String> NOeliminateAmosOrgCode;
//登录人id //登录人id
@TableField(exist = false) @TableField(exist = false)
private String userId; private String userId;
......
...@@ -2,6 +2,10 @@ package com.yeejoin.amos.boot.module.hygf.api.mapper; ...@@ -2,6 +2,10 @@ package com.yeejoin.amos.boot.module.hygf.api.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.hygf.api.entity.StdUserEmpower; 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: * @description:
...@@ -10,4 +14,7 @@ import com.yeejoin.amos.boot.module.hygf.api.entity.StdUserEmpower; ...@@ -10,4 +14,7 @@ import com.yeejoin.amos.boot.module.hygf.api.entity.StdUserEmpower;
*/ */
public interface UserEmpowerMapper extends BaseMapper<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 ...@@ -68,7 +68,6 @@ select ORG_CODE orgCode from privilege_company where privilege_company.SEQUEN
hygf_personnel_business.amos_dealer_id amosDealerId , hygf_personnel_business.amos_dealer_id amosDealerId ,
privilege_company.COMPANY_NAME amosDealerName , privilege_company.COMPANY_NAME amosDealerName ,
privilege_company.ORG_CODE amosDealerOrgCode, 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 (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>
...@@ -96,9 +96,9 @@ public class PowerStationController extends BaseController { ...@@ -96,9 +96,9 @@ public class PowerStationController extends BaseController {
@GetMapping(value = "/page") @GetMapping(value = "/page")
@ApiOperation(httpMethod = "GET",value = "分页查询", notes = "分页查询") @ApiOperation(httpMethod = "GET",value = "分页查询", notes = "分页查询")
public ResponseModel<Page<PowerStationDto>> queryForPage(@RequestParam(value = "current") int current, public ResponseModel<Page<PowerStationDto>> queryForPage(@RequestParam(value = "current") int current,
@RequestParam(value = "size") int size, @RequestParam(value = "size") int size,
@RequestParam(value = "powerStationCode",required = false)String powerStationCode, @RequestParam(value = "powerStationCode",required = false)String powerStationCode,
@RequestParam(value = "ownersName",required = false)String ownersName) { @RequestParam(value = "ownersName",required = false)String ownersName) {
Page<PowerStationDto> page = new Page<PowerStationDto>(); Page<PowerStationDto> page = new Page<PowerStationDto>();
page.setCurrent(current); page.setCurrent(current);
page.setSize(size); page.setSize(size);
......
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