Add: backlib for shared code between microservices. Started huertos microservice.

This commit is contained in:
Jose
2026-01-18 05:28:32 +01:00
parent ba5fc38b4b
commit 5f38bdc76f
50 changed files with 1191 additions and 216 deletions

View File

@@ -15,6 +15,11 @@
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.springframework.ide.eclipse.boot.validation.springbootbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>

View File

@@ -0,0 +1,2 @@
boot.validation.initialized=true
eclipse.preferences.version=1

View File

@@ -0,0 +1,11 @@
package net.miarma.backend.huertos;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class HuertosApplication {
public static void main(String[] args) {
SpringApplication.run(HuertosApplication.class, args);
}
}

View File

@@ -0,0 +1,70 @@
package net.miarma.backend.huertos.model;
import java.time.Instant;
import java.util.UUID;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
@Entity
@Table(name = "huertos_announces")
public class Announcement {
@Id
@Column(name = "announce_id", columnDefinition = "BINARY(16)")
private UUID announceId;
@Column(name = "body", nullable = false, columnDefinition = "TEXT")
private String body;
@Column(name = "priority", nullable = false)
private Byte priority;
@Column(name = "published_by", columnDefinition = "BINARY(16)", nullable = false)
private UUID publishedBy;
@Column(name = "created_at", nullable = false)
private Instant createdAt;
public UUID getAnnounceId() {
return announceId;
}
public void setAnnounceId(UUID announceId) {
this.announceId = announceId;
}
public String getBody() {
return body;
}
public void setBody(String body) {
this.body = body;
}
public Byte getPriority() {
return priority;
}
public void setPriority(Byte priority) {
this.priority = priority;
}
public UUID getPublishedBy() {
return publishedBy;
}
public void setPublishedBy(UUID publishedBy) {
this.publishedBy = publishedBy;
}
public Instant getCreatedAt() {
return createdAt;
}
public void setCreatedAt(Instant createdAt) {
this.createdAt = createdAt;
}
}

View File

@@ -0,0 +1,58 @@
package net.miarma.backend.huertos.model;
import java.math.BigDecimal;
import java.time.Instant;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
@Entity
@Table(name = "huertos_balance")
public class Balance {
@Id
private Byte id = 1;
@Column(name = "initial_bank", nullable = false)
private BigDecimal initialBank;
@Column(name = "initial_cash", nullable = false)
private BigDecimal initialCash;
@Column(name = "created_at", nullable = false)
private Instant createdAt;
public Byte getId() {
return id;
}
public void setId(Byte id) {
this.id = id;
}
public BigDecimal getInitialBank() {
return initialBank;
}
public void setInitialBank(BigDecimal initialBank) {
this.initialBank = initialBank;
}
public BigDecimal getInitialCash() {
return initialCash;
}
public void setInitialCash(BigDecimal initialCash) {
this.initialCash = initialCash;
}
public Instant getCreatedAt() {
return createdAt;
}
public void setCreatedAt(Instant createdAt) {
this.createdAt = createdAt;
}
}

View File

@@ -0,0 +1,93 @@
package net.miarma.backend.huertos.model;
import java.math.BigDecimal;
import java.time.Instant;
import java.util.UUID;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
@Entity
@Table(name = "huertos_expenses")
public class Expense {
@Id
@Column(name = "expense_id", columnDefinition = "BINARY(16)")
private UUID expenseId;
@Column(name = "concept", nullable = false, length = 128)
private String concept;
@Column(name = "amount", nullable = false)
private BigDecimal amount;
@Column(name = "supplier", nullable = false, length = 128)
private String supplier;
@Column(name = "invoice", nullable = false, length = 32)
private String invoice;
@Column(name = "type")
private Byte type;
@Column(name = "created_at", nullable = false)
private Instant createdAt;
public UUID getExpenseId() {
return expenseId;
}
public void setExpenseId(UUID expenseId) {
this.expenseId = expenseId;
}
public String getConcept() {
return concept;
}
public void setConcept(String concept) {
this.concept = concept;
}
public BigDecimal getAmount() {
return amount;
}
public void setAmount(BigDecimal amount) {
this.amount = amount;
}
public String getSupplier() {
return supplier;
}
public void setSupplier(String supplier) {
this.supplier = supplier;
}
public String getInvoice() {
return invoice;
}
public void setInvoice(String invoice) {
this.invoice = invoice;
}
public Byte getType() {
return type;
}
public void setType(Byte type) {
this.type = type;
}
public Instant getCreatedAt() {
return createdAt;
}
public void setCreatedAt(Instant createdAt) {
this.createdAt = createdAt;
}
}

View File

@@ -0,0 +1,136 @@
package net.miarma.backend.huertos.model;
import java.time.Instant;
import java.util.UUID;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
@Entity
@Table(name = "huertos_user_metadata")
public class HuertosUserMetadata {
@Id
@Column(name = "user_id", columnDefinition = "BINARY(16)")
private UUID userId;
@Column(name = "member_number", nullable = false, unique = true)
private Integer memberNumber;
@Column(name = "plot_number", nullable = false)
private Integer plotNumber;
@Column(name = "dni", nullable = false, unique = true, length = 9)
private String dni;
@Column(name = "phone", nullable = false, length = 20)
private String phone;
@Column(name = "type", nullable = false)
private Byte type;
@Column(name = "role", nullable = false)
private Byte role;
@Column(name = "notes")
private String notes;
@Column(name = "created_at", nullable = false)
private Instant createdAt;
@Column(name = "assigned_at")
private Instant assignedAt;
@Column(name = "deactivated_at")
private Instant deactivatedAt;
public UUID getUserId() {
return userId;
}
public void setUserId(UUID userId) {
this.userId = userId;
}
public Integer getMemberNumber() {
return memberNumber;
}
public void setMemberNumber(Integer memberNumber) {
this.memberNumber = memberNumber;
}
public Integer getPlotNumber() {
return plotNumber;
}
public void setPlotNumber(Integer plotNumber) {
this.plotNumber = plotNumber;
}
public String getDni() {
return dni;
}
public void setDni(String dni) {
this.dni = dni;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public Byte getType() {
return type;
}
public void setType(Byte type) {
this.type = type;
}
public Byte getRole() {
return role;
}
public void setRole(Byte role) {
this.role = role;
}
public String getNotes() {
return notes;
}
public void setNotes(String notes) {
this.notes = notes;
}
public Instant getCreatedAt() {
return createdAt;
}
public void setCreatedAt(Instant createdAt) {
this.createdAt = createdAt;
}
public Instant getAssignedAt() {
return assignedAt;
}
public void setAssignedAt(Instant assignedAt) {
this.assignedAt = assignedAt;
}
public Instant getDeactivatedAt() {
return deactivatedAt;
}
public void setDeactivatedAt(Instant deactivatedAt) {
this.deactivatedAt = deactivatedAt;
}
}

View File

@@ -0,0 +1,93 @@
package net.miarma.backend.huertos.model;
import java.math.BigDecimal;
import java.time.Instant;
import java.util.UUID;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
@Entity
@Table(name = "huertos_incomes")
public class Income {
@Id
@Column(name = "income_id", columnDefinition = "BINARY(16)")
private UUID incomeId;
@Column(name = "user_id", columnDefinition = "BINARY(16)", nullable = false)
private UUID userId;
@Column(name = "concept", nullable = false, length = 128)
private String concept;
@Column(name = "amount", nullable = false)
private BigDecimal amount;
@Column(name = "type")
private Byte type;
@Column(name = "frequency")
private Byte frequency;
@Column(name = "created_at", nullable = false)
private Instant createdAt;
public UUID getIncomeId() {
return incomeId;
}
public void setIncomeId(UUID incomeId) {
this.incomeId = incomeId;
}
public UUID getUserId() {
return userId;
}
public void setUserId(UUID userId) {
this.userId = userId;
}
public String getConcept() {
return concept;
}
public void setConcept(String concept) {
this.concept = concept;
}
public BigDecimal getAmount() {
return amount;
}
public void setAmount(BigDecimal amount) {
this.amount = amount;
}
public Byte getType() {
return type;
}
public void setType(Byte type) {
this.type = type;
}
public Byte getFrequency() {
return frequency;
}
public void setFrequency(Byte frequency) {
this.frequency = frequency;
}
public Instant getCreatedAt() {
return createdAt;
}
public void setCreatedAt(Instant createdAt) {
this.createdAt = createdAt;
}
}

View File

@@ -0,0 +1,191 @@
package net.miarma.backend.huertos.model;
import java.time.Instant;
import java.util.UUID;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
@Entity
@Table(name = "huertos_pre_users")
public class PreUser {
@Id
@Column(name = "pre_user_id", columnDefinition = "BINARY(16)")
private UUID preUserId;
@Column(name = "request_id", columnDefinition = "BINARY(16)", nullable = false)
private UUID requestId;
@Column(name = "user_name", nullable = false, length = 64)
private String userName;
@Column(name = "display_name", nullable = false, length = 128)
private String displayName;
@Column(name = "dni", nullable = false, length = 9)
private String dni;
@Column(name = "phone", nullable = false, length = 20)
private String phone;
@Column(name = "email", nullable = false, length = 128)
private String email;
@Column(name = "password", length = 256)
private String password;
@Column(name = "address", length = 128)
private String address;
@Column(name = "zip_code", length = 10)
private String zipCode;
@Column(name = "city", length = 64)
private String city;
@Column(name = "member_number")
private Integer memberNumber;
@Column(name = "plot_number")
private Integer plotNumber;
@Column(name = "type", nullable = false)
private Byte type;
@Column(name = "role", nullable = false)
private Byte role;
@Column(name = "created_at", nullable = false)
private Instant createdAt;
public UUID getPreUserId() {
return preUserId;
}
public void setPreUserId(UUID preUserId) {
this.preUserId = preUserId;
}
public UUID getRequestId() {
return requestId;
}
public void setRequestId(UUID requestId) {
this.requestId = requestId;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getDisplayName() {
return displayName;
}
public void setDisplayName(String displayName) {
this.displayName = displayName;
}
public String getDni() {
return dni;
}
public void setDni(String dni) {
this.dni = dni;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getZipCode() {
return zipCode;
}
public void setZipCode(String zipCode) {
this.zipCode = zipCode;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public Integer getMemberNumber() {
return memberNumber;
}
public void setMemberNumber(Integer memberNumber) {
this.memberNumber = memberNumber;
}
public Integer getPlotNumber() {
return plotNumber;
}
public void setPlotNumber(Integer plotNumber) {
this.plotNumber = plotNumber;
}
public Byte getType() {
return type;
}
public void setType(Byte type) {
this.type = type;
}
public Byte getRole() {
return role;
}
public void setRole(Byte role) {
this.role = role;
}
public Instant getCreatedAt() {
return createdAt;
}
public void setCreatedAt(Instant createdAt) {
this.createdAt = createdAt;
}
}

View File

@@ -0,0 +1,82 @@
package net.miarma.backend.huertos.model;
import java.time.Instant;
import java.util.UUID;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
@Entity
@Table(name = "huertos_requests")
public class Request {
@Id
@Column(name = "request_id", columnDefinition = "BINARY(16)")
private UUID requestId;
@Column(name = "type", nullable = false)
private Byte type;
@Column(name = "status", nullable = false)
private Byte status;
@Column(name = "requested_by", columnDefinition = "BINARY(16)")
private UUID requestedBy;
@Column(name = "target_user_id", columnDefinition = "BINARY(16)")
private UUID targetUserId;
@Column(name = "created_at", nullable = false)
private Instant createdAt;
public UUID getRequestId() {
return requestId;
}
public void setRequestId(UUID requestId) {
this.requestId = requestId;
}
public Byte getType() {
return type;
}
public void setType(Byte type) {
this.type = type;
}
public Byte getStatus() {
return status;
}
public void setStatus(Byte status) {
this.status = status;
}
public UUID getRequestedBy() {
return requestedBy;
}
public void setRequestedBy(UUID requestedBy) {
this.requestedBy = requestedBy;
}
public UUID getTargetUserId() {
return targetUserId;
}
public void setTargetUserId(UUID targetUserId) {
this.targetUserId = targetUserId;
}
public Instant getCreatedAt() {
return createdAt;
}
public void setCreatedAt(Instant createdAt) {
this.createdAt = createdAt;
}
}

View File

@@ -0,0 +1,47 @@
server:
port: 8081
servlet:
context-path: /v2/huertos
spring:
application:
name: huertos-service
datasource:
url: jdbc:mariadb://localhost:3306/miarma_v2
username: admin
password: ositovito
driver-class-name: org.mariadb.jdbc.Driver
jpa:
open-in-view: false
hibernate:
ddl-auto: update
show-sql: true
properties:
hibernate:
format_sql: true
jdbc:
time_zone: UTC
dialect: org.hibernate.dialect.MariaDBDialect
jackson:
serialization:
INDENT_OUTPUT: true
date-format: yyyy-MM-dd'T'HH:mm:ss
time-zone: Europe/Madrid
default-property-inclusion: non_null
generator:
WRITE_DATES_AS_TIMESTAMPS: false
logging:
level:
org.hibernate.SQL: DEBUG
org.hibernate.orm.jdbc.bind: TRACE
org.springframework.security: INFO
management:
endpoints:
web:
exposure:
include: health,info