123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- package com.hywa.banktest.common;
- import com.alibaba.fastjson.JSON;
- import java.util.Collection;
- public class AjaxJson {
- public static final Integer SUCCESS = 0;
- public static final Integer FAILURE = 1;
- public static final String MSGSUCCESS = "操作成功!";
- public static final String MSGFAILURE = "操作失败!";
- public static final String DEAL_CLEARING_APPLY_SUCCESS="处理客户打款请求成功!";
-
-
- private Integer code = SUCCESS;
-
-
- private String msg = "success";
-
- private Object data;
-
- private Integer total =SUCCESS;
- public void setTotal(Integer total) {
- this.total = total;
- }
- public AjaxJson(Object data){
- this.data = data;
-
- }
-
- public AjaxJson(Object data, Integer total){
- this.data = data;
- this.total = total;
-
- }
-
- public AjaxJson(Integer code, String msg, Object data) {
- super();
- this.code = code;
- this.msg = msg;
- this.data = data;
- }
-
- public AjaxJson(Integer code, String msg) {
- super();
- this.code = code;
- this.msg = msg;
- }
- public AjaxJson(ResponseEnum responseEnum){
- super();
- this.code= responseEnum.getCode();
- this.msg = responseEnum.getMsg();
- }
-
- public AjaxJson(){}
-
- @Override
- public String toString() {
-
- if(null ==this.data) {
- this.data = new StringBuilder("当前数据为空!");
- }
- return "AjaxJson [code=" + code + ", msg=" + msg + ", data=" +JSON.toJSONString(data) + ", total=" + total + "]";
- }
- public Integer getCode() {
- return code;
- }
- public String getMsg() {
- return msg;
- }
- public Object getData() {
- return data;
- }
- public Integer getTotal() {
-
-
- if(this.total > 0 ) {
- return this.total;
- }
-
-
- if(data instanceof Collection<?>){
- Collection<?> collection = (Collection<?>)data;
- if(null !=collection && !collection.isEmpty()){
- int size = collection.size();
- this.total = size;
- }
- }
- return this.total;
- }
-
- }
|