feat: 通用标准体系-增删改查

This commit is contained in:
2023-09-12 11:36:52 +08:00
parent f901fe8371
commit a66aac8deb
13 changed files with 679 additions and 455 deletions
@@ -26,4 +26,9 @@ public class FillRuleConstant {
*/
public static final String CATEGORY = "category_code_rule";
/**
* 体系字典编码
*/
public static final String SYSTEM = "system_tree_node";
}
@@ -60,4 +60,42 @@ public class FillRuleUtil {
}
return null;
}
/**
* @param ruleCode ruleCode
* @return
*/
@SuppressWarnings("unchecked")
public static Object executeRuleByParam(String ruleCode, JSONObject formData, String moduleCode) {
if (!StringUtils.isEmpty(ruleCode)) {
try {
// 获取 Service
ServiceImpl<BaseMapper<T>,T> impl = (ServiceImpl) SpringContextUtils.getBean("sysFillRuleServiceImpl");
// 根据 ruleCode 查询出实体
QueryWrapper<T> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("rule_code", ruleCode);
JSONObject entity = JSON.parseObject(JSON.toJSONString(impl.getOne(queryWrapper)));
if (entity == null) {
log.warn("填值规则:" + ruleCode + " 不存在");
return null;
}
// 获取必要的参数
String ruleClass = entity.getString("ruleClass");
JSONObject params = entity.getJSONObject("ruleParams");
if (params == null) {
params = new JSONObject();
}
if (formData == null) {
formData = new JSONObject();
}
params.put("moduleCode", moduleCode);
// 通过反射执行配置的类里的方法
IFillRuleHandler ruleHandler = (IFillRuleHandler) Class.forName(ruleClass).newInstance();
return ruleHandler.execute(params, formData);
} catch (Exception e) {
e.printStackTrace();
}
}
return null;
}
}