| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- package com.cyksj.enums;
- import com.cyksj.dto.Result;
- import java.util.Map;
- /**
- * @author chan
- * @className GatewayResponse
- * @date 2020/7/29 3:06 下午
- */
- public enum GatewayResponse {
- /**
- * 成功
- */
- SUCCESS(GatewayApiCode.SUCCESS.getCode(), GatewayApiCode.SUCCESS.getMsg(),Boolean.TRUE),
- /**
- * 失败
- */
- FAIL(GatewayApiCode.METADATA_SYSTEM_ERROR.getCode(), GatewayApiCode.METADATA_SYSTEM_ERROR.getMsg(),Boolean.FALSE);
- GatewayResponse(Integer _code, String _msg, boolean flag) {
- this.code = _code;
- this.msg = _msg;
- this.flag = flag;
- }
- private Integer code;
- private String msg;
- private boolean flag;
- public Integer getCode() {
- return code;
- }
- public String getMsg() {
- return msg;
- }
- public boolean getFlag(){
- return flag;
- }
- public buildGateWay newBuilder() {
- return new buildGateWay(this);
- }
- public class buildGateWay {
- private Integer code;
- private String msg;
- private boolean flag;
- buildGateWay(GatewayResponse response) {
- this.code = response.getCode();
- this.msg = response.getMsg();
- this.flag = response.getFlag();
- }
- public buildGateWay buildGatewayCode(GatewayApiCode gateWayCode) {
- this.code = gateWayCode.getCode();
- this.msg = gateWayCode.getMsg();
- return this;
- }
- public buildGateWay setMsg(String _msg) {
- this.msg = _msg;
- return this;
- }
- public buildGateWay setCode(Integer code) {
- this.code = code;
- return this;
- }
- public <T> Result<T> toResult() {
- return buildMap();
- }
- public <T extends java.io.Serializable> Result<T> toResult(T model) {
- return Result.of(this.code,this.msg,this.flag,model);
- }
- @SuppressWarnings("rawtypes")
- public <T extends java.util.Collection> Result<T> toResult(T model) {
- return Result.of(this.code,this.msg,this.flag,model);
- }
- @SuppressWarnings("rawtypes")
- public <T> Result<T> toResult(T model) {
- return Result.of(this.code,this.msg,this.flag,model);
- }
- @SuppressWarnings("rawtypes")
- public <T extends Map> Result<T> toResult(T model) {
- return Result.of(this.code,this.msg,this.flag,model);
- }
- private <T> Result<T> buildMap() {
- return Result.of(this.code,this.msg,this.flag,null);
- }
- }
- }
|