feat: 规则引擎
parent
bd595bc65d
commit
e9fce2f45d
|
@ -7,9 +7,7 @@ import com.muyu.data.source.service.DictionaryService;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import java.util.Dictionary;
|
import java.util.Dictionary;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -29,7 +27,28 @@ public class DictionaryController {
|
||||||
private DictionaryService dictionaryService;
|
private DictionaryService dictionaryService;
|
||||||
|
|
||||||
@GetMapping("/findDictionaryByStructureId")
|
@GetMapping("/findDictionaryByStructureId")
|
||||||
public Result<List<DictionaryType>> findDictionaryByStructureId(Integer id) {
|
public Result<List<DictionaryType>> findDictionaryByStructureId(@RequestParam Integer id) {
|
||||||
return dictionaryService.findDictionaryByStructureId(id);
|
return dictionaryService.findDictionaryByStructureId(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/addDictionaryType")
|
||||||
|
public Result addDictionaryType(@RequestBody DictionaryType dictionaryType) {
|
||||||
|
return dictionaryService.addDictionaryType(dictionaryType);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/addDictionaryData")
|
||||||
|
public Result addDictionaryData(@RequestBody DictionaryData dictionaryData) {
|
||||||
|
return dictionaryService.addDictionaryData(dictionaryData);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/deleteDictionaryData")
|
||||||
|
public Result deleteDictionaryData(@RequestParam Integer id) {
|
||||||
|
return dictionaryService.deleteDictionaryData(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/updateDictionaryData")
|
||||||
|
public Result updateDictionaryData(@RequestBody DictionaryData dictionaryData) {
|
||||||
|
return dictionaryService.updateDictionaryData(dictionaryData);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,4 +18,12 @@ public interface DictionaryMapper {
|
||||||
List<DictionaryType> selectDictionaryByStructureId(Integer id);
|
List<DictionaryType> selectDictionaryByStructureId(Integer id);
|
||||||
|
|
||||||
List<DictionaryData> selectDictionaryDataByType(@Param("dictionaryType") String dictionaryType);
|
List<DictionaryData> selectDictionaryDataByType(@Param("dictionaryType") String dictionaryType);
|
||||||
|
|
||||||
|
int addDictionaryType(DictionaryType dictionaryType);
|
||||||
|
|
||||||
|
int addDictionaryData(DictionaryData dictionaryData);
|
||||||
|
|
||||||
|
int deleteDictionaryData(@Param("id") Integer id);
|
||||||
|
|
||||||
|
int updateDictionaryData(DictionaryData dictionaryData);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,4 +14,12 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
public interface DictionaryService {
|
public interface DictionaryService {
|
||||||
Result<List<DictionaryType>> findDictionaryByStructureId(Integer id);
|
Result<List<DictionaryType>> findDictionaryByStructureId(Integer id);
|
||||||
|
|
||||||
|
Result addDictionaryType(DictionaryType dictionaryType);
|
||||||
|
|
||||||
|
Result addDictionaryData(DictionaryData dictionaryData);
|
||||||
|
|
||||||
|
Result deleteDictionaryData(Integer id);
|
||||||
|
|
||||||
|
Result updateDictionaryData(DictionaryData dictionaryData);
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,4 +47,24 @@ public class DictionaryServiceImpl implements DictionaryService {
|
||||||
}).toList();
|
}).toList();
|
||||||
return Result.success(list);
|
return Result.success(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result addDictionaryType(DictionaryType dictionaryType) {
|
||||||
|
return dictionaryMapper.addDictionaryType(dictionaryType) > 0 ? Result.success("上传成功") : Result.error("添加失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result addDictionaryData(DictionaryData dictionaryData) {
|
||||||
|
return dictionaryMapper.addDictionaryData(dictionaryData) > 0 ? Result.success("添加成功") : Result.error("添加失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result deleteDictionaryData(Integer id) {
|
||||||
|
return dictionaryMapper.deleteDictionaryData(id) > 0 ? Result.success("删除成功") : Result.error("删除失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result updateDictionaryData(DictionaryData dictionaryData) {
|
||||||
|
return dictionaryMapper.updateDictionaryData(dictionaryData) > 0 ? Result.success("修改成功") : Result.error("修改失败");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,23 @@
|
||||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.muyu.data.source.mapper.DictionaryMapper">
|
<mapper namespace="com.muyu.data.source.mapper.DictionaryMapper">
|
||||||
|
<insert id="addDictionaryType">
|
||||||
|
insert into dictionary_type(structure_id,dictionary_type,dictionary_name,create_time,update_time)
|
||||||
|
values(#{structureId},#{dictionaryType},#{dictionaryName},#{createTime},#{updateTime})
|
||||||
|
</insert>
|
||||||
|
<insert id="addDictionaryData">
|
||||||
|
insert into dictionary_data(dictionary_type,dictionary_label,dictionary_value)
|
||||||
|
values(#{dictionaryType},#{dictionaryLabel},#{dictionaryValue})
|
||||||
|
</insert>
|
||||||
|
<update id="updateDictionaryData">
|
||||||
|
update dictionary_data
|
||||||
|
set
|
||||||
|
dictionary_label = #{dictionaryLabel},
|
||||||
|
dictionary_value = #{dictionaryValue} where id = #{id}
|
||||||
|
</update>
|
||||||
|
<delete id="deleteDictionaryData">
|
||||||
|
delete from dictionary_data where id = #{id}
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
|
||||||
<select id="selectDictionaryByStructureId" resultType="com.muyu.data.source.domain.DictionaryType">
|
<select id="selectDictionaryByStructureId" resultType="com.muyu.data.source.domain.DictionaryType">
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
//
|
//
|
||||||
// // quartz参数
|
// // quartz参数
|
||||||
// Properties prop = new Properties();
|
// Properties prop = new Properties();
|
||||||
// prop.put("org.quartz.scheduler.instanceName", "RuoyiScheduler");
|
// prop.put("org.quartz.scheduler.instanceName", "muyuScheduler");
|
||||||
// prop.put("org.quartz.scheduler.instanceId", "AUTO");
|
// prop.put("org.quartz.scheduler.instanceId", "AUTO");
|
||||||
// // 线程池配置
|
// // 线程池配置
|
||||||
// prop.put("org.quartz.threadPool.class", "org.quartz.simpl.SimpleThreadPool");
|
// prop.put("org.quartz.threadPool.class", "org.quartz.simpl.SimpleThreadPool");
|
||||||
|
@ -42,7 +42,7 @@
|
||||||
// prop.put("org.quartz.jobStore.tablePrefix", "QRTZ_");
|
// prop.put("org.quartz.jobStore.tablePrefix", "QRTZ_");
|
||||||
// factory.setQuartzProperties(prop);
|
// factory.setQuartzProperties(prop);
|
||||||
//
|
//
|
||||||
// factory.setSchedulerName("RuoyiScheduler");
|
// factory.setSchedulerName("muyuScheduler");
|
||||||
// // 延时启动
|
// // 延时启动
|
||||||
// factory.setStartupDelay(1);
|
// factory.setStartupDelay(1);
|
||||||
// factory.setApplicationContextSchedulerContextKey("applicationContextKey");
|
// factory.setApplicationContextSchedulerContextKey("applicationContextKey");
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>com.muyu</groupId>
|
||||||
|
<artifactId>muyu-rule_engine</artifactId>
|
||||||
|
<version>3.6.3</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>muyu-rule_engine-common</artifactId>
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
|
<maven.compiler.target>17</maven.compiler.target>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
<dependencies>
|
||||||
|
<!-- MuYu Common Core-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.muyu</groupId>
|
||||||
|
<artifactId>muyu-common-core</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
|
@ -0,0 +1,97 @@
|
||||||
|
package com.muyu.ruleEngine.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
import io.swagger.annotations.*;
|
||||||
|
import com.muyu.common.core.annotation.Excel;
|
||||||
|
import com.muyu.ruleEngine.domain.req.EngineConfigQueryReq;
|
||||||
|
import com.muyu.ruleEngine.domain.req.EngineConfigSaveReq;
|
||||||
|
import com.muyu.ruleEngine.domain.req.EngineConfigEditReq;
|
||||||
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 引擎规则配置对象 engine_config
|
||||||
|
*
|
||||||
|
* @author DeKangLiu
|
||||||
|
* @date 2024-05-02
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@TableName("engine_config")
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ApiModel(value = "EngineConfig", description = "引擎规则配置")
|
||||||
|
public class EngineConfig extends BaseEntity {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** 编号 */
|
||||||
|
@TableId(value = "id",type = IdType.AUTO)
|
||||||
|
@ApiModelProperty(name = "编号", value = "编号")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/** 版本编码 */
|
||||||
|
@Excel(name = "版本编码")
|
||||||
|
@ApiModelProperty(name = "版本编码", value = "版本编码", required = true)
|
||||||
|
private String versionCode;
|
||||||
|
|
||||||
|
/** 规则内容 */
|
||||||
|
@Excel(name = "规则内容")
|
||||||
|
@ApiModelProperty(name = "规则内容", value = "规则内容", required = true)
|
||||||
|
private String ruleContent;
|
||||||
|
|
||||||
|
/** 引擎维护编号 */
|
||||||
|
@Excel(name = "引擎维护编号")
|
||||||
|
@ApiModelProperty(name = "引擎维护编号", value = "引擎维护编号", required = true)
|
||||||
|
private Long engineMaintenanceId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询构造器
|
||||||
|
*/
|
||||||
|
public static EngineConfig queryBuild( EngineConfigQueryReq engineConfigQueryReq){
|
||||||
|
return EngineConfig.builder()
|
||||||
|
.versionCode(engineConfigQueryReq.getVersionCode())
|
||||||
|
.ruleContent(engineConfigQueryReq.getRuleContent())
|
||||||
|
.engineMaintenanceId(engineConfigQueryReq.getEngineMaintenanceId())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加构造器
|
||||||
|
*/
|
||||||
|
public static EngineConfig saveBuild(EngineConfigSaveReq engineConfigSaveReq,Supplier<String> createBy){
|
||||||
|
return EngineConfig.builder()
|
||||||
|
.versionCode(engineConfigSaveReq.getVersionCode())
|
||||||
|
.ruleContent(engineConfigSaveReq.getRuleContent())
|
||||||
|
.engineMaintenanceId(engineConfigSaveReq.getEngineMaintenanceId())
|
||||||
|
.remark(engineConfigSaveReq.getRemark())
|
||||||
|
.createBy(createBy.get())
|
||||||
|
.createTime(new Date())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改构造器
|
||||||
|
*/
|
||||||
|
public static EngineConfig editBuild(Long id, EngineConfigEditReq engineConfigEditReq, Supplier<String> updateBy){
|
||||||
|
return EngineConfig.builder()
|
||||||
|
.id(id)
|
||||||
|
.versionCode(engineConfigEditReq.getVersionCode())
|
||||||
|
.ruleContent(engineConfigEditReq.getRuleContent())
|
||||||
|
.engineMaintenanceId(engineConfigEditReq.getEngineMaintenanceId())
|
||||||
|
.remark(engineConfigEditReq.getRemark())
|
||||||
|
.updateBy(updateBy.get())
|
||||||
|
.updateTime(new Date())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,119 @@
|
||||||
|
package com.muyu.ruleEngine.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
import io.swagger.annotations.*;
|
||||||
|
import com.muyu.common.core.annotation.Excel;
|
||||||
|
import com.muyu.ruleEngine.domain.req.EngineMaintenanceQueryReq;
|
||||||
|
import com.muyu.ruleEngine.domain.req.EngineMaintenanceSaveReq;
|
||||||
|
import com.muyu.ruleEngine.domain.req.EngineMaintenanceEditReq;
|
||||||
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 引擎维护对象 engine_maintenance
|
||||||
|
*
|
||||||
|
* @author DeKangLiu
|
||||||
|
* @date 2024-05-02
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@TableName("engine_maintenance")
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ApiModel(value = "EngineMaintenance", description = "引擎维护")
|
||||||
|
public class EngineMaintenance extends BaseEntity {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** 编号 */
|
||||||
|
@TableId(value = "id",type = IdType.AUTO)
|
||||||
|
@ApiModelProperty(name = "编号", value = "编号")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/** 名称 */
|
||||||
|
@Excel(name = "名称")
|
||||||
|
@ApiModelProperty(name = "名称", value = "名称")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/** 类型 */
|
||||||
|
@Excel(name = "类型")
|
||||||
|
@ApiModelProperty(name = "类型", value = "类型")
|
||||||
|
private Long type;
|
||||||
|
|
||||||
|
/** 作用域 */
|
||||||
|
@Excel(name = "作用域")
|
||||||
|
@ApiModelProperty(name = "作用域", value = "作用域")
|
||||||
|
private Integer scope;
|
||||||
|
|
||||||
|
/** 引擎编码 */
|
||||||
|
@Excel(name = "引擎编码")
|
||||||
|
@ApiModelProperty(name = "引擎编码", value = "引擎编码")
|
||||||
|
private String engineCode;
|
||||||
|
|
||||||
|
/** 是否激活 */
|
||||||
|
@Excel(name = "是否激活")
|
||||||
|
@ApiModelProperty(name = "是否激活", value = "是否激活")
|
||||||
|
private String isActivate;
|
||||||
|
|
||||||
|
/** 状态 */
|
||||||
|
@Excel(name = "状态")
|
||||||
|
@ApiModelProperty(name = "状态", value = "状态")
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询构造器
|
||||||
|
*/
|
||||||
|
public static EngineMaintenance queryBuild( EngineMaintenanceQueryReq engineMaintenanceQueryReq){
|
||||||
|
return EngineMaintenance.builder()
|
||||||
|
.name(engineMaintenanceQueryReq.getName())
|
||||||
|
.type(engineMaintenanceQueryReq.getType())
|
||||||
|
.scope(engineMaintenanceQueryReq.getScope())
|
||||||
|
.engineCode(engineMaintenanceQueryReq.getEngineCode())
|
||||||
|
.isActivate(engineMaintenanceQueryReq.getIsActivate())
|
||||||
|
.status(engineMaintenanceQueryReq.getStatus())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加构造器
|
||||||
|
*/
|
||||||
|
public static EngineMaintenance saveBuild(EngineMaintenanceSaveReq engineMaintenanceSaveReq,Supplier<String> createBy){
|
||||||
|
return EngineMaintenance.builder()
|
||||||
|
.name(engineMaintenanceSaveReq.getName())
|
||||||
|
.type(engineMaintenanceSaveReq.getType())
|
||||||
|
.scope(engineMaintenanceSaveReq.getScope())
|
||||||
|
.engineCode(engineMaintenanceSaveReq.getEngineCode())
|
||||||
|
.isActivate(engineMaintenanceSaveReq.getIsActivate())
|
||||||
|
.status(engineMaintenanceSaveReq.getStatus())
|
||||||
|
.createBy(createBy.get())
|
||||||
|
.createTime(new Date())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改构造器
|
||||||
|
*/
|
||||||
|
public static EngineMaintenance editBuild(Long id, EngineMaintenanceEditReq engineMaintenanceEditReq, Supplier<String> updateBy){
|
||||||
|
return EngineMaintenance.builder()
|
||||||
|
.id(id)
|
||||||
|
.name(engineMaintenanceEditReq.getName())
|
||||||
|
.type(engineMaintenanceEditReq.getType())
|
||||||
|
.scope(engineMaintenanceEditReq.getScope())
|
||||||
|
.engineCode(engineMaintenanceEditReq.getEngineCode())
|
||||||
|
.isActivate(engineMaintenanceEditReq.getIsActivate())
|
||||||
|
.status(engineMaintenanceEditReq.getStatus())
|
||||||
|
.updateBy(updateBy.get())
|
||||||
|
.updateTime(new Date())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
package com.muyu.ruleEngine.domain.model;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 测试数据
|
||||||
|
* @ClassName TestData
|
||||||
|
* @Author DeKangLiu
|
||||||
|
* @Date 2024/5/3 16:13
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class TestData {
|
||||||
|
/**
|
||||||
|
* 引擎配置编号
|
||||||
|
*/
|
||||||
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 测试数据集合
|
||||||
|
*/
|
||||||
|
private List<String> list;
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
package com.muyu.ruleEngine.domain.req;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
import io.swagger.annotations.*;
|
||||||
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 引擎规则配置对象 engine_config
|
||||||
|
*
|
||||||
|
* @author DeKangLiu
|
||||||
|
* @date 2024-05-02
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@ApiModel(value = "EngineConfigEditReq", description = "引擎规则配置")
|
||||||
|
public class EngineConfigEditReq extends BaseEntity {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** 版本编码 */
|
||||||
|
@ApiModelProperty(name = "版本编码", value = "版本编码", required = true)
|
||||||
|
private String versionCode;
|
||||||
|
|
||||||
|
/** 规则内容 */
|
||||||
|
@ApiModelProperty(name = "规则内容", value = "规则内容", required = true)
|
||||||
|
private String ruleContent;
|
||||||
|
|
||||||
|
/** 引擎维护编号 */
|
||||||
|
@ApiModelProperty(name = "引擎维护编号", value = "引擎维护编号", required = true)
|
||||||
|
private Long engineMaintenanceId;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
package com.muyu.ruleEngine.domain.req;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
import io.swagger.annotations.*;
|
||||||
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 引擎规则配置对象 engine_config
|
||||||
|
*
|
||||||
|
* @author DeKangLiu
|
||||||
|
* @date 2024-05-02
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@ApiModel(value = "EngineConfigQueryReq", description = "引擎规则配置")
|
||||||
|
public class EngineConfigQueryReq extends BaseEntity {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** 版本编码 */
|
||||||
|
@ApiModelProperty(name = "版本编码", value = "版本编码")
|
||||||
|
private String versionCode;
|
||||||
|
|
||||||
|
/** 规则内容 */
|
||||||
|
@ApiModelProperty(name = "规则内容", value = "规则内容")
|
||||||
|
private String ruleContent;
|
||||||
|
|
||||||
|
/** 引擎维护编号 */
|
||||||
|
@ApiModelProperty(name = "引擎维护编号", value = "引擎维护编号")
|
||||||
|
private Long engineMaintenanceId;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,46 @@
|
||||||
|
package com.muyu.ruleEngine.domain.req;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
import io.swagger.annotations.*;
|
||||||
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 引擎规则配置对象 engine_config
|
||||||
|
*
|
||||||
|
* @author DeKangLiu
|
||||||
|
* @date 2024-05-02
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@ApiModel(value = "EngineConfigSaveReq", description = "引擎规则配置")
|
||||||
|
public class EngineConfigSaveReq extends BaseEntity {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** 编号 */
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "编号", value = "编号")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/** 版本编码 */
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "版本编码", value = "版本编码", required = true)
|
||||||
|
private String versionCode;
|
||||||
|
|
||||||
|
/** 规则内容 */
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "规则内容", value = "规则内容", required = true)
|
||||||
|
private String ruleContent;
|
||||||
|
|
||||||
|
/** 引擎维护编号 */
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "引擎维护编号", value = "引擎维护编号", required = true)
|
||||||
|
private Long engineMaintenanceId;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,49 @@
|
||||||
|
package com.muyu.ruleEngine.domain.req;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
import io.swagger.annotations.*;
|
||||||
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 引擎维护对象 engine_maintenance
|
||||||
|
*
|
||||||
|
* @author DeKangLiu
|
||||||
|
* @date 2024-05-02
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@ApiModel(value = "EngineMaintenanceEditReq", description = "引擎维护")
|
||||||
|
public class EngineMaintenanceEditReq extends BaseEntity {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** 名称 */
|
||||||
|
@ApiModelProperty(name = "名称", value = "名称")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/** 类型 */
|
||||||
|
@ApiModelProperty(name = "类型", value = "类型")
|
||||||
|
private Long type;
|
||||||
|
|
||||||
|
/** 作用域 */
|
||||||
|
@ApiModelProperty(name = "作用域", value = "作用域")
|
||||||
|
private Integer scope;
|
||||||
|
|
||||||
|
/** 引擎编码 */
|
||||||
|
@ApiModelProperty(name = "引擎编码", value = "引擎编码")
|
||||||
|
private String engineCode;
|
||||||
|
|
||||||
|
/** 是否激活 */
|
||||||
|
@ApiModelProperty(name = "是否激活", value = "是否激活")
|
||||||
|
private String isActivate;
|
||||||
|
|
||||||
|
/** 状态 */
|
||||||
|
@ApiModelProperty(name = "状态", value = "状态")
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,49 @@
|
||||||
|
package com.muyu.ruleEngine.domain.req;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
import io.swagger.annotations.*;
|
||||||
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 引擎维护对象 engine_maintenance
|
||||||
|
*
|
||||||
|
* @author DeKangLiu
|
||||||
|
* @date 2024-05-02
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@ApiModel(value = "EngineMaintenanceQueryReq", description = "引擎维护")
|
||||||
|
public class EngineMaintenanceQueryReq extends BaseEntity {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** 名称 */
|
||||||
|
@ApiModelProperty(name = "名称", value = "名称")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/** 类型 */
|
||||||
|
@ApiModelProperty(name = "类型", value = "类型")
|
||||||
|
private Long type;
|
||||||
|
|
||||||
|
/** 作用域 */
|
||||||
|
@ApiModelProperty(name = "作用域", value = "作用域")
|
||||||
|
private Integer scope;
|
||||||
|
|
||||||
|
/** 引擎编码 */
|
||||||
|
@ApiModelProperty(name = "引擎编码", value = "引擎编码")
|
||||||
|
private String engineCode;
|
||||||
|
|
||||||
|
/** 是否激活 */
|
||||||
|
@ApiModelProperty(name = "是否激活", value = "是否激活")
|
||||||
|
private String isActivate;
|
||||||
|
|
||||||
|
/** 状态 */
|
||||||
|
@ApiModelProperty(name = "状态", value = "状态")
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,60 @@
|
||||||
|
package com.muyu.ruleEngine.domain.req;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
import io.swagger.annotations.*;
|
||||||
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 引擎维护对象 engine_maintenance
|
||||||
|
*
|
||||||
|
* @author DeKangLiu
|
||||||
|
* @date 2024-05-02
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@ApiModel(value = "EngineMaintenanceSaveReq", description = "引擎维护")
|
||||||
|
public class EngineMaintenanceSaveReq extends BaseEntity {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** 编号 */
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "编号", value = "编号")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/** 名称 */
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "名称", value = "名称")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/** 类型 */
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "类型", value = "类型")
|
||||||
|
private Long type;
|
||||||
|
|
||||||
|
/** 作用域 */
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "作用域", value = "作用域")
|
||||||
|
private Integer scope;
|
||||||
|
|
||||||
|
/** 引擎编码 */
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "引擎编码", value = "引擎编码")
|
||||||
|
private String engineCode;
|
||||||
|
|
||||||
|
/** 是否激活 */
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "是否激活", value = "是否激活")
|
||||||
|
private String isActivate;
|
||||||
|
|
||||||
|
/** 状态 */
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "状态", value = "状态")
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
package com.muyu.ruleEngine.domain.resp;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 规则引擎作用域
|
||||||
|
* @ClassName RuleEngineScopeResp
|
||||||
|
* @Author DeKangLiu
|
||||||
|
* @Date 2024/5/2 15:05
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
public class EngineConfigScopeResp implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** 类型 */
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
/** 名称 */
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/** 代码 */
|
||||||
|
private String code;
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>com.muyu</groupId>
|
||||||
|
<artifactId>muyu-rule_engine</artifactId>
|
||||||
|
<version>3.6.3</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>muyu-rule_engine-remote</artifactId>
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
|
<maven.compiler.target>17</maven.compiler.target>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
</project>
|
|
@ -0,0 +1,124 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>com.muyu</groupId>
|
||||||
|
<artifactId>muyu-rule_engine</artifactId>
|
||||||
|
<version>3.6.3</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>muyu-rule_engine-server</artifactId>
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
|
<maven.compiler.target>17</maven.compiler.target>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
<dependencies>
|
||||||
|
<!-- muyu-rule_engine-common 规则引擎公共模块 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.muyu</groupId>
|
||||||
|
<artifactId>muyu-rule_engine-common</artifactId>
|
||||||
|
<version>3.6.3</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- SpringCloud Alibaba Nacos -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<!-- SpringCloud Alibaba Nacos Config -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- SpringCloud Alibaba Sentinel -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- SpringBoot Actuator -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Swagger UI -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.springfox</groupId>
|
||||||
|
<artifactId>springfox-swagger-ui</artifactId>
|
||||||
|
<version>${swagger.fox.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Mysql Connector -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.mysql</groupId>
|
||||||
|
<artifactId>mysql-connector-j</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- MuYu Common DataSource -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.muyu</groupId>
|
||||||
|
<artifactId>muyu-common-datasource</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- MuYu Common DataScope -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.muyu</groupId>
|
||||||
|
<artifactId>muyu-common-datascope</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- MuYu Common Log -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.muyu</groupId>
|
||||||
|
<artifactId>muyu-common-log</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- MuYu Common Swagger -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.muyu</groupId>
|
||||||
|
<artifactId>muyu-common-swagger</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Sql Server 驱动 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.microsoft.sqlserver</groupId>
|
||||||
|
<artifactId>mssql-jdbc</artifactId>
|
||||||
|
<version>9.4.0.jre8</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<finalName>${project.artifactId}</finalName>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>repackage</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<!-- 加入maven deploy插件,当在deploy时,忽略些model-->
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-deploy-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<skip>true</skip>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<mainClass>com.muyu.ruleEngine.DeKangLiuRuleEngineApplication</mainClass>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
|
@ -0,0 +1,23 @@
|
||||||
|
package com.muyu.ruleEngine;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* rule_engine服务模块
|
||||||
|
*
|
||||||
|
* @author DeKangLiu
|
||||||
|
*/
|
||||||
|
@EnableCustomConfig
|
||||||
|
@EnableCustomSwagger2
|
||||||
|
@EnableMyFeignClients
|
||||||
|
@SpringBootApplication
|
||||||
|
public class MuYuRuleEngineApplication {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
|
||||||
|
SpringApplication.run(MuYuRuleEngineApplication.class,args);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,111 @@
|
||||||
|
package com.muyu.ruleEngine.controller;
|
||||||
|
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
|
import com.muyu.common.core.web.controller.BaseController;
|
||||||
|
import com.muyu.common.log.annotation.Log;
|
||||||
|
import com.muyu.common.log.enums.BusinessType;
|
||||||
|
import com.muyu.common.security.annotation.RequiresPermissions;
|
||||||
|
import com.muyu.common.security.utils.SecurityUtils;
|
||||||
|
import com.muyu.ruleEngine.domain.EngineConfig;
|
||||||
|
import com.muyu.ruleEngine.domain.model.TestData;
|
||||||
|
import com.muyu.ruleEngine.domain.req.EngineConfigEditReq;
|
||||||
|
import com.muyu.ruleEngine.domain.req.EngineConfigQueryReq;
|
||||||
|
import com.muyu.ruleEngine.domain.req.EngineConfigSaveReq;
|
||||||
|
import com.muyu.ruleEngine.domain.resp.EngineConfigScopeResp;
|
||||||
|
import com.muyu.ruleEngine.service.EngineConfigService;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 引擎配置Controller
|
||||||
|
*
|
||||||
|
* @author DeKangLiu
|
||||||
|
* @date 2024-05-02
|
||||||
|
*/
|
||||||
|
@Api(tags = "引擎配置")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/config")
|
||||||
|
public class EngineConfigController extends BaseController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private EngineConfigService engineConfigService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取引擎配置作用域列表
|
||||||
|
*/
|
||||||
|
@ApiOperation("获取引擎配置作用域列表")
|
||||||
|
@RequiresPermissions("rule_engine:config:list")
|
||||||
|
@GetMapping("/getScopeList")
|
||||||
|
public Result<List<EngineConfigScopeResp>> getScopeList() {
|
||||||
|
return Result.success(engineConfigService.getScopeList());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过引擎作用域编号获取引擎配置作用域信息
|
||||||
|
*/
|
||||||
|
@ApiOperation("通过引擎作用域编号获取引擎配置作用域信息")
|
||||||
|
@RequiresPermissions("rule_engine:config:list")
|
||||||
|
@GetMapping("/getScopeInfo/{id}")
|
||||||
|
public Result<EngineConfigScopeResp> getScopeInfoById(@PathVariable Integer id) {
|
||||||
|
return Result.success(engineConfigService.getScopeInfoById(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询引擎规则配置列表
|
||||||
|
*/
|
||||||
|
@ApiOperation("获取引擎规则配置列表")
|
||||||
|
@RequiresPermissions("ruleEngine:config:list")
|
||||||
|
@GetMapping("/list")
|
||||||
|
public Result<List<EngineConfig>> list(EngineConfigQueryReq engineConfigQueryReq) {
|
||||||
|
return Result.success(engineConfigService.list(EngineConfig.queryBuild(engineConfigQueryReq)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 测试引擎规则配置
|
||||||
|
*/
|
||||||
|
@ApiOperation("测试引擎规则配置")
|
||||||
|
@RequiresPermissions("ruleEngine:config:add")
|
||||||
|
@PostMapping(value = "/test")
|
||||||
|
public Result<Object> ruleTest(@RequestBody TestData testData) {
|
||||||
|
return Result.success(engineConfigService.ruleTest(testData));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增引擎规则配置
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("ruleEngine:config:add")
|
||||||
|
@Log(title = "引擎规则配置", businessType = BusinessType.INSERT)
|
||||||
|
@PostMapping
|
||||||
|
@ApiOperation("新增引擎规则配置")
|
||||||
|
public Result<String> add(@RequestBody EngineConfigSaveReq engineConfigSaveReq) {
|
||||||
|
return toAjax(engineConfigService.save(EngineConfig.saveBuild(engineConfigSaveReq, SecurityUtils::getUsername)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改引擎规则配置
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("ruleEngine:config:edit")
|
||||||
|
@Log(title = "引擎规则配置", businessType = BusinessType.UPDATE)
|
||||||
|
@PutMapping("/{id}")
|
||||||
|
@ApiOperation("修改引擎规则配置")
|
||||||
|
public Result<String> edit(@PathVariable Long id, @RequestBody EngineConfigEditReq engineConfigEditReq) {
|
||||||
|
return toAjax(engineConfigService.updateById(EngineConfig.editBuild(id,engineConfigEditReq, SecurityUtils::getUsername)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除引擎规则配置
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("ruleEngine:config:remove")
|
||||||
|
@Log(title = "引擎规则配置", businessType = BusinessType.DELETE)
|
||||||
|
@DeleteMapping("/{ids}")
|
||||||
|
@ApiOperation("删除引擎规则配置")
|
||||||
|
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = String.class, example = "1,2,3,4")
|
||||||
|
public Result<String> remove(@PathVariable List<Long> ids) {
|
||||||
|
return toAjax(engineConfigService.removeBatchByIds(ids));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,112 @@
|
||||||
|
package com.muyu.ruleEngine.controller;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import com.muyu.common.core.utils.poi.ExcelUtil;
|
||||||
|
import com.muyu.common.core.web.page.TableDataInfo;
|
||||||
|
import com.muyu.common.security.utils.SecurityUtils;
|
||||||
|
import com.muyu.ruleEngine.service.EngineMaintenanceService;
|
||||||
|
import io.swagger.annotations.*;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
|
import com.muyu.common.core.web.controller.BaseController;
|
||||||
|
import com.muyu.common.log.annotation.Log;
|
||||||
|
import com.muyu.common.log.enums.BusinessType;
|
||||||
|
import com.muyu.common.security.annotation.RequiresPermissions;
|
||||||
|
import com.muyu.ruleEngine.domain.EngineMaintenance;
|
||||||
|
import com.muyu.ruleEngine.domain.req.EngineMaintenanceQueryReq;
|
||||||
|
import com.muyu.ruleEngine.domain.req.EngineMaintenanceSaveReq;
|
||||||
|
import com.muyu.ruleEngine.domain.req.EngineMaintenanceEditReq;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 引擎维护Controller
|
||||||
|
*
|
||||||
|
* @author DeKangLiu
|
||||||
|
* @date 2024-05-02
|
||||||
|
*/
|
||||||
|
@Api(tags = "引擎维护")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/maintenance")
|
||||||
|
public class EngineMaintenanceController extends BaseController {
|
||||||
|
@Autowired
|
||||||
|
private EngineMaintenanceService engineMaintenanceService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询引擎维护列表
|
||||||
|
*/
|
||||||
|
@ApiOperation("获取引擎维护列表")
|
||||||
|
@RequiresPermissions("rule_engine:maintenance:list")
|
||||||
|
@GetMapping("/list")
|
||||||
|
public Result<TableDataInfo<EngineMaintenance>> list(EngineMaintenanceQueryReq engineMaintenanceQueryReq) {
|
||||||
|
startPage();
|
||||||
|
List<EngineMaintenance> list = engineMaintenanceService.list(EngineMaintenance.queryBuild(engineMaintenanceQueryReq));
|
||||||
|
return getDataTable(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出引擎维护列表
|
||||||
|
*/
|
||||||
|
@ApiOperation("导出引擎维护列表")
|
||||||
|
@RequiresPermissions("rule_engine:maintenance:export")
|
||||||
|
@Log(title = "引擎维护", businessType = BusinessType.EXPORT)
|
||||||
|
@PostMapping("/export")
|
||||||
|
public void export(HttpServletResponse response, EngineMaintenance engineMaintenance) {
|
||||||
|
List<EngineMaintenance> list = engineMaintenanceService.list(engineMaintenance);
|
||||||
|
ExcelUtil<EngineMaintenance> util = new ExcelUtil<EngineMaintenance>(EngineMaintenance.class);
|
||||||
|
util.exportExcel(response, list, "引擎维护数据");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取引擎维护详细信息
|
||||||
|
*/
|
||||||
|
@ApiOperation("获取引擎维护详细信息")
|
||||||
|
@RequiresPermissions("rule_engine:maintenance:query")
|
||||||
|
@GetMapping(value = "/{id}")
|
||||||
|
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class)
|
||||||
|
public Result<EngineMaintenance> getInfo(@PathVariable("id") Long id) {
|
||||||
|
return Result.success(engineMaintenanceService.getById(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增引擎维护
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("rule_engine:maintenance:add")
|
||||||
|
@Log(title = "引擎维护", businessType = BusinessType.INSERT)
|
||||||
|
@PostMapping
|
||||||
|
@ApiOperation("新增引擎维护")
|
||||||
|
public Result<String> add(@RequestBody EngineMaintenanceSaveReq engineMaintenanceSaveReq) {
|
||||||
|
return toAjax(engineMaintenanceService.saveEngineMaintenance(EngineMaintenance.saveBuild(engineMaintenanceSaveReq, SecurityUtils::getUsername)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改引擎维护
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("rule_engine:maintenance:edit")
|
||||||
|
@Log(title = "引擎维护", businessType = BusinessType.UPDATE)
|
||||||
|
@PutMapping("/{id}")
|
||||||
|
@ApiOperation("修改引擎维护")
|
||||||
|
public Result<String> edit(@PathVariable Long id, @RequestBody EngineMaintenanceEditReq engineMaintenanceEditReq) {
|
||||||
|
return toAjax(engineMaintenanceService.updateById(EngineMaintenance.editBuild(id,engineMaintenanceEditReq, SecurityUtils::getUsername)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除引擎维护
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("rule_engine:maintenance:remove")
|
||||||
|
@Log(title = "引擎维护", businessType = BusinessType.DELETE)
|
||||||
|
@DeleteMapping("/{ids}")
|
||||||
|
@ApiOperation("删除引擎维护")
|
||||||
|
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = String.class, example = "1,2,3,4")
|
||||||
|
public Result<String> remove(@PathVariable List<Long> ids) {
|
||||||
|
return toAjax(engineMaintenanceService.removeBatchEngineMaintenanceByIds(ids));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,78 @@
|
||||||
|
package com.muyu.ruleEngine.dynamicLoad;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.URLClassLoader;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import javax.tools.JavaCompiler;
|
||||||
|
import javax.tools.JavaFileObject;
|
||||||
|
import javax.tools.StandardJavaFileManager;
|
||||||
|
import javax.tools.ToolProvider;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName DynamicLoader
|
||||||
|
* @Author DeKangLiu
|
||||||
|
* @Date 2024/5/1 20:37
|
||||||
|
*/
|
||||||
|
public class DynamicLoader {
|
||||||
|
/**
|
||||||
|
* 通过类名和其代码(Java代码字符串),编译得到字节码,返回类名及其对应类的字节码,封装于Map中,值得注意的是,
|
||||||
|
* 平常类中就编译出来的字节码只有一个类,但是考虑到内部类的情况, 会出现很多个类名及其字节码,所以用Map封装方便。
|
||||||
|
*
|
||||||
|
* @param javaName 类名
|
||||||
|
* @param javaSrc Java源码
|
||||||
|
* @return map
|
||||||
|
*/
|
||||||
|
public static Map<String, byte[]> compile(String javaName, String javaSrc) {
|
||||||
|
// 调用java编译器接口
|
||||||
|
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
|
||||||
|
StandardJavaFileManager stdManager = compiler
|
||||||
|
.getStandardFileManager(null, null, null);
|
||||||
|
|
||||||
|
try (MemoryJavaFileManager manager = new MemoryJavaFileManager(
|
||||||
|
stdManager)) {
|
||||||
|
|
||||||
|
@SuppressWarnings("static-access")
|
||||||
|
JavaFileObject javaFileObject = manager.makeStringSource(javaName,
|
||||||
|
javaSrc);
|
||||||
|
JavaCompiler.CompilationTask task = compiler.getTask(null, manager,
|
||||||
|
null, null, null, Arrays.asList(javaFileObject));
|
||||||
|
if (task.call()) {
|
||||||
|
return manager.getClassBytes();
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 先根据类名在内存中查找是否已存在该类,若不存在则调用 URLClassLoader的 defineClass方法加载该类
|
||||||
|
* URLClassLoader的具体作用就是将class文件加载到jvm虚拟机中去
|
||||||
|
*
|
||||||
|
* @author Administrator
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public static class MemoryClassLoader extends URLClassLoader {
|
||||||
|
Map<String, byte[]> classBytes = new HashMap<String, byte[]>();
|
||||||
|
|
||||||
|
public MemoryClassLoader(Map<String, byte[]> classBytes) {
|
||||||
|
super(new URL[0], MemoryClassLoader.class.getClassLoader());
|
||||||
|
this.classBytes.putAll(classBytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Class<?> findClass(String name)
|
||||||
|
throws ClassNotFoundException {
|
||||||
|
byte[] buf = classBytes.get(name);
|
||||||
|
if (buf == null) {
|
||||||
|
return super.findClass(name);
|
||||||
|
}
|
||||||
|
classBytes.remove(name);
|
||||||
|
return defineClass(name, buf, 0, buf.length);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,143 @@
|
||||||
|
package com.muyu.ruleEngine.dynamicLoad;
|
||||||
|
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FilterOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.io.Reader;
|
||||||
|
import java.io.StringReader;
|
||||||
|
import java.net.URI;
|
||||||
|
import java.nio.CharBuffer;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import javax.tools.FileObject;
|
||||||
|
import javax.tools.ForwardingJavaFileManager;
|
||||||
|
import javax.tools.JavaFileManager;
|
||||||
|
import javax.tools.JavaFileObject;
|
||||||
|
import javax.tools.SimpleJavaFileObject;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName MemoryJavaFileManager
|
||||||
|
* @Author DeKangLiu
|
||||||
|
* @Date 2024/5/1 20:38
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
public final class MemoryJavaFileManager extends ForwardingJavaFileManager {
|
||||||
|
|
||||||
|
private final static String EXT = ".java";// Java源文件的扩展名
|
||||||
|
private Map<String, byte[]> classBytes;// 用于存放.class文件的内存
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public MemoryJavaFileManager(JavaFileManager fileManager) {
|
||||||
|
super(fileManager);
|
||||||
|
classBytes = new HashMap<String, byte[]>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, byte[]> getClassBytes() {
|
||||||
|
return classBytes;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close() throws IOException {
|
||||||
|
classBytes = new HashMap<String, byte[]>();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void flush() throws IOException {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 一个文件对象,用来表示从string中获取到的source,一下类容是按照jkd给出的例子写的
|
||||||
|
*/
|
||||||
|
private static class StringInputBuffer extends SimpleJavaFileObject {
|
||||||
|
// The source code of this "file".
|
||||||
|
final String code;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a new JavaSourceFromString.
|
||||||
|
*
|
||||||
|
* @param name 此文件对象表示的编译单元的name
|
||||||
|
* @param code 此文件对象表示的编译单元source的code
|
||||||
|
*/
|
||||||
|
StringInputBuffer(String name, String code) {
|
||||||
|
super(toURI(name), Kind.SOURCE);
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CharBuffer getCharContent(boolean ignoreEncodingErrors) {
|
||||||
|
return CharBuffer.wrap(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
public Reader openReader() {
|
||||||
|
return new StringReader(code);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将Java字节码存储到classBytes映射中的文件对象
|
||||||
|
*/
|
||||||
|
private class ClassOutputBuffer extends SimpleJavaFileObject {
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param name className
|
||||||
|
*/
|
||||||
|
ClassOutputBuffer(String name) {
|
||||||
|
super(toURI(name), Kind.CLASS);
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OutputStream openOutputStream() {
|
||||||
|
return new FilterOutputStream(new ByteArrayOutputStream()) {
|
||||||
|
@Override
|
||||||
|
public void close() throws IOException {
|
||||||
|
out.close();
|
||||||
|
ByteArrayOutputStream bos = (ByteArrayOutputStream) out;
|
||||||
|
|
||||||
|
// 这里需要修改
|
||||||
|
classBytes.put(name, bos.toByteArray());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JavaFileObject getJavaFileForOutput(
|
||||||
|
JavaFileManager.Location location, String className,
|
||||||
|
JavaFileObject.Kind kind, FileObject sibling) throws IOException {
|
||||||
|
if (kind == JavaFileObject.Kind.CLASS) {
|
||||||
|
return new ClassOutputBuffer(className);
|
||||||
|
} else {
|
||||||
|
return super.getJavaFileForOutput(location, className, kind,
|
||||||
|
sibling);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static JavaFileObject makeStringSource(String name, String code) {
|
||||||
|
return new StringInputBuffer(name, code);
|
||||||
|
}
|
||||||
|
|
||||||
|
static URI toURI(String name) {
|
||||||
|
File file = new File(name);
|
||||||
|
if (file.exists()) {// 如果文件存在,返回他的URI
|
||||||
|
return file.toURI();
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
final StringBuilder newUri = new StringBuilder();
|
||||||
|
newUri.append("mfm:///");
|
||||||
|
newUri.append(name.replace('.', '/'));
|
||||||
|
if (name.endsWith(EXT)) {
|
||||||
|
newUri.replace(newUri.length() - EXT.length(),
|
||||||
|
newUri.length(), EXT);
|
||||||
|
}
|
||||||
|
return URI.create(newUri.toString());
|
||||||
|
} catch (Exception exp) {
|
||||||
|
return URI.create("mfm:///com/sun/script/java/java_source");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package com.muyu.ruleEngine.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.muyu.ruleEngine.domain.EngineConfig;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 引擎规则配置Mapper接口
|
||||||
|
*
|
||||||
|
* @author DeKangLiu
|
||||||
|
* @date 2024-05-02
|
||||||
|
*/
|
||||||
|
public interface EngineConfigMapper extends BaseMapper<EngineConfig> {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package com.muyu.ruleEngine.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.muyu.ruleEngine.domain.EngineMaintenance;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 引擎维护Mapper接口
|
||||||
|
*
|
||||||
|
* @author DeKangLiu
|
||||||
|
* @date 2024-05-02
|
||||||
|
*/
|
||||||
|
public interface EngineMaintenanceMapper extends BaseMapper<EngineMaintenance> {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
package com.muyu.ruleEngine.scope;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据模型上下文
|
||||||
|
* @ClassName DataModelContextHolder
|
||||||
|
* @Author DeKangLiu
|
||||||
|
* @Version: 1.0
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class DataModelContextHolder {
|
||||||
|
|
||||||
|
private final RecordContextHolder recordContextHolder;
|
||||||
|
|
||||||
|
public static DataModelContextHolder build(RecordContextHolder recordContextHolder){
|
||||||
|
return new DataModelContextHolder(recordContextHolder);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
package com.muyu.ruleEngine.scope;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据集上下文
|
||||||
|
* @ClassName DataSetContextHolder
|
||||||
|
* @Author DeKangLiu
|
||||||
|
* @Version: 1.0
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class DataSetContextHolder {
|
||||||
|
|
||||||
|
private final TaskContextHolder taskContextHolder;
|
||||||
|
|
||||||
|
public static DataSetContextHolder build(TaskContextHolder taskContextHolder){
|
||||||
|
return new DataSetContextHolder(taskContextHolder);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
package com.muyu.ruleEngine.scope;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 记录上下文
|
||||||
|
* @ClassName RecordContextHolder
|
||||||
|
* @Author DeKangLiu
|
||||||
|
* @Version: 1.0
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class RecordContextHolder {
|
||||||
|
|
||||||
|
private final DataSetContextHolder dataSetContextHolder;
|
||||||
|
|
||||||
|
public static RecordContextHolder build(DataSetContextHolder dataSetContextHolder){
|
||||||
|
return new RecordContextHolder(dataSetContextHolder);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package com.muyu.ruleEngine.scope;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 任务上下文
|
||||||
|
* @ClassName TaskContextHolder
|
||||||
|
* @Author DeKangLiu
|
||||||
|
* @Version: 1.0
|
||||||
|
*/
|
||||||
|
public class TaskContextHolder {
|
||||||
|
|
||||||
|
public static TaskContextHolder build(){
|
||||||
|
return new TaskContextHolder();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author DeKangLiu
|
||||||
|
*/
|
||||||
|
public class TestClass {
|
||||||
|
public String ruleTest(List<String> list) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,43 @@
|
||||||
|
package com.muyu.ruleEngine.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.muyu.ruleEngine.domain.EngineConfig;
|
||||||
|
import com.muyu.ruleEngine.domain.model.TestData;
|
||||||
|
import com.muyu.ruleEngine.domain.resp.EngineConfigScopeResp;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 引擎配置Service接口
|
||||||
|
*
|
||||||
|
* @author DeKangLiu
|
||||||
|
* @date 2024-05-02
|
||||||
|
*/
|
||||||
|
public interface EngineConfigService extends IService<EngineConfig> {
|
||||||
|
/**
|
||||||
|
* 查询引擎配置作用域列表
|
||||||
|
*
|
||||||
|
* @return 引擎规则作用域集合
|
||||||
|
*/
|
||||||
|
public List<EngineConfigScopeResp> getScopeList();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询引擎规则配置列表
|
||||||
|
*
|
||||||
|
* @param engineConfig 引擎规则配置
|
||||||
|
* @return 引擎规则配置集合
|
||||||
|
*/
|
||||||
|
public List<EngineConfig> list(EngineConfig engineConfig);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过引擎作用域编号获取引擎配置作用域信息
|
||||||
|
* @param id 引擎作用域编号
|
||||||
|
* @return 引擎配置作用域信息
|
||||||
|
*/
|
||||||
|
EngineConfigScopeResp getScopeInfoById(Integer id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 规则测试
|
||||||
|
* @param testData 规则配置版本编号
|
||||||
|
*/
|
||||||
|
Object ruleTest(TestData testData);
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
package com.muyu.ruleEngine.service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import com.muyu.ruleEngine.domain.EngineMaintenance;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 引擎维护Service接口
|
||||||
|
*
|
||||||
|
* @author DeKangLiu
|
||||||
|
* @date 2024-05-02
|
||||||
|
*/
|
||||||
|
public interface EngineMaintenanceService extends IService<EngineMaintenance> {
|
||||||
|
/**
|
||||||
|
* 查询引擎维护列表
|
||||||
|
*
|
||||||
|
* @param engineMaintenance 引擎维护
|
||||||
|
* @return 引擎维护集合
|
||||||
|
*/
|
||||||
|
public List<EngineMaintenance> list(EngineMaintenance engineMaintenance);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增引擎维护
|
||||||
|
* @param engineMaintenance 引擎维护对象
|
||||||
|
* @return 是否
|
||||||
|
*/
|
||||||
|
boolean saveEngineMaintenance(EngineMaintenance engineMaintenance);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除引擎维护
|
||||||
|
* @param ids 引擎维护编号集合
|
||||||
|
* @return 是否
|
||||||
|
*/
|
||||||
|
boolean removeBatchEngineMaintenanceByIds(List<Long> ids);
|
||||||
|
}
|
|
@ -0,0 +1,161 @@
|
||||||
|
package com.muyu.ruleEngine.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.muyu.common.core.exception.ServiceException;
|
||||||
|
import com.muyu.common.core.utils.ObjUtils;
|
||||||
|
import com.muyu.ruleEngine.domain.EngineConfig;
|
||||||
|
import com.muyu.ruleEngine.domain.model.TestData;
|
||||||
|
import com.muyu.ruleEngine.domain.resp.EngineConfigScopeResp;
|
||||||
|
import com.muyu.ruleEngine.dynamicLoad.DynamicLoader;
|
||||||
|
import com.muyu.ruleEngine.mapper.EngineConfigMapper;
|
||||||
|
import com.muyu.ruleEngine.service.EngineConfigService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 引擎配置Service业务层处理
|
||||||
|
*
|
||||||
|
* @author DeKangLiu
|
||||||
|
* @date 2024-05-02
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
public class EngineConfigServiceImpl extends ServiceImpl<EngineConfigMapper, EngineConfig> implements EngineConfigService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询引擎配置作用域列表
|
||||||
|
*
|
||||||
|
* @return 引擎规则作用域集合
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<EngineConfigScopeResp> getScopeList() {
|
||||||
|
List<EngineConfigScopeResp> list=new ArrayList<>();
|
||||||
|
List<String> scopeName=List.of("TaskContextHolder","DataSetContextHolder","RecordContextHolder","DataModelContextHolder");
|
||||||
|
try {
|
||||||
|
for (String scope : scopeName) {
|
||||||
|
String path="D:\\work\\2108A(3)\\cloud-server\\muyu-modules\\muyu-rule_engine\\muyu-rule_engine-server\\src\\main\\java\\com\\muyu\\ruleEngine\\scope\\"+scope+".java";
|
||||||
|
String code = Files.readString(Paths.get(path));
|
||||||
|
String type=null;
|
||||||
|
if(scope.contains("Task")){
|
||||||
|
type="任务";
|
||||||
|
}else if(scope.contains("DataSet")){
|
||||||
|
type="数据集";
|
||||||
|
}else if(scope.contains("Record")){
|
||||||
|
type="资产记录";
|
||||||
|
}else{
|
||||||
|
type="资产模型";
|
||||||
|
}
|
||||||
|
list.add(EngineConfigScopeResp.builder().type(type).name(scope).code(code).build());
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询引擎规则配置列表
|
||||||
|
*
|
||||||
|
* @param engineConfig 引擎规则配置
|
||||||
|
* @return 引擎规则配置
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<EngineConfig> list(EngineConfig engineConfig) {
|
||||||
|
LambdaQueryWrapper<EngineConfig> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
|
||||||
|
|
||||||
|
if (ObjUtils.notNull(engineConfig.getVersionCode())){
|
||||||
|
queryWrapper.eq(EngineConfig::getVersionCode, engineConfig.getVersionCode());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ObjUtils.notNull(engineConfig.getRuleContent())){
|
||||||
|
queryWrapper.eq(EngineConfig::getRuleContent, engineConfig.getRuleContent());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ObjUtils.notNull(engineConfig.getEngineMaintenanceId())){
|
||||||
|
queryWrapper.eq(EngineConfig::getEngineMaintenanceId, engineConfig.getEngineMaintenanceId());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return list(queryWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过引擎作用域编号获取引擎配置作用域信息
|
||||||
|
* @param id 引擎作用域编号
|
||||||
|
* @return 引擎配置作用域信息
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public EngineConfigScopeResp getScopeInfoById(Integer id) {
|
||||||
|
String scope=null;
|
||||||
|
String type=null;
|
||||||
|
if(id==0){
|
||||||
|
type="测试模版";
|
||||||
|
scope="TestClass.txt";
|
||||||
|
}else if(id==1){
|
||||||
|
type="任务";
|
||||||
|
scope="TaskContextHolder.java";
|
||||||
|
}else if(id==2){
|
||||||
|
type="数据集";
|
||||||
|
scope="DataSetContextHolder.java";
|
||||||
|
}else if(id==3){
|
||||||
|
type="资产记录";
|
||||||
|
scope="RecordContextHolder.java";
|
||||||
|
}else{
|
||||||
|
type="资产模型";
|
||||||
|
scope="DataModelContextHolder.java";
|
||||||
|
}
|
||||||
|
String path="D:\\work\\2108A(3)\\cloud-server\\muyu-modules\\muyu-rule_engine\\muyu-rule_engine-server\\src\\main\\java\\com\\muyu\\ruleEngine\\scope\\"+scope;
|
||||||
|
String code = null;
|
||||||
|
try {
|
||||||
|
code = Files.readString(Paths.get(path));
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
return EngineConfigScopeResp.builder().type(type).name(scope).code(code).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 规则测试
|
||||||
|
* @param testData 规则配置版本编号
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Object ruleTest(TestData testData) {
|
||||||
|
Object invoke=null;
|
||||||
|
try {
|
||||||
|
String className="TestClass";
|
||||||
|
final String SUFFIX = ".java";// 类名后面要跟的后缀
|
||||||
|
EngineConfig config = this.getById(testData.getId());
|
||||||
|
String content = config.getRuleContent().replaceAll("\r\n", "");
|
||||||
|
// 对source进行编译生成class文件存放在Map中,这里用bytecode接收
|
||||||
|
Map<String, byte[]> bytecode = DynamicLoader.compile(className + SUFFIX,content );
|
||||||
|
|
||||||
|
// 加载class文件到虚拟机中,然后通过反射执行
|
||||||
|
@SuppressWarnings("resource")
|
||||||
|
DynamicLoader.MemoryClassLoader classLoader = new DynamicLoader.MemoryClassLoader(
|
||||||
|
bytecode);
|
||||||
|
Class<?> clazz = classLoader.loadClass(className);
|
||||||
|
|
||||||
|
// 调用ruleTest方法
|
||||||
|
Method mainMethod = clazz.getDeclaredMethod("ruleTest", List.class);
|
||||||
|
invoke = mainMethod.invoke(null, testData.getList());
|
||||||
|
} catch (ClassNotFoundException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
throw new ServiceException("测试失败");
|
||||||
|
}
|
||||||
|
return invoke;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,105 @@
|
||||||
|
package com.muyu.ruleEngine.service.impl;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import com.muyu.common.core.utils.ObjUtils;
|
||||||
|
import com.muyu.ruleEngine.domain.EngineConfig;
|
||||||
|
import com.muyu.ruleEngine.domain.resp.EngineConfigScopeResp;
|
||||||
|
import com.muyu.ruleEngine.service.EngineConfigService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import com.muyu.ruleEngine.mapper.EngineMaintenanceMapper;
|
||||||
|
import com.muyu.ruleEngine.domain.EngineMaintenance;
|
||||||
|
import com.muyu.ruleEngine.service.EngineMaintenanceService;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 引擎维护Service业务层处理
|
||||||
|
*
|
||||||
|
* @author DeKangLiu
|
||||||
|
* @date 2024-05-02
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
public class EngineMaintenanceServiceImpl extends ServiceImpl<EngineMaintenanceMapper, EngineMaintenance> implements EngineMaintenanceService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private EngineConfigService engineConfigService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询引擎维护列表
|
||||||
|
*
|
||||||
|
* @param engineMaintenance 引擎维护
|
||||||
|
* @return 引擎维护
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<EngineMaintenance> list(EngineMaintenance engineMaintenance) {
|
||||||
|
LambdaQueryWrapper<EngineMaintenance> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
|
||||||
|
|
||||||
|
if (ObjUtils.notNull(engineMaintenance.getName())){
|
||||||
|
queryWrapper.like(EngineMaintenance::getName, engineMaintenance.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ObjUtils.notNull(engineMaintenance.getType())){
|
||||||
|
queryWrapper.eq(EngineMaintenance::getType, engineMaintenance.getType());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ObjUtils.notNull(engineMaintenance.getScope())){
|
||||||
|
queryWrapper.eq(EngineMaintenance::getScope, engineMaintenance.getScope());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ObjUtils.notNull(engineMaintenance.getEngineCode())){
|
||||||
|
queryWrapper.eq(EngineMaintenance::getEngineCode, engineMaintenance.getEngineCode());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ObjUtils.notNull(engineMaintenance.getIsActivate())){
|
||||||
|
queryWrapper.eq(EngineMaintenance::getIsActivate, engineMaintenance.getIsActivate());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ObjUtils.notNull(engineMaintenance.getStatus())){
|
||||||
|
queryWrapper.eq(EngineMaintenance::getStatus, engineMaintenance.getStatus());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return list(queryWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增引擎维护
|
||||||
|
* @param engineMaintenance 引擎维护对象
|
||||||
|
* @return 是否
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public boolean saveEngineMaintenance(EngineMaintenance engineMaintenance) {
|
||||||
|
boolean save = this.save(engineMaintenance);
|
||||||
|
EngineConfigScopeResp scopeInfo = engineConfigService.getScopeInfoById(engineMaintenance.getScope());
|
||||||
|
engineConfigService.save(EngineConfig.builder().versionCode("1.0").ruleContent(scopeInfo.getCode()).build());
|
||||||
|
return save;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除引擎维护
|
||||||
|
* @param ids 引擎维护编号集合
|
||||||
|
* @return 是否
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public boolean removeBatchEngineMaintenanceByIds(List<Long> ids) {
|
||||||
|
boolean removed = this.removeBatchByIds(ids);
|
||||||
|
List<EngineConfig> engineConfigs = engineConfigService.list(new LambdaQueryWrapper<EngineConfig>()
|
||||||
|
.in(EngineConfig::getEngineMaintenanceId, ids));
|
||||||
|
if(!engineConfigs.isEmpty()){
|
||||||
|
engineConfigService.removeBatchByIds(engineConfigs.stream().map(EngineConfig::getId).toList());
|
||||||
|
}
|
||||||
|
return removed;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
Spring Boot Version: ${spring-boot.version}
|
||||||
|
Spring Application Name: ${spring.application.name}
|
||||||
|
__ .__ .__
|
||||||
|
____ _/ |_ | | _______ __ __ ____ ___.__.|__|
|
||||||
|
/ ___\ \ __\| | ______ \_ __ \| | \ / _ \ < | || |
|
||||||
|
/ /_/ > | | | |__ /_____/ | | \/| | /( <_> ) \___ || |
|
||||||
|
\___ / |__| |____/ |__| |____/ \____/ / ____||__|
|
||||||
|
/_____/ \/
|
|
@ -0,0 +1,29 @@
|
||||||
|
# Tomcat
|
||||||
|
server:
|
||||||
|
port: 9205
|
||||||
|
|
||||||
|
# Spring
|
||||||
|
spring:
|
||||||
|
application:
|
||||||
|
# 应用名称
|
||||||
|
name: muyu-rule-engine
|
||||||
|
profiles:
|
||||||
|
# 环境配置
|
||||||
|
active: dev
|
||||||
|
cloud:
|
||||||
|
nacos:
|
||||||
|
discovery:
|
||||||
|
# 服务注册地址
|
||||||
|
server-addr: 115.159.81.159:8848
|
||||||
|
config:
|
||||||
|
# 配置中心地址
|
||||||
|
server-addr: 115.159.81.159:8848
|
||||||
|
namespace: f394dee0-fead-4010-8359-2955bacca31f
|
||||||
|
# 配置文件格式
|
||||||
|
file-extension: yml
|
||||||
|
# 共享配置
|
||||||
|
shared-configs:
|
||||||
|
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||||
|
logging:
|
||||||
|
level:
|
||||||
|
com.muyu.ruleEngine.mapper: DEBUG
|
|
@ -0,0 +1,74 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<configuration scan="true" scanPeriod="60 seconds" debug="false">
|
||||||
|
<!-- 日志存放路径 -->
|
||||||
|
<property name="log.path" value="logs/muyu-ruleEngine"/>
|
||||||
|
<!-- 日志输出格式 -->
|
||||||
|
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
|
||||||
|
|
||||||
|
<!-- 控制台输出 -->
|
||||||
|
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||||
|
<encoder>
|
||||||
|
<pattern>${log.pattern}</pattern>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<!-- 系统日志输出 -->
|
||||||
|
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
|
<file>${log.path}/info.log</file>
|
||||||
|
<!-- 循环政策:基于时间创建日志文件 -->
|
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||||
|
<!-- 日志文件名格式 -->
|
||||||
|
<fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||||
|
<!-- 日志最大的历史 60天 -->
|
||||||
|
<maxHistory>60</maxHistory>
|
||||||
|
</rollingPolicy>
|
||||||
|
<encoder>
|
||||||
|
<pattern>${log.pattern}</pattern>
|
||||||
|
</encoder>
|
||||||
|
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||||
|
<!-- 过滤的级别 -->
|
||||||
|
<level>INFO</level>
|
||||||
|
<!-- 匹配时的操作:接收(记录) -->
|
||||||
|
<onMatch>ACCEPT</onMatch>
|
||||||
|
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||||
|
<onMismatch>DENY</onMismatch>
|
||||||
|
</filter>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
|
<file>${log.path}/error.log</file>
|
||||||
|
<!-- 循环政策:基于时间创建日志文件 -->
|
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||||
|
<!-- 日志文件名格式 -->
|
||||||
|
<fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||||
|
<!-- 日志最大的历史 60天 -->
|
||||||
|
<maxHistory>60</maxHistory>
|
||||||
|
</rollingPolicy>
|
||||||
|
<encoder>
|
||||||
|
<pattern>${log.pattern}</pattern>
|
||||||
|
</encoder>
|
||||||
|
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||||
|
<!-- 过滤的级别 -->
|
||||||
|
<level>ERROR</level>
|
||||||
|
<!-- 匹配时的操作:接收(记录) -->
|
||||||
|
<onMatch>ACCEPT</onMatch>
|
||||||
|
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||||
|
<onMismatch>DENY</onMismatch>
|
||||||
|
</filter>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<!-- 系统模块日志级别控制 -->
|
||||||
|
<logger name="com.muyu" level="info"/>
|
||||||
|
<!-- Spring日志级别控制 -->
|
||||||
|
<logger name="org.springframework" level="warn"/>
|
||||||
|
|
||||||
|
<root level="info">
|
||||||
|
<appender-ref ref="console"/>
|
||||||
|
</root>
|
||||||
|
|
||||||
|
<!--系统操作日志-->
|
||||||
|
<root level="info">
|
||||||
|
<appender-ref ref="file_info"/>
|
||||||
|
<appender-ref ref="file_error"/>
|
||||||
|
</root>
|
||||||
|
</configuration>
|
|
@ -0,0 +1,26 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>com.muyu</groupId>
|
||||||
|
<artifactId>muyu-modules</artifactId>
|
||||||
|
<version>3.6.3</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>muyu-rule_engine</artifactId>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
<modules>
|
||||||
|
<module>muyu-rule_engine-common</module>
|
||||||
|
<module>muyu-rule_engine-remote</module>
|
||||||
|
<module>muyu-rule_engine-server</module>
|
||||||
|
</modules>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
|
<maven.compiler.target>17</maven.compiler.target>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
</project>
|
|
@ -22,7 +22,6 @@
|
||||||
<groupId>com.alibaba.cloud</groupId>
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- SpringCloud Alibaba Nacos Config -->
|
<!-- SpringCloud Alibaba Nacos Config -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alibaba.cloud</groupId>
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
@ -78,6 +77,12 @@
|
||||||
<artifactId>muyu-common-swagger</artifactId>
|
<artifactId>muyu-common-swagger</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Sql Server 驱动 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.microsoft.sqlserver</groupId>
|
||||||
|
<artifactId>mssql-jdbc</artifactId>
|
||||||
|
<version>9.4.0.jre8</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
@ -102,7 +107,13 @@
|
||||||
<skip>true</skip>
|
<skip>true</skip>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<mainClass>com.muyu.ruleEngine.DeKangLiuRuleEngineApplication</mainClass>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -1,113 +0,0 @@
|
||||||
package com.muyu.system.controller;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
|
|
||||||
import com.muyu.system.domain.resp.AsUserDeptNumResponse;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
import com.muyu.common.log.annotation.Log;
|
|
||||||
import com.muyu.common.log.enums.BusinessType;
|
|
||||||
import com.muyu.common.security.annotation.RequiresPermissions;
|
|
||||||
import com.muyu.system.domain.AsUserDept;
|
|
||||||
import com.muyu.system.service.IAsUserDeptService;
|
|
||||||
import com.muyu.common.core.web.controller.BaseController;
|
|
||||||
import com.muyu.common.core.domain.Result;
|
|
||||||
import com.muyu.common.core.utils.poi.ExcelUtil;
|
|
||||||
import com.muyu.common.core.web.page.TableDataInfo;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 【请填写功能名称】Controller
|
|
||||||
*
|
|
||||||
* @author muyu
|
|
||||||
* @date 2024-04-14
|
|
||||||
*/
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/userDept")
|
|
||||||
public class AsUserDeptController extends BaseController
|
|
||||||
{
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private IAsUserDeptService asUserDeptService;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询【请填写功能名称】列表
|
|
||||||
*/
|
|
||||||
@RequiresPermissions("system:dept:list")
|
|
||||||
@GetMapping("/list")
|
|
||||||
public Result<TableDataInfo<AsUserDept>> list(AsUserDept asUserDept)
|
|
||||||
{
|
|
||||||
startPage();
|
|
||||||
List<AsUserDept> list = asUserDeptService.selectAsUserDeptList(asUserDept);
|
|
||||||
return getDataTable(list);
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/UpdateAsUserDept")
|
|
||||||
public Result list(@RequestParam("id") Long id)
|
|
||||||
{
|
|
||||||
return asUserDeptService.updateAsUserDeptRead(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/GetNum")
|
|
||||||
public Result<AsUserDeptNumResponse> getNum(@RequestParam("noticeId") Long noticeId)
|
|
||||||
{
|
|
||||||
return asUserDeptService.getNum(noticeId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 导出【请填写功能名称】列表
|
|
||||||
*/
|
|
||||||
@RequiresPermissions("system:dept:export")
|
|
||||||
@Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
|
|
||||||
@PostMapping("/export")
|
|
||||||
public void export(HttpServletResponse response, AsUserDept asUserDept)
|
|
||||||
{
|
|
||||||
List<AsUserDept> list = asUserDeptService.selectAsUserDeptList(asUserDept);
|
|
||||||
ExcelUtil<AsUserDept> util = new ExcelUtil<AsUserDept>(AsUserDept.class);
|
|
||||||
util.exportExcel(response, list, "【请填写功能名称】数据");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取【请填写功能名称】详细信息
|
|
||||||
*/
|
|
||||||
@RequiresPermissions("system:dept:query")
|
|
||||||
@GetMapping(value = "/{id}")
|
|
||||||
public Result getInfo(@PathVariable("id") Long id)
|
|
||||||
{
|
|
||||||
return success(asUserDeptService.selectAsUserDeptById(id));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增【请填写功能名称】
|
|
||||||
*/
|
|
||||||
@RequiresPermissions("system:dept:add")
|
|
||||||
@Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
|
|
||||||
@PostMapping
|
|
||||||
public Result add(@RequestBody AsUserDept asUserDept)
|
|
||||||
{
|
|
||||||
return toAjax(asUserDeptService.insertAsUserDept(asUserDept));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改【请填写功能名称】
|
|
||||||
*/
|
|
||||||
@RequiresPermissions("system:dept:edit")
|
|
||||||
@Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
|
|
||||||
@PutMapping
|
|
||||||
public Result edit(@RequestBody AsUserDept asUserDept)
|
|
||||||
{
|
|
||||||
return toAjax(asUserDeptService.updateAsUserDept(asUserDept));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除【请填写功能名称】
|
|
||||||
*/
|
|
||||||
@RequiresPermissions("system:dept:remove")
|
|
||||||
@Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
|
|
||||||
@DeleteMapping("/{ids}")
|
|
||||||
public Result remove(@PathVariable Long[] ids)
|
|
||||||
{
|
|
||||||
return toAjax(asUserDeptService.deleteAsUserDeptByIds(ids));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -15,7 +15,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -36,9 +35,7 @@ public class SysMenuController extends BaseController {
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public Result list (SysMenu menu) {
|
public Result list (SysMenu menu) {
|
||||||
Long userId = SecurityUtils.getUserId();
|
Long userId = SecurityUtils.getUserId();
|
||||||
|
|
||||||
List<SysMenu> menus = menuService.selectMenuList(menu, userId);
|
List<SysMenu> menus = menuService.selectMenuList(menu, userId);
|
||||||
|
|
||||||
return success(menus);
|
return success(menus);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,8 +8,6 @@ import com.muyu.common.log.enums.BusinessType;
|
||||||
import com.muyu.common.security.annotation.RequiresPermissions;
|
import com.muyu.common.security.annotation.RequiresPermissions;
|
||||||
import com.muyu.common.security.utils.SecurityUtils;
|
import com.muyu.common.security.utils.SecurityUtils;
|
||||||
import com.muyu.system.domain.SysNotice;
|
import com.muyu.system.domain.SysNotice;
|
||||||
import com.muyu.system.domain.req.SysNoticeRequest;
|
|
||||||
import com.muyu.system.domain.resp.SysNoticeResponse;
|
|
||||||
import com.muyu.system.service.SysNoticeService;
|
import com.muyu.system.service.SysNoticeService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
@ -39,11 +37,6 @@ public class SysNoticeController extends BaseController {
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/GetNoticeList")
|
|
||||||
public Result<List<SysNoticeResponse>> getNoticeList(@RequestBody SysNoticeRequest sysNoticeRequest){
|
|
||||||
return noticeService.getNoticeList(sysNoticeRequest);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据通知公告编号获取详细信息
|
* 根据通知公告编号获取详细信息
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -14,7 +14,6 @@ import com.muyu.common.system.domain.SysDept;
|
||||||
import com.muyu.common.system.domain.SysRole;
|
import com.muyu.common.system.domain.SysRole;
|
||||||
import com.muyu.common.system.domain.SysUser;
|
import com.muyu.common.system.domain.SysUser;
|
||||||
import com.muyu.common.system.domain.LoginUser;
|
import com.muyu.common.system.domain.LoginUser;
|
||||||
import com.muyu.system.domain.SysUserOnline;
|
|
||||||
import com.muyu.system.domain.resp.AuthRoleResp;
|
import com.muyu.system.domain.resp.AuthRoleResp;
|
||||||
import com.muyu.system.domain.resp.UserDetailInfoResp;
|
import com.muyu.system.domain.resp.UserDetailInfoResp;
|
||||||
import com.muyu.system.domain.resp.UserInfoResp;
|
import com.muyu.system.domain.resp.UserInfoResp;
|
||||||
|
@ -56,8 +55,6 @@ public class SysUserController extends BaseController {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SysConfigService configService;
|
private SysConfigService configService;
|
||||||
@Autowired
|
|
||||||
private SysUserOnlineController sysUserOnlineController;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取用户列表
|
* 获取用户列表
|
||||||
|
@ -102,11 +99,9 @@ public class SysUserController extends BaseController {
|
||||||
@InnerAuth
|
@InnerAuth
|
||||||
@GetMapping("/info/{username}")
|
@GetMapping("/info/{username}")
|
||||||
public Result<LoginUser> info (@PathVariable("username") String username) {
|
public Result<LoginUser> info (@PathVariable("username") String username) {
|
||||||
|
|
||||||
|
|
||||||
SysUser sysUser = userService.selectUserByUserName(username);
|
SysUser sysUser = userService.selectUserByUserName(username);
|
||||||
if (StringUtils.isNull(sysUser)) {
|
if (StringUtils.isNull(sysUser)) {
|
||||||
return Result.error("用户名,邮箱或密码错误");
|
return Result.error("用户名或密码错误");
|
||||||
}
|
}
|
||||||
// 角色集合
|
// 角色集合
|
||||||
Set<String> roles = permissionService.getRolePermission(sysUser);
|
Set<String> roles = permissionService.getRolePermission(sysUser);
|
||||||
|
@ -235,25 +230,15 @@ public class SysUserController extends BaseController {
|
||||||
/**
|
/**
|
||||||
* 重置密码
|
* 重置密码
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("`system:user:edit")
|
@RequiresPermissions("system:user:edit")
|
||||||
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping("/resetPwd")
|
@PutMapping("/resetPwd")
|
||||||
public Result resetPwd (@RequestBody SysUser user) {
|
public Result resetPwd (@RequestBody SysUser user) {
|
||||||
SysUser sysUser = userService.selectUserById(user.getUserId());
|
userService.checkUserAllowed(user);
|
||||||
userService.checkUserAllowed(sysUser);
|
userService.checkUserDataScope(user.getUserId());
|
||||||
userService.checkUserDataScope(sysUser.getUserId());
|
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
|
||||||
user.setPassword(SecurityUtils.encryptPassword(sysUser.getPassword()));
|
|
||||||
user.setUpdateBy(SecurityUtils.getUsername());
|
user.setUpdateBy(SecurityUtils.getUsername());
|
||||||
Result<TableDataInfo<SysUserOnline>> list = sysUserOnlineController.list(user.getLoginIp(), user.getUserName());
|
return toAjax(userService.resetPwd(user));
|
||||||
System.out.println(list);
|
|
||||||
TableDataInfo<SysUserOnline> data = list.getData();
|
|
||||||
List<SysUserOnline> rows = data.getRows();
|
|
||||||
for (SysUserOnline row : rows) {
|
|
||||||
if (row.getUserName().equals(sysUser.getUserName())){
|
|
||||||
sysUserOnlineController.forceLogout(row.getTokenId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return toAjax(userService.resetPwd(sysUser));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,84 +0,0 @@
|
||||||
package com.muyu.system.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;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 【请填写功能名称】对象 as_user_dept
|
|
||||||
*
|
|
||||||
* @author muyu
|
|
||||||
* @date 2024-04-14
|
|
||||||
*/
|
|
||||||
public class AsUserDept extends BaseEntity
|
|
||||||
{
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
/** $column.columnComment */
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
/** $column.columnComment */
|
|
||||||
@Excel(name = "用户ID", readConverterExp = "$column.readConverterExp()")
|
|
||||||
private Long userId;
|
|
||||||
|
|
||||||
/** $column.columnComment */
|
|
||||||
@Excel(name = "公告ID", readConverterExp = "$column.readConverterExp()")
|
|
||||||
private Long noticeId;
|
|
||||||
|
|
||||||
/** $column.columnComment */
|
|
||||||
@Excel(name = "是否已读", readConverterExp = "$column.readConverterExp()")
|
|
||||||
private String isRead;
|
|
||||||
|
|
||||||
public void setId(Long id)
|
|
||||||
{
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getId()
|
|
||||||
{
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
public void setUserId(Long userId)
|
|
||||||
{
|
|
||||||
this.userId = userId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getUserId()
|
|
||||||
{
|
|
||||||
return userId;
|
|
||||||
}
|
|
||||||
public void setNoticeId(Long noticeId)
|
|
||||||
{
|
|
||||||
this.noticeId = noticeId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getNoticeId()
|
|
||||||
{
|
|
||||||
return noticeId;
|
|
||||||
}
|
|
||||||
public void setIsRead(String isRead)
|
|
||||||
{
|
|
||||||
this.isRead = isRead;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getIsRead()
|
|
||||||
{
|
|
||||||
return isRead;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
|
||||||
.append("id", getId())
|
|
||||||
.append("userId", getUserId())
|
|
||||||
.append("noticeId", getNoticeId())
|
|
||||||
.append("isRead", getIsRead())
|
|
||||||
.append("createBy", getCreateBy())
|
|
||||||
.append("createTime", getCreateTime())
|
|
||||||
.append("updateBy", getUpdateBy())
|
|
||||||
.append("updateTime", getUpdateTime())
|
|
||||||
.append("remark", getRemark())
|
|
||||||
.toString();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -12,7 +12,6 @@ import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
|
|
||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
import javax.validation.constraints.Size;
|
import javax.validation.constraints.Size;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通知公告表 sys_notice
|
* 通知公告表 sys_notice
|
||||||
|
@ -52,16 +51,6 @@ public class SysNotice extends BaseEntity {
|
||||||
*/
|
*/
|
||||||
private String status;
|
private String status;
|
||||||
|
|
||||||
/**
|
|
||||||
* 部门id集合
|
|
||||||
*/
|
|
||||||
private List<List<Long>> sectionList;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户ID集合
|
|
||||||
*/
|
|
||||||
private List<Long> personneList;
|
|
||||||
|
|
||||||
public Long getNoticeId () {
|
public Long getNoticeId () {
|
||||||
return noticeId;
|
return noticeId;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,26 +0,0 @@
|
||||||
package com.muyu.system.domain.req;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* SysNoticeRequest
|
|
||||||
*
|
|
||||||
* @author DeKangLiu
|
|
||||||
* on 2024/4/14
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@Builder
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class SysNoticeRequest {
|
|
||||||
private Long noticeId;
|
|
||||||
|
|
||||||
private Long userId;
|
|
||||||
|
|
||||||
private String noticeType;
|
|
||||||
|
|
||||||
private String isRead;
|
|
||||||
}
|
|
|
@ -1,24 +0,0 @@
|
||||||
package com.muyu.system.domain.resp;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* AsUserDeotNumResponse
|
|
||||||
*
|
|
||||||
* @author DeKangLiu
|
|
||||||
* on 2024/4/14
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@Builder
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class AsUserDeptNumResponse {
|
|
||||||
private Long num;
|
|
||||||
|
|
||||||
private Long readNum;
|
|
||||||
|
|
||||||
private Long noReadNum;
|
|
||||||
}
|
|
|
@ -1,34 +0,0 @@
|
||||||
package com.muyu.system.domain.resp;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* SysNoticeResponse
|
|
||||||
*
|
|
||||||
* @author DeKangLiu
|
|
||||||
* on 2024/4/14
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@Builder
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class SysNoticeResponse {
|
|
||||||
private Date createTime;
|
|
||||||
|
|
||||||
private String createBy;
|
|
||||||
|
|
||||||
private String noticeType;
|
|
||||||
|
|
||||||
private String isRead;
|
|
||||||
|
|
||||||
private String noticeTitle;
|
|
||||||
|
|
||||||
private String noticeContent;
|
|
||||||
|
|
||||||
private Long id;
|
|
||||||
}
|
|
|
@ -1,71 +0,0 @@
|
||||||
package com.muyu.system.mapper;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import com.muyu.system.domain.AsUserDept;
|
|
||||||
import org.apache.ibatis.annotations.Param;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 【请填写功能名称】Mapper接口
|
|
||||||
*
|
|
||||||
* @author muyu
|
|
||||||
* @date 2024-04-14
|
|
||||||
*/
|
|
||||||
public interface AsUserDeptMapper
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* 查询【请填写功能名称】
|
|
||||||
*
|
|
||||||
* @param id 【请填写功能名称】主键
|
|
||||||
* @return 【请填写功能名称】
|
|
||||||
*/
|
|
||||||
public AsUserDept selectAsUserDeptById(Long id);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询【请填写功能名称】列表
|
|
||||||
*
|
|
||||||
* @param asUserDept 【请填写功能名称】
|
|
||||||
* @return 【请填写功能名称】集合
|
|
||||||
*/
|
|
||||||
public List<AsUserDept> selectAsUserDeptList(AsUserDept asUserDept);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增【请填写功能名称】
|
|
||||||
*
|
|
||||||
* @param asUserDept 【请填写功能名称】
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public int insertAsUserDept(AsUserDept asUserDept);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改【请填写功能名称】
|
|
||||||
*
|
|
||||||
* @param asUserDept 【请填写功能名称】
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public int updateAsUserDept(AsUserDept asUserDept);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除【请填写功能名称】
|
|
||||||
*
|
|
||||||
* @param id 【请填写功能名称】主键
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public int deleteAsUserDeptById(Long id);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量删除【请填写功能名称】
|
|
||||||
*
|
|
||||||
* @param ids 需要删除的数据主键集合
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public int deleteAsUserDeptByIds(Long[] ids);
|
|
||||||
|
|
||||||
Long selectAsUserDeptReadNum(@Param("noticeId") Long noticeId);
|
|
||||||
|
|
||||||
Long selectAsUserDeptNum(@Param("noticeId") Long noticeId);
|
|
||||||
|
|
||||||
void updateAsUserDeptRead(@Param("id") Long id);
|
|
||||||
|
|
||||||
void insertBachAsUserDept(@Param("asUserDepts") List<AsUserDept> asUserDepts);
|
|
||||||
|
|
||||||
}
|
|
|
@ -135,7 +135,4 @@ public interface SysMenuMapper extends BaseMapper<SysMenu> {
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public SysMenu checkMenuNameUnique (@Param("menuName") String menuName, @Param("parentId") Long parentId);
|
public SysMenu checkMenuNameUnique (@Param("menuName") String menuName, @Param("parentId") Long parentId);
|
||||||
|
|
||||||
public List<SysMenu> selectSysMenuList(@Param("list") List<Long> list);
|
|
||||||
public List<SysMenu> selectSysChdMenuList(@Param("list") List<Long> list);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,6 @@ package com.muyu.system.mapper;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.muyu.system.domain.SysNotice;
|
import com.muyu.system.domain.SysNotice;
|
||||||
import com.muyu.system.domain.req.SysNoticeRequest;
|
|
||||||
import com.muyu.system.domain.resp.SysNoticeResponse;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -66,9 +64,4 @@ public interface SysNoticeMapper extends BaseMapper<SysNotice> {
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int deleteNoticeByIds (Long[] noticeIds);
|
public int deleteNoticeByIds (Long[] noticeIds);
|
||||||
|
|
||||||
List<SysNoticeResponse> getNoticeList(SysNoticeRequest sysNoticeRequest);
|
|
||||||
|
|
||||||
List<Long> selectUser();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -139,7 +139,4 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public SysUser checkEmailUnique (String email);
|
public SysUser checkEmailUnique (String email);
|
||||||
|
|
||||||
List<Long> selectDeptUser(@Param("sectionIds") List<Long> sectionIds);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,69 +0,0 @@
|
||||||
package com.muyu.system.service;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.muyu.common.core.domain.Result;
|
|
||||||
import com.muyu.system.domain.AsUserDept;
|
|
||||||
import com.muyu.system.domain.resp.AsUserDeptNumResponse;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 【请填写功能名称】Service接口
|
|
||||||
*
|
|
||||||
* @author muyu
|
|
||||||
* @date 2024-04-14
|
|
||||||
*/
|
|
||||||
public interface IAsUserDeptService
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* 查询【请填写功能名称】
|
|
||||||
*
|
|
||||||
* @param id 【请填写功能名称】主键
|
|
||||||
* @return 【请填写功能名称】
|
|
||||||
*/
|
|
||||||
public AsUserDept selectAsUserDeptById(Long id);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询【请填写功能名称】列表
|
|
||||||
*
|
|
||||||
* @param asUserDept 【请填写功能名称】
|
|
||||||
* @return 【请填写功能名称】集合
|
|
||||||
*/
|
|
||||||
public List<AsUserDept> selectAsUserDeptList(AsUserDept asUserDept);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增【请填写功能名称】
|
|
||||||
*
|
|
||||||
* @param asUserDept 【请填写功能名称】
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public int insertAsUserDept(AsUserDept asUserDept);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改【请填写功能名称】
|
|
||||||
*
|
|
||||||
* @param asUserDept 【请填写功能名称】
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public int updateAsUserDept(AsUserDept asUserDept);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量删除【请填写功能名称】
|
|
||||||
*
|
|
||||||
* @param ids 需要删除的【请填写功能名称】主键集合
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public int deleteAsUserDeptByIds(Long[] ids);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除【请填写功能名称】信息
|
|
||||||
*
|
|
||||||
* @param id 【请填写功能名称】主键
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public int deleteAsUserDeptById(Long id);
|
|
||||||
|
|
||||||
Result updateAsUserDeptRead(Long id);
|
|
||||||
|
|
||||||
Result<AsUserDeptNumResponse> getNum(Long noticeId);
|
|
||||||
|
|
||||||
}
|
|
|
@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.muyu.system.domain.SysMenu;
|
import com.muyu.system.domain.SysMenu;
|
||||||
import com.muyu.system.domain.vo.RouterVo;
|
import com.muyu.system.domain.vo.RouterVo;
|
||||||
import com.muyu.system.domain.vo.TreeSelect;
|
import com.muyu.system.domain.vo.TreeSelect;
|
||||||
import org.apache.ibatis.annotations.Param;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -159,5 +158,4 @@ public interface SysMenuService extends IService<SysMenu> {
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public boolean checkMenuNameUnique (SysMenu menu);
|
public boolean checkMenuNameUnique (SysMenu menu);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,7 @@
|
||||||
package com.muyu.system.service;
|
package com.muyu.system.service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.muyu.common.core.domain.Result;
|
|
||||||
import com.muyu.system.domain.SysNotice;
|
import com.muyu.system.domain.SysNotice;
|
||||||
import com.muyu.system.domain.req.SysNoticeRequest;
|
|
||||||
import com.muyu.system.domain.resp.SysNoticeResponse;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -67,6 +64,4 @@ public interface SysNoticeService extends IService<SysNotice> {
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int deleteNoticeByIds (Long[] noticeIds);
|
public int deleteNoticeByIds (Long[] noticeIds);
|
||||||
|
|
||||||
Result<List<SysNoticeResponse>> getNoticeList(SysNoticeRequest sysNoticeRequest);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -225,6 +225,4 @@ public interface SysUserService extends IService<SysUser> {
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public String importUser (List<SysUser> userList, Boolean isUpdateSupport, String operName);
|
public String importUser (List<SysUser> userList, Boolean isUpdateSupport, String operName);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,119 +0,0 @@
|
||||||
package com.muyu.system.service.impl;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.muyu.common.core.domain.Result;
|
|
||||||
import com.muyu.common.core.utils.DateUtils;
|
|
||||||
import com.muyu.system.domain.resp.AsUserDeptNumResponse;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import com.muyu.system.mapper.AsUserDeptMapper;
|
|
||||||
import com.muyu.system.domain.AsUserDept;
|
|
||||||
import com.muyu.system.service.IAsUserDeptService;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 【请填写功能名称】Service业务层处理
|
|
||||||
*
|
|
||||||
* @author muyu
|
|
||||||
* @date 2024-04-14
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
public class AsUserDeptServiceImpl implements IAsUserDeptService
|
|
||||||
{
|
|
||||||
@Autowired
|
|
||||||
private AsUserDeptMapper asUserDeptMapper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询【请填写功能名称】
|
|
||||||
*
|
|
||||||
* @param id 【请填写功能名称】主键
|
|
||||||
* @return 【请填写功能名称】
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public AsUserDept selectAsUserDeptById(Long id)
|
|
||||||
{
|
|
||||||
return asUserDeptMapper.selectAsUserDeptById(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询【请填写功能名称】列表
|
|
||||||
*
|
|
||||||
* @param asUserDept 【请填写功能名称】
|
|
||||||
* @return 【请填写功能名称】
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public List<AsUserDept> selectAsUserDeptList(AsUserDept asUserDept)
|
|
||||||
{
|
|
||||||
return asUserDeptMapper.selectAsUserDeptList(asUserDept);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增【请填写功能名称】
|
|
||||||
*
|
|
||||||
* @param asUserDept 【请填写功能名称】
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public int insertAsUserDept(AsUserDept asUserDept)
|
|
||||||
{
|
|
||||||
asUserDept.setCreateTime(DateUtils.getNowDate());
|
|
||||||
return asUserDeptMapper.insertAsUserDept(asUserDept);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改【请填写功能名称】
|
|
||||||
*
|
|
||||||
* @param asUserDept 【请填写功能名称】
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public int updateAsUserDept(AsUserDept asUserDept)
|
|
||||||
{
|
|
||||||
asUserDept.setUpdateTime(DateUtils.getNowDate());
|
|
||||||
return asUserDeptMapper.updateAsUserDept(asUserDept);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量删除【请填写功能名称】
|
|
||||||
*
|
|
||||||
* @param ids 需要删除的【请填写功能名称】主键
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public int deleteAsUserDeptByIds(Long[] ids)
|
|
||||||
{
|
|
||||||
return asUserDeptMapper.deleteAsUserDeptByIds(ids);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除【请填写功能名称】信息
|
|
||||||
*
|
|
||||||
* @param id 【请填写功能名称】主键
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public int deleteAsUserDeptById(Long id)
|
|
||||||
{
|
|
||||||
return asUserDeptMapper.deleteAsUserDeptById(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional
|
|
||||||
public Result updateAsUserDeptRead(Long id) {
|
|
||||||
asUserDeptMapper.updateAsUserDeptRead(id);
|
|
||||||
return Result.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Result<AsUserDeptNumResponse> getNum(Long noticeId) {
|
|
||||||
Long num = asUserDeptMapper.selectAsUserDeptNum(noticeId);
|
|
||||||
Long readNum = asUserDeptMapper.selectAsUserDeptReadNum(noticeId);
|
|
||||||
long noReadNum = num-readNum;
|
|
||||||
return Result.success(AsUserDeptNumResponse.builder()
|
|
||||||
.num(num)
|
|
||||||
.readNum(readNum)
|
|
||||||
.noReadNum(noReadNum)
|
|
||||||
.build());
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -51,22 +51,6 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
||||||
return selectMenuList(new SysMenu(), userId);
|
return selectMenuList(new SysMenu(), userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<SysMenu> selectSysMenuList(List<SysMenu> menuList){
|
|
||||||
List<Long> list = menuList.stream()
|
|
||||||
.map(menu -> menu.getParentId())
|
|
||||||
.filter(parentId -> parentId != 0)
|
|
||||||
.distinct()
|
|
||||||
.toList();
|
|
||||||
if (list.size()==0){
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
List<SysMenu> sysMenus = menuMapper.selectSysMenuList(list);
|
|
||||||
List<SysMenu> sysMenus1 = selectSysMenuList(sysMenus);
|
|
||||||
if (sysMenus1!=null){
|
|
||||||
sysMenus.addAll(sysMenus1);
|
|
||||||
}
|
|
||||||
return sysMenus;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* 查询系统菜单列表
|
* 查询系统菜单列表
|
||||||
*
|
*
|
||||||
|
@ -80,42 +64,13 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
||||||
// 管理员显示所有菜单信息
|
// 管理员显示所有菜单信息
|
||||||
if (SysUser.isAdmin(userId)) {
|
if (SysUser.isAdmin(userId)) {
|
||||||
menuList = menuMapper.selectMenuList(menu);
|
menuList = menuMapper.selectMenuList(menu);
|
||||||
List<SysMenu> sysMenus1 = selectSysChdMenuList(menuList);
|
|
||||||
if (sysMenus1!=null&& sysMenus1.size()!=0){
|
|
||||||
menuList.addAll(sysMenus1);
|
|
||||||
|
|
||||||
}
|
|
||||||
List<SysMenu> sysMenus = selectSysChdMenuList(menuMapper.selectMenuList(menu));
|
|
||||||
if (sysMenus!=null&& sysMenus.size()!=0){
|
|
||||||
menuList.addAll(sysMenus);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
menu.getParams().put("userId", userId);
|
menu.getParams().put("userId", userId);
|
||||||
menuList = menuMapper.selectMenuListByUserId(menu);
|
menuList = menuMapper.selectMenuListByUserId(menu);
|
||||||
}
|
}
|
||||||
menuList= menuList.stream()
|
|
||||||
.distinct()
|
|
||||||
.toList();
|
|
||||||
return menuList;
|
return menuList;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<SysMenu> selectSysChdMenuList(List<SysMenu> menuList) {
|
|
||||||
List<Long> list = menuList.stream()
|
|
||||||
.map(sysMenu -> sysMenu.getMenuId())
|
|
||||||
.toList();
|
|
||||||
System.out.println(list);
|
|
||||||
List<SysMenu> sysMenus = menuMapper.selectSysChdMenuList(list);
|
|
||||||
if (sysMenus!=null&&sysMenus.size()!=0){
|
|
||||||
List<SysMenu> sysMenus1 = selectSysChdMenuList(sysMenus);
|
|
||||||
if (sysMenus1!=null){
|
|
||||||
sysMenus.addAll(sysMenus1);
|
|
||||||
}
|
|
||||||
}else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return sysMenus;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据用户ID查询权限
|
* 根据用户ID查询权限
|
||||||
*
|
*
|
||||||
|
@ -366,7 +321,6 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
||||||
return UserConstants.UNIQUE;
|
return UserConstants.UNIQUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取路由名称
|
* 获取路由名称
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,24 +1,13 @@
|
||||||
package com.muyu.system.service.impl;
|
package com.muyu.system.service.impl;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.muyu.common.core.domain.Result;
|
|
||||||
import com.muyu.common.security.utils.SecurityUtils;
|
|
||||||
import com.muyu.system.domain.AsUserDept;
|
|
||||||
import com.muyu.system.domain.SysNotice;
|
import com.muyu.system.domain.SysNotice;
|
||||||
import com.muyu.system.domain.req.SysNoticeRequest;
|
|
||||||
import com.muyu.system.domain.resp.SysNoticeResponse;
|
|
||||||
import com.muyu.system.mapper.AsUserDeptMapper;
|
|
||||||
import com.muyu.system.mapper.SysNoticeMapper;
|
import com.muyu.system.mapper.SysNoticeMapper;
|
||||||
import com.muyu.system.mapper.SysUserMapper;
|
|
||||||
import com.muyu.system.service.SysNoticeService;
|
import com.muyu.system.service.SysNoticeService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 公告 服务层实现
|
* 公告 服务层实现
|
||||||
|
@ -30,12 +19,6 @@ public class SysNoticeServiceImpl extends ServiceImpl<SysNoticeMapper, SysNotice
|
||||||
@Autowired
|
@Autowired
|
||||||
private SysNoticeMapper noticeMapper;
|
private SysNoticeMapper noticeMapper;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private SysUserMapper sysUserMapper;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private AsUserDeptMapper asUserDeptMapper;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询公告信息
|
* 查询公告信息
|
||||||
*
|
*
|
||||||
|
@ -68,29 +51,8 @@ public class SysNoticeServiceImpl extends ServiceImpl<SysNoticeMapper, SysNotice
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
|
||||||
public int insertNotice (SysNotice notice) {
|
public int insertNotice (SysNotice notice) {
|
||||||
int i = noticeMapper.insertNotice(notice);
|
return noticeMapper.insertNotice(notice);
|
||||||
if (notice.getNoticeType().equals("1")){
|
|
||||||
Long noticeId = notice.getNoticeId();
|
|
||||||
List<Long> personneList = notice.getPersonneList();
|
|
||||||
List<List<Long>> sectionList = notice.getSectionList();
|
|
||||||
List<AsUserDept> asUserDepts = handleList(personneList, sectionList, noticeId);
|
|
||||||
asUserDeptMapper.insertBachAsUserDept(asUserDepts);
|
|
||||||
} else {
|
|
||||||
List<Long> userIds = noticeMapper.selectUser();
|
|
||||||
List<AsUserDept> asUserDeptList = userIds.stream()
|
|
||||||
.map(id -> {
|
|
||||||
AsUserDept asUserDept = new AsUserDept();
|
|
||||||
asUserDept.setUserId(id);
|
|
||||||
asUserDept.setNoticeId(notice.getNoticeId());
|
|
||||||
asUserDept.setCreateTime(new Date());
|
|
||||||
asUserDept.setCreateBy(SecurityUtils.getUsername());
|
|
||||||
return asUserDept;
|
|
||||||
}).toList();
|
|
||||||
asUserDeptMapper.insertBachAsUserDept(asUserDeptList);
|
|
||||||
}
|
|
||||||
return i;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -128,44 +90,4 @@ public class SysNoticeServiceImpl extends ServiceImpl<SysNoticeMapper, SysNotice
|
||||||
public int deleteNoticeByIds (Long[] noticeIds) {
|
public int deleteNoticeByIds (Long[] noticeIds) {
|
||||||
return noticeMapper.deleteNoticeByIds(noticeIds);
|
return noticeMapper.deleteNoticeByIds(noticeIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Result<List<SysNoticeResponse>> getNoticeList(SysNoticeRequest sysNoticeRequest) {
|
|
||||||
sysNoticeRequest.setUserId(SecurityUtils.getUserId());
|
|
||||||
List<SysNoticeResponse> noticeList = noticeMapper.getNoticeList(sysNoticeRequest);
|
|
||||||
return Result.success(noticeList);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<AsUserDept> handleList(List<Long> personneList,List<List<Long>> sectionList,Long noticeId){
|
|
||||||
List<Long> list = new ArrayList<>();
|
|
||||||
if (sectionList!=null&§ionList.size()!=0){
|
|
||||||
sectionList.stream()
|
|
||||||
.map(
|
|
||||||
section->{
|
|
||||||
for (Long aLong : section) {
|
|
||||||
list.add(aLong);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
).collect(Collectors.toList());
|
|
||||||
List<Long> sectionIds = list.stream().distinct().toList();
|
|
||||||
List<Long> userIds = sysUserMapper.selectDeptUser(sectionIds);
|
|
||||||
if (userIds!=null){
|
|
||||||
personneList.addAll(userIds);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
personneList=personneList.stream().distinct().toList();
|
|
||||||
List<AsUserDept> asUserDeptList = personneList.stream()
|
|
||||||
.map(personne -> {
|
|
||||||
AsUserDept asUserDept = new AsUserDept();
|
|
||||||
asUserDept.setUserId(personne);
|
|
||||||
asUserDept.setNoticeId(noticeId);
|
|
||||||
asUserDept.setCreateTime(new Date());
|
|
||||||
asUserDept.setCreateBy(SecurityUtils.getUsername());
|
|
||||||
return asUserDept;
|
|
||||||
}).toList();
|
|
||||||
return asUserDeptList;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,13 +3,10 @@ package com.muyu.system.service.impl;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.muyu.common.core.constant.UserConstants;
|
import com.muyu.common.core.constant.UserConstants;
|
||||||
import com.muyu.common.core.exception.ServiceException;
|
import com.muyu.common.core.exception.ServiceException;
|
||||||
import com.muyu.common.core.utils.JwtUtils;
|
|
||||||
import com.muyu.common.core.utils.SpringUtils;
|
import com.muyu.common.core.utils.SpringUtils;
|
||||||
import com.muyu.common.core.utils.StringUtils;
|
import com.muyu.common.core.utils.StringUtils;
|
||||||
import com.muyu.common.core.utils.bean.BeanValidators;
|
import com.muyu.common.core.utils.bean.BeanValidators;
|
||||||
import com.muyu.common.datascope.annotation.DataScope;
|
import com.muyu.common.datascope.annotation.DataScope;
|
||||||
import com.muyu.common.redis.service.RedisService;
|
|
||||||
import com.muyu.common.security.auth.AuthUtil;
|
|
||||||
import com.muyu.common.security.utils.SecurityUtils;
|
import com.muyu.common.security.utils.SecurityUtils;
|
||||||
import com.muyu.common.system.domain.SysRole;
|
import com.muyu.common.system.domain.SysRole;
|
||||||
import com.muyu.common.system.domain.SysUser;
|
import com.muyu.common.system.domain.SysUser;
|
||||||
|
@ -22,12 +19,10 @@ import com.muyu.system.service.SysConfigService;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.validation.Validator;
|
import javax.validation.Validator;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -341,15 +336,9 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||||
*
|
*
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Autowired
|
|
||||||
private RedisService redisService;
|
|
||||||
@Autowired
|
|
||||||
private StringRedisTemplate redisTemplate;
|
|
||||||
@Override
|
@Override
|
||||||
public int resetPwd (SysUser user) {
|
public int resetPwd (SysUser user) {
|
||||||
int i = userMapper.updateUser(user);
|
return userMapper.updateUser(user);
|
||||||
|
|
||||||
return i;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,104 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
|
||||||
<!DOCTYPE mapper
|
|
||||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
||||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
||||||
<mapper namespace="com.muyu.system.mapper.AsUserDeptMapper">
|
|
||||||
|
|
||||||
<resultMap type="com.muyu.system.domain.AsUserDept" id="AsUserDeptResult">
|
|
||||||
<result property="id" column="id" />
|
|
||||||
<result property="userId" column="user_id" />
|
|
||||||
<result property="noticeId" column="notice_id" />
|
|
||||||
<result property="isRead" column="is_read" />
|
|
||||||
<result property="createBy" column="create_by" />
|
|
||||||
<result property="createTime" column="create_time" />
|
|
||||||
<result property="updateBy" column="update_by" />
|
|
||||||
<result property="updateTime" column="update_time" />
|
|
||||||
<result property="remark" column="remark" />
|
|
||||||
</resultMap>
|
|
||||||
|
|
||||||
<sql id="selectAsUserDeptVo">
|
|
||||||
select id, user_id, notice_id, is_read, create_by, create_time, update_by, update_time, remark from as_user_dept
|
|
||||||
</sql>
|
|
||||||
|
|
||||||
<select id="selectAsUserDeptList" parameterType="com.muyu.system.domain.AsUserDept" resultMap="AsUserDeptResult">
|
|
||||||
<include refid="selectAsUserDeptVo"/>
|
|
||||||
<where>
|
|
||||||
<if test="userId != null "> and user_id = #{userId}</if>
|
|
||||||
<if test="noticeId != null "> and notice_id = #{noticeId}</if>
|
|
||||||
<if test="isRead != null and isRead != ''"> and is_read = #{isRead}</if>
|
|
||||||
</where>
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="selectAsUserDeptById" parameterType="Long" resultMap="AsUserDeptResult">
|
|
||||||
<include refid="selectAsUserDeptVo"/>
|
|
||||||
where id = #{id}
|
|
||||||
</select>
|
|
||||||
<select id="selectAsUserDeptReadNum" resultType="java.lang.Long">
|
|
||||||
select count(*) from as_user_dept where notice_id=#{noticeId} and is_read = '0'
|
|
||||||
</select>
|
|
||||||
<select id="selectAsUserDeptNum" resultType="java.lang.Long">
|
|
||||||
select count(*) from as_user_dept where notice_id=#{noticeId}
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<insert id="insertAsUserDept" parameterType="com.muyu.system.domain.AsUserDept" useGeneratedKeys="true" keyProperty="id">
|
|
||||||
insert into as_user_dept
|
|
||||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
||||||
<if test="userId != null">user_id,</if>
|
|
||||||
<if test="noticeId != null">notice_id,</if>
|
|
||||||
<if test="isRead != null">is_read,</if>
|
|
||||||
<if test="createBy != null">create_by,</if>
|
|
||||||
<if test="createTime != null">create_time,</if>
|
|
||||||
<if test="updateBy != null">update_by,</if>
|
|
||||||
<if test="updateTime != null">update_time,</if>
|
|
||||||
<if test="remark != null">remark,</if>
|
|
||||||
</trim>
|
|
||||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
||||||
<if test="userId != null">#{userId},</if>
|
|
||||||
<if test="noticeId != null">#{noticeId},</if>
|
|
||||||
<if test="isRead != null">#{isRead},</if>
|
|
||||||
<if test="createBy != null">#{createBy},</if>
|
|
||||||
<if test="createTime != null">#{createTime},</if>
|
|
||||||
<if test="updateBy != null">#{updateBy},</if>
|
|
||||||
<if test="updateTime != null">#{updateTime},</if>
|
|
||||||
<if test="remark != null">#{remark},</if>
|
|
||||||
</trim>
|
|
||||||
</insert>
|
|
||||||
<insert id="insertBachAsUserDept">
|
|
||||||
INSERT INTO `as_user_dept` (`user_id`, `notice_id`, `create_by`, `create_time`)
|
|
||||||
VALUES
|
|
||||||
<foreach collection="asUserDepts" separator="," item="asUserDept">
|
|
||||||
(#{asUserDept.userId}, #{asUserDept.noticeId}, #{asUserDept.createBy}, #{asUserDept.createTime})
|
|
||||||
</foreach>
|
|
||||||
|
|
||||||
|
|
||||||
</insert>
|
|
||||||
|
|
||||||
<update id="updateAsUserDept" parameterType="com.muyu.system.domain.AsUserDept">
|
|
||||||
update as_user_dept
|
|
||||||
<trim prefix="SET" suffixOverrides=",">
|
|
||||||
<if test="userId != null">user_id = #{userId},</if>
|
|
||||||
<if test="noticeId != null">notice_id = #{noticeId},</if>
|
|
||||||
<if test="isRead != null">is_read = #{isRead},</if>
|
|
||||||
<if test="createBy != null">create_by = #{createBy},</if>
|
|
||||||
<if test="createTime != null">create_time = #{createTime},</if>
|
|
||||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
|
||||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
|
||||||
<if test="remark != null">remark = #{remark},</if>
|
|
||||||
</trim>
|
|
||||||
where id = #{id}
|
|
||||||
</update>
|
|
||||||
<update id="updateAsUserDeptRead">
|
|
||||||
update as_user_dept set is_read = 0 where id=#{id}
|
|
||||||
</update>
|
|
||||||
|
|
||||||
<delete id="deleteAsUserDeptById" parameterType="Long">
|
|
||||||
delete from as_user_dept where id = #{id}
|
|
||||||
</delete>
|
|
||||||
|
|
||||||
<delete id="deleteAsUserDeptByIds" parameterType="String">
|
|
||||||
delete from as_user_dept where id in
|
|
||||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
|
||||||
#{id}
|
|
||||||
</foreach>
|
|
||||||
</delete>
|
|
||||||
</mapper>
|
|
|
@ -185,38 +185,6 @@
|
||||||
<include refid="selectMenuVo"/>
|
<include refid="selectMenuVo"/>
|
||||||
where menu_name=#{menuName} and parent_id = #{parentId} limit 1
|
where menu_name=#{menuName} and parent_id = #{parentId} limit 1
|
||||||
</select>
|
</select>
|
||||||
<select id="selectMenuByParentId" parameterType="com.muyu.system.domain.SysMenu" resultMap="SysMenuResult">
|
|
||||||
<include refid="selectMenuVo"/>
|
|
||||||
<where>
|
|
||||||
<if test="parentId!=null">
|
|
||||||
and menu_id=#{parentId}
|
|
||||||
</if>
|
|
||||||
</where>
|
|
||||||
|
|
||||||
</select>
|
|
||||||
<select id="selectSysMenuList" resultType="com.muyu.system.domain.SysMenu">
|
|
||||||
<include refid="selectMenuVo"/>
|
|
||||||
<where>
|
|
||||||
menu_id in(
|
|
||||||
<foreach collection="list" separator="," item="id">
|
|
||||||
#{id}
|
|
||||||
</foreach>
|
|
||||||
)
|
|
||||||
</where>
|
|
||||||
order by parent_id,order_num
|
|
||||||
</select>
|
|
||||||
<select id="selectSysChdMenuList" resultType="com.muyu.system.domain.SysMenu">
|
|
||||||
<include refid="selectMenuVo"/>
|
|
||||||
<where>
|
|
||||||
parent_id in(
|
|
||||||
<foreach collection="list" separator="," item="id">
|
|
||||||
#{id}
|
|
||||||
</foreach>
|
|
||||||
)
|
|
||||||
</where>
|
|
||||||
|
|
||||||
order by parent_id,order_num
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<update id="updateMenu" parameterType="com.muyu.system.domain.SysMenu">
|
<update id="updateMenu" parameterType="com.muyu.system.domain.SysMenu">
|
||||||
update sys_menu
|
update sys_menu
|
||||||
|
|
|
@ -50,22 +50,8 @@
|
||||||
</if>
|
</if>
|
||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
<select id="getNoticeList" resultType="com.muyu.system.domain.resp.SysNoticeResponse">
|
|
||||||
select id,a.notice_id,is_read,a.create_by,a.create_time,notice_title,notice_content,notice_type
|
|
||||||
from as_user_dept a join sys_notice n on a.notice_id=n.notice_id
|
|
||||||
where a.user_id=#{userId}
|
|
||||||
<if test="isRead !=null and isRead!=''">
|
|
||||||
and is_read = #{isRead}
|
|
||||||
</if>
|
|
||||||
<if test="noticeType !=null and noticeType!=''">
|
|
||||||
and n.notice_type = #{noticeType}
|
|
||||||
</if>
|
|
||||||
</select>
|
|
||||||
<select id="selectUser" resultType="java.lang.Long">
|
|
||||||
select user_id from sys_user
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<insert id="insertNotice" parameterType="com.muyu.system.domain.SysNotice" useGeneratedKeys="true" keyProperty="noticeId">
|
<insert id="insertNotice" parameterType="com.muyu.system.domain.SysNotice">
|
||||||
insert into sys_notice (
|
insert into sys_notice (
|
||||||
<if test="noticeTitle != null and noticeTitle != '' ">notice_title,</if>
|
<if test="noticeTitle != null and noticeTitle != '' ">notice_title,</if>
|
||||||
<if test="noticeType != null and noticeType != '' ">notice_type,</if>
|
<if test="noticeType != null and noticeType != '' ">notice_type,</if>
|
||||||
|
|
|
@ -152,7 +152,7 @@
|
||||||
|
|
||||||
<select id="selectUserByUserName" parameterType="String" resultMap="SysUserResult">
|
<select id="selectUserByUserName" parameterType="String" resultMap="SysUserResult">
|
||||||
<include refid="selectUserVo"/>
|
<include refid="selectUserVo"/>
|
||||||
where u.user_name = #{userName} or u.email = #{userName} and u.del_flag = '0'
|
where u.user_name = #{userName} and u.del_flag = '0'
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectUserById" parameterType="Long" resultMap="SysUserResult">
|
<select id="selectUserById" parameterType="Long" resultMap="SysUserResult">
|
||||||
|
@ -183,14 +183,6 @@
|
||||||
and del_flag = '0'
|
and del_flag = '0'
|
||||||
limit 1
|
limit 1
|
||||||
</select>
|
</select>
|
||||||
<select id="selectDeptUser" resultType="java.lang.Long">
|
|
||||||
select user_id from sys_user where dept_id in (
|
|
||||||
<foreach collection="sectionIds" separator="," item="id">
|
|
||||||
#{id}
|
|
||||||
</foreach>
|
|
||||||
)
|
|
||||||
</select>
|
|
||||||
|
|
||||||
|
|
||||||
<insert id="insertUser" parameterType="com.muyu.common.system.domain.SysUser" useGeneratedKeys="true" keyProperty="userId">
|
<insert id="insertUser" parameterType="com.muyu.common.system.domain.SysUser" useGeneratedKeys="true" keyProperty="userId">
|
||||||
insert into sys_user(
|
insert into sys_user(
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
<module>muyu-job</module>
|
<module>muyu-job</module>
|
||||||
<module>muyu-file</module>
|
<module>muyu-file</module>
|
||||||
<module>muyu-data-source</module>
|
<module>muyu-data-source</module>
|
||||||
|
<module>muyu-rule_engine</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<artifactId>muyu-modules</artifactId>
|
<artifactId>muyu-modules</artifactId>
|
||||||
|
|
Loading…
Reference in New Issue