Просмотр исходного кода

渠道权限控制校验公共方法

master
zouhantao 1 месяц назад
Родитель
Сommit
51317caa22

+ 23
- 0
zhywpt-service-ias/src/main/java/cn/com/taiji/ias/dict/AgencyConfigType.java Просмотреть файл

@@ -0,0 +1,23 @@
package cn.com.taiji.ias.dict;

import lombok.AllArgsConstructor;
import lombok.Getter;

@AllArgsConstructor
@Getter
public enum AgencyConfigType {

DEVICE_CHANGE("支持设备更换"),
VEHICLE_CHANGE("支持车牌变更"),
DEVICE_CANCEL("支持设备注销"),
SIGN_CHANGE("支持签约代扣信息变更"),
QT_SIGN("是否黔通代扣签约"),
CHANNEL_SIGN_URL("渠道签约地址"),
CHANNEL_SIGN_APP_ID("渠道签约小程序id"),
QT_USER_SIGN("是否黔通产品签约"),
;

private final String value;


}

+ 65
- 0
zhywpt-service-ias/src/main/java/cn/com/taiji/ias/manager/agencyConfig/AgencyConfigManager.java Просмотреть файл

@@ -0,0 +1,65 @@
package cn.com.taiji.ias.manager.agencyConfig;

import cn.com.taiji.common.manager.net.http.ServiceHandleException;
import cn.com.taiji.core.model.comm.protocol.valid.GlyServiceError;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.com.taiji.common.manager.ManagerException;
import cn.com.taiji.core.entity.ass.AssAgencyConfig;
import cn.com.taiji.core.entity.dict.EnableStatus;
import cn.com.taiji.core.manager.cache.RedisCacheManager;
import cn.com.taiji.core.repo.jpa.ass.AssAgencyConfigRepo;
import cn.com.taiji.core.repo.jpa.basic.QtkCardInfoRepo;
import cn.com.taiji.ias.dict.AgencyConfigType;

@Service
public class AgencyConfigManager extends RedisCacheManager {

@Autowired
protected QtkCardInfoRepo cardInfoRepo;
@Autowired
protected AssAgencyConfigRepo agencyConfigRepo;

/**
* 获取渠道权限配置
* @param agencyId 渠道id
* @return
* @throws ManagerException
*/
public AssAgencyConfig queryAgencyAuthConfig(String agencyId) throws ServiceHandleException {
AssAgencyConfig agencyAuthConfig = agencyConfigRepo.findByAgencyId(agencyId);
if (agencyAuthConfig == null){
throw GlyServiceError.BUSINESS_VALIDATE_ERR.toHandleException("渠道未配置权限");
}
if (agencyAuthConfig.getStatus().equals(EnableStatus.DISABLE)){
throw GlyServiceError.BUSINESS_VALIDATE_ERR.toHandleException("渠道状态异常");
}
return agencyAuthConfig;
}

// 校验渠道权限
public boolean checkAgencyConfig(String agencyId, AgencyConfigType configType) throws ServiceHandleException {
AssAgencyConfig config = queryAgencyAuthConfig(agencyId);
if (configType == null) return false;
if (configType.equals(AgencyConfigType.DEVICE_CHANGE)){
return config.getDeviceChange();
} else if (configType.equals(AgencyConfigType.VEHICLE_CHANGE)) {
return config.getVehicleChange();
} else if (configType.equals(AgencyConfigType.DEVICE_CANCEL)) {
return config.getDeviceChange();
} else if (configType.equals(AgencyConfigType.SIGN_CHANGE)) {
return config.getSignChange();
} else if (configType.equals(AgencyConfigType.QT_SIGN)) {
return config.getQtSign();
} else if (configType.equals(AgencyConfigType.CHANNEL_SIGN_URL)) {
return config.getChannelSignUrl();
} else if (configType.equals(AgencyConfigType.CHANNEL_SIGN_APP_ID)) {
return config.getChannelSignAppId();
} else if (configType.equals(AgencyConfigType.QT_USER_SIGN)) {
return config.getQtUserSign();
}
return false;
}

}

+ 3
- 3
zhywpt-service-ias/src/main/java/cn/com/taiji/ias/manager/vehicleInfoChange/VehicleChangeArtificialManager.java Просмотреть файл

@@ -2,9 +2,7 @@ package cn.com.taiji.ias.manager.vehicleInfoChange;

import java.time.LocalDateTime;

import cn.com.taiji.common.pub.BeanTools;
import cn.com.taiji.core.entity.ass.AssDeviceUpgrade;
import cn.com.taiji.core.repo.jpa.ass.AssDeviceUpgradeRepo;
import cn.com.taiji.ias.manager.agencyConfig.AgencyConfigManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@@ -56,6 +54,8 @@ public class VehicleChangeArtificialManager extends AbstractCommManager
private VehicleInfoChangeManager infoChangeManager;
@Autowired
private VehiclePlateChangeManager plateChangeManager;
@Autowired
private AgencyConfigManager configManager;

@Override
public void doSaveLog(VehicleChangeArtificialRequest request, VehicleChangeArtificialResponse response,

+ 11
- 7
zhywpt-service-ias/src/main/java/cn/com/taiji/ias/manager/vehicleInfoChange/VehicleInfoChangeManager.java Просмотреть файл

@@ -6,6 +6,8 @@ import java.time.LocalDateTime;
import java.util.List;
import java.util.Objects;

import cn.com.taiji.ias.dict.AgencyConfigType;
import cn.com.taiji.ias.manager.agencyConfig.AgencyConfigManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
@@ -81,6 +83,8 @@ public class VehicleInfoChangeManager extends AbstractCommManager
private VerificationRuleManager verificationRuleManager;
@Autowired
private IasInterfaceLogRepo logRepo;
@Autowired
private AgencyConfigManager configManager;

/**
* 车辆信息变更申请
@@ -90,10 +94,10 @@ public class VehicleInfoChangeManager extends AbstractCommManager
public VehicleInfoChangeResponse vehicleInfoChangeInfoApply(VehicleInfoChangeRequest req)
throws ServiceHandleException {
VehicleInfoChangeResponse res = new VehicleInfoChangeResponse();
// todo 卡渠道是否支持车辆信息变更
// if (checkAgencyAuthConfig(req.getCardId(), AgencyAuthConfigType.VEHICLE_INFO_CHANGE)) {
// throw GlyServiceError.RESPONSE_ERROR.toHandleException("当前渠道不支持车辆信息变更!");
// }
// 卡渠道是否支持车辆信息变更
if (configManager.checkAgencyConfig(req.getAgencyId(), AgencyConfigType.VEHICLE_CHANGE)) {
throw GlyServiceError.RESPONSE_ERROR.toHandleException("当前渠道不支持车辆信息变更!");
}
// 校验DTO参数
if (!req.ifMyselfHandle()) {
throw GlyServiceError.RESPONSE_ERROR.toHandleException("非自主办理,请上传委托书及经办人信息!");
@@ -297,9 +301,9 @@ public class VehicleInfoChangeManager extends AbstractCommManager
// 发生车型从大到小变更 转入人工审核
if (newVehicleType >= vehicleInfo.getType()) {
// todo 校验是否支持小改大
// if (checkAgencyAuthConfig(req.getCardId(), AgencyAuthConfigType.SMALL_TO_BIG)) {
// throw GlyServiceError.RESPONSE_ERROR.toHandleException("该渠道不支持收费车型小改大!");
// }
// if (configManager.checkAgencyConfig(req.getAgencyId(), AgencyConfigType.SMALL_TO_BIG)) {
// throw GlyServiceError.RESPONSE_ERROR.toHandleException("该渠道不支持收费车型小改大!");
// }
return true;
} else {
manualReview(assOrderinfo, "车辆信息变更自动审核失败原因:车辆收费类型从大改小!");

+ 8
- 4
zhywpt-service-ias/src/main/java/cn/com/taiji/ias/manager/vehicleInfoChange/VehiclePlateChangeManager.java Просмотреть файл

@@ -8,6 +8,8 @@ import java.util.Objects;

import cn.com.taiji.core.manager.tools.issue.IssueTools;
import cn.com.taiji.core.model.comm.protocol.ias.ygz.*;
import cn.com.taiji.ias.dict.AgencyConfigType;
import cn.com.taiji.ias.manager.agencyConfig.AgencyConfigManager;
import cn.com.taiji.ias.manager.ygz.YgzCardUploadManager;
import cn.com.taiji.ias.manager.ygz.YgzObuUploadManager;
import org.springframework.beans.factory.annotation.Autowired;
@@ -86,15 +88,17 @@ public class VehiclePlateChangeManager extends AbstractCommManager implements Lo
private AssVehicleInfoChangeRepo vehicleInfoChangeRepo;
@Autowired
private VehicleInfoChangeManager infoChangeManager;
@Autowired
private AgencyConfigManager configManager;

@Transactional
public VehiclePlateChangeResponse vehiclePlateChangeInfoApply(VehiclePlateChangeRequest req)
throws ServiceHandleException {
VehiclePlateChangeResponse res = new VehiclePlateChangeResponse();
// todo 渠道是否支持车牌变更
// if (checkAgencyAuthConfig(req.getCardId(), AgencyAuthConfigType.VEHICLE_PLATE_CHANGE)) {
// throw GlyServiceError.RESPONSE_ERROR.toHandleException("当前渠道不支持车辆信息变更!");
// }
// 渠道是否支持车牌变更
if (configManager.checkAgencyConfig(req.getAgencyId(), AgencyConfigType.VEHICLE_CHANGE)) {
throw GlyServiceError.RESPONSE_ERROR.toHandleException("当前渠道不支持车辆信息变更!");
}
// 校验DTO参数
if (!req.ifMyselfHandle()) {
throw GlyServiceError.RESPONSE_ERROR.toHandleException("非自主办理,请上传委托书及经办人信息!");

Загрузка…
Отмена
Сохранить