提交 0c706923 作者: 沈振路

人群包配置、接口

上级 81c4d132
package com.yaoyaozw.customer.constants;
import java.util.regex.Pattern;
/**
* @author darker
* @date 2022/9/20 14:54
......@@ -26,4 +29,6 @@ public class CrowdPackageCommonConstant {
public static final Integer NUN_STATIC_CONDITION = 0;
public static final Pattern NUMBER_COMPILE = Pattern.compile("[\\d]");
}
......@@ -63,6 +63,15 @@ public class CrowdPackageServiceImpl extends ServiceImpl<MaterialCrowdPackageMap
Long userId = tokenManager.getUserIdFromToken();
CrowdPackage crowdPackage = new CrowdPackage(id, name);
crowdPackage.handleInfo(new Date(), userId, isCreate);
if (ObjectUtil.isNotNull(name)) {
// 判断是否有重名
QueryWrapper<CrowdPackage> nameRepeatWrapper = new QueryWrapper<CrowdPackage>().eq("name", name).ne("id", id);
int count = super.count(nameRepeatWrapper);
if (count != 0) {
LOCAL_LOG.info("人群包名: {} 有重复", name);
return new GenericsResult<>(false, "人群包名已存在!");
}
}
// 执行保存
boolean result = super.saveOrUpdate(crowdPackage);
return result ? new GenericsResult<>(new CrowdPackageCommonIdVO(crowdPackage.getId(), null)) : new GenericsResult<>(false, "新增人群包失败!");
......@@ -99,6 +108,7 @@ public class CrowdPackageServiceImpl extends ServiceImpl<MaterialCrowdPackageMap
@Override
public GenericsResult<CrowdPackageDetailVO> getPackageInfo(Long id) {
LOCAL_LOG.info("获取详情");
CrowdPackage byId = super.getById(id);
if (ObjectUtil.isNull(byId)) {
return new GenericsResult<>(false, "无法获取主体数据");
......@@ -123,7 +133,7 @@ public class CrowdPackageServiceImpl extends ServiceImpl<MaterialCrowdPackageMap
@Override
public BaseResult removeCrowdPackage(Long id) {
return super.removeById(id) ? new BaseResult().error("删除异常!") : new BaseResult().success();
return super.removeById(id) ? new BaseResult().success() : new BaseResult().error("删除异常!");
}
@Override
......@@ -217,6 +227,7 @@ public class CrowdPackageServiceImpl extends ServiceImpl<MaterialCrowdPackageMap
String compareOperator = conditionDto.getCompareOperator();
String conditionValue = conditionDto.getConditionValue();
LOCAL_LOG.info("比较符: {}; 条件值: {}", compareOperator, conditionValue);
match.setConditionOperator(compareOperator);
match.setOperatorValue(conditionValue);
......@@ -224,12 +235,19 @@ public class CrowdPackageServiceImpl extends ServiceImpl<MaterialCrowdPackageMap
if (ObjectUtil.isNull(operatorInfo)) {
throw new RuntimeException("无法获取比较类型");
}
String expression = conditionInfo.getConditionKey() + " " + operatorInfo.getMeaning() + " " + conditionValue;
LOCAL_LOG.info("表达式拼接结果: {}", expression);
String description = conditionInfo.getConditionName() + operatorInfo.getDescription() + conditionValue;
LOCAL_LOG.info("条件描述: {}", description);
// 判断是不是数字
if (!CrowdPackageCommonConstant.NUMBER_COMPILE.matcher(conditionValue).matches()) {
// 不是数字,添加引号,否则sql报错
conditionValue = "'" + conditionValue + "'";
}
String expression = conditionInfo.getConditionKey() + " " + operatorInfo.getMeaning() + " " + conditionValue;
LOCAL_LOG.info("表达式拼接结果: {}", expression);
match.setOperatorExpression(expression);
match.setOperatorDescription(description);
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论