Commit b89b8da6 authored by tangwei's avatar tangwei

修改权限注解

parent f564cc3c
...@@ -2,6 +2,8 @@ package com.yeejoin.amos.boot.module.hygf.api.config; ...@@ -2,6 +2,8 @@ package com.yeejoin.amos.boot.module.hygf.api.config;
import com.baomidou.mybatisplus.core.toolkit.PluginUtils; import com.baomidou.mybatisplus.core.toolkit.PluginUtils;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.module.hygf.api.entity.StdUserEmpower; import com.yeejoin.amos.boot.module.hygf.api.entity.StdUserEmpower;
import net.sf.jsqlparser.expression.operators.conditional.AndExpression; import net.sf.jsqlparser.expression.operators.conditional.AndExpression;
import net.sf.jsqlparser.parser.CCJSqlParserUtil; import net.sf.jsqlparser.parser.CCJSqlParserUtil;
...@@ -16,6 +18,8 @@ import org.apache.ibatis.reflection.MetaObject; ...@@ -16,6 +18,8 @@ import org.apache.ibatis.reflection.MetaObject;
import org.apache.ibatis.reflection.SystemMetaObject; import org.apache.ibatis.reflection.SystemMetaObject;
import org.apache.ibatis.session.ResultHandler; import org.apache.ibatis.session.ResultHandler;
import org.apache.ibatis.session.RowBounds; import org.apache.ibatis.session.RowBounds;
import org.springframework.beans.factory.annotation.Autowired;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil; import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest; import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
...@@ -29,6 +33,15 @@ import java.util.Properties; ...@@ -29,6 +33,15 @@ import java.util.Properties;
RowBounds.class, ResultHandler.class}), @Signature(type = StatementHandler.class, method = "prepare", args = {Connection.class, Integer.class})}) RowBounds.class, ResultHandler.class}), @Signature(type = StatementHandler.class, method = "prepare", args = {Connection.class, Integer.class})})
public class UserEmpowerInterceptor implements Interceptor { public class UserEmpowerInterceptor implements Interceptor {
@Autowired
private RedisUtils redisUtils;
private static final String ROLEFLAG="-经销商-";
@Override @Override
public Object intercept(Invocation invocation) throws Throwable { public Object intercept(Invocation invocation) throws Throwable {
...@@ -44,7 +57,10 @@ public class UserEmpowerInterceptor implements Interceptor { ...@@ -44,7 +57,10 @@ public class UserEmpowerInterceptor implements Interceptor {
if(userEmpower==null){ if(userEmpower==null){
return invocation.proceed(); return invocation.proceed();
} }
StdUserEmpower orgCode = UserEmpowerThreadLocal.getDataAuthRule(); //StdUserEmpower orgCode = UserEmpowerThreadLocal.getDataAuthRule();
StdUserEmpower orgCode =(StdUserEmpower) redisUtils.get("Emp_"+RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken()));
if(orgCode!=null&&orgCode.isFlag()){ if(orgCode!=null&&orgCode.isFlag()){
//获取字段 //获取字段
String[] filed= userEmpower.field(); String[] filed= userEmpower.field();
...@@ -107,7 +123,7 @@ public class UserEmpowerInterceptor implements Interceptor { ...@@ -107,7 +123,7 @@ public class UserEmpowerInterceptor implements Interceptor {
e.printStackTrace(); e.printStackTrace();
throw new BadRequest("权限认证失败!"); throw new BadRequest("权限认证失败!");
}finally { }finally {
UserEmpowerThreadLocal.clean(); // UserEmpowerThreadLocal.clean();
} }
return invocation.proceed(); return invocation.proceed();
......
package com.yeejoin.amos.boot.module.hygf.api.config; //package com.yeejoin.amos.boot.module.hygf.api.config;
//
import com.yeejoin.amos.boot.module.hygf.api.entity.StdUserEmpower; //import com.yeejoin.amos.boot.module.hygf.api.entity.StdUserEmpower;
import org.slf4j.Logger; //import org.slf4j.Logger;
import org.slf4j.LoggerFactory; //import org.slf4j.LoggerFactory;
//
import java.util.List; //import java.util.List;
//
/** ///**
* @description: // * @description:
* @author: tw // * @author: tw
* @createDate: 2023/11/9 // * @createDate: 2023/11/9
*/ // */
public class UserEmpowerThreadLocal { //public class UserEmpowerThreadLocal {
private static final Logger logger = LoggerFactory.getLogger(com.yeejoin.amos.boot.biz.common.interceptors.PermissionInterceptorContext.class); // private static final Logger logger = LoggerFactory.getLogger(com.yeejoin.amos.boot.biz.common.interceptors.PermissionInterceptorContext.class);
//
private static ThreadLocal<UserEmpowerThreadLocalModel> requestContext = ThreadLocal.withInitial(UserEmpowerThreadLocalModel::new); // private static ThreadLocal<UserEmpowerThreadLocalModel> requestContext = ThreadLocal.withInitial(UserEmpowerThreadLocalModel::new);
//
private static UserEmpowerThreadLocalModel getPermissionInterceptorContext() { // private static UserEmpowerThreadLocalModel getPermissionInterceptorContext() {
return requestContext.get(); // return requestContext.get();
} // }
//
public static StdUserEmpower getDataAuthRule() { // public static StdUserEmpower getDataAuthRule() {
return getPermissionInterceptorContext().getThreadLocalData(); // return getPermissionInterceptorContext().getThreadLocalData();
} // }
//
public static void setDataAuthRule(StdUserEmpower dataAuthRule) { // public static void setDataAuthRule(StdUserEmpower dataAuthRule) {
getPermissionInterceptorContext().setDataAuthRule(dataAuthRule); // getPermissionInterceptorContext().setDataAuthRule(dataAuthRule);
} // }
//
public static void clean() { // public static void clean() {
if (requestContext != null) { // if (requestContext != null) {
requestContext.remove(); // requestContext.remove();
} // }
} // }
} // }
\ No newline at end of file \ No newline at end of file
package com.yeejoin.amos.boot.module.hygf.api.config; //package com.yeejoin.amos.boot.module.hygf.api.config;
//
import com.yeejoin.amos.boot.module.hygf.api.entity.StdUserEmpower; //import com.yeejoin.amos.boot.module.hygf.api.entity.StdUserEmpower;
//
import java.io.Serializable; //import java.io.Serializable;
import java.util.List; //import java.util.List;
//
/** ///**
* @description: // * @description:
* @author: tw // * @author: tw
* @createDate: 2023/11/9 // * @createDate: 2023/11/9
*/ // */
public class UserEmpowerThreadLocalModel implements Serializable { //public class UserEmpowerThreadLocalModel implements Serializable {
private static final long serialVersionUID = 1L; // private static final long serialVersionUID = 1L;
//
private StdUserEmpower threadLocalData; // private StdUserEmpower threadLocalData;
//
public StdUserEmpower getThreadLocalData() { // public StdUserEmpower getThreadLocalData() {
return threadLocalData; // return threadLocalData;
} // }
//
public void setDataAuthRule(StdUserEmpower threadLocalData) { // public void setDataAuthRule(StdUserEmpower threadLocalData) {
this.threadLocalData = threadLocalData; // this.threadLocalData = threadLocalData;
} // }
//
public void clean() { // public void clean() {
this.threadLocalData = null; // this.threadLocalData = null;
} // }
//
} //}
...@@ -40,8 +40,8 @@ public class UserLimitsAdvice { ...@@ -40,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;
...@@ -63,8 +63,8 @@ public class UserLimitsAdvice { ...@@ -63,8 +63,8 @@ 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; //UserUnitInformationDto userUnitInformationDto=null;
stdUserEmpower.setFlag(false); stdUserEmpower.setFlag(false);
stdUserEmpower.setDeveloperId(userUnitInformationDto!=null?userUnitInformationDto.getAmosUnitInfoId():null); stdUserEmpower.setDeveloperId(userUnitInformationDto!=null?userUnitInformationDto.getAmosUnitInfoId():null);
stdUserEmpower.setRegionalCompaniesCode(userUnitInformationDto!=null?userUnitInformationDto.getRegionalCompaniesCode():null); stdUserEmpower.setRegionalCompaniesCode(userUnitInformationDto!=null?userUnitInformationDto.getRegionalCompaniesCode():null);
...@@ -74,12 +74,19 @@ public class UserLimitsAdvice { ...@@ -74,12 +74,19 @@ public class UserLimitsAdvice {
qu.eq(StdUserEmpower::getAmosUserId,userid); qu.eq(StdUserEmpower::getAmosUserId,userid);
qu.eq(StdUserEmpower::getPermissionType,"HYGF"); qu.eq(StdUserEmpower::getPermissionType,"HYGF");
stdUserEmpower= userEmpowerMapper.selectOne(qu); stdUserEmpower= userEmpowerMapper.selectOne(qu);
if(stdUserEmpower==null){
stdUserEmpower=new StdUserEmpower();
}
stdUserEmpower.setFlag(true); stdUserEmpower.setFlag(true);
//获取外部不选数据 //获取外部不选数据
List<Map<String,String>> lis=userEmpowerMapper.georgcodelist(stdUserEmpower.getEliminateAmosOrgCode()); 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); 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);
redisUtils.set("Emp_"+RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken()),stdUserEmpower!=null?stdUserEmpower:null);
//正常往后执行 //正常往后执行
return joinPoint.proceed(); return joinPoint.proceed();
} }
......
...@@ -2,6 +2,7 @@ package com.yeejoin.amos.boot.module.hygf.api.mapper; ...@@ -2,6 +2,7 @@ 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.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yeejoin.amos.boot.module.hygf.api.config.UserEmpower;
import com.yeejoin.amos.boot.module.hygf.api.dto.CompanyDtoUserDto; import com.yeejoin.amos.boot.module.hygf.api.dto.CompanyDtoUserDto;
import com.yeejoin.amos.boot.module.hygf.api.dto.UserUnitInformationDto; import com.yeejoin.amos.boot.module.hygf.api.dto.UserUnitInformationDto;
import com.yeejoin.amos.boot.module.hygf.api.entity.PersonnelBusiness; import com.yeejoin.amos.boot.module.hygf.api.entity.PersonnelBusiness;
...@@ -21,7 +22,6 @@ public interface PersonnelBusinessMapper extends BaseMapper<PersonnelBusiness> { ...@@ -21,7 +22,6 @@ public interface PersonnelBusinessMapper extends BaseMapper<PersonnelBusiness> {
Map<String,String> getorgcode(@Param("id")Long id); Map<String,String> getorgcode(@Param("id")Long id);
//根据平台userid 获取人员所属经销商 //根据平台userid 获取人员所属经销商
UserUnitInformationDto getUserUnitInformationDto(@Param("userId")String userId); UserUnitInformationDto getUserUnitInformationDto(@Param("userId")String userId);
......
package com.yeejoin.amos.boot.module.hygf.api.mapper; 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.config.UserEmpower;
import com.yeejoin.amos.boot.module.hygf.api.config.UserLimits;
import com.yeejoin.amos.boot.module.hygf.api.dto.PowerStationDto; import com.yeejoin.amos.boot.module.hygf.api.dto.PowerStationDto;
import com.yeejoin.amos.boot.module.hygf.api.entity.PowerStation; import com.yeejoin.amos.boot.module.hygf.api.entity.PowerStation;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
...@@ -14,6 +16,7 @@ import java.util.List; ...@@ -14,6 +16,7 @@ import java.util.List;
* @date 2023-07-15 * @date 2023-07-15
*/ */
public interface PowerStationMapper extends BaseMapper<PowerStation> { public interface PowerStationMapper extends BaseMapper<PowerStation> {
@UserEmpower(field ={"regional_companies_code"} ,fieldConditions ={"in"} ,relationship="and")
List<PowerStationDto> queryPage(@Param("powerStationCode") String powerStationCode, List<PowerStationDto> queryPage(@Param("powerStationCode") String powerStationCode,
@Param("ownersName")String ownersName, @Param("ownersName")String ownersName,
@Param("serviceAgent")String serviceAgent); @Param("serviceAgent")String serviceAgent);
......
...@@ -5,9 +5,11 @@ ...@@ -5,9 +5,11 @@
select * from (select select * from (select
hygf_power_station.*, hygf_power_station.*,
b.initiate_status, b.initiate_status,
b.contract_lock_id b.contract_lock_id,
hygf_peasant_household.regional_companies_code
from hygf_power_station LEFT JOIN ( select peasant_household_id,initiate_status, contract_lock_id from hygf_household_contract where hygf_household_contract.status !='已作废' from hygf_power_station LEFT JOIN ( select peasant_household_id,initiate_status, contract_lock_id from hygf_household_contract where hygf_household_contract.status !='已作废'
) b on b.peasant_household_id=hygf_power_station.peasant_household_id ) b on b.peasant_household_id=hygf_power_station.peasant_household_id
LEFT JOIN hygf_peasant_household on hygf_peasant_household.sequence_nbr=hygf_power_station.peasant_household_id
where hygf_power_station.is_delete=0 where hygf_power_station.is_delete=0
<if test="powerStationCode!=null and powerStationCode!=''"> <if test="powerStationCode!=null and powerStationCode!=''">
......
...@@ -2,6 +2,7 @@ package com.yeejoin.amos.boot.module.hygf.biz.controller; ...@@ -2,6 +2,7 @@ package com.yeejoin.amos.boot.module.hygf.biz.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.controller.BaseController; import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.module.hygf.api.config.UserLimits;
import com.yeejoin.amos.boot.module.hygf.api.dto.PowerStationDto; import com.yeejoin.amos.boot.module.hygf.api.dto.PowerStationDto;
import com.yeejoin.amos.boot.module.hygf.biz.service.impl.PowerStationServiceImpl; import com.yeejoin.amos.boot.module.hygf.biz.service.impl.PowerStationServiceImpl;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel; import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
...@@ -95,6 +96,7 @@ public class PowerStationController extends BaseController { ...@@ -95,6 +96,7 @@ public class PowerStationController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/page") @GetMapping(value = "/page")
@ApiOperation(httpMethod = "GET",value = "分页查询", notes = "分页查询") @ApiOperation(httpMethod = "GET",value = "分页查询", notes = "分页查询")
@UserLimits
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,
......
...@@ -9,6 +9,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; ...@@ -9,6 +9,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.yeejoin.amos.boot.module.hygf.api.Enum.*; import com.yeejoin.amos.boot.module.hygf.api.Enum.*;
import com.yeejoin.amos.boot.module.hygf.api.config.UserLimits;
import com.yeejoin.amos.boot.module.hygf.api.dto.*; import com.yeejoin.amos.boot.module.hygf.api.dto.*;
import com.yeejoin.amos.boot.module.hygf.api.entity.*; import com.yeejoin.amos.boot.module.hygf.api.entity.*;
import com.yeejoin.amos.boot.module.hygf.api.fegin.IdxFeginService; import com.yeejoin.amos.boot.module.hygf.api.fegin.IdxFeginService;
...@@ -100,18 +101,17 @@ public class PowerStationServiceImpl extends BaseService<PowerStationDto, PowerS ...@@ -100,18 +101,17 @@ public class PowerStationServiceImpl extends BaseService<PowerStationDto, PowerS
// } // }
//获取用户所在经销商单位 //获取用户所在经销商单位
UserUnitInformationDto userUnitInformationDto=personnelBusinessMapper.getUserUnitInformationDto(userInfo.getUserId()); // UserUnitInformationDto userUnitInformationDto=personnelBusinessMapper.getUserUnitInformationDto(userInfo.getUserId());
//
if(userUnitInformationDto!=null&&userUnitInformationDto.getAmosDealerName()!=null){ // if(userUnitInformationDto!=null&&userUnitInformationDto.getAmosDealerName()!=null){
serviceAgent=userUnitInformationDto.getAmosDealerName(); // serviceAgent=userUnitInformationDto.getAmosDealerName();
} // }
//return this.queryForPowerStationPage(page,powerStationCode,ownersName,serviceAgent); //return this.queryForPowerStationPage(page,powerStationCode,ownersName,serviceAgent);
return this.queryPage((int) page.getCurrent(), (int) page.getSize(),powerStationCode,ownersName,serviceAgent); return this.queryPage((int) page.getCurrent(), (int) page.getSize(),powerStationCode,ownersName,serviceAgent);
} }
//查询电站审核记录 //查询电站审核记录
public Page<PowerStationDto> queryPage(int current, int size, public Page<PowerStationDto> queryPage(int current, int size,
String powerStationCode, String powerStationCode,
String ownersName,String serviceAgent) { String ownersName,String serviceAgent) {
......
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