From 183bb5855ab47231821125b774468a4dfa430a56 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sat, 20 Feb 2021 22:02:24 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=20db=20doc=20=E5=AF=BC?= =?UTF-8?q?=E5=87=BA=E7=9A=84=E6=8A=A5=E9=94=99=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ruoyi/common/config/ResourcesConfig.java | 11 +-- .../config/properties/DruidProperties.java | 75 ------------------- .../controller/doc/InfDbDocController.java | 33 ++++---- .../logger/impl/SysLoginLogServiceImpl.java | 6 +- 4 files changed, 20 insertions(+), 105 deletions(-) delete mode 100644 ruoyi-common/src/main/java/com/ruoyi/common/config/properties/DruidProperties.java diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/config/ResourcesConfig.java b/ruoyi-common/src/main/java/com/ruoyi/common/config/ResourcesConfig.java index b5d749c0a..fdb76ac92 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/config/ResourcesConfig.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/config/ResourcesConfig.java @@ -20,19 +20,10 @@ import com.ruoyi.framework.interceptor.RepeatSubmitInterceptor; */ @Configuration public class ResourcesConfig implements WebMvcConfigurer { + @Autowired private RepeatSubmitInterceptor repeatSubmitInterceptor; - @Override - public void addResourceHandlers(ResourceHandlerRegistry registry) { - /** 本地文件上传路径 */ - registry.addResourceHandler(Constants.RESOURCE_PREFIX + "/**").addResourceLocations("file:" + RuoYiConfig.getProfile() + "/"); - - /** swagger配置 */ - registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/"); - registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/"); - } - /** * 自定义拦截规则 */ diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/config/properties/DruidProperties.java b/ruoyi-common/src/main/java/com/ruoyi/common/config/properties/DruidProperties.java deleted file mode 100644 index 339839001..000000000 --- a/ruoyi-common/src/main/java/com/ruoyi/common/config/properties/DruidProperties.java +++ /dev/null @@ -1,75 +0,0 @@ -package com.ruoyi.framework.config.properties; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Configuration; -import com.alibaba.druid.pool.DruidDataSource; - -/** - * druid 配置属性 - * - * @author ruoyi - */ -@Configuration -public class DruidProperties { - @Value("${spring.datasource.druid.initialSize}") - private int initialSize; - - @Value("${spring.datasource.druid.minIdle}") - private int minIdle; - - @Value("${spring.datasource.druid.maxActive}") - private int maxActive; - - @Value("${spring.datasource.druid.maxWait}") - private int maxWait; - - @Value("${spring.datasource.druid.timeBetweenEvictionRunsMillis}") - private int timeBetweenEvictionRunsMillis; - - @Value("${spring.datasource.druid.minEvictableIdleTimeMillis}") - private int minEvictableIdleTimeMillis; - - @Value("${spring.datasource.druid.maxEvictableIdleTimeMillis}") - private int maxEvictableIdleTimeMillis; - - @Value("${spring.datasource.druid.validationQuery}") - private String validationQuery; - - @Value("${spring.datasource.druid.testWhileIdle}") - private boolean testWhileIdle; - - @Value("${spring.datasource.druid.testOnBorrow}") - private boolean testOnBorrow; - - @Value("${spring.datasource.druid.testOnReturn}") - private boolean testOnReturn; - - public DruidDataSource dataSource(DruidDataSource datasource) { - /** 配置初始化大小、最小、最大 */ - datasource.setInitialSize(initialSize); - datasource.setMaxActive(maxActive); - datasource.setMinIdle(minIdle); - - /** 配置获取连接等待超时的时间 */ - datasource.setMaxWait(maxWait); - - /** 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 */ - datasource.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis); - - /** 配置一个连接在池中最小、最大生存的时间,单位是毫秒 */ - datasource.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis); - datasource.setMaxEvictableIdleTimeMillis(maxEvictableIdleTimeMillis); - - /** - * 用来检测连接是否有效的sql,要求是一个查询语句,常用select 'x'。如果validationQuery为null,testOnBorrow、testOnReturn、testWhileIdle都不会起作用。 - */ - datasource.setValidationQuery(validationQuery); - /** 建议配置为true,不影响性能,并且保证安全性。申请连接的时候检测,如果空闲时间大于timeBetweenEvictionRunsMillis,执行validationQuery检测连接是否有效。 */ - datasource.setTestWhileIdle(testWhileIdle); - /** 申请连接时执行validationQuery检测连接是否有效,做了这个配置会降低性能。 */ - datasource.setTestOnBorrow(testOnBorrow); - /** 归还连接时执行validationQuery检测连接是否有效,做了这个配置会降低性能。 */ - datasource.setTestOnReturn(testOnReturn); - return datasource; - } -} diff --git a/src/main/java/cn/iocoder/dashboard/modules/infra/controller/doc/InfDbDocController.java b/src/main/java/cn/iocoder/dashboard/modules/infra/controller/doc/InfDbDocController.java index 394809670..0735c4d54 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/infra/controller/doc/InfDbDocController.java +++ b/src/main/java/cn/iocoder/dashboard/modules/infra/controller/doc/InfDbDocController.java @@ -44,28 +44,31 @@ public class InfDbDocController { @GetMapping("/export-html") public synchronized void exportHtml(HttpServletResponse response) throws FileNotFoundException { - // 创建 screw 的配置 - Configuration config = Configuration.builder() - .version(DOC_VERSION) // 版本 - .description(DOC_DESCRIPTION) // 描述 - .dataSource(buildDataSource()) // 数据源 - .engineConfig(buildEngineConfig()) // 引擎配置 - .produceConfig(buildProcessConfig()) // 处理配置 - .build(); + try (HikariDataSource dataSource = buildDataSource()) { + // 创建 screw 的配置 + Configuration config = Configuration.builder() + .version(DOC_VERSION) // 版本 + .description(DOC_DESCRIPTION) // 描述 + .dataSource(dataSource) // 数据源 + .engineConfig(buildEngineConfig()) // 引擎配置 + .produceConfig(buildProcessConfig()) // 处理配置 + .build(); - // 执行 screw,生成数据库文档 - new DocumentationExecute(config).execute(); + // 执行 screw,生成数据库文档 + new DocumentationExecute(config).execute(); - // 读取,返回 - ServletUtil.write(response, - new FileInputStream(FILE_OUTPUT_DIR + File.separator + DOC_FILE_NAME + FILE_OUTPUT_TYPE.getFileSuffix()), - MediaType.TEXT_HTML_VALUE); + // 读取,返回 + ServletUtil.write(response, + new FileInputStream(FILE_OUTPUT_DIR + File.separator + DOC_FILE_NAME + FILE_OUTPUT_TYPE.getFileSuffix()), + MediaType.TEXT_HTML_VALUE); + } } /** * 创建数据源 */ - private DataSource buildDataSource() { + // TODO 芋艿:screw 暂时不支持 druid,尴尬 + private HikariDataSource buildDataSource() { // 创建 HikariConfig 配置类 HikariConfig hikariConfig = new HikariConfig(); // hikariConfig.setDriverClassName("com.mysql.cj.jdbc.Driver"); diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/service/logger/impl/SysLoginLogServiceImpl.java b/src/main/java/cn/iocoder/dashboard/modules/system/service/logger/impl/SysLoginLogServiceImpl.java index 1bcacafdc..ed51a2122 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/system/service/logger/impl/SysLoginLogServiceImpl.java +++ b/src/main/java/cn/iocoder/dashboard/modules/system/service/logger/impl/SysLoginLogServiceImpl.java @@ -5,10 +5,9 @@ import cn.iocoder.dashboard.modules.system.controller.logger.vo.loginlog.SysLogi import cn.iocoder.dashboard.modules.system.controller.logger.vo.loginlog.SysLoginLogExportReqVO; import cn.iocoder.dashboard.modules.system.controller.logger.vo.loginlog.SysLoginLogPageReqVO; import cn.iocoder.dashboard.modules.system.convert.logger.SysLoginLogConvert; -import cn.iocoder.dashboard.modules.system.dal.mysql.logger.SysLoginLogMapper; import cn.iocoder.dashboard.modules.system.dal.dataobject.logger.SysLoginLogDO; +import cn.iocoder.dashboard.modules.system.dal.mysql.logger.SysLoginLogMapper; import cn.iocoder.dashboard.modules.system.service.logger.SysLoginLogService; -import cn.iocoder.dashboard.modules.system.service.user.SysUserService; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -23,9 +22,6 @@ public class SysLoginLogServiceImpl implements SysLoginLogService { @Resource private SysLoginLogMapper loginLogMapper; - @Resource - private SysUserService userService; - @Override public void createLoginLog(SysLoginLogCreateReqVO reqVO) { SysLoginLogDO loginLog = SysLoginLogConvert.INSTANCE.convert(reqVO);