Compare commits

...

3 Commits

Author SHA1 Message Date
曾文豪
cf6d05c2b4 refactor(springboot-parent): 升级至 Java 17 及 Jakarta 包迁移 2025-12-11 14:40:52 +08:00
曾文豪
57f0e2ab82 publish 2.0.33
All checks were successful
/ local-deploy (push) Successful in 1m33s
2025-11-19 15:08:29 +08:00
曾文豪
cce180806b publish 2.0.32
All checks were successful
/ local-deploy (push) Successful in 24s
2025-09-28 16:02:57 +08:00
53 changed files with 466 additions and 170 deletions

View File

@@ -1,21 +1,2 @@
## 2.0.12
- 调整OkHttp日志
## 2.0.0.rc46
现在导入导出都接入底层流程,无需新增接口,只需要实现接口即可。
- 过程日志不再和操作日志同时存在
- 过程日志新增params参数
- 通过实现*TsImportHandler*接口编写导入逻辑
- 通过实现*TsExportHandler*接口编写导出逻辑
## 2.0.0.rc4
- perfTsTokenConfig不在提供静态方法
- perf移除TsTokenAspect由TokenWebMvcConfigurer替代并实现TokenBean参数注入
## 4.0.0

21
CHANGELOG_v2.md Normal file
View File

@@ -0,0 +1,21 @@
## 2.0.12
- 调整OkHttp日志
## 2.0.0.rc46
现在导入导出都接入底层流程,无需新增接口,只需要实现接口即可。
- 过程日志不再和操作日志同时存在
- 过程日志新增params参数
- 通过实现*TsImportHandler*接口编写导入逻辑
- 通过实现*TsExportHandler*接口编写导出逻辑
## 2.0.0.rc4
- perfTsTokenConfig不在提供静态方法
- perf移除TsTokenAspect由TokenWebMvcConfigurer替代并实现TokenBean参数注入

26
pom.xml
View File

@@ -6,7 +6,7 @@
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId>
<version>2.0.31</version>
<version>4.0.0.alpha1</version>
<packaging>pom</packaging>
<name>springboot-parent</name>
<description>杭州铁晟科技有限公司基础依赖</description>
@@ -14,7 +14,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.4</version>
<version>4.0.0</version>
</parent>
<modules>
@@ -31,11 +31,11 @@
</modules>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<hutool.version>5.8.31</hutool.version>
<hutool.version>5.8.42</hutool.version>
</properties>
<developers>
@@ -59,49 +59,49 @@
<dependency>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-database</artifactId>
<version>2.0.31</version>
<version>4.0.0.alpha1</version>
</dependency>
<dependency>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-login</artifactId>
<version>2.0.31</version>
<version>4.0.0.alpha1</version>
</dependency>
<dependency>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-web</artifactId>
<version>2.0.31</version>
<version>4.0.0.alpha1</version>
</dependency>
<dependency>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-util</artifactId>
<version>2.0.31</version>
<version>4.0.0.alpha1</version>
</dependency>
<dependency>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-platform</artifactId>
<version>2.0.31</version>
<version>4.0.0.alpha1</version>
</dependency>
<dependency>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-message</artifactId>
<version>2.0.31</version>
<version>4.0.0.alpha1</version>
</dependency>
<dependency>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-role</artifactId>
<version>2.0.31</version>
<version>4.0.0.alpha1</version>
</dependency>
<dependency>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-annotation</artifactId>
<version>2.0.31</version>
<version>4.0.0.alpha1</version>
</dependency>
<dependency>

View File

@@ -1,31 +0,0 @@
#-------------------------------------------------------------------------------#
# Qodana analysis is configured by qodana.yaml file #
# https://www.jetbrains.com/help/qodana/qodana-yaml.html #
#-------------------------------------------------------------------------------#
version: "1.0"
#Specify inspection profile for code analysis
profile:
name: qodana.starter
#Enable inspections
#include:
# - name: <SomeEnabledInspectionId>
#Disable inspections
#exclude:
# - name: <SomeDisabledInspectionId>
# paths:
# - <path/where/not/run/inspection>
projectJDK: 17 #(Applied in CI/CD pipeline)
#Execute shell command before Qodana execution (Applied in CI/CD pipeline)
#bootstrap: sh ./prepare-qodana.sh
#Install IDE plugins before Qodana execution (Applied in CI/CD pipeline)
#plugins:
# - id: <plugin.id> #(plugin id can be found at https://plugins.jetbrains.com)
#Specify Qodana linter for analysis (Applied in CI/CD pipeline)
linter: jetbrains/qodana-jvm:latest

View File

@@ -6,15 +6,15 @@
<parent>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId>
<version>2.0.31</version>
<version>4.0.0.alpha1</version>
</parent>
<artifactId>springboot-ademo</artifactId>
<version>2.0.31</version>
<version>4.0.0.alpha1</version>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- 该模块不发布到maven仓库 -->
<maven.deploy.skip>true</maven.deploy.skip>

View File

@@ -10,7 +10,7 @@ import com.tiesheng.web.service.TieshengWebConfigurer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpServletResponse;
import java.util.Objects;
@Component

View File

@@ -35,7 +35,7 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpServletResponse;
import java.io.File;
import java.util.function.Consumer;

View File

@@ -6,14 +6,14 @@
<parent>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId>
<version>2.0.31</version>
<version>4.0.0.alpha1</version>
</parent>
<artifactId>springboot-annotation</artifactId>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

View File

@@ -6,14 +6,14 @@
<parent>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId>
<version>2.0.31</version>
<version>4.0.0.alpha1</version>
</parent>
<artifactId>springboot-chart</artifactId>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

View File

@@ -15,13 +15,13 @@ import com.tiesheng.util.config.GlobalConfig;
import com.tiesheng.util.exception.ApiException;
import com.tiesheng.util.pojos.ApiResp;
import com.tiesheng.util.pojos.FileUploadPath;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.ArrayList;
import java.util.List;

View File

@@ -17,10 +17,10 @@ import com.tiesheng.util.exception.ApiException;
import com.tiesheng.util.pojos.ApiResp;
import com.tiesheng.util.pojos.IdDTO;
import com.tiesheng.util.pojos.PageDTO;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;
@RestController

View File

@@ -1,9 +1,9 @@
package com.tiesheng.role.pojos.dto;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.Size;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.Size;
import java.util.List;
@Data

View File

@@ -2,9 +2,9 @@ package com.tiesheng.role.pojos.dto;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.annotation.JSONField;
import jakarta.validation.constraints.NotEmpty;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
import java.util.List;
@Data

View File

@@ -4,11 +4,10 @@ import com.tiesheng.role.mapper.CoreChartTableMapper;
import com.tiesheng.role.mapper.CoreChartTemplateMapper;
import com.tiesheng.role.pojos.dao.CoreChartTemplate;
import com.tiesheng.util.service.TsServiceBase;
import jakarta.annotation.Resource;
import lombok.Getter;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@Service
public class ChartService extends TsServiceBase<CoreChartTemplateMapper, CoreChartTemplate> {

View File

@@ -6,14 +6,14 @@
<parent>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId>
<version>2.0.31</version>
<version>4.0.0.alpha1</version>
</parent>
<artifactId>springboot-database</artifactId>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

View File

@@ -9,13 +9,13 @@ import cn.hutool.core.util.StrUtil;
import cn.hutool.db.Db;
import cn.hutool.db.Entity;
import com.tiesheng.database.config.DbMigrationConfig;
import jakarta.servlet.ServletContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.ServletContextInitializer;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.stereotype.Component;
import javax.servlet.ServletContext;
import javax.sql.DataSource;
import java.io.InputStream;
import java.sql.SQLException;

View File

@@ -6,14 +6,14 @@
<parent>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId>
<version>2.0.31</version>
<version>4.0.0.alpha1</version>
</parent>
<artifactId>springboot-login</artifactId>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

View File

@@ -23,7 +23,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpServletResponse;
import java.lang.reflect.Method;
import java.util.List;

View File

@@ -28,7 +28,7 @@ import com.tiesheng.util.pojos.TokenBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.Map;

View File

@@ -18,7 +18,7 @@ import com.tiesheng.util.service.role.TsAuthorityHandler;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpServletResponse;
import java.util.Objects;
/**

View File

@@ -9,7 +9,7 @@ import com.tiesheng.util.pojos.TokenBean;
import com.tiesheng.util.service.TsCacheService;
import org.springframework.context.annotation.Configuration;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpServletResponse;
/**
* @author hao

View File

@@ -6,14 +6,14 @@
<parent>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId>
<version>2.0.31</version>
<version>4.0.0.alpha1</version>
</parent>
<artifactId>springboot-message</artifactId>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

View File

@@ -6,14 +6,14 @@
<parent>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId>
<version>2.0.31</version>
<version>4.0.0.alpha1</version>
</parent>
<artifactId>springboot-platform</artifactId>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

View File

@@ -141,7 +141,13 @@ public class PlatformWxmpConfig {
public WxUserInfo getOAuth2AccessToken(String service, String code) {
WxConfigBean configBean = getConfigBean(service);
WxOAuth2AccessToken wxOAuth2AccessToken = WxOAuth2AccessToken.create(configBean.getAppId(), configBean.getAppSecret(), code);
WxUserInfo wxUserInfo = WxUserInfo.create(wxOAuth2AccessToken);
WxUserInfo wxUserInfo;
if (configBean.canUserInfo()) {
wxUserInfo = WxUserInfo.create(wxOAuth2AccessToken);
} else {
wxUserInfo = new WxUserInfo();
wxUserInfo.setOpenid(wxOAuth2AccessToken.getOpenid());
}
wxUserInfo.setAppId(configBean.getAppId());
return wxUserInfo;
}
@@ -162,7 +168,8 @@ public class PlatformWxmpConfig {
///////////////////////////////////////////////////////////////////////////
// setter\getter
///////////////////////////////////////////////////////////////////////////
/// ////////////////////////////////////////////////////////////////////////
public Map<String, WxConfigBean> getConfigs() {
return configs;

View File

@@ -9,6 +9,15 @@ public class WxConfigBean {
private String appSecret;
private String scope = "snsapi_base";
/**
* 是否可以获取用户信息
*
* @return
*/
public boolean canUserInfo() {
return !"snsapi_base".equals(scope);
}
///////////////////////////////////////////////////////////////////////////
// setter\getter

View File

@@ -6,14 +6,14 @@
<parent>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId>
<version>2.0.31</version>
<version>4.0.0.alpha1</version>
</parent>
<artifactId>springboot-role</artifactId>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

View File

@@ -6,14 +6,14 @@
<parent>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId>
<version>2.0.31</version>
<version>4.0.0.alpha1</version>
</parent>
<artifactId>springboot-util</artifactId>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

View File

@@ -1,12 +1,337 @@
package com.tiesheng.util;
import cn.hutool.extra.servlet.ServletUtil;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import cn.hutool.core.bean.copier.ValueProvider;
import cn.hutool.core.collection.ArrayIter;
import cn.hutool.core.collection.IterUtil;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.exceptions.UtilException;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.io.IORuntimeException;
import cn.hutool.core.io.IoUtil;
import cn.hutool.core.map.CaseInsensitiveMap;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.net.NetUtil;
import cn.hutool.core.net.multipart.MultipartFormData;
import cn.hutool.core.net.multipart.UploadSetting;
import cn.hutool.core.util.*;
import jakarta.servlet.ServletOutputStream;
import jakarta.servlet.ServletRequest;
import jakarta.servlet.http.Cookie;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
import java.io.*;
import java.lang.reflect.Type;
import java.nio.charset.Charset;
import java.util.*;
public class ServletKit extends ServletUtil {
public class ServletKit {
public static final String METHOD_DELETE = "DELETE";
public static final String METHOD_HEAD = "HEAD";
public static final String METHOD_GET = "GET";
public static final String METHOD_OPTIONS = "OPTIONS";
public static final String METHOD_POST = "POST";
public static final String METHOD_PUT = "PUT";
public static final String METHOD_TRACE = "TRACE";
public static Map<String, String[]> getParams(ServletRequest request) {
Map<String, String[]> map = request.getParameterMap();
return Collections.unmodifiableMap(map);
}
public static Map<String, String> getParamMap(ServletRequest request) {
Map<String, String> params = new HashMap();
for (Map.Entry<String, String[]> entry : getParams(request).entrySet()) {
params.put(entry.getKey(), ArrayUtil.join(entry.getValue(), ","));
}
return params;
}
public static String getBody(ServletRequest request) {
try (BufferedReader reader = request.getReader()) {
String var3 = IoUtil.read(reader);
return var3;
} catch (IOException e) {
throw new IORuntimeException(e);
}
}
public static byte[] getBodyBytes(ServletRequest request) {
try {
return IoUtil.readBytes(request.getInputStream());
} catch (IOException e) {
throw new IORuntimeException(e);
}
}
public static <T> T fillBean(final ServletRequest request, T bean, CopyOptions copyOptions) {
final String beanName = StrUtil.lowerFirst(bean.getClass().getSimpleName());
return (T) BeanUtil.fillBean(bean, new ValueProvider<String>() {
public Object value(String key, Type valueType) {
String[] values = request.getParameterValues(key);
if (ArrayUtil.isEmpty(values)) {
values = request.getParameterValues(beanName + "." + key);
if (ArrayUtil.isEmpty(values)) {
return null;
}
}
return 1 == values.length ? values[0] : values;
}
public boolean containsKey(String key) {
return null != request.getParameter(key) || null != request.getParameter(beanName + "." + key);
}
}, copyOptions);
}
public static <T> T fillBean(ServletRequest request, T bean, boolean isIgnoreError) {
return (T) fillBean(request, bean, CopyOptions.create().setIgnoreError(isIgnoreError));
}
public static <T> T toBean(ServletRequest request, Class<T> beanClass, boolean isIgnoreError) {
return (T) fillBean(request, ReflectUtil.newInstanceIfPossible(beanClass), isIgnoreError);
}
public static String getClientIP(HttpServletRequest request, String... otherHeaderNames) {
String[] headers = new String[]{"X-Forwarded-For", "X-Real-IP", "Proxy-Client-IP", "WL-Proxy-Client-IP", "HTTP_CLIENT_IP", "HTTP_X_FORWARDED_FOR"};
if (ArrayUtil.isNotEmpty(otherHeaderNames)) {
headers = (String[]) ArrayUtil.addAll(new String[][]{otherHeaderNames, headers});
}
return getClientIPByHeader(request, headers);
}
public static String getClientIPByHeader(HttpServletRequest request, String... headerNames) {
for (String header : headerNames) {
String ip = request.getHeader(header);
if (!NetUtil.isUnknown(ip)) {
return NetUtil.getMultistageReverseProxyIp(ip);
}
}
String ip = request.getRemoteAddr();
return NetUtil.getMultistageReverseProxyIp(ip);
}
public static MultipartFormData getMultipart(ServletRequest request) throws IORuntimeException {
return getMultipart(request, new UploadSetting());
}
public static MultipartFormData getMultipart(ServletRequest request, UploadSetting uploadSetting) throws IORuntimeException {
MultipartFormData formData = new MultipartFormData(uploadSetting);
try {
formData.parseRequestStream(request.getInputStream(), CharsetUtil.charset(request.getCharacterEncoding()));
return formData;
} catch (IOException e) {
throw new IORuntimeException(e);
}
}
public static Map<String, String> getHeaderMap(HttpServletRequest request) {
Map<String, String> headerMap = new HashMap();
Enumeration<String> names = request.getHeaderNames();
while (names.hasMoreElements()) {
String name = (String) names.nextElement();
headerMap.put(name, request.getHeader(name));
}
return headerMap;
}
public static Map<String, List<String>> getHeadersMap(HttpServletRequest request) {
Map<String, List<String>> headerMap = new LinkedHashMap();
Enumeration<String> names = request.getHeaderNames();
while (names.hasMoreElements()) {
String name = (String) names.nextElement();
headerMap.put(name, ListUtil.list(false, request.getHeaders(name)));
}
return headerMap;
}
public static Map<String, Collection<String>> getHeadersMap(HttpServletResponse response) {
Map<String, Collection<String>> headerMap = new HashMap();
for (String name : response.getHeaderNames()) {
headerMap.put(name, response.getHeaders(name));
}
return headerMap;
}
public static String getHeaderIgnoreCase(HttpServletRequest request, String nameIgnoreCase) {
Enumeration<String> names = request.getHeaderNames();
while (names.hasMoreElements()) {
String name = (String) names.nextElement();
if (name != null && name.equalsIgnoreCase(nameIgnoreCase)) {
return request.getHeader(name);
}
}
return null;
}
public static String getHeader(HttpServletRequest request, String name, String charsetName) {
return getHeader(request, name, CharsetUtil.charset(charsetName));
}
public static String getHeader(HttpServletRequest request, String name, Charset charset) {
String header = request.getHeader(name);
return null != header ? CharsetUtil.convert(header, CharsetUtil.CHARSET_ISO_8859_1, charset) : null;
}
public static boolean isIE(HttpServletRequest request) {
String userAgent = getHeaderIgnoreCase(request, "User-Agent");
if (!StrUtil.isNotBlank(userAgent)) {
return false;
} else {
userAgent = userAgent.toUpperCase();
return userAgent.contains("MSIE") || userAgent.contains("TRIDENT");
}
}
public static boolean isGetMethod(HttpServletRequest request) {
return "GET".equalsIgnoreCase(request.getMethod());
}
public static boolean isPostMethod(HttpServletRequest request) {
return "POST".equalsIgnoreCase(request.getMethod());
}
public static boolean isMultipart(HttpServletRequest request) {
if (!isPostMethod(request)) {
return false;
} else {
String contentType = request.getContentType();
return StrUtil.isBlank(contentType) ? false : contentType.toLowerCase().startsWith("multipart/");
}
}
public static Cookie getCookie(HttpServletRequest httpServletRequest, String name) {
return readCookieMap(httpServletRequest).get(name);
}
public static Map<String, Cookie> readCookieMap(HttpServletRequest httpServletRequest) {
Cookie[] cookies = httpServletRequest.getCookies();
return ArrayUtil.isEmpty(cookies) ? MapUtil.empty() : IterUtil.toMap(new ArrayIter(httpServletRequest.getCookies()), new CaseInsensitiveMap(), Cookie::getName);
}
public static void addCookie(HttpServletResponse response, Cookie cookie) {
response.addCookie(cookie);
}
public static void addCookie(HttpServletResponse response, String name, String value) {
response.addCookie(new Cookie(name, value));
}
public static void addCookie(HttpServletResponse response, String name, String value, int maxAgeInSeconds, String path, String domain) {
Cookie cookie = new Cookie(name, value);
if (domain != null) {
cookie.setDomain(domain);
}
cookie.setMaxAge(maxAgeInSeconds);
cookie.setPath(path);
addCookie(response, cookie);
}
public static void addCookie(HttpServletResponse response, String name, String value, int maxAgeInSeconds) {
addCookie(response, name, value, maxAgeInSeconds, "/", (String) null);
}
public static PrintWriter getWriter(HttpServletResponse response) throws IORuntimeException {
try {
return response.getWriter();
} catch (IOException e) {
throw new IORuntimeException(e);
}
}
public static void write(HttpServletResponse response, String text, String contentType) {
response.setContentType(contentType);
Writer writer = null;
try {
writer = response.getWriter();
writer.write(text);
writer.flush();
} catch (IOException e) {
throw new UtilException(e);
} finally {
IoUtil.close(writer);
}
}
public static void write(HttpServletResponse response, File file) {
String fileName = file.getName();
String contentType = (String) ObjectUtil.defaultIfNull(FileUtil.getMimeType(fileName), "application/octet-stream");
BufferedInputStream in = null;
try {
in = FileUtil.getInputStream(file);
write(response, in, contentType, fileName);
} finally {
IoUtil.close(in);
}
}
public static void write(HttpServletResponse response, InputStream in, String contentType, String fileName) {
String charset = (String) ObjectUtil.defaultIfNull(response.getCharacterEncoding(), "UTF-8");
String encodeText = URLUtil.encodeAll(fileName, CharsetUtil.charset(charset));
response.setHeader("Content-Disposition", StrUtil.format("attachment;filename=\"{}\";filename*={}''{}", new Object[]{encodeText, charset, encodeText}));
response.setContentType(contentType);
write(response, in);
}
public static void write(HttpServletResponse response, InputStream in, String contentType) {
response.setContentType(contentType);
write(response, in);
}
public static void write(HttpServletResponse response, InputStream in) {
write(response, in, 8192);
}
public static void write(HttpServletResponse response, InputStream in, int bufferSize) {
ServletOutputStream out = null;
try {
out = response.getOutputStream();
IoUtil.copy(in, out, bufferSize);
} catch (IOException e) {
throw new UtilException(e);
} finally {
IoUtil.close(out);
IoUtil.close(in);
}
}
public static void setHeader(HttpServletResponse response, String name, Object value) {
if (value instanceof String) {
response.setHeader(name, (String) value);
} else if (Date.class.isAssignableFrom(value.getClass())) {
response.setDateHeader(name, ((Date) value).getTime());
} else if (!(value instanceof Integer) && !"int".equalsIgnoreCase(value.getClass().getSimpleName())) {
response.setHeader(name, value.toString());
} else {
response.setIntHeader(name, (Integer) value);
}
}
/**

View File

@@ -9,12 +9,12 @@ import cn.hutool.log.LogFactory;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.tiesheng.util.exception.ApiException;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;

View File

@@ -4,11 +4,10 @@ import cn.hutool.core.io.FileUtil;
import cn.hutool.log.LogFactory;
import com.tiesheng.util.ip2region.Searcher;
import com.tiesheng.util.service.http.OkHttpUtil;
import jakarta.annotation.PostConstruct;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import javax.annotation.PostConstruct;
/**
* @author hao
*/

View File

@@ -3,16 +3,16 @@ package com.tiesheng.util.config;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.servlet.ServletUtil;
import com.alibaba.fastjson.JSON;
import com.tiesheng.util.ServletKit;
import com.tiesheng.util.exception.ApiException;
import com.tiesheng.util.jwt.JWT;
import com.tiesheng.util.jwt.JWTValidator;
import com.tiesheng.util.pojos.TokenBean;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;
@@ -62,7 +62,7 @@ public class TsTokenConfig {
* @return
*/
public TokenBean validToken(HttpServletRequest request, boolean thrExp) {
String token = ServletUtil.getHeader(request, TOKEN_KEY, "utf-8");
String token = ServletKit.getHeader(request, TOKEN_KEY, "utf-8");
return validToken(token, thrExp);
}

View File

@@ -1,6 +1,7 @@
package com.tiesheng.util.pojos;
import javax.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotEmpty;
public class IdDTO {
@@ -9,7 +10,8 @@ public class IdDTO {
///////////////////////////////////////////////////////////////////////////
// setter\getter
///////////////////////////////////////////////////////////////////////////
/// ////////////////////////////////////////////////////////////////////////
public String getId() {
return id;

View File

@@ -5,8 +5,6 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.RedisTemplate;
import javax.annotation.Resource;
import java.util.Collections;
import java.util.Set;
import java.util.concurrent.TimeUnit;

View File

@@ -6,14 +6,14 @@
<parent>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-parent</artifactId>
<version>2.0.31</version>
<version>4.0.0.alpha1</version>
</parent>
<artifactId>springboot-web</artifactId>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
@@ -45,6 +45,11 @@
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-core</artifactId>
@@ -63,12 +68,6 @@
<version>9.0.104</version>
</dependency>
<!-- aspect -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<dependency>
<groupId>com.tiesheng.springboot-parent</groupId>
<artifactId>springboot-util</artifactId>

View File

@@ -27,7 +27,8 @@ public class EncryptResponseBodyAdvice implements ResponseBodyAdvice<ApiResp> {
@Override
public boolean supports(MethodParameter returnType, Class<? extends HttpMessageConverter<?>> converterType) {
return AnnotationUtil.getAnnotation(returnType.getContainingClass(), RestController.class) != null;
return AnnotationUtil.getAnnotation(returnType.getContainingClass(), RestController.class) != null
&& returnType.getParameterType() == ApiResp.class;
}
@Override

View File

@@ -7,7 +7,7 @@ import com.tiesheng.util.exception.ApiRespEnum;
import com.tiesheng.util.pojos.ApiResp;
import com.tiesheng.web.service.TieshengWebConfigurer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.web.servlet.MultipartProperties;
import org.springframework.boot.servlet.autoconfigure.MultipartProperties;
import org.springframework.http.converter.HttpMessageNotReadableException;
import org.springframework.validation.BindException;
import org.springframework.validation.FieldError;

View File

@@ -3,10 +3,10 @@ package com.tiesheng.web.config.json;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.support.config.FastJsonConfig;
import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.MediaType;
import org.springframework.http.converter.HttpMessageConverters;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
@@ -16,16 +16,11 @@ import java.util.List;
* @author hao
*/
@Configuration
public class FastJsonMessageConverter {
public class FastJsonMessageConverter implements WebMvcConfigurer {
/**
* 配置FastJson
*
* @return HttpMessageConverters
*/
@Bean
public HttpMessageConverters fastJsonHttpMessageConverters() {
@Override
public void configureMessageConverters(HttpMessageConverters.ServerBuilder builder) {
FastJsonConfig config = new FastJsonConfig();
config.setDateFormat(JSON.DEFFAULT_DATE_FORMAT);
@@ -37,7 +32,7 @@ public class FastJsonMessageConverter {
fastConverter.setDefaultCharset(StandardCharsets.UTF_8);
fastConverter.setSupportedMediaTypes(mediaTypes);
return new HttpMessageConverters(fastConverter);
builder.addCustomConverter(fastConverter);
}
}

View File

@@ -11,11 +11,6 @@ import com.tiesheng.annotation.operation.OperationLog;
import com.tiesheng.util.ServletKit;
import com.tiesheng.util.config.TsTokenConfig;
import com.tiesheng.web.service.CoreLogService;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

View File

@@ -17,9 +17,9 @@ import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.stereotype.Component;
import jakarta.servlet.http.HttpServletRequest;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.stream.Collectors;

View File

@@ -4,6 +4,7 @@ import cn.hutool.core.annotation.AnnotationUtil;
import cn.hutool.core.date.DateUtil;
import com.tiesheng.annotation.role.RoleAuthority;
import com.tiesheng.util.service.role.TsAuthorityHandler;
import jakarta.annotation.Resource;
import org.springframework.aop.support.AopUtils;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.context.ApplicationContext;
@@ -11,7 +12,6 @@ import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Date;

View File

@@ -12,12 +12,12 @@ import com.tiesheng.web.pojos.dto.config.EnumTypeDTO;
import com.tiesheng.web.pojos.vo.ProcessDetailVo;
import com.tiesheng.web.service.CoreConfigService;
import com.tiesheng.web.service.CoreLogService;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;
import java.util.List;
@RestController

View File

@@ -26,11 +26,11 @@ import com.tiesheng.web.service.CoreLogService;
import com.tiesheng.web.service.FileUploadService;
import com.tiesheng.web.service.imex.TsExportHandler;
import com.tiesheng.web.service.imex.TsImportHandler;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.validation.Valid;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

View File

@@ -8,12 +8,12 @@ import com.tiesheng.util.pojos.ApiResp;
import com.tiesheng.util.pojos.PageDTO;
import com.tiesheng.web.pojos.dao.CoreLogApi;
import com.tiesheng.web.service.CoreLogService;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;
import java.util.List;
/**

View File

@@ -7,12 +7,12 @@ import com.tiesheng.login.pojos.dao.CoreLogLogin;
import com.tiesheng.util.pojos.ApiResp;
import com.tiesheng.util.pojos.PageDTO;
import com.tiesheng.web.service.CoreLogService;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;
import java.util.List;
/**

View File

@@ -7,12 +7,12 @@ import com.tiesheng.util.pojos.ApiResp;
import com.tiesheng.util.pojos.PageDTO;
import com.tiesheng.web.pojos.dao.CoreLogOperation;
import com.tiesheng.web.service.CoreLogService;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;
import java.util.List;
/**

View File

@@ -8,12 +8,12 @@ import com.tiesheng.util.pojos.ApiResp;
import com.tiesheng.util.pojos.PageDTO;
import com.tiesheng.web.pojos.dao.CoreLogProcess;
import com.tiesheng.web.service.CoreLogService;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;
import java.util.List;
/**

View File

@@ -1,6 +1,6 @@
package com.tiesheng.web.pojos.dto.config;
import javax.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotEmpty;
public class ConfigSystemDTO {

View File

@@ -1,8 +1,7 @@
package com.tiesheng.web.pojos.imex;
import com.alibaba.fastjson.JSONObject;
import javax.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotEmpty;
public class ExportDealDTO {

View File

@@ -1,8 +1,8 @@
package com.tiesheng.web.pojos.imex;
import com.alibaba.fastjson.JSONObject;
import jakarta.validation.constraints.NotEmpty;
import javax.validation.constraints.NotEmpty;
public class ImportDealDTO {

View File

@@ -1,8 +1,6 @@
package com.tiesheng.web.pojos.imex;
import javax.validation.constraints.NotEmpty;
public class ImportInfoDTO {
@NotEmpty(message = "操作必须存在")
@@ -13,7 +11,8 @@ public class ImportInfoDTO {
///////////////////////////////////////////////////////////////////////////
// setter\getter
///////////////////////////////////////////////////////////////////////////
/// ////////////////////////////////////////////////////////////////////////
public String getAction() {
return action;

View File

@@ -8,11 +8,10 @@ import com.tiesheng.web.mapper.CoreConfigEnumMapper;
import com.tiesheng.web.mapper.CoreConfigSystemMapper;
import com.tiesheng.web.pojos.dao.CoreConfigSystem;
import com.tiesheng.web.pojos.dto.config.ConfigSystemDTO;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
/**
* @author hao
*/

View File

@@ -5,12 +5,12 @@ import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import com.tiesheng.web.mapper.CoreLogApiMapper;
import com.tiesheng.web.pojos.dao.CoreLogApi;
import jakarta.annotation.Resource;
import jakarta.validation.constraints.NotNull;
import okhttp3.*;
import okio.Buffer;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import javax.validation.constraints.NotNull;
import java.io.IOException;
import java.util.Objects;

View File

@@ -4,7 +4,6 @@ import cn.hutool.log.LogFactory;
import com.tiesheng.login.service.TsLoginConfigurer;
import com.tiesheng.util.exception.ApiRespEnum;
import com.tiesheng.util.pojos.ApiResp;
import com.tiesheng.web.pojos.dao.CoreConfigSystem;
import com.tiesheng.web.pojos.dto.config.ConfigSystemDTO;
import org.springframework.web.multipart.MultipartFile;