Skip to content

Commit

Permalink
Merge pull request #119 from atomfrede/103-put-introspected-on-dtos
Browse files Browse the repository at this point in the history
put introspected on dtos such that they can be validated
  • Loading branch information
JasonTypesCodes authored Jul 19, 2020
2 parents c282e11 + 62d00e6 commit f777d15
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
-%>
package <%= packageName %>.service.dto;
import io.micronaut.core.annotation.Introspected;
<%_
let { importApiModelProperty, importJsonIgnore, importJsonIgnoreProperties, importSet, uniqueEnums } = _processJavaEntityImports(fields, relationships);
_%>
Expand Down Expand Up @@ -69,6 +70,7 @@ import <%= packageName %>.domain.enumeration.<%= element %>;
<%_ if (typeof javadoc !== 'undefined') { _%>
@ApiModel(description = "<%- formatAsApiDescription(javadoc) %>")
<%_ } _%>
@Introspected
public class <%= asDto(entityClass) %> implements Serializable {
private <%= primaryKeyType %> id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,6 @@ import org.springframework.http.HttpStatus; %>
import reactor.core.publisher.Flux;
<%_ } _%>
import javax.annotation.Nullable;
<%_ if (validation) { _%>
import javax.validation.Valid;
<%_ } _%>
import java.net.URI;
import java.net.URISyntaxException;
<%_ if (pagination === 'no' && dto === 'mapstruct' && !viaService && fieldsContainNoOwnerOneToOne === true) { _%>
Expand Down Expand Up @@ -172,7 +169,7 @@ public class <%= entityClass %>Resource {
*/
@Post("/<%= entityApiUrl %>")
@ExecuteOn(TaskExecutors.IO)
public HttpResponse<<%= instanceType %>> create<%= entityClass %>(<% if (validation) { %>@Valid <% } %>@Body <%= instanceType %> <%= instanceName %>) throws URISyntaxException {
public HttpResponse<<%= instanceType %>> create<%= entityClass %>(@Body <%= instanceType %> <%= instanceName %>) throws URISyntaxException {
log.debug("REST request to save <%= entityClass %> : {}", <%= instanceName %>);
if (<%= instanceName %>.getId() != null) {
throw new BadRequestAlertException("A new <%= entityInstance %> cannot already have an ID", ENTITY_NAME, "idexists");
Expand Down Expand Up @@ -212,7 +209,7 @@ public class <%= entityClass %>Resource {
*/
@Put("/<%= entityApiUrl %>")
@ExecuteOn(TaskExecutors.IO)
public HttpResponse<<%= instanceType %>> update<%= entityClass %>(<% if (validation) { %>@Valid <% } %>@Body <%= instanceType %> <%= instanceName %>) throws URISyntaxException {
public HttpResponse<<%= instanceType %>> update<%= entityClass %>(@Body <%= instanceType %> <%= instanceName %>) throws URISyntaxException {
log.debug("REST request to update <%= entityClass %> : {}", <%= instanceName %>);
if (<%= instanceName %>.getId() == null) {
throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull");
Expand Down

0 comments on commit f777d15

Please sign in to comment.