java110
2021-01-26 e94845798c7a99fddc364c00a80e76294cf83aa8
java110-bean/src/main/java/com/java110/vo/ResultVo.java
@@ -52,7 +52,7 @@
    // 总记录数
    private int total;
    //状态嘛
    //状态
    private int code;
    //错误提示
@@ -60,6 +60,9 @@
    //数据对象
    private Object data;
    //用来存放大计、小计金额
    private Object sumTotal;
    public ResultVo() {
    }
@@ -81,6 +84,15 @@
        this.records = records;
        this.total = total;
        this.data = data;
    }
    public ResultVo(int records, int total, Object data, Object sumTotal) {
        this.code = CODE_OK;
        this.msg = MSG_OK;
        this.records = records;
        this.total = total;
        this.data = data;
        this.sumTotal = sumTotal;
    }
    public ResultVo(int code, String msg, Object data) {
@@ -153,6 +165,14 @@
        this.data = data;
    }
    public Object getSumTotal() {
        return sumTotal;
    }
    public void setSumTotal(Object sumTotal) {
        this.sumTotal = sumTotal;
    }
    @Override
    public String toString() {
        return JSONObject.toJSONString(this, SerializerFeature.DisableCircularReferenceDetect, SerializerFeature.WriteDateUseDateFormat);
@@ -184,6 +204,7 @@
    /**
     * 成功通用回复
     *
     * @return
     */
    public static ResponseEntity<String> success() {
@@ -194,6 +215,7 @@
    /**
     * 成功通用回复
     *
     * @return
     */
    public static ResponseEntity<String> error(String msg) {
@@ -212,6 +234,21 @@
     */
    public static ResponseEntity<String> createResponseEntity(int records, int total, Object data) {
        ResultVo resultVo = new ResultVo(records, total, data);
        ResponseEntity<String> responseEntity = new ResponseEntity<String>(resultVo.toString(), HttpStatus.OK);
        return responseEntity;
    }
    /**
     * 创建ResponseEntity对象
     *
     * @param records
     * @param total
     * @param data
     * @param sumTotal
     * @return
     */
    public static ResponseEntity<String> createResponseEntity(int records, int total, Object data, Object sumTotal) {
        ResultVo resultVo = new ResultVo(records, total, data, sumTotal);
        ResponseEntity<String> responseEntity = new ResponseEntity<String>(resultVo.toString(), HttpStatus.OK);
        return responseEntity;
    }
@@ -271,4 +308,6 @@
        ResponseEntity<String> responseEntity = new ResponseEntity<String>(resultVo.toString(), HttpStatus.OK);
        return responseEntity;
    }
}