diff --git a/muyu-modules/muyu-ruleEngine/muyu-ruleEngine-common/src/main/java/com/muyu/engine/domain/Scope.java b/muyu-modules/muyu-ruleEngine/muyu-ruleEngine-common/src/main/java/com/muyu/engine/domain/Scope.java new file mode 100644 index 0000000..5bd89ec --- /dev/null +++ b/muyu-modules/muyu-ruleEngine/muyu-ruleEngine-common/src/main/java/com/muyu/engine/domain/Scope.java @@ -0,0 +1,98 @@ +package com.muyu.engine.domain; + +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.muyu.common.core.annotation.Excel; +import com.muyu.common.core.web.domain.BaseEntity; + +/** + * 规则引擎代码对象 scope + * + * @author Saisai + * @date 2024-05-03 + */ +public class Scope extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 主键 */ + private Long id; + + /** 引擎id */ + @Excel(name = "引擎id") + private Long ruleEnginId; + + /** 类型 */ + @Excel(name = "类型") + private String type; + + /** 类型值 */ + @Excel(name = "类型值") + private String value; + + /** 编码 */ + @Excel(name = "编码") + private String code; + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + public void setRuleEnginId(Long ruleEnginId) + { + this.ruleEnginId = ruleEnginId; + } + + public Long getRuleEnginId() + { + return ruleEnginId; + } + public void setType(String type) + { + this.type = type; + } + + public String getType() + { + return type; + } + public void setValue(String value) + { + this.value = value; + } + + public String getValue() + { + return value; + } + public void setCode(String code) + { + this.code = code; + } + + public String getCode() + { + return code; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("ruleEnginId", getRuleEnginId()) + .append("type", getType()) + .append("value", getValue()) + .append("code", getCode()) + .append("remark", getRemark()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .toString(); + } +} diff --git a/muyu-modules/muyu-ruleEngine/muyu-ruleEngine-service/src/main/java/com/muyu/RuleEngineApplication.java b/muyu-modules/muyu-ruleEngine/muyu-ruleEngine-service/src/main/java/com/muyu/RuleEngineApplication.java new file mode 100644 index 0000000..34fff42 --- /dev/null +++ b/muyu-modules/muyu-ruleEngine/muyu-ruleEngine-service/src/main/java/com/muyu/RuleEngineApplication.java @@ -0,0 +1,24 @@ +package com.muyu; + +import com.muyu.common.security.annotation.EnableCustomConfig; +import com.muyu.common.security.annotation.EnableMyFeignClients; +import com.muyu.common.swagger.annotation.EnableCustomSwagger2; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.openfeign.EnableFeignClients; + +/** + * @ClassName RuleEngineApplication + * @Description 描述 + * @Author SaiSai.Liu + * @Date 2024/5/3 11:43 + */ +@EnableCustomConfig +@EnableCustomSwagger2 +@EnableMyFeignClients +@SpringBootApplication +public class RuleEngineApplication { + public static void main(String[] args) { + SpringApplication.run(RuleEngineApplication.class); + } +} diff --git a/muyu-modules/muyu-ruleEngine/muyu-ruleEngine-service/src/main/java/com/muyu/engine/controller/RuleEngineController.java b/muyu-modules/muyu-ruleEngine/muyu-ruleEngine-service/src/main/java/com/muyu/engine/controller/RuleEngineController.java index 31422e6..e437d69 100644 --- a/muyu-modules/muyu-ruleEngine/muyu-ruleEngine-service/src/main/java/com/muyu/engine/controller/RuleEngineController.java +++ b/muyu-modules/muyu-ruleEngine/muyu-ruleEngine-service/src/main/java/com/muyu/engine/controller/RuleEngineController.java @@ -12,6 +12,7 @@ import com.muyu.engine.service.RuleEngineService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import javax.servlet.ServletException; import javax.servlet.http.HttpServletResponse; import java.util.List; @@ -95,4 +96,17 @@ public class RuleEngineController extends BaseController { return toAjax(ruleEngineService.deleteRuleEngineByIds(ids)); } + + /** + * 测试引擎流程 + */ + @RequiresPermissions("engine:engine:testRuleEngine") + @Log(title = "规则引擎", businessType = BusinessType.DELETE) + @DeleteMapping("testRuleEngine/{id}") + public Result testRuleEngine(@PathVariable Long id) throws ServletException { + return toAjax(ruleEngineService.testRuleEngine(id)); + } + + + } diff --git a/muyu-modules/muyu-ruleEngine/muyu-ruleEngine-service/src/main/java/com/muyu/engine/mapper/ScopeMapper.java b/muyu-modules/muyu-ruleEngine/muyu-ruleEngine-service/src/main/java/com/muyu/engine/mapper/ScopeMapper.java new file mode 100644 index 0000000..2bd915c --- /dev/null +++ b/muyu-modules/muyu-ruleEngine/muyu-ruleEngine-service/src/main/java/com/muyu/engine/mapper/ScopeMapper.java @@ -0,0 +1,63 @@ +package com.muyu.engine.mapper; + +import java.util.List; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.muyu.engine.domain.Scope; + +/** + * 规则引擎代码Mapper接口 + * + * @author Saisai + * @date 2024-05-03 + */ +public interface ScopeMapper extends BaseMapper +{ + /** + * 查询规则引擎代码 + * + * @param id 规则引擎代码主键 + * @return 规则引擎代码 + */ + public Scope selectScopeById(Long id); + + /** + * 查询规则引擎代码列表 + * + * @param scope 规则引擎代码 + * @return 规则引擎代码集合 + */ + public List selectScopeList(Scope scope); + + /** + * 新增规则引擎代码 + * + * @param scope 规则引擎代码 + * @return 结果 + */ + public int insertScope(Scope scope); + + /** + * 修改规则引擎代码 + * + * @param scope 规则引擎代码 + * @return 结果 + */ + public int updateScope(Scope scope); + + /** + * 删除规则引擎代码 + * + * @param id 规则引擎代码主键 + * @return 结果 + */ + public int deleteScopeById(Long id); + + /** + * 批量删除规则引擎代码 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteScopeByIds(Long[] ids); +} diff --git a/muyu-modules/muyu-ruleEngine/muyu-ruleEngine-service/src/main/java/com/muyu/engine/service/RuleEngineService.java b/muyu-modules/muyu-ruleEngine/muyu-ruleEngine-service/src/main/java/com/muyu/engine/service/RuleEngineService.java index 6253fdc..465990c 100644 --- a/muyu-modules/muyu-ruleEngine/muyu-ruleEngine-service/src/main/java/com/muyu/engine/service/RuleEngineService.java +++ b/muyu-modules/muyu-ruleEngine/muyu-ruleEngine-service/src/main/java/com/muyu/engine/service/RuleEngineService.java @@ -3,6 +3,7 @@ package com.muyu.engine.service; import com.baomidou.mybatisplus.extension.service.IService; import com.muyu.engine.domain.RuleEngine; +import javax.servlet.ServletException; import java.util.List; /** @@ -60,4 +61,11 @@ public interface RuleEngineService extends IService * @return 结果 */ public int deleteRuleEngineById(Long id); + + /** + * 测试引擎流程 + * @param id + * @return + */ + boolean testRuleEngine(Long id) throws ServletException; } diff --git a/muyu-modules/muyu-ruleEngine/muyu-ruleEngine-service/src/main/java/com/muyu/engine/service/ScopeService.java b/muyu-modules/muyu-ruleEngine/muyu-ruleEngine-service/src/main/java/com/muyu/engine/service/ScopeService.java new file mode 100644 index 0000000..1b3f7b1 --- /dev/null +++ b/muyu-modules/muyu-ruleEngine/muyu-ruleEngine-service/src/main/java/com/muyu/engine/service/ScopeService.java @@ -0,0 +1,63 @@ +package com.muyu.engine.service; + +import java.util.List; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.muyu.engine.domain.Scope; + +/** + * 规则引擎代码Service接口 + * + * @author Saisai + * @date 2024-05-03 + */ +public interface ScopeService extends IService +{ + /** + * 查询规则引擎代码 + * + * @param id 规则引擎代码主键 + * @return 规则引擎代码 + */ + public Scope selectScopeById(Long id); + + /** + * 查询规则引擎代码列表 + * + * @param scope 规则引擎代码 + * @return 规则引擎代码集合 + */ + public List selectScopeList(Scope scope); + + /** + * 新增规则引擎代码 + * + * @param scope 规则引擎代码 + * @return 结果 + */ + public int insertScope(Scope scope); + + /** + * 修改规则引擎代码 + * + * @param scope 规则引擎代码 + * @return 结果 + */ + public int updateScope(Scope scope); + + /** + * 批量删除规则引擎代码 + * + * @param ids 需要删除的规则引擎代码主键集合 + * @return 结果 + */ + public int deleteScopeByIds(Long[] ids); + + /** + * 删除规则引擎代码信息 + * + * @param id 规则引擎代码主键 + * @return 结果 + */ + public int deleteScopeById(Long id); +} diff --git a/muyu-modules/muyu-ruleEngine/muyu-ruleEngine-service/src/main/java/com/muyu/engine/service/impl/RuleEngineServiceImpl.java b/muyu-modules/muyu-ruleEngine/muyu-ruleEngine-service/src/main/java/com/muyu/engine/service/impl/RuleEngineServiceImpl.java index 0b1635c..d9e2985 100644 --- a/muyu-modules/muyu-ruleEngine/muyu-ruleEngine-service/src/main/java/com/muyu/engine/service/impl/RuleEngineServiceImpl.java +++ b/muyu-modules/muyu-ruleEngine/muyu-ruleEngine-service/src/main/java/com/muyu/engine/service/impl/RuleEngineServiceImpl.java @@ -1,5 +1,6 @@ package com.muyu.engine.service.impl; +import com.alibaba.nacos.shaded.com.google.common.base.Supplier; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.muyu.common.core.utils.DateUtils; import com.muyu.engine.domain.RuleEngine; @@ -9,7 +10,10 @@ import lombok.extern.log4j.Log4j2; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import javax.servlet.ServletException; +import java.io.File; import java.util.List; +import java.util.concurrent.Callable; /** * 规则引擎Service业务层处理 @@ -97,4 +101,33 @@ public class RuleEngineServiceImpl extends ServiceImpl booleanSupplier = () -> { + try { + return testEngine(ruleEngine).booleanValue(); + } catch (ServletException e) { + log.error(e.getMessage()); + throw new RuntimeException(e); + } + }; + System.out.println(); + return booleanSupplier.get(); + } + + private Boolean testEngine(RuleEngine ruleEngine) throws ServletException { + +// new File(ruleEngine); +// if (false)throw new ServletException("不存在"); + return true; + } } diff --git a/muyu-modules/muyu-ruleEngine/muyu-ruleEngine-service/src/main/java/com/muyu/engine/service/impl/ScopeServiceImpl.java b/muyu-modules/muyu-ruleEngine/muyu-ruleEngine-service/src/main/java/com/muyu/engine/service/impl/ScopeServiceImpl.java new file mode 100644 index 0000000..0234538 --- /dev/null +++ b/muyu-modules/muyu-ruleEngine/muyu-ruleEngine-service/src/main/java/com/muyu/engine/service/impl/ScopeServiceImpl.java @@ -0,0 +1,100 @@ +package com.muyu.engine.service.impl; + +import java.util.List; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.muyu.common.core.utils.DateUtils; +import lombok.extern.log4j.Log4j2; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.muyu.engine.mapper.ScopeMapper; +import com.muyu.engine.domain.Scope; +import com.muyu.engine.service.ScopeService; + +/** + * 规则引擎代码Service业务层处理 + * + * @author Saisai + * @date 2024-05-03 + */ +@Service +@Log4j2 +public class ScopeServiceImpl extends ServiceImpl implements ScopeService +{ + @Autowired + private ScopeMapper scopeMapper; + + /** + * 查询规则引擎代码 + * + * @param id 规则引擎代码主键 + * @return 规则引擎代码 + */ + @Override + public Scope selectScopeById(Long id) + { + return scopeMapper.selectScopeById(id); + } + + /** + * 查询规则引擎代码列表 + * + * @param scope 规则引擎代码 + * @return 规则引擎代码 + */ + @Override + public List selectScopeList(Scope scope) + { + return scopeMapper.selectScopeList(scope); + } + + /** + * 新增规则引擎代码 + * + * @param scope 规则引擎代码 + * @return 结果 + */ + @Override + public int insertScope(Scope scope) + { + scope.setCreateTime(DateUtils.getNowDate()); + return scopeMapper.insertScope(scope); + } + + /** + * 修改规则引擎代码 + * + * @param scope 规则引擎代码 + * @return 结果 + */ + @Override + public int updateScope(Scope scope) + { + scope.setUpdateTime(DateUtils.getNowDate()); + return scopeMapper.updateScope(scope); + } + + /** + * 批量删除规则引擎代码 + * + * @param ids 需要删除的规则引擎代码主键 + * @return 结果 + */ + @Override + public int deleteScopeByIds(Long[] ids) + { + return scopeMapper.deleteScopeByIds(ids); + } + + /** + * 删除规则引擎代码信息 + * + * @param id 规则引擎代码主键 + * @return 结果 + */ + @Override + public int deleteScopeById(Long id) + { + return scopeMapper.deleteScopeById(id); + } +} diff --git a/muyu-modules/muyu-ruleEngine/muyu-ruleEngine-service/src/main/resources/mapper/ScopeMapper.xml b/muyu-modules/muyu-ruleEngine/muyu-ruleEngine-service/src/main/resources/mapper/ScopeMapper.xml new file mode 100644 index 0000000..fae957c --- /dev/null +++ b/muyu-modules/muyu-ruleEngine/muyu-ruleEngine-service/src/main/resources/mapper/ScopeMapper.xml @@ -0,0 +1,93 @@ + + + + + + + + + + + + + + + + + + + select id, ruleEnginId, type, value, code, remark, create_by, create_time, update_by, update_time from scope + + + + + + + + insert into scope + + id, + ruleEnginId, + type, + value, + code, + remark, + create_by, + create_time, + update_by, + update_time, + + + #{id}, + #{ruleEnginId}, + #{type}, + #{value}, + #{code}, + #{remark}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + + + + + update scope + + ruleEnginId = #{ruleEnginId}, + type = #{type}, + value = #{value}, + code = #{code}, + remark = #{remark}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + + where id = #{id} + + + + delete from scope where id = #{id} + + + + delete from scope where id in + + #{id} + + +