java110
2020-06-20 112692f0627b6250266b4fe64358f26693b26ff6
java110-bean/src/main/java/com/java110/vo/ResultVo.java
@@ -1,6 +1,7 @@
package com.java110.vo;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
@@ -19,7 +20,7 @@
    public static final int CODE_ERROR = 404;// 未知异常
    public static final int CODE_OK = 200; // 成功
    public static final int CODE_OK = 0; // 成功
    public static final int CODE_MACHINE_OK = 0; // 成功
@@ -36,6 +37,9 @@
    public static final String MSG_OK = "成功"; // 成功
    public static final String MSG_UNAUTHORIZED = "认证失败"; //认证失败
    public static final int DEFAULT_RECORD = 1;
    public static final int DEFAULT_TOTAL = 1;
    // 分页页数
    private int page;
@@ -151,7 +155,20 @@
    @Override
    public String toString() {
        return JSONObject.toJSONString(this);
        return JSONObject.toJSONString(this, SerializerFeature.DisableCircularReferenceDetect, SerializerFeature.WriteDateUseDateFormat);
    }
    /**
     * 创建ResponseEntity对象
     *
     * @param data 数据对象
     * @return
     */
    public static ResponseEntity<String> createResponseEntity(Object data) {
        ResultVo resultVo = new ResultVo(DEFAULT_RECORD, DEFAULT_TOTAL, data);
        ResponseEntity<String> responseEntity = new ResponseEntity<String>(resultVo.toString(), HttpStatus.OK);
        return responseEntity;
    }
    /**
@@ -170,13 +187,14 @@
    /**
     * 页面跳转
     *
     * @param url
     * @return
     */
    public static ResponseEntity<String> redirectPage(String url) {
        HttpHeaders headers = new HttpHeaders();
        headers.add(HttpHeaders.LOCATION, url);
        ResponseEntity<String> responseEntity = new ResponseEntity<String>("123123", headers, HttpStatus.BAD_REQUEST);
        ResponseEntity<String> responseEntity = new ResponseEntity<String>("", headers, HttpStatus.FOUND);
        return responseEntity;
    }
@@ -197,6 +215,19 @@
    /**
     * 创建ResponseEntity对象
     *
     * @param code 状态嘛
     * @param msg  返回信息
     * @return
     */
    public static ResponseEntity<String> createResponseEntity(int code, String msg) {
        ResultVo resultVo = new ResultVo(code, msg);
        ResponseEntity<String> responseEntity = new ResponseEntity<String>(resultVo.toString(), HttpStatus.OK);
        return responseEntity;
    }
    /**
     * 创建ResponseEntity对象
     *
     * @param records 页数
     * @param total   总记录数
     * @param code    状态嘛