update 删除通用工具 改为使用hutool

This commit is contained in:
疯狂的狮子li
2021-03-15 16:38:43 +08:00
parent 46aa17db9c
commit 9b4b9e0c74
73 changed files with 720 additions and 3681 deletions

View File

@ -21,7 +21,7 @@ import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.text.Convert;
import cn.hutool.core.convert.Convert;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.generator.domain.GenTable;
import com.ruoyi.generator.domain.GenTableColumn;

View File

@ -1,12 +1,13 @@
package com.ruoyi.generator.domain;
import java.util.List;
import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import org.apache.commons.lang3.ArrayUtils;
import cn.hutool.core.util.StrUtil;
import com.ruoyi.common.constant.GenConstants;
import com.ruoyi.common.core.domain.BaseEntity;
import com.ruoyi.common.utils.StringUtils;
import org.apache.commons.lang3.ArrayUtils;
import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import java.util.List;
/**
* 业务表 gen_table
@ -332,7 +333,7 @@ public class GenTable extends BaseEntity
public static boolean isSub(String tplCategory)
{
return tplCategory != null && StringUtils.equals(GenConstants.TPL_SUB, tplCategory);
return tplCategory != null && StrUtil.equals(GenConstants.TPL_SUB, tplCategory);
}
public boolean isTree()
@ -342,7 +343,7 @@ public class GenTable extends BaseEntity
public static boolean isTree(String tplCategory)
{
return tplCategory != null && StringUtils.equals(GenConstants.TPL_TREE, tplCategory);
return tplCategory != null && StrUtil.equals(GenConstants.TPL_TREE, tplCategory);
}
public boolean isCrud()
@ -352,7 +353,7 @@ public class GenTable extends BaseEntity
public static boolean isCrud(String tplCategory)
{
return tplCategory != null && StringUtils.equals(GenConstants.TPL_CRUD, tplCategory);
return tplCategory != null && StrUtil.equals(GenConstants.TPL_CRUD, tplCategory);
}
public boolean isSuperColumn(String javaField)
@ -364,9 +365,9 @@ public class GenTable extends BaseEntity
{
if (isTree(tplCategory))
{
return StringUtils.equalsAnyIgnoreCase(javaField,
return StrUtil.equalsAnyIgnoreCase(javaField,
ArrayUtils.addAll(GenConstants.TREE_ENTITY, GenConstants.BASE_ENTITY));
}
return StringUtils.equalsAnyIgnoreCase(javaField, GenConstants.BASE_ENTITY);
return StrUtil.equalsAnyIgnoreCase(javaField, GenConstants.BASE_ENTITY);
}
}

View File

@ -1,8 +1,9 @@
package com.ruoyi.generator.domain;
import javax.validation.constraints.NotBlank;
import cn.hutool.core.util.StrUtil;
import com.ruoyi.common.core.domain.BaseEntity;
import com.ruoyi.common.utils.StringUtils;
import javax.validation.constraints.NotBlank;
/**
* 代码生成业务字段表 gen_table_column
@ -140,7 +141,7 @@ public class GenTableColumn extends BaseEntity
public String getCapJavaField()
{
return StringUtils.capitalize(javaField);
return StrUtil.upperFirst(javaField);
}
public void setIsPk(String isPk)
@ -160,7 +161,7 @@ public class GenTableColumn extends BaseEntity
public boolean isPk(String isPk)
{
return isPk != null && StringUtils.equals("1", isPk);
return isPk != null && StrUtil.equals("1", isPk);
}
public String getIsIncrement()
@ -180,7 +181,7 @@ public class GenTableColumn extends BaseEntity
public boolean isIncrement(String isIncrement)
{
return isIncrement != null && StringUtils.equals("1", isIncrement);
return isIncrement != null && StrUtil.equals("1", isIncrement);
}
public void setIsRequired(String isRequired)
@ -200,7 +201,7 @@ public class GenTableColumn extends BaseEntity
public boolean isRequired(String isRequired)
{
return isRequired != null && StringUtils.equals("1", isRequired);
return isRequired != null && StrUtil.equals("1", isRequired);
}
public void setIsInsert(String isInsert)
@ -220,7 +221,7 @@ public class GenTableColumn extends BaseEntity
public boolean isInsert(String isInsert)
{
return isInsert != null && StringUtils.equals("1", isInsert);
return isInsert != null && StrUtil.equals("1", isInsert);
}
public void setIsEdit(String isEdit)
@ -240,7 +241,7 @@ public class GenTableColumn extends BaseEntity
public boolean isEdit(String isEdit)
{
return isEdit != null && StringUtils.equals("1", isEdit);
return isEdit != null && StrUtil.equals("1", isEdit);
}
public void setIsList(String isList)
@ -260,7 +261,7 @@ public class GenTableColumn extends BaseEntity
public boolean isList(String isList)
{
return isList != null && StringUtils.equals("1", isList);
return isList != null && StrUtil.equals("1", isList);
}
public void setIsQuery(String isQuery)
@ -280,7 +281,7 @@ public class GenTableColumn extends BaseEntity
public boolean isQuery(String isQuery)
{
return isQuery != null && StringUtils.equals("1", isQuery);
return isQuery != null && StrUtil.equals("1", isQuery);
}
public void setQueryType(String queryType)
@ -330,7 +331,7 @@ public class GenTableColumn extends BaseEntity
public static boolean isSuperColumn(String javaField)
{
return StringUtils.equalsAnyIgnoreCase(javaField,
return StrUtil.equalsAnyIgnoreCase(javaField,
// BaseEntity
"createBy", "createTime", "updateBy", "updateTime", "remark",
// TreeEntity
@ -345,18 +346,18 @@ public class GenTableColumn extends BaseEntity
public static boolean isUsableColumn(String javaField)
{
// isSuperColumn()中的名单用于避免生成多余Domain属性若某些属性在生成页面时需要用到不能忽略则放在此处白名单
return StringUtils.equalsAnyIgnoreCase(javaField, "parentId", "orderNum", "remark");
return StrUtil.equalsAnyIgnoreCase(javaField, "parentId", "orderNum", "remark");
}
public String readConverterExp()
{
String remarks = StringUtils.substringBetween(this.columnComment, "", "");
String remarks = StrUtil.subBetween(this.columnComment, "", "");
StringBuffer sb = new StringBuffer();
if (StringUtils.isNotEmpty(remarks))
if (StrUtil.isNotEmpty(remarks))
{
for (String value : remarks.split(" "))
{
if (StringUtils.isNotEmpty(value))
if (StrUtil.isNotEmpty(value))
{
Object startStr = value.subSequence(0, 1);
String endStr = value.substring(1);

View File

@ -3,7 +3,7 @@ package com.ruoyi.generator.service;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.common.core.text.Convert;
import cn.hutool.core.convert.Convert;
import com.ruoyi.generator.domain.GenTableColumn;
import com.ruoyi.generator.mapper.GenTableColumnMapper;

View File

@ -1,5 +1,31 @@
package com.ruoyi.generator.service;
import cn.hutool.core.lang.Validator;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.constant.GenConstants;
import com.ruoyi.common.exception.CustomException;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.file.FileUtils;
import com.ruoyi.generator.domain.GenTable;
import com.ruoyi.generator.domain.GenTableColumn;
import com.ruoyi.generator.mapper.GenTableColumnMapper;
import com.ruoyi.generator.mapper.GenTableMapper;
import com.ruoyi.generator.util.GenUtils;
import com.ruoyi.generator.util.VelocityInitializer;
import com.ruoyi.generator.util.VelocityUtils;
import org.apache.commons.io.IOUtils;
import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.Velocity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
@ -10,31 +36,6 @@ import java.util.Map;
import java.util.stream.Collectors;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import org.apache.commons.io.IOUtils;
import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.Velocity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.constant.GenConstants;
import com.ruoyi.common.core.text.CharsetKit;
import com.ruoyi.common.exception.CustomException;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.file.FileUtils;
import com.ruoyi.generator.domain.GenTable;
import com.ruoyi.generator.domain.GenTableColumn;
import com.ruoyi.generator.mapper.GenTableColumnMapper;
import com.ruoyi.generator.mapper.GenTableMapper;
import com.ruoyi.generator.util.GenUtils;
import com.ruoyi.generator.util.VelocityInitializer;
import com.ruoyi.generator.util.VelocityUtils;
/**
* 业务 服务层实现
@ -256,7 +257,7 @@ public class GenTableServiceImpl implements IGenTableService
List<String> templates = VelocityUtils.getTemplateList(table.getTplCategory());
for (String template : templates)
{
if (!StringUtils.containsAny(template, "sql.vm", "api.js.vm", "index.vue.vm", "index-tree.vue.vm"))
if (!StrUtil.containsAny(template, "sql.vm", "api.js.vm", "index.vue.vm", "index-tree.vue.vm"))
{
// 渲染模板
StringWriter sw = new StringWriter();
@ -265,7 +266,7 @@ public class GenTableServiceImpl implements IGenTableService
try
{
String path = getGenPath(table, template);
FileUtils.writeStringToFile(new File(path), sw.toString(), CharsetKit.UTF_8);
FileUtils.writeStringToFile(new File(path), sw.toString(), Constants.UTF8);
}
catch (IOException e)
{
@ -289,7 +290,7 @@ public class GenTableServiceImpl implements IGenTableService
List<String> tableColumnNames = tableColumns.stream().map(GenTableColumn::getColumnName).collect(Collectors.toList());
List<GenTableColumn> dbTableColumns = genTableColumnMapper.selectDbTableColumnsByName(tableName);
if (StringUtils.isEmpty(dbTableColumns))
if (Validator.isEmpty(dbTableColumns))
{
throw new CustomException("同步数据失败,原表结构不存在");
}
@ -304,7 +305,7 @@ public class GenTableServiceImpl implements IGenTableService
});
List<GenTableColumn> delColumns = tableColumns.stream().filter(column -> !dbTableColumnNames.contains(column.getColumnName())).collect(Collectors.toList());
if (StringUtils.isNotEmpty(delColumns))
if (Validator.isNotEmpty(delColumns))
{
genTableColumnMapper.deleteGenTableColumns(delColumns);
}
@ -381,25 +382,25 @@ public class GenTableServiceImpl implements IGenTableService
{
String options = JSON.toJSONString(genTable.getParams());
JSONObject paramsObj = JSONObject.parseObject(options);
if (StringUtils.isEmpty(paramsObj.getString(GenConstants.TREE_CODE)))
if (Validator.isEmpty(paramsObj.getString(GenConstants.TREE_CODE)))
{
throw new CustomException("树编码字段不能为空");
}
else if (StringUtils.isEmpty(paramsObj.getString(GenConstants.TREE_PARENT_CODE)))
else if (Validator.isEmpty(paramsObj.getString(GenConstants.TREE_PARENT_CODE)))
{
throw new CustomException("树父编码字段不能为空");
}
else if (StringUtils.isEmpty(paramsObj.getString(GenConstants.TREE_NAME)))
else if (Validator.isEmpty(paramsObj.getString(GenConstants.TREE_NAME)))
{
throw new CustomException("树名称字段不能为空");
}
else if (GenConstants.TPL_SUB.equals(genTable.getTplCategory()))
{
if (StringUtils.isEmpty(genTable.getSubTableName()))
if (Validator.isEmpty(genTable.getSubTableName()))
{
throw new CustomException("关联子表的表名不能为空");
}
else if (StringUtils.isEmpty(genTable.getSubTableFkName()))
else if (Validator.isEmpty(genTable.getSubTableFkName()))
{
throw new CustomException("子表关联的外键名不能为空");
}
@ -422,7 +423,7 @@ public class GenTableServiceImpl implements IGenTableService
break;
}
}
if (StringUtils.isNull(table.getPkColumn()))
if (Validator.isNull(table.getPkColumn()))
{
table.setPkColumn(table.getColumns().get(0));
}
@ -436,7 +437,7 @@ public class GenTableServiceImpl implements IGenTableService
break;
}
}
if (StringUtils.isNull(table.getSubTable().getPkColumn()))
if (Validator.isNull(table.getSubTable().getPkColumn()))
{
table.getSubTable().setPkColumn(table.getSubTable().getColumns().get(0));
}
@ -451,7 +452,7 @@ public class GenTableServiceImpl implements IGenTableService
public void setSubTable(GenTable table)
{
String subTableName = table.getSubTableName();
if (StringUtils.isNotEmpty(subTableName))
if (Validator.isNotEmpty(subTableName))
{
table.setSubTable(genTableMapper.selectGenTableByName(subTableName));
}
@ -465,7 +466,7 @@ public class GenTableServiceImpl implements IGenTableService
public void setTableFromOptions(GenTable genTable)
{
JSONObject paramsObj = JSONObject.parseObject(genTable.getOptions());
if (StringUtils.isNotNull(paramsObj))
if (Validator.isNotNull(paramsObj))
{
String treeCode = paramsObj.getString(GenConstants.TREE_CODE);
String treeParentCode = paramsObj.getString(GenConstants.TREE_PARENT_CODE);
@ -491,7 +492,7 @@ public class GenTableServiceImpl implements IGenTableService
public static String getGenPath(GenTable table, String template)
{
String genPath = table.getGenPath();
if (StringUtils.equals(genPath, "/"))
if (StrUtil.equals(genPath, "/"))
{
return System.getProperty("user.dir") + File.separator + "src" + File.separator + VelocityUtils.getFileName(template, table);
}

View File

@ -1,12 +1,13 @@
package com.ruoyi.generator.util;
import java.util.Arrays;
import org.apache.commons.lang3.RegExUtils;
import cn.hutool.core.util.StrUtil;
import com.ruoyi.common.constant.GenConstants;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.generator.config.GenConfig;
import com.ruoyi.generator.domain.GenTable;
import com.ruoyi.generator.domain.GenTableColumn;
import org.apache.commons.lang3.RegExUtils;
import java.util.Arrays;
/**
* 代码生成器 工具类
@ -39,7 +40,7 @@ public class GenUtils
column.setTableId(table.getTableId());
column.setCreateBy(table.getCreateBy());
// 设置java字段名
column.setJavaField(StringUtils.toCamelCase(columnName));
column.setJavaField(StrUtil.toCamelCase(columnName));
// 设置默认类型
column.setJavaType(GenConstants.TYPE_STRING);
@ -60,7 +61,7 @@ public class GenUtils
column.setHtmlType(GenConstants.HTML_INPUT);
// 如果是浮点型 统一用BigDecimal
String[] str = StringUtils.split(StringUtils.substringBetween(column.getColumnType(), "(", ")"), ",");
String[] str = StrUtil.split(StrUtil.subBetween(column.getColumnType(), "(", ")"), ",");
if (str != null && str.length == 2 && Integer.parseInt(str[1]) > 0)
{
column.setJavaType(GenConstants.TYPE_BIGDECIMAL);
@ -97,33 +98,33 @@ public class GenUtils
}
// 查询字段类型
if (StringUtils.endsWithIgnoreCase(columnName, "name"))
if (StrUtil.endWithIgnoreCase(columnName, "name"))
{
column.setQueryType(GenConstants.QUERY_LIKE);
}
// 状态字段设置单选框
if (StringUtils.endsWithIgnoreCase(columnName, "status"))
if (StrUtil.endWithIgnoreCase(columnName, "status"))
{
column.setHtmlType(GenConstants.HTML_RADIO);
}
// 类型&性别字段设置下拉框
else if (StringUtils.endsWithIgnoreCase(columnName, "type")
|| StringUtils.endsWithIgnoreCase(columnName, "sex"))
else if (StrUtil.endWithIgnoreCase(columnName, "type")
|| StrUtil.endWithIgnoreCase(columnName, "sex"))
{
column.setHtmlType(GenConstants.HTML_SELECT);
}
// 图片字段设置图片上传控件
else if (StringUtils.endsWithIgnoreCase(columnName, "image"))
else if (StrUtil.endWithIgnoreCase(columnName, "image"))
{
column.setHtmlType(GenConstants.HTML_IMAGE_UPLOAD);
}
// 文件字段设置文件上传控件
else if (StringUtils.endsWithIgnoreCase(columnName, "file"))
else if (StrUtil.endWithIgnoreCase(columnName, "file"))
{
column.setHtmlType(GenConstants.HTML_FILE_UPLOAD);
}
// 内容字段设置富文本控件
else if (StringUtils.endsWithIgnoreCase(columnName, "content"))
else if (StrUtil.endWithIgnoreCase(columnName, "content"))
{
column.setHtmlType(GenConstants.HTML_EDITOR);
}
@ -151,7 +152,7 @@ public class GenUtils
{
int lastIndex = packageName.lastIndexOf(".");
int nameLength = packageName.length();
String moduleName = StringUtils.substring(packageName, lastIndex + 1, nameLength);
String moduleName = StrUtil.sub(packageName, lastIndex + 1, nameLength);
return moduleName;
}
@ -165,7 +166,7 @@ public class GenUtils
{
int lastIndex = tableName.lastIndexOf("_");
int nameLength = tableName.length();
String businessName = StringUtils.substring(tableName, lastIndex + 1, nameLength);
String businessName = StrUtil.sub(tableName, lastIndex + 1, nameLength);
return businessName;
}
@ -179,12 +180,12 @@ public class GenUtils
{
boolean autoRemovePre = GenConfig.getAutoRemovePre();
String tablePrefix = GenConfig.getTablePrefix();
if (autoRemovePre && StringUtils.isNotEmpty(tablePrefix))
if (autoRemovePre && StrUtil.isNotEmpty(tablePrefix))
{
String[] searchList = StringUtils.split(tablePrefix, ",");
String[] searchList = StrUtil.split(tablePrefix, ",");
tableName = replaceFirst(tableName, searchList);
}
return StringUtils.convertToCamelCase(tableName);
return StrUtil.toCamelCase(tableName);
}
/**
@ -227,9 +228,9 @@ public class GenUtils
*/
public static String getDbType(String columnType)
{
if (StringUtils.indexOf(columnType, "(") > 0)
if (StrUtil.indexOf(columnType, '(') > 0)
{
return StringUtils.substringBefore(columnType, "(");
return StrUtil.subBefore(columnType, "(",false);
}
else
{
@ -245,9 +246,9 @@ public class GenUtils
*/
public static Integer getColumnLength(String columnType)
{
if (StringUtils.indexOf(columnType, "(") > 0)
if (StrUtil.indexOf(columnType, '(') > 0)
{
String length = StringUtils.substringBetween(columnType, "(", ")");
String length = StrUtil.subBetween(columnType, "(", ")");
return Integer.valueOf(length);
}
else

View File

@ -1,15 +1,17 @@
package com.ruoyi.generator.util;
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.generator.domain.GenTable;
import com.ruoyi.generator.domain.GenTableColumn;
import org.apache.velocity.VelocityContext;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import org.apache.velocity.VelocityContext;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.constant.GenConstants;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.generator.domain.GenTable;
import com.ruoyi.generator.domain.GenTableColumn;
/**
* 模板处理工具类
@ -43,11 +45,11 @@ public class VelocityUtils
VelocityContext velocityContext = new VelocityContext();
velocityContext.put("tplCategory", genTable.getTplCategory());
velocityContext.put("tableName", genTable.getTableName());
velocityContext.put("functionName", StringUtils.isNotEmpty(functionName) ? functionName : "【请填写功能名称】");
velocityContext.put("functionName", StrUtil.isNotEmpty(functionName) ? functionName : "【请填写功能名称】");
velocityContext.put("ClassName", genTable.getClassName());
velocityContext.put("className", StringUtils.uncapitalize(genTable.getClassName()));
velocityContext.put("className", StrUtil.lowerFirst(genTable.getClassName()));
velocityContext.put("moduleName", genTable.getModuleName());
velocityContext.put("BusinessName", StringUtils.capitalize(genTable.getBusinessName()));
velocityContext.put("BusinessName", StrUtil.upperFirst(genTable.getBusinessName()));
velocityContext.put("businessName", genTable.getBusinessName());
velocityContext.put("basePackage", getPackagePrefix(packageName));
velocityContext.put("packageName", packageName);
@ -106,15 +108,15 @@ public class VelocityUtils
String subTableName = genTable.getSubTableName();
String subTableFkName = genTable.getSubTableFkName();
String subClassName = genTable.getSubTable().getClassName();
String subTableFkClassName = StringUtils.convertToCamelCase(subTableFkName);
String subTableFkClassName = StrUtil.toCamelCase(subTableFkName);
context.put("subTable", subTable);
context.put("subTableName", subTableName);
context.put("subTableFkName", subTableFkName);
context.put("subTableFkClassName", subTableFkClassName);
context.put("subTableFkclassName", StringUtils.uncapitalize(subTableFkClassName));
context.put("subTableFkclassName", StrUtil.lowerFirst(subTableFkClassName));
context.put("subClassName", subClassName);
context.put("subclassName", StringUtils.uncapitalize(subClassName));
context.put("subclassName", StrUtil.lowerFirst(subClassName));
context.put("subImportList", getImportList(genTable.getSubTable()));
}
@ -166,37 +168,37 @@ public class VelocityUtils
// 业务名称
String businessName = genTable.getBusinessName();
String javaPath = PROJECT_PATH + "/" + StringUtils.replace(packageName, ".", "/");
String javaPath = PROJECT_PATH + "/" + StrUtil.replace(packageName, ".", "/");
String mybatisPath = MYBATIS_PATH + "/" + moduleName;
String vuePath = "vue";
if (template.contains("domain.java.vm"))
{
fileName = StringUtils.format("{}/domain/{}.java", javaPath, className);
fileName = StrUtil.format("{}/domain/{}.java", javaPath, className);
}
if (template.contains("sub-domain.java.vm") && StringUtils.equals(GenConstants.TPL_SUB, genTable.getTplCategory()))
if (template.contains("sub-domain.java.vm") && StrUtil.equals(GenConstants.TPL_SUB, genTable.getTplCategory()))
{
fileName = StringUtils.format("{}/domain/{}.java", javaPath, genTable.getSubTable().getClassName());
fileName = StrUtil.format("{}/domain/{}.java", javaPath, genTable.getSubTable().getClassName());
}
else if (template.contains("mapper.java.vm"))
{
fileName = StringUtils.format("{}/mapper/{}Mapper.java", javaPath, className);
fileName = StrUtil.format("{}/mapper/{}Mapper.java", javaPath, className);
}
else if (template.contains("service.java.vm"))
{
fileName = StringUtils.format("{}/service/I{}Service.java", javaPath, className);
fileName = StrUtil.format("{}/service/I{}Service.java", javaPath, className);
}
else if (template.contains("serviceImpl.java.vm"))
{
fileName = StringUtils.format("{}/service/impl/{}ServiceImpl.java", javaPath, className);
fileName = StrUtil.format("{}/service/impl/{}ServiceImpl.java", javaPath, className);
}
else if (template.contains("controller.java.vm"))
{
fileName = StringUtils.format("{}/controller/{}Controller.java", javaPath, className);
fileName = StrUtil.format("{}/controller/{}Controller.java", javaPath, className);
}
else if (template.contains("mapper.xml.vm"))
{
fileName = StringUtils.format("{}/{}Mapper.xml", mybatisPath, className);
fileName = StrUtil.format("{}/{}Mapper.xml", mybatisPath, className);
}
else if (template.contains("sql.vm"))
{
@ -204,15 +206,15 @@ public class VelocityUtils
}
else if (template.contains("api.js.vm"))
{
fileName = StringUtils.format("{}/api/{}/{}.js", vuePath, moduleName, businessName);
fileName = StrUtil.format("{}/api/{}/{}.js", vuePath, moduleName, businessName);
}
else if (template.contains("index.vue.vm"))
{
fileName = StringUtils.format("{}/views/{}/{}/index.vue", vuePath, moduleName, businessName);
fileName = StrUtil.format("{}/views/{}/{}/index.vue", vuePath, moduleName, businessName);
}
else if (template.contains("index-tree.vue.vm"))
{
fileName = StringUtils.format("{}/views/{}/{}/index.vue", vuePath, moduleName, businessName);
fileName = StrUtil.format("{}/views/{}/{}/index.vue", vuePath, moduleName, businessName);
}
return fileName;
}
@ -226,7 +228,7 @@ public class VelocityUtils
public static String getPackagePrefix(String packageName)
{
int lastIndex = packageName.lastIndexOf(".");
String basePackage = StringUtils.substring(packageName, 0, lastIndex);
String basePackage = StrUtil.sub(packageName, 0, lastIndex);
return basePackage;
}
@ -241,7 +243,7 @@ public class VelocityUtils
List<GenTableColumn> columns = genTable.getColumns();
GenTable subGenTable = genTable.getSubTable();
HashSet<String> importList = new HashSet<String>();
if (StringUtils.isNotNull(subGenTable))
if (Validator.isNotNull(subGenTable))
{
importList.add("java.util.List");
}
@ -269,7 +271,7 @@ public class VelocityUtils
*/
public static String getPermissionPrefix(String moduleName, String businessName)
{
return StringUtils.format("{}:{}", moduleName, businessName);
return StrUtil.format("{}:{}", moduleName, businessName);
}
/**
@ -280,7 +282,7 @@ public class VelocityUtils
*/
public static String getParentMenuId(JSONObject paramsObj)
{
if (StringUtils.isNotEmpty(paramsObj) && paramsObj.containsKey(GenConstants.PARENT_MENU_ID))
if (Validator.isNotEmpty(paramsObj) && paramsObj.containsKey(GenConstants.PARENT_MENU_ID))
{
return paramsObj.getString(GenConstants.PARENT_MENU_ID);
}
@ -297,9 +299,9 @@ public class VelocityUtils
{
if (paramsObj.containsKey(GenConstants.TREE_CODE))
{
return StringUtils.toCamelCase(paramsObj.getString(GenConstants.TREE_CODE));
return StrUtil.toCamelCase(paramsObj.getString(GenConstants.TREE_CODE));
}
return StringUtils.EMPTY;
return StrUtil.EMPTY;
}
/**
@ -312,9 +314,9 @@ public class VelocityUtils
{
if (paramsObj.containsKey(GenConstants.TREE_PARENT_CODE))
{
return StringUtils.toCamelCase(paramsObj.getString(GenConstants.TREE_PARENT_CODE));
return StrUtil.toCamelCase(paramsObj.getString(GenConstants.TREE_PARENT_CODE));
}
return StringUtils.EMPTY;
return StrUtil.EMPTY;
}
/**
@ -327,9 +329,9 @@ public class VelocityUtils
{
if (paramsObj.containsKey(GenConstants.TREE_NAME))
{
return StringUtils.toCamelCase(paramsObj.getString(GenConstants.TREE_NAME));
return StrUtil.toCamelCase(paramsObj.getString(GenConstants.TREE_NAME));
}
return StringUtils.EMPTY;
return StrUtil.EMPTY;
}
/**