代码优化
This commit is contained in:
@@ -93,7 +93,7 @@ public class IpUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] textToNumericFormatV4(String paramString) {
|
public static byte[] textToNumericFormatV4(String paramString) {
|
||||||
if (paramString.length() == 0) {
|
if (paramString.isEmpty()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
byte[] arrayOfByte = new byte[4];
|
byte[] arrayOfByte = new byte[4];
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package com.jeesite.common.utils;
|
package com.jeesite.common.utils;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
@@ -7,8 +9,6 @@ import java.util.Date;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 身份证工具类
|
* 身份证工具类
|
||||||
*
|
*
|
||||||
@@ -152,7 +152,7 @@ public class IdcardUtils extends StringUtils {
|
|||||||
int iSum17 = getPowerSum(iCard);
|
int iSum17 = getPowerSum(iCard);
|
||||||
// 获取校验位
|
// 获取校验位
|
||||||
String sVal = getCheckCode18(iSum17);
|
String sVal = getCheckCode18(iSum17);
|
||||||
if (sVal.length() > 0) {
|
if (!sVal.isEmpty()) {
|
||||||
idCard18 += sVal;
|
idCard18 += sVal;
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
@@ -205,7 +205,7 @@ public class IdcardUtils extends StringUtils {
|
|||||||
int iSum17 = getPowerSum(iCard);
|
int iSum17 = getPowerSum(iCard);
|
||||||
// 获取校验位
|
// 获取校验位
|
||||||
String val = getCheckCode18(iSum17);
|
String val = getCheckCode18(iSum17);
|
||||||
if (val.length() > 0) {
|
if (!val.isEmpty()) {
|
||||||
if (val.equalsIgnoreCase(code18)) {
|
if (val.equalsIgnoreCase(code18)) {
|
||||||
bTrue = true;
|
bTrue = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -263,21 +263,19 @@ public class FormFilter extends org.apache.shiro.web.filter.authc.FormAuthentica
|
|||||||
protected boolean executeLogin(ServletRequest request, ServletResponse response) throws Exception {
|
protected boolean executeLogin(ServletRequest request, ServletResponse response) throws Exception {
|
||||||
// 是否在登录后生成新的Session(默认false)
|
// 是否在登录后生成新的Session(默认false)
|
||||||
if (Global.getPropertyToBoolean("shiro.isGenerateNewSessionAfterLogin", "false")){
|
if (Global.getPropertyToBoolean("shiro.isGenerateNewSessionAfterLogin", "false")){
|
||||||
String[] keys = new String[] {ValidCodeUtils.VALID_CODE};
|
String[] keys = new String[] { ValidCodeUtils.VALID_CODE };
|
||||||
Map<String, Object> map = MapUtils.newHashMap();
|
Map<String, Object> attrMap = MapUtils.newHashMap();
|
||||||
final Session sessionOld = UserUtils.getSession();
|
final Session sessionOld = UserUtils.getSession();
|
||||||
for (String key : keys) {
|
for (String key : keys) {
|
||||||
Object value = sessionOld.getAttribute(key);
|
Object value = sessionOld.getAttribute(key);
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
map.put(key, value);
|
attrMap.put(key, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
UserUtils.getSubject().logout();
|
UserUtils.getSubject().logout();
|
||||||
// 恢复生成新的Session之前的Session数据
|
// 恢复生成新的Session之前的Session数据
|
||||||
final Session sessionNew = UserUtils.getSession();
|
final Session sessionNew = UserUtils.getSession();
|
||||||
map.forEach((key, value) -> {
|
attrMap.forEach(sessionNew::setAttribute);
|
||||||
sessionNew.setAttribute(key, value);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
return super.executeLogin(request, response);
|
return super.executeLogin(request, response);
|
||||||
}
|
}
|
||||||
@@ -362,8 +360,10 @@ public class FormFilter extends org.apache.shiro.web.filter.authc.FormAuthentica
|
|||||||
data.put("isValidCodeLogin", Global.getConfigToInteger("sys.login.failedNumAfterValidCode", "200") == 0);
|
data.put("isValidCodeLogin", Global.getConfigToInteger("sys.login.failedNumAfterValidCode", "200") == 0);
|
||||||
|
|
||||||
//获取当前会话对象
|
//获取当前会话对象
|
||||||
Session session = UserUtils.getSession();
|
if (ServletUtils.isAjaxRequest(request)) {
|
||||||
data.put("sessionid", (String)session.getId());
|
Session session = UserUtils.getSession();
|
||||||
|
data.put("sessionid", (String)session.getId());
|
||||||
|
}
|
||||||
|
|
||||||
// 如果登录设置了语言,则切换语言
|
// 如果登录设置了语言,则切换语言
|
||||||
if (paramMap.get("lang") != null){
|
if (paramMap.get("lang") != null){
|
||||||
|
|||||||
@@ -240,7 +240,7 @@ public class Log extends DataEntity<Log> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置请求参数
|
* 设置请求参数
|
||||||
* @param paramMap
|
* @param paramsMap
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||||
public void setRequestParams(Map paramsMap){
|
public void setRequestParams(Map paramsMap){
|
||||||
@@ -252,7 +252,7 @@ public class Log extends DataEntity<Log> {
|
|||||||
}
|
}
|
||||||
StringBuilder params = new StringBuilder();
|
StringBuilder params = new StringBuilder();
|
||||||
for (Map.Entry<String, String[]> param : ((Map<String, String[]>)paramsMap).entrySet()){
|
for (Map.Entry<String, String[]> param : ((Map<String, String[]>)paramsMap).entrySet()){
|
||||||
if (params.length() != 0) {
|
if (!params.isEmpty()) {
|
||||||
params.append("&");
|
params.append("&");
|
||||||
}
|
}
|
||||||
params.append(param.getKey() + "=");
|
params.append(param.getKey() + "=");
|
||||||
|
|||||||
@@ -23,13 +23,13 @@ import com.jeesite.modules.sys.service.EmployeeService;
|
|||||||
import com.jeesite.modules.sys.service.UserService;
|
import com.jeesite.modules.sys.service.UserService;
|
||||||
import com.jeesite.modules.sys.utils.EmpUtils;
|
import com.jeesite.modules.sys.utils.EmpUtils;
|
||||||
import com.jeesite.modules.sys.utils.UserUtils;
|
import com.jeesite.modules.sys.utils.UserUtils;
|
||||||
|
import jakarta.validation.ConstraintViolation;
|
||||||
|
import jakarta.validation.ConstraintViolationException;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
import jakarta.validation.ConstraintViolation;
|
|
||||||
import jakarta.validation.ConstraintViolationException;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -80,6 +80,14 @@ public class EmpUserServiceSupport extends CrudService<EmpUserDao, EmpUser>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询数据
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<EmpUser> findList(EmpUser entity) {
|
||||||
|
return super.findList(entity);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页查询数据
|
* 分页查询数据
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -49,7 +49,15 @@ public class EmployeeServiceSupport extends CrudService<EmployeeDao, Employee>
|
|||||||
where.setEmpNo(employee.getEmpNo());
|
where.setEmpNo(employee.getEmpNo());
|
||||||
return dao.getByEntity(where);
|
return dao.getByEntity(where);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询数据
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<Employee> findList(Employee entity) {
|
||||||
|
return super.findList(entity);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询分页数据
|
* 查询分页数据
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -50,6 +50,14 @@ public class PostServiceSupport extends CrudService<PostDao, Post>
|
|||||||
return dao.getByEntity(where);
|
return dao.getByEntity(where);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询数据
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<Post> findList(Post entity) {
|
||||||
|
return super.findList(entity);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询岗位
|
* 查询岗位
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user