From fcfd76d60cb4f9e6629465bfca07d529a5c8896d Mon Sep 17 00:00:00 2001 From: FatttSnake Date: Mon, 22 Apr 2024 00:14:34 +0800 Subject: [PATCH 1/5] Fix(Tool): Fix bug in tool update version number verification Fix bug in tool update version number verification --- .../api/service/tool/impl/EditServiceImpl.kt | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/kotlin/top/fatweb/oxygen/api/service/tool/impl/EditServiceImpl.kt b/src/main/kotlin/top/fatweb/oxygen/api/service/tool/impl/EditServiceImpl.kt index 344a198..44165cb 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/service/tool/impl/EditServiceImpl.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/service/tool/impl/EditServiceImpl.kt @@ -111,16 +111,16 @@ class EditServiceImpl( } val originalVersion = originalTool.ver!! - if (originalVersion.split(".").map(String::toLong).joinToString(".") == toolUpgradeParam.ver!!.split(".") - .map(String::toLong).joinToString(".") - ) { + val originalVersionNumberList = originalVersion.split(".").map(String::toLong) + val newVersionNumberList = toolUpgradeParam.ver!!.split(".").map(String::toLong) + if (!newVersionNumberList.foldIndexed(false) { index: Int, acc: Boolean, version: Long -> + if (!acc && originalVersionNumberList[index] > version) { + throw IllegalVersionException() + } + if (originalVersionNumberList[index] < version) true else acc + }) { throw IllegalVersionException() } - originalVersion.split(".").forEachIndexed { index, s -> - if ((toolUpgradeParam.ver.split(".")[index].toLong() < s.toLong())) { - throw IllegalVersionException() - } - } val newSource = ToolData().apply { data = originalTool.source!!.data } val newDist = ToolData().apply { data = "" } @@ -134,7 +134,7 @@ class EditServiceImpl( description = originalTool.description baseId = originalTool.base!!.id authorId = WebUtil.getLoginUserId()!! - ver = toolUpgradeParam.ver.split(".").map(String::toLong).joinToString(".") + ver = newVersionNumberList.joinToString(".") keywords = originalTool.keywords sourceId = newSource.id distId = newDist.id -- 2.49.1 From a0812b4f11a8b63a0992a9ec6c5c40c968759c56 Mon Sep 17 00:00:00 2001 From: FatttSnake Date: Mon, 22 Apr 2024 00:17:48 +0800 Subject: [PATCH 2/5] Refactor(UserService): Change wrong method name Change method getIdsWithRoleIds to getIdsByRoleIds, and change method getIdsWithGroupIds to getIdsByGroupIds --- .../top/fatweb/oxygen/api/service/permission/IUserService.kt | 4 ++-- .../oxygen/api/service/permission/impl/GroupServiceImpl.kt | 2 +- .../oxygen/api/service/permission/impl/RoleServiceImpl.kt | 2 +- .../oxygen/api/service/permission/impl/UserServiceImpl.kt | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/top/fatweb/oxygen/api/service/permission/IUserService.kt b/src/main/kotlin/top/fatweb/oxygen/api/service/permission/IUserService.kt index 06351d7..f7b2475 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/service/permission/IUserService.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/service/permission/IUserService.kt @@ -161,7 +161,7 @@ interface IUserService : IService { * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 */ - fun getIdsWithRoleIds(roleIds: List): List + fun getIdsByRoleIds(roleIds: List): List /** * Get user IDs list by list of group IDs @@ -171,5 +171,5 @@ interface IUserService : IService { * @author FatttSnake, fatttsnake@gmail.com * @since 1.0.0 */ - fun getIdsWithGroupIds(groupIds: List): List + fun getIdsByGroupIds(groupIds: List): List } diff --git a/src/main/kotlin/top/fatweb/oxygen/api/service/permission/impl/GroupServiceImpl.kt b/src/main/kotlin/top/fatweb/oxygen/api/service/permission/impl/GroupServiceImpl.kt index 416bc65..5a61ce4 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/service/permission/impl/GroupServiceImpl.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/service/permission/impl/GroupServiceImpl.kt @@ -148,7 +148,7 @@ class GroupServiceImpl( } private fun offlineUser(vararg groupIds: Long) { - val userIds = userService.getIdsWithGroupIds(groupIds.toList()) + val userIds = userService.getIdsByGroupIds(groupIds.toList()) WebUtil.offlineUser(redisUtil, *userIds.toLongArray()) } } diff --git a/src/main/kotlin/top/fatweb/oxygen/api/service/permission/impl/RoleServiceImpl.kt b/src/main/kotlin/top/fatweb/oxygen/api/service/permission/impl/RoleServiceImpl.kt index 4fb6636..dc40da1 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/service/permission/impl/RoleServiceImpl.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/service/permission/impl/RoleServiceImpl.kt @@ -181,7 +181,7 @@ class RoleServiceImpl( } private fun offlineUser(vararg roleIds: Long) { - val userIds = userService.getIdsWithRoleIds(roleIds.toList()) + val userIds = userService.getIdsByRoleIds(roleIds.toList()) WebUtil.offlineUser(redisUtil, *userIds.toLongArray()) } } diff --git a/src/main/kotlin/top/fatweb/oxygen/api/service/permission/impl/UserServiceImpl.kt b/src/main/kotlin/top/fatweb/oxygen/api/service/permission/impl/UserServiceImpl.kt index 64375b3..059b22c 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/service/permission/impl/UserServiceImpl.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/service/permission/impl/UserServiceImpl.kt @@ -323,7 +323,7 @@ class UserServiceImpl( WebUtil.offlineUser(redisUtil, *ids.toLongArray()) } - override fun getIdsWithRoleIds(roleIds: List) = baseMapper.selectIdsWithRoleIds(roleIds) + override fun getIdsByRoleIds(roleIds: List) = baseMapper.selectIdsWithRoleIds(roleIds) - override fun getIdsWithGroupIds(groupIds: List) = baseMapper.selectIdsWithGroupIds(groupIds) + override fun getIdsByGroupIds(groupIds: List) = baseMapper.selectIdsWithGroupIds(groupIds) } -- 2.49.1 From cebe809504adad3cbfa43a5037e8606415cc0b49 Mon Sep 17 00:00:00 2001 From: FatttSnake Date: Mon, 22 Apr 2024 00:18:35 +0800 Subject: [PATCH 3/5] Style(Code): Format code --- .../oxygen/api/config/DateFormatConfig.kt | 9 +++---- .../fatweb/oxygen/api/config/FilterConfig.kt | 12 ++++------ .../fatweb/oxygen/api/config/JacksonConfig.kt | 17 +++++++------ .../oxygen/api/config/MybatisPlusConfig.kt | 12 ++++------ .../fatweb/oxygen/api/config/RedisConfig.kt | 4 ++-- .../service/api/v1/impl/AvatarServiceImpl.kt | 24 +++++++++---------- .../system/impl/SettingsServiceImpl.kt | 2 +- .../util/ApiResponseMappingHandlerMapping.kt | 8 ++----- .../top/fatweb/oxygen/api/util/WebUtil.kt | 5 ++-- 9 files changed, 41 insertions(+), 52 deletions(-) diff --git a/src/main/kotlin/top/fatweb/oxygen/api/config/DateFormatConfig.kt b/src/main/kotlin/top/fatweb/oxygen/api/config/DateFormatConfig.kt index 2e908a8..a2ff193 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/config/DateFormatConfig.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/config/DateFormatConfig.kt @@ -6,7 +6,6 @@ import org.springframework.beans.factory.annotation.Value import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer import org.springframework.boot.jackson.JsonComponent import org.springframework.context.annotation.Bean -import java.text.DateFormat import java.text.SimpleDateFormat import java.time.LocalDateTime import java.time.format.DateTimeFormatter @@ -41,11 +40,10 @@ class DateFormatConfig { @Bean fun jackson2ObjectMapperBuilder() = Jackson2ObjectMapperBuilderCustomizer { - val tz = timeZone - val df: DateFormat = SimpleDateFormat(dateFormat) - df.timeZone = tz + val dateFormat = SimpleDateFormat(dateFormat) + dateFormat.timeZone = timeZone it.failOnEmptyBeans(false).failOnUnknownProperties(false) - .featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS).dateFormat(df) + .featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS).dateFormat(dateFormat) } @Bean @@ -55,5 +53,4 @@ class DateFormatConfig { LocalDateTime::class.java, LocalDateTimeSerializer(DateTimeFormatter.ofPattern(dateFormat)) ) } - } \ No newline at end of file diff --git a/src/main/kotlin/top/fatweb/oxygen/api/config/FilterConfig.kt b/src/main/kotlin/top/fatweb/oxygen/api/config/FilterConfig.kt index 7b1883b..54d659e 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/config/FilterConfig.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/config/FilterConfig.kt @@ -14,11 +14,9 @@ import top.fatweb.oxygen.api.filter.ExceptionFilter @Configuration class FilterConfig { @Bean - fun exceptionFilterRegistrationBean(exceptionFilter: ExceptionFilter): FilterRegistrationBean { - val registrationBean = FilterRegistrationBean(exceptionFilter) - registrationBean.setBeanName("exceptionFilter") - registrationBean.order = -100 - - return registrationBean - } + fun exceptionFilterRegistrationBean(exceptionFilter: ExceptionFilter): FilterRegistrationBean = + FilterRegistrationBean(exceptionFilter).apply { + setBeanName("exceptionFilter") + order = -100 + } } \ No newline at end of file diff --git a/src/main/kotlin/top/fatweb/oxygen/api/config/JacksonConfig.kt b/src/main/kotlin/top/fatweb/oxygen/api/config/JacksonConfig.kt index b3518e0..795435d 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/config/JacksonConfig.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/config/JacksonConfig.kt @@ -16,13 +16,12 @@ import retrofit2.converter.jackson.JacksonConverterFactory @Configuration class JacksonConfig { @Bean - fun jacksonConverterFactory(): JacksonConverterFactory { - val mapper = JsonMapper.builder() - .findAndAddModules() - .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) - .serializationInclusion(JsonInclude.Include.NON_NULL) - .build() - - return JacksonConverterFactory.create(mapper) - } + fun jacksonConverterFactory(): JacksonConverterFactory = + JacksonConverterFactory.create( + JsonMapper.builder() + .findAndAddModules() + .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) + .serializationInclusion(JsonInclude.Include.NON_NULL) + .build() + ) } \ No newline at end of file diff --git a/src/main/kotlin/top/fatweb/oxygen/api/config/MybatisPlusConfig.kt b/src/main/kotlin/top/fatweb/oxygen/api/config/MybatisPlusConfig.kt index 9d36fe0..0d163bd 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/config/MybatisPlusConfig.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/config/MybatisPlusConfig.kt @@ -15,11 +15,9 @@ import org.springframework.context.annotation.Configuration @Configuration class MybatisPlusConfig { @Bean - fun mybatisPlusInterceptor(): MybatisPlusInterceptor { - val mybatisPlusInterceptor = MybatisPlusInterceptor() - mybatisPlusInterceptor.addInnerInterceptor(OptimisticLockerInnerInterceptor()) - mybatisPlusInterceptor.addInnerInterceptor(PaginationInnerInterceptor()) - - return mybatisPlusInterceptor - } + fun mybatisPlusInterceptor(): MybatisPlusInterceptor = + MybatisPlusInterceptor().apply { + addInnerInterceptor(OptimisticLockerInnerInterceptor()) + addInnerInterceptor(PaginationInnerInterceptor()) + } } \ No newline at end of file diff --git a/src/main/kotlin/top/fatweb/oxygen/api/config/RedisConfig.kt b/src/main/kotlin/top/fatweb/oxygen/api/config/RedisConfig.kt index b22b12f..a28eacb 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/config/RedisConfig.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/config/RedisConfig.kt @@ -33,11 +33,11 @@ class RedisConfig { } val anyJackson2JsonRedisSerializer = Jackson2JsonRedisSerializer(objectMapper, Any::class.java) - // 使用StringRedisSerializer来序列化和反序列化redis的key值 + // Use String Redis Serializer to serialize and deserialize redis key values redisTemplate.keySerializer = stringRedisSerializer redisTemplate.valueSerializer = anyJackson2JsonRedisSerializer - // Hash的key也采用StringRedisSerializer的序列化方式 + // The Hash key also uses the String Redis Serializer serialization method. redisTemplate.hashKeySerializer = stringRedisSerializer redisTemplate.hashValueSerializer = anyJackson2JsonRedisSerializer diff --git a/src/main/kotlin/top/fatweb/oxygen/api/service/api/v1/impl/AvatarServiceImpl.kt b/src/main/kotlin/top/fatweb/oxygen/api/service/api/v1/impl/AvatarServiceImpl.kt index 630d46b..ddb2de5 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/service/api/v1/impl/AvatarServiceImpl.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/service/api/v1/impl/AvatarServiceImpl.kt @@ -56,12 +56,12 @@ class AvatarServiceImpl : IAvatarService { override fun triangle(avatarBaseParam: AvatarBaseParam?): ByteArray { val avatar = ( - if (avatarBaseParam == null || avatarBaseParam.colors.isNullOrEmpty()) - TriangleAvatar.newAvatarBuilder() - else TriangleAvatar.newAvatarBuilder( - *avatarBaseParam.colors!!.map(::decodeColor).toTypedArray() - ) - ).apply { + if (avatarBaseParam == null || avatarBaseParam.colors.isNullOrEmpty()) + TriangleAvatar.newAvatarBuilder() + else TriangleAvatar.newAvatarBuilder( + *avatarBaseParam.colors!!.map(::decodeColor).toTypedArray() + ) + ).apply { avatarBaseParam?.size?.let(::size) avatarBaseParam?.margin?.let(::margin) avatarBaseParam?.padding?.let(::padding) @@ -76,12 +76,12 @@ class AvatarServiceImpl : IAvatarService { override fun square(avatarBaseParam: AvatarBaseParam?): ByteArray { val avatar = ( - if (avatarBaseParam == null || avatarBaseParam.colors.isNullOrEmpty()) - SquareAvatar.newAvatarBuilder() - else SquareAvatar.newAvatarBuilder( - *avatarBaseParam.colors!!.map(::decodeColor).toTypedArray() - ) - ).apply { + if (avatarBaseParam == null || avatarBaseParam.colors.isNullOrEmpty()) + SquareAvatar.newAvatarBuilder() + else SquareAvatar.newAvatarBuilder( + *avatarBaseParam.colors!!.map(::decodeColor).toTypedArray() + ) + ).apply { avatarBaseParam?.size?.let(::size) avatarBaseParam?.margin?.let(::margin) avatarBaseParam?.padding?.let(::padding) diff --git a/src/main/kotlin/top/fatweb/oxygen/api/service/system/impl/SettingsServiceImpl.kt b/src/main/kotlin/top/fatweb/oxygen/api/service/system/impl/SettingsServiceImpl.kt index 556cc2a..46b02d0 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/service/system/impl/SettingsServiceImpl.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/service/system/impl/SettingsServiceImpl.kt @@ -35,7 +35,7 @@ class SettingsServiceImpl : ISettingsService { ), retrieveUrl = SettingsOperator.getAppValue( BaseSettings::retrieveUrl, - "http://localhost/retrieve?code=\${retrieveCode}" + "http://localhost/forget?code=\${retrieveCode}" ) ) diff --git a/src/main/kotlin/top/fatweb/oxygen/api/util/ApiResponseMappingHandlerMapping.kt b/src/main/kotlin/top/fatweb/oxygen/api/util/ApiResponseMappingHandlerMapping.kt index 7d10d7e..62afabf 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/util/ApiResponseMappingHandlerMapping.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/util/ApiResponseMappingHandlerMapping.kt @@ -13,12 +13,8 @@ import java.lang.reflect.Method */ class ApiResponseMappingHandlerMapping : RequestMappingHandlerMapping() { - private fun createCondition(clazz: Class<*>): RequestCondition? { - val apiController = clazz.getAnnotation(ApiController::class.java) - apiController ?: return null - - return ApiVersionCondition(apiController.version) - } + private fun createCondition(clazz: Class<*>): RequestCondition? = + clazz.getAnnotation(ApiController::class.java)?.version?.let { ApiVersionCondition(it) } override fun getCustomMethodCondition(method: Method): RequestCondition<*>? = createCondition(method.javaClass) diff --git a/src/main/kotlin/top/fatweb/oxygen/api/util/WebUtil.kt b/src/main/kotlin/top/fatweb/oxygen/api/util/WebUtil.kt index 6e3ad46..103e536 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/util/WebUtil.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/util/WebUtil.kt @@ -20,8 +20,9 @@ object WebUtil { * @since 1.0.0 * @see LoginUser */ - fun getLoginUser(): LoginUser? = if (SecurityContextHolder.getContext().authentication.principal is String) null - else SecurityContextHolder.getContext().authentication.principal as LoginUser + fun getLoginUser(): LoginUser? = + if (SecurityContextHolder.getContext().authentication.principal is String) null + else SecurityContextHolder.getContext().authentication.principal as LoginUser /** * Get ID of the user currently calling api -- 2.49.1 From ff0c31d26381af1632a1ee974b2d11e2dcab8906 Mon Sep 17 00:00:00 2001 From: FatttSnake Date: Mon, 22 Apr 2024 11:54:35 +0800 Subject: [PATCH 4/5] Docs(Graph): Update Update database and permission --- doc/database.drawio | 1225 ++++++++++++++++++++++++++++++++++++++--- doc/permission.drawio | 483 +++++++++++----- 2 files changed, 1488 insertions(+), 220 deletions(-) diff --git a/doc/database.drawio b/doc/database.drawio index 007b0d0..1106267 100644 --- a/doc/database.drawio +++ b/doc/database.drawio @@ -1,11 +1,11 @@ - + - + - + @@ -46,9 +46,22 @@ - + + + + + + + + + + + + + + @@ -60,7 +73,7 @@ - + @@ -73,7 +86,7 @@ - + @@ -86,7 +99,7 @@ - + @@ -99,7 +112,7 @@ - + @@ -112,7 +125,7 @@ - + @@ -125,7 +138,7 @@ - + @@ -138,7 +151,7 @@ - + @@ -151,7 +164,7 @@ - + @@ -164,7 +177,7 @@ - + @@ -177,7 +190,7 @@ - + @@ -190,7 +203,7 @@ - + @@ -203,7 +216,7 @@ - + @@ -232,7 +245,7 @@ - + @@ -261,7 +274,7 @@ - + @@ -329,7 +342,7 @@ - + @@ -384,7 +397,7 @@ - + @@ -413,7 +426,7 @@ - + @@ -468,7 +481,7 @@ - + @@ -578,7 +591,7 @@ - + @@ -646,7 +659,7 @@ - + @@ -730,7 +743,7 @@ - + @@ -745,21 +758,8 @@ - - - - - - - - - - - - - - + @@ -771,6 +771,19 @@ + + + + + + + + + + + + + @@ -867,71 +880,71 @@ - - + + - + - - + + - + - - + + - + - - + + - + - - + + - + - + - - + + + + + - + - + - - - - - - + + + @@ -939,7 +952,7 @@ - + @@ -948,7 +961,7 @@ - + @@ -976,6 +989,1084 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/doc/permission.drawio b/doc/permission.drawio index f2f17a0..2ca4a6e 100644 --- a/doc/permission.drawio +++ b/doc/permission.drawio @@ -1,341 +1,518 @@ - + - + - + - + - + - + - + - + - + - - + + - + - - - - + - + + + + - + - + - + - + - + + + + - + - + - + - + - + - + - + - + - + - + - + - - + + - + - + - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + + - + - + - - - - + - + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- 2.49.1 From 1083b8aa946757a4bdcd8ace04538bd5f9e932ff Mon Sep 17 00:00:00 2001 From: FatttSnake Date: Mon, 22 Apr 2024 13:30:03 +0800 Subject: [PATCH 5/5] Refactor(Database): Update database Update database unique key and format SQL --- .../master/V1_0_0_231019__Add_table_'t_s_user'.sql | 13 ++++++------- ...1_0_0_240103__Add_table_‘t_s_sensitive_word'.sql | 10 +++++----- ...V1_0_0_240116__Add_table_'t_b_tool_category'.sql | 2 +- ...V1_0_0_240119__Add_table_'t_b_tool_template'.sql | 2 +- .../V1_0_0_240120__Add_table_'t_b_tool_base'.sql | 4 ++-- .../V1_0_0_231212__Add_table_'t_l_sys_log'.sql | 12 ++++++------ ...1_0_0_231214__Add_table_'t_l_statistics_log'.sql | 2 +- 7 files changed, 22 insertions(+), 23 deletions(-) diff --git a/src/main/resources/db/migration/master/V1_0_0_231019__Add_table_'t_s_user'.sql b/src/main/resources/db/migration/master/V1_0_0_231019__Add_table_'t_s_user'.sql index 4526913..490aa4a 100644 --- a/src/main/resources/db/migration/master/V1_0_0_231019__Add_table_'t_s_user'.sql +++ b/src/main/resources/db/migration/master/V1_0_0_231019__Add_table_'t_s_user'.sql @@ -9,19 +9,18 @@ create table if not exists t_s_user verify varchar(144) null comment '验证邮箱', forget varchar(144) null comment '忘记密码', locking int not null comment '锁定', - expiration datetime comment '过期时间', - credentials_expiration datetime comment '认证过期时间', + expiration datetime null comment '过期时间', + credentials_expiration datetime null comment '认证过期时间', enable int not null comment '启用', - current_login_time datetime comment '当前登录时间', - current_login_ip varchar(128) comment '当前登录 IP', - last_login_time datetime comment '上次登录时间', - last_login_ip varchar(128) comment '上次登录 IP', + current_login_time datetime null comment '当前登录时间', + current_login_ip varchar(128) null comment '当前登录 IP', + last_login_time datetime null comment '上次登录时间', + last_login_ip varchar(128) null comment '上次登录 IP', create_time datetime not null default (utc_timestamp()) comment '创建时间', update_time datetime not null default (utc_timestamp()) comment '修改时间', deleted bigint not null default 0, version int not null default 0, constraint t_s_user_unique_username unique (username, deleted), - constraint t_s_user_unique_two_factor unique (two_factor, deleted), constraint t_s_user_unique_verify unique (verify, deleted), constraint t_s_user_unique_forget unique (forget, deleted) ) comment '系统-用户表'; \ No newline at end of file diff --git a/src/main/resources/db/migration/master/V1_0_0_240103__Add_table_‘t_s_sensitive_word'.sql b/src/main/resources/db/migration/master/V1_0_0_240103__Add_table_‘t_s_sensitive_word'.sql index 5177ab7..d6c2830 100644 --- a/src/main/resources/db/migration/master/V1_0_0_240103__Add_table_‘t_s_sensitive_word'.sql +++ b/src/main/resources/db/migration/master/V1_0_0_240103__Add_table_‘t_s_sensitive_word'.sql @@ -2,11 +2,11 @@ drop table if exists t_s_sensitive_word; create table if not exists t_s_sensitive_word ( - id bigint not null primary key, - word varchar(400) not null comment '词', + id bigint not null primary key, + word varchar(400) not null comment '词', use_for varchar(50) null comment '用于', - enable int not null default 1 comment '启用', - deleted bigint not null default 0, - version int not null default 0, + enable int not null default 1 comment '启用', + deleted bigint not null default 0, + version int not null default 0, constraint t_s_sensitive_word_unique_word unique (word, deleted) ) comment '系统-敏感词表'; \ No newline at end of file diff --git a/src/main/resources/db/migration/master/V1_0_0_240116__Add_table_'t_b_tool_category'.sql b/src/main/resources/db/migration/master/V1_0_0_240116__Add_table_'t_b_tool_category'.sql index 21a15d5..1b5ef6e 100644 --- a/src/main/resources/db/migration/master/V1_0_0_240116__Add_table_'t_b_tool_category'.sql +++ b/src/main/resources/db/migration/master/V1_0_0_240116__Add_table_'t_b_tool_category'.sql @@ -3,7 +3,7 @@ drop table if exists t_b_tool_category; create table if not exists t_b_tool_category ( id bigint not null primary key, - name varchar(50) not null comment '工具类别名', + name varchar(50) not null comment '类别名', enable int not null default 1 comment '启用', create_time datetime not null default (utc_timestamp()) comment '创建时间', update_time datetime not null default (utc_timestamp()) comment '修改时间', diff --git a/src/main/resources/db/migration/master/V1_0_0_240119__Add_table_'t_b_tool_template'.sql b/src/main/resources/db/migration/master/V1_0_0_240119__Add_table_'t_b_tool_template'.sql index 899b171..3b4bd89 100644 --- a/src/main/resources/db/migration/master/V1_0_0_240119__Add_table_'t_b_tool_template'.sql +++ b/src/main/resources/db/migration/master/V1_0_0_240119__Add_table_'t_b_tool_template'.sql @@ -14,4 +14,4 @@ create table if not exists t_b_tool_template deleted bigint not null default 0, version int not null default 0, constraint t_b_tool_template_unique_name_platform unique (name, platform, deleted) -) comment '工具-模板表' \ No newline at end of file +) comment '工具-模板表'; \ No newline at end of file diff --git a/src/main/resources/db/migration/master/V1_0_0_240120__Add_table_'t_b_tool_base'.sql b/src/main/resources/db/migration/master/V1_0_0_240120__Add_table_'t_b_tool_base'.sql index 8531682..0956bf6 100644 --- a/src/main/resources/db/migration/master/V1_0_0_240120__Add_table_'t_b_tool_base'.sql +++ b/src/main/resources/db/migration/master/V1_0_0_240120__Add_table_'t_b_tool_base'.sql @@ -6,11 +6,11 @@ create table if not exists t_b_tool_base name varchar(20) not null comment '基板名', source_id bigint not null comment '源码 ID', dist_id bigint not null comment '产物 ID', - platform varchar(20) not null comment '平台', + platform varchar(20) not null comment '平台', compiled int not null default 0 comment '已编译', create_time datetime not null default (utc_timestamp()) comment '创建时间', update_time datetime not null default (utc_timestamp()) comment '修改时间', deleted bigint not null default 0, version int not null default 0, constraint t_b_tool_base_unique_name_platform unique (name, platform, deleted) -) \ No newline at end of file +) comment '工具-基板表'; \ No newline at end of file diff --git a/src/main/resources/db/migration/sqlite/V1_0_0_231212__Add_table_'t_l_sys_log'.sql b/src/main/resources/db/migration/sqlite/V1_0_0_231212__Add_table_'t_l_sys_log'.sql index a49c66c..ba3c20a 100644 --- a/src/main/resources/db/migration/sqlite/V1_0_0_231212__Add_table_'t_l_sys_log'.sql +++ b/src/main/resources/db/migration/sqlite/V1_0_0_231212__Add_table_'t_l_sys_log'.sql @@ -6,15 +6,15 @@ create table t_l_sys_log -- 本地-系统日志表 log_type text not null, -- 日志类型 operate_user_id integer not null, -- 操作用户 operate_time text not null default (strftime('%Y-%m-%d %H:%M:%f', 'now')), -- 操作时间 - request_uri text default null, -- 请求 URI - request_method text default null, -- 请求方式 - request_params text, -- 请求参数 + request_uri text null default null, -- 请求 URI + request_method text null default null, -- 请求方式 + request_params text null, -- 请求参数 request_ip text not null, -- 请求 IP request_server_address text not null, -- 请求服务器地址 exception integer not null default 0, -- 是否异常 - exception_info text, -- 异常信息 + exception_info text null, -- 异常信息 start_time text not null, -- 开始时间 end_time text not null, -- 结束时间 - execute_time integer default null, -- 执行时间 - user_agent text default null -- 用户代理 + execute_time integer null default null, -- 执行时间 + user_agent text null default null -- 用户代理 ); \ No newline at end of file diff --git a/src/main/resources/db/migration/sqlite/V1_0_0_231214__Add_table_'t_l_statistics_log'.sql b/src/main/resources/db/migration/sqlite/V1_0_0_231214__Add_table_'t_l_statistics_log'.sql index 2fb9390..8f8331a 100644 --- a/src/main/resources/db/migration/sqlite/V1_0_0_231214__Add_table_'t_l_statistics_log'.sql +++ b/src/main/resources/db/migration/sqlite/V1_0_0_231214__Add_table_'t_l_statistics_log'.sql @@ -6,4 +6,4 @@ create table if not exists t_l_statistics_log -- 本地-统计日志表 key text not null, -- 记录键 value text not null, -- 记录值 record_time text not null default (strftime('%Y-%m-%d %H:%M:%f', 'now')) -- 记录时间 -) \ No newline at end of file +); \ No newline at end of file -- 2.49.1