diff --git a/plugins/backend-application-default/src/main/resources/io/zenwave360/sdk/plugins/BackendApplicationDefaultGenerator/src/main/java/core/implementation/mappers/BaseMapper.java.hbs b/plugins/backend-application-default/src/main/resources/io/zenwave360/sdk/plugins/BackendApplicationDefaultGenerator/src/main/java/core/implementation/mappers/BaseMapper.java.hbs index 09c6068f..8c747e51 100644 --- a/plugins/backend-application-default/src/main/resources/io/zenwave360/sdk/plugins/BackendApplicationDefaultGenerator/src/main/java/core/implementation/mappers/BaseMapper.java.hbs +++ b/plugins/backend-application-default/src/main/resources/io/zenwave360/sdk/plugins/BackendApplicationDefaultGenerator/src/main/java/core/implementation/mappers/BaseMapper.java.hbs @@ -3,12 +3,26 @@ package {{coreImplementationPackage}}.mappers; import org.mapstruct.Mapper; import java.time.Instant; +import java.time.LocalDateTime; import java.time.OffsetDateTime; +import java.time.ZoneOffset; @Mapper public interface BaseMapper { - default OffsetDateTime asOffsetDateTime(Instant value) { - return value == null ? null : OffsetDateTime.ofInstant(value, OffsetDateTime.now().getOffset()); + default Instant asInstant(OffsetDateTime date) { + return date != null? date.toInstant() : null; + } + + default OffsetDateTime asOffsetDateTime(Instant date) { + return date != null? OffsetDateTime.ofInstant(date, ZoneOffset.UTC) : null; + } + + default LocalDateTime map(OffsetDateTime value) { + return value != null ? value.toLocalDateTime() : null; + } + + default OffsetDateTime map(LocalDateTime value) { + return value != null ? OffsetDateTime.of(value, ZoneOffset.UTC) : null; } } diff --git a/plugins/backend-application-default/src/main/resources/io/zenwave360/sdk/plugins/BackendApplicationDefaultGenerator/src/main/java/core/implementation/partials/jpa/entities-crud-methodBody.hbs b/plugins/backend-application-default/src/main/resources/io/zenwave360/sdk/plugins/BackendApplicationDefaultGenerator/src/main/java/core/implementation/partials/jpa/entities-crud-methodBody.hbs index e9e3481c..ca96634f 100644 --- a/plugins/backend-application-default/src/main/resources/io/zenwave360/sdk/plugins/BackendApplicationDefaultGenerator/src/main/java/core/implementation/partials/jpa/entities-crud-methodBody.hbs +++ b/plugins/backend-application-default/src/main/resources/io/zenwave360/sdk/plugins/BackendApplicationDefaultGenerator/src/main/java/core/implementation/partials/jpa/entities-crud-methodBody.hbs @@ -3,7 +3,7 @@ log.debug("[CRUD] Request to save {{entity.className}}: {}", input); var {{entity.instanceName}} = {{asInstanceName service.name}}Mapper.update(new {{entity.className}}(), {{{mapperInputCallSignature method.parameter}}}); {{entity.instanceName}} = {{entity.instanceName}}Repository.save({{entity.instanceName}}); - // TODO: you may need to reload the entity here to fetch relationships 'mapped by id' + // TODO: may need to reload the entity to fetch relationships 'mapped by id' {{~> (partial '../withEvents')}} return {{wrapWithMapper entity}}; {{~else if (isCrudMethod 'list' method=method entity=entity )}}