Commit bffbcacd by guojuxing

平台规则编辑、删除、查询接口添加

parent eebd41a5
package com.gic.enterprise.service;
import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.enterprise.dto.rule.RuleClassifyDTO;
import com.gic.enterprise.dto.rule.RuleClassifySceneDTO;
import com.gic.enterprise.dto.rule.RuleDTO;
import java.util.List;
/**
* 平台规则配置
* @ClassName: ConfigRuleApiService

......@@ -22,6 +26,42 @@ public interface ConfigRuleApiService {
* @return com.gic.api.base.commons.ServiceResponse<java.lang.Integer>


*/
ServiceResponse<Integer> saveRule(RuleDTO dto);
ServiceResponse<Integer> editRule(RuleDTO dto);
/**
* 规则列表
* @Title: listRule

* @Description:
* @param search 规则名称

* @author guojuxing 

* @return com.gic.api.base.commons.ServiceResponse<java.util.List<com.gic.enterprise.dto.rule.RuleDTO>>


*/
ServiceResponse<List<RuleDTO>> listRule(String search);
/**
* 分页查询分类列表
* @Title: listRuleClassify

* @Description:

* @author guojuxing
* @param search 分类名称
* @param ruleId 规则ID
* @param pageNum
* @param pageSize

* @return com.gic.api.base.commons.ServiceResponse<com.gic.api.base.commons.Page<com.gic.enterprise.dto.rule.RuleClassifyDTO>>


*/
ServiceResponse<Page<RuleClassifyDTO>> listRuleClassify(String search, Integer ruleId, Integer pageNum, Integer pageSize);
/**
* 分页查询场景列表
* @Title: listRuleClassifyScene

* @Description:

* @author guojuxing
* @param search 场景名称
* @param ruleId 分类ID
* @param pageNum
* @param pageSize

* @return com.gic.api.base.commons.ServiceResponse<com.gic.api.base.commons.Page<com.gic.enterprise.dto.rule.RuleClassifySceneDTO>>


*/
ServiceResponse<Page<RuleClassifySceneDTO>> listRuleClassifyScene(String search, Integer ruleId, Integer pageNum, Integer pageSize);
/**
* 新增分类
* @Title: saveRuleClassify

......@@ -31,6 +71,7 @@ public interface ConfigRuleApiService {
* @return com.gic.api.base.commons.ServiceResponse<java.lang.Integer>


*/
ServiceResponse<Integer> saveRuleClassify(RuleClassifyDTO dto);
ServiceResponse<String> editRuleClassify(RuleClassifyDTO dto);
/**
* 新增场景
* @Title: saveRuleClassifyScene

......@@ -40,4 +81,9 @@ public interface ConfigRuleApiService {
* @return com.gic.api.base.commons.ServiceResponse<java.lang.Integer>


*/
ServiceResponse<Integer> saveRuleClassifyScene(RuleClassifySceneDTO dto);
ServiceResponse<String> editRuleClassifyScene(RuleClassifySceneDTO dto);
ServiceResponse<String> deleteRule(Integer ruleId);
ServiceResponse<String> deleteRuleClassify(Integer ruleId);
ServiceResponse<String> deleteRuleClassifyScene(Integer ruleId);
}
......@@ -3,6 +3,8 @@ package com.gic.enterprise.dao.mapper;
import com.gic.enterprise.entity.TabConfigRule;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface TabConfigRuleMapper {
/**
* 根据主键删除
......@@ -52,5 +54,9 @@ public interface TabConfigRuleMapper {
*/
int updateByPrimaryKey(TabConfigRule record);
int countRepeatName(@Param("ruleId") Integer ruleId, @Param("ruleLevel") Integer ruleLevel, @Param("name") String name);
int countRepeatName(@Param("ruleId") Integer ruleId, @Param("ruleLevel") Integer ruleLevel,
@Param("name") String name, @Param("parentRuleId") Integer parentRuleId);
List<TabConfigRule> listRule(@Param("search") String search, @Param("ruleLevel") Integer ruleLevel,
@Param("ruleId") Integer ruleId);
}
\ No newline at end of file
......@@ -4,6 +4,9 @@ import com.gic.enterprise.dto.rule.RuleClassifyDTO;
import com.gic.enterprise.dto.rule.RuleClassifySceneDTO;
import com.gic.enterprise.dto.rule.RuleDTO;
import com.gic.enterprise.entity.TabConfigRule;
import com.github.pagehelper.Page;
import java.util.List;
/**
* 平台规则配置
......@@ -49,9 +52,26 @@ public interface ConfigRuleService {
/**
* 名称唯一性校验
* @param ruleId
* @param ruleLevel
* @param name
* @param ruleLevel 层级1:规则 2:分类 3:场景
* @param name 规则/分类/场景名称
* @param parentRuleId 父级ID
* @return
*/
boolean isRepeatName(Integer ruleId, Integer ruleLevel, String name);
boolean isRepeatName(Integer ruleId, Integer ruleLevel, String name, Integer parentRuleId);
/**
* 分页查询
* @Title: listRule

* @Description:

* @author guojuxing
* @param search 规则/分类/场景名称
* @param ruleLevel 1:规则 2:分类 3:场景
* @param ruleId
如果是规则,则不需要;如果是分类,则需要规则ID;如果是场景,需要分类ID
* @param pageNum
* @param pageSize
* @return java.util.List<com.gic.enterprise.entity.TabConfigRule>


*/
Page<TabConfigRule> listRule(String search, Integer ruleLevel, Integer ruleId, Integer pageNum, Integer pageSize);
List<TabConfigRule> listRule(String search, Integer ruleLevel, Integer ruleId);
}
......@@ -7,10 +7,13 @@ import com.gic.enterprise.dto.rule.RuleClassifySceneDTO;
import com.gic.enterprise.dto.rule.RuleDTO;
import com.gic.enterprise.entity.TabConfigRule;
import com.gic.enterprise.service.ConfigRuleService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
@Service("configRuleService")
public class ConfigRuleServiceImpl implements ConfigRuleService{
......@@ -34,6 +37,7 @@ public class ConfigRuleServiceImpl implements ConfigRuleService{
@Override
public void update(TabConfigRule record) {
record.setUpdateTime(new Date());
tabConfigRuleMapper.updateByPrimaryKeySelective(record);
}
......@@ -43,14 +47,26 @@ public class ConfigRuleServiceImpl implements ConfigRuleService{
}
@Override
public boolean isRepeatName(Integer ruleId, Integer ruleLevel, String name) {
int count = tabConfigRuleMapper.countRepeatName(ruleId, ruleLevel, name);
public boolean isRepeatName(Integer ruleId, Integer ruleLevel, String name, Integer parentRuleId) {
int count = tabConfigRuleMapper.countRepeatName(ruleId, ruleLevel, name, parentRuleId);
if (count > 0) {
return true;
}
return false;
}
@Override
public Page<TabConfigRule> listRule(String search, Integer ruleLevel, Integer ruleId, Integer pageNum, Integer pageSize) {
PageHelper.startPage(pageNum, pageSize);
List<TabConfigRule> list = tabConfigRuleMapper.listRule(search, ruleLevel, ruleId);
return (Page<TabConfigRule>) list;
}
@Override
public List<TabConfigRule> listRule(String search, Integer ruleLevel, Integer ruleId) {
return tabConfigRuleMapper.listRule(search, ruleLevel, ruleId);
}
private Integer save(TabConfigRule record) {
record.setStatus(1);
record.setCreateTime(new Date());
......
......@@ -215,8 +215,30 @@
where status = 1
and rule_level = #{ruleLevel}
and name = #{name}
<if test="ruleId != null">
and rule_id &lt;&gt; #{ruleId}
<if test="ruleLevel == 1">
<if test="ruleId != null">
and rule_id &lt;&gt; #{ruleId}
</if>
</if>
<if test="ruleLevel != 1">
and parent_rule_id = #{parentRuleId}
<if test="ruleId != null">
and rule_id &lt;&gt; #{ruleId}
</if>
</if>
</select>
<select id="listRule" resultMap="BaseResultMap">
select <include refid="Base_Column_List"></include>
from tab_config_rule
where status = 1
and rule_level = #{ruleLevel}
<if test="ruleLevel != 1 ">
and parent_rule_id = #{ruleId}
</if>
<if test="search != null and search != '' ">
and ( name like concat('%', #{search}, '%') )
</if>
order by create_time desc
</select>
</mapper>
\ No newline at end of file
......@@ -183,6 +183,11 @@
<artifactId>gic-mall-share-api</artifactId>
<version>${gic-mall-share-api}</version>
</dependency>
<dependency>
<groupId>com.gic</groupId>
<artifactId>rule-manage-api</artifactId>
<version>${rule-manage-api}</version>
</dependency>
</dependencies>
<dependencyManagement>
......
package com.gic.operation.web.controller;
import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.enterprise.dto.rule.RuleClassifyDTO;
import com.gic.enterprise.dto.rule.RuleClassifySceneDTO;
import com.gic.enterprise.dto.rule.RuleDTO;
import com.gic.enterprise.service.ConfigRuleApiService;
import com.gic.enterprise.utils.ResultControllerUtils;
import com.gic.operation.web.vo.SceneCategoryVO;
import com.gic.rule.manage.api.service.DealOperationApiService;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/config/rule")
public class ConfigRuleController {
private static final Logger LOGGER = LogManager.getLogger(ConfigRuleController.class);
@Autowired
private ConfigRuleApiService configRuleApiService;
@Autowired
private DealOperationApiService dealOperationApiService;
@RequestMapping("/saveRule")
public RestResponse saveRule(RuleDTO dto) {
return ResultControllerUtils.commonResult(configRuleApiService.saveRule(dto));
}
@RequestMapping("/editRule")
public RestResponse editRule(RuleDTO dto) {
return ResultControllerUtils.commonResult(configRuleApiService.editRule(dto));
}
@RequestMapping("/saveRuleClassify")
public RestResponse saveRuleClassify(RuleClassifyDTO dto) {
return ResultControllerUtils.commonResult(configRuleApiService.saveRuleClassify(dto));
}
@RequestMapping("/editRuleClassify")
public RestResponse editRuleClassify(RuleClassifyDTO dto) {
return ResultControllerUtils.commonResult(configRuleApiService.editRuleClassify(dto));
}
@RequestMapping("/saveRuleClassifyScene")
public RestResponse saveRuleClassifyScene(RuleClassifySceneDTO dto) {
return ResultControllerUtils.commonResult(configRuleApiService.saveRuleClassifyScene(dto));
}
@RequestMapping("/editRuleClassifyScene")
public RestResponse editRuleClassifyScene(RuleClassifySceneDTO dto) {
return ResultControllerUtils.commonResult(configRuleApiService.editRuleClassifyScene(dto));
}
@RequestMapping("/deleteClassify")
public RestResponse deleteClassify(Integer ruleId) {
return ResultControllerUtils.commonResult(configRuleApiService.deleteRuleClassify(ruleId));
}
@RequestMapping("/deleteClassifyScene")
public RestResponse deleteClassifyScene(Integer ruleId) {
return ResultControllerUtils.commonResult(configRuleApiService.deleteRuleClassifyScene(ruleId));
}
@RequestMapping("/list-scene")
public RestResponse listScene(String search, Integer pageNum, Integer pageSize) {
return ResultControllerUtils.commonPageResult(
dealOperationApiService.pageSceneCategory(search, pageNum, pageSize), SceneCategoryVO.class);
}
}
package com.gic.operation.web.vo;
import lombok.Data;
import java.io.Serializable;
/**
* 规则引擎场景组
* @ClassName: SceneCategoryVO

* @Description: 

* @author guojuxing

* @date 2020/3/4 10:34 AM

*/
@Data
public class SceneCategoryVO implements Serializable{
private static final long serialVersionUID = -7881761432709566286L;
/**
* 场景组code
*/
private String sceneCode;
private String sceneName;
}
......@@ -79,6 +79,10 @@
<dubbo:reference interface="com.gic.open.api.service.market.MarketAppCategoryApiService" id="marketAppCategoryApiService" timeout="6000" />
<!--链接小工具-->
<dubbo:reference interface="com.gic.enterprise.service.LinkApiService" id="linkApiService" timeout="6000" />
<!--平台规则配置-->
<dubbo:reference interface="com.gic.enterprise.service.ConfigRuleApiService" id="configRuleApiService" timeout="6000" />
<dubbo:reference interface="com.gic.rule.manage.api.service.DealOperationApiService" id="dealOperationApiService" timeout="6000" />
<dubbo:reference interface="com.gic.auth.service.BusinessFrontResApiService" id="businessFrontResApiService" timeout="6000" />
<!-- 消息路由 -->
<dubbo:reference interface="com.gic.mq.sdk.service.MQConfigService" id="mQConfigService" timeout="6000"/>
......
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