feat: 数据授权
parent
e9fce2f45d
commit
9e1cb850df
|
@ -0,0 +1,82 @@
|
|||
package com.muyu.data.source.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import com.muyu.data.source.domain.req.AssetAuthInfoQueryReq;
|
||||
import com.muyu.data.source.domain.req.AssetAuthInfoSaveReq;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* 资产授权对象 AssetAuthInfo
|
||||
*
|
||||
* @author DeKangLiu
|
||||
* Date 2024/5/7 15:13
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@TableName(value = "asset_auth_info")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ApiModel(value = "AssetAuthInfo",description = "资产授权")
|
||||
public class AssetAuthInfo extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
/**授权主键*/
|
||||
@TableId(value = "id",type = IdType.AUTO)
|
||||
@ApiModelProperty(name = "授权主键", value = "授权主键")
|
||||
private Long id;
|
||||
|
||||
/**授权编号*/
|
||||
@ApiModelProperty(name = "授权编号", value = "授权编号")
|
||||
private Long authId;
|
||||
|
||||
/**编号类型*/
|
||||
@ApiModelProperty(name = "编号类型", value = "编号类型")
|
||||
private String idType;
|
||||
|
||||
/**授权数据*/
|
||||
@ApiModelProperty(name = "授权数据", value = "授权数据")
|
||||
private String authData;
|
||||
|
||||
/**授权类型*/
|
||||
@ApiModelProperty(name = "授权类型", value = "授权类型")
|
||||
private String authType;
|
||||
|
||||
|
||||
|
||||
public static AssetAuthInfo queryBuild( AssetAuthInfoQueryReq assetAuthInfoQueryReq) {
|
||||
return AssetAuthInfo.builder()
|
||||
.id(assetAuthInfoQueryReq.getAuthId())
|
||||
.authId(assetAuthInfoQueryReq.getAuthId())
|
||||
.idType(assetAuthInfoQueryReq.getIdType())
|
||||
.authData(assetAuthInfoQueryReq.getAuthData())
|
||||
.authType(assetAuthInfoQueryReq.getAuthType())
|
||||
.build();
|
||||
}
|
||||
|
||||
public static AssetAuthInfo saveBuild(AssetAuthInfoQueryReq assetAuthInfoQueryReq, Supplier<String> getUsername) {
|
||||
|
||||
return AssetAuthInfo.builder()
|
||||
.authId(assetAuthInfoQueryReq.getAuthId())
|
||||
.idType(assetAuthInfoQueryReq.getIdType())
|
||||
.authData(assetAuthInfoQueryReq.getAuthData())
|
||||
.authType(assetAuthInfoQueryReq.getAuthType())
|
||||
.createBy(getUsername.get())
|
||||
.createTime(new Date())
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
|
@ -55,5 +55,11 @@ public class DataBaseTable {
|
|||
/**信息表id*/
|
||||
private Integer informationId;
|
||||
|
||||
/**是否为字典*/
|
||||
private String isDict;
|
||||
|
||||
/**映射字典*/
|
||||
private String dictKey;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
package com.muyu.data.source.domain.req;
|
||||
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* 资产授权对象查询 AssetAuthInfoQueryReq
|
||||
*
|
||||
* @author DeKangLiu
|
||||
* Date 2024/5/7 15:24
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ApiModel(value = "AssetAuthInfoQueryReq", description = "资产授权")
|
||||
public class AssetAuthInfoQueryReq extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**授权编号*/
|
||||
@ApiModelProperty(name = "授权编号", value = "授权编号")
|
||||
private Long authId;
|
||||
|
||||
/**编号类型*/
|
||||
@ApiModelProperty(name = "编号类型", value = "编号类型")
|
||||
private String idType;
|
||||
|
||||
/**授权数据*/
|
||||
@ApiModelProperty(name = "授权数据", value = "授权数据")
|
||||
private String authData;
|
||||
|
||||
/**授权类型*/
|
||||
@ApiModelProperty(name = "授权类型", value = "授权类型")
|
||||
private String authType;
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
package com.muyu.data.source.domain.req;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* 资产授权对象添加 AssetAuthInfoSaveReq
|
||||
*
|
||||
* @author DeKangLiu
|
||||
* Date 2024/5/7 15:28
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ApiModel(value = "AssetAuthInfoSaveReq", description = "资产授权")
|
||||
public class AssetAuthInfoSaveReq {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
/**编号*/
|
||||
@ApiModelProperty(name = "授权编号", value = "授权编号")
|
||||
private Long id;
|
||||
|
||||
/**授权编号*/
|
||||
@ApiModelProperty(name = "授权编号", value = "授权编号")
|
||||
private Long authId;
|
||||
|
||||
/**编号类型*/
|
||||
@ApiModelProperty(name = "编号类型", value = "编号类型")
|
||||
private String idType;
|
||||
|
||||
/**授权数据*/
|
||||
@ApiModelProperty(name = "授权数据", value = "授权数据")
|
||||
private String authData;
|
||||
|
||||
/**授权类型*/
|
||||
@ApiModelProperty(name = "授权类型", value = "授权类型")
|
||||
private String authType;
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package com.muyu.data.source.controller;
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.web.controller.BaseController;
|
||||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
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.data.source.domain.AssetAuthInfo;
|
||||
import com.muyu.data.source.domain.req.AssetAuthInfoQueryReq;
|
||||
import com.muyu.data.source.service.AssetAuthInfoService;
|
||||
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层
|
||||
*
|
||||
* @ClassName AssetAuthInfoController
|
||||
* @Author AnNan.Wang
|
||||
* @Date 2024/5/5 15:38
|
||||
*/
|
||||
|
||||
@Api(tags = "资产授权")
|
||||
@RestController
|
||||
@RequestMapping("/auth")
|
||||
public class AssetAuthInfoController extends BaseController {
|
||||
@Autowired
|
||||
private AssetAuthInfoService assetAuthInfoService;
|
||||
|
||||
@ApiOperation("获取资产授权列表")
|
||||
@RequiresPermissions("source:auth:list")
|
||||
@GetMapping("/list")
|
||||
public Result<TableDataInfo<AssetAuthInfo>> list(AssetAuthInfoQueryReq assetAuthInfoQueryReq) {
|
||||
startPage();
|
||||
List<AssetAuthInfo> list = assetAuthInfoService.list(AssetAuthInfo.queryBuild(assetAuthInfoQueryReq));
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
@RequiresPermissions("source:auth:add")
|
||||
@Log(title = "资产授权", businessType = BusinessType.DELETE)
|
||||
@RequestMapping
|
||||
@ApiOperation("新增资产授权")
|
||||
public Result<String> add(@RequestBody AssetAuthInfoQueryReq assetAuthInfoQueryReq){
|
||||
return toAjax(assetAuthInfoService.save(AssetAuthInfo.saveBuild(assetAuthInfoQueryReq, SecurityUtils::getUsername)));
|
||||
}
|
||||
|
||||
@RequiresPermissions("source:auth:remove")
|
||||
@Log(title = "资产授权", businessType = BusinessType.DELETE)
|
||||
@PostMapping("/remove")
|
||||
@ApiOperation("删除资产授权")
|
||||
public Result<String> remove(@RequestBody AssetAuthInfoQueryReq assetAuthInfoQueryReq){
|
||||
return assetAuthInfoService.removeList(assetAuthInfoQueryReq);
|
||||
}
|
||||
}
|
|
@ -193,4 +193,9 @@ public class DataSourceController extends BaseController {
|
|||
public Result<List<DatabaseTableInformation>> dataBaseTableInformation(){
|
||||
return dataSourceService.dataBaseTableInformation();
|
||||
}
|
||||
|
||||
@PostMapping("/updateDatabaseTable")
|
||||
public Result updateDatabaseTable(@RequestBody DataBaseTable dataBaseTable){
|
||||
return dataSourceService.updateDatabaseTable(dataBaseTable);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
package com.muyu.data.source.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.muyu.data.source.domain.AssetAuthInfo;
|
||||
|
||||
/**
|
||||
* AssetAuthInfo 数据权限Mapper层接口
|
||||
*
|
||||
* @author AnNan.Wang
|
||||
* @ClassName: AssetAuthInfoMapper
|
||||
* @createTime: 2024/5/5 18:30
|
||||
*/
|
||||
public interface AssetAuthInfoMapper extends BaseMapper<AssetAuthInfo> {
|
||||
}
|
|
@ -48,6 +48,8 @@ public interface DataSourceMapper extends BaseMapper<DataSource> {
|
|||
|
||||
List<DatabaseTableInformation> dataBaseTableInformation();
|
||||
|
||||
Integer updateDatabaseTable(@Param("dataBaseTable") DataBaseTable dataBaseTable);
|
||||
|
||||
// AssetStructure findDatabaseName(DataSource dataSource);
|
||||
|
||||
// void updateAssets(@Param("assetStructure") AssetStructure assetStructure, @Param("id") Long id);
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
package com.muyu.data.source.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.data.source.domain.AssetAuthInfo;
|
||||
import com.muyu.data.source.domain.req.AssetAuthInfoQueryReq;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* AssetAuthInfo 资产授权 Service层接口
|
||||
*
|
||||
* @author AnNan.Wang
|
||||
* @ClassName: AssetAuthInfoService
|
||||
* @createTime: 2024/5/5 15:40
|
||||
*/
|
||||
public interface AssetAuthInfoService extends IService<AssetAuthInfo> {
|
||||
/**
|
||||
* 查询资产授权列表
|
||||
*
|
||||
* @param assetAuthInfo 资产授权
|
||||
* @return 资产授权集合
|
||||
*/
|
||||
public List<AssetAuthInfo> list(AssetAuthInfo assetAuthInfo);
|
||||
|
||||
Result<String> removeList(AssetAuthInfoQueryReq assetAuthInfoQueryReq);
|
||||
}
|
|
@ -44,4 +44,6 @@ public interface DataSourceService extends IService<DataSource> {
|
|||
Result<List<DataBaseTable>> findDataBaseByInformationId(Integer id);
|
||||
|
||||
Result<List<DatabaseTableInformation>> dataBaseTableInformation();
|
||||
|
||||
Result updateDatabaseTable(DataBaseTable dataBaseTable);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
package com.muyu.data.source.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.exception.ServiceException;
|
||||
import com.muyu.data.source.domain.AssetAuthInfo;
|
||||
import com.muyu.data.source.domain.req.AssetAuthInfoQueryReq;
|
||||
import com.muyu.data.source.mapper.AssetAuthInfoMapper;
|
||||
import com.muyu.data.source.service.AssetAuthInfoService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* AssetAuthInfo 资产授权Impl实现层
|
||||
*
|
||||
* @ClassName AssetAuthInfoServiceImpl
|
||||
* @Author AnNan.Wang
|
||||
* @Date 2024/5/5 18:29
|
||||
*/
|
||||
|
||||
@Service
|
||||
public class AssetAuthInfoServiceImpl extends ServiceImpl<AssetAuthInfoMapper, AssetAuthInfo>
|
||||
implements AssetAuthInfoService{
|
||||
@Autowired
|
||||
private AssetAuthInfoMapper assetAuthInfoMapper;
|
||||
|
||||
@Override
|
||||
public List<AssetAuthInfo> list(AssetAuthInfo assetAuthInfo) {
|
||||
if (Objects.isNull(assetAuthInfo.getIdType())){
|
||||
throw new ServiceException("id类型不能为空");
|
||||
}
|
||||
if (Objects.isNull(assetAuthInfo.getAuthType())){
|
||||
throw new ServiceException("授权类型不能为空");
|
||||
}
|
||||
|
||||
return list(new LambdaQueryWrapper<AssetAuthInfo>()
|
||||
.eq(AssetAuthInfo::getIdType, assetAuthInfo.getIdType())
|
||||
.eq(AssetAuthInfo::getAuthType, assetAuthInfo.getAuthType()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<String> removeList(AssetAuthInfoQueryReq assetAuthInfoQueryReq) {
|
||||
int delete = assetAuthInfoMapper.delete(
|
||||
new LambdaQueryWrapper<AssetAuthInfo>() {{
|
||||
eq(AssetAuthInfo::getAuthId, assetAuthInfoQueryReq.getAuthId());
|
||||
eq(AssetAuthInfo::getIdType, assetAuthInfoQueryReq.getIdType());
|
||||
eq(AssetAuthInfo::getAuthData, assetAuthInfoQueryReq.getAuthData());
|
||||
eq(AssetAuthInfo::getAuthType, assetAuthInfoQueryReq.getAuthType());
|
||||
}}
|
||||
);
|
||||
if (delete>0) {
|
||||
return Result.success("删除成功");
|
||||
}else {
|
||||
return Result.success("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -316,5 +316,11 @@ public class DataSourceServiceImpl extends ServiceImpl<DataSourceMapper, DataSou
|
|||
return Result.success(databaseTableInformationList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result updateDatabaseTable(DataBaseTable dataBaseTable) {
|
||||
Integer integer = dataSourceMapper.updateDatabaseTable(dataBaseTable);
|
||||
return Result.success("修改成功");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ public class DictionaryServiceImpl implements DictionaryService {
|
|||
.map(dictionaryType -> {
|
||||
List<DictionaryData> dictionaryDataList = dictionaryMapper.selectDictionaryDataByType(dictionaryType.getDictionaryType());
|
||||
DictionaryType build = DictionaryType.builder()
|
||||
.id(dictionaryType.getId())
|
||||
.dictionaryDataList(dictionaryDataList)
|
||||
.dictionaryType(dictionaryType.getDictionaryType())
|
||||
.dictionaryName(dictionaryType.getDictionaryName())
|
||||
|
|
|
@ -109,6 +109,25 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
<update id="updateDatabaseTable">
|
||||
UPDATE `data_management`.`database_table` SET
|
||||
`tableName` = #{dataBaseTable.tableName},
|
||||
`name` = #{dataBaseTable.name},
|
||||
`comment` = #{dataBaseTable.comment},
|
||||
`isPrimaryKey` = #{dataBaseTable.isPrimaryKey},
|
||||
`type` = #{dataBaseTable.type},
|
||||
`detailType` = #{dataBaseTable.detailType},
|
||||
`length` = #{dataBaseTable.length},
|
||||
`decimalPlaces` = #{dataBaseTable.decimalPlaces},
|
||||
`isNull` = #{dataBaseTable.isNull},
|
||||
`defaultValue` = #{dataBaseTable.defaultValue},
|
||||
`information_id` = #{dataBaseTable.informationId},
|
||||
`is_dict`=#{dataBaseTable.isDict},
|
||||
`dict_key`=#{dataBaseTable.dictKey}
|
||||
|
||||
WHERE id = #{dataBaseTable.id}
|
||||
|
||||
</update>
|
||||
<!-- <update id="updateAssets">-->
|
||||
<!-- UPDATE `data_management`.`asset_structure` SET-->
|
||||
<!-- `access_source_name` = #{assetStructure.accessSourceName},-->
|
||||
|
|
|
@ -1,97 +0,0 @@
|
|||
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();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,119 +0,0 @@
|
|||
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();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
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;
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
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;
|
||||
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
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;
|
||||
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
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;
|
||||
|
||||
}
|
|
@ -1,49 +0,0 @@
|
|||
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;
|
||||
|
||||
}
|
|
@ -1,49 +0,0 @@
|
|||
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;
|
||||
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
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;
|
||||
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
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;
|
||||
}
|
|
@ -1,111 +0,0 @@
|
|||
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));
|
||||
}
|
||||
|
||||
}
|
|
@ -1,112 +0,0 @@
|
|||
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));
|
||||
}
|
||||
}
|
|
@ -1,78 +0,0 @@
|
|||
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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,143 +0,0 @@
|
|||
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");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
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> {
|
||||
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
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> {
|
||||
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
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);
|
||||
}
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
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);
|
||||
}
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
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);
|
||||
}
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
package com.muyu.ruleEngine.scope;
|
||||
|
||||
/**
|
||||
* 任务上下文
|
||||
* @ClassName TaskContextHolder
|
||||
* @Author DeKangLiu
|
||||
* @Version: 1.0
|
||||
*/
|
||||
public class TaskContextHolder {
|
||||
|
||||
public static TaskContextHolder build(){
|
||||
return new TaskContextHolder();
|
||||
}
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author DeKangLiu
|
||||
*/
|
||||
public class TestClass {
|
||||
public String ruleTest(List<String> list) {
|
||||
|
||||
}
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
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);
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
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);
|
||||
}
|
|
@ -1,161 +0,0 @@
|
|||
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;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,105 +0,0 @@
|
|||
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;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
Spring Boot Version: ${spring-boot.version}
|
||||
Spring Application Name: ${spring.application.name}
|
||||
__ .__ .__
|
||||
____ _/ |_ | | _______ __ __ ____ ___.__.|__|
|
||||
/ ___\ \ __\| | ______ \_ __ \| | \ / _ \ < | || |
|
||||
/ /_/ > | | | |__ /_____/ | | \/| | /( <_> ) \___ || |
|
||||
\___ / |__| |____/ |__| |____/ \____/ / ____||__|
|
||||
/_____/ \/
|
|
@ -1,26 +0,0 @@
|
|||
<?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>
|
|
@ -5,21 +5,18 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-rule_engine</artifactId>
|
||||
<artifactId>muyu-ruleengine</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>
|
||||
<artifactId>muyu-ruleengine-common</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<!-- MuYu Common Core-->
|
||||
<!-- 系统公共核心包 -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-core</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -5,28 +5,39 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-rule_engine</artifactId>
|
||||
<artifactId>muyu-ruleengine</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>muyu-rule_engine-server</artifactId>
|
||||
<artifactId>muyu-ruleengine-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>
|
||||
<artifactId>muyu-ruleengine-common</artifactId>
|
||||
<version>${muyu.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-core</artifactId>
|
||||
</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>
|
||||
|
@ -82,12 +93,6 @@
|
|||
<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>
|
||||
|
@ -112,13 +117,7 @@
|
|||
<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>
|
|
@ -1,23 +1,26 @@
|
|||
package com.muyu.ruleEngine;
|
||||
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;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
|
||||
/**
|
||||
* rule_engine服务模块
|
||||
* MuYuRuleEngineApplication
|
||||
*
|
||||
* @author DeKangLiu
|
||||
* @author WangLei
|
||||
* @Date 2024/4/24 024 10:07
|
||||
*/
|
||||
@EnableCustomConfig
|
||||
@EnableCustomSwagger2
|
||||
@EnableMyFeignClients
|
||||
@SpringBootApplication
|
||||
@EnableAsync
|
||||
public class MuYuRuleEngineApplication {
|
||||
public static void main (String[] args) {
|
||||
|
||||
SpringApplication.run(MuYuRuleEngineApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
Spring Boot Version: ${spring-boot.version}
|
||||
Spring Application Name: ${spring.application.name}
|
|
@ -1,12 +1,12 @@
|
|||
# Tomcat
|
||||
server:
|
||||
port: 9205
|
||||
port: 9216
|
||||
|
||||
# Spring
|
||||
spring:
|
||||
application:
|
||||
# 应用名称
|
||||
name: muyu-rule-engine
|
||||
name: muyu-ruleengine
|
||||
profiles:
|
||||
# 环境配置
|
||||
active: dev
|
||||
|
@ -15,6 +15,7 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 115.159.81.159:8848
|
||||
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 115.159.81.159:8848
|
||||
|
@ -26,4 +27,4 @@ spring:
|
|||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||
logging:
|
||||
level:
|
||||
com.muyu.ruleEngine.mapper: DEBUG
|
||||
com.muyu.system.mapper: DEBUG
|
|
@ -1,7 +1,7 @@
|
|||
<?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.path" value="logs/muyu-system"/>
|
||||
<!-- 日志输出格式 -->
|
||||
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
|
||||
|
|
@ -5,15 +5,19 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-rule_engine</artifactId>
|
||||
<artifactId>muyu-modules</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>
|
||||
<artifactId>muyu-ruleengine</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<description>
|
||||
muyu-ruleengine规则引擎
|
||||
</description>
|
||||
<modules>
|
||||
<module>muyu-ruleengine-common</module>
|
||||
<module>muyu-ruleengine-server</module>
|
||||
</modules>
|
||||
|
||||
</project>
|
|
@ -14,7 +14,7 @@
|
|||
<module>muyu-job</module>
|
||||
<module>muyu-file</module>
|
||||
<module>muyu-data-source</module>
|
||||
<module>muyu-rule_engine</module>
|
||||
<module>muyu-ruleengine</module>
|
||||
</modules>
|
||||
|
||||
<artifactId>muyu-modules</artifactId>
|
||||
|
|
Loading…
Reference in New Issue