Commit 8ff56827 by guojuxing

复制规则

parent 8482cc8d
package com.gic.enterprise.dto.rule;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
......@@ -12,6 +13,7 @@ import java.util.Date;
* @author guojuxing

* @date 2020/3/3 2:45 PM

*/
@Accessors(chain = true)
@Data
public class RuleClassifyDTO implements Serializable{
private static final long serialVersionUID = 6258321185779741516L;
......
package com.gic.enterprise.dto.rule;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
......@@ -12,6 +13,7 @@ import java.util.Date;
* @author guojuxing

* @date 2020/3/3 2:46 PM

*/
@Accessors(chain = true)
@Data
public class RuleClassifySceneDTO implements Serializable{
private static final long serialVersionUID = 2944424324223164756L;
......
package com.gic.enterprise.dto.rule;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
......@@ -12,6 +13,7 @@ import java.util.Date;
* @author guojuxing

* @date 2020/3/3 2:43 PM

*/
@Accessors(chain = true)
@Data
public class RuleDTO implements Serializable{
private static final long serialVersionUID = 5568436339396966487L;
......
......@@ -97,4 +97,14 @@ public interface ConfigRuleApiService {
* @return com.gic.api.base.commons.ServiceResponse<com.gic.enterprise.dto.rule.ConfigRuleDTO>


*/
ServiceResponse<ConfigRuleDTO> getDetailByRuleId(Integer ruleId);
/**
* 复制规则,包括下面的分类和分类下的场景;应用code是空
* @Title: copyRule

* @Description:

* @author guojuxing
* @param ruleId

* @return com.gic.api.base.commons.ServiceResponse<java.lang.Void>


*/
ServiceResponse<Integer> copyRule(Integer ruleId);
}
......@@ -95,7 +95,8 @@ public class ConfigRuleApiServiceImpl implements ConfigRuleApiService {
public ServiceResponse<com.gic.api.base.commons.Page<RuleClassifyDTO>> listRuleClassify(String search,
Integer ruleId, Integer pageNum, Integer pageSize) {
Page<TabConfigRule> page = configRuleService.listRule(search, 2, ruleId, pageNum, pageSize);
com.gic.api.base.commons.Page resultPage = PageHelperUtils.changePageHelperToCurrentPage(page, RuleClassifyDTO.class);
com.gic.api.base.commons.Page resultPage = PageHelperUtils.changePageHelperToCurrentPage(page,
RuleClassifyDTO.class);
return ServiceResponse.success(resultPage);
}
......@@ -103,7 +104,8 @@ public class ConfigRuleApiServiceImpl implements ConfigRuleApiService {
public ServiceResponse<com.gic.api.base.commons.Page<RuleClassifySceneDTO>> listRuleClassifyScene(String search,
Integer ruleId, Integer pageNum, Integer pageSize) {
Page<TabConfigRule> page = configRuleService.listRule(search, 3, ruleId, pageNum, pageSize);
com.gic.api.base.commons.Page resultPage = PageHelperUtils.changePageHelperToCurrentPage(page, RuleClassifySceneDTO.class);
com.gic.api.base.commons.Page resultPage = PageHelperUtils.changePageHelperToCurrentPage(page,
RuleClassifySceneDTO.class);
return ServiceResponse.success(resultPage);
}
......@@ -191,14 +193,14 @@ public class ConfigRuleApiServiceImpl implements ConfigRuleApiService {
@Override
public ServiceResponse<String> deleteRule(Integer ruleId) {
//规则不允许删除
// TabConfigRule record = configRuleService.getByRuleId(ruleId);
// if (record == null) {
// return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "规则ID错误,规则不存在");
// }
// if (record.getRuleLevel() != 1) {
// return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "规则ID错误,不是规则类型");
// }
// configRuleService.update(new TabConfigRule().setRuleId(ruleId).setStatus(0));
// TabConfigRule record = configRuleService.getByRuleId(ruleId);
// if (record == null) {
// return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "规则ID错误,规则不存在");
// }
// if (record.getRuleLevel() != 1) {
// return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "规则ID错误,不是规则类型");
// }
// configRuleService.update(new TabConfigRule().setRuleId(ruleId).setStatus(0));
return ServiceResponse.success();
}
......@@ -244,6 +246,50 @@ public class ConfigRuleApiServiceImpl implements ConfigRuleApiService {
return ServiceResponse.success(EntityUtil.changeEntityNew(ConfigRuleDTO.class, record));
}
@Override
public ServiceResponse<Integer> copyRule(Integer ruleId) {
TabConfigRule record = configRuleService.getByRuleId(ruleId);
if (record == null) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "规则ID错误,规则不存在");
}
if (record.getRuleLevel() != 1) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "规则ID错误,不是规则类型");
}
//复制规则
Integer copyRuleId = configRuleService
.saveRule(new RuleDTO().setRuleName(record.getRuleName() + "-副本").setRuleLevel(1).setParentRuleId(0));
//更新操作ID链数据
configRuleService.update(new TabConfigRule().setRuleId(ruleId).setRuleChain("_0_" + copyRuleId + "_"));
//复制分类
List<TabConfigRule> classifyList = configRuleService.listRule(null, 2, ruleId);
if (CollectionUtils.isNotEmpty(classifyList)) {
for (TabConfigRule tabConfigRule : classifyList) {
Integer classifyId = configRuleService.saveRuleClassify(new RuleClassifyDTO()
.setParentRuleId(copyRuleId).setClassifyIcon(tabConfigRule.getClassifyIcon())
.setRemark(tabConfigRule.getRemark()).setRuleDesc(tabConfigRule.getRuleDesc())
.setRuleLevel(2).setRuleName(tabConfigRule.getRuleName()));
//更新操作ID链数据
String classifyChain = "_0_" + copyRuleId + "_" + classifyId + "_";
configRuleService.update(new TabConfigRule().setRuleId(ruleId).setRuleChain(classifyChain));
//复制场景
List<TabConfigRule> sceneList = configRuleService.listRule(null, 3, tabConfigRule.getRuleId());
if (CollectionUtils.isNotEmpty(sceneList)) {
for (TabConfigRule scene : sceneList) {
//新增场景
Integer sceneId = configRuleService.saveRuleClassifyScene(new RuleClassifySceneDTO()
.setParentRuleId(classifyId).setMarketObject(scene.getMarketObject())
.setMarketScene(scene.getMarketScene()).setRemark(scene.getRemark())
.setRuleDesc(scene.getRuleDesc()).setRuleLevel(3).setRuleName(scene.getRuleName()));
//更新操作ID链数据
configRuleService.update(new TabConfigRule().setRuleId(ruleId).setRuleChain(classifyChain + sceneId + "_"));
}
}
}
}
return ServiceResponse.success(copyRuleId);
}
private ServiceResponse<Void> validRuleClassify(RuleClassifyDTO dto) {
TabConfigRule record = configRuleService.getByRuleId(dto.getParentRuleId());
if (record == null) {
......
......@@ -53,6 +53,11 @@ public class ConfigRuleController {
return ResultControllerUtils.commonResultOne(configRuleApiService.getDetailByRuleId(ruleId), RuleVO.class);
}
@RequestMapping("/copyRule")
public RestResponse copyRule(Integer ruleId) {
return ResultControllerUtils.commonResult(configRuleApiService.copyRule(ruleId));
}
@RequestMapping("/saveRuleClassify")
public RestResponse saveRuleClassify(RuleClassifyDTO dto) {
return ResultControllerUtils.commonResult(configRuleApiService.saveRuleClassify(dto));
......
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