Sfoglia il codice sorgente

Fix: 修复异常回滚

lwh 3 settimane fa
parent
commit
c1fd651a59

+ 10 - 2
pig-marketing/pig-marketing-biz/src/main/java/com/pig4cloud/pig/marketing/service/impl/MarketingAppsServiceImpl.java

@@ -336,6 +336,7 @@ public class MarketingAppsServiceImpl implements MarketingAppsService {
 	 * @return R
 	 */
 	@Override
+	@Transactional(rollbackFor = Exception.class)
 	public R modMarketingAppsIps(ModMarketingAppsIpDTO reqDto) {
 		Long appId = reqDto.getId();
 		if (reqDto.getId() == null) {
@@ -363,6 +364,7 @@ public class MarketingAppsServiceImpl implements MarketingAppsService {
 	 * @return R
 	 */
 	@Override
+	@Transactional(rollbackFor = Exception.class)
 	public R modMarketingAppsDomains(ModMarketingAppsDomainDTO reqDto) {
 		Long appId = reqDto.getId();
 		if (reqDto.getId() == null){
@@ -499,7 +501,7 @@ public class MarketingAppsServiceImpl implements MarketingAppsService {
 	/**
 	 * 处理IP的新增/修改/删除,包含分组存在性检查
 	 */
-	private void handleIpOperations(BatchUpdateMarketingAppsDTO reqDto, Long appId) {
+	private void handleIpOperations(BatchUpdateMarketingAppsDTO reqDto, Long appId) throws BusinessException {
 		// 2.1 删除指定IP
 		if (reqDto.getDelIps() != null && !reqDto.getDelIps().isEmpty()) {
 			appsIpMapper.deleteByIds(reqDto.getDelIps());
@@ -535,6 +537,9 @@ public class MarketingAppsServiceImpl implements MarketingAppsService {
 
 				// 查询ip表和ip分组表中是否存在
 				if (checkIp(ipDto, appId, false)){
+					if (ipDto.getSourceType() == 1){
+						throw new BusinessException("分组ID:"+ipDto.getGroupId()+"已存在");
+					}
 					if (ipDto.getIpMode() == 1){
 						throw new BusinessException("ip:"+ipDto.getStartIp()+"已存在");
 					}
@@ -560,7 +565,7 @@ public class MarketingAppsServiceImpl implements MarketingAppsService {
 	/**
 	 * 处理域名的新增/修改/删除,包含完整校验逻辑
 	 */
-	private void handleDomainOperations(BatchUpdateMarketingAppsDTO reqDto, Long appId) {
+	private void handleDomainOperations(BatchUpdateMarketingAppsDTO reqDto, Long appId) throws BusinessException {
 		// 3.1 删除指定域名
 		if (reqDto.getDelDomains() != null && !reqDto.getDelDomains().isEmpty()) {
 			appsDomainMapper.deleteBatchIds(reqDto.getDelDomains());
@@ -591,6 +596,9 @@ public class MarketingAppsServiceImpl implements MarketingAppsService {
 				}
 
 				if (checkDomain(domainDto, appId, false)){
+					if (domainDto.getSourceType() == 1){
+						throw new BusinessException("分组ID:"+domainDto.getGroupId()+"已存在");
+					}
 					throw new BusinessException("域名:"+domainDto.getDomain()+"已存在");
 				}