Commit b89b8da6 authored by tangwei's avatar tangwei

修改权限注解

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