mirror of
				https://github.com/continew-org/continew-admin.git
				synced 2025-11-03 22:57:14 +08:00 
			
		
		
		
	chore: Spring Boot 2.7.8 => 3.0.3
1.Spring Boot 2.7.8 => 3.0.3 2.Knife4j 适配 Spring Boot 3.x 3.ServletUtil => JakartaServletUtil 4.javax.* => jakarta.*
This commit is contained in:
		@@ -18,7 +18,7 @@ package top.charles7c.cnadmin.common.base;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
import javax.servlet.http.HttpServletResponse;
 | 
			
		||||
import jakarta.servlet.http.HttpServletResponse;
 | 
			
		||||
 | 
			
		||||
import lombok.NoArgsConstructor;
 | 
			
		||||
 | 
			
		||||
@@ -75,7 +75,7 @@ public abstract class BaseController<S extends BaseService<V, D, Q, C>, V, D, Q,
 | 
			
		||||
    @Operation(summary = "分页查询列表")
 | 
			
		||||
    @ResponseBody
 | 
			
		||||
    @GetMapping
 | 
			
		||||
    protected R<PageDataVO<V>> page(@Validated Q query, @Validated PageQuery pageQuery) {
 | 
			
		||||
    public R<PageDataVO<V>> page(@Validated Q query, @Validated PageQuery pageQuery) {
 | 
			
		||||
        this.checkPermission("list");
 | 
			
		||||
        PageDataVO<V> pageDataVO = baseService.page(query, pageQuery);
 | 
			
		||||
        return R.ok(pageDataVO);
 | 
			
		||||
@@ -93,7 +93,7 @@ public abstract class BaseController<S extends BaseService<V, D, Q, C>, V, D, Q,
 | 
			
		||||
    @Operation(summary = "查询树列表")
 | 
			
		||||
    @ResponseBody
 | 
			
		||||
    @GetMapping("/tree")
 | 
			
		||||
    protected R<List<Tree<Long>>> tree(@Validated Q query, @Validated SortQuery sortQuery) {
 | 
			
		||||
    public R<List<Tree<Long>>> tree(@Validated Q query, @Validated SortQuery sortQuery) {
 | 
			
		||||
        this.checkPermission("list");
 | 
			
		||||
        List<Tree<Long>> list = baseService.tree(query, sortQuery, false);
 | 
			
		||||
        return R.ok(list);
 | 
			
		||||
@@ -111,7 +111,7 @@ public abstract class BaseController<S extends BaseService<V, D, Q, C>, V, D, Q,
 | 
			
		||||
    @Operation(summary = "查询列表")
 | 
			
		||||
    @ResponseBody
 | 
			
		||||
    @GetMapping("/list")
 | 
			
		||||
    protected R<List<V>> list(@Validated Q query, @Validated SortQuery sortQuery) {
 | 
			
		||||
    public R<List<V>> list(@Validated Q query, @Validated SortQuery sortQuery) {
 | 
			
		||||
        this.checkPermission("list");
 | 
			
		||||
        List<V> list = baseService.list(query, sortQuery);
 | 
			
		||||
        return R.ok(list);
 | 
			
		||||
@@ -128,7 +128,7 @@ public abstract class BaseController<S extends BaseService<V, D, Q, C>, V, D, Q,
 | 
			
		||||
    @Parameter(name = "id", description = "ID", in = ParameterIn.PATH)
 | 
			
		||||
    @ResponseBody
 | 
			
		||||
    @GetMapping("/{id}")
 | 
			
		||||
    protected R<D> get(@PathVariable Long id) {
 | 
			
		||||
    public R<D> get(@PathVariable Long id) {
 | 
			
		||||
        this.checkPermission("list");
 | 
			
		||||
        D detail = baseService.get(id);
 | 
			
		||||
        return R.ok(detail);
 | 
			
		||||
@@ -144,7 +144,7 @@ public abstract class BaseController<S extends BaseService<V, D, Q, C>, V, D, Q,
 | 
			
		||||
    @Operation(summary = "新增数据")
 | 
			
		||||
    @ResponseBody
 | 
			
		||||
    @PostMapping
 | 
			
		||||
    protected R<Long> add(@Validated @RequestBody C request) {
 | 
			
		||||
    public R<Long> add(@Validated @RequestBody C request) {
 | 
			
		||||
        this.checkPermission("add");
 | 
			
		||||
        Long id = baseService.add(request);
 | 
			
		||||
        return R.ok("新增成功", id);
 | 
			
		||||
@@ -162,7 +162,7 @@ public abstract class BaseController<S extends BaseService<V, D, Q, C>, V, D, Q,
 | 
			
		||||
    @Operation(summary = "修改数据")
 | 
			
		||||
    @ResponseBody
 | 
			
		||||
    @PutMapping("/{id}")
 | 
			
		||||
    protected R update(@Validated @RequestBody C request, @PathVariable Long id) {
 | 
			
		||||
    public R update(@Validated @RequestBody C request, @PathVariable Long id) {
 | 
			
		||||
        this.checkPermission("update");
 | 
			
		||||
        baseService.update(request, id);
 | 
			
		||||
        return R.ok("修改成功");
 | 
			
		||||
@@ -179,7 +179,7 @@ public abstract class BaseController<S extends BaseService<V, D, Q, C>, V, D, Q,
 | 
			
		||||
    @Parameter(name = "ids", description = "ID 列表", in = ParameterIn.PATH)
 | 
			
		||||
    @ResponseBody
 | 
			
		||||
    @DeleteMapping("/{ids}")
 | 
			
		||||
    protected R delete(@PathVariable List<Long> ids) {
 | 
			
		||||
    public R delete(@PathVariable List<Long> ids) {
 | 
			
		||||
        this.checkPermission("delete");
 | 
			
		||||
        baseService.delete(ids);
 | 
			
		||||
        return R.ok("删除成功");
 | 
			
		||||
@@ -197,7 +197,7 @@ public abstract class BaseController<S extends BaseService<V, D, Q, C>, V, D, Q,
 | 
			
		||||
     */
 | 
			
		||||
    @Operation(summary = "导出数据")
 | 
			
		||||
    @GetMapping("/export")
 | 
			
		||||
    protected void export(@Validated Q query, @Validated SortQuery sortQuery, HttpServletResponse response) {
 | 
			
		||||
    public void export(@Validated Q query, @Validated SortQuery sortQuery, HttpServletResponse response) {
 | 
			
		||||
        this.checkPermission("export");
 | 
			
		||||
        baseService.export(query, sortQuery, response);
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -18,7 +18,7 @@ package top.charles7c.cnadmin.common.base;
 | 
			
		||||
 | 
			
		||||
import java.io.Serializable;
 | 
			
		||||
 | 
			
		||||
import javax.validation.groups.Default;
 | 
			
		||||
import jakarta.validation.groups.Default;
 | 
			
		||||
 | 
			
		||||
import lombok.Data;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -18,7 +18,7 @@ package top.charles7c.cnadmin.common.base;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
import javax.servlet.http.HttpServletResponse;
 | 
			
		||||
import jakarta.servlet.http.HttpServletResponse;
 | 
			
		||||
 | 
			
		||||
import cn.hutool.core.lang.tree.Tree;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -20,7 +20,7 @@ import java.lang.reflect.Field;
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
import javax.servlet.http.HttpServletResponse;
 | 
			
		||||
import jakarta.servlet.http.HttpServletResponse;
 | 
			
		||||
 | 
			
		||||
import org.springframework.beans.factory.annotation.Autowired;
 | 
			
		||||
import org.springframework.data.domain.Sort;
 | 
			
		||||
 
 | 
			
		||||
@@ -23,6 +23,7 @@ import java.lang.reflect.Method;
 | 
			
		||||
import org.springframework.lang.NonNull;
 | 
			
		||||
import org.springframework.web.servlet.mvc.method.RequestMappingInfo;
 | 
			
		||||
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
 | 
			
		||||
import org.springframework.web.util.pattern.PathPatternParser;
 | 
			
		||||
 | 
			
		||||
import cn.hutool.core.util.ArrayUtil;
 | 
			
		||||
import cn.hutool.core.util.StrUtil;
 | 
			
		||||
@@ -55,7 +56,14 @@ public class CrudRequestMappingHandlerMapping extends RequestMappingHandlerMappi
 | 
			
		||||
        // 拼接路径前缀(合并了 @RequestMapping 的部分能力)
 | 
			
		||||
        String pathPrefix = crudRequestMapping.value();
 | 
			
		||||
        if (StrUtil.isNotBlank(pathPrefix)) {
 | 
			
		||||
            requestMappingInfo = RequestMappingInfo.paths(pathPrefix).build().combine(requestMappingInfo);
 | 
			
		||||
            /**
 | 
			
		||||
             * 问题:RequestMappingInfo.paths(pathPrefix)返回的RequestMappingInfo对象里pathPatternsCondition = null
 | 
			
		||||
             * 导致combine()方法抛出断言异常!
 | 
			
		||||
             * 修复: 创建options对象, 并设置PatternParser
 | 
			
		||||
             */
 | 
			
		||||
            RequestMappingInfo.BuilderConfiguration options = new RequestMappingInfo.BuilderConfiguration();
 | 
			
		||||
            options.setPatternParser(PathPatternParser.defaultInstance);
 | 
			
		||||
            requestMappingInfo = RequestMappingInfo.paths(pathPrefix).options(options).build().combine(requestMappingInfo);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // 过滤 API
 | 
			
		||||
 
 | 
			
		||||
@@ -18,9 +18,9 @@ package top.charles7c.cnadmin.common.handler;
 | 
			
		||||
 | 
			
		||||
import java.util.Objects;
 | 
			
		||||
 | 
			
		||||
import javax.servlet.http.HttpServletRequest;
 | 
			
		||||
import javax.validation.ConstraintViolation;
 | 
			
		||||
import javax.validation.ConstraintViolationException;
 | 
			
		||||
import jakarta.servlet.http.HttpServletRequest;
 | 
			
		||||
import jakarta.validation.ConstraintViolation;
 | 
			
		||||
import jakarta.validation.ConstraintViolationException;
 | 
			
		||||
 | 
			
		||||
import lombok.extern.slf4j.Slf4j;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -16,7 +16,7 @@
 | 
			
		||||
 | 
			
		||||
package top.charles7c.cnadmin.common.model.query;
 | 
			
		||||
 | 
			
		||||
import javax.validation.constraints.Min;
 | 
			
		||||
import jakarta.validation.constraints.Min;
 | 
			
		||||
 | 
			
		||||
import lombok.Data;
 | 
			
		||||
import lombok.NoArgsConstructor;
 | 
			
		||||
@@ -24,7 +24,7 @@ import lombok.NoArgsConstructor;
 | 
			
		||||
import io.swagger.v3.oas.annotations.media.Schema;
 | 
			
		||||
 | 
			
		||||
import org.hibernate.validator.constraints.Range;
 | 
			
		||||
import org.springdoc.api.annotations.ParameterObject;
 | 
			
		||||
import org.springdoc.core.annotations.ParameterObject;
 | 
			
		||||
import org.springframework.data.domain.Sort;
 | 
			
		||||
 | 
			
		||||
import com.baomidou.mybatisplus.core.metadata.IPage;
 | 
			
		||||
 
 | 
			
		||||
@@ -24,7 +24,7 @@ import lombok.Data;
 | 
			
		||||
 | 
			
		||||
import io.swagger.v3.oas.annotations.media.Schema;
 | 
			
		||||
 | 
			
		||||
import org.springdoc.api.annotations.ParameterObject;
 | 
			
		||||
import org.springdoc.core.annotations.ParameterObject;
 | 
			
		||||
import org.springframework.data.domain.Sort;
 | 
			
		||||
 | 
			
		||||
import cn.hutool.core.util.ArrayUtil;
 | 
			
		||||
 
 | 
			
		||||
@@ -18,7 +18,7 @@ package top.charles7c.cnadmin.common.model.request;
 | 
			
		||||
 | 
			
		||||
import java.io.Serializable;
 | 
			
		||||
 | 
			
		||||
import javax.validation.constraints.NotNull;
 | 
			
		||||
import jakarta.validation.constraints.NotNull;
 | 
			
		||||
 | 
			
		||||
import lombok.Data;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -19,7 +19,7 @@ package top.charles7c.cnadmin.common.util;
 | 
			
		||||
import java.util.Date;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
import javax.servlet.http.HttpServletResponse;
 | 
			
		||||
import jakarta.servlet.http.HttpServletResponse;
 | 
			
		||||
 | 
			
		||||
import lombok.AccessLevel;
 | 
			
		||||
import lombok.NoArgsConstructor;
 | 
			
		||||
 
 | 
			
		||||
@@ -22,8 +22,8 @@ import java.util.ArrayList;
 | 
			
		||||
import java.util.Collection;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
import javax.mail.MessagingException;
 | 
			
		||||
import javax.mail.internet.MimeMessage;
 | 
			
		||||
import jakarta.mail.MessagingException;
 | 
			
		||||
import jakarta.mail.internet.MimeMessage;
 | 
			
		||||
 | 
			
		||||
import lombok.AccessLevel;
 | 
			
		||||
import lombok.Data;
 | 
			
		||||
 
 | 
			
		||||
@@ -18,8 +18,8 @@ package top.charles7c.cnadmin.common.util;
 | 
			
		||||
 | 
			
		||||
import java.util.*;
 | 
			
		||||
 | 
			
		||||
import javax.servlet.http.HttpServletRequest;
 | 
			
		||||
import javax.servlet.http.HttpServletResponse;
 | 
			
		||||
import jakarta.servlet.http.HttpServletRequest;
 | 
			
		||||
import jakarta.servlet.http.HttpServletResponse;
 | 
			
		||||
 | 
			
		||||
import lombok.AccessLevel;
 | 
			
		||||
import lombok.NoArgsConstructor;
 | 
			
		||||
 
 | 
			
		||||
@@ -18,14 +18,14 @@ package top.charles7c.cnadmin.common.util.helper;
 | 
			
		||||
 | 
			
		||||
import java.time.LocalDateTime;
 | 
			
		||||
 | 
			
		||||
import javax.servlet.http.HttpServletRequest;
 | 
			
		||||
import jakarta.servlet.http.HttpServletRequest;
 | 
			
		||||
 | 
			
		||||
import lombok.AccessLevel;
 | 
			
		||||
import lombok.NoArgsConstructor;
 | 
			
		||||
 | 
			
		||||
import cn.dev33.satoken.context.SaHolder;
 | 
			
		||||
import cn.dev33.satoken.stp.StpUtil;
 | 
			
		||||
import cn.hutool.extra.servlet.ServletUtil;
 | 
			
		||||
import cn.hutool.extra.servlet.JakartaServletUtil;
 | 
			
		||||
 | 
			
		||||
import top.charles7c.cnadmin.common.constant.CacheConsts;
 | 
			
		||||
import top.charles7c.cnadmin.common.model.dto.LogContext;
 | 
			
		||||
@@ -57,7 +57,7 @@ public class LoginHelper {
 | 
			
		||||
 | 
			
		||||
        // 记录登录信息
 | 
			
		||||
        HttpServletRequest request = ServletUtils.getRequest();
 | 
			
		||||
        loginUser.setClientIp(ServletUtil.getClientIP(request));
 | 
			
		||||
        loginUser.setClientIp(JakartaServletUtil.getClientIP(request));
 | 
			
		||||
        loginUser.setLocation(IpUtils.getCityInfo(loginUser.getClientIp()));
 | 
			
		||||
        loginUser.setBrowser(ServletUtils.getBrowser(request));
 | 
			
		||||
        LogContext logContext = LogContextHolder.get();
 | 
			
		||||
 
 | 
			
		||||
@@ -82,7 +82,7 @@ public class QueryHelper {
 | 
			
		||||
     *            查询数据类型
 | 
			
		||||
     */
 | 
			
		||||
    private static <Q, R> void buildQuery(Q query, Field field, QueryWrapper<R> queryWrapper) {
 | 
			
		||||
        boolean accessible = field.isAccessible();
 | 
			
		||||
        boolean accessible = field.canAccess(null);
 | 
			
		||||
        try {
 | 
			
		||||
            field.setAccessible(true);
 | 
			
		||||
            // 没有 @Query,直接返回
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user