优化代码
This commit is contained in:
parent
bc75dc8ddc
commit
46ae31a041
@ -108,7 +108,6 @@ public class Arith
|
|||||||
"The scale must be a positive integer or zero");
|
"The scale must be a positive integer or zero");
|
||||||
}
|
}
|
||||||
BigDecimal b = new BigDecimal(Double.toString(v));
|
BigDecimal b = new BigDecimal(Double.toString(v));
|
||||||
BigDecimal one = new BigDecimal("1");
|
return b.divide(BigDecimal.ONE, scale, RoundingMode.HALF_UP).doubleValue();
|
||||||
return b.divide(one, scale, RoundingMode.HALF_UP).doubleValue();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -286,6 +286,32 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
|
|||||||
return str.substring(start, end);
|
return str.substring(start, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 在字符串中查找第一个出现的 `open` 和最后一个出现的 `close` 之间的子字符串
|
||||||
|
*
|
||||||
|
* @param str 要截取的字符串
|
||||||
|
* @param open 起始字符串
|
||||||
|
* @param close 结束字符串
|
||||||
|
* @return 截取结果
|
||||||
|
*/
|
||||||
|
public static String substringBetweenLast(final String str, final String open, final String close)
|
||||||
|
{
|
||||||
|
if (isEmpty(str) || isEmpty(open) || isEmpty(close))
|
||||||
|
{
|
||||||
|
return NULLSTR;
|
||||||
|
}
|
||||||
|
final int start = str.indexOf(open);
|
||||||
|
if (start != INDEX_NOT_FOUND)
|
||||||
|
{
|
||||||
|
final int end = str.lastIndexOf(close);
|
||||||
|
if (end != INDEX_NOT_FOUND)
|
||||||
|
{
|
||||||
|
return str.substring(start + open.length(), end);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NULLSTR;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 判断是否为空,并且不是空白字符
|
* 判断是否为空,并且不是空白字符
|
||||||
*
|
*
|
||||||
|
@ -105,7 +105,7 @@ public class JobInvokeUtil
|
|||||||
*/
|
*/
|
||||||
public static List<Object[]> getMethodParams(String invokeTarget)
|
public static List<Object[]> getMethodParams(String invokeTarget)
|
||||||
{
|
{
|
||||||
String methodStr = StringUtils.substringBetween(invokeTarget, "(", ")");
|
String methodStr = StringUtils.substringBetweenLast(invokeTarget, "(", ")");
|
||||||
if (StringUtils.isEmpty(methodStr))
|
if (StringUtils.isEmpty(methodStr))
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
|
@ -1448,8 +1448,7 @@ public class ExcelUtil<T>
|
|||||||
*/
|
*/
|
||||||
public String encodingFilename(String filename)
|
public String encodingFilename(String filename)
|
||||||
{
|
{
|
||||||
filename = UUID.randomUUID() + "_" + filename + ".xlsx";
|
return UUID.randomUUID() + "_" + filename + ".xlsx";
|
||||||
return filename;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -52,7 +52,7 @@ public class LogAspect
|
|||||||
* 处理请求前执行
|
* 处理请求前执行
|
||||||
*/
|
*/
|
||||||
@Before(value = "@annotation(controllerLog)")
|
@Before(value = "@annotation(controllerLog)")
|
||||||
public void boBefore(JoinPoint joinPoint, Log controllerLog)
|
public void doBefore(JoinPoint joinPoint, Log controllerLog)
|
||||||
{
|
{
|
||||||
TIME_THREADLOCAL.set(System.currentTimeMillis());
|
TIME_THREADLOCAL.set(System.currentTimeMillis());
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ public class SysPermissionService
|
|||||||
// 设置permissions属性,以便数据权限匹配权限
|
// 设置permissions属性,以便数据权限匹配权限
|
||||||
for (SysRole role : roles)
|
for (SysRole role : roles)
|
||||||
{
|
{
|
||||||
if (StringUtils.equals(role.getStatus(), UserConstants.ROLE_NORMAL))
|
if (StringUtils.equals(role.getStatus(), UserConstants.ROLE_NORMAL) && !role.isAdmin())
|
||||||
{
|
{
|
||||||
Set<String> rolePerms = menuService.selectMenuPermsByRoleId(role.getRoleId());
|
Set<String> rolePerms = menuService.selectMenuPermsByRoleId(role.getRoleId());
|
||||||
role.setPermissions(rolePerms);
|
role.setPermissions(rolePerms);
|
||||||
|
@ -120,6 +120,7 @@ public class TokenService
|
|||||||
|
|
||||||
Map<String, Object> claims = new HashMap<>();
|
Map<String, Object> claims = new HashMap<>();
|
||||||
claims.put(Constants.LOGIN_USER_KEY, token);
|
claims.put(Constants.LOGIN_USER_KEY, token);
|
||||||
|
claims.put(Constants.JWT_USERNAME, loginUser.getUsername());
|
||||||
return createToken(claims);
|
return createToken(claims);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ public class TableDataInfo implements Serializable
|
|||||||
* @param list 列表数据
|
* @param list 列表数据
|
||||||
* @param total 总记录数
|
* @param total 总记录数
|
||||||
*/
|
*/
|
||||||
public TableDataInfo(List<?> list, int total)
|
public TableDataInfo(List<?> list, long total)
|
||||||
{
|
{
|
||||||
this.rows = list;
|
this.rows = list;
|
||||||
this.total = total;
|
this.total = total;
|
||||||
|
@ -181,7 +181,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
update sys_user
|
update sys_user
|
||||||
<set>
|
<set>
|
||||||
<if test="deptId != null and deptId != 0">dept_id = #{deptId},</if>
|
<if test="deptId != null and deptId != 0">dept_id = #{deptId},</if>
|
||||||
<if test="userName != null and userName != ''">user_name = #{userName},</if>
|
|
||||||
<if test="nickName != null and nickName != ''">nick_name = #{nickName},</if>
|
<if test="nickName != null and nickName != ''">nick_name = #{nickName},</if>
|
||||||
<if test="email != null ">email = #{email},</if>
|
<if test="email != null ">email = #{email},</if>
|
||||||
<if test="phonenumber != null ">phonenumber = #{phonenumber},</if>
|
<if test="phonenumber != null ">phonenumber = #{phonenumber},</if>
|
||||||
|
Loading…
Reference in New Issue
Block a user