refactor: change mutable properties to immutable in data classes

This commit is contained in:
grtsinry43 2025-10-05 11:42:29 +08:00
parent 586425998d
commit 6d1c03ec85
Signed by: grtsinry43
GPG Key ID: F3305FB3A978C934
14 changed files with 72 additions and 75 deletions

View File

@ -4,10 +4,10 @@
<selectionStates> <selectionStates>
<SelectionState runConfigName="app"> <SelectionState runConfigName="app">
<option name="selectionMode" value="DROPDOWN" /> <option name="selectionMode" value="DROPDOWN" />
<DropdownSelection timestamp="2025-10-04T16:00:07.516752Z"> <DropdownSelection timestamp="2025-10-05T02:12:09.761378Z">
<Target type="DEFAULT_BOOT"> <Target type="DEFAULT_BOOT">
<handle> <handle>
<DeviceId pluginId="PhysicalDevice" identifier="serial=15947d21" /> <DeviceId pluginId="PhysicalDevice" identifier="serial=6fbe7ac" />
</handle> </handle>
</Target> </Target>
</DropdownSelection> </DropdownSelection>

1
.idea/gradle.xml generated
View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="GradleMigrationSettings" migrationVersion="1" />
<component name="GradleSettings"> <component name="GradleSettings">
<option name="linkedExternalProjectsSettings"> <option name="linkedExternalProjectsSettings">
<GradleProjectSettings> <GradleProjectSettings>

View File

@ -1,11 +1,7 @@
package com.qingshuige.tangyuan.model package com.qingshuige.tangyuan.model
data class Category( data class Category(
var categoryId: Int = 0, val categoryId: Int = 0,
var baseName: String? = null, val baseName: String? = null,
var baseDescription: String? = null val baseDescription: String? = null
) { )
override fun toString(): String {
return baseName!!
}
}

View File

@ -3,11 +3,11 @@ package com.qingshuige.tangyuan.model
import java.util.Date import java.util.Date
data class Comment( data class Comment(
var commentId: Int = 0, val commentId: Int = 0,
var parentCommentId: Int = 0, val parentCommentId: Int = 0,
var userId: Int = 0, val userId: Int = 0,
var postId: Int = 0, val postId: Int = 0,
var content: String? = null, val content: String? = null,
var imageGuid: String? = null, val imageGuid: String? = null,
var commentDateTime: Date? = null val commentDateTime: Date? = null
) )

View File

@ -3,9 +3,9 @@ package com.qingshuige.tangyuan.model
import java.util.Date import java.util.Date
data class CreatPostMetadataDto( data class CreatPostMetadataDto(
var isVisible: Boolean = false, val isVisible: Boolean = false,
var postDateTime: Date? = null, val postDateTime: Date? = null,
var sectionId: Int = 0, val sectionId: Int = 0,
var categoryId: Int = 0, val categoryId: Int = 0,
var userId: Int = 0 val userId: Int = 0
) )

View File

@ -3,10 +3,10 @@ package com.qingshuige.tangyuan.model
import java.util.Date import java.util.Date
data class CreateCommentDto( data class CreateCommentDto(
var commentDateTime: Date? = null, val commentDateTime: Date? = null,
var content: String? = null, val content: String? = null,
var imageGuid: String? = null, val imageGuid: String? = null,
var parentCommentId: Long = 0, val parentCommentId: Long = 0,
var postId: Long = 0, val postId: Long = 0,
var userId: Long = 0 val userId: Long = 0
) )

View File

@ -1,9 +1,9 @@
package com.qingshuige.tangyuan.model package com.qingshuige.tangyuan.model
data class CreateUserDto( data class CreateUserDto(
var avatarGuid: String? = null, val avatarGuid: String? = null,
var isoRegionName: String? = null, val isoRegionName: String? = null,
var nickName: String? = null, val nickName: String? = null,
var password: String? = null, val password: String? = null,
var phoneNumber: String? = null val phoneNumber: String? = null
) )

View File

@ -1,6 +1,6 @@
package com.qingshuige.tangyuan.model package com.qingshuige.tangyuan.model
data class LoginDto( data class LoginDto(
var password: String? = null, val password: String? = null,
var phoneNumber: String? = null val phoneNumber: String? = null
) )

View File

@ -3,11 +3,11 @@ package com.qingshuige.tangyuan.model
import java.util.Date import java.util.Date
data class NewNotification( data class NewNotification(
var notificationId: Int = 0, val notificationId: Int = 0,
var type: String? = null, val type: String? = null,
var targetUserId: Int = 0, val targetUserId: Int = 0,
var sourceId: Int = 0, val sourceId: Int = 0,
var sourceType: String? = null, val sourceType: String? = null,
var isRead: Boolean = false, val isRead: Boolean = false,
var createDate: Date? = null val createDate: Date? = null
) )

View File

@ -3,12 +3,12 @@ package com.qingshuige.tangyuan.model
import java.util.Date import java.util.Date
data class Notification( data class Notification(
var notificationId: Int = 0, val notificationId: Int = 0,
var targetUserId: Int = 0, val targetUserId: Int = 0,
var targetPostId: Int = 0, val targetPostId: Int = 0,
var targetCommentId: Int = 0, val targetCommentId: Int = 0,
var sourceCommentId: Int = 0, val sourceCommentId: Int = 0,
var sourceUserId: Int = 0, val sourceUserId: Int = 0,
var isRead: Boolean = false, val isRead: Boolean = false,
var notificationDateTime: Date? = null val notificationDateTime: Date? = null
) )

View File

@ -1,9 +1,9 @@
package com.qingshuige.tangyuan.model package com.qingshuige.tangyuan.model
data class PostBody( data class PostBody(
var postId: Int = 0, val postId: Int = 0,
var textContent: String? = null, val textContent: String? = null,
var image1UUID: String? = null, val image1UUID: String? = null,
var image2UUID: String? = null, val image2UUID: String? = null,
var image3UUID: String? = null val image3UUID: String? = null
) )

View File

@ -1,12 +1,12 @@
package com.qingshuige.tangyuan.model package com.qingshuige.tangyuan.model
data class User( data class User(
var userId: Int = 0, val userId: Int = 0,
var nickName: String = "", val nickName: String = "",
var phoneNumber: String = "", val phoneNumber: String = "",
var isoRegionName: String = "", val isoRegionName: String = "",
var email: String = "", val email: String = "",
var bio: String = "", val bio: String = "",
var avatarGuid: String = "", val avatarGuid: String = "",
var password: String = "" val password: String = ""
) )

View File

@ -16,10 +16,10 @@ class JwtAuthenticator(private val tm: TokenManager, private val baseUrl: String
@Throws(IOException::class) @Throws(IOException::class)
override fun authenticate(route: Route?, response: Response): Request? { override fun authenticate(route: Route?, response: Response): Request? {
// 创建登录请求体 // 创建登录请求体
val loginDto = LoginDto().apply { val loginDto = LoginDto(
password = tm.password,
phoneNumber = tm.phoneNumber phoneNumber = tm.phoneNumber
password = tm.password )
}
val json = gson.toJson(loginDto) val json = gson.toJson(loginDto)
val requestBody = json.toRequestBody(mediaType) val requestBody = json.toRequestBody(mediaType)