mirror of https://github.com/jeecgboot/jeecg-boot
Merge branch 'master' of https://github.com/zhangdaiscott/jeecg-boot
commit
beff2a271e
|
@ -3,7 +3,6 @@ package org.jeecg.config;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.models.Components;
|
import io.swagger.v3.oas.models.Components;
|
||||||
import io.swagger.v3.oas.models.OpenAPI;
|
import io.swagger.v3.oas.models.OpenAPI;
|
||||||
import io.swagger.v3.oas.models.Paths;
|
|
||||||
import io.swagger.v3.oas.models.info.Contact;
|
import io.swagger.v3.oas.models.info.Contact;
|
||||||
import io.swagger.v3.oas.models.info.Info;
|
import io.swagger.v3.oas.models.info.Info;
|
||||||
import io.swagger.v3.oas.models.info.License;
|
import io.swagger.v3.oas.models.info.License;
|
||||||
|
@ -11,10 +10,11 @@ import io.swagger.v3.oas.models.security.SecurityRequirement;
|
||||||
import io.swagger.v3.oas.models.security.SecurityScheme;
|
import io.swagger.v3.oas.models.security.SecurityScheme;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.jeecg.common.constant.CommonConstant;
|
import org.jeecg.common.constant.CommonConstant;
|
||||||
import org.springdoc.core.GroupedOpenApi;
|
|
||||||
import org.springdoc.core.customizers.GlobalOpenApiCustomizer;
|
import org.springdoc.core.customizers.GlobalOpenApiCustomizer;
|
||||||
|
import org.springdoc.core.filters.GlobalOpenApiMethodFilter;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.context.annotation.PropertySource;
|
||||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@ import java.util.Set;
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Configuration
|
@Configuration
|
||||||
|
@PropertySource("classpath:config/default-spring-doc.properties")
|
||||||
public class Swagger3Config implements WebMvcConfigurer {
|
public class Swagger3Config implements WebMvcConfigurer {
|
||||||
// 定义不需要注入安全要求的路径集合
|
// 定义不需要注入安全要求的路径集合
|
||||||
Set<String> excludedPaths = new HashSet<>(Arrays.asList(
|
Set<String> excludedPaths = new HashSet<>(Arrays.asList(
|
||||||
|
@ -55,16 +56,8 @@ public class Swagger3Config implements WebMvcConfigurer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public GroupedOpenApi swaggerOpenApi() {
|
public GlobalOpenApiMethodFilter globalOpenApiMethodFilter() {
|
||||||
return GroupedOpenApi.builder()
|
return method -> method.isAnnotationPresent(Operation.class);
|
||||||
.group("default")
|
|
||||||
.packagesToScan("org.jeecg")
|
|
||||||
// 剔除以下几个包路径的接口生成文档
|
|
||||||
.packagesToExclude("org.jeecg.modules.drag", "org.jeecg.modules.online", "org.jeecg.modules.jmreport")
|
|
||||||
// 加了Operation注解的方法,才生成接口文档
|
|
||||||
.addOpenApiMethodFilter(method -> method.isAnnotationPresent(Operation.class))
|
|
||||||
.addOpenApiCustomiser(globalOpenApiCustomizer())
|
|
||||||
.build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
|
|
@ -13,9 +13,11 @@ import com.fasterxml.jackson.datatype.jsr310.ser.LocalTimeSerializer;
|
||||||
import io.micrometer.prometheus.PrometheusMeterRegistry;
|
import io.micrometer.prometheus.PrometheusMeterRegistry;
|
||||||
import org.springframework.beans.factory.InitializingBean;
|
import org.springframework.beans.factory.InitializingBean;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.beans.factory.config.BeanPostProcessor;
|
import org.springframework.beans.factory.config.BeanPostProcessor;
|
||||||
import org.springframework.boot.actuate.trace.http.InMemoryHttpTraceRepository;
|
import org.springframework.boot.actuate.trace.http.InMemoryHttpTraceRepository;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Conditional;
|
import org.springframework.context.annotation.Conditional;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
@ -148,6 +150,7 @@ public class WebMvcConfiguration implements WebMvcConfigurer {
|
||||||
* 解决metrics端点不显示jvm信息的问题(zyf)
|
* 解决metrics端点不显示jvm信息的问题(zyf)
|
||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
|
@ConditionalOnBean(name = "meterRegistryPostProcessor")
|
||||||
InitializingBean forcePrometheusPostProcessor(BeanPostProcessor meterRegistryPostProcessor) {
|
InitializingBean forcePrometheusPostProcessor(BeanPostProcessor meterRegistryPostProcessor) {
|
||||||
return () -> meterRegistryPostProcessor.postProcessAfterInitialization(prometheusMeterRegistry, "");
|
return () -> meterRegistryPostProcessor.postProcessAfterInitialization(prometheusMeterRegistry, "");
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
springdoc.auto-tag-classes: false
|
||||||
|
springdoc.packages-to-scan: org.jeecg
|
|
@ -281,7 +281,6 @@ logging:
|
||||||
level:
|
level:
|
||||||
org.flywaydb: debug
|
org.flywaydb: debug
|
||||||
org.jeecg.modules.system.mapper: info
|
org.jeecg.modules.system.mapper: info
|
||||||
#swagger
|
|
||||||
knife4j:
|
knife4j:
|
||||||
#开启增强配置
|
#开启增强配置
|
||||||
enable: true
|
enable: true
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
package org.jeecg.modules.system.test;
|
||||||
|
|
||||||
|
import org.jeecg.config.JeecgBaseConfig;
|
||||||
|
import org.jeecg.modules.base.service.BaseCommonService;
|
||||||
|
import org.jeecg.modules.demo.mock.MockController;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
|
||||||
|
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||||
|
import org.springframework.test.web.servlet.MockMvc;
|
||||||
|
import org.springframework.test.web.servlet.result.MockMvcResultHandlers;
|
||||||
|
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
|
||||||
|
|
||||||
|
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单个controller测试
|
||||||
|
* @date 2025/4/7 11:21
|
||||||
|
*/
|
||||||
|
@WebMvcTest(value = MockController.class)
|
||||||
|
public class MockControllerTest {
|
||||||
|
@Autowired
|
||||||
|
private MockMvc mockMvc;
|
||||||
|
|
||||||
|
@MockBean
|
||||||
|
private BaseCommonService baseCommonService;
|
||||||
|
@MockBean
|
||||||
|
private JeecgBaseConfig jeecgBaseConfig;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSave() throws Exception {
|
||||||
|
mockMvc.perform(get("/mock/api/json/area"))
|
||||||
|
.andDo(MockMvcResultHandlers.print())
|
||||||
|
.andExpect(MockMvcResultMatchers.status().isOk());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -73,7 +73,7 @@
|
||||||
<!-- Swagger API文档 -->
|
<!-- Swagger API文档 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.xiaoymin</groupId>
|
<groupId>com.github.xiaoymin</groupId>
|
||||||
<artifactId>knife4j-gateway-spring-boot-starter</artifactId>
|
<artifactId>knife4j-openapi2-spring-boot-starter</artifactId>
|
||||||
<version>${knife4j-spring-boot-starter.version}</version>
|
<version>${knife4j-spring-boot-starter.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -1,160 +1,160 @@
|
||||||
//package org.jeecg.handler.swagger;
|
package org.jeecg.handler.swagger;
|
||||||
//
|
|
||||||
//import cn.hutool.core.util.ArrayUtil;
|
import cn.hutool.core.util.ArrayUtil;
|
||||||
//import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
//import com.alibaba.nacos.api.naming.NamingFactory;
|
import com.alibaba.nacos.api.naming.NamingFactory;
|
||||||
//import com.alibaba.nacos.api.naming.NamingService;
|
import com.alibaba.nacos.api.naming.NamingService;
|
||||||
//import com.alibaba.nacos.api.naming.pojo.Instance;
|
import com.alibaba.nacos.api.naming.pojo.Instance;
|
||||||
//import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
//import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
//import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
//import org.springframework.cloud.gateway.route.RouteLocator;
|
import org.springframework.cloud.gateway.route.RouteLocator;
|
||||||
//import org.springframework.context.annotation.Primary;
|
import org.springframework.context.annotation.Primary;
|
||||||
//import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
//
|
|
||||||
//import springfox.documentation.swagger.web.SwaggerResource;
|
import springfox.documentation.swagger.web.SwaggerResource;
|
||||||
//import springfox.documentation.swagger.web.SwaggerResourcesProvider;
|
import springfox.documentation.swagger.web.SwaggerResourcesProvider;
|
||||||
//
|
|
||||||
//import java.util.*;
|
import java.util.*;
|
||||||
//
|
|
||||||
///**
|
/** 已使用knife4j-gateway支持该功能
|
||||||
// * 聚合各个服务的swagger接口
|
* 聚合各个服务的swagger接口
|
||||||
// * @author zyf
|
* @author zyf
|
||||||
// * @date: 2022/4/21 10:55
|
* @date: 2022/4/21 10:55
|
||||||
// */
|
*/
|
||||||
//@Component
|
@Component
|
||||||
//@Slf4j
|
@Slf4j
|
||||||
//@Primary
|
@Primary
|
||||||
//public class MySwaggerResourceProvider implements SwaggerResourcesProvider {
|
public class MySwaggerResourceProvider implements SwaggerResourcesProvider {
|
||||||
// /**
|
/**
|
||||||
// * swagger2默认的url后缀
|
* swagger2默认的url后缀
|
||||||
// */
|
*/
|
||||||
// private static final String SWAGGER2URL = "/v2/api-docs";
|
private static final String SWAGGER2URL = "/v3/api-docs";
|
||||||
//
|
|
||||||
// /**
|
/**
|
||||||
// * 网关路由
|
* 网关路由
|
||||||
// */
|
*/
|
||||||
// private final RouteLocator routeLocator;
|
private final RouteLocator routeLocator;
|
||||||
// /**
|
/**
|
||||||
// * Nacos名字服务
|
* Nacos名字服务
|
||||||
// */
|
*/
|
||||||
// private NamingService naming;
|
private NamingService naming;
|
||||||
//
|
|
||||||
// /**
|
/**
|
||||||
// * nacos服务地址
|
* nacos服务地址
|
||||||
// */
|
*/
|
||||||
// @Value("${spring.cloud.nacos.discovery.server-addr}")
|
@Value("${spring.cloud.nacos.discovery.server-addr}")
|
||||||
// private String serverAddr;
|
private String serverAddr;
|
||||||
// /**
|
/**
|
||||||
// * nacos namespace
|
* nacos namespace
|
||||||
// */
|
*/
|
||||||
// @Value("${spring.cloud.nacos.discovery.namespace:#{null}}")
|
@Value("${spring.cloud.nacos.discovery.namespace:#{null}}")
|
||||||
// private String namespace;
|
private String namespace;
|
||||||
//
|
|
||||||
// /**
|
/**
|
||||||
// * nacos groupName
|
* nacos groupName
|
||||||
// */
|
*/
|
||||||
// @Value("${spring.cloud.nacos.config.group:DEFAULT_GROUP:#{null}}")
|
@Value("${spring.cloud.nacos.config.group:DEFAULT_GROUP:#{null}}")
|
||||||
// private String group;
|
private String group;
|
||||||
//
|
|
||||||
// /**
|
/**
|
||||||
// * nacos username
|
* nacos username
|
||||||
// */
|
*/
|
||||||
// @Value("${spring.cloud.nacos.discovery.username:#{null}}")
|
@Value("${spring.cloud.nacos.discovery.username:#{null}}")
|
||||||
// private String username;
|
private String username;
|
||||||
// /**
|
/**
|
||||||
// * nacos password
|
* nacos password
|
||||||
// */
|
*/
|
||||||
// @Value("${spring.cloud.nacos.discovery.password:#{null}}")
|
@Value("${spring.cloud.nacos.discovery.password:#{null}}")
|
||||||
// private String password;
|
private String password;
|
||||||
//
|
|
||||||
// /**
|
/**
|
||||||
// * Swagger中需要排除的服务
|
* Swagger中需要排除的服务
|
||||||
// */
|
*/
|
||||||
// private String[] excludeServiceIds=new String[]{"jeecg-cloud-monitor"};
|
private String[] excludeServiceIds=new String[]{"jeecg-cloud-monitor"};
|
||||||
//
|
|
||||||
//
|
|
||||||
// /**
|
/**
|
||||||
// * 网关应用名称
|
* 网关应用名称
|
||||||
// */
|
*/
|
||||||
// @Value("${spring.application.name}")
|
@Value("${spring.application.name}")
|
||||||
// private String self;
|
private String self;
|
||||||
//
|
|
||||||
// @Autowired
|
@Autowired
|
||||||
// public MySwaggerResourceProvider(RouteLocator routeLocator) {
|
public MySwaggerResourceProvider(RouteLocator routeLocator) {
|
||||||
// this.routeLocator = routeLocator;
|
this.routeLocator = routeLocator;
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// @Override
|
@Override
|
||||||
// public List<SwaggerResource> get() {
|
public List<SwaggerResource> get() {
|
||||||
// List<SwaggerResource> resources = new ArrayList<>();
|
List<SwaggerResource> resources = new ArrayList<>();
|
||||||
// List<String> routeHosts = new ArrayList<>();
|
List<String> routeHosts = new ArrayList<>();
|
||||||
// // 获取所有可用的host:serviceId
|
// 获取所有可用的host:serviceId
|
||||||
// routeLocator.getRoutes().filter(route -> route.getUri().getHost() != null)
|
routeLocator.getRoutes().filter(route -> route.getUri().getHost() != null)
|
||||||
// .filter(route -> !self.equals(route.getUri().getHost()))
|
.filter(route -> !self.equals(route.getUri().getHost()))
|
||||||
// .subscribe(route ->{
|
.subscribe(route ->{
|
||||||
// //update-begin---author:zyf ---date:20220413 for:过滤掉无效路由,避免接口文档报错无法打开
|
//update-begin---author:zyf ---date:20220413 for:过滤掉无效路由,避免接口文档报错无法打开
|
||||||
// boolean hasRoute=checkRoute(route.getId());
|
boolean hasRoute=checkRoute(route.getId());
|
||||||
// if(hasRoute){
|
if(hasRoute){
|
||||||
// routeHosts.add(route.getUri().getHost());
|
routeHosts.add(route.getUri().getHost());
|
||||||
// }
|
}
|
||||||
// //update-end---author:zyf ---date:20220413 for:过滤掉无效路由,避免接口文档报错无法打开
|
//update-end---author:zyf ---date:20220413 for:过滤掉无效路由,避免接口文档报错无法打开
|
||||||
// });
|
});
|
||||||
//
|
|
||||||
// // 记录已经添加过的server,存在同一个应用注册了多个服务在nacos上
|
// 记录已经添加过的server,存在同一个应用注册了多个服务在nacos上
|
||||||
// Set<String> dealed = new HashSet<>();
|
Set<String> dealed = new HashSet<>();
|
||||||
// routeHosts.forEach(instance -> {
|
routeHosts.forEach(instance -> {
|
||||||
// // 拼接url
|
// 拼接url
|
||||||
// String url = "/" + instance.toLowerCase() + SWAGGER2URL;
|
String url = "/" + instance.toLowerCase() + SWAGGER2URL;
|
||||||
// if (!dealed.contains(url)) {
|
if (!dealed.contains(url)) {
|
||||||
// dealed.add(url);
|
dealed.add(url);
|
||||||
// log.info(" Gateway add SwaggerResource: {}",url);
|
log.info(" Gateway add SwaggerResource: {}",url);
|
||||||
// SwaggerResource swaggerResource = new SwaggerResource();
|
SwaggerResource swaggerResource = new SwaggerResource();
|
||||||
// swaggerResource.setUrl(url);
|
swaggerResource.setUrl(url);
|
||||||
// swaggerResource.setSwaggerVersion("2.0");
|
swaggerResource.setSwaggerVersion("2.0");
|
||||||
// swaggerResource.setName(instance);
|
swaggerResource.setName(instance);
|
||||||
// //Swagger排除不展示的服务
|
//Swagger排除不展示的服务
|
||||||
// if(!ArrayUtil.contains(excludeServiceIds,instance)){
|
if(!ArrayUtil.contains(excludeServiceIds,instance)){
|
||||||
// resources.add(swaggerResource);
|
resources.add(swaggerResource);
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// });
|
});
|
||||||
// return resources;
|
return resources;
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// /**
|
/**
|
||||||
// * 检测nacos中是否有健康实例
|
* 检测nacos中是否有健康实例
|
||||||
// * @param routeId
|
* @param routeId
|
||||||
// * @return
|
* @return
|
||||||
// */
|
*/
|
||||||
// private Boolean checkRoute(String routeId) {
|
private Boolean checkRoute(String routeId) {
|
||||||
// Boolean hasRoute = false;
|
Boolean hasRoute = false;
|
||||||
// try {
|
try {
|
||||||
// //修复使用带命名空间启动网关swagger看不到接口文档的问题
|
//修复使用带命名空间启动网关swagger看不到接口文档的问题
|
||||||
// Properties properties=new Properties();
|
Properties properties=new Properties();
|
||||||
// properties.setProperty("serverAddr",serverAddr);
|
properties.setProperty("serverAddr",serverAddr);
|
||||||
// if(namespace!=null && !"".equals(namespace)){
|
if(namespace!=null && !"".equals(namespace)){
|
||||||
// log.info("nacos.discovery.namespace = {}", namespace);
|
log.info("nacos.discovery.namespace = {}", namespace);
|
||||||
// properties.setProperty("namespace",namespace);
|
properties.setProperty("namespace",namespace);
|
||||||
// }
|
}
|
||||||
// if(username!=null && !"".equals(username)){
|
if(username!=null && !"".equals(username)){
|
||||||
// properties.setProperty("username",username);
|
properties.setProperty("username",username);
|
||||||
// }
|
}
|
||||||
// if(password!=null && !"".equals(password)){
|
if(password!=null && !"".equals(password)){
|
||||||
// properties.setProperty("password",password);
|
properties.setProperty("password",password);
|
||||||
// }
|
}
|
||||||
// //【issues/5115】因swagger文档导致gateway内存溢出
|
//【issues/5115】因swagger文档导致gateway内存溢出
|
||||||
// if (this.naming == null) {
|
if (this.naming == null) {
|
||||||
// this.naming = NamingFactory.createNamingService(properties);
|
this.naming = NamingFactory.createNamingService(properties);
|
||||||
// }
|
}
|
||||||
// log.info(" config.group : {}", group);
|
log.info(" config.group : {}", group);
|
||||||
// List<Instance> list = this.naming.selectInstances(routeId, group , true);
|
List<Instance> list = this.naming.selectInstances(routeId, group , true);
|
||||||
// if (ObjectUtil.isNotEmpty(list)) {
|
if (ObjectUtil.isNotEmpty(list)) {
|
||||||
// hasRoute = true;
|
hasRoute = true;
|
||||||
// }
|
}
|
||||||
// } catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// e.printStackTrace();
|
e.printStackTrace();
|
||||||
// }
|
}
|
||||||
// return hasRoute;
|
return hasRoute;
|
||||||
// }
|
}
|
||||||
//}
|
}
|
|
@ -1,52 +1,41 @@
|
||||||
//package org.jeecg.handler.swagger;
|
package org.jeecg.handler.swagger;
|
||||||
//
|
|
||||||
//import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
//import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.http.HttpStatus;
|
||||||
//import org.springframework.http.HttpStatus;
|
import org.springframework.http.ResponseEntity;
|
||||||
//import org.springframework.http.ResponseEntity;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
//import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
//import org.springframework.web.bind.annotation.RestController;
|
import springfox.documentation.swagger.web.*;
|
||||||
//import springfox.documentation.swagger.web.*;
|
|
||||||
//
|
import java.util.List;
|
||||||
//import java.util.ArrayList;
|
|
||||||
//import java.util.List;
|
/** 已使用knife4j-gateway支持该功能
|
||||||
//
|
* swagger聚合接口,三个接口都是 doc.html需要访问的接口
|
||||||
///**
|
* @author zyf
|
||||||
// * swagger聚合接口,三个接口都是 doc.html需要访问的接口
|
* @date: 2022/4/21 10:55
|
||||||
// * @author zyf
|
*/
|
||||||
// * @date: 2022/4/21 10:55
|
@RestController
|
||||||
// */
|
@RequestMapping("/swagger-resources")
|
||||||
//@RestController
|
public class SwaggerResourceController {
|
||||||
//@RequestMapping("/swagger-resources")
|
private MySwaggerResourceProvider swaggerResourceProvider;
|
||||||
//public class SwaggerResourceController {
|
|
||||||
// private MySwaggerResourceProvider swaggerResourceProvider;
|
@Autowired
|
||||||
// /**
|
public SwaggerResourceController(MySwaggerResourceProvider swaggerResourceProvider) {
|
||||||
// * 生产环境,关闭swagger文档
|
this.swaggerResourceProvider = swaggerResourceProvider;
|
||||||
// */
|
}
|
||||||
// @Value("${knife4j.production:#{null}}")
|
|
||||||
// private Boolean production;
|
@RequestMapping(value = "/configuration/security")
|
||||||
//
|
public ResponseEntity<SecurityConfiguration> securityConfiguration() {
|
||||||
// @Autowired
|
return new ResponseEntity<>(SecurityConfigurationBuilder.builder().build(), HttpStatus.OK);
|
||||||
// public SwaggerResourceController(MySwaggerResourceProvider swaggerResourceProvider) {
|
}
|
||||||
// this.swaggerResourceProvider = swaggerResourceProvider;
|
|
||||||
// }
|
@RequestMapping(value = "/configuration/ui")
|
||||||
//
|
public ResponseEntity<UiConfiguration> uiConfiguration() {
|
||||||
// @RequestMapping(value = "/configuration/security")
|
return new ResponseEntity<>(UiConfigurationBuilder.builder().build(), HttpStatus.OK);
|
||||||
// public ResponseEntity<SecurityConfiguration> securityConfiguration() {
|
}
|
||||||
// return new ResponseEntity<>(SecurityConfigurationBuilder.builder().build(), HttpStatus.OK);
|
|
||||||
// }
|
@RequestMapping
|
||||||
//
|
public ResponseEntity<List<SwaggerResource>> swaggerResources() {
|
||||||
// @RequestMapping(value = "/configuration/ui")
|
return new ResponseEntity<>(swaggerResourceProvider.get(), HttpStatus.OK);
|
||||||
// public ResponseEntity<UiConfiguration> uiConfiguration() {
|
}
|
||||||
// return new ResponseEntity<>(UiConfigurationBuilder.builder().build(), HttpStatus.OK);
|
}
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @RequestMapping
|
|
||||||
// public ResponseEntity<List<SwaggerResource>> swaggerResources() {
|
|
||||||
// // 是否开启生产环境屏蔽swagger
|
|
||||||
// if (production != null && production) {
|
|
||||||
// return new ResponseEntity<>(new ArrayList<>(), HttpStatus.OK);
|
|
||||||
// }
|
|
||||||
// return new ResponseEntity<>(swaggerResourceProvider.get(), HttpStatus.OK);
|
|
||||||
// }
|
|
||||||
//}
|
|
|
@ -1,11 +1,6 @@
|
||||||
server:
|
server:
|
||||||
port: 7001
|
port: 7001
|
||||||
|
|
||||||
springdoc:
|
|
||||||
packages-to-exclude:
|
|
||||||
- org.jeecg.modules.drag
|
|
||||||
- org.jeecg.modules.online
|
|
||||||
- org.jeecg.modules.jmreport
|
|
||||||
spring:
|
spring:
|
||||||
application:
|
application:
|
||||||
name: jeecg-system
|
name: jeecg-system
|
||||||
|
|
|
@ -188,7 +188,7 @@
|
||||||
const sortableOrder = ref<string[]>();
|
const sortableOrder = ref<string[]>();
|
||||||
const localeStore = useLocaleStoreWithOut();
|
const localeStore = useLocaleStoreWithOut();
|
||||||
// 列表字段配置缓存
|
// 列表字段配置缓存
|
||||||
const { saveSetting, resetSetting } = useColumnsCache(
|
const { saveSetting, resetSetting, getCache } = useColumnsCache(
|
||||||
{
|
{
|
||||||
state,
|
state,
|
||||||
popoverVisible,
|
popoverVisible,
|
||||||
|
@ -204,8 +204,7 @@
|
||||||
|
|
||||||
watchEffect(() => {
|
watchEffect(() => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
const columns = table.getColumns();
|
if (!state.isInit) {
|
||||||
if (columns.length && !state.isInit) {
|
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
}, 0);
|
}, 0);
|
||||||
|
@ -227,7 +226,13 @@
|
||||||
|
|
||||||
function getColumns() {
|
function getColumns() {
|
||||||
const ret: Options[] = [];
|
const ret: Options[] = [];
|
||||||
table.getColumns({ ignoreIndex: true, ignoreAction: true }).forEach((item) => {
|
// update-begin--author:liaozhiyang---date:20250403---for:【issues/7996】表格列组件取消所有或者只勾选中间,显示非预期
|
||||||
|
let t = table.getColumns({ ignoreIndex: true, ignoreAction: true });
|
||||||
|
if (!t.length) {
|
||||||
|
t = table.getCacheColumns();
|
||||||
|
}
|
||||||
|
// update-end--author:liaozhiyang---date:20250403---for:【issues/7996】表格列组件取消所有或者只勾选中间,显示非预期
|
||||||
|
t.forEach((item) => {
|
||||||
ret.push({
|
ret.push({
|
||||||
label: (item.title as string) || (item.customTitle as string),
|
label: (item.title as string) || (item.customTitle as string),
|
||||||
value: (item.dataIndex || item.title) as string,
|
value: (item.dataIndex || item.title) as string,
|
||||||
|
@ -237,7 +242,7 @@
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
function init() {
|
async function init() {
|
||||||
const columns = getColumns();
|
const columns = getColumns();
|
||||||
|
|
||||||
const checkList = table
|
const checkList = table
|
||||||
|
@ -249,11 +254,22 @@
|
||||||
return item.dataIndex || item.title;
|
return item.dataIndex || item.title;
|
||||||
})
|
})
|
||||||
.filter(Boolean) as string[];
|
.filter(Boolean) as string[];
|
||||||
|
// update-begin--author:liaozhiyang---date:20250403---for:【issues/7996】表格列组件取消所有或者只勾选中间,显示非预期
|
||||||
|
const { sortedList = [] } = getCache() || {};
|
||||||
|
await nextTick();
|
||||||
|
// update-end--author:liaozhiyang---date:20250403---for:【issues/7996】表格列组件取消所有或者只勾选中间,显示非预期
|
||||||
if (!plainOptions.value.length) {
|
if (!plainOptions.value.length) {
|
||||||
plainOptions.value = columns;
|
// update-begin--author:liaozhiyang---date:20250403---for:【issues/7996】表格列组件取消所有或者只勾选中间,显示非预期
|
||||||
plainSortOptions.value = columns;
|
let tmp = columns;
|
||||||
cachePlainOptions.value = columns;
|
if (sortedList?.length) {
|
||||||
|
tmp = columns.sort((prev, next) => {
|
||||||
|
return sortedList.indexOf(prev.value) - sortedList.indexOf(next.value);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// update-end--author:liaozhiyang---date:20250403---for:【issues/7996】表格列组件取消所有或者只勾选中间,显示非预期
|
||||||
|
plainOptions.value = tmp;
|
||||||
|
plainSortOptions.value = tmp;
|
||||||
|
cachePlainOptions.value = tmp;
|
||||||
state.defaultCheckList = checkList;
|
state.defaultCheckList = checkList;
|
||||||
} else {
|
} else {
|
||||||
// const fixedColumns = columns.filter((item) =>
|
// const fixedColumns = columns.filter((item) =>
|
||||||
|
@ -266,6 +282,13 @@
|
||||||
item.fixed = findItem.fixed;
|
item.fixed = findItem.fixed;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
// update-begin--author:liaozhiyang---date:20250403---for:【issues/7996】表格列组件取消所有或者只勾选中间,显示非预期
|
||||||
|
if (sortedList?.length) {
|
||||||
|
plainOptions.value.sort((prev, next) => {
|
||||||
|
return sortedList.indexOf(prev.value) - sortedList.indexOf(next.value);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// update-end--author:liaozhiyang---date:20250403---for:【issues/7996】表格列组件取消所有或者只勾选中间,显示非预期
|
||||||
}
|
}
|
||||||
state.isInit = true;
|
state.isInit = true;
|
||||||
state.checkedList = checkList;
|
state.checkedList = checkList;
|
||||||
|
|
|
@ -144,5 +144,6 @@ export function useColumnsCache(opt, setColumns, handleColumnFixed) {
|
||||||
return {
|
return {
|
||||||
saveSetting,
|
saveSetting,
|
||||||
resetSetting,
|
resetSetting,
|
||||||
|
getCache: () => $ls.get(cacheKey.value),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import type { JVxeColumn, JVxeDataProps, JVxeTableProps } from '../types';
|
import type { JVxeColumn, JVxeDataProps, JVxeTableProps } from '../types';
|
||||||
import { computed, nextTick } from 'vue';
|
import { computed, nextTick, toRaw } from 'vue';
|
||||||
import { isArray, isEmpty, isPromise } from '/@/utils/is';
|
import { isArray, isEmpty, isPromise } from '/@/utils/is';
|
||||||
import { cloneDeep } from 'lodash-es';
|
import { cloneDeep } from 'lodash-es';
|
||||||
import { JVxeTypePrefix, JVxeTypes } from '../types/JVxeTypes';
|
import { JVxeTypePrefix, JVxeTypes } from '../types/JVxeTypes';
|
||||||
|
@ -25,6 +25,11 @@ export interface HandleArgs {
|
||||||
|
|
||||||
export function useColumns(props: JVxeTableProps, data: JVxeDataProps, methods: JVxeTableMethods, slots) {
|
export function useColumns(props: JVxeTableProps, data: JVxeDataProps, methods: JVxeTableMethods, slots) {
|
||||||
data.vxeColumns = computed(() => {
|
data.vxeColumns = computed(() => {
|
||||||
|
// update-begin--author:liaozhiyang---date:20250403---for:【issues/7812】linkageConfig改变了,vxetable没更新
|
||||||
|
// linkageConfig变化时也需要执行
|
||||||
|
const linkageConfig = toRaw(props.linkageConfig);
|
||||||
|
console.log(linkageConfig);
|
||||||
|
// update-end--author:liaozhiyang---date:20250403---for:【issues/7812】linkageConfig改变了,vxetable没更新
|
||||||
let columns: JVxeColumn[] = [];
|
let columns: JVxeColumn[] = [];
|
||||||
if (isArray(props.columns)) {
|
if (isArray(props.columns)) {
|
||||||
// handle 方法参数
|
// handle 方法参数
|
||||||
|
|
Loading…
Reference in New Issue