| | |
| | | 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; |
| | |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return JSONObject.toJSONString(this); |
| | | return JSONObject.toJSONString(this, SerializerFeature.DisableCircularReferenceDetect, SerializerFeature.WriteDateUseDateFormat); |
| | | } |
| | | |
| | | |
| | |
| | | */ |
| | | 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; |
| | | } |
| | | |
| | | /** |
| | | * 成功通用回复 |
| | | * @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; |
| | | } |
| | |
| | | /** |
| | | * 创建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 状态嘛 |