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 Result toResult() { return buildMap(); } public Result toResult(T model) { return Result.of(this.code,this.msg,this.flag,model); } @SuppressWarnings("rawtypes") public Result toResult(T model) { return Result.of(this.code,this.msg,this.flag,model); } @SuppressWarnings("rawtypes") public Result toResult(T model) { return Result.of(this.code,this.msg,this.flag,model); } @SuppressWarnings("rawtypes") public Result toResult(T model) { return Result.of(this.code,this.msg,this.flag,model); } private Result buildMap() { return Result.of(this.code,this.msg,this.flag,null); } } }