mirror of
https://github.com/dromara/RuoYi-Vue-Plus.git
synced 2025-09-24 07:19:46 +08:00
update 移除 fastjson 增加 jackson 工具类 重写相关业务
This commit is contained in:
@ -3,8 +3,6 @@ package com.ruoyi.generator.service;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.lang.Validator;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
@ -12,6 +10,7 @@ import com.ruoyi.common.constant.Constants;
|
||||
import com.ruoyi.common.constant.GenConstants;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.exception.CustomException;
|
||||
import com.ruoyi.common.utils.JsonUtils;
|
||||
import com.ruoyi.common.utils.PageUtils;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.common.utils.file.FileUtils;
|
||||
@ -130,7 +129,7 @@ public class GenTableServiceImpl extends ServiceImpl<GenTableMapper, GenTable> i
|
||||
@Override
|
||||
@Transactional
|
||||
public void updateGenTable(GenTable genTable) {
|
||||
String options = JSON.toJSONString(genTable.getParams());
|
||||
String options = JsonUtils.toJsonString(genTable.getParams());
|
||||
genTable.setOptions(options);
|
||||
int row = baseMapper.updateById(genTable);
|
||||
if (row > 0) {
|
||||
@ -361,13 +360,12 @@ public class GenTableServiceImpl extends ServiceImpl<GenTableMapper, GenTable> i
|
||||
@Override
|
||||
public void validateEdit(GenTable genTable) {
|
||||
if (GenConstants.TPL_TREE.equals(genTable.getTplCategory())) {
|
||||
String options = JSON.toJSONString(genTable.getParams());
|
||||
JSONObject paramsObj = JSONObject.parseObject(options);
|
||||
if (Validator.isEmpty(paramsObj.getString(GenConstants.TREE_CODE))) {
|
||||
Map<String, Object> paramsObj = genTable.getParams();
|
||||
if (Validator.isEmpty(paramsObj.get(GenConstants.TREE_CODE))) {
|
||||
throw new CustomException("树编码字段不能为空");
|
||||
} else if (Validator.isEmpty(paramsObj.getString(GenConstants.TREE_PARENT_CODE))) {
|
||||
} else if (Validator.isEmpty(paramsObj.get(GenConstants.TREE_PARENT_CODE))) {
|
||||
throw new CustomException("树父编码字段不能为空");
|
||||
} else if (Validator.isEmpty(paramsObj.getString(GenConstants.TREE_NAME))) {
|
||||
} else if (Validator.isEmpty(paramsObj.get(GenConstants.TREE_NAME))) {
|
||||
throw new CustomException("树名称字段不能为空");
|
||||
} else if (GenConstants.TPL_SUB.equals(genTable.getTplCategory())) {
|
||||
if (Validator.isEmpty(genTable.getSubTableName())) {
|
||||
@ -425,13 +423,13 @@ public class GenTableServiceImpl extends ServiceImpl<GenTableMapper, GenTable> i
|
||||
* @param genTable 设置后的生成对象
|
||||
*/
|
||||
public void setTableFromOptions(GenTable genTable) {
|
||||
JSONObject paramsObj = JSONObject.parseObject(genTable.getOptions());
|
||||
Map<String, String> paramsObj = JsonUtils.parseMap(genTable.getOptions());
|
||||
if (Validator.isNotNull(paramsObj)) {
|
||||
String treeCode = paramsObj.getString(GenConstants.TREE_CODE);
|
||||
String treeParentCode = paramsObj.getString(GenConstants.TREE_PARENT_CODE);
|
||||
String treeName = paramsObj.getString(GenConstants.TREE_NAME);
|
||||
String parentMenuId = paramsObj.getString(GenConstants.PARENT_MENU_ID);
|
||||
String parentMenuName = paramsObj.getString(GenConstants.PARENT_MENU_NAME);
|
||||
String treeCode = paramsObj.get(GenConstants.TREE_CODE);
|
||||
String treeParentCode = paramsObj.get(GenConstants.TREE_PARENT_CODE);
|
||||
String treeName = paramsObj.get(GenConstants.TREE_NAME);
|
||||
String parentMenuId = paramsObj.get(GenConstants.PARENT_MENU_ID);
|
||||
String parentMenuName = paramsObj.get(GenConstants.PARENT_MENU_NAME);
|
||||
|
||||
genTable.setTreeCode(treeCode);
|
||||
genTable.setTreeParentCode(treeParentCode);
|
||||
|
@ -1,10 +1,11 @@
|
||||
package com.ruoyi.generator.util;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.lang.Validator;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.ruoyi.common.constant.GenConstants;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.JsonUtils;
|
||||
import com.ruoyi.generator.domain.GenTable;
|
||||
import com.ruoyi.generator.domain.GenTableColumn;
|
||||
import org.apache.velocity.VelocityContext;
|
||||
@ -12,10 +13,11 @@ import org.apache.velocity.VelocityContext;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 模板处理工具类
|
||||
*
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class VelocityUtils
|
||||
@ -75,7 +77,7 @@ public class VelocityUtils
|
||||
public static void setMenuVelocityContext(VelocityContext context, GenTable genTable)
|
||||
{
|
||||
String options = genTable.getOptions();
|
||||
JSONObject paramsObj = JSONObject.parseObject(options);
|
||||
Map<String, Object> paramsObj = JsonUtils.parseMap(options);
|
||||
String parentMenuId = getParentMenuId(paramsObj);
|
||||
context.put("parentMenuId", parentMenuId);
|
||||
}
|
||||
@ -83,7 +85,7 @@ public class VelocityUtils
|
||||
public static void setTreeVelocityContext(VelocityContext context, GenTable genTable)
|
||||
{
|
||||
String options = genTable.getOptions();
|
||||
JSONObject paramsObj = JSONObject.parseObject(options);
|
||||
Map<String, Object> paramsObj = JsonUtils.parseMap(options);
|
||||
String treeCode = getTreecode(paramsObj);
|
||||
String treeParentCode = getTreeParentCode(paramsObj);
|
||||
String treeName = getTreeName(paramsObj);
|
||||
@ -94,11 +96,11 @@ public class VelocityUtils
|
||||
context.put("expandColumn", getExpandColumn(genTable));
|
||||
if (paramsObj.containsKey(GenConstants.TREE_PARENT_CODE))
|
||||
{
|
||||
context.put("tree_parent_code", paramsObj.getString(GenConstants.TREE_PARENT_CODE));
|
||||
context.put("tree_parent_code", paramsObj.get(GenConstants.TREE_PARENT_CODE));
|
||||
}
|
||||
if (paramsObj.containsKey(GenConstants.TREE_NAME))
|
||||
{
|
||||
context.put("tree_name", paramsObj.getString(GenConstants.TREE_NAME));
|
||||
context.put("tree_name", paramsObj.get(GenConstants.TREE_NAME));
|
||||
}
|
||||
}
|
||||
|
||||
@ -300,11 +302,11 @@ public class VelocityUtils
|
||||
* @param paramsObj 生成其他选项
|
||||
* @return 上级菜单ID字段
|
||||
*/
|
||||
public static String getParentMenuId(JSONObject paramsObj)
|
||||
public static String getParentMenuId(Map<String, Object> paramsObj)
|
||||
{
|
||||
if (Validator.isNotEmpty(paramsObj) && paramsObj.containsKey(GenConstants.PARENT_MENU_ID))
|
||||
{
|
||||
return paramsObj.getString(GenConstants.PARENT_MENU_ID);
|
||||
return Convert.toStr(paramsObj.get(GenConstants.PARENT_MENU_ID));
|
||||
}
|
||||
return DEFAULT_PARENT_MENU_ID;
|
||||
}
|
||||
@ -315,11 +317,11 @@ public class VelocityUtils
|
||||
* @param paramsObj 生成其他选项
|
||||
* @return 树编码
|
||||
*/
|
||||
public static String getTreecode(JSONObject paramsObj)
|
||||
public static String getTreecode(Map<String, Object> paramsObj)
|
||||
{
|
||||
if (paramsObj.containsKey(GenConstants.TREE_CODE))
|
||||
{
|
||||
return StrUtil.toCamelCase(paramsObj.getString(GenConstants.TREE_CODE));
|
||||
return StrUtil.toCamelCase(Convert.toStr(paramsObj.get(GenConstants.TREE_CODE)));
|
||||
}
|
||||
return StrUtil.EMPTY;
|
||||
}
|
||||
@ -330,11 +332,11 @@ public class VelocityUtils
|
||||
* @param paramsObj 生成其他选项
|
||||
* @return 树父编码
|
||||
*/
|
||||
public static String getTreeParentCode(JSONObject paramsObj)
|
||||
public static String getTreeParentCode(Map<String, Object> paramsObj)
|
||||
{
|
||||
if (paramsObj.containsKey(GenConstants.TREE_PARENT_CODE))
|
||||
{
|
||||
return StrUtil.toCamelCase(paramsObj.getString(GenConstants.TREE_PARENT_CODE));
|
||||
return StrUtil.toCamelCase(Convert.toStr(paramsObj.get(GenConstants.TREE_PARENT_CODE)));
|
||||
}
|
||||
return StrUtil.EMPTY;
|
||||
}
|
||||
@ -345,11 +347,11 @@ public class VelocityUtils
|
||||
* @param paramsObj 生成其他选项
|
||||
* @return 树名称
|
||||
*/
|
||||
public static String getTreeName(JSONObject paramsObj)
|
||||
public static String getTreeName(Map<String, Object> paramsObj)
|
||||
{
|
||||
if (paramsObj.containsKey(GenConstants.TREE_NAME))
|
||||
{
|
||||
return StrUtil.toCamelCase(paramsObj.getString(GenConstants.TREE_NAME));
|
||||
return StrUtil.toCamelCase(Convert.toStr(paramsObj.get(GenConstants.TREE_NAME)));
|
||||
}
|
||||
return StrUtil.EMPTY;
|
||||
}
|
||||
@ -363,8 +365,8 @@ public class VelocityUtils
|
||||
public static int getExpandColumn(GenTable genTable)
|
||||
{
|
||||
String options = genTable.getOptions();
|
||||
JSONObject paramsObj = JSONObject.parseObject(options);
|
||||
String treeName = paramsObj.getString(GenConstants.TREE_NAME);
|
||||
Map<String, String> paramsObj = JsonUtils.parseMap(options);
|
||||
String treeName = paramsObj.get(GenConstants.TREE_NAME);
|
||||
int num = 0;
|
||||
for (GenTableColumn column : genTable.getColumns())
|
||||
{
|
||||
|
Reference in New Issue
Block a user