parent
798482c9ec
commit
3be168b3b2
@ -0,0 +1,42 @@
|
||||
package com.power.travel.core;
|
||||
|
||||
/**
|
||||
* 响应结果生成工具
|
||||
*/
|
||||
public class ResultGenerator {
|
||||
|
||||
private static final String DEFAULT_SUCCESS_MESSAGE = "SUCCESS";
|
||||
|
||||
|
||||
public static Result genSuccessResult() {
|
||||
return new Result()
|
||||
.setCode(ResultCode.SUCCESS)
|
||||
.setMessage(DEFAULT_SUCCESS_MESSAGE);
|
||||
}
|
||||
|
||||
public static Result genSuccessResult(Object data) {
|
||||
return new Result()
|
||||
.setCode(ResultCode.SUCCESS)
|
||||
.setMessage(DEFAULT_SUCCESS_MESSAGE)
|
||||
.setData(data);
|
||||
}
|
||||
|
||||
public static Result genSuccessMsgResult(String msg) {
|
||||
return new Result()
|
||||
.setCode(ResultCode.SUCCESS)
|
||||
.setMessage(msg);
|
||||
}
|
||||
|
||||
public static Result genFailResult(String message) {
|
||||
return new Result()
|
||||
.setCode(ResultCode.FAIL)
|
||||
.setMessage(message);
|
||||
}
|
||||
|
||||
public static Result genResult(String message) {
|
||||
return new Result()
|
||||
.setCode(ResultCode.DATA_ERROR)
|
||||
.setMessage(message);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in new issue