代码-去掉jsx和jsoup
This commit is contained in:
@@ -210,7 +210,6 @@ public class AnchorCheckAdminService extends BaseService {
|
|||||||
officialGoldRecord.setDiamondNum(diamondNum);
|
officialGoldRecord.setDiamondNum(diamondNum);
|
||||||
}
|
}
|
||||||
if (fourthCell != null) {
|
if (fourthCell != null) {
|
||||||
fourthCell.setCellType(Cell.CELL_TYPE_STRING);
|
|
||||||
String remark = fourthCell.getStringCellValue();
|
String remark = fourthCell.getStringCellValue();
|
||||||
officialGoldRecord.setRemark(remark);
|
officialGoldRecord.setRemark(remark);
|
||||||
}
|
}
|
||||||
|
@@ -505,7 +505,7 @@ public class GiftAdminService extends AbstractCoreService<Gift, GiftExample> {
|
|||||||
RoomExclusiveGift roomExclusiveGift = new RoomExclusiveGift();
|
RoomExclusiveGift roomExclusiveGift = new RoomExclusiveGift();
|
||||||
//获取房主uid
|
//获取房主uid
|
||||||
Cell firstCell = row.getCell(row.getFirstCellNum());
|
Cell firstCell = row.getCell(row.getFirstCellNum());
|
||||||
if (firstCell != null && firstCell.getCellType() != Cell.CELL_TYPE_BLANK) {
|
if (firstCell != null) {
|
||||||
Long erbanNo = Double.valueOf(firstCell.getNumericCellValue()).longValue();
|
Long erbanNo = Double.valueOf(firstCell.getNumericCellValue()).longValue();
|
||||||
Users users = usersService.getUserByErbanNo(erbanNo);
|
Users users = usersService.getUserByErbanNo(erbanNo);
|
||||||
if (users == null) {
|
if (users == null) {
|
||||||
|
@@ -1,13 +1,10 @@
|
|||||||
package com.accompany.admin.util;
|
package com.accompany.admin.util;
|
||||||
|
|
||||||
import net.sf.jxls.exception.ParsePropertyException;
|
|
||||||
import net.sf.jxls.transformer.XLSTransformer;
|
|
||||||
import org.apache.poi.hssf.usermodel.HSSFCell;
|
import org.apache.poi.hssf.usermodel.HSSFCell;
|
||||||
import org.apache.poi.hssf.usermodel.HSSFFont;
|
import org.apache.poi.hssf.usermodel.HSSFFont;
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||||
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
||||||
import org.apache.poi.ss.usermodel.*;
|
import org.apache.poi.ss.usermodel.*;
|
||||||
import org.jsoup.Jsoup;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.util.ObjectUtils;
|
import org.springframework.util.ObjectUtils;
|
||||||
@@ -50,17 +47,13 @@ public class ExcelUtils {
|
|||||||
// head font style
|
// head font style
|
||||||
CellStyle style = workbook.createCellStyle();
|
CellStyle style = workbook.createCellStyle();
|
||||||
Font font = workbook.createFont();
|
Font font = workbook.createFont();
|
||||||
font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
|
|
||||||
style.setFont(font);
|
style.setFont(font);
|
||||||
style.setFillForegroundColor(IndexedColors.LIME.getIndex());
|
style.setFillForegroundColor(IndexedColors.LIME.getIndex());
|
||||||
style.setFillPattern(CellStyle.SOLID_FOREGROUND);
|
|
||||||
style.setAlignment(CellStyle.ALIGN_CENTER);
|
|
||||||
|
|
||||||
Sheet sheet = workbook.createSheet("Sheet1");
|
Sheet sheet = workbook.createSheet("Sheet1");
|
||||||
Row row = sheet.createRow(0);
|
Row row = sheet.createRow(0);
|
||||||
for (int i = 0; i < listHeaders.size(); i++) {
|
for (int i = 0; i < listHeaders.size(); i++) {
|
||||||
Cell cell = row.createCell(i);
|
Cell cell = row.createCell(i);
|
||||||
cell.setCellType(HSSFCell.ENCODING_UTF_16);
|
|
||||||
cell.setCellValue(listHeaders.get(i));
|
cell.setCellValue(listHeaders.get(i));
|
||||||
cell.setCellStyle(style);
|
cell.setCellStyle(style);
|
||||||
sheet.setColumnWidth(i,
|
sheet.setColumnWidth(i,
|
||||||
@@ -75,37 +68,12 @@ public class ExcelUtils {
|
|||||||
Cell cell = row.createCell(j);
|
Cell cell = row.createCell(j);
|
||||||
if(bean.get(j)!=null) {
|
if(bean.get(j)!=null) {
|
||||||
String cellValue = bean.get(j).toString();
|
String cellValue = bean.get(j).toString();
|
||||||
if (cellValue.matches(htmlRegex))
|
|
||||||
cellValue = Jsoup.parse(cellValue).text();
|
|
||||||
cell.setCellValue(cellValue);
|
cell.setCellValue(cellValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return workbook;
|
return workbook;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 使用模板来创建Excel。使用了jxls库。
|
|
||||||
* <p>
|
|
||||||
* Excel模板请参考:http://jxls.sourceforge.net/reference/simplebeans.html
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @see http://jxls.sourceforge.net/reference/simplebeans.html
|
|
||||||
* @param templatePath
|
|
||||||
* @param map
|
|
||||||
* @return
|
|
||||||
* @throws FileNotFoundException
|
|
||||||
* @throws ParsePropertyException
|
|
||||||
* @throws InvalidFormatException
|
|
||||||
*/
|
|
||||||
public static Workbook createExcelSheetByTemplate(String templatePath,
|
|
||||||
Map<String, Object> map) throws FileNotFoundException,
|
|
||||||
ParsePropertyException, InvalidFormatException {
|
|
||||||
FileInputStream in = new FileInputStream(templatePath);
|
|
||||||
XLSTransformer transformer = new XLSTransformer();
|
|
||||||
Workbook workbook = transformer.transformXLS(in, map);
|
|
||||||
return workbook;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 帮助方法:设置Excel文件下载的response头。
|
* 帮助方法:设置Excel文件下载的response头。
|
||||||
@@ -175,78 +143,4 @@ public class ExcelUtils {
|
|||||||
|
|
||||||
return pixels;
|
return pixels;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* 读取某个工作簿上的所有单元格的值。
|
|
||||||
* @param fis 文件流
|
|
||||||
* @param sheetOrder
|
|
||||||
* 工作簿序号,从0开始。
|
|
||||||
* @return List<Object[]> 所有单元格的值。
|
|
||||||
* @throws IOException
|
|
||||||
* 加载excel文件IO异常。
|
|
||||||
* @throws FileNotFoundException
|
|
||||||
* excel文件没有找到异常。
|
|
||||||
* @throws InvalidFormatException
|
|
||||||
*/
|
|
||||||
public static List<Object[]> read(InputStream fis,int sheetOrder) throws FileNotFoundException,
|
|
||||||
IOException, InvalidFormatException {
|
|
||||||
Workbook workbook = WorkbookFactory.create(fis);
|
|
||||||
if (fis != null) {
|
|
||||||
fis.close();
|
|
||||||
}
|
|
||||||
Sheet sheet = workbook.getSheetAt(sheetOrder);
|
|
||||||
// 用来记录excel值
|
|
||||||
List<Object[]> valueList = new LinkedList<Object[]>();
|
|
||||||
int coloumNum=sheet.getRow(0).getPhysicalNumberOfCells();
|
|
||||||
// 循环遍历每一行、每一列。
|
|
||||||
for (Row row : sheet) {
|
|
||||||
// 每一行
|
|
||||||
Object[] rowObject = null;
|
|
||||||
for (int i =0;i<coloumNum;i++) {
|
|
||||||
// cell.getCellType是获得cell里面保存的值的type
|
|
||||||
Cell cell = row.getCell(i);
|
|
||||||
if(cell!=null){
|
|
||||||
switch (cell.getCellType()) {
|
|
||||||
case Cell.CELL_TYPE_BOOLEAN:
|
|
||||||
// 得到Boolean对象的方法
|
|
||||||
rowObject = ObjectUtils.addObjectToArray(rowObject,
|
|
||||||
cell.getBooleanCellValue());
|
|
||||||
break;
|
|
||||||
case Cell.CELL_TYPE_NUMERIC:
|
|
||||||
// 先看是否是日期格式
|
|
||||||
if (DateUtil.isCellDateFormatted(cell)) {
|
|
||||||
// 读取日期格式
|
|
||||||
rowObject = ObjectUtils.addObjectToArray(rowObject,
|
|
||||||
cell.getDateCellValue());
|
|
||||||
} else {
|
|
||||||
DecimalFormat df = new DecimalFormat();
|
|
||||||
// 单元格的值,替换掉,
|
|
||||||
String value = df.format(cell.getNumericCellValue())
|
|
||||||
.replace(",", "");
|
|
||||||
// 读取数字
|
|
||||||
rowObject = ObjectUtils.addObjectToArray(rowObject,
|
|
||||||
value);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case Cell.CELL_TYPE_FORMULA:
|
|
||||||
// 读取公式
|
|
||||||
rowObject = ObjectUtils.addObjectToArray(rowObject,
|
|
||||||
cell.getCellFormula());
|
|
||||||
break;
|
|
||||||
case Cell.CELL_TYPE_STRING:
|
|
||||||
// 读取String
|
|
||||||
rowObject = ObjectUtils.addObjectToArray(rowObject, cell
|
|
||||||
.getRichStringCellValue().toString());
|
|
||||||
break;
|
|
||||||
default : rowObject = ObjectUtils.addObjectToArray(rowObject, "");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
rowObject = ObjectUtils.addObjectToArray(rowObject, "");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 将这行添加到list。
|
|
||||||
valueList.add(rowObject);
|
|
||||||
}
|
|
||||||
return valueList;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -22,11 +22,6 @@ public class WebInterceptorConfig implements WebMvcConfigurer {
|
|||||||
return new LoginInterceptor();
|
return new LoginInterceptor();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
|
||||||
public FusingInterceptor getFusingInterceptor() {
|
|
||||||
return new FusingInterceptor();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public ModelHallAuthInterceptor getModelHallAuthInterceptor() {
|
public ModelHallAuthInterceptor getModelHallAuthInterceptor() {
|
||||||
return new ModelHallAuthInterceptor();
|
return new ModelHallAuthInterceptor();
|
||||||
@@ -47,11 +42,6 @@ public class WebInterceptorConfig implements WebMvcConfigurer {
|
|||||||
return new AppVersionInterceptor();
|
return new AppVersionInterceptor();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
|
||||||
public UserInfoCompletedInterceptor getUserInfoCompletedInterceptor() {
|
|
||||||
return new UserInfoCompletedInterceptor();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加拦截器
|
* 添加拦截器
|
||||||
* @param registry
|
* @param registry
|
||||||
@@ -62,7 +52,6 @@ public class WebInterceptorConfig implements WebMvcConfigurer {
|
|||||||
registry.addInterceptor(getSecurityInterceptor()).addPathPatterns("/**");
|
registry.addInterceptor(getSecurityInterceptor()).addPathPatterns("/**");
|
||||||
registry.addInterceptor(getAppVersionInterceptor());
|
registry.addInterceptor(getAppVersionInterceptor());
|
||||||
registry.addInterceptor(getModelHallAuthInterceptor());
|
registry.addInterceptor(getModelHallAuthInterceptor());
|
||||||
registry.addInterceptor(getUserInfoCompletedInterceptor()).addPathPatterns("/**");
|
|
||||||
registry.addInterceptor(getWebInterceptor());
|
registry.addInterceptor(getWebInterceptor());
|
||||||
registry.addInterceptor(getXssInterceptor());
|
registry.addInterceptor(getXssInterceptor());
|
||||||
}
|
}
|
||||||
|
@@ -1,48 +0,0 @@
|
|||||||
package com.accompany.business.interceptor;
|
|
||||||
|
|
||||||
import com.accompany.common.redis.RedisKey;
|
|
||||||
import com.accompany.core.service.common.JedisService;
|
|
||||||
import com.accompany.core.util.StringUtils;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.web.servlet.ModelAndView;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author yangziwen
|
|
||||||
* @description 根据配置动态熔断服务
|
|
||||||
* @date 2018/6/22 00:49
|
|
||||||
*/
|
|
||||||
public class FusingInterceptor extends BasicInterceptor {
|
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(FusingInterceptor.class);
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private JedisService jedisService;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object object) throws Exception {
|
|
||||||
String cache = this.jedisService.hget(RedisKey.stop_service.getKey(), request.getRequestURI());
|
|
||||||
if (StringUtils.isNotEmpty(cache)) {
|
|
||||||
logger.warn("{} has been fusing", request.getRequestURI());
|
|
||||||
this.writeResponse(response, 503, "service suspend");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void postHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, ModelAndView modelAndView) throws Exception {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void afterCompletion(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, Exception e) throws Exception {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -1,92 +0,0 @@
|
|||||||
package com.accompany.business.interceptor;
|
|
||||||
|
|
||||||
import com.accompany.common.utils.EnvComponent;
|
|
||||||
import com.accompany.core.service.SysConfService;
|
|
||||||
import com.alibaba.fastjson.JSON;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.core.MethodParameter;
|
|
||||||
import org.springframework.http.MediaType;
|
|
||||||
import org.springframework.http.server.ServerHttpRequest;
|
|
||||||
import org.springframework.http.server.ServerHttpResponse;
|
|
||||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
|
||||||
import org.springframework.web.context.request.RequestContextHolder;
|
|
||||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
|
||||||
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Harry Zhang
|
|
||||||
* @since 9/16/20 4:21 PM
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
@ControllerAdvice
|
|
||||||
public class ResponseBodyHandler implements ResponseBodyAdvice {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private SysConfService sysConfService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private EnvComponent envComponent;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean supports(MethodParameter returnType, Class converterType) {
|
|
||||||
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
|
||||||
if (null == attributes) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
HttpServletRequest request = attributes.getRequest();
|
|
||||||
String app = request.getParameter("app");
|
|
||||||
String channel = request.getParameter("channel");
|
|
||||||
return ("youmi_appstore".equals(channel) || "youmi".equals(app));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object beforeBodyWrite(Object body, MethodParameter returnType, MediaType selectedContentType,
|
|
||||||
Class selectedConverterType, ServerHttpRequest request, ServerHttpResponse response) {
|
|
||||||
|
|
||||||
if (null == body) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (!envComponent.getOnlineEnv()) {
|
|
||||||
boolean isReplaceDomain = sysConfService.getBoolValueById("is_replace_domain");
|
|
||||||
if (!isReplaceDomain) {
|
|
||||||
return body;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
log.info("是悠米包,替换图片域名...");
|
|
||||||
String json = JSON.toJSONString(body);
|
|
||||||
log.info("json: {}", json);
|
|
||||||
String firstChars = json.substring(0, 1);
|
|
||||||
String imgSourceUrl = "img.pekolive.com";
|
|
||||||
String imgTargetUrl = "image.hfighting.com";
|
|
||||||
if (json.contains(imgSourceUrl)) {
|
|
||||||
json = json.replaceAll(imgSourceUrl, imgTargetUrl);
|
|
||||||
}
|
|
||||||
String h5SourceUrl = "api.lecheng163.com/yinyou";
|
|
||||||
String h5TargetUrl = "api.hfighting.com/youmi";
|
|
||||||
if (json.contains(h5SourceUrl)) {
|
|
||||||
json = json.replaceAll(h5SourceUrl, h5TargetUrl);
|
|
||||||
}
|
|
||||||
String apiSourceUrl = "api.pekolive.com";
|
|
||||||
String apiTargetUrl = "api.hfighting.com";
|
|
||||||
if (json.contains(apiSourceUrl)) {
|
|
||||||
json = json.replaceAll(apiSourceUrl, apiTargetUrl);
|
|
||||||
}
|
|
||||||
// 对象
|
|
||||||
if ("{".equals(firstChars)) {
|
|
||||||
Map object = JSON.parseObject(json, Map.class);
|
|
||||||
return object;
|
|
||||||
}
|
|
||||||
// 数组
|
|
||||||
if ("[".equals(firstChars)) {
|
|
||||||
List<Map> maps = JSON.parseArray(json, Map.class);
|
|
||||||
return maps;
|
|
||||||
}
|
|
||||||
return body;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -76,12 +76,10 @@ public class SecurityInterceptor extends BasicInterceptor {
|
|||||||
* @return
|
* @return
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
private boolean isLegalRequest(HttpServletRequest request) throws Exception {
|
private boolean isLegalRequest(HttpServletRequest request) {
|
||||||
TreeMap<String, String[]> paramsMap = new TreeMap<>();
|
TreeMap<String, String[]> paramsMap = new TreeMap<>(request.getParameterMap());
|
||||||
paramsMap.putAll(request.getParameterMap());
|
|
||||||
|
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
StringBuffer builder = new StringBuffer();
|
|
||||||
Set<Map.Entry<String, String[]>> entries = paramsMap.entrySet();
|
Set<Map.Entry<String, String[]>> entries = paramsMap.entrySet();
|
||||||
for (Map.Entry<String, String[]> entry : entries) {
|
for (Map.Entry<String, String[]> entry : entries) {
|
||||||
String name = entry.getKey();
|
String name = entry.getKey();
|
||||||
@@ -111,16 +109,4 @@ public class SecurityInterceptor extends BasicInterceptor {
|
|||||||
return StringUtils.isNotEmpty(excludeUri) && StringUtils.equalsIgnoreCase(excludeUri, Boolean.TRUE.toString());
|
return StringUtils.isNotEmpty(excludeUri) && StringUtils.equalsIgnoreCase(excludeUri, Boolean.TRUE.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void postHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, ModelAndView modelAndView)
|
|
||||||
throws Exception {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void afterCompletion(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, Exception e) throws Exception {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -1,105 +0,0 @@
|
|||||||
package com.accompany.business.interceptor;
|
|
||||||
|
|
||||||
|
|
||||||
import com.accompany.common.annotation.Authorization;
|
|
||||||
import com.accompany.common.annotation.H5Authorization;
|
|
||||||
import com.accompany.common.config.SystemConfig;
|
|
||||||
import com.accompany.common.constant.ApplicationConstant;
|
|
||||||
import com.accompany.common.status.BusiStatus;
|
|
||||||
import com.accompany.common.utils.StringUtils;
|
|
||||||
import com.accompany.core.model.Users;
|
|
||||||
import com.accompany.core.service.common.JedisService;
|
|
||||||
import com.accompany.core.service.user.UsersBaseService;
|
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.web.method.HandlerMethod;
|
|
||||||
import org.springframework.web.servlet.ModelAndView;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户完善资料拦截器
|
|
||||||
*/
|
|
||||||
public class UserInfoCompletedInterceptor extends BasicInterceptor {
|
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(UserInfoCompletedInterceptor.class);
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
JedisService jedisService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private UsersBaseService usersBaseService;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
|
||||||
if (!(handler instanceof HandlerMethod)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isWhiteList(request.getRequestURI())) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
HandlerMethod handlerMethod = (HandlerMethod) handler;
|
|
||||||
Method method = handlerMethod.getMethod();
|
|
||||||
|
|
||||||
// 不需要登录校验
|
|
||||||
if (method.getAnnotation(Authorization.class) == null && method.getAnnotation(H5Authorization.class) == null) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
String uid = this.getUid(request);
|
|
||||||
if (StringUtils.isEmpty(uid) || StringUtils.equalsIgnoreCase(uid, "null") || !StringUtils.isNumeric(uid)) {
|
|
||||||
logger.warn("uid illegal, uri={}, uid={}", request.getRequestURI(), uid);
|
|
||||||
writeLoginExpireResponse(response, 401, "Login status has expired, please log in again ~");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Users user = usersBaseService.getUsersByUid(Long.valueOf(uid));
|
|
||||||
if (user == null || StringUtils.isBlank(user.getNick()) ||user.getGender() == null || StringUtils.isBlank(user.getAvatar())) {
|
|
||||||
logger.warn("user not complete info, uri={}, uid={}", request.getRequestURI(), uid);
|
|
||||||
writeResponse(response, HttpServletResponse.SC_OK, BusiStatus.USER_NOT_COMPLETE_INFO.value(), BusiStatus.USER_NOT_COMPLETE_INFO.getReasonPhrase());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isWhiteList(String requestURI) {
|
|
||||||
if (CollectionUtils.isNotEmpty(SystemConfig.userInfoCompleteInterceptWhiteList)) {
|
|
||||||
return SystemConfig.userInfoCompleteInterceptWhiteList.contains(requestURI);
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取 uid, 以业务参数为首选
|
|
||||||
* @param request
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private String getUid(HttpServletRequest request) {
|
|
||||||
String uidStr = request.getHeader(ApplicationConstant.PublicParameters.PUB_UID);
|
|
||||||
if (StringUtils.isEmpty(uidStr)) {
|
|
||||||
uidStr = request.getParameter(ApplicationConstant.PublicParameters.UID);
|
|
||||||
}
|
|
||||||
return uidStr;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void postHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, ModelAndView modelAndView)
|
|
||||||
throws Exception {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void afterCompletion(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, Exception e) throws Exception {
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -55,12 +55,10 @@
|
|||||||
<ons-client.version>1.2.1</ons-client.version>
|
<ons-client.version>1.2.1</ons-client.version>
|
||||||
<sitemesh.version>2.4.2</sitemesh.version>
|
<sitemesh.version>2.4.2</sitemesh.version>
|
||||||
<pagehelper.version>5.1.8</pagehelper.version>
|
<pagehelper.version>5.1.8</pagehelper.version>
|
||||||
<jsoup.version>1.10.2</jsoup.version>
|
|
||||||
<validation-api.version>2.0.1.Final</validation-api.version>
|
<validation-api.version>2.0.1.Final</validation-api.version>
|
||||||
<aliyun-java-sdk-dysmsapi.version>1.1.0</aliyun-java-sdk-dysmsapi.version>
|
<aliyun-java-sdk-dysmsapi.version>1.1.0</aliyun-java-sdk-dysmsapi.version>
|
||||||
<aliyun-sdk-mns.version>1.1.8</aliyun-sdk-mns.version>
|
<aliyun-sdk-mns.version>1.1.8</aliyun-sdk-mns.version>
|
||||||
<commons-fileupload.version>1.3</commons-fileupload.version>
|
<commons-fileupload.version>1.3</commons-fileupload.version>
|
||||||
<jxls-core.version>1.0.5</jxls-core.version>
|
|
||||||
<elasticsearch.version>7.10.0</elasticsearch.version>
|
<elasticsearch.version>7.10.0</elasticsearch.version>
|
||||||
<orika-core.version>1.5.4</orika-core.version>
|
<orika-core.version>1.5.4</orika-core.version>
|
||||||
<spring-security-oauth2-autoconfigure.version>2.0.1.RELEASE</spring-security-oauth2-autoconfigure.version>
|
<spring-security-oauth2-autoconfigure.version>2.0.1.RELEASE</spring-security-oauth2-autoconfigure.version>
|
||||||
@@ -356,12 +354,6 @@
|
|||||||
<version>${commons-fileupload.version}</version>
|
<version>${commons-fileupload.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>net.sf.jxls</groupId>
|
|
||||||
<artifactId>jxls-core</artifactId>
|
|
||||||
<version>${jxls-core.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jsoup</groupId>
|
<groupId>org.jsoup</groupId>
|
||||||
<artifactId>jsoup</artifactId>
|
<artifactId>jsoup</artifactId>
|
||||||
@@ -618,16 +610,6 @@
|
|||||||
<artifactId>aliyun-java-sdk-cloudauth</artifactId>
|
<artifactId>aliyun-java-sdk-cloudauth</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>net.sf.jxls</groupId>
|
|
||||||
<artifactId>jxls-core</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.jsoup</groupId>
|
|
||||||
<artifactId>jsoup</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.validation</groupId>
|
<groupId>javax.validation</groupId>
|
||||||
<artifactId>validation-api</artifactId>
|
<artifactId>validation-api</artifactId>
|
||||||
|
@@ -51,7 +51,7 @@ public class PasswordAuthenticationProvider implements AuthenticationProvider {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
|
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
|
||||||
Map<?, ?> params = (Map<?, ?>) authentication.getDetails();
|
Map<String, ?> params = (Map<String, ?>) authentication.getDetails();
|
||||||
String smsCode = (String) params.get("code");
|
String smsCode = (String) params.get("code");
|
||||||
String phoneAreaCode = (String) params.get("phoneAreaCode");
|
String phoneAreaCode = (String) params.get("phoneAreaCode");
|
||||||
String ipAddress = RequestContextHolderUtils.getRemoteAddr();
|
String ipAddress = RequestContextHolderUtils.getRemoteAddr();
|
||||||
|
@@ -38,7 +38,7 @@ public class VerifyCodeAuthenticationProvider implements AuthenticationProvider
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
|
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
|
||||||
Map<?, ?> params = (Map<?, ?>) authentication.getDetails();
|
Map<String, ?> params = (Map<String, ?>) authentication.getDetails();
|
||||||
String phone = authentication.getName();
|
String phone = authentication.getName();
|
||||||
String code = (String) authentication.getCredentials();
|
String code = (String) authentication.getCredentials();
|
||||||
String phoneAreaCode = (String) params.get(PHONE_AREA_CODE);
|
String phoneAreaCode = (String) params.get(PHONE_AREA_CODE);
|
||||||
|
@@ -75,12 +75,10 @@ public class SecurityInterceptor extends BasicInterceptor {
|
|||||||
* @return
|
* @return
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
private boolean isLegalRequest(HttpServletRequest request) throws Exception {
|
private boolean isLegalRequest(HttpServletRequest request) {
|
||||||
TreeMap<String, String[]> paramsMap = new TreeMap<>();
|
TreeMap<String, String[]> paramsMap = new TreeMap<>(request.getParameterMap());
|
||||||
paramsMap.putAll(request.getParameterMap());
|
|
||||||
|
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
StringBuffer builder = new StringBuffer();
|
|
||||||
Set<Map.Entry<String, String[]>> entries = paramsMap.entrySet();
|
Set<Map.Entry<String, String[]>> entries = paramsMap.entrySet();
|
||||||
for (Map.Entry<String, String[]> entry : entries) {
|
for (Map.Entry<String, String[]> entry : entries) {
|
||||||
String name = entry.getKey();
|
String name = entry.getKey();
|
||||||
@@ -110,16 +108,4 @@ public class SecurityInterceptor extends BasicInterceptor {
|
|||||||
String excludeUri = this.jedisService.hget(RedisKey.exclude_uri.getKey(), url);
|
String excludeUri = this.jedisService.hget(RedisKey.exclude_uri.getKey(), url);
|
||||||
return StringUtils.isNotEmpty(excludeUri) && StringUtils.equalsIgnoreCase(excludeUri, Boolean.TRUE.toString());
|
return StringUtils.isNotEmpty(excludeUri) && StringUtils.equalsIgnoreCase(excludeUri, Boolean.TRUE.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void postHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, ModelAndView modelAndView)
|
|
||||||
throws Exception {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void afterCompletion(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, Exception e) throws Exception {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user