|
@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
+import com.pig4cloud.pig.common.core.exception.BusinessException;
|
|
import com.pig4cloud.pig.common.core.util.R;
|
|
import com.pig4cloud.pig.common.core.util.R;
|
|
import com.pig4cloud.pig.marketing.api.dto.app.*;
|
|
import com.pig4cloud.pig.marketing.api.dto.app.*;
|
|
import com.pig4cloud.pig.marketing.api.entity.*;
|
|
import com.pig4cloud.pig.marketing.api.entity.*;
|
|
@@ -130,7 +131,7 @@ public class MarketingAppsServiceImpl implements MarketingAppsService {
|
|
public PageMarketingAppsVO getMarketingAppById(Long id) {
|
|
public PageMarketingAppsVO getMarketingAppById(Long id) {
|
|
MarketingApps app = appsMapper.selectById(id);
|
|
MarketingApps app = appsMapper.selectById(id);
|
|
if (app == null){
|
|
if (app == null){
|
|
- throw new RuntimeException("应用不存在");
|
|
|
|
|
|
+ throw new BusinessException("应用不存在");
|
|
}
|
|
}
|
|
PageMarketingAppsVO appsVO = new PageMarketingAppsVO();
|
|
PageMarketingAppsVO appsVO = new PageMarketingAppsVO();
|
|
BeanUtils.copyProperties(app, appsVO);
|
|
BeanUtils.copyProperties(app, appsVO);
|
|
@@ -177,15 +178,15 @@ public class MarketingAppsServiceImpl implements MarketingAppsService {
|
|
for (BatchUpdateMarketingAppsDTO reqDto : reqDtoList) {
|
|
for (BatchUpdateMarketingAppsDTO reqDto : reqDtoList) {
|
|
Long id = reqDto.getId();
|
|
Long id = reqDto.getId();
|
|
if (reqDto.getId() == null){
|
|
if (reqDto.getId() == null){
|
|
- throw new RuntimeException("应用ID不能为空");
|
|
|
|
|
|
+ throw new BusinessException("应用ID不能为空");
|
|
}
|
|
}
|
|
|
|
|
|
MarketingApps apps = appsMapper.selectById(id);
|
|
MarketingApps apps = appsMapper.selectById(id);
|
|
if (apps == null){
|
|
if (apps == null){
|
|
- throw new RuntimeException("应用ID:"+id+"不存在");
|
|
|
|
|
|
+ throw new BusinessException("应用ID:"+id+"不存在");
|
|
}
|
|
}
|
|
if (!apps.getStatus()){
|
|
if (!apps.getStatus()){
|
|
- throw new RuntimeException("应用ID:"+id+"已拉黑,请还原后操作");
|
|
|
|
|
|
+ throw new BusinessException("应用ID:"+id+"已拉黑,请还原后操作");
|
|
}
|
|
}
|
|
|
|
|
|
// 1、更新基本信息
|
|
// 1、更新基本信息
|
|
@@ -212,10 +213,10 @@ public class MarketingAppsServiceImpl implements MarketingAppsService {
|
|
public Boolean setMarketingAppsInfo(SetMarketingAppsDTO reqDto) {
|
|
public Boolean setMarketingAppsInfo(SetMarketingAppsDTO reqDto) {
|
|
MarketingApps app = appsMapper.selectById(reqDto.getId());
|
|
MarketingApps app = appsMapper.selectById(reqDto.getId());
|
|
if (app == null){
|
|
if (app == null){
|
|
- throw new RuntimeException("应用不存在");
|
|
|
|
|
|
+ throw new BusinessException("应用不存在");
|
|
}
|
|
}
|
|
if (!app.getStatus()){
|
|
if (!app.getStatus()){
|
|
- throw new RuntimeException("应用ID:"+app.getId()+"已拉黑,请还原后操作");
|
|
|
|
|
|
+ throw new BusinessException("应用ID:"+app.getId()+"已拉黑,请还原后操作");
|
|
}
|
|
}
|
|
MarketingApps apps = new MarketingApps();
|
|
MarketingApps apps = new MarketingApps();
|
|
BeanUtils.copyProperties(reqDto, apps);
|
|
BeanUtils.copyProperties(reqDto, apps);
|
|
@@ -232,7 +233,7 @@ public class MarketingAppsServiceImpl implements MarketingAppsService {
|
|
public Boolean setAppStatusById(SetMarketingAppsStatusDTO reqDto) {
|
|
public Boolean setAppStatusById(SetMarketingAppsStatusDTO reqDto) {
|
|
MarketingApps apps = appsMapper.selectById(reqDto.getId());
|
|
MarketingApps apps = appsMapper.selectById(reqDto.getId());
|
|
if (apps == null) {
|
|
if (apps == null) {
|
|
- throw new RuntimeException("应用不存在");
|
|
|
|
|
|
+ throw new BusinessException("应用不存在");
|
|
}
|
|
}
|
|
apps.setStatus(reqDto.getStatus());
|
|
apps.setStatus(reqDto.getStatus());
|
|
return appsMapper.updateById(apps) > 0;
|
|
return appsMapper.updateById(apps) > 0;
|
|
@@ -323,14 +324,14 @@ public class MarketingAppsServiceImpl implements MarketingAppsService {
|
|
public R modMarketingAppsIps(ModMarketingAppsIpDTO reqDto) {
|
|
public R modMarketingAppsIps(ModMarketingAppsIpDTO reqDto) {
|
|
Long appId = reqDto.getId();
|
|
Long appId = reqDto.getId();
|
|
if (reqDto.getId() == null) {
|
|
if (reqDto.getId() == null) {
|
|
- throw new RuntimeException("应用ID不能为空");
|
|
|
|
|
|
+ throw new BusinessException("应用ID不能为空");
|
|
}
|
|
}
|
|
MarketingApps app = appsMapper.selectById(appId);
|
|
MarketingApps app = appsMapper.selectById(appId);
|
|
if (app == null){
|
|
if (app == null){
|
|
- throw new RuntimeException("应用ID:"+appId+"不存在");
|
|
|
|
|
|
+ throw new BusinessException("应用ID:"+appId+"不存在");
|
|
}
|
|
}
|
|
if (!app.getStatus()){
|
|
if (!app.getStatus()){
|
|
- throw new RuntimeException("应用ID:"+app.getId()+"已拉黑,请还原后操作");
|
|
|
|
|
|
+ throw new BusinessException("应用ID:"+app.getId()+"已拉黑,请还原后操作");
|
|
}
|
|
}
|
|
BatchUpdateMarketingAppsDTO updateIp = new BatchUpdateMarketingAppsDTO();
|
|
BatchUpdateMarketingAppsDTO updateIp = new BatchUpdateMarketingAppsDTO();
|
|
updateIp.setId(appId);
|
|
updateIp.setId(appId);
|
|
@@ -350,14 +351,14 @@ public class MarketingAppsServiceImpl implements MarketingAppsService {
|
|
public R modMarketingAppsDomains(ModMarketingAppsDomainDTO reqDto) {
|
|
public R modMarketingAppsDomains(ModMarketingAppsDomainDTO reqDto) {
|
|
Long appId = reqDto.getId();
|
|
Long appId = reqDto.getId();
|
|
if (reqDto.getId() == null){
|
|
if (reqDto.getId() == null){
|
|
- throw new RuntimeException("应用ID不能为空");
|
|
|
|
|
|
+ throw new BusinessException("应用ID不能为空");
|
|
}
|
|
}
|
|
MarketingApps app = appsMapper.selectById(appId);
|
|
MarketingApps app = appsMapper.selectById(appId);
|
|
if (app == null){
|
|
if (app == null){
|
|
- throw new RuntimeException("应用ID:"+appId+"不存在");
|
|
|
|
|
|
+ throw new BusinessException("应用ID:"+appId+"不存在");
|
|
}
|
|
}
|
|
if (!app.getStatus()){
|
|
if (!app.getStatus()){
|
|
- throw new RuntimeException("应用ID:"+app.getId()+"已拉黑,请还原后操作");
|
|
|
|
|
|
+ throw new BusinessException("应用ID:"+app.getId()+"已拉黑,请还原后操作");
|
|
}
|
|
}
|
|
BatchUpdateMarketingAppsDTO updateDomain = new BatchUpdateMarketingAppsDTO();
|
|
BatchUpdateMarketingAppsDTO updateDomain = new BatchUpdateMarketingAppsDTO();
|
|
updateDomain.setId(appId);
|
|
updateDomain.setId(appId);
|
|
@@ -455,7 +456,10 @@ public class MarketingAppsServiceImpl implements MarketingAppsService {
|
|
|
|
|
|
// 查询ip表和ip分组表中是否存在
|
|
// 查询ip表和ip分组表中是否存在
|
|
if (checkIp(ipDto, appId)){
|
|
if (checkIp(ipDto, appId)){
|
|
- throw new RuntimeException("ip已存在");
|
|
|
|
|
|
+ if (ipDto.getIpMode() == 1){
|
|
|
|
+ throw new BusinessException("ip:"+ipDto.getStartIp()+"已存在");
|
|
|
|
+ }
|
|
|
|
+ throw new BusinessException("ip:"+ipDto.getStartIp()+"/"+ipDto.getEndIp()+"已存在");
|
|
}
|
|
}
|
|
|
|
|
|
// 执行新增或修改
|
|
// 执行新增或修改
|
|
@@ -490,7 +494,7 @@ public class MarketingAppsServiceImpl implements MarketingAppsService {
|
|
}
|
|
}
|
|
|
|
|
|
if (checkDomain(domainDto, appId)){
|
|
if (checkDomain(domainDto, appId)){
|
|
- throw new RuntimeException("域名已存在");
|
|
|
|
|
|
+ throw new BusinessException("域名:"+domainDto.getDomain()+"已存在");
|
|
}
|
|
}
|
|
|
|
|
|
// 执行新增或修改
|
|
// 执行新增或修改
|
|
@@ -511,17 +515,21 @@ public class MarketingAppsServiceImpl implements MarketingAppsService {
|
|
/**
|
|
/**
|
|
* 判断IP是否已存在(单IP或IP段)
|
|
* 判断IP是否已存在(单IP或IP段)
|
|
* @param appId 应用数据ID
|
|
* @param appId 应用数据ID
|
|
- * @param ipDTO IP
|
|
|
|
|
|
+ * @param ipDto IP
|
|
* @return 是否存在
|
|
* @return 是否存在
|
|
*/
|
|
*/
|
|
- public boolean checkIp(MarketingAppsIpDTO ipDTO, Long appId) {
|
|
|
|
|
|
+ public boolean checkIp(MarketingAppsIpDTO ipDto, Long appId) {
|
|
|
|
+ List<Long> groupIds = getAppRelatedGroupIds(appId, true);
|
|
|
|
+ if (ipDto.getSourceType().equals(1)){
|
|
|
|
+ return groupIds.contains(ipDto.getGroupId());
|
|
|
|
+ }
|
|
// 1. 检查应用IP表
|
|
// 1. 检查应用IP表
|
|
- if (checkAppsIpExists(ipDTO, appId)) {
|
|
|
|
|
|
+ if (checkAppsIpExists(ipDto, appId)) {
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
// 2. 检查分组IP表(需要关联应用关联的分组)
|
|
// 2. 检查分组IP表(需要关联应用关联的分组)
|
|
- return checkGroupIpExists(ipDTO, appId);
|
|
|
|
|
|
+ return checkGroupIpExists(ipDto, groupIds);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -531,16 +539,22 @@ public class MarketingAppsServiceImpl implements MarketingAppsService {
|
|
* @return 是否存在
|
|
* @return 是否存在
|
|
*/
|
|
*/
|
|
public Boolean checkDomain(MarketingAppsDomainDTO domainDTO, Long appId) {
|
|
public Boolean checkDomain(MarketingAppsDomainDTO domainDTO, Long appId) {
|
|
|
|
+ List<Long> groupIds = getAppRelatedGroupIds(appId, false); // 需要实现获取应用关联的分组ID列表
|
|
|
|
+ if (domainDTO.getSourceType().equals(1)){
|
|
|
|
+ // 来自分组
|
|
|
|
+ return groupIds.contains(domainDTO.getGroupId());
|
|
|
|
+ }
|
|
|
|
+
|
|
// 1. 检查应用域名表
|
|
// 1. 检查应用域名表
|
|
LambdaQueryWrapper<MarketingAppsDomain> appsQuery = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<MarketingAppsDomain> appsQuery = new LambdaQueryWrapper<>();
|
|
appsQuery.eq(MarketingAppsDomain::getAppId, appId)
|
|
appsQuery.eq(MarketingAppsDomain::getAppId, appId)
|
|
|
|
+ .eq(MarketingAppsDomain::getSourceType, 2)
|
|
.eq(MarketingAppsDomain::getDomain, domainDTO.getDomain());
|
|
.eq(MarketingAppsDomain::getDomain, domainDTO.getDomain());
|
|
if (appsDomainMapper.selectCount(appsQuery) > 0) {
|
|
if (appsDomainMapper.selectCount(appsQuery) > 0) {
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
// 2. 检查分组域名表(需要关联应用关联的分组)
|
|
// 2. 检查分组域名表(需要关联应用关联的分组)
|
|
- List<Long> groupIds = getAppRelatedGroupIds(appId, false); // 需要实现获取应用关联的分组ID列表
|
|
|
|
if (!groupIds.isEmpty()) {
|
|
if (!groupIds.isEmpty()) {
|
|
LambdaQueryWrapper<MarketingGroupDomain> groupQuery = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<MarketingGroupDomain> groupQuery = new LambdaQueryWrapper<>();
|
|
groupQuery.in(MarketingGroupDomain::getGroupId, groupIds)
|
|
groupQuery.in(MarketingGroupDomain::getGroupId, groupIds)
|
|
@@ -558,7 +572,7 @@ public class MarketingAppsServiceImpl implements MarketingAppsService {
|
|
// 1.1、校验marketing_apps_ip表,appId=appId,是否包含
|
|
// 1.1、校验marketing_apps_ip表,appId=appId,是否包含
|
|
// 1.2、校验marketing_group_ip表,是否包含ip,如果包含查出分组id,在查看appId下是否包含这个分组
|
|
// 1.2、校验marketing_group_ip表,是否包含ip,如果包含查出分组id,在查看appId下是否包含这个分组
|
|
QueryWrapper<MarketingAppsIp> query = new QueryWrapper<>();
|
|
QueryWrapper<MarketingAppsIp> query = new QueryWrapper<>();
|
|
- query.eq("app_id", appId);
|
|
|
|
|
|
+ query.eq("app_id", appId).eq("source_type",2);
|
|
|
|
|
|
// 单IP模式检查
|
|
// 单IP模式检查
|
|
if (ipDto.getIpMode() == 1) {
|
|
if (ipDto.getIpMode() == 1) {
|
|
@@ -601,8 +615,7 @@ public class MarketingAppsServiceImpl implements MarketingAppsService {
|
|
/**
|
|
/**
|
|
* 检查分组IP表中是否存在冲突
|
|
* 检查分组IP表中是否存在冲突
|
|
*/
|
|
*/
|
|
- private boolean checkGroupIpExists(MarketingAppsIpDTO ipDTO, Long appId) {
|
|
|
|
- List<Long> groupIds = getAppRelatedGroupIds(appId, true); // 需要实现获取应用关联的分组ID列表
|
|
|
|
|
|
+ private boolean checkGroupIpExists(MarketingAppsIpDTO ipDTO, List<Long> groupIds) {
|
|
if (groupIds.isEmpty()) {
|
|
if (groupIds.isEmpty()) {
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|