generated from orchestr7/react-kotlin-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
802 additions
and
238 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
backend/src/main/kotlin/ru/posidata/backend/entity/OurUserEntityFromDb.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package ru.posidata.backend.entity | ||
|
||
import jakarta.persistence.* | ||
import ru.posidata.common.UserForSerializationDTO | ||
|
||
@Entity | ||
@Table(name = "users") | ||
class OurUserEntityFromDb( | ||
@Id @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
var id: Long = 0, | ||
var firstName: String?, | ||
var lastName: String?, | ||
var username: String?, | ||
|
||
var firstGameScore: Int, | ||
var secondGameScore: Int, | ||
var thirdGameScore: Int, | ||
) { | ||
fun toDTO(): UserForSerializationDTO { | ||
return UserForSerializationDTO( | ||
firstName = this.firstName, | ||
lastName = this.lastName, | ||
username = this.username, | ||
firstGameScore = this.firstGameScore, | ||
secondGameScore = this.secondGameScore, | ||
thirdGameScore = this.thirdGameScore | ||
) | ||
} | ||
|
||
fun currentGameNumber() = | ||
when { | ||
firstGameScore == -1 -> 1 | ||
secondGameScore == -1 && firstGameScore != -1 -> 2 | ||
thirdGameScore == -1 && firstGameScore != -1 && secondGameScore != -1 -> 3 | ||
else -> 4 | ||
} | ||
|
||
fun updateResultIn(currentGameNumber: Int, isNextRound: Boolean) { | ||
when(currentGameNumber) { | ||
1 -> if(!isNextRound) ++firstGameScore else ++secondGameScore | ||
2 -> if(!isNextRound) ++secondGameScore else ++thirdGameScore | ||
3 -> if(!isNextRound) ++thirdGameScore | ||
} | ||
println(firstGameScore) | ||
println(secondGameScore) | ||
println(thirdGameScore) | ||
} | ||
|
||
override fun equals(other: Any?): Boolean { | ||
if (this === other) return true | ||
if (javaClass != other?.javaClass) return false | ||
|
||
other as OurUserEntityFromDb | ||
|
||
if (id != other.id) return false | ||
if (firstName != other.firstName) return false | ||
if (lastName != other.lastName) return false | ||
if (username != other.username) return false | ||
if (firstGameScore != other.firstGameScore) return false | ||
if (secondGameScore != other.secondGameScore) return false | ||
if (thirdGameScore != other.thirdGameScore) return false | ||
|
||
return true | ||
} | ||
|
||
override fun hashCode(): Int { | ||
var result = id.hashCode() | ||
result = 31 * result + (firstName?.hashCode() ?: 0) | ||
result = 31 * result + (lastName?.hashCode() ?: 0) | ||
result = 31 * result + (username?.hashCode() ?: 0) | ||
result = 31 * result + (firstGameScore?.hashCode() ?: 0) | ||
result = 31 * result + (secondGameScore?.hashCode() ?: 0) | ||
result = 31 * result + (thirdGameScore?.hashCode() ?: 0) | ||
return result | ||
} | ||
} |
24 changes: 0 additions & 24 deletions
24
backend/src/main/kotlin/ru/posidata/backend/entity/User.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.