init
This commit is contained in:
51
src/main/kotlin/space/luminic/finance/models/Account.kt
Normal file
51
src/main/kotlin/space/luminic/finance/models/Account.kt
Normal file
@@ -0,0 +1,51 @@
|
||||
package space.luminic.finance.models
|
||||
|
||||
import org.springframework.data.annotation.CreatedDate
|
||||
import org.springframework.data.annotation.Id
|
||||
import org.springframework.data.annotation.LastModifiedDate
|
||||
import org.springframework.data.annotation.ReadOnlyProperty
|
||||
import org.springframework.data.relational.core.mapping.Column
|
||||
import org.springframework.data.relational.core.mapping.Table
|
||||
import java.math.BigDecimal
|
||||
import java.time.Instant
|
||||
|
||||
@Table(name = "accounts")
|
||||
data class Account (
|
||||
@Id val id: Int? = null,
|
||||
@Column("space_id")
|
||||
val spaceId: Int,
|
||||
val name: String,
|
||||
val type: AccountType = AccountType.COLLECTING,
|
||||
@Column("currency_code")
|
||||
val currencyCode: String,
|
||||
|
||||
var amount: BigDecimal,
|
||||
@Column("goal_id")
|
||||
var goalId: Int? = null,
|
||||
@Column("is_deleted")
|
||||
var isDeleted: Boolean = false,
|
||||
@Column("created_by")
|
||||
val createdById: String? = null,
|
||||
@CreatedDate
|
||||
@Column("created_at")
|
||||
val createdAt: Instant? = null,
|
||||
@Column("updated_by")
|
||||
val updatedById: String? = null,
|
||||
@LastModifiedDate
|
||||
@Column("updated_at")
|
||||
val updatedAt: Instant? = null,
|
||||
|
||||
) {
|
||||
@ReadOnlyProperty var goal: Goal? = null
|
||||
@ReadOnlyProperty var currency: Currency? = null
|
||||
@ReadOnlyProperty var transactions: List<Transaction>? = null
|
||||
@ReadOnlyProperty var createdBy: User? = null
|
||||
@ReadOnlyProperty var updatedBy: User? = null
|
||||
|
||||
|
||||
enum class AccountType(displayName: String) {
|
||||
SALARY("Зарплатный"),
|
||||
COLLECTING("Накопительный"),
|
||||
LOANS("Долговой"),
|
||||
}
|
||||
}
|
||||
62
src/main/kotlin/space/luminic/finance/models/Budget.kt
Normal file
62
src/main/kotlin/space/luminic/finance/models/Budget.kt
Normal file
@@ -0,0 +1,62 @@
|
||||
package space.luminic.finance.models
|
||||
|
||||
import org.springframework.data.annotation.CreatedBy
|
||||
import org.springframework.data.annotation.CreatedDate
|
||||
import org.springframework.data.annotation.Id
|
||||
import org.springframework.data.annotation.LastModifiedBy
|
||||
import org.springframework.data.annotation.LastModifiedDate
|
||||
import org.springframework.data.annotation.ReadOnlyProperty
|
||||
import org.springframework.data.relational.core.mapping.Column
|
||||
import org.springframework.data.relational.core.mapping.Table
|
||||
import java.math.BigDecimal
|
||||
import java.time.Instant
|
||||
import java.time.LocalDate
|
||||
|
||||
|
||||
@Table( "budgets")
|
||||
data class Budget(
|
||||
@Id var id: Int? = null,
|
||||
@Column("space_id")
|
||||
val spaceId: Int,
|
||||
val type: BudgetType = BudgetType.SPECIAL,
|
||||
var name: String,
|
||||
var description: String? = null,
|
||||
@Column("date_from")
|
||||
var dateFrom: LocalDate,
|
||||
@Column("date_to")
|
||||
var dateTo: LocalDate,
|
||||
val transactions: List<Transaction> = listOf(),
|
||||
val categories: List<BudgetCategory> = listOf(),
|
||||
@Column("is_deleted")
|
||||
var isDeleted: Boolean = false,
|
||||
@CreatedBy
|
||||
@Column("created_by")
|
||||
val createdById: Int? = null,
|
||||
@CreatedDate
|
||||
@Column("created_at")
|
||||
var createdAt: Instant? = null,
|
||||
@LastModifiedBy
|
||||
@Column("updated_by")
|
||||
var updatedById: Int? = null,
|
||||
@LastModifiedDate
|
||||
@Column("updated_at")
|
||||
var updatedAt: Instant? = null,
|
||||
) {
|
||||
|
||||
@ReadOnlyProperty var createdBy: User? = null
|
||||
@ReadOnlyProperty var updatedBy: User? = null
|
||||
data class BudgetCategory(
|
||||
val categoryId: String,
|
||||
val limit: BigDecimal
|
||||
) {
|
||||
@ReadOnlyProperty var category: Category? = null
|
||||
}
|
||||
|
||||
enum class BudgetType(val displayName: String) {
|
||||
MONTHLY("Месячный"),
|
||||
SPECIAL("Специальный")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
49
src/main/kotlin/space/luminic/finance/models/Category.kt
Normal file
49
src/main/kotlin/space/luminic/finance/models/Category.kt
Normal file
@@ -0,0 +1,49 @@
|
||||
package space.luminic.finance.models
|
||||
|
||||
import org.springframework.data.annotation.CreatedBy
|
||||
import org.springframework.data.annotation.CreatedDate
|
||||
import org.springframework.data.annotation.Id
|
||||
import org.springframework.data.annotation.LastModifiedBy
|
||||
import org.springframework.data.annotation.LastModifiedDate
|
||||
import org.springframework.data.annotation.ReadOnlyProperty
|
||||
import org.springframework.data.mongodb.core.mapping.Document
|
||||
import org.springframework.data.annotation.Transient
|
||||
import java.time.Instant
|
||||
|
||||
|
||||
@Document(collection = "categories")
|
||||
data class Category(
|
||||
@Id val id: String? = null,
|
||||
val spaceId: String,
|
||||
val type: CategoryType,
|
||||
val name: String,
|
||||
val icon: String,
|
||||
var isDeleted: Boolean = false,
|
||||
|
||||
@CreatedBy
|
||||
val createdById: String? = null,
|
||||
@CreatedDate
|
||||
val createdAt: Instant? = null,
|
||||
@LastModifiedBy
|
||||
val updatedById: String? = null,
|
||||
@LastModifiedDate
|
||||
val updatedAt: Instant? = null,
|
||||
) {
|
||||
@ReadOnlyProperty var createdBy: User? = null
|
||||
@ReadOnlyProperty var updatedBy: User? = null
|
||||
|
||||
enum class CategoryType(val displayName: String) {
|
||||
INCOME("Поступления"),
|
||||
EXPENSE("Расходы")
|
||||
}
|
||||
|
||||
|
||||
@Document(collection = "categories_etalon")
|
||||
data class CategoryEtalon(
|
||||
@Id val id: String? = null,
|
||||
val type: CategoryType,
|
||||
val name: String,
|
||||
val icon: String
|
||||
)
|
||||
|
||||
}
|
||||
13
src/main/kotlin/space/luminic/finance/models/Currency.kt
Normal file
13
src/main/kotlin/space/luminic/finance/models/Currency.kt
Normal file
@@ -0,0 +1,13 @@
|
||||
package space.luminic.finance.models
|
||||
|
||||
import org.springframework.data.annotation.Id
|
||||
import org.springframework.data.mongodb.core.mapping.Document
|
||||
import java.math.BigDecimal
|
||||
|
||||
@Document(collection = "currencies_ref")
|
||||
data class Currency(
|
||||
@Id val code: String,
|
||||
val name: String,
|
||||
val symbol: String
|
||||
)
|
||||
|
||||
18
src/main/kotlin/space/luminic/finance/models/CurrencyRate.kt
Normal file
18
src/main/kotlin/space/luminic/finance/models/CurrencyRate.kt
Normal file
@@ -0,0 +1,18 @@
|
||||
package space.luminic.finance.models
|
||||
|
||||
import org.springframework.data.annotation.Id
|
||||
import org.springframework.data.annotation.ReadOnlyProperty
|
||||
import org.springframework.data.mongodb.core.mapping.Document
|
||||
import java.math.BigDecimal
|
||||
import java.time.LocalDate
|
||||
|
||||
@Document(collection = "currency_rates")
|
||||
data class CurrencyRate(
|
||||
@Id val id: String? = null,
|
||||
val currencyCode: String,
|
||||
val rate: BigDecimal,
|
||||
val date: LocalDate
|
||||
)
|
||||
{
|
||||
@ReadOnlyProperty var currency: Currency? = null
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package space.luminic.finance.models
|
||||
|
||||
|
||||
open class NotFoundException(message: String) : Exception(message)
|
||||
open class TelegramBotException(message: String, val chatId: Long) : Exception(message)
|
||||
40
src/main/kotlin/space/luminic/finance/models/Goal.kt
Normal file
40
src/main/kotlin/space/luminic/finance/models/Goal.kt
Normal file
@@ -0,0 +1,40 @@
|
||||
package space.luminic.finance.models
|
||||
|
||||
import org.springframework.data.annotation.CreatedBy
|
||||
import org.springframework.data.annotation.CreatedDate
|
||||
import org.springframework.data.annotation.Id
|
||||
import org.springframework.data.annotation.LastModifiedBy
|
||||
import org.springframework.data.annotation.LastModifiedDate
|
||||
import org.springframework.data.mongodb.core.mapping.Document
|
||||
import org.springframework.data.annotation.Transient
|
||||
import space.luminic.finance.dtos.UserDTO
|
||||
import java.math.BigDecimal
|
||||
import java.text.Bidi
|
||||
import java.time.Instant
|
||||
import java.time.LocalDate
|
||||
|
||||
|
||||
@Document(collection = "goals")
|
||||
data class Goal(
|
||||
@Id val id: String? = null,
|
||||
val spaceId: String,
|
||||
val type: GoalType,
|
||||
val name: String,
|
||||
val description: String? = null,
|
||||
val goalAmount: BigDecimal,
|
||||
val goalDate: LocalDate,
|
||||
@CreatedBy val createdById: String,
|
||||
@Transient val createdBy: User? = null,
|
||||
@CreatedDate val createdAt: Instant? = null,
|
||||
@LastModifiedBy val updatedById: String,
|
||||
@Transient val updatedBy: User? = null,
|
||||
@LastModifiedDate val updatedAt: Instant? = null,
|
||||
) {
|
||||
|
||||
enum class GoalType(val displayName: String, val icon: String) {
|
||||
AUTO("Авто", "🏎️"),
|
||||
VACATION("Отпуск", "🏖️"),
|
||||
GOODS("Покупка", "🛍️"),
|
||||
OTHER("Прочее", "💸")
|
||||
}
|
||||
}
|
||||
20
src/main/kotlin/space/luminic/finance/models/PushMessage.kt
Normal file
20
src/main/kotlin/space/luminic/finance/models/PushMessage.kt
Normal file
@@ -0,0 +1,20 @@
|
||||
package space.luminic.finance.models
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
|
||||
@Serializable
|
||||
data class PushMessage(
|
||||
|
||||
// title: str
|
||||
// body: str
|
||||
// icon: str
|
||||
// badge: str
|
||||
// url: str
|
||||
val title: String,
|
||||
val body: String,
|
||||
val icon: String? = null,
|
||||
val badge: String? = null,
|
||||
val url: String? = null
|
||||
|
||||
)
|
||||
36
src/main/kotlin/space/luminic/finance/models/Space.kt
Normal file
36
src/main/kotlin/space/luminic/finance/models/Space.kt
Normal file
@@ -0,0 +1,36 @@
|
||||
package space.luminic.finance.models
|
||||
|
||||
import org.springframework.data.annotation.CreatedBy
|
||||
import org.springframework.data.annotation.CreatedDate
|
||||
import org.springframework.data.annotation.Id
|
||||
import org.springframework.data.annotation.LastModifiedBy
|
||||
import org.springframework.data.annotation.LastModifiedDate
|
||||
import org.springframework.data.annotation.ReadOnlyProperty
|
||||
import org.springframework.data.mongodb.core.mapping.Document
|
||||
import org.springframework.data.annotation.Transient
|
||||
import java.time.Instant
|
||||
|
||||
|
||||
@Document(collection = "spaces")
|
||||
data class Space (
|
||||
@Id val id: String? = null,
|
||||
val name: String,
|
||||
val ownerId: String,
|
||||
val participantsIds: List<String> = emptyList(),
|
||||
var isDeleted: Boolean = false,
|
||||
@CreatedBy val createdById: String? = null,
|
||||
@CreatedDate val createdAt: Instant? = null,
|
||||
@LastModifiedBy val updatedById: String? = null,
|
||||
@LastModifiedDate var updatedAt: Instant? = null,
|
||||
) {
|
||||
@ReadOnlyProperty var owner: User? = null
|
||||
|
||||
@ReadOnlyProperty var participants: List<User>? = null
|
||||
|
||||
@ReadOnlyProperty var createdBy: User? = null
|
||||
|
||||
@ReadOnlyProperty var updatedBy: User? = null
|
||||
|
||||
|
||||
|
||||
}
|
||||
23
src/main/kotlin/space/luminic/finance/models/Subscription.kt
Normal file
23
src/main/kotlin/space/luminic/finance/models/Subscription.kt
Normal file
@@ -0,0 +1,23 @@
|
||||
package space.luminic.finance.models
|
||||
|
||||
import org.springframework.data.annotation.Id
|
||||
import org.springframework.data.mongodb.core.mapping.DBRef
|
||||
import org.springframework.data.mongodb.core.mapping.Document
|
||||
import java.time.Instant
|
||||
|
||||
@Document(collection = "subscriptions")
|
||||
data class Subscription(
|
||||
@Id val id: String? = null,
|
||||
@DBRef val user: User? = null,
|
||||
val endpoint: String,
|
||||
val auth: String,
|
||||
val p256dh: String,
|
||||
var isActive: Boolean,
|
||||
val createdAt: Instant = Instant.now(),
|
||||
)
|
||||
|
||||
|
||||
data class SubscriptionDTO (
|
||||
val endpoint: String,
|
||||
val keys: Map<String, String>
|
||||
)
|
||||
22
src/main/kotlin/space/luminic/finance/models/Token.kt
Normal file
22
src/main/kotlin/space/luminic/finance/models/Token.kt
Normal file
@@ -0,0 +1,22 @@
|
||||
package space.luminic.finance.models
|
||||
|
||||
import org.springframework.data.annotation.Id
|
||||
import org.springframework.data.mongodb.core.mapping.Document
|
||||
import java.time.LocalDateTime
|
||||
|
||||
@Document(collection = "tokens")
|
||||
data class Token(
|
||||
@Id
|
||||
val id: String? = null,
|
||||
val token: String,
|
||||
val username: String,
|
||||
val issuedAt: LocalDateTime,
|
||||
val expiresAt: LocalDateTime,
|
||||
val status: TokenStatus = TokenStatus.ACTIVE
|
||||
) {
|
||||
|
||||
enum class TokenStatus {
|
||||
ACTIVE, REVOKED, EXPIRED
|
||||
}
|
||||
|
||||
}
|
||||
59
src/main/kotlin/space/luminic/finance/models/Transaction.kt
Normal file
59
src/main/kotlin/space/luminic/finance/models/Transaction.kt
Normal file
@@ -0,0 +1,59 @@
|
||||
package space.luminic.finance.models
|
||||
|
||||
import org.springframework.data.annotation.CreatedBy
|
||||
import org.springframework.data.annotation.CreatedDate
|
||||
import org.springframework.data.annotation.Id
|
||||
import org.springframework.data.annotation.LastModifiedBy
|
||||
import org.springframework.data.annotation.LastModifiedDate
|
||||
import org.springframework.data.annotation.ReadOnlyProperty
|
||||
import org.springframework.data.mongodb.core.mapping.Document
|
||||
import org.springframework.data.annotation.Transient
|
||||
import java.math.BigDecimal
|
||||
import java.time.Instant
|
||||
|
||||
@Document(collection = "transactions")
|
||||
data class Transaction(
|
||||
@Id val id: String? = null,
|
||||
val spaceId: String,
|
||||
var parentId: String? = null,
|
||||
val type: TransactionType = TransactionType.EXPENSE,
|
||||
val kind: TransactionKind = TransactionKind.INSTANT,
|
||||
val categoryId: String,
|
||||
|
||||
val comment: String,
|
||||
val amount: BigDecimal,
|
||||
val fees: BigDecimal = BigDecimal.ZERO,
|
||||
val fromAccountId: String,
|
||||
val toAccountId: String? = null,
|
||||
val date: Instant = Instant.now(),
|
||||
var isDeleted: Boolean = false,
|
||||
@CreatedBy
|
||||
val createdById: String? = null,
|
||||
@CreatedDate
|
||||
val createdAt: Instant? = null,
|
||||
@LastModifiedBy
|
||||
val updatedById: String? = null,
|
||||
@LastModifiedDate
|
||||
val updatedAt: Instant? = null,
|
||||
) {
|
||||
|
||||
@ReadOnlyProperty var category: Category? = null
|
||||
@ReadOnlyProperty var toAccount: Account? = null
|
||||
@ReadOnlyProperty var fromAccount: Account? = null
|
||||
@ReadOnlyProperty var createdBy: User? = null
|
||||
@ReadOnlyProperty var updatedBy: User? = null
|
||||
|
||||
|
||||
|
||||
|
||||
enum class TransactionType(val displayName: String) {
|
||||
INCOME("Поступления"),
|
||||
EXPENSE("Расходы"),
|
||||
TRANSFER("Перевод")
|
||||
}
|
||||
|
||||
enum class TransactionKind(val displayName: String) {
|
||||
PLANNING("Плановая"),
|
||||
INSTANT("Текущая")
|
||||
}
|
||||
}
|
||||
26
src/main/kotlin/space/luminic/finance/models/User.kt
Normal file
26
src/main/kotlin/space/luminic/finance/models/User.kt
Normal file
@@ -0,0 +1,26 @@
|
||||
package space.luminic.finance.models
|
||||
|
||||
|
||||
import org.springframework.data.annotation.Id
|
||||
import org.springframework.data.mongodb.core.mapping.Document
|
||||
import org.springframework.data.annotation.Transient
|
||||
import java.time.LocalDate
|
||||
import java.time.LocalDateTime
|
||||
|
||||
@Document("users")
|
||||
data class User(
|
||||
@Id
|
||||
var id: String? = null,
|
||||
val username: String,
|
||||
var firstName: String,
|
||||
var tgId: String? = null,
|
||||
var tgUserName: String? = null,
|
||||
var password: String,
|
||||
var isActive: Boolean = true,
|
||||
var regDate: LocalDate = LocalDate.now(),
|
||||
val createdAt: LocalDateTime = LocalDateTime.now(),
|
||||
var roles: MutableList<String> = mutableListOf(),
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user