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

View File

@ -1,29 +1,29 @@
package com.pcloud.booksflow.form;
import com.pcloud.booksflow.form.config.BooksflowFormDataSourceConfig;
import com.pcloud.common.config.PublicConfig;
import com.pcloud.common.constant.AppLabelConstant;
import com.pcloud.common.core.datasource.DataSourceConfig;
import com.pcloud.common.readwrite.config.ReadWriteSplittingDataSourceConfig;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.FilterType;
import org.springframework.scheduling.annotation.EnableScheduling;
@Configuration
@ComponentScan(basePackages = {"com.pcloud"}, excludeFilters = {
@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 = PublicConfig.class),
@ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = AppLabelConstant.class)
})
@EnableScheduling
@EnableEurekaClient
@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)
public class AppContext {
}
//package com.pcloud.booksflow.form;
//
//import com.pcloud.booksflow.form.config.BooksflowFormDataSourceConfig;
//import com.pcloud.common.config.PublicConfig;
//import com.pcloud.common.constant.AppLabelConstant;
//import com.pcloud.common.core.datasource.DataSourceConfig;
//import com.pcloud.common.readwrite.config.ReadWriteSplittingDataSourceConfig;
//import org.mybatis.spring.annotation.MapperScan;
//import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
//import org.springframework.cloud.openfeign.EnableFeignClients;
//import org.springframework.context.annotation.ComponentScan;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.context.annotation.FilterType;
//import org.springframework.scheduling.annotation.EnableScheduling;
//
//
//@Configuration
//@ComponentScan(basePackages = {"com.pcloud"}, excludeFilters = {
// @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 = PublicConfig.class),
// @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = AppLabelConstant.class)
//})
//@EnableScheduling
//@EnableEurekaClient
//@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)
//public class AppContext {
//}

View File

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

View File

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

View File

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

View File

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