-
Notifications
You must be signed in to change notification settings - Fork 113
[-] Drop the codebase #187
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: v1-dev
Are you sure you want to change the base?
Conversation
审阅者指南此 PR 清理了遗留的 Java 代码库,转而采用纯 Kotlin 实现,标准化了跨模块的工具和导入用法,重组了 JSON 序列化辅助工具,添加了新的卡片制作器 API,并包含一个数据库迁移以删除废弃的表。 数据库迁移中已删除表的 ER 图erDiagram
MAIMAI_USER_WEB_OPTION ||--o| MAIMAI_USER_DATA : "user_id"
MAIMAI_USER_SURVIVAL ||--o| MAIMAI_USER_DATA : "user_id"
MAIMAI_USER_PRESENT_EVENT ||--o| MAIMAI_USER_DATA : "user_id"
MAIMAI_USER_PLAYLOG ||--o| MAIMAI_USER_DATA : "user_id"
MAIMAI_USER_OPTION ||--o| MAIMAI_USER_DATA : "user_id"
MAIMAI_USER_MUSIC_DETAIL ||--o| MAIMAI_USER_DATA : "user_id"
MAIMAI_USER_GENERAL_DATA ||--o| MAIMAI_USER_DATA : "user_id"
MAIMAI_USER_CHARACTER ||--o| MAIMAI_USER_DATA : "user_id"
MAIMAI_USER_BOSS ||--o| MAIMAI_USER_DATA : "user_id"
MAIMAI_USER_ACTIVITY ||--o| MAIMAI_USER_DATA : "user_id"
MAIMAI_USER_ITEM ||--o| MAIMAI_USER_DATA : "user_id"
MAIMAI_GAME_EVENT ||--o| MAIMAI_USER_DATA : "event_id"
CHUNI_GAME_CHARACTER ||--o| CHUNI_USER_DATA : "user_id"
CHUNI_GAME_CHARGE ||--o| CHUNI_USER_DATA : "user_id"
CHUNI_GAME_EVENT ||--o| CHUNI_USER_DATA : "user_id"
CHUNI_GAME_MESSAGE ||--o| CHUNI_USER_DATA : "user_id"
CHUNI_GAME_SKILL ||--o| CHUNI_USER_DATA : "user_id"
CHUNI_MUSIC_LEVEL ||--o| CHUNI_USER_DATA : "user_id"
CHUNI_USER_ACTIVITY ||--o| CHUNI_USER_DATA : "user_id"
CHUNI_USER_CHARACTER ||--o| CHUNI_USER_DATA : "user_id"
CHUNI_USER_CHARGE ||--o| CHUNI_USER_DATA : "user_id"
CHUNI_USER_COURSE ||--o| CHUNI_USER_DATA : "user_id"
CHUNI_USER_DUEL ||--o| CHUNI_USER_DATA : "user_id"
CHUNI_USER_GAME_OPTION ||--o| CHUNI_USER_DATA : "user_id"
CHUNI_USER_GAME_OPTION_EX ||--o| CHUNI_USER_DATA : "user_id"
CHUNI_USER_GENERAL_DATA ||--o| CHUNI_USER_DATA : "user_id"
CHUNI_USER_ITEM ||--o| CHUNI_USER_DATA : "user_id"
CHUNI_USER_MAP ||--o| CHUNI_USER_DATA : "user_id"
CHUNI_USER_MUSIC_DETAIL ||--o| CHUNI_USER_DATA : "user_id"
CHUNI_USER_PLAYLOG ||--o| CHUNI_USER_DATA : "user_id"
CHUNI_MUSIC ||--o| CHUNI_USER_DATA : "music_id"
CHUNI_USER_DATA_EX ||--o| CHUNI_USER_DATA : "user_id"
SEGA_GAME_VERSION ||--o| CHUNI_USER_DATA : "version_id"
新 CardMakerController 和 CardMakerControllerAdvice 的类图classDiagram
class CardMakerController {
+BasicMapper mapper
+String ALLNET_HOST
+String ALLNET_PORT
+String SERVER_PORT
+getGameSetting(request: MutableMap<String, Any>): Any?
+getGameConnect(request: MutableMap<String, Any>): Any?
+getClientBookkeeping(request: MutableMap<String, Any>): Any?
+upsertClientBookkeeping(): String
+upsertClientSetting(): String
}
class CardMakerControllerAdvice {
+preHandle(request: HttpServletRequest): MutableMap<String, Any>
}
CardMakerController --> BasicMapper
CardMakerControllerAdvice --> HttpServletRequest
新 PropertyEntry 和 PropertyEntryRepository 的类图classDiagram
class PropertyEntry {
+Long id
+String propertyKey
+String propertyValue
+PropertyEntry(propertyKey: String, propertyValue: String)
+PropertyEntry()
}
class PropertyEntryRepository {
+findByPropertyKey(key: String): Optional<PropertyEntry>
}
PropertyEntryRepository --> PropertyEntry
新 CompressRequestWrapper 的类图classDiagram
class CompressRequestWrapper {
+ByteArrayInputStream input
+ServletInputStream? filterInput
+getInputStream(): ServletInputStream
}
CompressRequestWrapper --> HttpServletRequestWrapper
新 UserRecentRating 的类图classDiagram
class UserRecentRating {
+Int musicId
+Int difficultId
+String romVersionCode
+Int score
+toString(): String
}
新 CardRepository 的类图classDiagram
class CardRepository {
+findByExtId(extId: Long): Optional<Card>
+findByLuid(luid: String): Optional<Card>
}
CardRepository --> Card
新 URIEncoder 对象的类图classDiagram
class URIEncoder {
+encode(str: String): String
}
文件级变更
提示和命令与 Sourcery 交互
自定义你的体验访问你的仪表盘以:
获取帮助Original review guide in EnglishReviewer's GuideThis PR purges the legacy Java codebase in favor of a pure Kotlin implementation, standardizes utility and import usage across modules, reorganizes JSON serialization helpers, adds new card maker APIs, and includes a database migration to drop obsolete tables. ER diagram for dropped tables in database migrationerDiagram
MAIMAI_USER_WEB_OPTION ||--o| MAIMAI_USER_DATA : "user_id"
MAIMAI_USER_SURVIVAL ||--o| MAIMAI_USER_DATA : "user_id"
MAIMAI_USER_PRESENT_EVENT ||--o| MAIMAI_USER_DATA : "user_id"
MAIMAI_USER_PLAYLOG ||--o| MAIMAI_USER_DATA : "user_id"
MAIMAI_USER_OPTION ||--o| MAIMAI_USER_DATA : "user_id"
MAIMAI_USER_MUSIC_DETAIL ||--o| MAIMAI_USER_DATA : "user_id"
MAIMAI_USER_GENERAL_DATA ||--o| MAIMAI_USER_DATA : "user_id"
MAIMAI_USER_CHARACTER ||--o| MAIMAI_USER_DATA : "user_id"
MAIMAI_USER_BOSS ||--o| MAIMAI_USER_DATA : "user_id"
MAIMAI_USER_ACTIVITY ||--o| MAIMAI_USER_DATA : "user_id"
MAIMAI_USER_ITEM ||--o| MAIMAI_USER_DATA : "user_id"
MAIMAI_GAME_EVENT ||--o| MAIMAI_USER_DATA : "event_id"
CHUNI_GAME_CHARACTER ||--o| CHUNI_USER_DATA : "user_id"
CHUNI_GAME_CHARGE ||--o| CHUNI_USER_DATA : "user_id"
CHUNI_GAME_EVENT ||--o| CHUNI_USER_DATA : "user_id"
CHUNI_GAME_MESSAGE ||--o| CHUNI_USER_DATA : "user_id"
CHUNI_GAME_SKILL ||--o| CHUNI_USER_DATA : "user_id"
CHUNI_MUSIC_LEVEL ||--o| CHUNI_USER_DATA : "user_id"
CHUNI_USER_ACTIVITY ||--o| CHUNI_USER_DATA : "user_id"
CHUNI_USER_CHARACTER ||--o| CHUNI_USER_DATA : "user_id"
CHUNI_USER_CHARGE ||--o| CHUNI_USER_DATA : "user_id"
CHUNI_USER_COURSE ||--o| CHUNI_USER_DATA : "user_id"
CHUNI_USER_DUEL ||--o| CHUNI_USER_DATA : "user_id"
CHUNI_USER_GAME_OPTION ||--o| CHUNI_USER_DATA : "user_id"
CHUNI_USER_GAME_OPTION_EX ||--o| CHUNI_USER_DATA : "user_id"
CHUNI_USER_GENERAL_DATA ||--o| CHUNI_USER_DATA : "user_id"
CHUNI_USER_ITEM ||--o| CHUNI_USER_DATA : "user_id"
CHUNI_USER_MAP ||--o| CHUNI_USER_DATA : "user_id"
CHUNI_USER_MUSIC_DETAIL ||--o| CHUNI_USER_DATA : "user_id"
CHUNI_USER_PLAYLOG ||--o| CHUNI_USER_DATA : "user_id"
CHUNI_MUSIC ||--o| CHUNI_USER_DATA : "music_id"
CHUNI_USER_DATA_EX ||--o| CHUNI_USER_DATA : "user_id"
SEGA_GAME_VERSION ||--o| CHUNI_USER_DATA : "version_id"
Class diagram for new CardMakerController and CardMakerControllerAdviceclassDiagram
class CardMakerController {
+BasicMapper mapper
+String ALLNET_HOST
+String ALLNET_PORT
+String SERVER_PORT
+getGameSetting(request: MutableMap<String, Any>): Any?
+getGameConnect(request: MutableMap<String, Any>): Any?
+getClientBookkeeping(request: MutableMap<String, Any>): Any?
+upsertClientBookkeeping(): String
+upsertClientSetting(): String
}
class CardMakerControllerAdvice {
+preHandle(request: HttpServletRequest): MutableMap<String, Any>
}
CardMakerController --> BasicMapper
CardMakerControllerAdvice --> HttpServletRequest
Class diagram for new PropertyEntry and PropertyEntryRepositoryclassDiagram
class PropertyEntry {
+Long id
+String propertyKey
+String propertyValue
+PropertyEntry(propertyKey: String, propertyValue: String)
+PropertyEntry()
}
class PropertyEntryRepository {
+findByPropertyKey(key: String): Optional<PropertyEntry>
}
PropertyEntryRepository --> PropertyEntry
Class diagram for new CompressRequestWrapperclassDiagram
class CompressRequestWrapper {
+ByteArrayInputStream input
+ServletInputStream? filterInput
+getInputStream(): ServletInputStream
}
CompressRequestWrapper --> HttpServletRequestWrapper
Class diagram for new UserRecentRatingclassDiagram
class UserRecentRating {
+Int musicId
+Int difficultId
+String romVersionCode
+Int score
+toString(): String
}
Class diagram for new CardRepositoryclassDiagram
class CardRepository {
+findByExtId(extId: Long): Optional<Card>
+findByLuid(luid: String): Optional<Card>
}
CardRepository --> Card
Class diagram for new URIEncoder objectclassDiagram
class URIEncoder {
+encode(str: String): String
}
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
大家好 - 我已审阅了您的更改 - 以下是一些反馈:
- 这个 PR 非常大,几乎触及了整个代码库——考虑将其分解为更小、更集中的提交(例如,Kotlin 迁移、SQL 清理、Java 删除),以使审阅和验证更易于管理。
- 您正在迁移到纯 Kotlin——不要忘记更新您的构建配置 (Gradle/Maven) 以删除 Java 源集、插件和依赖项,以便 CI 只编译 Kotlin 代码。
- SQL 迁移删除了许多生产表——考虑在脚本中添加备份或条件检查,以防止部署过程中意外数据丢失。
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- This PR is very large and touches almost the entire codebase—consider breaking it into smaller, focused commits (e.g., Kotlin migration, SQL cleanup, Java removals) to make review and validation more manageable.
- You’re migrating to pure Kotlin—don’t forget to update your build configuration (Gradle/Maven) to remove Java source sets, plugins, and dependencies so CI only compiles Kotlin code.
- The SQL migration drops a lot of production tables—consider adding backup or conditional checks in the script to prevent accidental data loss during deployment.
## Individual Comments
### Comment 1
<location> `src/main/java/icu/samnyan/aqua/sega/general/filter/CompressRequestWrapper.kt:16` </location>
<code_context>
+ val input: ByteArrayInputStream = ByteArrayInputStream(input)
+ var filterInput: ServletInputStream? = null
+
+ override fun getInputStream(): ServletInputStream {
+ return filterInput ?: object : ServletInputStream() {
+ override fun isFinished() = false
</code_context>
<issue_to_address>
**issue (bug_risk):** isFinished and isReady always return false in ServletInputStream implementation.
This implementation may not work correctly with async or non-blocking IO. Please update these methods to accurately represent the input stream's state.
</issue_to_address>
### Comment 2
<location> `src/main/java/icu/samnyan/aqua/sega/cardmaker/CardMakerController.kt:70` </location>
<code_context>
+ )
+
+ @API("GetGameConnectApi")
+ fun getGameConnect(@ModelAttribute request: MutableMap<String, Any>): Any? {
+ val version = parsing { request["version"]!!.long } // Rom version
+ val session = TokenChecker.Companion.getCurrentSession()
</code_context>
<issue_to_address>
**issue (bug_risk):** Potential null dereference on request["version"] in getGameConnect.
Use safe access or a default value for request["version"] to prevent NullPointerException.
</issue_to_address>
### Comment 3
<location> `src/main/java/icu/samnyan/aqua/sega/cardmaker/CardMakerControllerAdvice.kt:26` </location>
<code_context>
+ @ModelAttribute
+ fun preHandle(request: HttpServletRequest): MutableMap<String, Any> {
+ val src = request.inputStream.readAllBytes()
+ val outputString = String(src, StandardCharsets.UTF_8).trim { it <= ' ' }
+ logger.info("Request ${request.requestURI}: $outputString")
+ val mapper = ObjectMapper()
</code_context>
<issue_to_address>
**suggestion (bug_risk):** Trimming with predicate 'it <= ' '' may remove valid whitespace from JSON.
Using this trim predicate may remove valid whitespace from JSON, leading to parsing errors. Please use standard trim() or ensure input validation is appropriate.
```suggestion
val outputString = String(src, StandardCharsets.UTF_8).trim()
```
</issue_to_address>
### Comment 4
<location> `src/main/java/icu/samnyan/aqua/sega/cardmaker/CardMakerControllerAdvice.kt:28` </location>
<code_context>
+ val src = request.inputStream.readAllBytes()
+ val outputString = String(src, StandardCharsets.UTF_8).trim { it <= ' ' }
+ logger.info("Request ${request.requestURI}: $outputString")
+ val mapper = ObjectMapper()
+ return mapper.readValue(outputString, object : TypeReference<MutableMap<String, Any>>() {})
+ }
</code_context>
<issue_to_address>
**suggestion (performance):** ObjectMapper is instantiated per request, which may impact performance.
Reuse ObjectMapper as a singleton or bean to avoid unnecessary instantiation and improve performance.
</issue_to_address>Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Original comment in English
Hey there - I've reviewed your changes - here's some feedback:
- This PR is very large and touches almost the entire codebase—consider breaking it into smaller, focused commits (e.g., Kotlin migration, SQL cleanup, Java removals) to make review and validation more manageable.
- You’re migrating to pure Kotlin—don’t forget to update your build configuration (Gradle/Maven) to remove Java source sets, plugins, and dependencies so CI only compiles Kotlin code.
- The SQL migration drops a lot of production tables—consider adding backup or conditional checks in the script to prevent accidental data loss during deployment.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- This PR is very large and touches almost the entire codebase—consider breaking it into smaller, focused commits (e.g., Kotlin migration, SQL cleanup, Java removals) to make review and validation more manageable.
- You’re migrating to pure Kotlin—don’t forget to update your build configuration (Gradle/Maven) to remove Java source sets, plugins, and dependencies so CI only compiles Kotlin code.
- The SQL migration drops a lot of production tables—consider adding backup or conditional checks in the script to prevent accidental data loss during deployment.
## Individual Comments
### Comment 1
<location> `src/main/java/icu/samnyan/aqua/sega/general/filter/CompressRequestWrapper.kt:16` </location>
<code_context>
+ val input: ByteArrayInputStream = ByteArrayInputStream(input)
+ var filterInput: ServletInputStream? = null
+
+ override fun getInputStream(): ServletInputStream {
+ return filterInput ?: object : ServletInputStream() {
+ override fun isFinished() = false
</code_context>
<issue_to_address>
**issue (bug_risk):** isFinished and isReady always return false in ServletInputStream implementation.
This implementation may not work correctly with async or non-blocking IO. Please update these methods to accurately represent the input stream's state.
</issue_to_address>
### Comment 2
<location> `src/main/java/icu/samnyan/aqua/sega/cardmaker/CardMakerController.kt:70` </location>
<code_context>
+ )
+
+ @API("GetGameConnectApi")
+ fun getGameConnect(@ModelAttribute request: MutableMap<String, Any>): Any? {
+ val version = parsing { request["version"]!!.long } // Rom version
+ val session = TokenChecker.Companion.getCurrentSession()
</code_context>
<issue_to_address>
**issue (bug_risk):** Potential null dereference on request["version"] in getGameConnect.
Use safe access or a default value for request["version"] to prevent NullPointerException.
</issue_to_address>
### Comment 3
<location> `src/main/java/icu/samnyan/aqua/sega/cardmaker/CardMakerControllerAdvice.kt:26` </location>
<code_context>
+ @ModelAttribute
+ fun preHandle(request: HttpServletRequest): MutableMap<String, Any> {
+ val src = request.inputStream.readAllBytes()
+ val outputString = String(src, StandardCharsets.UTF_8).trim { it <= ' ' }
+ logger.info("Request ${request.requestURI}: $outputString")
+ val mapper = ObjectMapper()
</code_context>
<issue_to_address>
**suggestion (bug_risk):** Trimming with predicate 'it <= ' '' may remove valid whitespace from JSON.
Using this trim predicate may remove valid whitespace from JSON, leading to parsing errors. Please use standard trim() or ensure input validation is appropriate.
```suggestion
val outputString = String(src, StandardCharsets.UTF_8).trim()
```
</issue_to_address>
### Comment 4
<location> `src/main/java/icu/samnyan/aqua/sega/cardmaker/CardMakerControllerAdvice.kt:28` </location>
<code_context>
+ val src = request.inputStream.readAllBytes()
+ val outputString = String(src, StandardCharsets.UTF_8).trim { it <= ' ' }
+ logger.info("Request ${request.requestURI}: $outputString")
+ val mapper = ObjectMapper()
+ return mapper.readValue(outputString, object : TypeReference<MutableMap<String, Any>>() {})
+ }
</code_context>
<issue_to_address>
**suggestion (performance):** ObjectMapper is instantiated per request, which may impact performance.
Reuse ObjectMapper as a singleton or bean to avoid unnecessary instantiation and improve performance.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| val input: ByteArrayInputStream = ByteArrayInputStream(input) | ||
| var filterInput: ServletInputStream? = null | ||
|
|
||
| override fun getInputStream(): ServletInputStream { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (bug_risk): ServletInputStream 实现中 isFinished 和 isReady 始终返回 false。
此实现可能无法与异步或非阻塞 IO 正确配合。请更新这些方法以准确表示输入流的状态。
Original comment in English
issue (bug_risk): isFinished and isReady always return false in ServletInputStream implementation.
This implementation may not work correctly with async or non-blocking IO. Please update these methods to accurately represent the input stream's state.
| ) | ||
|
|
||
| @API("GetGameConnectApi") | ||
| fun getGameConnect(@ModelAttribute request: MutableMap<String, Any>): Any? { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (bug_risk): getGameConnect 中 request["version"] 可能存在空指针解引用。
请使用安全访问或为 request["version"] 设置默认值,以防止 NullPointerException。
Original comment in English
issue (bug_risk): Potential null dereference on request["version"] in getGameConnect.
Use safe access or a default value for request["version"] to prevent NullPointerException.
| @ModelAttribute | ||
| fun preHandle(request: HttpServletRequest): MutableMap<String, Any> { | ||
| val src = request.inputStream.readAllBytes() | ||
| val outputString = String(src, StandardCharsets.UTF_8).trim { it <= ' ' } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (bug_risk): 使用谓词 'it <= ' '' 进行修剪可能会删除 JSON 中的有效空格。
使用此修剪谓词可能会删除 JSON 中的有效空格,从而导致解析错误。请使用标准的 trim() 或确保输入验证是适当的。
| val outputString = String(src, StandardCharsets.UTF_8).trim { it <= ' ' } | |
| val outputString = String(src, StandardCharsets.UTF_8).trim() |
Original comment in English
suggestion (bug_risk): Trimming with predicate 'it <= ' '' may remove valid whitespace from JSON.
Using this trim predicate may remove valid whitespace from JSON, leading to parsing errors. Please use standard trim() or ensure input validation is appropriate.
| val outputString = String(src, StandardCharsets.UTF_8).trim { it <= ' ' } | |
| val outputString = String(src, StandardCharsets.UTF_8).trim() |
src/main/java/icu/samnyan/aqua/sega/cardmaker/CardMakerControllerAdvice.kt
Outdated
Show resolved
Hide resolved
|
TODO before merging:
|
This would finally make AquaDX pure kotlin
TODO next:
Sourcery 总结
删除遗留的Java模块和依赖项,将代码库转换为纯Kotlin,重构工具类和加密逻辑,引入新的ByteBuf扩展和CardMakerController API,并添加Flyway迁移以删除旧的数据库表。
新功能:
改进:
构建:
杂项:
Original summary in English
Summary by Sourcery
Drop legacy Java modules and dependencies to convert the codebase to pure Kotlin, refactor utilities and encryption logic, introduce new ByteBuf extensions and a CardMakerController API, and add a Flyway migration to remove old database tables.
New Features:
Enhancements:
Build:
Chores: