add account data

- AccountRepository
- AccountEntity
- 001-accounts.sql
- Account with Request and Response
This commit is contained in:
2025-09-11 10:31:23 +02:00
parent 61519fc586
commit 9e5bf28ff9
4 changed files with 61 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
-- Table: public.accounts
DROP TABLE IF EXISTS public.accounts;
CREATE TABLE IF NOT EXISTS public.accounts
(
id UUID DEFAULT uuidv7(),
name VARCHAR(50) NOT NULL,
amount NUMERIC(19, 2) NOT NULL,
CONSTRAINT pk_contact_types PRIMARY KEY (id)
);
ALTER TABLE IF EXISTS public.accounts
OWNER to role_owner;
-- Revoke all permissions from existing roles
REVOKE ALL ON TABLE public.accounts FROM role_service, role_support;
-- Grant appropriate permissions
GRANT ALL ON TABLE public.accounts TO role_maintainer;
GRANT SELECT, INSERT, UPDATE ON TABLE public.accounts TO role_service;
GRANT SELECT ON TABLE public.accounts TO role_support;

View File

@@ -0,0 +1,17 @@
package ltd.lulz.model
import java.math.BigDecimal
import java.util.UUID
object Account {
data class Request(
val name: String,
val amount: BigDecimal,
)
data class Response(
val id: UUID,
val name: String,
val amount: BigDecimal,
)
}

View File

@@ -0,0 +1,14 @@
package ltd.lulz.model
import java.math.BigDecimal
import java.util.UUID
import org.springframework.data.annotation.Id
import org.springframework.data.relational.core.mapping.Table
@Table("accounts")
data class AccountEntity(
@Id
val id: UUID? = null,
val name: String,
val amount: BigDecimal,
)

View File

@@ -0,0 +1,9 @@
package ltd.lulz.repository
import java.util.UUID
import ltd.lulz.model.AccountEntity
import org.springframework.data.repository.reactive.ReactiveCrudRepository
import org.springframework.stereotype.Repository
@Repository
interface AccountRepository : ReactiveCrudRepository<AccountEntity, UUID>