h5 动态表单

This commit is contained in:
lizhengwei 2026-02-13 21:20:37 +08:00
parent b3e9f1a218
commit 02d58f5979
6 changed files with 330 additions and 330 deletions

View File

@ -1,17 +1,17 @@
package com.pcloud.booksflow.form; //package com.pcloud.booksflow.form;
//
import lombok.extern.slf4j.Slf4j; //import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.SpringBootApplication; //import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder; //import org.springframework.boot.builder.SpringApplicationBuilder;
//
@Slf4j //@Slf4j
@SpringBootApplication //@SpringBootApplication
public class AppApplication { //public class AppApplication {
//
public static void main(String[] args) { // public static void main(String[] args) {
log.warn("Start AppApplication service."); // log.warn("Start AppApplication service.");
new SpringApplicationBuilder(AppContext.class).build(args).run(args); // new SpringApplicationBuilder(AppContext.class).build(args).run(args);
log.warn("Start AppApplication successfully."); // log.warn("Start AppApplication successfully.");
} // }
//
} //}

View File

@ -1,29 +1,29 @@
package com.pcloud.booksflow.form; //package com.pcloud.booksflow.form;
//
import com.pcloud.booksflow.form.config.BooksflowFormDataSourceConfig; //import com.pcloud.booksflow.form.config.BooksflowFormDataSourceConfig;
import com.pcloud.common.config.PublicConfig; //import com.pcloud.common.config.PublicConfig;
import com.pcloud.common.constant.AppLabelConstant; //import com.pcloud.common.constant.AppLabelConstant;
import com.pcloud.common.core.datasource.DataSourceConfig; //import com.pcloud.common.core.datasource.DataSourceConfig;
import com.pcloud.common.readwrite.config.ReadWriteSplittingDataSourceConfig; //import com.pcloud.common.readwrite.config.ReadWriteSplittingDataSourceConfig;
import org.mybatis.spring.annotation.MapperScan; //import org.mybatis.spring.annotation.MapperScan;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient; //import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.openfeign.EnableFeignClients; //import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.ComponentScan; //import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration; //import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.FilterType; //import org.springframework.context.annotation.FilterType;
import org.springframework.scheduling.annotation.EnableScheduling; //import org.springframework.scheduling.annotation.EnableScheduling;
//
//
@Configuration //@Configuration
@ComponentScan(basePackages = {"com.pcloud"}, excludeFilters = { //@ComponentScan(basePackages = {"com.pcloud"}, excludeFilters = {
@ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = DataSourceConfig.class), // @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = DataSourceConfig.class),
@ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = ReadWriteSplittingDataSourceConfig.class), // @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = ReadWriteSplittingDataSourceConfig.class),
@ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = PublicConfig.class), // @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = PublicConfig.class),
@ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = AppLabelConstant.class) // @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = AppLabelConstant.class)
}) //})
@EnableScheduling //@EnableScheduling
@EnableEurekaClient //@EnableEurekaClient
@EnableFeignClients({"com.pcloud", "com.commons.weboffice.api.service", "com.pcloud.llm.cockpit.client"}) //@EnableFeignClients({"com.pcloud", "com.commons.weboffice.api.service", "com.pcloud.llm.cockpit.client"})
@MapperScan(basePackages = "com.pcloud.booksflow.form.mybatis.mapper", sqlSessionFactoryRef = BooksflowFormDataSourceConfig.SESSION_FACTORY_NAME) //@MapperScan(basePackages = "com.pcloud.booksflow.form.mybatis.mapper", sqlSessionFactoryRef = BooksflowFormDataSourceConfig.SESSION_FACTORY_NAME)
public class AppContext { //public class AppContext {
} //}

View File

@ -1,173 +1,173 @@
package com.pcloud.booksflow.form.config; //package com.pcloud.booksflow.form.config;
//
import com.alibaba.druid.pool.DruidDataSource; //import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.druid.support.http.StatViewServlet; //import com.alibaba.druid.support.http.StatViewServlet;
import com.pcloud.booksflow.form.utils.TenantHelper; //import com.pcloud.booksflow.form.utils.TenantHelper;
import com.pcloud.common.core.mybatis.interceptor.ExecutorInterceptor; //import com.pcloud.common.core.mybatis.interceptor.ExecutorInterceptor;
import com.pcloud.common.druid.DruidDatasourceBuilder; //import com.pcloud.common.druid.DruidDatasourceBuilder;
import com.pcloud.common.druid.DruidDefaultProperties; //import com.pcloud.common.druid.DruidDefaultProperties;
import com.pcloud.common.readwrite.datasource.ReadWriteDataSource; //import com.pcloud.common.readwrite.datasource.ReadWriteDataSource;
import com.pcloud.common.readwrite.route.ReadWriteMybatisRouter; //import com.pcloud.common.readwrite.route.ReadWriteMybatisRouter;
import com.pcloud.common.readwrite.route.context.ReadWriteLookupKey; //import com.pcloud.common.readwrite.route.context.ReadWriteLookupKey;
import com.pcloud.mybatis.Interceptor.MybatisPlusInterceptor; //import com.pcloud.mybatis.Interceptor.MybatisPlusInterceptor;
import com.pcloud.mybatis.Interceptor.tenant.TenantLineInnerInterceptor; //import com.pcloud.mybatis.Interceptor.tenant.TenantLineInnerInterceptor;
import com.pcloud.mybatis.Interceptor.tenant.handler.TenantLineHandler; //import com.pcloud.mybatis.Interceptor.tenant.handler.TenantLineHandler;
import net.sf.jsqlparser.expression.Expression; //import net.sf.jsqlparser.expression.Expression;
import net.sf.jsqlparser.expression.LongValue; //import net.sf.jsqlparser.expression.LongValue;
import org.apache.ibatis.plugin.Interceptor; //import org.apache.ibatis.plugin.Interceptor;
import org.apache.ibatis.session.SqlSessionFactory; //import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionFactoryBean; //import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.SqlSessionTemplate; //import org.mybatis.spring.SqlSessionTemplate;
import org.mybatis.spring.annotation.MapperScan; //import org.mybatis.spring.annotation.MapperScan;
import org.mybatis.spring.boot.autoconfigure.SpringBootVFS; //import org.mybatis.spring.boot.autoconfigure.SpringBootVFS;
import org.slf4j.Logger; //import org.slf4j.Logger;
import org.slf4j.LoggerFactory; //import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Qualifier; //import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value; //import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; //import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.ConfigurationProperties; //import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.web.servlet.ServletRegistrationBean; //import org.springframework.boot.web.servlet.ServletRegistrationBean;
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.DependsOn; //import org.springframework.context.annotation.DependsOn;
import org.springframework.context.annotation.Primary; //import org.springframework.context.annotation.Primary;
import org.springframework.transaction.TransactionManager; //import org.springframework.transaction.TransactionManager;
//
import javax.sql.DataSource; //import javax.sql.DataSource;
import java.io.IOException; //import java.io.IOException;
import java.sql.SQLException; //import java.sql.SQLException;
import java.util.*; //import java.util.*;
//
@Configuration //@Configuration
@MapperScan(basePackages = "com.pcloud.booksflow.form.mybatis.mapper") //@MapperScan(basePackages = "com.pcloud.booksflow.form.mybatis.mapper")
public class BooksflowFormDataSourceConfig { //public class BooksflowFormDataSourceConfig {
private final Logger logger = LoggerFactory.getLogger(getClass()); // private final Logger logger = LoggerFactory.getLogger(getClass());
//
private static final String PREFIX = "booksflowForm"; // private static final String PREFIX = "booksflowForm";
//
public static final String DATASOURCE_NAME = PREFIX + "DataSource"; // public static final String DATASOURCE_NAME = PREFIX + "DataSource";
private static final String MASTER_DATASOURCE_NAME = PREFIX + "MasterDataSource"; // private static final String MASTER_DATASOURCE_NAME = PREFIX + "MasterDataSource";
private static final String SLAVE_DATASOURCE_NAME = PREFIX + "SlaveDataSource"; // private static final String SLAVE_DATASOURCE_NAME = PREFIX + "SlaveDataSource";
public static final String TRANSACTION_MANAGER_NAME = PREFIX + "TransactionManager"; // public static final String TRANSACTION_MANAGER_NAME = PREFIX + "TransactionManager";
public static final String SESSION_FACTORY_NAME = PREFIX + "SqlSessionFactory"; // public static final String SESSION_FACTORY_NAME = PREFIX + "SqlSessionFactory";
public static final String SESSION_TEMPLATE_NAME = PREFIX + "SqlSessionTemplate"; // public static final String SESSION_TEMPLATE_NAME = PREFIX + "SqlSessionTemplate";
//
@Value("${mybatis.mapper-locations}") // @Value("${mybatis.mapper-locations}")
private String mapperLocations; // private String mapperLocations;
//
@Value("${mybatis.type-aliases-package}") // @Value("${mybatis.type-aliases-package}")
private String typeAliasesPackage; // private String typeAliasesPackage;
//
@Bean(DruidDatasourceBuilder.DRUID_DEFAULT_PROPERTIES_NAME) // @Bean(DruidDatasourceBuilder.DRUID_DEFAULT_PROPERTIES_NAME)
@ConditionalOnMissingBean // @ConditionalOnMissingBean
@ConfigurationProperties(prefix = "spring.datasource") // @ConfigurationProperties(prefix = "spring.datasource")
public DruidDefaultProperties druidDefaultProperties() { // public DruidDefaultProperties druidDefaultProperties() {
return new DruidDefaultProperties(); // return new DruidDefaultProperties();
} // }
//
@Bean(MASTER_DATASOURCE_NAME) // @Bean(MASTER_DATASOURCE_NAME)
@ConfigurationProperties(prefix = "spring.datasource.booksflow-form.master") // @ConfigurationProperties(prefix = "spring.datasource.booksflow-form.master")
public DruidDataSource master() { // public DruidDataSource master() {
logger.info("start create master datasource {}", PREFIX); // logger.info("start create master datasource {}", PREFIX);
return DruidDatasourceBuilder.createDruidDatasource(druidDefaultProperties()); // return DruidDatasourceBuilder.createDruidDatasource(druidDefaultProperties());
} // }
//
@Bean(SLAVE_DATASOURCE_NAME) // @Bean(SLAVE_DATASOURCE_NAME)
@ConfigurationProperties(prefix = "spring.datasource.booksflow-form.slave") // @ConfigurationProperties(prefix = "spring.datasource.booksflow-form.slave")
public DruidDataSource slave() { // public DruidDataSource slave() {
logger.info("start create slave datasource {}", PREFIX); // logger.info("start create slave datasource {}", PREFIX);
return DruidDatasourceBuilder.createDruidDatasource(druidDefaultProperties()); // return DruidDatasourceBuilder.createDruidDatasource(druidDefaultProperties());
} // }
//
@Primary // @Primary
@Bean(DATASOURCE_NAME) // @Bean(DATASOURCE_NAME)
@DependsOn({MASTER_DATASOURCE_NAME, SLAVE_DATASOURCE_NAME}) // @DependsOn({MASTER_DATASOURCE_NAME, SLAVE_DATASOURCE_NAME})
public DataSource dataSource(DruidDefaultProperties druidDefaultProperties, // public DataSource dataSource(DruidDefaultProperties druidDefaultProperties,
@Qualifier(MASTER_DATASOURCE_NAME) DruidDataSource master, // @Qualifier(MASTER_DATASOURCE_NAME) DruidDataSource master,
@Qualifier(SLAVE_DATASOURCE_NAME) DruidDataSource slave) throws SQLException, IOException { // @Qualifier(SLAVE_DATASOURCE_NAME) DruidDataSource slave) throws SQLException, IOException {
ReadWriteDataSource ds = new ReadWriteDataSource(); // ReadWriteDataSource ds = new ReadWriteDataSource();
ds.setDefaultTargetDataSource(master); // ds.setDefaultTargetDataSource(master);
//
Map<Object, Object> dataSourceMap = new HashMap<>(); // Map<Object, Object> dataSourceMap = new HashMap<>();
dataSourceMap.put(ReadWriteLookupKey.MASTER, master); // dataSourceMap.put(ReadWriteLookupKey.MASTER, master);
dataSourceMap.put(ReadWriteLookupKey.SLAVE, slave); // dataSourceMap.put(ReadWriteLookupKey.SLAVE, slave);
//
ds.setTargetDataSources(dataSourceMap); // ds.setTargetDataSources(dataSourceMap);
return ds; // return ds;
} // }
//
@Primary // @Primary
@Bean(SESSION_FACTORY_NAME) // @Bean(SESSION_FACTORY_NAME)
public SqlSessionFactory sqlSessionFactory(@Qualifier(DATASOURCE_NAME) DataSource dataSource, // public SqlSessionFactory sqlSessionFactory(@Qualifier(DATASOURCE_NAME) DataSource dataSource,
ExecutorInterceptor interceptor, // ExecutorInterceptor interceptor,
ReadWriteMybatisRouter rw) throws Exception { // ReadWriteMybatisRouter rw) throws Exception {
logger.info("【DataSource {}】初始化SqlSessionFactory<START>", PREFIX); // logger.info("【DataSource {}】初始化SqlSessionFactory<START>", PREFIX);
final SqlSessionFactoryBean sessionFactoryBean = DruidDatasourceBuilder.createSqlSessionFactory(dataSource, mapperLocations); // final SqlSessionFactoryBean sessionFactoryBean = DruidDatasourceBuilder.createSqlSessionFactory(dataSource, mapperLocations);
logger.info("【DataSource {}】初始化SqlSessionFactorymapperLocations={}", PREFIX, mapperLocations); // logger.info("【DataSource {}】初始化SqlSessionFactorymapperLocations={}", PREFIX, mapperLocations);
//
sessionFactoryBean.setVfs(SpringBootVFS.class); // sessionFactoryBean.setVfs(SpringBootVFS.class);
sessionFactoryBean.setTypeAliasesPackage(typeAliasesPackage); // sessionFactoryBean.setTypeAliasesPackage(typeAliasesPackage);
sessionFactoryBean.setPlugins(new Interceptor[] { rw, interceptor, mybatisPlusInterceptor()}); // sessionFactoryBean.setPlugins(new Interceptor[] { rw, interceptor, mybatisPlusInterceptor()});
return sessionFactoryBean.getObject(); // return sessionFactoryBean.getObject();
} // }
//
private MybatisPlusInterceptor mybatisPlusInterceptor() { // private MybatisPlusInterceptor mybatisPlusInterceptor() {
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); // MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
TenantLineInnerInterceptor tenant = new TenantHandler(Arrays.asList("tenant_init_status"), "agent_id"); // TenantLineInnerInterceptor tenant = new TenantHandler(Arrays.asList("tenant_init_status"), "agent_id");
interceptor.addInnerInterceptor(tenant); // interceptor.addInnerInterceptor(tenant);
return interceptor; // return interceptor;
} // }
//
//
public static class TenantHandler extends TenantLineInnerInterceptor { // public static class TenantHandler extends TenantLineInnerInterceptor {
/** // /**
* 多租户初始化设置 // * 多租户初始化设置
* // *
* @param ignoreTable 忽略的表 // * @param ignoreTable 忽略的表
* @param idName 租户id // * @param idName 租户id
*/ // */
public TenantHandler(final List<String> ignoreTable, final String idName) { // public TenantHandler(final List<String> ignoreTable, final String idName) {
super(new TenantLineHandler() { // super(new TenantLineHandler() {
@Override // @Override
public Expression getTenantId() { // public Expression getTenantId() {
String tenantId = String.valueOf(TenantHelper.getTenantId()); // String tenantId = String.valueOf(TenantHelper.getTenantId());
return new LongValue(tenantId); // return new LongValue(tenantId);
} // }
//
// 忽略表,true 表示忽略该表 // // 忽略表,true 表示忽略该表
@Override // @Override
public boolean ignoreTable(String tableName) { // public boolean ignoreTable(String tableName) {
return ignoreTable.contains(tableName); // return ignoreTable.contains(tableName);
} // }
//
// 多租户的列名自定义 // // 多租户的列名自定义
@Override // @Override
public String getTenantIdColumn() { // public String getTenantIdColumn() {
return idName; // return idName;
} // }
}); // });
} // }
} // }
//
@Primary // @Primary
@Bean(TRANSACTION_MANAGER_NAME) // @Bean(TRANSACTION_MANAGER_NAME)
public TransactionManager transactionManager(@Qualifier(DATASOURCE_NAME) DataSource dataSource) { // public TransactionManager transactionManager(@Qualifier(DATASOURCE_NAME) DataSource dataSource) {
return DruidDatasourceBuilder.createTransactionManager(dataSource); // return DruidDatasourceBuilder.createTransactionManager(dataSource);
} // }
//
@Bean(name = SESSION_TEMPLATE_NAME) // @Bean(name = SESSION_TEMPLATE_NAME)
@Primary // @Primary
public SqlSessionTemplate sqlSessionTemplate(@Qualifier(SESSION_FACTORY_NAME) SqlSessionFactory sqlSessionFactory, // public SqlSessionTemplate sqlSessionTemplate(@Qualifier(SESSION_FACTORY_NAME) SqlSessionFactory sqlSessionFactory,
ExecutorInterceptor interceptor) throws Exception { // ExecutorInterceptor interceptor) throws Exception {
logger.info("【DataSource {}】初始化SqlSessionTemplate<START>", PREFIX); // logger.info("【DataSource {}】初始化SqlSessionTemplate<START>", PREFIX);
return new SqlSessionTemplate(sqlSessionFactory); // return new SqlSessionTemplate(sqlSessionFactory);
} // }
//
@Bean(DruidDatasourceBuilder.DRUID_STAT_VIEW_SERVLET_BEAN_NAME) // @Bean(DruidDatasourceBuilder.DRUID_STAT_VIEW_SERVLET_BEAN_NAME)
@ConditionalOnMissingBean(name = DruidDatasourceBuilder.DRUID_STAT_VIEW_SERVLET_BEAN_NAME) // @ConditionalOnMissingBean(name = DruidDatasourceBuilder.DRUID_STAT_VIEW_SERVLET_BEAN_NAME)
public ServletRegistrationBean<StatViewServlet> druidStatViewServlet(){ // public ServletRegistrationBean<StatViewServlet> druidStatViewServlet(){
return DruidDatasourceBuilder.createDruidStatViewServlet(); // return DruidDatasourceBuilder.createDruidStatViewServlet();
} // }
//
//
} //}

View File

@ -1,55 +1,55 @@
package com.pcloud.booksflow.form.config; //package com.pcloud.booksflow.form.config;
//
import com.pcloud.common.core.exception.GlobalExceptionHandler; //import com.pcloud.common.core.exception.GlobalExceptionHandler;
import com.pcloud.common.dto.ResponseDto; //import com.pcloud.common.dto.ResponseDto;
import com.pcloud.common.exceptions.BizException; //import com.pcloud.common.exceptions.BizException;
import com.pcloud.common.permission.PermissionException; //import com.pcloud.common.permission.PermissionException;
import lombok.extern.slf4j.Slf4j; //import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.MyBatisSystemException; //import org.mybatis.spring.MyBatisSystemException;
import org.springframework.beans.factory.annotation.Autowired; //import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; //import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; //import org.springframework.http.ResponseEntity;
import org.springframework.validation.BindException; //import org.springframework.validation.BindException;
import org.springframework.web.bind.annotation.ControllerAdvice; //import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler; //import org.springframework.web.bind.annotation.ExceptionHandler;
//
import javax.servlet.http.HttpServletRequest; //import javax.servlet.http.HttpServletRequest;
import java.util.stream.Collectors; //import java.util.stream.Collectors;
//
@ControllerAdvice //@ControllerAdvice
@Slf4j //@Slf4j
public class BooksflowFormExceptionHandler { //public class BooksflowFormExceptionHandler {
//
@Autowired // @Autowired
private GlobalExceptionHandler globalExceptionHandler; // private GlobalExceptionHandler globalExceptionHandler;
//
@ExceptionHandler(BindException.class) // @ExceptionHandler(BindException.class)
public ResponseEntity<?> handleBindException(BindException e) { // public ResponseEntity<?> handleBindException(BindException e) {
String errorMsg = "参数校验失败: " + e.getBindingResult().getFieldErrors() // String errorMsg = "参数校验失败: " + e.getBindingResult().getFieldErrors()
.stream() // .stream()
.map(error -> error.getField() + ": " + error.getDefaultMessage()) // .map(error -> error.getField() + ": " + error.getDefaultMessage())
.collect(Collectors.joining(", ")); // .collect(Collectors.joining(", "));
log.warn(errorMsg, e); // log.warn(errorMsg, e);
ResponseDto<Object> responseDto = new ResponseDto<>(HttpStatus.BAD_REQUEST.value(), errorMsg); // ResponseDto<Object> responseDto = new ResponseDto<>(HttpStatus.BAD_REQUEST.value(), errorMsg);
return new ResponseEntity<>(responseDto, HttpStatus.BAD_REQUEST); // return new ResponseEntity<>(responseDto, HttpStatus.BAD_REQUEST);
} // }
//
@ExceptionHandler(BizException.class) // @ExceptionHandler(BizException.class)
public ResponseEntity<?> bizException(BizException e) { // public ResponseEntity<?> bizException(BizException e) {
log.error("错误:", e); // log.error("错误:", e);
ResponseDto<Object> responseDto = new ResponseDto<>(HttpStatus.INTERNAL_SERVER_ERROR.value(), e.getMessage()); // ResponseDto<Object> responseDto = new ResponseDto<>(HttpStatus.INTERNAL_SERVER_ERROR.value(), e.getMessage());
return new ResponseEntity<>(responseDto, HttpStatus.INTERNAL_SERVER_ERROR); // return new ResponseEntity<>(responseDto, HttpStatus.INTERNAL_SERVER_ERROR);
} // }
//
@ExceptionHandler(MyBatisSystemException.class) // @ExceptionHandler(MyBatisSystemException.class)
public ResponseEntity<?> myBatisSystemException(HttpServletRequest request, MyBatisSystemException e) throws Exception { // public ResponseEntity<?> myBatisSystemException(HttpServletRequest request, MyBatisSystemException e) throws Exception {
Throwable cause = e.getCause().getCause(); // Throwable cause = e.getCause().getCause();
if (cause instanceof PermissionException) { // if (cause instanceof PermissionException) {
return globalExceptionHandler.exceptionHandler(request, (PermissionException) cause); // return globalExceptionHandler.exceptionHandler(request, (PermissionException) cause);
} // }
log.warn("MyBatisSystemException:", e); // log.warn("MyBatisSystemException:", e);
ResponseDto<Object> responseDto = new ResponseDto<>(HttpStatus.INTERNAL_SERVER_ERROR.value(), "系统繁忙,请稍后再试!"); // ResponseDto<Object> responseDto = new ResponseDto<>(HttpStatus.INTERNAL_SERVER_ERROR.value(), "系统繁忙,请稍后再试!");
return new ResponseEntity<>(responseDto, HttpStatus.INTERNAL_SERVER_ERROR); // return new ResponseEntity<>(responseDto, HttpStatus.INTERNAL_SERVER_ERROR);
} // }
//
} //}

View File

@ -1,19 +1,19 @@
package com.pcloud.booksflow.form.config; //package com.pcloud.booksflow.form.config;
//
import com.alibaba.nacos.spring.context.annotation.config.EnableNacosConfig; //import com.alibaba.nacos.spring.context.annotation.config.EnableNacosConfig;
import com.alibaba.nacos.spring.context.annotation.config.NacosPropertySource; //import com.alibaba.nacos.spring.context.annotation.config.NacosPropertySource;
import lombok.Data; //import lombok.Data;
import org.springframework.context.annotation.Configuration; //import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component; //import org.springframework.stereotype.Component;
//
@Configuration //@Configuration
@EnableNacosConfig //@EnableNacosConfig
@NacosPropertySource(dataId = "booksflow-form.yml", autoRefreshed = true, groupId = "${config.group.id:DEFAULT_GROUP}") //@NacosPropertySource(dataId = "booksflow-form.yml", autoRefreshed = true, groupId = "${config.group.id:DEFAULT_GROUP}")
@NacosPropertySource(dataId = "db-default.yml") //@NacosPropertySource(dataId = "db-default.yml")
@NacosPropertySource(dataId = "eureka.yml", first = true, groupId = "${config.group.id:DEFAULT_GROUP}") //@NacosPropertySource(dataId = "eureka.yml", first = true, groupId = "${config.group.id:DEFAULT_GROUP}")
@NacosPropertySource(dataId = "redis.properties", groupId = "${config.group.id:DEFAULT_GROUP}") //@NacosPropertySource(dataId = "redis.properties", groupId = "${config.group.id:DEFAULT_GROUP}")
@Data //@Data
@Component //@Component
public class NacosPropertyLoadConfig { //public class NacosPropertyLoadConfig {
//
} //}

View File

@ -1,37 +1,37 @@
package com.pcloud.booksflow.form.config; //package com.pcloud.booksflow.form.config;
//
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.Profile; //import org.springframework.context.annotation.Profile;
import springfox.documentation.builders.ApiInfoBuilder; //import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors; //import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors; //import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo; //import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType; //import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket; //import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2; //import springfox.documentation.swagger2.annotations.EnableSwagger2;
//
//
@Configuration //@Configuration
@EnableSwagger2 //@EnableSwagger2
@Profile({"dev", "test"}) //@Profile({"dev", "test"})
public class SwaggerConfig { //public class SwaggerConfig {
//
@Bean // @Bean
public Docket api() { // public Docket api() {
return new Docket(DocumentationType.SWAGGER_2) // return new Docket(DocumentationType.SWAGGER_2)
.select() // .select()
.apis(RequestHandlerSelectors.basePackage("com.pcloud.booksflow.form")) // .apis(RequestHandlerSelectors.basePackage("com.pcloud.booksflow.form"))
.paths(PathSelectors.any()) // .paths(PathSelectors.any())
.build() // .build()
.apiInfo(apiInfo()); // .apiInfo(apiInfo());
} // }
//
private ApiInfo apiInfo() { // private ApiInfo apiInfo() {
return new ApiInfoBuilder() // return new ApiInfoBuilder()
.title("BooksFlow Form API") // .title("BooksFlow Form API")
.description("表单管理服务API文档") // .description("表单管理服务API文档")
.version("1.0") // .version("1.0")
.build(); // .build();
} // }
} //}