优化细节

This commit is contained in:
RuoYi 2020-07-17 11:24:59 +08:00
parent ec00527936
commit 6e56e6e7a4
24 changed files with 58 additions and 25 deletions

View File

@ -5,7 +5,7 @@ package com.ruoyi.common.constant;
* *
* @author ruoyi * @author ruoyi
*/ */
public interface HttpStatus public class HttpStatus
{ {
/** /**
* 操作成功 * 操作成功

View File

@ -5,7 +5,7 @@ package com.ruoyi.common.constant;
* *
* @author ruoyi * @author ruoyi
*/ */
public interface ScheduleConstants public class ScheduleConstants
{ {
public static final String TASK_CLASS_NAME = "TASK_CLASS_NAME"; public static final String TASK_CLASS_NAME = "TASK_CLASS_NAME";

View File

@ -376,6 +376,7 @@ public final class UUID implements java.io.Serializable, Comparable<UUID>
* *
* @return UUID 的哈希码值 * @return UUID 的哈希码值
*/ */
@Override
public int hashCode() public int hashCode()
{ {
long hilo = mostSigBits ^ leastSigBits; long hilo = mostSigBits ^ leastSigBits;
@ -391,6 +392,7 @@ public final class UUID implements java.io.Serializable, Comparable<UUID>
* *
* @return 如果对象相同则返回 {@code true}否则返回 {@code false} * @return 如果对象相同则返回 {@code true}否则返回 {@code false}
*/ */
@Override
public boolean equals(Object obj) public boolean equals(Object obj)
{ {
if ((null == obj) || (obj.getClass() != UUID.class)) if ((null == obj) || (obj.getClass() != UUID.class))
@ -414,6 +416,7 @@ public final class UUID implements java.io.Serializable, Comparable<UUID>
* @return 在此 UUID 小于等于或大于 val 分别返回 -10 1 * @return 在此 UUID 小于等于或大于 val 分别返回 -10 1
* *
*/ */
@Override
public int compareTo(UUID val) public int compareTo(UUID val)
{ {
// The ordering is intentionally set up so that the UUIDs // The ordering is intentionally set up so that the UUIDs

View File

@ -139,10 +139,12 @@ public class VerifyCodeUtils
private static Color getRandColor(int fc, int bc) private static Color getRandColor(int fc, int bc)
{ {
if (fc > 255) if (fc > 255) {
fc = 255; fc = 255;
if (bc > 255) }
if (bc > 255) {
bc = 255; bc = 255;
}
int r = fc + random.nextInt(bc - fc); int r = fc + random.nextInt(bc - fc);
int g = fc + random.nextInt(bc - fc); int g = fc + random.nextInt(bc - fc);
int b = fc + random.nextInt(bc - fc); int b = fc + random.nextInt(bc - fc);

View File

@ -118,7 +118,7 @@ public class HttpUtils
StringBuilder result = new StringBuilder(); StringBuilder result = new StringBuilder();
try try
{ {
String urlNameString = url + "?" + param; String urlNameString = url;
log.info("sendPost - {}", urlNameString); log.info("sendPost - {}", urlNameString);
URL realUrl = new URL(urlNameString); URL realUrl = new URL(urlNameString);
URLConnection conn = realUrl.openConnection(); URLConnection conn = realUrl.openConnection();
@ -204,7 +204,7 @@ public class HttpUtils
String ret = ""; String ret = "";
while ((ret = br.readLine()) != null) while ((ret = br.readLine()) != null)
{ {
if (ret != null && !ret.trim().equals("")) if (ret != null && !"".equals(ret.trim()))
{ {
result.append(new String(ret.getBytes("ISO-8859-1"), "utf-8")); result.append(new String(ret.getBytes("ISO-8859-1"), "utf-8"));
} }

View File

@ -4,6 +4,7 @@ import java.net.InetAddress;
import java.net.UnknownHostException; import java.net.UnknownHostException;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.html.EscapeUtil;
/** /**
* 获取IP方法 * 获取IP方法
@ -40,8 +41,7 @@ public class IpUtils
{ {
ip = request.getRemoteAddr(); ip = request.getRemoteAddr();
} }
return "0:0:0:0:0:0:0:1".equals(ip) ? "127.0.0.1" : EscapeUtil.clean(ip);
return "0:0:0:0:0:0:0:1".equals(ip) ? "127.0.0.1" : ip;
} }
public static boolean internalIp(String ip) public static boolean internalIp(String ip)
@ -110,8 +110,9 @@ public class IpUtils
{ {
case 1: case 1:
l = Long.parseLong(elements[0]); l = Long.parseLong(elements[0]);
if ((l < 0L) || (l > 4294967295L)) if ((l < 0L) || (l > 4294967295L)) {
return null; return null;
}
bytes[0] = (byte) (int) (l >> 24 & 0xFF); bytes[0] = (byte) (int) (l >> 24 & 0xFF);
bytes[1] = (byte) (int) ((l & 0xFFFFFF) >> 16 & 0xFF); bytes[1] = (byte) (int) ((l & 0xFFFFFF) >> 16 & 0xFF);
bytes[2] = (byte) (int) ((l & 0xFFFF) >> 8 & 0xFF); bytes[2] = (byte) (int) ((l & 0xFFFF) >> 8 & 0xFF);
@ -119,12 +120,14 @@ public class IpUtils
break; break;
case 2: case 2:
l = Integer.parseInt(elements[0]); l = Integer.parseInt(elements[0]);
if ((l < 0L) || (l > 255L)) if ((l < 0L) || (l > 255L)) {
return null; return null;
}
bytes[0] = (byte) (int) (l & 0xFF); bytes[0] = (byte) (int) (l & 0xFF);
l = Integer.parseInt(elements[1]); l = Integer.parseInt(elements[1]);
if ((l < 0L) || (l > 16777215L)) if ((l < 0L) || (l > 16777215L)) {
return null; return null;
}
bytes[1] = (byte) (int) (l >> 16 & 0xFF); bytes[1] = (byte) (int) (l >> 16 & 0xFF);
bytes[2] = (byte) (int) ((l & 0xFFFF) >> 8 & 0xFF); bytes[2] = (byte) (int) ((l & 0xFFFF) >> 8 & 0xFF);
bytes[3] = (byte) (int) (l & 0xFF); bytes[3] = (byte) (int) (l & 0xFF);
@ -133,13 +136,15 @@ public class IpUtils
for (i = 0; i < 2; ++i) for (i = 0; i < 2; ++i)
{ {
l = Integer.parseInt(elements[i]); l = Integer.parseInt(elements[i]);
if ((l < 0L) || (l > 255L)) if ((l < 0L) || (l > 255L)) {
return null; return null;
}
bytes[i] = (byte) (int) (l & 0xFF); bytes[i] = (byte) (int) (l & 0xFF);
} }
l = Integer.parseInt(elements[2]); l = Integer.parseInt(elements[2]);
if ((l < 0L) || (l > 65535L)) if ((l < 0L) || (l > 65535L)) {
return null; return null;
}
bytes[2] = (byte) (int) (l >> 8 & 0xFF); bytes[2] = (byte) (int) (l >> 8 & 0xFF);
bytes[3] = (byte) (int) (l & 0xFF); bytes[3] = (byte) (int) (l & 0xFF);
break; break;
@ -147,8 +152,9 @@ public class IpUtils
for (i = 0; i < 4; ++i) for (i = 0; i < 4; ++i)
{ {
l = Integer.parseInt(elements[i]); l = Integer.parseInt(elements[i]);
if ((l < 0L) || (l > 255L)) if ((l < 0L) || (l > 255L)) {
return null; return null;
}
bytes[i] = (byte) (int) (l & 0xFF); bytes[i] = (byte) (int) (l & 0xFF);
} }
break; break;

View File

@ -36,6 +36,7 @@ public class FastJson2JsonRedisSerializer<T> implements RedisSerializer<T>
this.clazz = clazz; this.clazz = clazz;
} }
@Override
public byte[] serialize(T t) throws SerializationException public byte[] serialize(T t) throws SerializationException
{ {
if (t == null) if (t == null)
@ -45,6 +46,7 @@ public class FastJson2JsonRedisSerializer<T> implements RedisSerializer<T>
return JSON.toJSONString(t, SerializerFeature.WriteClassName).getBytes(DEFAULT_CHARSET); return JSON.toJSONString(t, SerializerFeature.WriteClassName).getBytes(DEFAULT_CHARSET);
} }
@Override
public T deserialize(byte[] bytes) throws SerializationException public T deserialize(byte[] bytes) throws SerializationException
{ {
if (bytes == null || bytes.length <= 0) if (bytes == null || bytes.length <= 0)

View File

@ -40,7 +40,7 @@ public class SysLoginService
* *
* @param username 用户名 * @param username 用户名
* @param password 密码 * @param password 密码
* @param captcha 验证码 * @param code 验证码
* @param uuid 唯一标识 * @param uuid 唯一标识
* @return 结果 * @return 结果
*/ */

View File

@ -47,6 +47,7 @@ public class SysOperLogServiceImpl implements ISysOperLogService
* @param operIds 需要删除的操作日志ID * @param operIds 需要删除的操作日志ID
* @return 结果 * @return 结果
*/ */
@Override
public int deleteOperLogByIds(Long[] operIds) public int deleteOperLogByIds(Long[] operIds)
{ {
return operLogMapper.deleteOperLogByIds(operIds); return operLogMapper.deleteOperLogByIds(operIds);

View File

@ -42,10 +42,7 @@ public class SysLoginController
/** /**
* 登录方法 * 登录方法
* *
* @param username 用户名 * @param loginBody 登录信息
* @param password 密码
* @param captcha 验证码
* @param uuid 唯一标识
* @return 结果 * @return 结果
*/ */
@PostMapping("/login") @PostMapping("/login")

View File

@ -178,6 +178,7 @@ public class SysRole extends BaseEntity
this.deptIds = deptIds; this.deptIds = deptIds;
} }
@Override
public String toString() { public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("roleId", getRoleId()) .append("roleId", getRoleId())

View File

@ -77,8 +77,10 @@ public class SysUser extends BaseEntity
private Date loginDate; private Date loginDate;
/** 部门对象 */ /** 部门对象 */
@Excels({ @Excel(name = "部门名称", targetAttr = "deptName", type = Type.EXPORT), @Excels({
@Excel(name = "部门负责人", targetAttr = "leader", type = Type.EXPORT) }) @Excel(name = "部门名称", targetAttr = "deptName", type = Type.EXPORT),
@Excel(name = "部门负责人", targetAttr = "leader", type = Type.EXPORT)
})
private SysDept dept; private SysDept dept;
/** 角色对象 */ /** 角色对象 */

View File

@ -147,6 +147,7 @@ public class SysConfigServiceImpl implements ISysConfigService
/** /**
* 清空缓存数据 * 清空缓存数据
*/ */
@Override
public void clearCache() public void clearCache()
{ {
Collection<String> keys = redisCache.keys(Constants.SYS_CONFIG_KEY + "*"); Collection<String> keys = redisCache.keys(Constants.SYS_CONFIG_KEY + "*");

View File

@ -62,6 +62,7 @@ public class SysDictDataServiceImpl implements ISysDictDataService
* @param dictCodes 需要删除的字典数据ID * @param dictCodes 需要删除的字典数据ID
* @return 结果 * @return 结果
*/ */
@Override
public int deleteDictDataByIds(Long[] dictCodes) public int deleteDictDataByIds(Long[] dictCodes)
{ {
int row = dictDataMapper.deleteDictDataByIds(dictCodes); int row = dictDataMapper.deleteDictDataByIds(dictCodes);

View File

@ -107,6 +107,7 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService
* @param dictType 字典类型 * @param dictType 字典类型
* @return 字典类型 * @return 字典类型
*/ */
@Override
public SysDictType selectDictTypeByType(String dictType) public SysDictType selectDictTypeByType(String dictType)
{ {
return dictTypeMapper.selectDictTypeByType(dictType); return dictTypeMapper.selectDictTypeByType(dictType);
@ -118,6 +119,7 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService
* @param dictIds 需要删除的字典ID * @param dictIds 需要删除的字典ID
* @return 结果 * @return 结果
*/ */
@Override
public int deleteDictTypeByIds(Long[] dictIds) public int deleteDictTypeByIds(Long[] dictIds)
{ {
for (Long dictId : dictIds) for (Long dictId : dictIds)
@ -139,6 +141,7 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService
/** /**
* 清空缓存数据 * 清空缓存数据
*/ */
@Override
public void clearCache() public void clearCache()
{ {
DictUtils.clearDictCache(); DictUtils.clearDictCache();

View File

@ -121,6 +121,7 @@ public class SysMenuServiceImpl implements ISysMenuService
* @param roleId 角色ID * @param roleId 角色ID
* @return 选中菜单列表 * @return 选中菜单列表
*/ */
@Override
public List<Integer> selectMenuListByRoleId(Long roleId) public List<Integer> selectMenuListByRoleId(Long roleId)
{ {
return menuMapper.selectMenuListByRoleId(roleId); return menuMapper.selectMenuListByRoleId(roleId);

View File

@ -84,6 +84,7 @@ public class SysNoticeServiceImpl implements ISysNoticeService
* @param noticeIds 需要删除的公告ID * @param noticeIds 需要删除的公告ID
* @return 结果 * @return 结果
*/ */
@Override
public int deleteNoticeByIds(Long[] noticeIds) public int deleteNoticeByIds(Long[] noticeIds)
{ {
return noticeMapper.deleteNoticeByIds(noticeIds); return noticeMapper.deleteNoticeByIds(noticeIds);

View File

@ -66,6 +66,7 @@ public class SysPostServiceImpl implements ISysPostService
* @param userId 用户ID * @param userId 用户ID
* @return 选中岗位ID列表 * @return 选中岗位ID列表
*/ */
@Override
public List<Integer> selectPostListByUserId(Long userId) public List<Integer> selectPostListByUserId(Long userId)
{ {
return postMapper.selectPostListByUserId(userId); return postMapper.selectPostListByUserId(userId);
@ -138,6 +139,7 @@ public class SysPostServiceImpl implements ISysPostService
* @return 结果 * @return 结果
* @throws Exception 异常 * @throws Exception 异常
*/ */
@Override
public int deletePostByIds(Long[] postIds) public int deletePostByIds(Long[] postIds)
{ {
for (Long postId : postIds) for (Long postId : postIds)

View File

@ -81,6 +81,7 @@ public class SysRoleServiceImpl implements ISysRoleService
* *
* @return 角色列表 * @return 角色列表
*/ */
@Override
public List<SysRole> selectRoleAll() public List<SysRole> selectRoleAll()
{ {
return SpringUtils.getAopProxy(this).selectRoleList(new SysRole()); return SpringUtils.getAopProxy(this).selectRoleList(new SysRole());
@ -92,6 +93,7 @@ public class SysRoleServiceImpl implements ISysRoleService
* @param userId 用户ID * @param userId 用户ID
* @return 选中角色ID列表 * @return 选中角色ID列表
*/ */
@Override
public List<Integer> selectRoleListByUserId(Long userId) public List<Integer> selectRoleListByUserId(Long userId)
{ {
return roleMapper.selectRoleListByUserId(userId); return roleMapper.selectRoleListByUserId(userId);
@ -103,6 +105,7 @@ public class SysRoleServiceImpl implements ISysRoleService
* @param roleId 角色ID * @param roleId 角色ID
* @return 角色对象信息 * @return 角色对象信息
*/ */
@Override
public SysRole selectRoleById(Long roleId) public SysRole selectRoleById(Long roleId)
{ {
return roleMapper.selectRoleById(roleId); return roleMapper.selectRoleById(roleId);
@ -149,6 +152,7 @@ public class SysRoleServiceImpl implements ISysRoleService
* *
* @param role 角色信息 * @param role 角色信息
*/ */
@Override
public void checkRoleAllowed(SysRole role) public void checkRoleAllowed(SysRole role)
{ {
if (StringUtils.isNotNull(role.getRoleId()) && role.isAdmin()) if (StringUtils.isNotNull(role.getRoleId()) && role.isAdmin())
@ -207,6 +211,7 @@ public class SysRoleServiceImpl implements ISysRoleService
* @param role 角色信息 * @param role 角色信息
* @return 结果 * @return 结果
*/ */
@Override
public int updateRoleStatus(SysRole role) public int updateRoleStatus(SysRole role)
{ {
return roleMapper.updateRole(role); return roleMapper.updateRole(role);
@ -296,6 +301,7 @@ public class SysRoleServiceImpl implements ISysRoleService
* @param roleIds 需要删除的角色ID * @param roleIds 需要删除的角色ID
* @return 结果 * @return 结果
*/ */
@Override
public int deleteRoleByIds(Long[] roleIds) public int deleteRoleByIds(Long[] roleIds)
{ {
for (Long roleId : roleIds) for (Long roleId : roleIds)

View File

@ -72,6 +72,7 @@ public class SysUserOnlineServiceImpl implements ISysUserOnlineService
* @param user 用户信息 * @param user 用户信息
* @return 在线用户 * @return 在线用户
*/ */
@Override
public SysUserOnline loginUserToUserOnline(LoginUser user) public SysUserOnline loginUserToUserOnline(LoginUser user)
{ {
if (StringUtils.isNull(user) && StringUtils.isNull(user.getUser())) if (StringUtils.isNull(user) && StringUtils.isNull(user.getUser()))

View File

@ -192,6 +192,7 @@ public class SysUserServiceImpl implements ISysUserService
* *
* @param user 用户信息 * @param user 用户信息
*/ */
@Override
public void checkUserAllowed(SysUser user) public void checkUserAllowed(SysUser user)
{ {
if (StringUtils.isNotNull(user.getUserId()) && user.isAdmin()) if (StringUtils.isNotNull(user.getUserId()) && user.isAdmin())
@ -268,10 +269,11 @@ public class SysUserServiceImpl implements ISysUserService
/** /**
* 修改用户头像 * 修改用户头像
* *
* @param userId 用户ID * @param userName 用户名
* @param avatar 头像地址 * @param avatar 头像地址
* @return 结果 * @return 结果
*/ */
@Override
public boolean updateUserAvatar(String userName, String avatar) public boolean updateUserAvatar(String userName, String avatar)
{ {
return userMapper.updateUserAvatar(userName, avatar) > 0; return userMapper.updateUserAvatar(userName, avatar) > 0;
@ -376,6 +378,7 @@ public class SysUserServiceImpl implements ISysUserService
* @param userIds 需要删除的用户ID * @param userIds 需要删除的用户ID
* @return 结果 * @return 结果
*/ */
@Override
public int deleteUserByIds(Long[] userIds) public int deleteUserByIds(Long[] userIds)
{ {
for (Long userId : userIds) for (Long userId : userIds)

View File

@ -21,7 +21,7 @@ public class GenTableColumnServiceImpl implements IGenTableColumnService
/** /**
* 查询业务字段列表 * 查询业务字段列表
* *
* @param genTableColumn 业务字段编号 * @param tableId 业务字段编号
* @return 业务字段集合 * @return 业务字段集合
*/ */
@Override @Override

View File

@ -13,7 +13,7 @@ public interface IGenTableColumnService
/** /**
* 查询业务字段列表 * 查询业务字段列表
* *
* @param genTableColumn 业务字段编号 * @param tableId 业务字段编号
* @return 业务字段集合 * @return 业务字段集合
*/ */
public List<GenTableColumn> selectGenTableColumnListByTableId(Long tableId); public List<GenTableColumn> selectGenTableColumnListByTableId(Long tableId);

View File

@ -79,7 +79,7 @@ spring:
token: token:
# 令牌自定义标识 # 令牌自定义标识
header: Authorization header: Authorization
# 令牌 # 令牌
secret: abcdefghijklmnopqrstuvwxyz secret: abcdefghijklmnopqrstuvwxyz
# 令牌有效期默认30分钟 # 令牌有效期默认30分钟
expireTime: 30 expireTime: 30