Back to list
psh-inc

kotlin

by psh-inc

0🍴 0📅 Jan 24, 2026

SKILL.md


name: kotlin description: | Kotlin 2.3.0 language patterns, coroutines, and Spring integration Use when: Writing backend services, JPA entities, DTOs, controllers, or any Kotlin code in casino-b allowed-tools: Read, Edit, Write, Glob, Grep, Bash

Kotlin Skill

Kotlin 2.3.0 with Spring Boot 3.2.5 and Java 21 for the casino backend. This codebase uses data classes extensively for entities and DTOs, relies on constructor injection, and follows strict BigDecimal handling for financial operations. Null safety is critical—leverage Kotlin's type system to prevent runtime errors.

Quick Start

Data Class for DTOs

data class CreateBonusRequest(
    @field:NotBlank(message = "Name is required")
    val name: String,

    @field:NotNull(message = "Amount is required")
    val amount: BigDecimal,

    val category: BonusCategory? = null
)

Service with Constructor Injection

@Service
@Transactional
class BonusService(
    private val bonusRepository: BonusRepository,
    private val playerRepository: PlayerRepository,
    private val eventPublisher: EventPublisher
) {
    private val logger = LoggerFactory.getLogger(javaClass)

    fun create(request: CreateBonusRequest): BonusDto {
        logger.info("Creating bonus: ${request.name}")
        val bonus = Bonus(name = request.name, amount = request.amount)
        return BonusDto.from(bonusRepository.save(bonus))
    }
}

Entity with JPA Annotations

@Entity
@Table(name = "bonuses")
data class Bonus(
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    val id: Long? = null,

    @Column(nullable = false)
    val name: String,

    @Column(precision = 19, scale = 2)
    val amount: BigDecimal = BigDecimal.ZERO,

    @Enumerated(EnumType.STRING)
    val category: BonusCategory? = null
)

Key Concepts

ConceptUsageExample
Null safetyUse ? for nullable, !! sparinglyplayer?.wallet?.balance
BigDecimalAlways from StringBigDecimal("123.45")
Data classesDTOs and entitiesdata class PlayerDto(...)
Extension functionsUtility methodsfun String.toSlug()
Scope functionsObject configurationapply, let, also, run

Common Patterns

Repository Lookup with Null Handling

When: Finding entities that may not exist

fun findById(id: Long): PlayerDto {
    val player = playerRepository.findById(id)
        .orElseThrow { PlayerNotFoundException("Player not found: $id") }
    return PlayerDto.from(player)
}

Safe BigDecimal Comparison

When: Comparing monetary values

// CORRECT - use compareTo
if (balance.compareTo(BigDecimal.ZERO) > 0) {
    processWithdrawal()
}

// WRONG - equals checks scale too
if (balance == BigDecimal.ZERO) { } // May fail unexpectedly

See Also

  • See the spring-boot skill for REST controllers and service configuration
  • See the jpa skill for entity mapping and repository patterns
  • See the kafka skill for event publishing patterns
  • See the postgresql skill for database migrations and queries

Score

Total Score

50/100

Based on repository quality metrics

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

0/10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

0/5

Reviews

💬

Reviews coming soon