优化代码
parent
e66f65b257
commit
dbca691746
|
@ -18,8 +18,7 @@ public class ExceptionUtil
|
|||
{
|
||||
StringWriter sw = new StringWriter();
|
||||
e.printStackTrace(new PrintWriter(sw, true));
|
||||
String str = sw.toString();
|
||||
return str;
|
||||
return sw.toString();
|
||||
}
|
||||
|
||||
public static String getRootErrorMessage(Exception e)
|
||||
|
|
|
@ -161,9 +161,8 @@ public class ServletUtils
|
|||
*
|
||||
* @param response 渲染对象
|
||||
* @param string 待渲染的字符串
|
||||
* @return null
|
||||
*/
|
||||
public static String renderString(HttpServletResponse response, String string)
|
||||
public static void renderString(HttpServletResponse response, String string)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -176,7 +175,6 @@ public class ServletUtils
|
|||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -187,13 +185,13 @@ public class ServletUtils
|
|||
public static boolean isAjaxRequest(HttpServletRequest request)
|
||||
{
|
||||
String accept = request.getHeader("accept");
|
||||
if (accept != null && accept.indexOf("application/json") != -1)
|
||||
if (accept != null && accept.contains("application/json"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
String xRequestedWith = request.getHeader("X-Requested-With");
|
||||
if (xRequestedWith != null && xRequestedWith.indexOf("XMLHttpRequest") != -1)
|
||||
if (xRequestedWith != null && xRequestedWith.contains("XMLHttpRequest"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -205,11 +203,7 @@ public class ServletUtils
|
|||
}
|
||||
|
||||
String ajax = request.getParameter("__ajax");
|
||||
if (StringUtils.inStringIgnoreCase(ajax, "json", "xml"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return StringUtils.inStringIgnoreCase(ajax, "json", "xml");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -55,7 +55,7 @@ public class ImageUtils
|
|||
/**
|
||||
* 读取文件为字节数据
|
||||
*
|
||||
* @param key 地址
|
||||
* @param url 地址
|
||||
* @return 字节数据
|
||||
*/
|
||||
public static byte[] readFile(String url)
|
||||
|
|
|
@ -944,7 +944,7 @@ public class ExcelUtil<T>
|
|||
if (StringUtils.isNotEmpty(excel.targetAttr()))
|
||||
{
|
||||
String target = excel.targetAttr();
|
||||
if (target.indexOf(".") > -1)
|
||||
if (target.contains("."))
|
||||
{
|
||||
String[] targets = target.split("[.]");
|
||||
for (String name : targets)
|
||||
|
@ -1039,7 +1039,7 @@ public class ExcelUtil<T>
|
|||
for (Object[] os : this.fields)
|
||||
{
|
||||
Excel excel = (Excel) os[1];
|
||||
maxHeight = maxHeight > excel.height() ? maxHeight : excel.height();
|
||||
maxHeight = Math.max(maxHeight, excel.height());
|
||||
}
|
||||
return (short) (maxHeight * 20);
|
||||
}
|
||||
|
|
|
@ -50,9 +50,9 @@ public class SqlUtil
|
|||
return;
|
||||
}
|
||||
String[] sqlKeywords = StringUtils.split(SQL_REGEX, "\\|");
|
||||
for (int i = 0; i < sqlKeywords.length; i++)
|
||||
for (String sqlKeyword : sqlKeywords)
|
||||
{
|
||||
if (StringUtils.indexOfIgnoreCase(value, sqlKeywords[i]) > -1)
|
||||
if (StringUtils.indexOfIgnoreCase(value, sqlKeyword) > -1)
|
||||
{
|
||||
throw new UtilException("参数存在SQL注入风险");
|
||||
}
|
||||
|
|
|
@ -37,8 +37,7 @@ public class DictUtils
|
|||
Object cacheObj = SpringUtils.getBean(RedisService.class).getCacheObject(getCacheKey(key));
|
||||
if (StringUtils.isNotNull(cacheObj))
|
||||
{
|
||||
List<SysDictData> dictDatas = StringUtils.cast(cacheObj);
|
||||
return dictDatas;
|
||||
return StringUtils.cast(cacheObj);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.ruoyi.file.utils;
|
|||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import com.ruoyi.common.core.exception.file.FileNameLengthLimitExceededException;
|
||||
|
@ -65,7 +66,7 @@ public class FileUploadUtils
|
|||
throws FileSizeLimitExceededException, IOException, FileNameLengthLimitExceededException,
|
||||
InvalidExtensionException
|
||||
{
|
||||
int fileNamelength = file.getOriginalFilename().length();
|
||||
int fileNamelength = Objects.requireNonNull(file.getOriginalFilename()).length();
|
||||
if (fileNamelength > FileUploadUtils.DEFAULT_FILE_NAME_LENGTH)
|
||||
{
|
||||
throw new FileNameLengthLimitExceededException(FileUploadUtils.DEFAULT_FILE_NAME_LENGTH);
|
||||
|
@ -77,8 +78,7 @@ public class FileUploadUtils
|
|||
|
||||
File desc = getAbsoluteFile(baseDir, fileName);
|
||||
file.transferTo(desc);
|
||||
String pathFileName = getPathFileName(fileName);
|
||||
return pathFileName;
|
||||
return getPathFileName(fileName);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -186,7 +186,7 @@ public class FileUploadUtils
|
|||
String extension = FilenameUtils.getExtension(file.getOriginalFilename());
|
||||
if (StringUtils.isEmpty(extension))
|
||||
{
|
||||
extension = MimeTypeUtils.getExtension(file.getContentType());
|
||||
extension = MimeTypeUtils.getExtension(Objects.requireNonNull(file.getContentType()));
|
||||
}
|
||||
return extension;
|
||||
}
|
||||
|
|
|
@ -151,8 +151,7 @@ public class GenUtils
|
|||
{
|
||||
int lastIndex = packageName.lastIndexOf(".");
|
||||
int nameLength = packageName.length();
|
||||
String moduleName = StringUtils.substring(packageName, lastIndex + 1, nameLength);
|
||||
return moduleName;
|
||||
return StringUtils.substring(packageName, lastIndex + 1, nameLength);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -165,8 +164,7 @@ public class GenUtils
|
|||
{
|
||||
int lastIndex = tableName.lastIndexOf("_");
|
||||
int nameLength = tableName.length();
|
||||
String businessName = StringUtils.substring(tableName, lastIndex + 1, nameLength);
|
||||
return businessName;
|
||||
return StringUtils.substring(tableName, lastIndex + 1, nameLength);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -228,8 +228,7 @@ public class VelocityUtils
|
|||
public static String getPackagePrefix(String packageName)
|
||||
{
|
||||
int lastIndex = packageName.lastIndexOf(".");
|
||||
String basePackage = StringUtils.substring(packageName, 0, lastIndex);
|
||||
return basePackage;
|
||||
return StringUtils.substring(packageName, 0, lastIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -63,9 +63,8 @@ public class SysDeptServiceImpl implements ISysDeptService
|
|||
{
|
||||
tempList.add(dept.getDeptId());
|
||||
}
|
||||
for (Iterator<SysDept> iterator = depts.iterator(); iterator.hasNext();)
|
||||
for (SysDept dept : depts)
|
||||
{
|
||||
SysDept dept = (SysDept) iterator.next();
|
||||
// 如果是顶级节点, 遍历该父节点的所有子节点
|
||||
if (!tempList.contains(dept.getParentId()))
|
||||
{
|
||||
|
|
|
@ -498,7 +498,7 @@ public class SysMenuServiceImpl implements ISysMenuService
|
|||
*/
|
||||
private boolean hasChild(List<SysMenu> list, SysMenu t)
|
||||
{
|
||||
return getChildList(list, t).size() > 0 ? true : false;
|
||||
return getChildList(list, t).size() > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
</resultMap>
|
||||
|
||||
<sql id="selectMenuVo">
|
||||
select menu_id, menu_name, parent_id, order_num, path, component, query, is_frame, is_cache, menu_type, visible, status, ifnull(perms,'') as perms, icon, create_time
|
||||
select menu_id, menu_name, parent_id, order_num, path, component, `query`, is_frame, is_cache, menu_type, visible, status, ifnull(perms,'') as perms, icon, create_time
|
||||
from sys_menu
|
||||
</sql>
|
||||
|
||||
|
@ -49,13 +49,13 @@
|
|||
</select>
|
||||
|
||||
<select id="selectMenuTreeAll" resultMap="SysMenuResult">
|
||||
select distinct m.menu_id, m.parent_id, m.menu_name, m.path, m.component, m.query, m.visible, m.status, ifnull(m.perms,'') as perms, m.is_frame, m.is_cache, m.menu_type, m.icon, m.order_num, m.create_time
|
||||
select distinct m.menu_id, m.parent_id, m.menu_name, m.path, m.component, m.`query`, m.visible, m.status, ifnull(m.perms,'') as perms, m.is_frame, m.is_cache, m.menu_type, m.icon, m.order_num, m.create_time
|
||||
from sys_menu m where m.menu_type in ('M', 'C') and m.status = 0
|
||||
order by m.parent_id, m.order_num
|
||||
</select>
|
||||
|
||||
<select id="selectMenuListByUserId" parameterType="SysMenu" resultMap="SysMenuResult">
|
||||
select distinct m.menu_id, m.parent_id, m.menu_name, m.path, m.component, m.query, m.visible, m.status, ifnull(m.perms,'') as perms, m.is_frame, m.is_cache, m.menu_type, m.icon, m.order_num, m.create_time
|
||||
select distinct m.menu_id, m.parent_id, m.menu_name, m.path, m.component, m.`query`, m.visible, m.status, ifnull(m.perms,'') as perms, m.is_frame, m.is_cache, m.menu_type, m.icon, m.order_num, m.create_time
|
||||
from sys_menu m
|
||||
left join sys_role_menu rm on m.menu_id = rm.menu_id
|
||||
left join sys_user_role ur on rm.role_id = ur.role_id
|
||||
|
@ -74,7 +74,7 @@
|
|||
</select>
|
||||
|
||||
<select id="selectMenuTreeByUserId" parameterType="Long" resultMap="SysMenuResult">
|
||||
select distinct m.menu_id, m.parent_id, m.menu_name, m.path, m.component, m.query, m.visible, m.status, ifnull(m.perms,'') as perms, m.is_frame, m.is_cache, m.menu_type, m.icon, m.order_num, m.create_time
|
||||
select distinct m.menu_id, m.parent_id, m.menu_name, m.path, m.component, m.`query`, m.visible, m.status, ifnull(m.perms,'') as perms, m.is_frame, m.is_cache, m.menu_type, m.icon, m.order_num, m.create_time
|
||||
from sys_menu m
|
||||
left join sys_role_menu rm on m.menu_id = rm.menu_id
|
||||
left join sys_user_role ur on rm.role_id = ur.role_id
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
<!-- 文件列表 -->
|
||||
<transition-group class="upload-file-list el-upload-list el-upload-list--text" name="el-fade-in-linear" tag="ul">
|
||||
<li :key="file.uid" class="el-upload-list__item ele-upload-list__item-content" v-for="(file, index) in fileList">
|
||||
<li :key="file.url" class="el-upload-list__item ele-upload-list__item-content" v-for="(file, index) in fileList">
|
||||
<el-link :href="file.url" :underline="false" target="_blank">
|
||||
<span class="el-icon-document"> {{ getFileName(file.name) }} </span>
|
||||
</el-link>
|
||||
|
|
|
@ -5,11 +5,11 @@ let confGlobal
|
|||
let someSpanIsNot24
|
||||
|
||||
export function dialogWrapper(str) {
|
||||
return `<el-dialog v-bind="$attrs" v-on="$listeners" @open="onOpen" @close="onClose" title="Dialog Titile">
|
||||
return `<el-dialog v-bind="$attrs" v-on="$listeners" @open="onOpen" @close="onClose" title="Dialog Title">
|
||||
${str}
|
||||
<div slot="footer">
|
||||
<el-button @click="close">取消</el-button>
|
||||
<el-button type="primary" @click="handelConfirm">确定</el-button>
|
||||
<el-button type="primary" @click="handleConfirm">确定</el-button>
|
||||
</div>
|
||||
</el-dialog>`
|
||||
}
|
||||
|
|
|
@ -98,7 +98,7 @@ function mixinMethod(type) {
|
|||
close: `close() {
|
||||
this.$emit('update:visible', false)
|
||||
},`,
|
||||
handelConfirm: `handelConfirm() {
|
||||
handleConfirm: `handleConfirm() {
|
||||
this.$refs['${confGlobal.formRef}'].validate(valid => {
|
||||
if(!valid) return
|
||||
this.close()
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
<el-button @click="close">
|
||||
取消
|
||||
</el-button>
|
||||
<el-button type="primary" @click="handelConfirm">
|
||||
<el-button type="primary" @click="handleConfirm">
|
||||
确定
|
||||
</el-button>
|
||||
</div>
|
||||
|
@ -94,7 +94,7 @@ export default {
|
|||
close(e) {
|
||||
this.$emit('update:visible', false)
|
||||
},
|
||||
handelConfirm() {
|
||||
handleConfirm() {
|
||||
this.$refs.elForm.validate(valid => {
|
||||
if (!valid) return
|
||||
this.$emit('confirm', { ...this.formData })
|
||||
|
|
|
@ -59,7 +59,7 @@
|
|||
<div slot="footer">
|
||||
<el-button
|
||||
type="primary"
|
||||
@click="handelConfirm"
|
||||
@click="handleConfirm"
|
||||
>
|
||||
确定
|
||||
</el-button>
|
||||
|
@ -133,7 +133,7 @@ export default {
|
|||
close() {
|
||||
this.$emit('update:visible', false)
|
||||
},
|
||||
handelConfirm() {
|
||||
handleConfirm() {
|
||||
this.$refs.elForm.validate(valid => {
|
||||
if (!valid) return
|
||||
if (this.dataType === 'number') {
|
||||
|
|
|
@ -146,7 +146,7 @@ import { beautifierConf, titleCase } from '@/utils/index'
|
|||
import { makeUpHtml, vueTemplate, vueScript, cssStyle } from '@/utils/generator/html'
|
||||
import { makeUpJs } from '@/utils/generator/js'
|
||||
import { makeUpCss } from '@/utils/generator/css'
|
||||
import drawingDefalut from '@/utils/generator/drawingDefalut'
|
||||
import drawingDefault from '@/utils/generator/drawingDefault'
|
||||
import logo from '@/assets/logo/logo.png'
|
||||
import CodeTypeDialog from './CodeTypeDialog'
|
||||
import DraggableItem from './DraggableItem'
|
||||
|
@ -171,15 +171,15 @@ export default {
|
|||
selectComponents,
|
||||
layoutComponents,
|
||||
labelWidth: 100,
|
||||
drawingList: drawingDefalut,
|
||||
drawingList: drawingDefault,
|
||||
drawingData: {},
|
||||
activeId: drawingDefalut[0].formId,
|
||||
activeId: drawingDefault[0].formId,
|
||||
drawerVisible: false,
|
||||
formData: {},
|
||||
dialogVisible: false,
|
||||
generateConf: null,
|
||||
showFileName: false,
|
||||
activeData: drawingDefalut[0]
|
||||
activeData: drawingDefault[0]
|
||||
}
|
||||
},
|
||||
created() {
|
||||
|
|
Loading…
Reference in New Issue