Add: all of Huertos but controllers (jwt verification, MSR model, etc). Add: RS256 to global JWT handling
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -24,3 +24,4 @@
|
|||||||
hs_err_pid*
|
hs_err_pid*
|
||||||
replay_pid*
|
replay_pid*
|
||||||
|
|
||||||
|
core/.rsa/
|
||||||
|
|||||||
1
.idea/compiler.xml
generated
1
.idea/compiler.xml
generated
@@ -14,5 +14,6 @@
|
|||||||
<module name="mpaste" />
|
<module name="mpaste" />
|
||||||
</profile>
|
</profile>
|
||||||
</annotationProcessing>
|
</annotationProcessing>
|
||||||
|
<bytecodeTargetLevel target="25" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
@@ -8,5 +8,5 @@
|
|||||||
</list>
|
</list>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" project-jdk-name="25" project-jdk-type="JavaSDK" />
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_25" project-jdk-name="25 (3)" project-jdk-type="JavaSDK" />
|
||||||
</project>
|
</project>
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
eclipse.preferences.version=1
|
|
||||||
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
|
|
||||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=25
|
|
||||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
|
||||||
org.eclipse.jdt.core.compiler.compliance=25
|
|
||||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
|
||||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
|
||||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
|
||||||
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
|
|
||||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
|
||||||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
|
|
||||||
org.eclipse.jdt.core.compiler.release=enabled
|
|
||||||
org.eclipse.jdt.core.compiler.source=25
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
activeProfiles=
|
|
||||||
eclipse.preferences.version=1
|
|
||||||
resolveWorkspaceProjects=true
|
|
||||||
version=1
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
eclipse.preferences.version=1
|
|
||||||
org.eclipse.jdt.apt.aptEnabled=false
|
|
||||||
@@ -1,9 +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.processAnnotations=disabled
|
|
||||||
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
|
|
||||||
@@ -9,11 +9,74 @@
|
|||||||
</parent>
|
</parent>
|
||||||
<artifactId>backlib</artifactId>
|
<artifactId>backlib</artifactId>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>25</maven.compiler.source>
|
||||||
|
<maven.compiler.target>25</maven.compiler.target>
|
||||||
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<!-- Spring Boot -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-security</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mariadb.jdbc</groupId>
|
||||||
|
<artifactId>mariadb-java-client</artifactId>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>jakarta.validation</groupId>
|
<groupId>jakarta.validation</groupId>
|
||||||
<artifactId>jakarta.validation-api</artifactId>
|
<artifactId>jakarta.validation-api</artifactId>
|
||||||
<version>3.1.1</version>
|
<version>3.1.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.hibernate.validator</groupId>
|
||||||
|
<artifactId>hibernate-validator</artifactId>
|
||||||
|
<version>8.0.0.Final</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<version>1.18.42</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-webflux</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- JWT -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.jsonwebtoken</groupId>
|
||||||
|
<artifactId>jjwt-api</artifactId>
|
||||||
|
<version>0.11.5</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.jsonwebtoken</groupId>
|
||||||
|
<artifactId>jjwt-impl</artifactId>
|
||||||
|
<version>0.11.5</version>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.jsonwebtoken</groupId>
|
||||||
|
<artifactId>jjwt-jackson</artifactId>
|
||||||
|
<version>0.11.5</version>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.miarma</groupId>
|
||||||
|
<artifactId>backlib</artifactId>
|
||||||
|
<version>1.0.0</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package net.miarma.backlib.config;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.security.authentication.AuthenticationManager;
|
||||||
|
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
|
||||||
|
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||||
|
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||||
|
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class SecurityCommonConfig {
|
||||||
|
@Bean
|
||||||
|
public AuthenticationManager authManager(HttpSecurity http) throws Exception {
|
||||||
|
return http.getSharedObject(AuthenticationManagerBuilder.class)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public PasswordEncoder passwordEncoder() {
|
||||||
|
return new BCryptPasswordEncoder(12);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
package net.miarma.backlib.dto;
|
||||||
|
|
||||||
|
public record ChangeAvatarRequest(String avatar) {}
|
||||||
@@ -4,42 +4,7 @@ import jakarta.validation.constraints.Min;
|
|||||||
import jakarta.validation.constraints.NotBlank;
|
import jakarta.validation.constraints.NotBlank;
|
||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
|
||||||
public class ChangePasswordRequest {
|
public record ChangePasswordRequest(@NotBlank String oldPassword,
|
||||||
|
@NotBlank String newPassword,
|
||||||
@NotBlank
|
@NotBlank Byte serviceId) {}
|
||||||
private String oldPassword;
|
|
||||||
|
|
||||||
@NotBlank
|
|
||||||
private String newPassword;
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Min(0)
|
|
||||||
private Byte serviceId;
|
|
||||||
|
|
||||||
public String getOldPassword() {
|
|
||||||
return oldPassword;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOldPassword(String oldPassword) {
|
|
||||||
this.oldPassword = oldPassword;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getNewPassword() {
|
|
||||||
return newPassword;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setNewPassword(String newPassword) {
|
|
||||||
this.newPassword = newPassword;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Byte getServiceId() {
|
|
||||||
return serviceId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setServiceId(Byte serviceId) {
|
|
||||||
this.serviceId = serviceId;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
package net.miarma.backlib.dto;
|
||||||
|
|
||||||
|
public record ChangeRoleRequest(Byte role) {
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
package net.miarma.backlib.dto;
|
||||||
|
|
||||||
|
public record ChangeStatusRequest(Byte status) {}
|
||||||
@@ -2,36 +2,6 @@ package net.miarma.backlib.dto;
|
|||||||
|
|
||||||
import jakarta.validation.constraints.NotBlank;
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
|
||||||
public class LoginRequest {
|
public record LoginRequest(@NotBlank String username,
|
||||||
@NotBlank
|
@NotBlank String password,
|
||||||
private String username;
|
Byte serviceId) {}
|
||||||
|
|
||||||
@NotBlank
|
|
||||||
private String password;
|
|
||||||
|
|
||||||
private Byte serviceId;
|
|
||||||
|
|
||||||
public String getUsername() {
|
|
||||||
return username;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUsername(String username) {
|
|
||||||
this.username = username;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPassword() {
|
|
||||||
return password;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPassword(String password) {
|
|
||||||
this.password = password;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Byte getServiceId() {
|
|
||||||
return serviceId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setServiceId(Byte serviceId) {
|
|
||||||
this.serviceId = serviceId;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,37 +1,5 @@
|
|||||||
package net.miarma.backlib.dto;
|
package net.miarma.backlib.dto;
|
||||||
|
|
||||||
public class LoginResponse {
|
public record LoginResponse(String token,
|
||||||
private String token;
|
UserDto user,
|
||||||
private UserDto user;
|
CredentialDto account) {}
|
||||||
private CredentialDto account;
|
|
||||||
|
|
||||||
public LoginResponse(String token, UserDto user, CredentialDto account) {
|
|
||||||
this.token = token;
|
|
||||||
this.user = user;
|
|
||||||
this.account = account;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getToken() {
|
|
||||||
return token;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setToken(String token) {
|
|
||||||
this.token = token;
|
|
||||||
}
|
|
||||||
|
|
||||||
public UserDto getUser() {
|
|
||||||
return user;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUser(UserDto user) {
|
|
||||||
this.user = user;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CredentialDto getAccount() {
|
|
||||||
return account;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAccount(CredentialDto account) {
|
|
||||||
this.account = account;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,41 +1,9 @@
|
|||||||
package net.miarma.backlib.dto;
|
package net.miarma.backlib.dto;
|
||||||
|
|
||||||
public class RegisterRequest {
|
import jakarta.validation.constraints.NotBlank;
|
||||||
private String username;
|
|
||||||
private String email;
|
|
||||||
private String password;
|
|
||||||
private String displayName;
|
|
||||||
private Byte serviceId;
|
|
||||||
public String getUsername() {
|
|
||||||
return username;
|
|
||||||
}
|
|
||||||
public void setUsername(String username) {
|
|
||||||
this.username = username;
|
|
||||||
}
|
|
||||||
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 getDisplayName() {
|
|
||||||
return displayName;
|
|
||||||
}
|
|
||||||
public void setDisplayName(String displayName) {
|
|
||||||
this.displayName = displayName;
|
|
||||||
}
|
|
||||||
public Byte getServiceId() {
|
|
||||||
return serviceId;
|
|
||||||
}
|
|
||||||
public void setServiceId(Byte serviceId) {
|
|
||||||
this.serviceId = serviceId;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
public record RegisterRequest(@NotBlank String username,
|
||||||
}
|
String email,
|
||||||
|
@NotBlank String password,
|
||||||
|
@NotBlank String displayName,
|
||||||
|
Byte serviceId) {}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
package net.miarma.backlib.dto;
|
||||||
|
|
||||||
|
public record UserExistsResponse(boolean exists) {
|
||||||
|
}
|
||||||
@@ -0,0 +1,105 @@
|
|||||||
|
package net.miarma.backlib.security;
|
||||||
|
|
||||||
|
import io.jsonwebtoken.*;
|
||||||
|
import jakarta.annotation.PostConstruct;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.security.KeyFactory;
|
||||||
|
import java.security.PrivateKey;
|
||||||
|
import java.security.PublicKey;
|
||||||
|
import java.security.spec.PKCS8EncodedKeySpec;
|
||||||
|
import java.security.spec.X509EncodedKeySpec;
|
||||||
|
import java.util.Base64;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class JwtService {
|
||||||
|
|
||||||
|
@Value("${jwt.private-key-path}")
|
||||||
|
private String privateKeyPath;
|
||||||
|
|
||||||
|
@Value("${jwt.public-key-path}")
|
||||||
|
private String publicKeyPath;
|
||||||
|
|
||||||
|
@Value("${jwt.expiration-ms}")
|
||||||
|
private long expiration;
|
||||||
|
|
||||||
|
private PrivateKey privateKey;
|
||||||
|
private PublicKey publicKey;
|
||||||
|
|
||||||
|
@PostConstruct
|
||||||
|
public void init() throws Exception {
|
||||||
|
System.out.println("user.name = " + System.getProperty("user.name"));
|
||||||
|
System.out.println("user.home = " + System.getProperty("user.home"));
|
||||||
|
System.out.println("privateKeyPath = " + privateKeyPath);
|
||||||
|
|
||||||
|
this.privateKey = loadPrivateKey(privateKeyPath);
|
||||||
|
this.publicKey = loadPublicKey(publicKeyPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
private PrivateKey loadPrivateKey(String path) throws Exception {
|
||||||
|
String pem = Files.readString(Path.of(path));
|
||||||
|
pem = pem.replace("-----BEGIN PRIVATE KEY-----", "")
|
||||||
|
.replace("-----END PRIVATE KEY-----", "")
|
||||||
|
.replaceAll("\\s", "");
|
||||||
|
|
||||||
|
byte[] decoded = Base64.getDecoder().decode(pem);
|
||||||
|
PKCS8EncodedKeySpec spec = new PKCS8EncodedKeySpec(decoded);
|
||||||
|
KeyFactory kf = KeyFactory.getInstance("RSA");
|
||||||
|
return kf.generatePrivate(spec);
|
||||||
|
}
|
||||||
|
|
||||||
|
private PublicKey loadPublicKey(String path) throws Exception {
|
||||||
|
String pem = Files.readString(Path.of(path));
|
||||||
|
pem = pem.replace("-----BEGIN PUBLIC KEY-----", "")
|
||||||
|
.replace("-----END PUBLIC KEY-----", "")
|
||||||
|
.replaceAll("\\s", "");
|
||||||
|
|
||||||
|
byte[] decoded = Base64.getDecoder().decode(pem);
|
||||||
|
X509EncodedKeySpec spec = new X509EncodedKeySpec(decoded);
|
||||||
|
KeyFactory kf = KeyFactory.getInstance("RSA");
|
||||||
|
return kf.generatePublic(spec);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String generateToken(UUID userId, Byte serviceId) {
|
||||||
|
Date now = new Date();
|
||||||
|
Date exp = new Date(now.getTime() + expiration);
|
||||||
|
|
||||||
|
return Jwts.builder()
|
||||||
|
.setSubject(userId.toString())
|
||||||
|
.claim("service", serviceId)
|
||||||
|
.setIssuedAt(now)
|
||||||
|
.setExpiration(exp)
|
||||||
|
.signWith(privateKey, SignatureAlgorithm.RS256)
|
||||||
|
.compact();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean validateToken(String token) {
|
||||||
|
try {
|
||||||
|
Jwts.parserBuilder().setSigningKey(publicKey).build().parseClaimsJws(token);
|
||||||
|
return true;
|
||||||
|
} catch (JwtException | IllegalArgumentException e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public UUID getUserId(String token) {
|
||||||
|
Claims claims = Jwts.parserBuilder().setSigningKey(publicKey).build().parseClaimsJws(token).getBody();
|
||||||
|
return UUID.fromString(claims.getSubject());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Byte getServiceId(String token) {
|
||||||
|
Claims claims = Jwts.parserBuilder().setSigningKey(publicKey).build().parseClaimsJws(token).getBody();
|
||||||
|
return ((Number) claims.get("service")).byteValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getExpiration(String token) {
|
||||||
|
Claims claims = Jwts.parserBuilder().setSigningKey(publicKey).build().parseClaimsJws(token).getBody();
|
||||||
|
return claims.getExpiration();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
Manifest-Version: 1.0
|
|
||||||
Build-Jdk-Spec: 21
|
|
||||||
Created-By: Maven Integration for Eclipse
|
|
||||||
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
#Generated by Maven Integration for Eclipse
|
|
||||||
#Sun Jan 18 04:49:28 CET 2026
|
|
||||||
artifactId=backlib
|
|
||||||
groupId=net.miarma
|
|
||||||
m2e.projectLocation=/home/jomaa/git/miarma-backend/backlib
|
|
||||||
m2e.projectName=backlib
|
|
||||||
version=1.0.0
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<parent>
|
|
||||||
<groupId>net.miarma</groupId>
|
|
||||||
<artifactId>backend</artifactId>
|
|
||||||
<version>1.0.0</version>
|
|
||||||
</parent>
|
|
||||||
<artifactId>backlib</artifactId>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>jakarta.validation</groupId>
|
|
||||||
<artifactId>jakarta.validation-api</artifactId>
|
|
||||||
<version>3.1.1</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</project>
|
|
||||||
@@ -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
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
eclipse.preferences.version=1
|
|
||||||
org.eclipse.jdt.apt.aptEnabled=true
|
|
||||||
org.eclipse.jdt.apt.genSrcDir=target/generated-sources/annotations
|
|
||||||
org.eclipse.jdt.apt.genTestSrcDir=target/generated-test-sources/test-annotations
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
eclipse.preferences.version=1
|
|
||||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=25
|
|
||||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
|
||||||
org.eclipse.jdt.core.compiler.compliance=25
|
|
||||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
|
||||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
|
||||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
|
||||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
|
||||||
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
|
|
||||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
|
||||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
|
||||||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
|
|
||||||
org.eclipse.jdt.core.compiler.processAnnotations=enabled
|
|
||||||
org.eclipse.jdt.core.compiler.release=enabled
|
|
||||||
org.eclipse.jdt.core.compiler.source=25
|
|
||||||
@@ -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>
|
</parent>
|
||||||
<artifactId>core</artifactId>
|
<artifactId>core</artifactId>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>25</maven.compiler.source>
|
||||||
|
<maven.compiler.target>25</maven.compiler.target>
|
||||||
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<!-- Spring Boot -->
|
<!-- Spring Boot -->
|
||||||
<dependency>
|
<dependency>
|
||||||
@@ -44,6 +49,10 @@
|
|||||||
<version>1.18.42</version>
|
<version>1.18.42</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-webflux</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- JWT -->
|
<!-- JWT -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package net.miarma.backend.core.config;
|
package net.miarma.backend.core.config;
|
||||||
|
|
||||||
|
import net.miarma.backend.core.security.JwtFilter;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.security.authentication.AuthenticationManager;
|
import org.springframework.security.authentication.AuthenticationManager;
|
||||||
@@ -37,15 +38,4 @@ public class SecurityConfig {
|
|||||||
|
|
||||||
return http.build();
|
return http.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
|
||||||
public AuthenticationManager authManager(HttpSecurity http) throws Exception {
|
|
||||||
return http.getSharedObject(AuthenticationManagerBuilder.class)
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public PasswordEncoder passwordEncoder() {
|
|
||||||
return new BCryptPasswordEncoder(12);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import jakarta.validation.Valid;
|
|||||||
import net.miarma.backend.core.model.Credential;
|
import net.miarma.backend.core.model.Credential;
|
||||||
import net.miarma.backend.core.service.AuthService;
|
import net.miarma.backend.core.service.AuthService;
|
||||||
import net.miarma.backend.core.service.CredentialService;
|
import net.miarma.backend.core.service.CredentialService;
|
||||||
import net.miarma.backend.core.service.JwtService;
|
import net.miarma.backlib.security.JwtService;
|
||||||
import net.miarma.backlib.dto.ChangePasswordRequest;
|
import net.miarma.backlib.dto.ChangePasswordRequest;
|
||||||
import net.miarma.backlib.dto.LoginRequest;
|
import net.miarma.backlib.dto.LoginRequest;
|
||||||
import net.miarma.backlib.dto.LoginResponse;
|
import net.miarma.backlib.dto.LoginResponse;
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ package net.miarma.backend.core.controller;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import net.miarma.backlib.dto.ChangeRoleRequest;
|
||||||
|
import net.miarma.backlib.dto.ChangeStatusRequest;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
@@ -39,26 +41,54 @@ public class CredentialController {
|
|||||||
return ResponseEntity.ok(credentialService.getByUserId(userId));
|
return ResponseEntity.ok(credentialService.getByUserId(userId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/{credentialId}")
|
@GetMapping("/{credential_id}")
|
||||||
@PreAuthorize("hasRole('ADMIN') or @credentialService.isOwner(#credentialId, authentication.principal.userId)")
|
@PreAuthorize("hasRole('ADMIN') or @credentialService.isOwner(#credentialId, authentication.principal.userId)")
|
||||||
public ResponseEntity<Credential> getById(@PathVariable("credentialId") UUID credentialId) {
|
public ResponseEntity<Credential> getById(@PathVariable("credential_id") UUID credentialId) {
|
||||||
return ResponseEntity.ok(credentialService.getById(credentialId));
|
return ResponseEntity.ok(credentialService.getById(credentialId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/{credentialId}")
|
@PutMapping("/{credential_id}")
|
||||||
@PreAuthorize("hasRole('ADMIN') or @credentialService.isOwner(#credentialId, authentication.principal.userId)")
|
@PreAuthorize("hasRole('ADMIN') or @credentialService.isOwner(#credentialId, authentication.principal.userId)")
|
||||||
public ResponseEntity<Credential> update(
|
public ResponseEntity<Credential> update(
|
||||||
@PathVariable("credentialId") UUID credentialId,
|
@PathVariable("credential_id") UUID credentialId,
|
||||||
@RequestBody CredentialDto dto
|
@RequestBody CredentialDto dto
|
||||||
) {
|
) {
|
||||||
dto.setCredentialId(credentialId);
|
dto.setCredentialId(credentialId);
|
||||||
return ResponseEntity.ok(credentialService.update(credentialId, dto));
|
return ResponseEntity.ok(credentialService.update(credentialId, dto));
|
||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/{credentialId}")
|
@DeleteMapping("/{credential_id}")
|
||||||
@PreAuthorize("hasRole('ADMIN') or @credentialService.isOwner(#credentialId, authentication.principal.userId)")
|
@PreAuthorize("hasRole('ADMIN') or @credentialService.isOwner(#credentialId, authentication.principal.userId)")
|
||||||
public ResponseEntity<Void> delete(@PathVariable("credentialId") UUID credentialId) {
|
public ResponseEntity<Void> delete(@PathVariable("credential_id") UUID credentialId) {
|
||||||
credentialService.delete(credentialId);
|
credentialService.delete(credentialId);
|
||||||
return ResponseEntity.noContent().build();
|
return ResponseEntity.noContent().build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/{credential_id}/status")
|
||||||
|
public ResponseEntity<Byte> getStatus(@PathVariable("credential_id") UUID credentialId) {
|
||||||
|
return ResponseEntity.ok(credentialService.getStatus(credentialId));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/{credential_id}/status")
|
||||||
|
public ResponseEntity<Void> updateStatus(
|
||||||
|
@PathVariable("credential_id") UUID credentialId,
|
||||||
|
@RequestBody ChangeStatusRequest req
|
||||||
|
) {
|
||||||
|
credentialService.updateStatus(credentialId, req.status());
|
||||||
|
return ResponseEntity.noContent().build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/{credential_id}/role")
|
||||||
|
public ResponseEntity<Byte> getRole(@PathVariable("credential_id") UUID credentialId) {
|
||||||
|
return ResponseEntity.ok(credentialService.getRole(credentialId));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/{credential_id}/role")
|
||||||
|
public ResponseEntity<Void> updateRole(
|
||||||
|
@PathVariable("credential_id") UUID credentialId,
|
||||||
|
@RequestBody ChangeRoleRequest req
|
||||||
|
) {
|
||||||
|
credentialService.updateRole(credentialId, req.role());
|
||||||
|
return ResponseEntity.noContent().build();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ public class FileController {
|
|||||||
@RequestParam String fileName,
|
@RequestParam String fileName,
|
||||||
@RequestParam String mimeType,
|
@RequestParam String mimeType,
|
||||||
@RequestParam UUID uploadedBy,
|
@RequestParam UUID uploadedBy,
|
||||||
@RequestParam Short context,
|
@RequestParam Byte context,
|
||||||
@RequestPart("file") MultipartFile file
|
@RequestPart("file") MultipartFile file
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
File entity = new File();
|
File entity = new File();
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package net.miarma.backend.core.controller;
|
||||||
|
|
||||||
|
import net.miarma.backend.core.service.ScreenshotService;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/screenshot")
|
||||||
|
public class ScreenshotController {
|
||||||
|
private final ScreenshotService screenshotService;
|
||||||
|
|
||||||
|
public ScreenshotController(ScreenshotService screenshotService) {
|
||||||
|
this.screenshotService = screenshotService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/screenshot")
|
||||||
|
public Mono<ResponseEntity<byte[]>> getScreenshot(@RequestParam String url) {
|
||||||
|
return screenshotService.getScreenshot(url);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,6 +3,10 @@ package net.miarma.backend.core.controller;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import net.miarma.backlib.dto.ChangeRoleRequest;
|
||||||
|
import net.miarma.backlib.dto.ChangeAvatarRequest;
|
||||||
|
import net.miarma.backlib.dto.ChangeStatusRequest;
|
||||||
|
import net.miarma.backlib.dto.UserExistsResponse;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
@@ -16,7 +20,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
|
|
||||||
import net.miarma.backend.core.mapper.UserMapper;
|
import net.miarma.backend.core.mapper.UserMapper;
|
||||||
import net.miarma.backend.core.model.User;
|
import net.miarma.backend.core.model.User;
|
||||||
import net.miarma.backend.core.service.JwtService;
|
import net.miarma.backlib.security.JwtService;
|
||||||
import net.miarma.backend.core.service.UserService;
|
import net.miarma.backend.core.service.UserService;
|
||||||
import net.miarma.backlib.dto.UserDto;
|
import net.miarma.backlib.dto.UserDto;
|
||||||
|
|
||||||
@@ -60,6 +64,45 @@ public class UserController {
|
|||||||
return ResponseEntity.ok(userService.getById(userId).getAvatar());
|
return ResponseEntity.ok(userService.getById(userId).getAvatar());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PutMapping("/{user_id}/avatar")
|
||||||
|
public ResponseEntity<UserDto> updateAvatar(@PathVariable("user_id") UUID userId, @RequestBody ChangeAvatarRequest avatar) {
|
||||||
|
return ResponseEntity.ok(userService.updateAvatar(userId, avatar));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/{user_id}/status")
|
||||||
|
public ResponseEntity<Byte> getStatus(@PathVariable("user_id") UUID userId) {
|
||||||
|
return ResponseEntity.ok(userService.getStatus(userId));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/{user_id}/status")
|
||||||
|
public ResponseEntity<Void> updateStatus(
|
||||||
|
@PathVariable("user_id") UUID userId,
|
||||||
|
@RequestBody ChangeStatusRequest req
|
||||||
|
) {
|
||||||
|
userService.updateStatus(userId, req.status());
|
||||||
|
return ResponseEntity.noContent().build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/{user_id}/role")
|
||||||
|
public ResponseEntity<Byte> getRole(@PathVariable("user_id") UUID userId) {
|
||||||
|
return ResponseEntity.ok(userService.getRole(userId));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/{user_id}/role")
|
||||||
|
public ResponseEntity<Void> updateRole(
|
||||||
|
@PathVariable("user_id") UUID userid,
|
||||||
|
@RequestBody ChangeRoleRequest req
|
||||||
|
) {
|
||||||
|
userService.updateRole(userid, req.role());
|
||||||
|
return ResponseEntity.noContent().build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/{user_id}/exists")
|
||||||
|
public ResponseEntity<UserExistsResponse> exists(@PathVariable("user_id") UUID userId) {
|
||||||
|
boolean exists = userService.exists(userId);
|
||||||
|
return ResponseEntity.ok(new UserExistsResponse(exists));
|
||||||
|
}
|
||||||
|
|
||||||
@GetMapping("/me")
|
@GetMapping("/me")
|
||||||
public ResponseEntity<UserDto> getMe(@RequestHeader("Authorization") String authHeader) {
|
public ResponseEntity<UserDto> getMe(@RequestHeader("Authorization") String authHeader) {
|
||||||
if (authHeader == null || !authHeader.startsWith("Bearer ")) {
|
if (authHeader == null || !authHeader.startsWith("Bearer ")) {
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ public class Credential {
|
|||||||
private String email;
|
private String email;
|
||||||
private String password;
|
private String password;
|
||||||
private Byte status;
|
private Byte status;
|
||||||
|
private Byte role;
|
||||||
|
|
||||||
@CreationTimestamp
|
@CreationTimestamp
|
||||||
private Instant createdAt;
|
private Instant createdAt;
|
||||||
@@ -142,6 +143,10 @@ public class Credential {
|
|||||||
this.status = status;
|
this.status = status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Byte getRole() { return role; }
|
||||||
|
|
||||||
|
public void setRole(Byte role) { this.role = role; }
|
||||||
|
|
||||||
public Instant getCreatedAt() {
|
public Instant getCreatedAt() {
|
||||||
return createdAt;
|
return createdAt;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ public class File {
|
|||||||
private Instant uploadedAt;
|
private Instant uploadedAt;
|
||||||
|
|
||||||
@Column(name = "context", nullable = false)
|
@Column(name = "context", nullable = false)
|
||||||
private Short context;
|
private Byte context;
|
||||||
|
|
||||||
@PrePersist
|
@PrePersist
|
||||||
@PreUpdate
|
@PreUpdate
|
||||||
@@ -112,11 +112,11 @@ public class File {
|
|||||||
return uploadedAt;
|
return uploadedAt;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Short getContext() {
|
public Byte getContext() {
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setContext(Short context) {
|
public void setContext(Byte context) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import net.miarma.backend.core.model.File;
|
|||||||
public interface FileRepository extends JpaRepository<File, byte[]> {
|
public interface FileRepository extends JpaRepository<File, byte[]> {
|
||||||
List<File> findByUploadedBy(UUID uploadedBy);
|
List<File> findByUploadedBy(UUID uploadedBy);
|
||||||
|
|
||||||
List<File> findByContext(short context);
|
List<File> findByContext(Byte context);
|
||||||
|
|
||||||
List<File> findByUploadedByAndContext(UUID uploadedBy, short context);
|
List<File> findByUploadedByAndContext(UUID uploadedBy, Byte context);
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package net.miarma.backend.core.config;
|
package net.miarma.backend.core.security;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -16,7 +16,7 @@ import jakarta.servlet.ServletException;
|
|||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import net.miarma.backend.core.model.User;
|
import net.miarma.backend.core.model.User;
|
||||||
import net.miarma.backend.core.service.JwtService;
|
import net.miarma.backlib.security.JwtService;
|
||||||
import net.miarma.backend.core.service.UserService;
|
import net.miarma.backend.core.service.UserService;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@@ -20,11 +20,11 @@ public class AuthService {
|
|||||||
|
|
||||||
private final CredentialService credentialService;
|
private final CredentialService credentialService;
|
||||||
private final UserService userService;
|
private final UserService userService;
|
||||||
private final JwtService jwtService;
|
private final net.miarma.backlib.security.JwtService jwtService;
|
||||||
private final PasswordEncoder passwordEncoder;
|
private final PasswordEncoder passwordEncoder;
|
||||||
|
|
||||||
public AuthService(CredentialService credentialService, UserService userService,
|
public AuthService(CredentialService credentialService, UserService userService,
|
||||||
JwtService jwtService, PasswordEncoder passwordEncoder) {
|
net.miarma.backlib.security.JwtService jwtService, PasswordEncoder passwordEncoder) {
|
||||||
this.credentialService = credentialService;
|
this.credentialService = credentialService;
|
||||||
this.userService = userService;
|
this.userService = userService;
|
||||||
this.jwtService = jwtService;
|
this.jwtService = jwtService;
|
||||||
@@ -57,7 +57,7 @@ public class AuthService {
|
|||||||
user = credentialService.getByEmail(request.getEmail());
|
user = credentialService.getByEmail(request.getEmail());
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
UserDto dto = new UserDto();
|
UserDto dto = new UserDto();
|
||||||
dto.setUserId(UUID.randomUUID());
|
dto.userId(UUID.randomUUID());
|
||||||
dto.setDisplayName(request.getDisplayName());
|
dto.setDisplayName(request.getDisplayName());
|
||||||
user = userService.create(dto);
|
user = userService.create(dto);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -127,11 +127,11 @@ public class CredentialService {
|
|||||||
Credential cred = credentialRepository.findById(idBytes)
|
Credential cred = credentialRepository.findById(idBytes)
|
||||||
.orElseThrow(() -> new RuntimeException("Credential not found"));
|
.orElseThrow(() -> new RuntimeException("Credential not found"));
|
||||||
|
|
||||||
if (!passwordEncoder.matches(request.getOldPassword(), cred.getPassword())) {
|
if (!passwordEncoder.matches(request.oldPassword(), cred.getPassword())) {
|
||||||
throw new IllegalArgumentException("Old password is incorrect");
|
throw new IllegalArgumentException("Old password is incorrect");
|
||||||
}
|
}
|
||||||
|
|
||||||
cred.setPassword(passwordEncoder.encode(request.getNewPassword()));
|
cred.setPassword(passwordEncoder.encode(request.newPassword()));
|
||||||
return credentialRepository.save(cred);
|
return credentialRepository.save(cred);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -142,4 +142,30 @@ public class CredentialService {
|
|||||||
credentialRepository.deleteById(idBytes);
|
credentialRepository.deleteById(idBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Byte getStatus(UUID credentialId) {
|
||||||
|
Credential credential = credentialRepository.findById(UuidUtil.uuidToBin(credentialId))
|
||||||
|
.orElseThrow(() -> new RuntimeException("User not found"));;
|
||||||
|
return credential.getStatus();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateStatus(UUID credentialId, Byte status) {
|
||||||
|
Credential credential = credentialRepository.findById(UuidUtil.uuidToBin(credentialId))
|
||||||
|
.orElseThrow(() -> new RuntimeException("User not found"));;
|
||||||
|
credential.setStatus(status);
|
||||||
|
credentialRepository.save(credential);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Byte getRole(UUID credentialId) {
|
||||||
|
Credential credential = credentialRepository.findById(UuidUtil.uuidToBin(credentialId))
|
||||||
|
.orElseThrow(() -> new RuntimeException("User not found"));;
|
||||||
|
return credential.getRole();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateRole(UUID credentialId, Byte role) {
|
||||||
|
Credential credential = credentialRepository.findById(UuidUtil.uuidToBin(credentialId))
|
||||||
|
.orElseThrow(() -> new RuntimeException("User not found"));;
|
||||||
|
credential.setRole(role);
|
||||||
|
credentialRepository.save(credential);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ public class FileService {
|
|||||||
return fileRepository.findByUploadedBy(userId);
|
return fileRepository.findByUploadedBy(userId);
|
||||||
}
|
}
|
||||||
if (params.containsKey("context")) {
|
if (params.containsKey("context")) {
|
||||||
short context = Short.parseShort(params.get("context"));
|
Byte context = Byte.parseByte(params.get("context"));
|
||||||
return fileRepository.findByContext(context);
|
return fileRepository.findByContext(context);
|
||||||
}
|
}
|
||||||
return fileRepository.findAll();
|
return fileRepository.findAll();
|
||||||
|
|||||||
@@ -1,56 +0,0 @@
|
|||||||
package net.miarma.backend.core.service;
|
|
||||||
|
|
||||||
import io.jsonwebtoken.*;
|
|
||||||
import io.jsonwebtoken.security.Keys;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import java.security.Key;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
@Service
|
|
||||||
public class JwtService {
|
|
||||||
|
|
||||||
private final String secret = "miarma-esto-es-un-secreto-super-largo-para-jwt-1234567890";
|
|
||||||
private final Key key = Keys.hmacShaKeyFor(secret.getBytes());
|
|
||||||
|
|
||||||
private final long expiration = 3600_000;
|
|
||||||
|
|
||||||
public String generateToken(UUID userId, Byte serviceId) {
|
|
||||||
Date now = new Date();
|
|
||||||
Date exp = new Date(now.getTime() + expiration);
|
|
||||||
|
|
||||||
return Jwts.builder()
|
|
||||||
.setSubject(userId.toString())
|
|
||||||
.claim("service", serviceId)
|
|
||||||
.setIssuedAt(now)
|
|
||||||
.setExpiration(exp)
|
|
||||||
.signWith(key, SignatureAlgorithm.HS256)
|
|
||||||
.compact();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean validateToken(String token) {
|
|
||||||
try {
|
|
||||||
Jwts.parserBuilder().setSigningKey(key).build().parseClaimsJws(token);
|
|
||||||
return true;
|
|
||||||
} catch (JwtException | IllegalArgumentException e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public UUID getUserId(String token) {
|
|
||||||
Claims claims = Jwts.parserBuilder().setSigningKey(key).build().parseClaimsJws(token).getBody();
|
|
||||||
return UUID.fromString(claims.getSubject());
|
|
||||||
}
|
|
||||||
|
|
||||||
public Byte getServiceId(String token) {
|
|
||||||
Claims claims = Jwts.parserBuilder().setSigningKey(key).build().parseClaimsJws(token).getBody();
|
|
||||||
return ((Number) claims.get("service")).byteValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getExpiration(String token) {
|
|
||||||
Claims claims = Jwts.parserBuilder().setSigningKey(key).build().parseClaimsJws(token).getBody();
|
|
||||||
return claims.getExpiration();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package net.miarma.backend.core.service;
|
||||||
|
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.web.reactive.function.client.WebClient;
|
||||||
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
|
import java.net.URLEncoder;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class ScreenshotService {
|
||||||
|
|
||||||
|
private final WebClient webClient;
|
||||||
|
private final String URI = "http://screenshoter:7000";
|
||||||
|
|
||||||
|
public ScreenshotService(WebClient.Builder webClientBuilder) {
|
||||||
|
this.webClient = webClientBuilder.baseUrl(URI).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Mono<ResponseEntity<byte[]>> getScreenshot(String url) {
|
||||||
|
String encodedUrl = URLEncoder.encode(url, StandardCharsets.UTF_8);
|
||||||
|
|
||||||
|
return webClient.get()
|
||||||
|
.uri("/screenshot?url=" + encodedUrl)
|
||||||
|
.retrieve()
|
||||||
|
.toEntity(byte[].class)
|
||||||
|
.map(response -> ResponseEntity
|
||||||
|
.status(response.getStatusCode())
|
||||||
|
.header("Content-Type", "image/png")
|
||||||
|
.body(response.getBody())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,6 +3,8 @@ package net.miarma.backend.core.service;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import net.miarma.backend.core.mapper.UserMapper;
|
||||||
|
import net.miarma.backlib.dto.ChangeAvatarRequest;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import jakarta.transaction.Transactional;
|
import jakarta.transaction.Transactional;
|
||||||
@@ -75,4 +77,43 @@ public class UserService {
|
|||||||
throw new RuntimeException("User not found");
|
throw new RuntimeException("User not found");
|
||||||
userRepository.deleteById(idBytes);
|
userRepository.deleteById(idBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public UserDto updateAvatar(UUID userId, ChangeAvatarRequest req) {
|
||||||
|
User user = userRepository.findById(UuidUtil.uuidToBin(userId))
|
||||||
|
.orElseThrow(() -> new RuntimeException("User not found"));
|
||||||
|
user.setAvatar(req.avatar());
|
||||||
|
userRepository.save(user);
|
||||||
|
return UserMapper.toDto(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Byte getStatus(UUID userId) {
|
||||||
|
User user = userRepository.findById(UuidUtil.uuidToBin(userId))
|
||||||
|
.orElseThrow(() -> new RuntimeException("User not found"));;
|
||||||
|
return user.getGlobalStatus();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateStatus(UUID userId, Byte status) {
|
||||||
|
User user = userRepository.findById(UuidUtil.uuidToBin(userId))
|
||||||
|
.orElseThrow(() -> new RuntimeException("User not found"));;
|
||||||
|
user.setGlobalStatus(status);
|
||||||
|
userRepository.save(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Byte getRole(UUID userId) {
|
||||||
|
User user = userRepository.findById(UuidUtil.uuidToBin(userId))
|
||||||
|
.orElseThrow(() -> new RuntimeException("User not found"));;
|
||||||
|
return user.getGlobalRole();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateRole(UUID userId, Byte role) {
|
||||||
|
User user = userRepository.findById(UuidUtil.uuidToBin(userId))
|
||||||
|
.orElseThrow(() -> new RuntimeException("User not found"));;
|
||||||
|
user.setGlobalRole(role);
|
||||||
|
userRepository.save(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean exists(UUID userId) {
|
||||||
|
return userRepository.existsById(UuidUtil.uuidToBin(userId));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ spring:
|
|||||||
jpa:
|
jpa:
|
||||||
open-in-view: false
|
open-in-view: false
|
||||||
hibernate:
|
hibernate:
|
||||||
ddl-auto: update
|
ddl-auto: validate
|
||||||
properties:
|
properties:
|
||||||
hibernate:
|
hibernate:
|
||||||
format_sql: true
|
format_sql: true
|
||||||
@@ -35,6 +35,11 @@ logging:
|
|||||||
org.hibernate.orm.jdbc.bind: TRACE
|
org.hibernate.orm.jdbc.bind: TRACE
|
||||||
org.springframework.security: INFO
|
org.springframework.security: INFO
|
||||||
|
|
||||||
|
jwt:
|
||||||
|
private-key-path: /home/jomaa/.config/miarma-backend/private.pem
|
||||||
|
public-key-path: /home/jomaa/.config/miarma-backend/public.pem
|
||||||
|
expiration-ms: 3600000
|
||||||
|
|
||||||
management:
|
management:
|
||||||
endpoints:
|
endpoints:
|
||||||
web:
|
web:
|
||||||
|
|||||||
@@ -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>
|
</parent>
|
||||||
<artifactId>huertos</artifactId>
|
<artifactId>huertos</artifactId>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>25</maven.compiler.source>
|
||||||
|
<maven.compiler.target>25</maven.compiler.target>
|
||||||
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<!-- Spring Boot -->
|
<!-- Spring Boot -->
|
||||||
<dependency>
|
<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 org.springframework.data.repository.Repository;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
public interface VHuertosMemberRepository extends Repository<VHuertosMember, byte[]> {
|
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 org.springframework.data.repository.Repository;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
public interface VIncomesWithFullNamesRepository extends Repository<VIncomesWithFullNames, byte[]> {
|
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 org.springframework.data.repository.Repository;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
public interface VRequestsWithPreUsersRepository extends Repository<VRequestsWithPreUsers, byte[]> {
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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>
|
</parent>
|
||||||
<artifactId>minecraft</artifactId>
|
<artifactId>minecraft</artifactId>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>25</maven.compiler.source>
|
||||||
|
<maven.compiler.target>25</maven.compiler.target>
|
||||||
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<!-- Spring Boot -->
|
<!-- Spring Boot -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@@ -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>
|
</parent>
|
||||||
<artifactId>mpaste</artifactId>
|
<artifactId>mpaste</artifactId>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>25</maven.compiler.source>
|
||||||
|
<maven.compiler.target>25</maven.compiler.target>
|
||||||
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<!-- Spring Boot -->
|
<!-- Spring Boot -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
2
pom.xml
2
pom.xml
@@ -21,6 +21,8 @@
|
|||||||
<properties>
|
<properties>
|
||||||
<java.version>25</java.version>
|
<java.version>25</java.version>
|
||||||
<spring.boot.version>4.0.1</spring.boot.version>
|
<spring.boot.version>4.0.1</spring.boot.version>
|
||||||
|
<maven.compiler.source>25</maven.compiler.source>
|
||||||
|
<maven.compiler.target>25</maven.compiler.target>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
|
|||||||
Reference in New Issue
Block a user