11111
parent
c79f4f974f
commit
ee7ae4ff9a
|
@ -15,6 +15,7 @@ import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author:张承志
|
* @Author:张承志
|
||||||
|
@ -107,32 +108,22 @@ public class RuleEngineVersionController {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@PostMapping("/deposit/{type}")
|
@PostMapping("/deposit/{type}")
|
||||||
public Result deposit(@PathVariable("type")Integer type,@Validated @RequestBody VersionAddReq versionAddReq){
|
public Result deposit(@PathVariable("type") Integer type,
|
||||||
|
@Validated @RequestBody VersionAddReq versionAddReq) {
|
||||||
log.info("传入参数{}"+type);
|
|
||||||
|
|
||||||
//String versionClass = versionService.deposit(type);
|
|
||||||
|
|
||||||
versionAddReq.setVersionClazz("");
|
|
||||||
String parentClass = null;
|
|
||||||
if (type==1){
|
|
||||||
parentClass = "DataEngineValueActuator";
|
|
||||||
}else if (type==2){
|
|
||||||
parentClass="DataEngineRowActuator";
|
|
||||||
}else if (type==3){
|
|
||||||
parentClass="DataEngineDataSetActuator";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
log.info("传入参数{}", type);
|
||||||
|
|
||||||
|
// 根据类型确定父类
|
||||||
|
String parentClass = determineParentClass(type);
|
||||||
|
|
||||||
|
// 定义模板字符串
|
||||||
String template = "package com.muyu.rule.common.engine;\n" +
|
String template = "package com.muyu.rule.common.engine;\n" +
|
||||||
"\n" +
|
"\n" +
|
||||||
"import cn.hutool.core.util.DesensitizedUtil;\n" +
|
"import cn.hutool.core.util.DesensitizedUtil;\n" +
|
||||||
"import com.alibaba.fastjson2.JSON;\n" +
|
"import com.alibaba.fastjson2.JSON;\n" +
|
||||||
"import com.alibaba.fastjson2.JSONObject;\n" +
|
"import com.alibaba.fastjson2.JSONObject;\n" +
|
||||||
"import com.muyu.common.domain.DataValue;\n" +
|
"import com.muyu.common.domain.DataValue;\n" +
|
||||||
"import com.muyu.rule.common.basic.abstracts.${parentClass};\n" +
|
"import com.muyu.rule.common.basic.abstracts." + parentClass + ";\n" +
|
||||||
"\n" +
|
"\n" +
|
||||||
"\n" +
|
"\n" +
|
||||||
"/**\n" +
|
"/**\n" +
|
||||||
|
@ -143,7 +134,7 @@ public class RuleEngineVersionController {
|
||||||
" * @Date:2024/8/30 11:13\n" +
|
" * @Date:2024/8/30 11:13\n" +
|
||||||
" */\n" +
|
" */\n" +
|
||||||
"\n" +
|
"\n" +
|
||||||
"public class ${className} extends ${parentClass} {\n" +
|
"public class ${className} extends " + parentClass + " {\n" +
|
||||||
"\n" +
|
"\n" +
|
||||||
" @Override\n" +
|
" @Override\n" +
|
||||||
" public void run() {\n" +
|
" public void run() {\n" +
|
||||||
|
@ -158,7 +149,7 @@ public class RuleEngineVersionController {
|
||||||
"\n" +
|
"\n" +
|
||||||
" for (DataValue[] value : dataValues) {\n" +
|
" for (DataValue[] value : dataValues) {\n" +
|
||||||
" for (DataValue dataValue1 : value) {\n" +
|
" for (DataValue dataValue1 : value) {\n" +
|
||||||
" if (dataValue1.getKey().equals(key)){\n" +
|
" if (dataValue1.getKey().equals(key)) {\n" +
|
||||||
" dataValue1.setValue(DesensitizedUtil.mobilePhone((String) dataValue1.getValue()));\n" +
|
" dataValue1.setValue(DesensitizedUtil.mobilePhone((String) dataValue1.getValue()));\n" +
|
||||||
" }\n" +
|
" }\n" +
|
||||||
" }\n" +
|
" }\n" +
|
||||||
|
@ -168,15 +159,110 @@ public class RuleEngineVersionController {
|
||||||
" }\n" +
|
" }\n" +
|
||||||
"}\n";
|
"}\n";
|
||||||
|
|
||||||
String versionClass = template.replace("${className}", versionAddReq.getClassName());
|
// 使用Map进行模板替换
|
||||||
versionClass = template.replace("${parentClass}",parentClass);
|
Map<String, String> replacements = Map.of(
|
||||||
|
"${className}", versionAddReq.getClassName(),
|
||||||
|
"${parentClass}", parentClass
|
||||||
|
);
|
||||||
|
|
||||||
|
// 替换模板中的变量
|
||||||
|
String versionClass = replacePlaceholders(template, replacements);
|
||||||
|
|
||||||
versionAddReq.setVersionClazz(versionClass);
|
versionAddReq.setVersionClazz(versionClass);
|
||||||
|
|
||||||
|
|
||||||
return Result.success(versionAddReq);
|
return Result.success(versionAddReq);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 辅助方法用于根据类型决定父类
|
||||||
|
private String determineParentClass(Integer type) {
|
||||||
|
switch (type) {
|
||||||
|
case 1:
|
||||||
|
return "DataEngineValueActuator";
|
||||||
|
case 2:
|
||||||
|
return "DataEngineRowActuator";
|
||||||
|
case 3:
|
||||||
|
return "DataEngineDataSetActuator";
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException("Invalid type provided");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 辅助方法用于替换模板中的占位符
|
||||||
|
private String replacePlaceholders(String template, Map<String, String> replacements) {
|
||||||
|
for (Map.Entry<String, String> entry : replacements.entrySet()) {
|
||||||
|
template = template.replace(entry.getKey(), entry.getValue());
|
||||||
|
}
|
||||||
|
return template;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// @PostMapping("/deposit/{type}")
|
||||||
|
// public Result deposit(@PathVariable("type")Integer type,@Validated @RequestBody VersionAddReq versionAddReq){
|
||||||
|
//
|
||||||
|
// log.info("传入参数{}"+type);
|
||||||
|
//
|
||||||
|
// //String versionClass = versionService.deposit(type);
|
||||||
|
//
|
||||||
|
// String parentClass = null;
|
||||||
|
// if (type==1){
|
||||||
|
// parentClass = "DataEngineValueActuator";
|
||||||
|
// }else if (type==2){
|
||||||
|
// parentClass="DataEngineRowActuator";
|
||||||
|
// }else if (type==3){
|
||||||
|
// parentClass="DataEngineDataSetActuator";
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// String template = "package com.muyu.rule.common.engine;\n" +
|
||||||
|
// "\n" +
|
||||||
|
// "import cn.hutool.core.util.DesensitizedUtil;\n" +
|
||||||
|
// "import com.alibaba.fastjson2.JSON;\n" +
|
||||||
|
// "import com.alibaba.fastjson2.JSONObject;\n" +
|
||||||
|
// "import com.muyu.common.domain.DataValue;\n" +
|
||||||
|
// "import com.muyu.rule.common.basic.abstracts.${parentClass};\n" +
|
||||||
|
// "\n" +
|
||||||
|
// "\n" +
|
||||||
|
// "/**\n" +
|
||||||
|
// " * @Author:张承志\n" +
|
||||||
|
// " * @Package:com.muyu.rule.server.basic.engine.row\n" +
|
||||||
|
// " * @Project:cloud-etl-rule\n" +
|
||||||
|
// " * @name:数据集指定字段进行脱敏\n" +
|
||||||
|
// " * @Date:2024/8/30 11:13\n" +
|
||||||
|
// " */\n" +
|
||||||
|
// "\n" +
|
||||||
|
// "public class ${className} extends ${parentClass} {\n" +
|
||||||
|
// "\n" +
|
||||||
|
// " @Override\n" +
|
||||||
|
// " public void run() {\n" +
|
||||||
|
// "\n" +
|
||||||
|
// " DataValue[][] dataValues = get();\n" +
|
||||||
|
// "\n" +
|
||||||
|
// " String dataValue = getDataValue();\n" +
|
||||||
|
// "\n" +
|
||||||
|
// " JSONObject jsonObject = JSON.parseObject(dataValue);\n" +
|
||||||
|
// "\n" +
|
||||||
|
// " String key = (String)jsonObject.get(\"key\");\n" +
|
||||||
|
// "\n" +
|
||||||
|
// " for (DataValue[] value : dataValues) {\n" +
|
||||||
|
// " for (DataValue dataValue1 : value) {\n" +
|
||||||
|
// " if (dataValue1.getKey().equals(key)){\n" +
|
||||||
|
// " dataValue1.setValue(DesensitizedUtil.mobilePhone((String) dataValue1.getValue()));\n" +
|
||||||
|
// " }\n" +
|
||||||
|
// " }\n" +
|
||||||
|
// " }\n" +
|
||||||
|
// " set(dataValues);\n" +
|
||||||
|
// "\n" +
|
||||||
|
// " }\n" +
|
||||||
|
// "}\n";
|
||||||
|
//
|
||||||
|
// String versionClass = template.replace("${className}", versionAddReq.getClassName());
|
||||||
|
// versionClass = template.replace("${parentClass}",parentClass);
|
||||||
|
//
|
||||||
|
// versionAddReq.setVersionClazz(versionClass);
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// return Result.success(versionAddReq);
|
||||||
|
// }
|
||||||
|
|
||||||
@PostMapping("/readByOss/{className}")
|
@PostMapping("/readByOss/{className}")
|
||||||
@Operation(summary = "从Oss获取数据", description = "传入参数oss的key名从oss读取数据")
|
@Operation(summary = "从Oss获取数据", description = "传入参数oss的key名从oss读取数据")
|
||||||
public Result readByOss(@PathVariable String className){
|
public Result readByOss(@PathVariable String className){
|
||||||
|
|
Loading…
Reference in New Issue