| | |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.alibaba.fastjson.serializer.SerializerFeature; |
| | | import org.slf4j.Logger; |
| | | |
| | | import org.springframework.http.HttpHeaders; |
| | | import org.springframework.http.HttpStatus; |
| | | import org.springframework.http.ResponseEntity; |
| | |
| | | * add by wuxw 2020/5/28 |
| | | **/ |
| | | public class ResultVo implements Serializable { |
| | | |
| | | |
| | | |
| | | public static final int CODE_ERROR = 404;// 未知异常 |
| | | |
| | |
| | | public static final int DEFAULT_TOTAL = 1; |
| | | |
| | | public static final int CODE_WAIT_PAY = 41;// 支付未完成 |
| | | |
| | | public static final String EMPTY_ARRAY = "[]"; |
| | | |
| | | // 分页页数 |
| | | private int page; |
| | |
| | | return JSONObject.toJSONString(this, SerializerFeature.DisableCircularReferenceDetect, SerializerFeature.WriteDateUseDateFormat); |
| | | } |
| | | |
| | | public static ResultVo ok(){ |
| | | return new ResultVo(ResultVo.CODE_OK,ResultVo.MSG_OK); |
| | | } |
| | | |
| | | /** |
| | | * 创建ResponseEntity对象 |
| | |
| | | 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,HttpStatus status) { |
| | | ResultVo resultVo = new ResultVo(CODE_ERROR, msg); |
| | | ResponseEntity<String> responseEntity = new ResponseEntity<String>(resultVo.toString(), status); |
| | | return responseEntity; |
| | | } |
| | | |
| | |
| | | * @return |
| | | */ |
| | | public static ResponseEntity<String> redirectPage(String url) { |
| | | |
| | | HttpHeaders headers = new HttpHeaders(); |
| | | headers.add(HttpHeaders.LOCATION, url); |
| | | ResponseEntity<String> responseEntity = new ResponseEntity<String>("", headers, HttpStatus.FOUND); |