Add: all of Huertos but controllers (jwt verification, MSR model, etc). Add: RS256 to global JWT handling
This commit is contained in:
@@ -1,8 +0,0 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
|
||||
org.eclipse.jdt.core.compiler.release=disabled
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
||||
@@ -1,4 +0,0 @@
|
||||
activeProfiles=
|
||||
eclipse.preferences.version=1
|
||||
resolveWorkspaceProjects=true
|
||||
version=1
|
||||
@@ -1,2 +0,0 @@
|
||||
boot.validation.initialized=true
|
||||
eclipse.preferences.version=1
|
||||
@@ -9,6 +9,11 @@
|
||||
</parent>
|
||||
<artifactId>huertos</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>25</maven.compiler.source>
|
||||
<maven.compiler.target>25</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<!-- Spring Boot -->
|
||||
<dependency>
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package net.miarma.backend.huertos.config;
|
||||
|
||||
import net.miarma.backend.huertos.security.HuertosJwtFilter;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||
import org.springframework.security.config.http.SessionCreationPolicy;
|
||||
import org.springframework.security.web.SecurityFilterChain;
|
||||
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
|
||||
|
||||
@Configuration
|
||||
@EnableWebSecurity
|
||||
@EnableMethodSecurity(prePostEnabled = true)
|
||||
public class SecurityConfig {
|
||||
|
||||
private final HuertosJwtFilter jwtFilter;
|
||||
|
||||
public SecurityConfig(HuertosJwtFilter jwtFilter) {
|
||||
this.jwtFilter = jwtFilter;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
|
||||
http
|
||||
.csrf(csrf -> csrf.disable())
|
||||
.sessionManagement(sm -> sm.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
|
||||
.authorizeHttpRequests(auth -> auth
|
||||
// PUBLICAS
|
||||
.requestMatchers("/login").permitAll()
|
||||
.requestMatchers("/announces/**").permitAll()
|
||||
.requestMatchers("/huertos/members/waitlist").permitAll()
|
||||
.requestMatchers("/huertos/members/latest-number").permitAll()
|
||||
// PRIVADAS
|
||||
.requestMatchers("/**").authenticated()
|
||||
);
|
||||
http.addFilterBefore(jwtFilter, UsernamePasswordAuthenticationFilter.class);
|
||||
return http.build();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
package net.miarma.backend.huertos.dto;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.UUID;
|
||||
|
||||
public class AnnouncementDto {
|
||||
public static class Request {
|
||||
private String body;
|
||||
private Byte priority;
|
||||
private UUID publishedBy;
|
||||
|
||||
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 static class Response {
|
||||
private UUID announceId;
|
||||
private String body;
|
||||
private Byte priority;
|
||||
private UUID publishedBy;
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package net.miarma.backend.huertos.dto;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.Instant;
|
||||
|
||||
public class BalanceDto {
|
||||
private Byte id;
|
||||
private BigDecimal initialBank;
|
||||
private BigDecimal initialCash;
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package net.miarma.backend.huertos.dto;
|
||||
|
||||
public class BalanceWithTotalsDto {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
package net.miarma.backend.huertos.dto;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.Instant;
|
||||
import java.util.UUID;
|
||||
|
||||
public class ExpenseDto {
|
||||
public static class Request {
|
||||
private String concept;
|
||||
private BigDecimal amount;
|
||||
private String supplier;
|
||||
private String invoice;
|
||||
private Byte type;
|
||||
|
||||
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 static class Response {
|
||||
private UUID expenseId;
|
||||
private String concept;
|
||||
private BigDecimal amount;
|
||||
private String supplier;
|
||||
private String invoice;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
private Byte type;
|
||||
private Instant createdAt;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
package net.miarma.backend.huertos.dto;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.UUID;
|
||||
|
||||
public class HuertosUserMetadataDto {
|
||||
private UUID userId;
|
||||
private Integer memberNumber;
|
||||
private Integer plotNumber;
|
||||
private String dni;
|
||||
private String phone;
|
||||
private Byte type;
|
||||
private Byte role;
|
||||
private String notes;
|
||||
private Instant createdAt;
|
||||
private Instant assignedAt;
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
package net.miarma.backend.huertos.dto;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.Instant;
|
||||
import java.util.UUID;
|
||||
|
||||
public class IncomeDto {
|
||||
public static class Request {
|
||||
private UUID userId;
|
||||
private String concept;
|
||||
private BigDecimal amount;
|
||||
private Byte type;
|
||||
private Byte frequency;
|
||||
|
||||
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 static class Response {
|
||||
private UUID incomeId;
|
||||
private UUID userId;
|
||||
private String concept;
|
||||
private BigDecimal amount;
|
||||
private Byte type;
|
||||
private Byte frequency;
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,274 @@
|
||||
package net.miarma.backend.huertos.dto;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.UUID;
|
||||
|
||||
public class PreUserDto {
|
||||
public static class Request {
|
||||
private UUID requestId;
|
||||
private String userName;
|
||||
private String displayName;
|
||||
private String dni;
|
||||
private String phone;
|
||||
private String email;
|
||||
private String password;
|
||||
private String address;
|
||||
private String zipCode;
|
||||
private String city;
|
||||
private Integer memberNumber;
|
||||
private Integer plotNumber;
|
||||
private Byte type;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
private Byte role;
|
||||
}
|
||||
|
||||
public static class Response {
|
||||
private UUID preUserId;
|
||||
private UUID requestId;
|
||||
private String userName;
|
||||
private String displayName;
|
||||
private String dni;
|
||||
private String phone;
|
||||
private String email;
|
||||
private String address;
|
||||
private String zipCode;
|
||||
private String city;
|
||||
private Integer memberNumber;
|
||||
private Integer plotNumber;
|
||||
private Byte type;
|
||||
private Byte role;
|
||||
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 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
package net.miarma.backend.huertos.dto;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.UUID;
|
||||
|
||||
public class RequestDto {
|
||||
public static class Request {
|
||||
private Byte type;
|
||||
private Byte status;
|
||||
private UUID requestedBy;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
private UUID targetUserId;
|
||||
}
|
||||
|
||||
public static class Response {
|
||||
private UUID requestId;
|
||||
private Byte type;
|
||||
private Byte status;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
private UUID requestedBy;
|
||||
private UUID targetUserId;
|
||||
private Instant createdAt;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package net.miarma.backend.huertos.dto.view;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
public class VBalanceWithTotalsDto {
|
||||
private Long id;
|
||||
private Double initialBank;
|
||||
private Double initialCash;
|
||||
private Double totalBankExpenses;
|
||||
private Double totalCashExpenses;
|
||||
private Double totalBankIncomes;
|
||||
private Double totalCashIncomes;
|
||||
private Instant createdAt;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Double getInitialBank() {
|
||||
return initialBank;
|
||||
}
|
||||
|
||||
public void setInitialBank(Double initialBank) {
|
||||
this.initialBank = initialBank;
|
||||
}
|
||||
|
||||
public Double getInitialCash() {
|
||||
return initialCash;
|
||||
}
|
||||
|
||||
public void setInitialCash(Double initialCash) {
|
||||
this.initialCash = initialCash;
|
||||
}
|
||||
|
||||
public Double getTotalBankExpenses() {
|
||||
return totalBankExpenses;
|
||||
}
|
||||
|
||||
public void setTotalBankExpenses(Double totalBankExpenses) {
|
||||
this.totalBankExpenses = totalBankExpenses;
|
||||
}
|
||||
|
||||
public Double getTotalCashExpenses() {
|
||||
return totalCashExpenses;
|
||||
}
|
||||
|
||||
public void setTotalCashExpenses(Double totalCashExpenses) {
|
||||
this.totalCashExpenses = totalCashExpenses;
|
||||
}
|
||||
|
||||
public Double getTotalBankIncomes() {
|
||||
return totalBankIncomes;
|
||||
}
|
||||
|
||||
public void setTotalBankIncomes(Double totalBankIncomes) {
|
||||
this.totalBankIncomes = totalBankIncomes;
|
||||
}
|
||||
|
||||
public Double getTotalCashIncomes() {
|
||||
return totalCashIncomes;
|
||||
}
|
||||
|
||||
public void setTotalCashIncomes(Double totalCashIncomes) {
|
||||
this.totalCashIncomes = totalCashIncomes;
|
||||
}
|
||||
|
||||
public Instant getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(Instant createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,151 @@
|
||||
package net.miarma.backend.huertos.dto.view;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.UUID;
|
||||
|
||||
public class VHuertosMemberDto {
|
||||
private UUID userId;
|
||||
private String displayName;
|
||||
private String avatar;
|
||||
private Integer memberNumber;
|
||||
private Integer plotNumber;
|
||||
private String dni;
|
||||
private String phone;
|
||||
private Byte type;
|
||||
private Byte role;
|
||||
private Byte credentialStatus;
|
||||
private String notes;
|
||||
private Instant createdAt;
|
||||
private Instant assignedAt;
|
||||
private Instant deactivatedAt;
|
||||
private Byte serviceId;
|
||||
private String serviceName;
|
||||
|
||||
public UUID getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(UUID userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public String getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
public void setDisplayName(String displayName) {
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
public String getAvatar() {
|
||||
return avatar;
|
||||
}
|
||||
|
||||
public void setAvatar(String avatar) {
|
||||
this.avatar = avatar;
|
||||
}
|
||||
|
||||
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 Byte getCredentialStatus() {
|
||||
return credentialStatus;
|
||||
}
|
||||
|
||||
public void setCredentialStatus(Byte credentialStatus) {
|
||||
this.credentialStatus = credentialStatus;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public Byte getServiceId() {
|
||||
return serviceId;
|
||||
}
|
||||
|
||||
public void setServiceId(Byte serviceId) {
|
||||
this.serviceId = serviceId;
|
||||
}
|
||||
|
||||
public String getServiceName() {
|
||||
return serviceName;
|
||||
}
|
||||
|
||||
public void setServiceName(String serviceName) {
|
||||
this.serviceName = serviceName;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package net.miarma.backend.huertos.dto.view;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.UUID;
|
||||
|
||||
public class VIncomesWithFullNamesDto {
|
||||
private UUID incomeId;
|
||||
private UUID userId;
|
||||
private String displayName;
|
||||
private String concept;
|
||||
private Double amount;
|
||||
private Byte type;
|
||||
private Byte frequency;
|
||||
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 getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
public void setDisplayName(String displayName) {
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
public String getConcept() {
|
||||
return concept;
|
||||
}
|
||||
|
||||
public void setConcept(String concept) {
|
||||
this.concept = concept;
|
||||
}
|
||||
|
||||
public Double getAmount() {
|
||||
return amount;
|
||||
}
|
||||
|
||||
public void setAmount(Double 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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,198 @@
|
||||
package net.miarma.backend.huertos.dto.view;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.UUID;
|
||||
|
||||
public class VRequestsWithPreUsersDto {
|
||||
private UUID requestId;
|
||||
private Byte requestType;
|
||||
private Byte requestStatus;
|
||||
private UUID requestedBy;
|
||||
private String requestedByName;
|
||||
private UUID targetUserId;
|
||||
private Instant requestCreatedAt;
|
||||
|
||||
// PreUser fields
|
||||
private UUID preUserId;
|
||||
private String preUserName;
|
||||
private String preDisplayName;
|
||||
private String preDni;
|
||||
private String prePhone;
|
||||
private String preEmail;
|
||||
private String preAddress;
|
||||
private String preZipCode;
|
||||
private String preCity;
|
||||
private Integer preMemberNumber;
|
||||
private Integer prePlotNumber;
|
||||
private Byte preType;
|
||||
private Byte preRole;
|
||||
private Instant preCreatedAt;
|
||||
|
||||
public UUID getRequestId() {
|
||||
return requestId;
|
||||
}
|
||||
|
||||
public void setRequestId(UUID requestId) {
|
||||
this.requestId = requestId;
|
||||
}
|
||||
|
||||
public Byte getRequestType() {
|
||||
return requestType;
|
||||
}
|
||||
|
||||
public void setRequestType(Byte requestType) {
|
||||
this.requestType = requestType;
|
||||
}
|
||||
|
||||
public Byte getRequestStatus() {
|
||||
return requestStatus;
|
||||
}
|
||||
|
||||
public void setRequestStatus(Byte requestStatus) {
|
||||
this.requestStatus = requestStatus;
|
||||
}
|
||||
|
||||
public UUID getRequestedBy() {
|
||||
return requestedBy;
|
||||
}
|
||||
|
||||
public void setRequestedBy(UUID requestedBy) {
|
||||
this.requestedBy = requestedBy;
|
||||
}
|
||||
|
||||
public String getRequestedByName() {
|
||||
return requestedByName;
|
||||
}
|
||||
|
||||
public void setRequestedByName(String requestedByName) {
|
||||
this.requestedByName = requestedByName;
|
||||
}
|
||||
|
||||
public UUID getTargetUserId() {
|
||||
return targetUserId;
|
||||
}
|
||||
|
||||
public void setTargetUserId(UUID targetUserId) {
|
||||
this.targetUserId = targetUserId;
|
||||
}
|
||||
|
||||
public Instant getRequestCreatedAt() {
|
||||
return requestCreatedAt;
|
||||
}
|
||||
|
||||
public void setRequestCreatedAt(Instant requestCreatedAt) {
|
||||
this.requestCreatedAt = requestCreatedAt;
|
||||
}
|
||||
|
||||
public UUID getPreUserId() {
|
||||
return preUserId;
|
||||
}
|
||||
|
||||
public void setPreUserId(UUID preUserId) {
|
||||
this.preUserId = preUserId;
|
||||
}
|
||||
|
||||
public String getPreUserName() {
|
||||
return preUserName;
|
||||
}
|
||||
|
||||
public void setPreUserName(String preUserName) {
|
||||
this.preUserName = preUserName;
|
||||
}
|
||||
|
||||
public String getPreDisplayName() {
|
||||
return preDisplayName;
|
||||
}
|
||||
|
||||
public void setPreDisplayName(String preDisplayName) {
|
||||
this.preDisplayName = preDisplayName;
|
||||
}
|
||||
|
||||
public String getPreDni() {
|
||||
return preDni;
|
||||
}
|
||||
|
||||
public void setPreDni(String preDni) {
|
||||
this.preDni = preDni;
|
||||
}
|
||||
|
||||
public String getPrePhone() {
|
||||
return prePhone;
|
||||
}
|
||||
|
||||
public void setPrePhone(String prePhone) {
|
||||
this.prePhone = prePhone;
|
||||
}
|
||||
|
||||
public String getPreEmail() {
|
||||
return preEmail;
|
||||
}
|
||||
|
||||
public void setPreEmail(String preEmail) {
|
||||
this.preEmail = preEmail;
|
||||
}
|
||||
|
||||
public String getPreAddress() {
|
||||
return preAddress;
|
||||
}
|
||||
|
||||
public void setPreAddress(String preAddress) {
|
||||
this.preAddress = preAddress;
|
||||
}
|
||||
|
||||
public String getPreZipCode() {
|
||||
return preZipCode;
|
||||
}
|
||||
|
||||
public void setPreZipCode(String preZipCode) {
|
||||
this.preZipCode = preZipCode;
|
||||
}
|
||||
|
||||
public String getPreCity() {
|
||||
return preCity;
|
||||
}
|
||||
|
||||
public void setPreCity(String preCity) {
|
||||
this.preCity = preCity;
|
||||
}
|
||||
|
||||
public Integer getPreMemberNumber() {
|
||||
return preMemberNumber;
|
||||
}
|
||||
|
||||
public void setPreMemberNumber(Integer preMemberNumber) {
|
||||
this.preMemberNumber = preMemberNumber;
|
||||
}
|
||||
|
||||
public Integer getPrePlotNumber() {
|
||||
return prePlotNumber;
|
||||
}
|
||||
|
||||
public void setPrePlotNumber(Integer prePlotNumber) {
|
||||
this.prePlotNumber = prePlotNumber;
|
||||
}
|
||||
|
||||
public Byte getPreType() {
|
||||
return preType;
|
||||
}
|
||||
|
||||
public void setPreType(Byte preType) {
|
||||
this.preType = preType;
|
||||
}
|
||||
|
||||
public Byte getPreRole() {
|
||||
return preRole;
|
||||
}
|
||||
|
||||
public void setPreRole(Byte preRole) {
|
||||
this.preRole = preRole;
|
||||
}
|
||||
|
||||
public Instant getPreCreatedAt() {
|
||||
return preCreatedAt;
|
||||
}
|
||||
|
||||
public void setPreCreatedAt(Instant preCreatedAt) {
|
||||
this.preCreatedAt = preCreatedAt;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package net.miarma.backend.huertos.mapper;
|
||||
|
||||
import net.miarma.backend.huertos.dto.AnnouncementDto;
|
||||
import net.miarma.backend.huertos.model.Announcement;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.UUID;
|
||||
|
||||
public class AnnouncementMapper {
|
||||
|
||||
public static AnnouncementDto.Response toDto(Announcement entity) {
|
||||
AnnouncementDto.Response dto = new AnnouncementDto.Response();
|
||||
dto.setAnnounceId(entity.getAnnounceId());
|
||||
dto.setBody(entity.getBody());
|
||||
dto.setPriority(entity.getPriority());
|
||||
dto.setPublishedBy(entity.getPublishedBy());
|
||||
dto.setCreatedAt(entity.getCreatedAt());
|
||||
return dto;
|
||||
}
|
||||
|
||||
public static Announcement toEntity(AnnouncementDto.Request dto) {
|
||||
Announcement entity = new Announcement();
|
||||
entity.setAnnounceId(UUID.randomUUID());
|
||||
entity.setBody(dto.getBody());
|
||||
entity.setPriority(dto.getPriority());
|
||||
entity.setPublishedBy(dto.getPublishedBy());
|
||||
entity.setCreatedAt(Instant.now());
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package net.miarma.backend.huertos.mapper;
|
||||
|
||||
import net.miarma.backend.huertos.dto.BalanceDto;
|
||||
import net.miarma.backend.huertos.model.Balance;
|
||||
|
||||
public class BalanceMapper {
|
||||
|
||||
public static BalanceDto toDto(Balance balance) {
|
||||
if (balance == null) return null;
|
||||
|
||||
BalanceDto dto = new BalanceDto();
|
||||
dto.setId(balance.getId());
|
||||
dto.setInitialBank(balance.getInitialBank());
|
||||
dto.setInitialCash(balance.getInitialCash());
|
||||
dto.setCreatedAt(balance.getCreatedAt());
|
||||
return dto;
|
||||
}
|
||||
|
||||
public static Balance toEntity(BalanceDto dto) {
|
||||
if (dto == null) return null;
|
||||
|
||||
Balance balance = new Balance();
|
||||
balance.setId(dto.getId());
|
||||
balance.setInitialBank(dto.getInitialBank());
|
||||
balance.setInitialCash(dto.getInitialCash());
|
||||
balance.setCreatedAt(dto.getCreatedAt());
|
||||
return balance;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package net.miarma.backend.huertos.mapper;
|
||||
|
||||
import net.miarma.backend.huertos.dto.ExpenseDto;
|
||||
import net.miarma.backend.huertos.model.Expense;
|
||||
|
||||
public class ExpenseMapper {
|
||||
|
||||
public static ExpenseDto.Response toResponse(Expense entity) {
|
||||
if (entity == null) return null;
|
||||
|
||||
ExpenseDto.Response dto = new ExpenseDto.Response();
|
||||
dto.setExpenseId(entity.getExpenseId());
|
||||
dto.setConcept(entity.getConcept());
|
||||
dto.setAmount(entity.getAmount());
|
||||
dto.setSupplier(entity.getSupplier());
|
||||
dto.setInvoice(entity.getInvoice());
|
||||
dto.setType(entity.getType());
|
||||
dto.setCreatedAt(entity.getCreatedAt());
|
||||
return dto;
|
||||
}
|
||||
|
||||
public static Expense toEntity(ExpenseDto.Request dto) {
|
||||
if (dto == null) return null;
|
||||
|
||||
Expense entity = new Expense();
|
||||
entity.setConcept(dto.getConcept());
|
||||
entity.setAmount(dto.getAmount());
|
||||
entity.setSupplier(dto.getSupplier());
|
||||
entity.setInvoice(dto.getInvoice());
|
||||
entity.setType(dto.getType());
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package net.miarma.backend.huertos.mapper;
|
||||
|
||||
import net.miarma.backend.huertos.dto.HuertosUserMetadataDto;
|
||||
import net.miarma.backend.huertos.model.HuertosUserMetadata;
|
||||
|
||||
public class HuertosUserMetadataMapper {
|
||||
|
||||
public static HuertosUserMetadataDto toDto(HuertosUserMetadata entity) {
|
||||
HuertosUserMetadataDto dto = new HuertosUserMetadataDto();
|
||||
dto.setUserId(entity.getUserId());
|
||||
dto.setMemberNumber(entity.getMemberNumber());
|
||||
dto.setPlotNumber(entity.getPlotNumber());
|
||||
dto.setDni(entity.getDni());
|
||||
dto.setPhone(entity.getPhone());
|
||||
dto.setType(entity.getType());
|
||||
dto.setRole(entity.getRole());
|
||||
dto.setNotes(entity.getNotes());
|
||||
dto.setCreatedAt(entity.getCreatedAt());
|
||||
dto.setAssignedAt(entity.getAssignedAt());
|
||||
dto.setDeactivatedAt(entity.getDeactivatedAt());
|
||||
return dto;
|
||||
}
|
||||
|
||||
public static HuertosUserMetadata fromDto(HuertosUserMetadataDto dto) {
|
||||
HuertosUserMetadata entity = new HuertosUserMetadata();
|
||||
entity.setUserId(dto.getUserId());
|
||||
entity.setMemberNumber(dto.getMemberNumber());
|
||||
entity.setPlotNumber(dto.getPlotNumber());
|
||||
entity.setDni(dto.getDni());
|
||||
entity.setPhone(dto.getPhone());
|
||||
entity.setType(dto.getType());
|
||||
entity.setRole(dto.getRole());
|
||||
entity.setNotes(dto.getNotes());
|
||||
entity.setCreatedAt(dto.getCreatedAt());
|
||||
entity.setAssignedAt(dto.getAssignedAt());
|
||||
entity.setDeactivatedAt(dto.getDeactivatedAt());
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package net.miarma.backend.huertos.mapper;
|
||||
|
||||
import net.miarma.backend.huertos.dto.IncomeDto;
|
||||
import net.miarma.backend.huertos.model.Income;
|
||||
|
||||
public class IncomeMapper {
|
||||
|
||||
public static IncomeDto.Response toResponse(Income entity) {
|
||||
if (entity == null) return null;
|
||||
|
||||
IncomeDto.Response dto = new IncomeDto.Response();
|
||||
dto.setIncomeId(entity.getIncomeId());
|
||||
dto.setUserId(entity.getUserId());
|
||||
dto.setConcept(entity.getConcept());
|
||||
dto.setAmount(entity.getAmount());
|
||||
dto.setType(entity.getType());
|
||||
dto.setFrequency(entity.getFrequency());
|
||||
dto.setCreatedAt(entity.getCreatedAt());
|
||||
return dto;
|
||||
}
|
||||
|
||||
public static Income toEntity(IncomeDto.Request dto) {
|
||||
if (dto == null) return null;
|
||||
|
||||
Income entity = new Income();
|
||||
entity.setUserId(dto.getUserId());
|
||||
entity.setConcept(dto.getConcept());
|
||||
entity.setAmount(dto.getAmount());
|
||||
entity.setType(dto.getType());
|
||||
entity.setFrequency(dto.getFrequency());
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package net.miarma.backend.huertos.mapper;
|
||||
|
||||
import net.miarma.backend.huertos.dto.PreUserDto;
|
||||
import net.miarma.backend.huertos.model.PreUser;
|
||||
|
||||
public class PreUserMapper {
|
||||
|
||||
public static PreUserDto.Response toResponse(PreUser entity) {
|
||||
if (entity == null) return null;
|
||||
|
||||
PreUserDto.Response dto = new PreUserDto.Response();
|
||||
dto.setPreUserId(entity.getPreUserId());
|
||||
dto.setRequestId(entity.getRequestId());
|
||||
dto.setUserName(entity.getUserName());
|
||||
dto.setDisplayName(entity.getDisplayName());
|
||||
dto.setDni(entity.getDni());
|
||||
dto.setPhone(entity.getPhone());
|
||||
dto.setEmail(entity.getEmail());
|
||||
dto.setAddress(entity.getAddress());
|
||||
dto.setZipCode(entity.getZipCode());
|
||||
dto.setCity(entity.getCity());
|
||||
dto.setMemberNumber(entity.getMemberNumber());
|
||||
dto.setPlotNumber(entity.getPlotNumber());
|
||||
dto.setType(entity.getType());
|
||||
dto.setRole(entity.getRole());
|
||||
dto.setCreatedAt(entity.getCreatedAt());
|
||||
return dto;
|
||||
}
|
||||
|
||||
public static PreUser toEntity(PreUserDto.Request dto) {
|
||||
if (dto == null) return null;
|
||||
|
||||
PreUser entity = new PreUser();
|
||||
entity.setRequestId(dto.getRequestId());
|
||||
entity.setUserName(dto.getUserName());
|
||||
entity.setDisplayName(dto.getDisplayName());
|
||||
entity.setDni(dto.getDni());
|
||||
entity.setPhone(dto.getPhone());
|
||||
entity.setEmail(dto.getEmail());
|
||||
entity.setPassword(dto.getPassword());
|
||||
entity.setAddress(dto.getAddress());
|
||||
entity.setZipCode(dto.getZipCode());
|
||||
entity.setCity(dto.getCity());
|
||||
entity.setMemberNumber(dto.getMemberNumber());
|
||||
entity.setPlotNumber(dto.getPlotNumber());
|
||||
entity.setType(dto.getType());
|
||||
entity.setRole(dto.getRole());
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package net.miarma.backend.huertos.mapper;
|
||||
|
||||
import net.miarma.backend.huertos.dto.RequestDto;
|
||||
import net.miarma.backend.huertos.model.Request;
|
||||
|
||||
public class RequestMapper {
|
||||
|
||||
public static RequestDto.Response toResponse(Request entity) {
|
||||
if (entity == null) return null;
|
||||
|
||||
RequestDto.Response dto = new RequestDto.Response();
|
||||
dto.setRequestId(entity.getRequestId());
|
||||
dto.setType(entity.getType());
|
||||
dto.setStatus(entity.getStatus());
|
||||
dto.setRequestedBy(entity.getRequestedBy());
|
||||
dto.setTargetUserId(entity.getTargetUserId());
|
||||
dto.setCreatedAt(entity.getCreatedAt());
|
||||
return dto;
|
||||
}
|
||||
|
||||
public static Request toEntity(RequestDto.Request dto) {
|
||||
if (dto == null) return null;
|
||||
|
||||
Request entity = new Request();
|
||||
entity.setType(dto.getType());
|
||||
entity.setStatus(dto.getStatus());
|
||||
entity.setRequestedBy(dto.getRequestedBy());
|
||||
entity.setTargetUserId(dto.getTargetUserId());
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package net.miarma.backend.huertos.mapper.view;
|
||||
|
||||
import net.miarma.backend.huertos.dto.view.VBalanceWithTotalsDto;
|
||||
import net.miarma.backend.huertos.model.view.VBalanceWithTotals;
|
||||
|
||||
public class VBalanceWithTotalsMapper {
|
||||
|
||||
public static VBalanceWithTotalsDto toDto(VBalanceWithTotals entity) {
|
||||
VBalanceWithTotalsDto dto = new VBalanceWithTotalsDto();
|
||||
dto.setId(entity.getId());
|
||||
dto.setInitialBank(entity.getInitialBank());
|
||||
dto.setInitialCash(entity.getInitialCash());
|
||||
dto.setTotalBankExpenses(entity.getTotalBankExpenses());
|
||||
dto.setTotalCashExpenses(entity.getTotalCashExpenses());
|
||||
dto.setTotalBankIncomes(entity.getTotalBankIncomes());
|
||||
dto.setTotalCashIncomes(entity.getTotalCashIncomes());
|
||||
dto.setCreatedAt(entity.getCreatedAt());
|
||||
return dto;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package net.miarma.backend.huertos.mapper.view;
|
||||
|
||||
import net.miarma.backend.huertos.dto.view.VHuertosMemberDto;
|
||||
import net.miarma.backend.huertos.model.view.VHuertosMember;
|
||||
|
||||
public class VHuertosMemberMapper {
|
||||
|
||||
public static VHuertosMemberDto toDto(VHuertosMember entity) {
|
||||
VHuertosMemberDto dto = new VHuertosMemberDto();
|
||||
dto.setUserId(entity.getUserId());
|
||||
dto.setDisplayName(entity.getDisplayName());
|
||||
dto.setAvatar(entity.getAvatar());
|
||||
dto.setMemberNumber(entity.getMemberNumber());
|
||||
dto.setPlotNumber(entity.getPlotNumber());
|
||||
dto.setDni(entity.getDni());
|
||||
dto.setPhone(entity.getPhone());
|
||||
dto.setType(entity.getType());
|
||||
dto.setRole(entity.getRole());
|
||||
dto.setCredentialStatus(entity.getCredentialStatus());
|
||||
dto.setNotes(entity.getNotes());
|
||||
dto.setCreatedAt(entity.getCreatedAt());
|
||||
dto.setAssignedAt(entity.getAssignedAt());
|
||||
dto.setDeactivatedAt(entity.getDeactivatedAt());
|
||||
dto.setServiceId(entity.getServiceId());
|
||||
dto.setServiceName(entity.getServiceName());
|
||||
return dto;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package net.miarma.backend.huertos.mapper.view;
|
||||
|
||||
import net.miarma.backend.huertos.dto.view.VIncomesWithFullNamesDto;
|
||||
import net.miarma.backend.huertos.model.view.VIncomesWithFullNames;
|
||||
|
||||
public class VIncomesWithFullNamesMapper {
|
||||
|
||||
public static VIncomesWithFullNamesDto toDto(VIncomesWithFullNames entity) {
|
||||
VIncomesWithFullNamesDto dto = new VIncomesWithFullNamesDto();
|
||||
dto.setIncomeId(entity.getIncomeId());
|
||||
dto.setUserId(entity.getUserId());
|
||||
dto.setDisplayName(entity.getDisplayName());
|
||||
dto.setConcept(entity.getConcept());
|
||||
dto.setAmount(entity.getAmount());
|
||||
dto.setType(entity.getType());
|
||||
dto.setFrequency(entity.getFrequency());
|
||||
dto.setCreatedAt(entity.getCreatedAt());
|
||||
return dto;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package net.miarma.backend.huertos.mapper.view;
|
||||
|
||||
import net.miarma.backend.huertos.dto.view.VRequestsWithPreUsersDto;
|
||||
import net.miarma.backend.huertos.model.view.VRequestsWithPreUsers;
|
||||
|
||||
public class VRequestsWithPreUsersMapper {
|
||||
|
||||
public static VRequestsWithPreUsersDto toDto(VRequestsWithPreUsers entity) {
|
||||
VRequestsWithPreUsersDto dto = new VRequestsWithPreUsersDto();
|
||||
dto.setRequestId(entity.getRequestId());
|
||||
dto.setRequestType(entity.getRequestType());
|
||||
dto.setRequestStatus(entity.getRequestStatus());
|
||||
dto.setRequestedBy(entity.getRequestedBy());
|
||||
dto.setRequestedByName(entity.getRequestedByName());
|
||||
dto.setTargetUserId(entity.getTargetUserId());
|
||||
dto.setRequestCreatedAt(entity.getRequestCreatedAt());
|
||||
|
||||
dto.setPreUserId(entity.getPreUserId());
|
||||
dto.setPreUserName(entity.getPreUserName());
|
||||
dto.setPreDisplayName(entity.getPreDisplayName());
|
||||
dto.setPreDni(entity.getPreDni());
|
||||
dto.setPrePhone(entity.getPrePhone());
|
||||
dto.setPreEmail(entity.getPreEmail());
|
||||
dto.setPreAddress(entity.getPreAddress());
|
||||
dto.setPreZipCode(entity.getPreZipCode());
|
||||
dto.setPreCity(entity.getPreCity());
|
||||
dto.setPreMemberNumber(entity.getPreMemberNumber());
|
||||
dto.setPrePlotNumber(entity.getPrePlotNumber());
|
||||
dto.setPreType(entity.getPreType());
|
||||
dto.setPreRole(entity.getPreRole());
|
||||
dto.setPreCreatedAt(entity.getPreCreatedAt());
|
||||
|
||||
return dto;
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,9 @@ import net.miarma.backend.huertos.model.view.VHuertosMember;
|
||||
import org.springframework.data.repository.Repository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface VHuertosMemberRepository extends Repository<VHuertosMember, byte[]> {
|
||||
List<VHuertosMemberRepository> findAll();
|
||||
List<VHuertosMember> findAll();
|
||||
Optional<VHuertosMember> findById(byte[] userId);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,9 @@ import net.miarma.backend.huertos.model.view.VIncomesWithFullNames;
|
||||
import org.springframework.data.repository.Repository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface VIncomesWithFullNamesRepository extends Repository<VIncomesWithFullNames, byte[]> {
|
||||
List<VIncomesWithFullNamesRepository> findAll();
|
||||
List<VIncomesWithFullNames> findAll();
|
||||
Optional<VIncomesWithFullNames> findById(byte[] incomeId);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,9 @@ import net.miarma.backend.huertos.model.view.VRequestsWithPreUsers;
|
||||
import org.springframework.data.repository.Repository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface VRequestsWithPreUsersRepository extends Repository<VRequestsWithPreUsers, byte[]> {
|
||||
List<VRequestsWithPreUsersRepository> findAll();
|
||||
List<VRequestsWithPreUsers> findAll();
|
||||
Optional<VRequestsWithPreUsers> findById(byte[] requestId);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
package net.miarma.backend.huertos.security;
|
||||
|
||||
import jakarta.servlet.FilterChain;
|
||||
import jakarta.servlet.ServletException;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import net.miarma.backend.huertos.model.view.VHuertosMember;
|
||||
import net.miarma.backend.huertos.service.view.VHuertosMemberService;
|
||||
import net.miarma.backlib.security.JwtService;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.filter.OncePerRequestFilter;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
|
||||
@Component
|
||||
public class HuertosJwtFilter extends OncePerRequestFilter {
|
||||
|
||||
private final JwtService jwtService;
|
||||
private final VHuertosMemberService huertosUserService;
|
||||
|
||||
public HuertosJwtFilter(JwtService jwtService, VHuertosMemberService huertosUserService) {
|
||||
this.jwtService = jwtService;
|
||||
this.huertosUserService = huertosUserService;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doFilterInternal(HttpServletRequest request,
|
||||
HttpServletResponse response,
|
||||
FilterChain filterChain) throws ServletException, IOException {
|
||||
|
||||
String authHeader = request.getHeader("Authorization");
|
||||
if (authHeader != null && authHeader.startsWith("Bearer ")) {
|
||||
String token = authHeader.substring(7);
|
||||
|
||||
if (jwtService.validateToken(token)) {
|
||||
UUID userId = jwtService.getUserId(token);
|
||||
|
||||
VHuertosMember huertosUser = huertosUserService.getById(userId);
|
||||
|
||||
if (huertosUser != null) {
|
||||
var principal = new HuertosPrincipal(
|
||||
userId,
|
||||
huertosUser.getRole(),
|
||||
huertosUser.getType()
|
||||
);
|
||||
|
||||
var auth = new UsernamePasswordAuthenticationToken(
|
||||
principal, null, principal.getAuthorities()
|
||||
);
|
||||
|
||||
SecurityContextHolder.getContext().setAuthentication(auth);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
filterChain.doFilter(request, response);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package net.miarma.backend.huertos.security;
|
||||
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class HuertosPrincipal implements UserDetails {
|
||||
|
||||
private final UUID userId;
|
||||
private final Byte role;
|
||||
private final Byte type;
|
||||
|
||||
public HuertosPrincipal(UUID userId, Byte role, Byte type) {
|
||||
this.userId = userId;
|
||||
this.role = role;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public UUID getUserId() { return userId; }
|
||||
public Byte getHuertosRole() { return role; }
|
||||
public Byte getHuertosType() { return type; }
|
||||
|
||||
@Override
|
||||
public Collection<? extends GrantedAuthority> getAuthorities() {
|
||||
List<GrantedAuthority> auth = new ArrayList<>();
|
||||
|
||||
String roleName = switch(role) {
|
||||
case 0 -> "USER";
|
||||
case 1 -> "ADMIN";
|
||||
case 2 -> "DEV";
|
||||
default -> "USER";
|
||||
};
|
||||
|
||||
String typeName = switch(type) {
|
||||
case 0 -> "WAIT_LIST";
|
||||
case 1 -> "MEMBER";
|
||||
case 2 -> "WITH_GREENHOUSE";
|
||||
case 3 -> "COLLABORATOR";
|
||||
case 4 -> "SUBSIDY";
|
||||
case 5 -> "DEVELOPER";
|
||||
default -> "WAIT_LIST";
|
||||
};
|
||||
|
||||
auth.add(new SimpleGrantedAuthority("ROLE_HUERTOS_ROLE_" + roleName));
|
||||
auth.add(new SimpleGrantedAuthority("ROLE_HUERTOS_TYPE_" + typeName));
|
||||
|
||||
return auth;
|
||||
}
|
||||
|
||||
@Override public String getPassword() { return ""; }
|
||||
@Override public String getUsername() { return userId.toString(); }
|
||||
@Override public boolean isAccountNonExpired() { return true; }
|
||||
@Override public boolean isAccountNonLocked() { return true; }
|
||||
@Override public boolean isCredentialsNonExpired() { return true; }
|
||||
@Override public boolean isEnabled() { return true; }
|
||||
}
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
package net.miarma.backend.huertos.service;
|
||||
|
||||
import jakarta.transaction.Transactional;
|
||||
import net.miarma.backend.huertos.model.Announcement;
|
||||
import net.miarma.backend.huertos.repository.AnnouncementRepository;
|
||||
import net.miarma.backlib.util.UuidUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@Service
|
||||
@Transactional
|
||||
public class AnnouncementService {
|
||||
|
||||
private final AnnouncementRepository announcementRepository;
|
||||
|
||||
public AnnouncementService(AnnouncementRepository announcementRepository) {
|
||||
this.announcementRepository = announcementRepository;
|
||||
}
|
||||
|
||||
public List<Announcement> getAll() {
|
||||
return announcementRepository.findAll();
|
||||
}
|
||||
|
||||
public Announcement getById(UUID announceId) {
|
||||
byte[] idBytes = UuidUtil.uuidToBin(announceId);
|
||||
return announcementRepository.findById(idBytes)
|
||||
.orElseThrow(() -> new RuntimeException("Announcement not found"));
|
||||
}
|
||||
|
||||
public Announcement create(Announcement announcement) {
|
||||
if (announcement.getAnnounceId() == null) {
|
||||
announcement.setAnnounceId(UUID.randomUUID());
|
||||
}
|
||||
announcement.setCreatedAt(Instant.now());
|
||||
return announcementRepository.save(announcement);
|
||||
}
|
||||
|
||||
public Announcement update(UUID announceId, Announcement dto) {
|
||||
byte[] idBytes = UuidUtil.uuidToBin(announceId);
|
||||
Announcement announcement = announcementRepository.findById(idBytes)
|
||||
.orElseThrow(() -> new RuntimeException("Announcement not found"));
|
||||
|
||||
if (dto.getBody() != null) announcement.setBody(dto.getBody());
|
||||
if (dto.getPriority() != null) announcement.setPriority(dto.getPriority());
|
||||
if (dto.getPublishedBy() != null) announcement.setPublishedBy(dto.getPublishedBy());
|
||||
|
||||
return announcementRepository.save(announcement);
|
||||
}
|
||||
|
||||
public void delete(UUID announceId) {
|
||||
byte[] idBytes = UuidUtil.uuidToBin(announceId);
|
||||
if (!announcementRepository.existsById(idBytes))
|
||||
throw new RuntimeException("Announcement not found");
|
||||
announcementRepository.deleteById(idBytes);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package net.miarma.backend.huertos.service;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import jakarta.transaction.Transactional;
|
||||
import net.miarma.backend.huertos.model.Balance;
|
||||
import net.miarma.backend.huertos.repository.BalanceRepository;
|
||||
|
||||
@Service
|
||||
@Transactional
|
||||
public class BalanceService {
|
||||
|
||||
private final BalanceRepository repo;
|
||||
|
||||
public BalanceService(BalanceRepository repo) {
|
||||
this.repo = repo;
|
||||
}
|
||||
|
||||
public Balance get() {
|
||||
return repo.findById((byte) 1)
|
||||
.orElseThrow(() -> new RuntimeException("Balance not found"));
|
||||
}
|
||||
|
||||
public Balance create(Balance balance) {
|
||||
if (repo.existsById((byte) 1)) {
|
||||
throw new RuntimeException("Balance already exists");
|
||||
}
|
||||
balance.setId((byte) 1);
|
||||
balance.setCreatedAt(Instant.now());
|
||||
return repo.save(balance);
|
||||
}
|
||||
|
||||
public Balance update(Balance dto) {
|
||||
Balance balance = repo.findById((byte) 1)
|
||||
.orElseThrow(() -> new RuntimeException("Balance not found"));
|
||||
|
||||
if (dto.getInitialBank() != null) balance.setInitialBank(dto.getInitialBank());
|
||||
if (dto.getInitialCash() != null) balance.setInitialCash(dto.getInitialCash());
|
||||
|
||||
return repo.save(balance);
|
||||
}
|
||||
|
||||
public void delete() {
|
||||
if (!repo.existsById((byte) 1)) {
|
||||
throw new RuntimeException("Balance not found");
|
||||
}
|
||||
repo.deleteById((byte) 1);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package net.miarma.backend.huertos.service;
|
||||
|
||||
import jakarta.transaction.Transactional;
|
||||
import net.miarma.backend.huertos.model.Expense;
|
||||
import net.miarma.backend.huertos.repository.ExpenseRepository;
|
||||
import net.miarma.backlib.util.UuidUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@Service
|
||||
@Transactional
|
||||
public class ExpenseService {
|
||||
|
||||
private final ExpenseRepository expenseRepository;
|
||||
|
||||
public ExpenseService(ExpenseRepository expenseRepository) {
|
||||
this.expenseRepository = expenseRepository;
|
||||
}
|
||||
|
||||
public List<Expense> getAll() {
|
||||
return expenseRepository.findAll();
|
||||
}
|
||||
|
||||
public Expense getById(UUID expenseId) {
|
||||
byte[] idBytes = UuidUtil.uuidToBin(expenseId);
|
||||
return expenseRepository.findById(idBytes)
|
||||
.orElseThrow(() -> new RuntimeException("Expense not found"));
|
||||
}
|
||||
|
||||
public Expense create(Expense expense) {
|
||||
if (expense.getConcept() == null || expense.getConcept().isBlank()) {
|
||||
throw new RuntimeException("Concept is required");
|
||||
}
|
||||
if (expense.getAmount() == null) {
|
||||
throw new RuntimeException("Amount is required");
|
||||
}
|
||||
if (expense.getSupplier() == null || expense.getSupplier().isBlank()) {
|
||||
throw new RuntimeException("Supplier is required");
|
||||
}
|
||||
if (expense.getInvoice() == null || expense.getInvoice().isBlank()) {
|
||||
throw new RuntimeException("Invoice is required");
|
||||
}
|
||||
|
||||
expense.setExpenseId(UUID.randomUUID());
|
||||
expense.setCreatedAt(Instant.now());
|
||||
|
||||
return expenseRepository.save(expense);
|
||||
}
|
||||
|
||||
public Expense update(UUID expenseId, Expense dto) {
|
||||
byte[] idBytes = UuidUtil.uuidToBin(expenseId);
|
||||
Expense expense = expenseRepository.findById(idBytes)
|
||||
.orElseThrow(() -> new RuntimeException("Expense not found"));
|
||||
|
||||
if (dto.getConcept() != null) expense.setConcept(dto.getConcept());
|
||||
if (dto.getAmount() != null) expense.setAmount(dto.getAmount());
|
||||
if (dto.getSupplier() != null) expense.setSupplier(dto.getSupplier());
|
||||
if (dto.getInvoice() != null) expense.setInvoice(dto.getInvoice());
|
||||
if (dto.getType() != null) expense.setType(dto.getType());
|
||||
|
||||
return expenseRepository.save(expense);
|
||||
}
|
||||
|
||||
public void delete(UUID expenseId) {
|
||||
byte[] idBytes = UuidUtil.uuidToBin(expenseId);
|
||||
if (!expenseRepository.existsById(idBytes)) {
|
||||
throw new RuntimeException("Expense not found");
|
||||
}
|
||||
expenseRepository.deleteById(idBytes);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package net.miarma.backend.huertos.service;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import jakarta.transaction.Transactional;
|
||||
import net.miarma.backend.huertos.model.HuertosUserMetadata;
|
||||
import net.miarma.backend.huertos.repository.HuertosUserMetadataRepository;
|
||||
import net.miarma.backlib.util.UuidUtil;
|
||||
|
||||
@Service
|
||||
@Transactional
|
||||
public class HuertosUserMetadataService {
|
||||
|
||||
private final HuertosUserMetadataRepository repository;
|
||||
|
||||
public HuertosUserMetadataService(HuertosUserMetadataRepository repository) {
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
public List<HuertosUserMetadata> getAll() {
|
||||
return repository.findAll();
|
||||
}
|
||||
|
||||
public HuertosUserMetadata getById(UUID userId) {
|
||||
byte[] idBytes = UuidUtil.uuidToBin(userId);
|
||||
return repository.findById(idBytes)
|
||||
.orElseThrow(() -> new RuntimeException("User metadata not found"));
|
||||
}
|
||||
|
||||
public HuertosUserMetadata create(HuertosUserMetadata meta) {
|
||||
if (meta.getUserId() == null) {
|
||||
throw new RuntimeException("userId is required");
|
||||
}
|
||||
if (repository.existsById(UuidUtil.uuidToBin(meta.getUserId()))) {
|
||||
throw new RuntimeException("Metadata already exists for this user");
|
||||
}
|
||||
|
||||
if (meta.getMemberNumber() == null) throw new RuntimeException("memberNumber required");
|
||||
if (meta.getPlotNumber() == null) throw new RuntimeException("plotNumber required");
|
||||
if (meta.getDni() == null || meta.getDni().isBlank()) throw new RuntimeException("dni required");
|
||||
if (meta.getPhone() == null || meta.getPhone().isBlank()) throw new RuntimeException("phone required");
|
||||
if (meta.getType() == null) meta.setType((byte) 0);
|
||||
if (meta.getRole() == null) meta.setRole((byte) 0);
|
||||
|
||||
meta.setCreatedAt(Instant.now());
|
||||
meta.setAssignedAt(null);
|
||||
meta.setDeactivatedAt(null);
|
||||
|
||||
return repository.save(meta);
|
||||
}
|
||||
|
||||
public HuertosUserMetadata update(UUID userId, HuertosUserMetadata dto) {
|
||||
byte[] idBytes = UuidUtil.uuidToBin(userId);
|
||||
|
||||
HuertosUserMetadata meta = repository.findById(idBytes)
|
||||
.orElseThrow(() -> new RuntimeException("User metadata not found"));
|
||||
|
||||
if (dto.getMemberNumber() != null) meta.setMemberNumber(dto.getMemberNumber());
|
||||
if (dto.getPlotNumber() != null) meta.setPlotNumber(dto.getPlotNumber());
|
||||
if (dto.getDni() != null) meta.setDni(dto.getDni());
|
||||
if (dto.getPhone() != null) meta.setPhone(dto.getPhone());
|
||||
if (dto.getType() != null) meta.setType(dto.getType());
|
||||
if (dto.getRole() != null) meta.setRole(dto.getRole());
|
||||
if (dto.getNotes() != null) meta.setNotes(dto.getNotes());
|
||||
if (dto.getAssignedAt() != null) meta.setAssignedAt(dto.getAssignedAt());
|
||||
if (dto.getDeactivatedAt() != null) meta.setDeactivatedAt(dto.getDeactivatedAt());
|
||||
|
||||
return repository.save(meta);
|
||||
}
|
||||
|
||||
public void delete(UUID userId) {
|
||||
byte[] idBytes = UuidUtil.uuidToBin(userId);
|
||||
if (!repository.existsById(idBytes)) {
|
||||
throw new RuntimeException("User metadata not found");
|
||||
}
|
||||
repository.deleteById(idBytes);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
package net.miarma.backend.huertos.service;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import jakarta.transaction.Transactional;
|
||||
import net.miarma.backend.huertos.model.Income;
|
||||
import net.miarma.backend.huertos.repository.IncomeRepository;
|
||||
import net.miarma.backlib.util.UuidUtil;
|
||||
|
||||
@Service
|
||||
@Transactional
|
||||
public class IncomeService {
|
||||
|
||||
private final IncomeRepository repository;
|
||||
|
||||
public IncomeService(IncomeRepository repository) {
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
public List<Income> getAll() {
|
||||
return repository.findAll();
|
||||
}
|
||||
|
||||
public Income getById(UUID incomeId) {
|
||||
byte[] idBytes = UuidUtil.uuidToBin(incomeId);
|
||||
return repository.findById(idBytes)
|
||||
.orElseThrow(() -> new RuntimeException("Income not found"));
|
||||
}
|
||||
|
||||
public List<Income> getByUserId(UUID userId) {
|
||||
byte[] idBytes = UuidUtil.uuidToBin(userId);
|
||||
return repository.findAll().stream()
|
||||
.filter(i -> i.getUserId().equals(userId))
|
||||
.toList();
|
||||
}
|
||||
|
||||
public Income create(Income income) {
|
||||
if (income.getUserId() == null) {
|
||||
throw new RuntimeException("userId is required");
|
||||
}
|
||||
if (income.getConcept() == null || income.getConcept().isBlank()) {
|
||||
throw new RuntimeException("concept is required");
|
||||
}
|
||||
if (income.getAmount() == null || income.getAmount().signum() <= 0) {
|
||||
throw new RuntimeException("amount must be positive");
|
||||
}
|
||||
|
||||
income.setIncomeId(UUID.randomUUID());
|
||||
income.setCreatedAt(Instant.now());
|
||||
|
||||
return repository.save(income);
|
||||
}
|
||||
|
||||
public Income update(UUID incomeId, Income dto) {
|
||||
byte[] idBytes = UuidUtil.uuidToBin(incomeId);
|
||||
|
||||
Income income = repository.findById(idBytes)
|
||||
.orElseThrow(() -> new RuntimeException("Income not found"));
|
||||
|
||||
if (dto.getConcept() != null) income.setConcept(dto.getConcept());
|
||||
if (dto.getAmount() != null) {
|
||||
if (dto.getAmount().signum() <= 0) {
|
||||
throw new RuntimeException("amount must be positive");
|
||||
}
|
||||
income.setAmount(dto.getAmount());
|
||||
}
|
||||
if (dto.getType() != null) income.setType(dto.getType());
|
||||
if (dto.getFrequency() != null) income.setFrequency(dto.getFrequency());
|
||||
|
||||
return repository.save(income);
|
||||
}
|
||||
|
||||
public void delete(UUID incomeId) {
|
||||
byte[] idBytes = UuidUtil.uuidToBin(incomeId);
|
||||
|
||||
if (!repository.existsById(idBytes)) {
|
||||
throw new RuntimeException("Income not found");
|
||||
}
|
||||
|
||||
repository.deleteById(idBytes);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
package net.miarma.backend.huertos.service;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import jakarta.transaction.Transactional;
|
||||
import net.miarma.backend.huertos.model.PreUser;
|
||||
import net.miarma.backend.huertos.repository.PreUserRepository;
|
||||
import net.miarma.backlib.util.UuidUtil;
|
||||
|
||||
@Service
|
||||
@Transactional
|
||||
public class PreUserService {
|
||||
|
||||
private final PreUserRepository repository;
|
||||
|
||||
public PreUserService(PreUserRepository repository) {
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
public List<PreUser> getAll() {
|
||||
return repository.findAll();
|
||||
}
|
||||
|
||||
public PreUser getById(UUID preUserId) {
|
||||
byte[] idBytes = UuidUtil.uuidToBin(preUserId);
|
||||
return repository.findById(idBytes)
|
||||
.orElseThrow(() -> new RuntimeException("PreUser not found"));
|
||||
}
|
||||
|
||||
public List<PreUser> getByRequestId(UUID requestId) {
|
||||
byte[] idBytes = UuidUtil.uuidToBin(requestId);
|
||||
|
||||
return repository.findAll().stream()
|
||||
.filter(p -> p.getRequestId() != null && p.getRequestId().equals(requestId))
|
||||
.toList();
|
||||
}
|
||||
|
||||
public PreUser create(PreUser preUser) {
|
||||
if (preUser.getRequestId() == null) {
|
||||
throw new RuntimeException("requestId is required");
|
||||
}
|
||||
if (preUser.getUserName() == null || preUser.getUserName().isBlank()) {
|
||||
throw new RuntimeException("userName is required");
|
||||
}
|
||||
if (preUser.getDisplayName() == null || preUser.getDisplayName().isBlank()) {
|
||||
throw new RuntimeException("displayName is required");
|
||||
}
|
||||
if (preUser.getDni() == null || preUser.getDni().isBlank()) {
|
||||
throw new RuntimeException("dni is required");
|
||||
}
|
||||
if (preUser.getPhone() == null || preUser.getPhone().isBlank()) {
|
||||
throw new RuntimeException("phone is required");
|
||||
}
|
||||
if (preUser.getEmail() == null || preUser.getEmail().isBlank()) {
|
||||
throw new RuntimeException("email is required");
|
||||
}
|
||||
|
||||
preUser.setPreUserId(UUID.randomUUID());
|
||||
preUser.setCreatedAt(Instant.now());
|
||||
|
||||
return repository.save(preUser);
|
||||
}
|
||||
|
||||
public PreUser update(UUID preUserId, PreUser dto) {
|
||||
byte[] idBytes = UuidUtil.uuidToBin(preUserId);
|
||||
|
||||
PreUser preUser = repository.findById(idBytes)
|
||||
.orElseThrow(() -> new RuntimeException("PreUser not found"));
|
||||
|
||||
if (dto.getUserName() != null) preUser.setUserName(dto.getUserName());
|
||||
if (dto.getDisplayName() != null) preUser.setDisplayName(dto.getDisplayName());
|
||||
if (dto.getDni() != null) preUser.setDni(dto.getDni());
|
||||
if (dto.getPhone() != null) preUser.setPhone(dto.getPhone());
|
||||
if (dto.getEmail() != null) preUser.setEmail(dto.getEmail());
|
||||
if (dto.getPassword() != null) preUser.setPassword(dto.getPassword());
|
||||
if (dto.getAddress() != null) preUser.setAddress(dto.getAddress());
|
||||
if (dto.getZipCode() != null) preUser.setZipCode(dto.getZipCode());
|
||||
if (dto.getCity() != null) preUser.setCity(dto.getCity());
|
||||
if (dto.getMemberNumber() != null) preUser.setMemberNumber(dto.getMemberNumber());
|
||||
if (dto.getPlotNumber() != null) preUser.setPlotNumber(dto.getPlotNumber());
|
||||
if (dto.getType() != null) preUser.setType(dto.getType());
|
||||
if (dto.getRole() != null) preUser.setRole(dto.getRole());
|
||||
|
||||
return repository.save(preUser);
|
||||
}
|
||||
|
||||
public void delete(UUID preUserId) {
|
||||
byte[] idBytes = UuidUtil.uuidToBin(preUserId);
|
||||
|
||||
if (!repository.existsById(idBytes)) {
|
||||
throw new RuntimeException("PreUser not found");
|
||||
}
|
||||
|
||||
repository.deleteById(idBytes);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
package net.miarma.backend.huertos.service;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import jakarta.transaction.Transactional;
|
||||
import net.miarma.backend.huertos.model.Request;
|
||||
import net.miarma.backend.huertos.repository.RequestRepository;
|
||||
import net.miarma.backlib.util.UuidUtil;
|
||||
|
||||
@Service
|
||||
@Transactional
|
||||
public class RequestService {
|
||||
|
||||
private final RequestRepository repository;
|
||||
|
||||
public RequestService(RequestRepository repository) {
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
public List<Request> getAll() {
|
||||
return repository.findAll();
|
||||
}
|
||||
|
||||
public Request getById(UUID requestId) {
|
||||
byte[] idBytes = UuidUtil.uuidToBin(requestId);
|
||||
return repository.findById(idBytes)
|
||||
.orElseThrow(() -> new RuntimeException("Request not found"));
|
||||
}
|
||||
|
||||
public List<Request> getByRequestedBy(UUID requestedBy) {
|
||||
return repository.findAll().stream()
|
||||
.filter(r -> r.getRequestedBy() != null && r.getRequestedBy().equals(requestedBy))
|
||||
.toList();
|
||||
}
|
||||
|
||||
public List<Request> getByTargetUserId(UUID targetUserId) {
|
||||
return repository.findAll().stream()
|
||||
.filter(r -> r.getTargetUserId() != null && r.getTargetUserId().equals(targetUserId))
|
||||
.toList();
|
||||
}
|
||||
|
||||
public Request create(Request request) {
|
||||
if (request.getType() == null) {
|
||||
throw new RuntimeException("type is required");
|
||||
}
|
||||
if (request.getStatus() == null) {
|
||||
throw new RuntimeException("status is required");
|
||||
}
|
||||
if (request.getRequestedBy() == null) {
|
||||
throw new RuntimeException("requestedBy is required");
|
||||
}
|
||||
|
||||
request.setRequestId(UUID.randomUUID());
|
||||
request.setCreatedAt(Instant.now());
|
||||
|
||||
return repository.save(request);
|
||||
}
|
||||
|
||||
public Request update(UUID requestId, Request dto) {
|
||||
byte[] idBytes = UuidUtil.uuidToBin(requestId);
|
||||
|
||||
Request request = repository.findById(idBytes)
|
||||
.orElseThrow(() -> new RuntimeException("Request not found"));
|
||||
|
||||
if (dto.getType() != null) request.setType(dto.getType());
|
||||
if (dto.getStatus() != null) request.setStatus(dto.getStatus());
|
||||
if (dto.getRequestedBy() != null) request.setRequestedBy(dto.getRequestedBy());
|
||||
if (dto.getTargetUserId() != null) request.setTargetUserId(dto.getTargetUserId());
|
||||
|
||||
return repository.save(request);
|
||||
}
|
||||
|
||||
public void delete(UUID requestId) {
|
||||
byte[] idBytes = UuidUtil.uuidToBin(requestId);
|
||||
|
||||
if (!repository.existsById(idBytes)) {
|
||||
throw new RuntimeException("Request not found");
|
||||
}
|
||||
|
||||
repository.deleteById(idBytes);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package net.miarma.backend.huertos.service.view;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import jakarta.transaction.Transactional;
|
||||
import net.miarma.backend.huertos.model.view.VBalanceWithTotals;
|
||||
import net.miarma.backend.huertos.repository.view.VBalanceWithTotalsRepository;
|
||||
|
||||
@Service
|
||||
@Transactional
|
||||
public class VBalanceWithTotalsService {
|
||||
|
||||
private final VBalanceWithTotalsRepository repository;
|
||||
|
||||
public VBalanceWithTotalsService(VBalanceWithTotalsRepository repository) {
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
public List<VBalanceWithTotals> getAll() {
|
||||
return repository.findAll();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package net.miarma.backend.huertos.service.view;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import jakarta.transaction.Transactional;
|
||||
import net.miarma.backend.huertos.model.view.VHuertosMember;
|
||||
import net.miarma.backend.huertos.repository.view.VHuertosMemberRepository;
|
||||
import net.miarma.backlib.util.UuidUtil;
|
||||
|
||||
@Service
|
||||
@Transactional
|
||||
public class VHuertosMemberService {
|
||||
|
||||
private final VHuertosMemberRepository repository;
|
||||
|
||||
public VHuertosMemberService(VHuertosMemberRepository repository) {
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
public List<VHuertosMember> getAll() {
|
||||
return repository.findAll();
|
||||
}
|
||||
|
||||
public VHuertosMember getById(UUID userId) {
|
||||
byte[] idBytes = UuidUtil.uuidToBin(userId);
|
||||
return repository.findById(idBytes)
|
||||
.orElseThrow(() -> new RuntimeException("Member not found"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package net.miarma.backend.huertos.service.view;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import jakarta.transaction.Transactional;
|
||||
import net.miarma.backend.huertos.model.view.VIncomesWithFullNames;
|
||||
import net.miarma.backend.huertos.repository.view.VIncomesWithFullNamesRepository;
|
||||
import net.miarma.backlib.util.UuidUtil;
|
||||
|
||||
@Service
|
||||
@Transactional
|
||||
public class VIncomesWithFullNamesService {
|
||||
|
||||
private final VIncomesWithFullNamesRepository repository;
|
||||
|
||||
public VIncomesWithFullNamesService(VIncomesWithFullNamesRepository repository) {
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
public List<VIncomesWithFullNames> getAll() {
|
||||
return repository.findAll();
|
||||
}
|
||||
|
||||
public VIncomesWithFullNames getById(UUID incomeId) {
|
||||
byte[] idBytes = UuidUtil.uuidToBin(incomeId);
|
||||
return repository.findById(idBytes)
|
||||
.orElseThrow(() -> new RuntimeException("Income not found"));
|
||||
}
|
||||
|
||||
public List<VIncomesWithFullNames> getByUserId(UUID userId) {
|
||||
byte[] idBytes = UuidUtil.uuidToBin(userId);
|
||||
return repository.findAll().stream()
|
||||
.filter(i -> i.getUserId().equals(userId))
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package net.miarma.backend.huertos.service.view;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import jakarta.transaction.Transactional;
|
||||
import net.miarma.backend.huertos.model.view.VRequestsWithPreUsers;
|
||||
import net.miarma.backend.huertos.repository.view.VRequestsWithPreUsersRepository;
|
||||
import net.miarma.backlib.util.UuidUtil;
|
||||
|
||||
@Service
|
||||
@Transactional
|
||||
public class VRequestsWithPreUsersService {
|
||||
|
||||
private final VRequestsWithPreUsersRepository repository;
|
||||
|
||||
public VRequestsWithPreUsersService(VRequestsWithPreUsersRepository repository) {
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
public List<VRequestsWithPreUsers> getAll() {
|
||||
return repository.findAll();
|
||||
}
|
||||
|
||||
public VRequestsWithPreUsers getById(UUID requestId) {
|
||||
byte[] idBytes = UuidUtil.uuidToBin(requestId);
|
||||
return repository.findById(idBytes)
|
||||
.orElseThrow(() -> new RuntimeException("Request not found"));
|
||||
}
|
||||
|
||||
public List<VRequestsWithPreUsers> getByRequestType(Byte type) {
|
||||
return repository.findAll().stream()
|
||||
.filter(r -> r.getRequestType().equals(type))
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user