Skip to content

Commit

Permalink
♻️ refactor: update base model #3
Browse files Browse the repository at this point in the history
  • Loading branch information
pnguyen215 committed Jun 1, 2024
1 parent 7cfc5e9 commit 0cd2444
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package org.unify4j.model.filter;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import org.unify4j.common.Time4j;

import java.io.Serializable;
import java.util.Date;

@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class DateTimeFilter implements Serializable {
public DateTimeFilter() {
super();
}

public DateTimeFilter(Date from, Date to) {
super();
this.from = from;
this.to = to;
}

private Date from;
private Date to;

public Date getFrom() {
return from;
}

public void setFrom(Date from) {
this.from = from;
}

public Date getTo() {
return to;
}

public void setTo(Date to) {
this.to = to;
}

@Override
public String toString() {
return String.format("DateTime filtering { from: '%s', to: '%s' }", Time4j.format(from), Time4j.format(to));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.fasterxml.jackson.annotation.JsonAlias;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.unify4j.common.Json4j;

import java.io.Serializable;

Expand Down Expand Up @@ -52,4 +53,9 @@ public String getLabel() {
public void setLabel(String label) {
this.label = label;
}

@Override
public String toString() {
return String.format("IDecision request { label: '%s', enabled: %s, value: %s }", label, enabled, Json4j.toJson(value));
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package org.unify4j.model.response;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.*;
import org.unify4j.common.Json4j;
import org.unify4j.model.builder.HttpStatusBuilder;

Expand All @@ -16,6 +14,7 @@ public WrapResponse() {
super();
}

@JsonAlias({"code", "http_code", "status_http_code"})
@JsonProperty("status_code")
private int statusCode;
@JsonProperty("message")
Expand Down Expand Up @@ -101,10 +100,12 @@ public void setPagination(PaginationResponse pagination) {
this.pagination = pagination;
}

@JsonIgnore
public boolean isError() {
return this.errors != null;
}

@JsonIgnore
public boolean isSuccess() {
return this.statusCode >= HttpStatusBuilder.OK.getCode() && this.statusCode < HttpStatusBuilder.MULTIPLE_CHOICES.getCode();
}
Expand Down

0 comments on commit 0cd2444

Please sign in to comment.