java110
2021-03-04 0c51780582797cc003d59fe483c4e2754b2af577
java110-bean/src/main/java/com/java110/vo/ResultVo.java
@@ -52,7 +52,7 @@
    // 总记录数
    private int total;
    //状态嘛
    //状态
    private int code;
    //错误提示
@@ -60,6 +60,12 @@
    //数据对象
    private Object data;
    //用来存放大计、小计金额
    private Object sumTotal;
    //所需数据
    private Object rep;
    public ResultVo() {
    }
@@ -81,6 +87,25 @@
        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 records, int total, Object data, Object sumTotal, Object rep) {
        this.code = CODE_OK;
        this.msg = MSG_OK;
        this.records = records;
        this.total = total;
        this.data = data;
        this.sumTotal = sumTotal;
        this.rep = rep;
    }
    public ResultVo(int code, String msg, Object data) {
@@ -153,6 +178,22 @@
        this.data = data;
    }
    public Object getSumTotal() {
        return sumTotal;
    }
    public void setSumTotal(Object sumTotal) {
        this.sumTotal = sumTotal;
    }
    public Object getRep() {
        return rep;
    }
    public void setRep(Object rep) {
        this.rep = rep;
    }
    @Override
    public String toString() {
        return JSONObject.toJSONString(this, SerializerFeature.DisableCircularReferenceDetect, SerializerFeature.WriteDateUseDateFormat);
@@ -184,10 +225,22 @@
    /**
     * 成功通用回复
     *
     * @return
     */
    public static ResponseEntity<String> success() {
        ResultVo resultVo = new ResultVo(CODE_OK, MSG_OK);
        ResponseEntity<String> responseEntity = new ResponseEntity<String>(resultVo.toString(), HttpStatus.OK);
        return responseEntity;
    }
    /**
     * 成功通用回复
     *
     * @return
     */
    public static ResponseEntity<String> error(String msg) {
        ResultVo resultVo = new ResultVo(CODE_ERROR, msg);
        ResponseEntity<String> responseEntity = new ResponseEntity<String>(resultVo.toString(), HttpStatus.OK);
        return responseEntity;
    }
@@ -202,6 +255,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;
    }
@@ -261,4 +329,6 @@
        ResponseEntity<String> responseEntity = new ResponseEntity<String>(resultVo.toString(), HttpStatus.OK);
        return responseEntity;
    }
}