Add: backlib for shared code between microservices. Started huertos microservice.
This commit is contained in:
57
backlib/.classpath
Normal file
57
backlib/.classpath
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<classpath>
|
||||||
|
<classpathentry kind="src" output="target/classes" path="src/main/java">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="optional" value="true"/>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
<attribute name="optional" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="optional" value="true"/>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
<attribute name="test" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
<attribute name="test" value="true"/>
|
||||||
|
<attribute name="optional" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="src" path="target/generated-sources/annotations">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="optional" value="true"/>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
<attribute name="ignore_optional_problems" value="true"/>
|
||||||
|
<attribute name="m2e-apt" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/test-annotations">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="optional" value="true"/>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
<attribute name="ignore_optional_problems" value="true"/>
|
||||||
|
<attribute name="m2e-apt" value="true"/>
|
||||||
|
<attribute name="test" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="output" path="target/classes"/>
|
||||||
|
</classpath>
|
||||||
23
backlib/.project
Normal file
23
backlib/.project
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>backlib</name>
|
||||||
|
<comment></comment>
|
||||||
|
<projects>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
|
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||||
|
</natures>
|
||||||
|
</projectDescription>
|
||||||
2
backlib/.settings/org.eclipse.jdt.apt.core.prefs
Normal file
2
backlib/.settings/org.eclipse.jdt.apt.core.prefs
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
eclipse.preferences.version=1
|
||||||
|
org.eclipse.jdt.apt.aptEnabled=false
|
||||||
9
backlib/.settings/org.eclipse.jdt.core.prefs
Normal file
9
backlib/.settings/org.eclipse.jdt.core.prefs
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
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
|
||||||
4
backlib/.settings/org.eclipse.m2e.core.prefs
Normal file
4
backlib/.settings/org.eclipse.m2e.core.prefs
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
activeProfiles=
|
||||||
|
eclipse.preferences.version=1
|
||||||
|
resolveWorkspaceProjects=true
|
||||||
|
version=1
|
||||||
19
backlib/pom.xml
Normal file
19
backlib/pom.xml
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<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,4 +1,4 @@
|
|||||||
package net.miarma.backend.core.dto;
|
package net.miarma.backlib.dto;
|
||||||
|
|
||||||
import jakarta.validation.constraints.Min;
|
import jakarta.validation.constraints.Min;
|
||||||
import jakarta.validation.constraints.NotBlank;
|
import jakarta.validation.constraints.NotBlank;
|
||||||
@@ -1,12 +1,11 @@
|
|||||||
package net.miarma.backend.core.dto;
|
package net.miarma.backlib.dto;
|
||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import net.miarma.backend.core.model.Credential;
|
|
||||||
|
|
||||||
public class CredentialDto {
|
public class CredentialDto {
|
||||||
private UUID credentialId;
|
private UUID credentialId;
|
||||||
|
private UUID userId;
|
||||||
private Byte serviceId;
|
private Byte serviceId;
|
||||||
private String username;
|
private String username;
|
||||||
private String email;
|
private String email;
|
||||||
@@ -16,73 +15,64 @@ public class CredentialDto {
|
|||||||
|
|
||||||
public CredentialDto() {}
|
public CredentialDto() {}
|
||||||
|
|
||||||
public CredentialDto(Credential credential) {
|
public CredentialDto(UUID credentialId, UUID userId, Byte serviceId, String username, String email,
|
||||||
this.credentialId = credential.getCredentialId();
|
Byte status, Instant createdAt, Instant updatedAt) {
|
||||||
this.serviceId = credential.getServiceId();
|
this.credentialId = credentialId;
|
||||||
this.username = credential.getUsername();
|
this.userId = userId;
|
||||||
this.email = credential.getEmail();
|
this.serviceId = serviceId;
|
||||||
this.status = credential.getStatus();
|
this.username = username;
|
||||||
this.createdAt = credential.getCreatedAt();
|
this.email = email;
|
||||||
this.updatedAt = credential.getUpdatedAt();
|
this.status = status;
|
||||||
}
|
this.createdAt = createdAt;
|
||||||
|
this.updatedAt = updatedAt;
|
||||||
public static CredentialDto fromEntity(Credential credential) {
|
|
||||||
if (credential == null) return null;
|
|
||||||
return new CredentialDto(credential);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Getters y setters
|
||||||
public UUID getCredentialId() {
|
public UUID getCredentialId() {
|
||||||
return credentialId;
|
return credentialId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCredentialId(UUID credentialId) {
|
public void setCredentialId(UUID credentialId) {
|
||||||
this.credentialId = credentialId;
|
this.credentialId = credentialId;
|
||||||
}
|
}
|
||||||
|
public UUID getUserId() {
|
||||||
|
return userId;
|
||||||
|
}
|
||||||
|
public void setUserId(UUID userId) {
|
||||||
|
this.userId = userId;
|
||||||
|
}
|
||||||
public Byte getServiceId() {
|
public Byte getServiceId() {
|
||||||
return serviceId;
|
return serviceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setServiceId(Byte serviceId) {
|
public void setServiceId(Byte serviceId) {
|
||||||
this.serviceId = serviceId;
|
this.serviceId = serviceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUsername() {
|
public String getUsername() {
|
||||||
return username;
|
return username;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUsername(String username) {
|
public void setUsername(String username) {
|
||||||
this.username = username;
|
this.username = username;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getEmail() {
|
public String getEmail() {
|
||||||
return email;
|
return email;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEmail(String email) {
|
public void setEmail(String email) {
|
||||||
this.email = email;
|
this.email = email;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Byte getStatus() {
|
public Byte getStatus() {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStatus(Byte status) {
|
public void setStatus(Byte status) {
|
||||||
this.status = status;
|
this.status = status;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Instant getCreatedAt() {
|
public Instant getCreatedAt() {
|
||||||
return createdAt;
|
return createdAt;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCreatedAt(Instant createdAt) {
|
public void setCreatedAt(Instant createdAt) {
|
||||||
this.createdAt = createdAt;
|
this.createdAt = createdAt;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Instant getUpdatedAt() {
|
public Instant getUpdatedAt() {
|
||||||
return updatedAt;
|
return updatedAt;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUpdatedAt(Instant updatedAt) {
|
public void setUpdatedAt(Instant updatedAt) {
|
||||||
this.updatedAt = updatedAt;
|
this.updatedAt = updatedAt;
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package net.miarma.backend.core.dto;
|
package net.miarma.backlib.dto;
|
||||||
|
|
||||||
import jakarta.validation.constraints.NotBlank;
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package net.miarma.backend.core.dto;
|
package net.miarma.backlib.dto;
|
||||||
|
|
||||||
public class LoginResponse {
|
public class LoginResponse {
|
||||||
private String token;
|
private String token;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package net.miarma.backend.core.dto;
|
package net.miarma.backlib.dto;
|
||||||
|
|
||||||
public class RegisterRequest {
|
public class RegisterRequest {
|
||||||
private String username;
|
private String username;
|
||||||
71
backlib/src/main/java/net/miarma/backlib/dto/UserDto.java
Normal file
71
backlib/src/main/java/net/miarma/backlib/dto/UserDto.java
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
package net.miarma.backlib.dto;
|
||||||
|
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class UserDto {
|
||||||
|
private UUID userId;
|
||||||
|
private String displayName;
|
||||||
|
private String avatar;
|
||||||
|
private Byte globalStatus;
|
||||||
|
private Byte globalRole;
|
||||||
|
private Instant createdAt;
|
||||||
|
private Instant updatedAt;
|
||||||
|
|
||||||
|
public UserDto() {}
|
||||||
|
|
||||||
|
public UserDto(UUID userId, String displayName, String avatar, Byte globalStatus, Byte globalRole,
|
||||||
|
Instant createdAt, Instant updatedAt) {
|
||||||
|
this.userId = userId;
|
||||||
|
this.displayName = displayName;
|
||||||
|
this.avatar = avatar;
|
||||||
|
this.globalStatus = globalStatus;
|
||||||
|
this.globalRole = globalRole;
|
||||||
|
this.createdAt = createdAt;
|
||||||
|
this.updatedAt = updatedAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Getters y setters
|
||||||
|
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 Byte getGlobalStatus() {
|
||||||
|
return globalStatus;
|
||||||
|
}
|
||||||
|
public void setGlobalStatus(Byte globalStatus) {
|
||||||
|
this.globalStatus = globalStatus;
|
||||||
|
}
|
||||||
|
public Byte getGlobalRole() {
|
||||||
|
return globalRole;
|
||||||
|
}
|
||||||
|
public void setGlobalRole(Byte globalRole) {
|
||||||
|
this.globalRole = globalRole;
|
||||||
|
}
|
||||||
|
public Instant getCreatedAt() {
|
||||||
|
return createdAt;
|
||||||
|
}
|
||||||
|
public void setCreatedAt(Instant createdAt) {
|
||||||
|
this.createdAt = createdAt;
|
||||||
|
}
|
||||||
|
public Instant getUpdatedAt() {
|
||||||
|
return updatedAt;
|
||||||
|
}
|
||||||
|
public void setUpdatedAt(Instant updatedAt) {
|
||||||
|
this.updatedAt = updatedAt;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
package net.miarma.backend.core.util;
|
package net.miarma.backlib.util;
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class UuidUtils {
|
public class UuidUtil {
|
||||||
public static byte[] uuidToBin(UUID uuid) {
|
public static byte[] uuidToBin(UUID uuid) {
|
||||||
ByteBuffer bb = ByteBuffer.allocate(16);
|
ByteBuffer bb = ByteBuffer.allocate(16);
|
||||||
bb.putLong(uuid.getMostSignificantBits());
|
bb.putLong(uuid.getMostSignificantBits());
|
||||||
4
backlib/target/classes/META-INF/MANIFEST.MF
Normal file
4
backlib/target/classes/META-INF/MANIFEST.MF
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
Manifest-Version: 1.0
|
||||||
|
Build-Jdk-Spec: 21
|
||||||
|
Created-By: Maven Integration for Eclipse
|
||||||
|
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
#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
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<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>
|
||||||
@@ -15,6 +15,11 @@
|
|||||||
<arguments>
|
<arguments>
|
||||||
</arguments>
|
</arguments>
|
||||||
</buildCommand>
|
</buildCommand>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.springframework.ide.eclipse.boot.validation.springbootbuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
</buildSpec>
|
</buildSpec>
|
||||||
<natures>
|
<natures>
|
||||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
|
|||||||
2
cine/.settings/org.springframework.ide.eclipse.prefs
Normal file
2
cine/.settings/org.springframework.ide.eclipse.prefs
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
boot.validation.initialized=true
|
||||||
|
eclipse.preferences.version=1
|
||||||
@@ -15,6 +15,11 @@
|
|||||||
<arguments>
|
<arguments>
|
||||||
</arguments>
|
</arguments>
|
||||||
</buildCommand>
|
</buildCommand>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.springframework.ide.eclipse.boot.validation.springbootbuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
</buildSpec>
|
</buildSpec>
|
||||||
<natures>
|
<natures>
|
||||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
|
|||||||
2
core/.settings/org.springframework.ide.eclipse.prefs
Normal file
2
core/.settings/org.springframework.ide.eclipse.prefs
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
boot.validation.initialized=true
|
||||||
|
eclipse.preferences.version=1
|
||||||
@@ -63,6 +63,12 @@
|
|||||||
<version>0.11.5</version>
|
<version>0.11.5</version>
|
||||||
<scope>runtime</scope>
|
<scope>runtime</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.miarma</groupId>
|
||||||
|
<artifactId>backlib</artifactId>
|
||||||
|
<version>1.0.0</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
@@ -12,14 +12,14 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
import net.miarma.backend.core.dto.ChangePasswordRequest;
|
|
||||||
import net.miarma.backend.core.dto.LoginRequest;
|
|
||||||
import net.miarma.backend.core.dto.LoginResponse;
|
|
||||||
import net.miarma.backend.core.dto.RegisterRequest;
|
|
||||||
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.backend.core.service.JwtService;
|
||||||
|
import net.miarma.backlib.dto.ChangePasswordRequest;
|
||||||
|
import net.miarma.backlib.dto.LoginRequest;
|
||||||
|
import net.miarma.backlib.dto.LoginResponse;
|
||||||
|
import net.miarma.backlib.dto.RegisterRequest;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/auth")
|
@RequestMapping("/auth")
|
||||||
|
|||||||
@@ -13,9 +13,9 @@ import org.springframework.web.bind.annotation.RequestBody;
|
|||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import net.miarma.backend.core.dto.CredentialDto;
|
|
||||||
import net.miarma.backend.core.model.Credential;
|
import net.miarma.backend.core.model.Credential;
|
||||||
import net.miarma.backend.core.service.CredentialService;
|
import net.miarma.backend.core.service.CredentialService;
|
||||||
|
import net.miarma.backlib.dto.CredentialDto;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/credentials")
|
@RequestMapping("/credentials")
|
||||||
|
|||||||
@@ -14,10 +14,11 @@ import org.springframework.web.bind.annotation.RequestHeader;
|
|||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import net.miarma.backend.core.dto.UserDto;
|
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.backend.core.service.JwtService;
|
||||||
import net.miarma.backend.core.service.UserService;
|
import net.miarma.backend.core.service.UserService;
|
||||||
|
import net.miarma.backlib.dto.UserDto;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/users")
|
@RequestMapping("/users")
|
||||||
@@ -36,7 +37,7 @@ public class UserController {
|
|||||||
return ResponseEntity.ok(
|
return ResponseEntity.ok(
|
||||||
userService.getAll()
|
userService.getAll()
|
||||||
.stream()
|
.stream()
|
||||||
.map(UserDto::fromEntity)
|
.map(UserMapper::toDto)
|
||||||
.toList()
|
.toList()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -45,13 +46,13 @@ public class UserController {
|
|||||||
@PreAuthorize("hasRole('ADMIN')")
|
@PreAuthorize("hasRole('ADMIN')")
|
||||||
public ResponseEntity<UserDto> getById(@PathVariable("user_id") UUID userId) {
|
public ResponseEntity<UserDto> getById(@PathVariable("user_id") UUID userId) {
|
||||||
User user = userService.getById(userId);
|
User user = userService.getById(userId);
|
||||||
return ResponseEntity.ok(UserDto.fromEntity(user));
|
return ResponseEntity.ok(UserMapper.toDto(user));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/{user_id}")
|
@PutMapping("/{user_id}")
|
||||||
@PreAuthorize("hasRole('ADMIN') or #userId == principal.userId")
|
@PreAuthorize("hasRole('ADMIN') or #userId == principal.userId")
|
||||||
public ResponseEntity<UserDto> update(@PathVariable("user_id") UUID userId, @RequestBody UserDto dto) {
|
public ResponseEntity<UserDto> update(@PathVariable("user_id") UUID userId, @RequestBody UserDto dto) {
|
||||||
return ResponseEntity.ok(UserDto.fromEntity(userService.update(userId, dto)));
|
return ResponseEntity.ok(UserMapper.toDto(userService.update(userId, dto)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/{user_id}/avatar")
|
@GetMapping("/{user_id}/avatar")
|
||||||
@@ -75,6 +76,6 @@ public class UserController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
User user = userService.getById(userId);
|
User user = userService.getById(userId);
|
||||||
return ResponseEntity.ok(UserDto.fromEntity(user));
|
return ResponseEntity.ok(UserMapper.toDto(user));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,99 +0,0 @@
|
|||||||
package net.miarma.backend.core.dto;
|
|
||||||
|
|
||||||
import java.time.Instant;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import net.miarma.backend.core.model.User;
|
|
||||||
|
|
||||||
public class UserDto {
|
|
||||||
private UUID userId;
|
|
||||||
private String displayName;
|
|
||||||
private String avatar;
|
|
||||||
private Byte globalStatus;
|
|
||||||
private Byte globalRole;
|
|
||||||
private Instant createdAt;
|
|
||||||
private Instant updatedAt;
|
|
||||||
|
|
||||||
public UserDto() {}
|
|
||||||
|
|
||||||
public UserDto(UUID userId, String displayName, String avatar, Byte globalStatus, Byte globalRole,
|
|
||||||
Instant createdAt, Instant updatedAt) {
|
|
||||||
this.userId = userId;
|
|
||||||
this.displayName = displayName;
|
|
||||||
this.avatar = avatar;
|
|
||||||
this.globalStatus = globalStatus;
|
|
||||||
this.globalRole = globalRole;
|
|
||||||
this.createdAt = createdAt;
|
|
||||||
this.updatedAt = updatedAt;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static UserDto fromEntity(User user) {
|
|
||||||
if (user == null) return null;
|
|
||||||
|
|
||||||
return new UserDto(
|
|
||||||
user.getUserId(),
|
|
||||||
user.getDisplayName(),
|
|
||||||
user.getAvatar(),
|
|
||||||
user.getGlobalStatus(),
|
|
||||||
user.getGlobalRole(),
|
|
||||||
user.getCreatedAt(),
|
|
||||||
user.getUpdatedAt()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
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 Byte getGlobalStatus() {
|
|
||||||
return globalStatus;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setGlobalStatus(Byte globalStatus) {
|
|
||||||
this.globalStatus = globalStatus;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Byte getGlobalRole() {
|
|
||||||
return globalRole;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setGlobalRole(Byte globalRole) {
|
|
||||||
this.globalRole = globalRole;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Instant getCreatedAt() {
|
|
||||||
return createdAt;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCreatedAt(Instant createdAt) {
|
|
||||||
this.createdAt = createdAt;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Instant getUpdatedAt() {
|
|
||||||
return updatedAt;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUpdatedAt(Instant updatedAt) {
|
|
||||||
this.updatedAt = updatedAt;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package net.miarma.backend.core.mapper;
|
||||||
|
|
||||||
|
import net.miarma.backend.core.model.Credential;
|
||||||
|
import net.miarma.backlib.dto.CredentialDto;
|
||||||
|
|
||||||
|
public class CredentialMapper {
|
||||||
|
|
||||||
|
public static CredentialDto toDto(Credential c) {
|
||||||
|
if (c == null) return null;
|
||||||
|
|
||||||
|
return new CredentialDto(
|
||||||
|
c.getCredentialId(),
|
||||||
|
c.getUserId(),
|
||||||
|
c.getServiceId(),
|
||||||
|
c.getUsername(),
|
||||||
|
c.getEmail(),
|
||||||
|
c.getStatus(),
|
||||||
|
c.getCreatedAt(),
|
||||||
|
c.getUpdatedAt()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package net.miarma.backend.core.mapper;
|
||||||
|
|
||||||
|
import net.miarma.backend.core.model.User;
|
||||||
|
import net.miarma.backlib.dto.UserDto;
|
||||||
|
|
||||||
|
public class UserMapper {
|
||||||
|
public static UserDto toDto(User u) {
|
||||||
|
if (u == null) return null;
|
||||||
|
|
||||||
|
return new UserDto(
|
||||||
|
u.getUserId(),
|
||||||
|
u.getDisplayName(),
|
||||||
|
u.getAvatar(),
|
||||||
|
u.getGlobalStatus(),
|
||||||
|
u.getGlobalRole(),
|
||||||
|
u.getCreatedAt(),
|
||||||
|
u.getUpdatedAt()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,8 +3,10 @@ package net.miarma.backend.core.model;
|
|||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.hibernate.annotations.CreationTimestamp;
|
import org.hibernate.annotations.CreationTimestamp;
|
||||||
import org.hibernate.annotations.UpdateTimestamp;
|
import org.hibernate.annotations.UpdateTimestamp;
|
||||||
|
|
||||||
import jakarta.persistence.Column;
|
import jakarta.persistence.Column;
|
||||||
import jakarta.persistence.Entity;
|
import jakarta.persistence.Entity;
|
||||||
import jakarta.persistence.FetchType;
|
import jakarta.persistence.FetchType;
|
||||||
@@ -17,6 +19,7 @@ import jakarta.persistence.PreUpdate;
|
|||||||
import jakarta.persistence.Table;
|
import jakarta.persistence.Table;
|
||||||
import jakarta.persistence.Transient;
|
import jakarta.persistence.Transient;
|
||||||
import jakarta.persistence.UniqueConstraint;
|
import jakarta.persistence.UniqueConstraint;
|
||||||
|
import net.miarma.backlib.util.UuidUtil;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "credentials",
|
@Table(name = "credentials",
|
||||||
@@ -62,32 +65,20 @@ public class Credential {
|
|||||||
@PreUpdate
|
@PreUpdate
|
||||||
private void prePersist() {
|
private void prePersist() {
|
||||||
if (credentialId != null) {
|
if (credentialId != null) {
|
||||||
ByteBuffer bb = ByteBuffer.wrap(new byte[16]);
|
credentialIdBin = UuidUtil.uuidToBin(credentialId);
|
||||||
bb.putLong(credentialId.getMostSignificantBits());
|
|
||||||
bb.putLong(credentialId.getLeastSignificantBits());
|
|
||||||
credentialIdBin = bb.array();
|
|
||||||
}
|
}
|
||||||
if (userId != null) {
|
if (userId != null) {
|
||||||
ByteBuffer bb = ByteBuffer.wrap(new byte[16]);
|
userIdBin = UuidUtil.uuidToBin(userId);
|
||||||
bb.putLong(userId.getMostSignificantBits());
|
|
||||||
bb.putLong(userId.getLeastSignificantBits());
|
|
||||||
userIdBin = bb.array();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostLoad
|
@PostLoad
|
||||||
private void postLoad() {
|
private void postLoad() {
|
||||||
if (credentialIdBin != null) {
|
if (credentialIdBin != null) {
|
||||||
ByteBuffer bb = ByteBuffer.wrap(credentialIdBin);
|
credentialId = UuidUtil.binToUUID(credentialIdBin);
|
||||||
long high = bb.getLong();
|
|
||||||
long low = bb.getLong();
|
|
||||||
credentialId = new UUID(high, low);
|
|
||||||
}
|
}
|
||||||
if (userIdBin != null) {
|
if (userIdBin != null) {
|
||||||
ByteBuffer bb = ByteBuffer.wrap(userIdBin);
|
userId = UuidUtil.binToUUID(userIdBin);
|
||||||
long high = bb.getLong();
|
|
||||||
long low = bb.getLong();
|
|
||||||
userId = new UUID(high, low);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,9 +6,12 @@ import java.util.UUID;
|
|||||||
import jakarta.persistence.Column;
|
import jakarta.persistence.Column;
|
||||||
import jakarta.persistence.Entity;
|
import jakarta.persistence.Entity;
|
||||||
import jakarta.persistence.Id;
|
import jakarta.persistence.Id;
|
||||||
|
import jakarta.persistence.PostLoad;
|
||||||
import jakarta.persistence.PrePersist;
|
import jakarta.persistence.PrePersist;
|
||||||
|
import jakarta.persistence.PreUpdate;
|
||||||
import jakarta.persistence.Table;
|
import jakarta.persistence.Table;
|
||||||
import jakarta.persistence.Transient;
|
import jakarta.persistence.Transient;
|
||||||
|
import net.miarma.backlib.util.UuidUtil;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "files")
|
@Table(name = "files")
|
||||||
@@ -43,12 +46,25 @@ public class File {
|
|||||||
private Short context;
|
private Short context;
|
||||||
|
|
||||||
@PrePersist
|
@PrePersist
|
||||||
public void prePersist() {
|
@PreUpdate
|
||||||
if (fileId == null) {
|
private void prePersist() {
|
||||||
fileId = UUID.randomUUID();
|
if (fileId != null) {
|
||||||
|
fileIdBin = UuidUtil.uuidToBin(fileId);
|
||||||
}
|
}
|
||||||
if (uploadedAt == null) {
|
|
||||||
uploadedAt = Instant.now();
|
if (uploadedBy != null) {
|
||||||
|
uploadedByBin = UuidUtil.uuidToBin(uploadedBy);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostLoad
|
||||||
|
private void postLoad() {
|
||||||
|
if (fileIdBin != null) {
|
||||||
|
fileId = UuidUtil.binToUUID(fileIdBin);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (uploadedByBin != null) {
|
||||||
|
uploadedBy = UuidUtil.binToUUID(uploadedByBin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package net.miarma.backend.core.model;
|
package net.miarma.backend.core.model;
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@@ -15,6 +14,7 @@ import jakarta.persistence.PrePersist;
|
|||||||
import jakarta.persistence.PreUpdate;
|
import jakarta.persistence.PreUpdate;
|
||||||
import jakarta.persistence.Table;
|
import jakarta.persistence.Table;
|
||||||
import jakarta.persistence.Transient;
|
import jakarta.persistence.Transient;
|
||||||
|
import net.miarma.backlib.util.UuidUtil;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "users")
|
@Table(name = "users")
|
||||||
@@ -48,20 +48,14 @@ public class User {
|
|||||||
@PreUpdate
|
@PreUpdate
|
||||||
private void prePersist() {
|
private void prePersist() {
|
||||||
if (userId != null) {
|
if (userId != null) {
|
||||||
ByteBuffer bb = ByteBuffer.wrap(new byte[16]);
|
userIdBin = UuidUtil.uuidToBin(userId);
|
||||||
bb.putLong(userId.getMostSignificantBits());
|
|
||||||
bb.putLong(userId.getLeastSignificantBits());
|
|
||||||
userIdBin = bb.array();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostLoad
|
@PostLoad
|
||||||
private void postLoad() {
|
private void postLoad() {
|
||||||
if (userIdBin != null) {
|
if (userIdBin != null) {
|
||||||
ByteBuffer bb = ByteBuffer.wrap(userIdBin);
|
userId = UuidUtil.binToUUID(userIdBin);
|
||||||
long high = bb.getLong();
|
|
||||||
long low = bb.getLong();
|
|
||||||
userId = new UUID(high, low);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,13 +5,15 @@ import java.util.UUID;
|
|||||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import net.miarma.backend.core.dto.CredentialDto;
|
import net.miarma.backend.core.mapper.CredentialMapper;
|
||||||
import net.miarma.backend.core.dto.LoginRequest;
|
import net.miarma.backend.core.mapper.UserMapper;
|
||||||
import net.miarma.backend.core.dto.LoginResponse;
|
|
||||||
import net.miarma.backend.core.dto.RegisterRequest;
|
|
||||||
import net.miarma.backend.core.dto.UserDto;
|
|
||||||
import net.miarma.backend.core.model.Credential;
|
import net.miarma.backend.core.model.Credential;
|
||||||
import net.miarma.backend.core.model.User;
|
import net.miarma.backend.core.model.User;
|
||||||
|
import net.miarma.backlib.dto.CredentialDto;
|
||||||
|
import net.miarma.backlib.dto.LoginRequest;
|
||||||
|
import net.miarma.backlib.dto.LoginResponse;
|
||||||
|
import net.miarma.backlib.dto.RegisterRequest;
|
||||||
|
import net.miarma.backlib.dto.UserDto;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class AuthService {
|
public class AuthService {
|
||||||
@@ -38,9 +40,9 @@ public class AuthService {
|
|||||||
|
|
||||||
String token = jwtService.generateToken(cred.getUserId(), request.getServiceId());
|
String token = jwtService.generateToken(cred.getUserId(), request.getServiceId());
|
||||||
|
|
||||||
UserDto userDto = UserDto.fromEntity(cred.getUser());
|
UserDto userDto = UserMapper.toDto(cred.getUser());
|
||||||
|
|
||||||
CredentialDto credentialDto = CredentialDto.fromEntity(cred);
|
CredentialDto credentialDto = CredentialMapper.toDto(cred);
|
||||||
|
|
||||||
return new LoginResponse(token, userDto, credentialDto);
|
return new LoginResponse(token, userDto, credentialDto);
|
||||||
}
|
}
|
||||||
@@ -71,6 +73,6 @@ public class AuthService {
|
|||||||
|
|
||||||
String token = jwtService.generateToken(user.getUserId(), request.getServiceId());
|
String token = jwtService.generateToken(user.getUserId(), request.getServiceId());
|
||||||
|
|
||||||
return new LoginResponse(token, UserDto.fromEntity(user), CredentialDto.fromEntity(cred));
|
return new LoginResponse(token, UserMapper.toDto(user), CredentialMapper.toDto(cred));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,12 +7,12 @@ import org.springframework.security.crypto.password.PasswordEncoder;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import net.miarma.backend.core.dto.ChangePasswordRequest;
|
|
||||||
import net.miarma.backend.core.dto.CredentialDto;
|
|
||||||
import net.miarma.backend.core.model.Credential;
|
import net.miarma.backend.core.model.Credential;
|
||||||
import net.miarma.backend.core.model.User;
|
import net.miarma.backend.core.model.User;
|
||||||
import net.miarma.backend.core.repository.CredentialRepository;
|
import net.miarma.backend.core.repository.CredentialRepository;
|
||||||
import net.miarma.backend.core.util.UuidUtils;
|
import net.miarma.backlib.dto.ChangePasswordRequest;
|
||||||
|
import net.miarma.backlib.dto.CredentialDto;
|
||||||
|
import net.miarma.backlib.util.UuidUtil;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@Transactional
|
@Transactional
|
||||||
@@ -27,7 +27,7 @@ public class CredentialService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Credential getById(UUID credentialId) {
|
public Credential getById(UUID credentialId) {
|
||||||
byte[] idBytes = UuidUtils.uuidToBin(credentialId);
|
byte[] idBytes = UuidUtil.uuidToBin(credentialId);
|
||||||
return credentialRepository.findById(idBytes)
|
return credentialRepository.findById(idBytes)
|
||||||
.orElseThrow(() -> new RuntimeException("Credential not found"));
|
.orElseThrow(() -> new RuntimeException("Credential not found"));
|
||||||
}
|
}
|
||||||
@@ -63,7 +63,7 @@ public class CredentialService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<Credential> getByUserId(UUID userId) {
|
public List<Credential> getByUserId(UUID userId) {
|
||||||
List<Credential> creds = credentialRepository.findByUserId(UuidUtils.uuidToBin(userId));
|
List<Credential> creds = credentialRepository.findByUserId(UuidUtil.uuidToBin(userId));
|
||||||
if (creds.isEmpty()) {
|
if (creds.isEmpty()) {
|
||||||
throw new RuntimeException("User has no credentials");
|
throw new RuntimeException("User has no credentials");
|
||||||
}
|
}
|
||||||
@@ -91,14 +91,14 @@ public class CredentialService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isOwner(UUID credentialId, UUID userId) {
|
public boolean isOwner(UUID credentialId, UUID userId) {
|
||||||
byte[] idBytes = UuidUtils.uuidToBin(credentialId);
|
byte[] idBytes = UuidUtil.uuidToBin(credentialId);
|
||||||
Credential c = credentialRepository.findById(idBytes)
|
Credential c = credentialRepository.findById(idBytes)
|
||||||
.orElseThrow(() -> new RuntimeException("Credential not found"));
|
.orElseThrow(() -> new RuntimeException("Credential not found"));
|
||||||
return c.getUserId().equals(userId);
|
return c.getUserId().equals(userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Credential update(UUID credentialId, CredentialDto dto) {
|
public Credential update(UUID credentialId, CredentialDto dto) {
|
||||||
byte[] idBytes = UuidUtils.uuidToBin(credentialId);
|
byte[] idBytes = UuidUtil.uuidToBin(credentialId);
|
||||||
|
|
||||||
Credential cred = credentialRepository.findById(idBytes)
|
Credential cred = credentialRepository.findById(idBytes)
|
||||||
.orElseThrow(() -> new RuntimeException("Credential not found"));
|
.orElseThrow(() -> new RuntimeException("Credential not found"));
|
||||||
@@ -122,7 +122,7 @@ public class CredentialService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Credential updatePassword(UUID credentialId, ChangePasswordRequest request) {
|
public Credential updatePassword(UUID credentialId, ChangePasswordRequest request) {
|
||||||
byte[] idBytes = UuidUtils.uuidToBin(credentialId);
|
byte[] idBytes = UuidUtil.uuidToBin(credentialId);
|
||||||
|
|
||||||
Credential cred = credentialRepository.findById(idBytes)
|
Credential cred = credentialRepository.findById(idBytes)
|
||||||
.orElseThrow(() -> new RuntimeException("Credential not found"));
|
.orElseThrow(() -> new RuntimeException("Credential not found"));
|
||||||
@@ -136,7 +136,7 @@ public class CredentialService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void delete(UUID credentialId) {
|
public void delete(UUID credentialId) {
|
||||||
byte[] idBytes = UuidUtils.uuidToBin(credentialId);
|
byte[] idBytes = UuidUtil.uuidToBin(credentialId);
|
||||||
if(!credentialRepository.existsById(idBytes))
|
if(!credentialRepository.existsById(idBytes))
|
||||||
throw new RuntimeException("Credential not found");
|
throw new RuntimeException("Credential not found");
|
||||||
credentialRepository.deleteById(idBytes);
|
credentialRepository.deleteById(idBytes);
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|||||||
|
|
||||||
import net.miarma.backend.core.model.File;
|
import net.miarma.backend.core.model.File;
|
||||||
import net.miarma.backend.core.repository.FileRepository;
|
import net.miarma.backend.core.repository.FileRepository;
|
||||||
import net.miarma.backend.core.util.UuidUtils;
|
import net.miarma.backlib.util.UuidUtil;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@Transactional
|
@Transactional
|
||||||
@@ -28,7 +28,7 @@ public class FileService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public File getById(UUID fileId) {
|
public File getById(UUID fileId) {
|
||||||
byte[] idBytes = UuidUtils.uuidToBin(fileId);
|
byte[] idBytes = UuidUtil.uuidToBin(fileId);
|
||||||
return fileRepository.findById(idBytes)
|
return fileRepository.findById(idBytes)
|
||||||
.orElseThrow(() -> new RuntimeException("File not found"));
|
.orElseThrow(() -> new RuntimeException("File not found"));
|
||||||
}
|
}
|
||||||
@@ -66,7 +66,7 @@ public class FileService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public File update(File file) {
|
public File update(File file) {
|
||||||
byte[] idBytes = UuidUtils.uuidToBin(file.getFileId());
|
byte[] idBytes = UuidUtil.uuidToBin(file.getFileId());
|
||||||
if (!fileRepository.existsById(idBytes)) {
|
if (!fileRepository.existsById(idBytes)) {
|
||||||
throw new RuntimeException("File not found");
|
throw new RuntimeException("File not found");
|
||||||
}
|
}
|
||||||
@@ -74,7 +74,7 @@ public class FileService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void delete(UUID fileId) {
|
public void delete(UUID fileId) {
|
||||||
byte[] idBytes = UuidUtils.uuidToBin(fileId);
|
byte[] idBytes = UuidUtil.uuidToBin(fileId);
|
||||||
if (!fileRepository.existsById(idBytes)) {
|
if (!fileRepository.existsById(idBytes)) {
|
||||||
throw new RuntimeException("File not found");
|
throw new RuntimeException("File not found");
|
||||||
}
|
}
|
||||||
@@ -82,7 +82,7 @@ public class FileService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isOwner(UUID fileId, UUID userId) {
|
public boolean isOwner(UUID fileId, UUID userId) {
|
||||||
byte[] fileBytes = UuidUtils.uuidToBin(fileId);
|
byte[] fileBytes = UuidUtil.uuidToBin(fileId);
|
||||||
return fileRepository.findById(fileBytes)
|
return fileRepository.findById(fileBytes)
|
||||||
.map(f -> f.getUploadedBy().equals(userId))
|
.map(f -> f.getUploadedBy().equals(userId))
|
||||||
.orElse(false);
|
.orElse(false);
|
||||||
|
|||||||
@@ -6,10 +6,10 @@ import java.util.UUID;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import jakarta.transaction.Transactional;
|
import jakarta.transaction.Transactional;
|
||||||
import net.miarma.backend.core.dto.UserDto;
|
|
||||||
import net.miarma.backend.core.model.User;
|
import net.miarma.backend.core.model.User;
|
||||||
import net.miarma.backend.core.repository.UserRepository;
|
import net.miarma.backend.core.repository.UserRepository;
|
||||||
import net.miarma.backend.core.util.UuidUtils;
|
import net.miarma.backlib.dto.UserDto;
|
||||||
|
import net.miarma.backlib.util.UuidUtil;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@Transactional
|
@Transactional
|
||||||
@@ -25,7 +25,7 @@ public class UserService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public User getById(UUID userId) {
|
public User getById(UUID userId) {
|
||||||
byte[] idBytes = UuidUtils.uuidToBin(userId);
|
byte[] idBytes = UuidUtil.uuidToBin(userId);
|
||||||
return userRepository.findById(idBytes)
|
return userRepository.findById(idBytes)
|
||||||
.orElseThrow(() -> new RuntimeException("User not found"));
|
.orElseThrow(() -> new RuntimeException("User not found"));
|
||||||
}
|
}
|
||||||
@@ -46,7 +46,7 @@ public class UserService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public User update(UUID userId, UserDto dto) {
|
public User update(UUID userId, UserDto dto) {
|
||||||
byte[] idBytes = UuidUtils.uuidToBin(userId);
|
byte[] idBytes = UuidUtil.uuidToBin(userId);
|
||||||
User user = userRepository.findById(idBytes)
|
User user = userRepository.findById(idBytes)
|
||||||
.orElseThrow(() -> new RuntimeException("User not found"));
|
.orElseThrow(() -> new RuntimeException("User not found"));
|
||||||
|
|
||||||
@@ -70,7 +70,7 @@ public class UserService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void delete(UUID userId) {
|
public void delete(UUID userId) {
|
||||||
byte[] idBytes = UuidUtils.uuidToBin(userId);
|
byte[] idBytes = UuidUtil.uuidToBin(userId);
|
||||||
if(!userRepository.existsById(idBytes))
|
if(!userRepository.existsById(idBytes))
|
||||||
throw new RuntimeException("User not found");
|
throw new RuntimeException("User not found");
|
||||||
userRepository.deleteById(idBytes);
|
userRepository.deleteById(idBytes);
|
||||||
|
|||||||
@@ -15,6 +15,11 @@
|
|||||||
<arguments>
|
<arguments>
|
||||||
</arguments>
|
</arguments>
|
||||||
</buildCommand>
|
</buildCommand>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.springframework.ide.eclipse.boot.validation.springbootbuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
</buildSpec>
|
</buildSpec>
|
||||||
<natures>
|
<natures>
|
||||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
|
|||||||
2
huertos/.settings/org.springframework.ide.eclipse.prefs
Normal file
2
huertos/.settings/org.springframework.ide.eclipse.prefs
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
boot.validation.initialized=true
|
||||||
|
eclipse.preferences.version=1
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package net.miarma.backend.huertos;
|
||||||
|
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
|
@SpringBootApplication
|
||||||
|
public class HuertosApplication {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(HuertosApplication.class, args);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
package net.miarma.backend.huertos.model;
|
||||||
|
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import jakarta.persistence.Column;
|
||||||
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.Id;
|
||||||
|
import jakarta.persistence.Table;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "huertos_announces")
|
||||||
|
public class Announcement {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@Column(name = "announce_id", columnDefinition = "BINARY(16)")
|
||||||
|
private UUID announceId;
|
||||||
|
|
||||||
|
@Column(name = "body", nullable = false, columnDefinition = "TEXT")
|
||||||
|
private String body;
|
||||||
|
|
||||||
|
@Column(name = "priority", nullable = false)
|
||||||
|
private Byte priority;
|
||||||
|
|
||||||
|
@Column(name = "published_by", columnDefinition = "BINARY(16)", nullable = false)
|
||||||
|
private UUID publishedBy;
|
||||||
|
|
||||||
|
@Column(name = "created_at", nullable = false)
|
||||||
|
private Instant createdAt;
|
||||||
|
|
||||||
|
public UUID getAnnounceId() {
|
||||||
|
return announceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAnnounceId(UUID announceId) {
|
||||||
|
this.announceId = announceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBody() {
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBody(String body) {
|
||||||
|
this.body = body;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Byte getPriority() {
|
||||||
|
return priority;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPriority(Byte priority) {
|
||||||
|
this.priority = priority;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UUID getPublishedBy() {
|
||||||
|
return publishedBy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPublishedBy(UUID publishedBy) {
|
||||||
|
this.publishedBy = publishedBy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Instant getCreatedAt() {
|
||||||
|
return createdAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreatedAt(Instant createdAt) {
|
||||||
|
this.createdAt = createdAt;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
package net.miarma.backend.huertos.model;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.Instant;
|
||||||
|
|
||||||
|
import jakarta.persistence.Column;
|
||||||
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.Id;
|
||||||
|
import jakarta.persistence.Table;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "huertos_balance")
|
||||||
|
public class Balance {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
private Byte id = 1;
|
||||||
|
|
||||||
|
@Column(name = "initial_bank", nullable = false)
|
||||||
|
private BigDecimal initialBank;
|
||||||
|
|
||||||
|
@Column(name = "initial_cash", nullable = false)
|
||||||
|
private BigDecimal initialCash;
|
||||||
|
|
||||||
|
@Column(name = "created_at", nullable = false)
|
||||||
|
private Instant createdAt;
|
||||||
|
|
||||||
|
public Byte getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(Byte id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getInitialBank() {
|
||||||
|
return initialBank;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInitialBank(BigDecimal initialBank) {
|
||||||
|
this.initialBank = initialBank;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getInitialCash() {
|
||||||
|
return initialCash;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInitialCash(BigDecimal initialCash) {
|
||||||
|
this.initialCash = initialCash;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Instant getCreatedAt() {
|
||||||
|
return createdAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreatedAt(Instant createdAt) {
|
||||||
|
this.createdAt = createdAt;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,93 @@
|
|||||||
|
package net.miarma.backend.huertos.model;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import jakarta.persistence.Column;
|
||||||
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.Id;
|
||||||
|
import jakarta.persistence.Table;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "huertos_expenses")
|
||||||
|
public class Expense {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@Column(name = "expense_id", columnDefinition = "BINARY(16)")
|
||||||
|
private UUID expenseId;
|
||||||
|
|
||||||
|
@Column(name = "concept", nullable = false, length = 128)
|
||||||
|
private String concept;
|
||||||
|
|
||||||
|
@Column(name = "amount", nullable = false)
|
||||||
|
private BigDecimal amount;
|
||||||
|
|
||||||
|
@Column(name = "supplier", nullable = false, length = 128)
|
||||||
|
private String supplier;
|
||||||
|
|
||||||
|
@Column(name = "invoice", nullable = false, length = 32)
|
||||||
|
private String invoice;
|
||||||
|
|
||||||
|
@Column(name = "type")
|
||||||
|
private Byte type;
|
||||||
|
|
||||||
|
@Column(name = "created_at", nullable = false)
|
||||||
|
private Instant createdAt;
|
||||||
|
|
||||||
|
public UUID getExpenseId() {
|
||||||
|
return expenseId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setExpenseId(UUID expenseId) {
|
||||||
|
this.expenseId = expenseId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getConcept() {
|
||||||
|
return concept;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setConcept(String concept) {
|
||||||
|
this.concept = concept;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getAmount() {
|
||||||
|
return amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAmount(BigDecimal amount) {
|
||||||
|
this.amount = amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSupplier() {
|
||||||
|
return supplier;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSupplier(String supplier) {
|
||||||
|
this.supplier = supplier;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getInvoice() {
|
||||||
|
return invoice;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInvoice(String invoice) {
|
||||||
|
this.invoice = invoice;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Byte getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(Byte type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Instant getCreatedAt() {
|
||||||
|
return createdAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreatedAt(Instant createdAt) {
|
||||||
|
this.createdAt = createdAt;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,136 @@
|
|||||||
|
package net.miarma.backend.huertos.model;
|
||||||
|
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import jakarta.persistence.Column;
|
||||||
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.Id;
|
||||||
|
import jakarta.persistence.Table;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "huertos_user_metadata")
|
||||||
|
public class HuertosUserMetadata {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@Column(name = "user_id", columnDefinition = "BINARY(16)")
|
||||||
|
private UUID userId;
|
||||||
|
|
||||||
|
@Column(name = "member_number", nullable = false, unique = true)
|
||||||
|
private Integer memberNumber;
|
||||||
|
|
||||||
|
@Column(name = "plot_number", nullable = false)
|
||||||
|
private Integer plotNumber;
|
||||||
|
|
||||||
|
@Column(name = "dni", nullable = false, unique = true, length = 9)
|
||||||
|
private String dni;
|
||||||
|
|
||||||
|
@Column(name = "phone", nullable = false, length = 20)
|
||||||
|
private String phone;
|
||||||
|
|
||||||
|
@Column(name = "type", nullable = false)
|
||||||
|
private Byte type;
|
||||||
|
|
||||||
|
@Column(name = "role", nullable = false)
|
||||||
|
private Byte role;
|
||||||
|
|
||||||
|
@Column(name = "notes")
|
||||||
|
private String notes;
|
||||||
|
|
||||||
|
@Column(name = "created_at", nullable = false)
|
||||||
|
private Instant createdAt;
|
||||||
|
|
||||||
|
@Column(name = "assigned_at")
|
||||||
|
private Instant assignedAt;
|
||||||
|
|
||||||
|
@Column(name = "deactivated_at")
|
||||||
|
private Instant deactivatedAt;
|
||||||
|
|
||||||
|
public UUID getUserId() {
|
||||||
|
return userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUserId(UUID userId) {
|
||||||
|
this.userId = userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getMemberNumber() {
|
||||||
|
return memberNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMemberNumber(Integer memberNumber) {
|
||||||
|
this.memberNumber = memberNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getPlotNumber() {
|
||||||
|
return plotNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPlotNumber(Integer plotNumber) {
|
||||||
|
this.plotNumber = plotNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDni() {
|
||||||
|
return dni;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDni(String dni) {
|
||||||
|
this.dni = dni;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPhone() {
|
||||||
|
return phone;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPhone(String phone) {
|
||||||
|
this.phone = phone;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Byte getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(Byte type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Byte getRole() {
|
||||||
|
return role;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRole(Byte role) {
|
||||||
|
this.role = role;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNotes() {
|
||||||
|
return notes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNotes(String notes) {
|
||||||
|
this.notes = notes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Instant getCreatedAt() {
|
||||||
|
return createdAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreatedAt(Instant createdAt) {
|
||||||
|
this.createdAt = createdAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Instant getAssignedAt() {
|
||||||
|
return assignedAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAssignedAt(Instant assignedAt) {
|
||||||
|
this.assignedAt = assignedAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Instant getDeactivatedAt() {
|
||||||
|
return deactivatedAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDeactivatedAt(Instant deactivatedAt) {
|
||||||
|
this.deactivatedAt = deactivatedAt;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,93 @@
|
|||||||
|
package net.miarma.backend.huertos.model;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import jakarta.persistence.Column;
|
||||||
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.Id;
|
||||||
|
import jakarta.persistence.Table;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "huertos_incomes")
|
||||||
|
public class Income {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@Column(name = "income_id", columnDefinition = "BINARY(16)")
|
||||||
|
private UUID incomeId;
|
||||||
|
|
||||||
|
@Column(name = "user_id", columnDefinition = "BINARY(16)", nullable = false)
|
||||||
|
private UUID userId;
|
||||||
|
|
||||||
|
@Column(name = "concept", nullable = false, length = 128)
|
||||||
|
private String concept;
|
||||||
|
|
||||||
|
@Column(name = "amount", nullable = false)
|
||||||
|
private BigDecimal amount;
|
||||||
|
|
||||||
|
@Column(name = "type")
|
||||||
|
private Byte type;
|
||||||
|
|
||||||
|
@Column(name = "frequency")
|
||||||
|
private Byte frequency;
|
||||||
|
|
||||||
|
@Column(name = "created_at", nullable = false)
|
||||||
|
private Instant createdAt;
|
||||||
|
|
||||||
|
public UUID getIncomeId() {
|
||||||
|
return incomeId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIncomeId(UUID incomeId) {
|
||||||
|
this.incomeId = incomeId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UUID getUserId() {
|
||||||
|
return userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUserId(UUID userId) {
|
||||||
|
this.userId = userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getConcept() {
|
||||||
|
return concept;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setConcept(String concept) {
|
||||||
|
this.concept = concept;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getAmount() {
|
||||||
|
return amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAmount(BigDecimal amount) {
|
||||||
|
this.amount = amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Byte getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(Byte type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Byte getFrequency() {
|
||||||
|
return frequency;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFrequency(Byte frequency) {
|
||||||
|
this.frequency = frequency;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Instant getCreatedAt() {
|
||||||
|
return createdAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreatedAt(Instant createdAt) {
|
||||||
|
this.createdAt = createdAt;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,191 @@
|
|||||||
|
package net.miarma.backend.huertos.model;
|
||||||
|
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import jakarta.persistence.Column;
|
||||||
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.Id;
|
||||||
|
import jakarta.persistence.Table;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "huertos_pre_users")
|
||||||
|
public class PreUser {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@Column(name = "pre_user_id", columnDefinition = "BINARY(16)")
|
||||||
|
private UUID preUserId;
|
||||||
|
|
||||||
|
@Column(name = "request_id", columnDefinition = "BINARY(16)", nullable = false)
|
||||||
|
private UUID requestId;
|
||||||
|
|
||||||
|
@Column(name = "user_name", nullable = false, length = 64)
|
||||||
|
private String userName;
|
||||||
|
|
||||||
|
@Column(name = "display_name", nullable = false, length = 128)
|
||||||
|
private String displayName;
|
||||||
|
|
||||||
|
@Column(name = "dni", nullable = false, length = 9)
|
||||||
|
private String dni;
|
||||||
|
|
||||||
|
@Column(name = "phone", nullable = false, length = 20)
|
||||||
|
private String phone;
|
||||||
|
|
||||||
|
@Column(name = "email", nullable = false, length = 128)
|
||||||
|
private String email;
|
||||||
|
|
||||||
|
@Column(name = "password", length = 256)
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
@Column(name = "address", length = 128)
|
||||||
|
private String address;
|
||||||
|
|
||||||
|
@Column(name = "zip_code", length = 10)
|
||||||
|
private String zipCode;
|
||||||
|
|
||||||
|
@Column(name = "city", length = 64)
|
||||||
|
private String city;
|
||||||
|
|
||||||
|
@Column(name = "member_number")
|
||||||
|
private Integer memberNumber;
|
||||||
|
|
||||||
|
@Column(name = "plot_number")
|
||||||
|
private Integer plotNumber;
|
||||||
|
|
||||||
|
@Column(name = "type", nullable = false)
|
||||||
|
private Byte type;
|
||||||
|
|
||||||
|
@Column(name = "role", nullable = false)
|
||||||
|
private Byte role;
|
||||||
|
|
||||||
|
@Column(name = "created_at", nullable = false)
|
||||||
|
private Instant createdAt;
|
||||||
|
|
||||||
|
public UUID getPreUserId() {
|
||||||
|
return preUserId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPreUserId(UUID preUserId) {
|
||||||
|
this.preUserId = preUserId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UUID getRequestId() {
|
||||||
|
return requestId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRequestId(UUID requestId) {
|
||||||
|
this.requestId = requestId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUserName() {
|
||||||
|
return userName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUserName(String userName) {
|
||||||
|
this.userName = userName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDisplayName() {
|
||||||
|
return displayName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDisplayName(String displayName) {
|
||||||
|
this.displayName = displayName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDni() {
|
||||||
|
return dni;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDni(String dni) {
|
||||||
|
this.dni = dni;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPhone() {
|
||||||
|
return phone;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPhone(String phone) {
|
||||||
|
this.phone = phone;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEmail() {
|
||||||
|
return email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEmail(String email) {
|
||||||
|
this.email = email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPassword() {
|
||||||
|
return password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPassword(String password) {
|
||||||
|
this.password = password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAddress() {
|
||||||
|
return address;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAddress(String address) {
|
||||||
|
this.address = address;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getZipCode() {
|
||||||
|
return zipCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setZipCode(String zipCode) {
|
||||||
|
this.zipCode = zipCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCity() {
|
||||||
|
return city;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCity(String city) {
|
||||||
|
this.city = city;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getMemberNumber() {
|
||||||
|
return memberNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMemberNumber(Integer memberNumber) {
|
||||||
|
this.memberNumber = memberNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getPlotNumber() {
|
||||||
|
return plotNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPlotNumber(Integer plotNumber) {
|
||||||
|
this.plotNumber = plotNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Byte getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(Byte type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Byte getRole() {
|
||||||
|
return role;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRole(Byte role) {
|
||||||
|
this.role = role;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Instant getCreatedAt() {
|
||||||
|
return createdAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreatedAt(Instant createdAt) {
|
||||||
|
this.createdAt = createdAt;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
package net.miarma.backend.huertos.model;
|
||||||
|
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import jakarta.persistence.Column;
|
||||||
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.Id;
|
||||||
|
import jakarta.persistence.Table;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "huertos_requests")
|
||||||
|
public class Request {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@Column(name = "request_id", columnDefinition = "BINARY(16)")
|
||||||
|
private UUID requestId;
|
||||||
|
|
||||||
|
@Column(name = "type", nullable = false)
|
||||||
|
private Byte type;
|
||||||
|
|
||||||
|
@Column(name = "status", nullable = false)
|
||||||
|
private Byte status;
|
||||||
|
|
||||||
|
@Column(name = "requested_by", columnDefinition = "BINARY(16)")
|
||||||
|
private UUID requestedBy;
|
||||||
|
|
||||||
|
@Column(name = "target_user_id", columnDefinition = "BINARY(16)")
|
||||||
|
private UUID targetUserId;
|
||||||
|
|
||||||
|
@Column(name = "created_at", nullable = false)
|
||||||
|
private Instant createdAt;
|
||||||
|
|
||||||
|
public UUID getRequestId() {
|
||||||
|
return requestId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRequestId(UUID requestId) {
|
||||||
|
this.requestId = requestId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Byte getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(Byte type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Byte getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(Byte status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UUID getRequestedBy() {
|
||||||
|
return requestedBy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRequestedBy(UUID requestedBy) {
|
||||||
|
this.requestedBy = requestedBy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UUID getTargetUserId() {
|
||||||
|
return targetUserId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTargetUserId(UUID targetUserId) {
|
||||||
|
this.targetUserId = targetUserId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Instant getCreatedAt() {
|
||||||
|
return createdAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreatedAt(Instant createdAt) {
|
||||||
|
this.createdAt = createdAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
47
huertos/src/main/resources/application.yml
Normal file
47
huertos/src/main/resources/application.yml
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
server:
|
||||||
|
port: 8081
|
||||||
|
servlet:
|
||||||
|
context-path: /v2/huertos
|
||||||
|
|
||||||
|
spring:
|
||||||
|
application:
|
||||||
|
name: huertos-service
|
||||||
|
|
||||||
|
datasource:
|
||||||
|
url: jdbc:mariadb://localhost:3306/miarma_v2
|
||||||
|
username: admin
|
||||||
|
password: ositovito
|
||||||
|
driver-class-name: org.mariadb.jdbc.Driver
|
||||||
|
|
||||||
|
jpa:
|
||||||
|
open-in-view: false
|
||||||
|
hibernate:
|
||||||
|
ddl-auto: update
|
||||||
|
show-sql: true
|
||||||
|
properties:
|
||||||
|
hibernate:
|
||||||
|
format_sql: true
|
||||||
|
jdbc:
|
||||||
|
time_zone: UTC
|
||||||
|
dialect: org.hibernate.dialect.MariaDBDialect
|
||||||
|
|
||||||
|
jackson:
|
||||||
|
serialization:
|
||||||
|
INDENT_OUTPUT: true
|
||||||
|
date-format: yyyy-MM-dd'T'HH:mm:ss
|
||||||
|
time-zone: Europe/Madrid
|
||||||
|
default-property-inclusion: non_null
|
||||||
|
generator:
|
||||||
|
WRITE_DATES_AS_TIMESTAMPS: false
|
||||||
|
|
||||||
|
logging:
|
||||||
|
level:
|
||||||
|
org.hibernate.SQL: DEBUG
|
||||||
|
org.hibernate.orm.jdbc.bind: TRACE
|
||||||
|
org.springframework.security: INFO
|
||||||
|
|
||||||
|
management:
|
||||||
|
endpoints:
|
||||||
|
web:
|
||||||
|
exposure:
|
||||||
|
include: health,info
|
||||||
@@ -15,6 +15,11 @@
|
|||||||
<arguments>
|
<arguments>
|
||||||
</arguments>
|
</arguments>
|
||||||
</buildCommand>
|
</buildCommand>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.springframework.ide.eclipse.boot.validation.springbootbuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
</buildSpec>
|
</buildSpec>
|
||||||
<natures>
|
<natures>
|
||||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
boot.validation.initialized=true
|
||||||
|
eclipse.preferences.version=1
|
||||||
@@ -15,6 +15,11 @@
|
|||||||
<arguments>
|
<arguments>
|
||||||
</arguments>
|
</arguments>
|
||||||
</buildCommand>
|
</buildCommand>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.springframework.ide.eclipse.boot.validation.springbootbuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
</buildSpec>
|
</buildSpec>
|
||||||
<natures>
|
<natures>
|
||||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
|
|||||||
2
mpaste/.settings/org.springframework.ide.eclipse.prefs
Normal file
2
mpaste/.settings/org.springframework.ide.eclipse.prefs
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
boot.validation.initialized=true
|
||||||
|
eclipse.preferences.version=1
|
||||||
Reference in New Issue
Block a user