1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| @Getter @Setter @AllArgsConstructor @NoArgsConstructor public class ResultDTO {
private Integer status; private String msg; private Map<String, Object> body;
public boolean isSuccess() { return status == 200; }
public static ResultDTO success() { return new ResultDTO(200, "OK", new LinkedHashMap<>()); }
public static ResultDTO error(Integer status, String message) { return new ResultDTO(status, message, new LinkedHashMap<>()); }
public ResultDTO add(String key, Object value) { body.put(key, value); return this; }
public ResultDTO addAll(Map<String, Object> map) { body.putAll(map); return this; }
@Override public String toString() { return String.format( "%s(status=%d, msg=%s, body[%s].size=%d", this.getClass().getName(), status, msg, body.getClass().getName(), body.size() ); } }
|