Feito para pegar mais retornos da api do coolify.
This commit is contained in:
@@ -60,4 +60,14 @@ public class CoolifyPersistence {
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CoolifyPersistence{" +
|
||||
"sequence=" + sequence +
|
||||
", nameProject='" + nameProject + '\'' +
|
||||
", uuid='" + uuid + '\'' +
|
||||
", description='" + description + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
package br.com.stackpanel.api.entity.dto;
|
||||
|
||||
public record ApplicationResponse(String name, String uuid) {
|
||||
}
|
||||
@@ -5,5 +5,5 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import java.util.List;
|
||||
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public record CoolifyResponseProjects(List<MysqlResponse> mysqls, List<ServiceResponse> services) {
|
||||
public record CoolifyResponseProjects(List<MysqlResponse> mysqls, List<ServiceResponse> services, List<ApplicationResponse> applications, List<PostgreResponse> postgresqls) {
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
package br.com.stackpanel.api.entity.dto;
|
||||
|
||||
public record PostgreResponse(String name, String uuid, String image) {
|
||||
}
|
||||
@@ -1,10 +1,7 @@
|
||||
package br.com.stackpanel.api.service.impl;
|
||||
|
||||
import br.com.stackpanel.api.entity.CoolifyPersistence;
|
||||
import br.com.stackpanel.api.entity.dto.CoolifyResponse;
|
||||
import br.com.stackpanel.api.entity.dto.CoolifyResponseProjects;
|
||||
import br.com.stackpanel.api.entity.dto.MysqlResponse;
|
||||
import br.com.stackpanel.api.entity.dto.ServiceResponse;
|
||||
import br.com.stackpanel.api.entity.dto.*;
|
||||
import br.com.stackpanel.api.entity.mapper.CoolifyMapper;
|
||||
import br.com.stackpanel.api.integration.CoolifyClient;
|
||||
import br.com.stackpanel.api.repository.CoolifyRepository;
|
||||
@@ -41,16 +38,20 @@ public class CoolifyServiceImpl implements CoolifyService {
|
||||
List<String> dbProjects = repository.buscarListaUuids();
|
||||
|
||||
|
||||
if (!projects.isEmpty()) {
|
||||
projects.stream()
|
||||
.filter(item -> !dbProjects.contains(item.uuid()))
|
||||
.map(mapper::toDomain)
|
||||
.map(this::salvarProjects)
|
||||
.forEach(System.out::println);
|
||||
|
||||
return projects.stream()
|
||||
.filter(item -> !dbProjects.contains(item.uuid()))
|
||||
.map(mapper::toDomain)
|
||||
.map(this::salvarProjects)
|
||||
}
|
||||
|
||||
|
||||
return repository.buscarProjects().stream()
|
||||
.toList();
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -78,7 +79,15 @@ public class CoolifyServiceImpl implements CoolifyService {
|
||||
.flatMap(flat -> flat.services().stream())
|
||||
.toList();
|
||||
|
||||
return new CoolifyResponseProjects(listaDeMysqls, listaDeServices);
|
||||
List<ApplicationResponse> listaDeApplications = buscarPorUuids.stream()
|
||||
.flatMap(item -> item.applications().stream())
|
||||
.toList();
|
||||
|
||||
List<PostgreResponse> listaDePostgreSql = buscarPorUuids.stream()
|
||||
.flatMap(item -> item.postgresqls().stream())
|
||||
.toList();
|
||||
|
||||
return new CoolifyResponseProjects(listaDeMysqls, listaDeServices, listaDeApplications, listaDePostgreSql);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user