Gitlab - Argos ALM by PALO IT

Commit c79acb03 authored by Andres Isaac Garcia's avatar Andres Isaac Garcia

Improve upgrading and homologate BD

parent e017f1e1
......@@ -8,6 +8,7 @@ import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
public class MeasureDTO {
private String id;
private String deviceId;
private String value;
private Instant date;
......
......@@ -2,6 +2,6 @@ package com.br.cardif.pocmeasureinternalrest.in.controller.model;
import java.time.Instant;
public record MeasureRequest(String deviceId, String value, Instant date) {
public record MeasureRequest(String id, String deviceId, String value, Instant date) {
}
......@@ -3,6 +3,6 @@ package com.br.cardif.pocmeasureinternalrest.in.controller.model;
import java.io.Serializable;
import java.time.Instant;
public record MeasureResponse(String deviceId, String value, Instant date) implements Serializable {
public record MeasureResponse(String id, String deviceId, String value, Instant date) implements Serializable {
}
......@@ -8,9 +8,11 @@ import com.br.cardif.pocmeasureinternalrest.out.mongo.MeasureDocument;
import com.br.cardif.pocmeasureinternalrest.out.mongo.adapter.MeasureMongoAdapter;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@Service
@RequiredArgsConstructor
@Slf4j
public class MeasureService {
private final MeasureMongoAdapter measureMongoAdapter;
......@@ -18,12 +20,13 @@ public class MeasureService {
public MeasureDTO updateMeasure(MeasureDTO measure){
MeasureDocument document = mapper.documentFromDto(measure);
MeasureDocument documentResult =measureMongoAdapter.save(document);
MeasureDocument documentResult = measureMongoAdapter.save(document);
return mapper.dtoFromDocument(documentResult);
}
public MeasureDTO getMeasure(String deviceId){
MeasureDocument document = measureMongoAdapter.findById(deviceId);
MeasureDocument document = measureMongoAdapter.findByDeviceId(deviceId);
log.info("Measure Id recovered from BD {}", document.getId());
return mapper.dtoFromDocument(document);
}
}
......@@ -10,13 +10,14 @@ import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Document
@Document(collection = "measure")
@Setter
@Getter
@NoArgsConstructor
public class MeasureDocument
{
@Id
private String id;
private String deviceId;
private String value;
private Instant date;
......
......@@ -23,5 +23,9 @@ public class MeasureMongoAdapter {
return repository.findById(deviceId).orElseThrow(() -> new HttpClientErrorException(HttpStatus.NOT_FOUND));
}
public MeasureDocument findByDeviceId(String deviceId) {
return repository.findByDeviceId(deviceId).orElseThrow(() -> new HttpClientErrorException(HttpStatus.NOT_FOUND));
}
}
package com.br.cardif.pocmeasureinternalrest.out.mongo.repo;
import java.util.Optional;
import org.springframework.data.mongodb.repository.MongoRepository;
import com.br.cardif.pocmeasureinternalrest.out.mongo.MeasureDocument;
public interface MeasureMongoRepository extends MongoRepository<MeasureDocument, String> {
Optional<MeasureDocument> findByDeviceId(String deviceId);
}
......@@ -5,10 +5,10 @@ management.endpoint.health.show-components=always
management.endpoint.health.show-details=always
# MongoDB
spring.data.mongodb.uri=mongodb://user:pa55word@localhost/petstore?authSource=admin
spring.data.mongodb.uri=mongodb://user:myPasswordMongo21c@localhost:27017/carrefur-database?authSource=admin
#logs
logging.pattern.level: "%5p [${spring.application.name:},%X{traceId:-},%X{spanId:-}]"
logging.pattern.level=%5p [${spring.application.name:},%X{traceId:-},%X{spanId:-}]
# Actuator
......
......@@ -23,11 +23,3 @@ spring.jackson.visibility.field=any
spring.jackson.visibility.getter=none
spring.jackson.visibility.setter=none
spring.jackson.visibility.is-getter=none
spring.cloud.function.definition=measureConsumer
#Producer
spring.cloud.stream.bindings.measureProducer.destination=measure
# MongoDB
spring.data.mongodb.uri=mongodb://user:pa55word@localhost/petstore?authSource=admin
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment