Commit 5ac447b9 by “zcwang”

change: 返回结构兼容

parent 79664b19
package com.netease.mail.yanxuan.change.biz.meta; package com.netease.mail.yanxuan.change.biz.meta;
import java.util.LinkedHashMap;
/** /**
* @author lwtang * @author lwtang
*/ */
public class AjaxResult extends LinkedHashMap<String, Object> { public class AjaxResult<T> {
private static final long serialVersionUID = 5451316194035153776L; private static final long serialVersionUID = 1L;
private Integer code;
private String msg;
private T data;
private Exception e;
public AjaxResult() { public Boolean isSuccess() {
setCode(ResponseCode.SUCCESS); return this.code.equals(ResponseCodeEnum.SUCCESS.getCode());
}
public Boolean isFail() {
return !this.isSuccess();
}
public static <R> AjaxResult<R> success() {
return of(ResponseCodeEnum.SUCCESS);
}
public static <R> AjaxResult<R> success(R data) {
return of(ResponseCodeEnum.SUCCESS).setData(data);
}
public static <R> AjaxResult<R> error() {
return of(ResponseCodeEnum.INTERNAL_ERROR);
}
public static <R> AjaxResult<R> error(Exception e) {
return of(ResponseCodeEnum.INTERNAL_ERROR).setE(e);
}
public static <R> AjaxResult<R> badRequest() {
return of(ResponseCodeEnum.BAD_REQUEST);
} }
public AjaxResult(int code, String msg) { public static <R> AjaxResult<R> badRequest(String msg) {
setCodeInt(code); return of(ResponseCodeEnum.BAD_REQUEST).setMsg(msg);
put(MSG, msg);
} }
public AjaxResult(ResponseCode responseCode) { public static <R> AjaxResult<R> badRequest(Exception e) {
setCode(responseCode); return of(ResponseCodeEnum.BAD_REQUEST).setE(e);
} }
public AjaxResult(ResponseCode responseCode, Object result) { public static <R> AjaxResult<R> badRequest(String msg, Exception e) {
setCode(responseCode); return of(ResponseCodeEnum.BAD_REQUEST).setMsg(msg).setE(e);
put(RESULT, result);
} }
/** public static <R> AjaxResult<R> of(ResponseCodeEnum code) {
* 响应code,默认<code>ResponseCode.SUCCESS</code> return (new AjaxResult()).setCode(code.getCode()).setMsg(code.getMsg());
*/ }
public static final String CODE = "code";
/** public static <R> AjaxResult<R> of(Integer code, String msg) {
* 消息 return (new AjaxResult()).setCode(code).setMsg(msg);
*/ }
public static final String MSG = "msg";
/** public static <R> AjaxResult<R> of(Integer code, String msg, R data) {
* 结果 return of(code, msg).setData(data);
*/ }
public static final String RESULT = "data";
public static <R> AjaxResult<R> of(Integer code, String msg, R data, Exception e) {
return of(code, msg, data).setE(e);
}
public boolean equals(Object o) {
if (o == this) {
return true;
} else if (!(o instanceof AjaxResult)) {
return false;
} else {
AjaxResult<?> other = (AjaxResult)o;
if (!other.canEqual(this)) {
return false;
} else if (!super.equals(o)) {
return false;
} else {
label61: {
Object this$code = this.getCode();
Object other$code = other.getCode();
if (this$code == null) {
if (other$code == null) {
break label61;
}
} else if (this$code.equals(other$code)) {
break label61;
}
return false;
}
label54: {
Object this$msg = this.getMsg();
Object other$msg = other.getMsg();
if (this$msg == null) {
if (other$msg == null) {
break label54;
}
} else if (this$msg.equals(other$msg)) {
break label54;
}
return false;
}
Object this$data = this.getData();
Object other$data = other.getData();
if (this$data == null) {
if (other$data != null) {
return false;
}
} else if (!this$data.equals(other$data)) {
return false;
}
Object this$e = this.getE();
Object other$e = other.getE();
if (this$e == null) {
if (other$e != null) {
return false;
}
} else if (!this$e.equals(other$e)) {
return false;
}
return true;
}
}
}
protected boolean canEqual(Object other) {
return other instanceof AjaxResult;
}
public int hashCode() {
int PRIME = true;
int result = super.hashCode();
Object $code = this.getCode();
result = result * 59 + ($code == null ? 43 : $code.hashCode());
Object $msg = this.getMsg();
result = result * 59 + ($msg == null ? 43 : $msg.hashCode());
Object $data = this.getData();
result = result * 59 + ($data == null ? 43 : $data.hashCode());
Object $e = this.getE();
result = result * 59 + ($e == null ? 43 : $e.hashCode());
return result;
}
public AjaxResult() {
}
public Integer getCode() {
return this.code;
}
public String getMsg() {
return this.msg;
}
public void setCode(ResponseCode code) { public T getData() {
put(CODE, code.getCode()); return this.data;
} }
public void setMsg(String msg) { public Exception getE() {
put(MSG, msg); return this.e;
} }
public void setCodeInt(int code) { public AjaxResult<T> setCode(Integer code) {
put(CODE, code); this.code = code;
return this;
} }
public ResponseCode getCode() { public AjaxResult<T> setMsg(String msg) {
return (ResponseCode) get(CODE); this.msg = msg;
return this;
} }
public Object getResult() { public AjaxResult<T> setData(T data) {
return (String) get(RESULT); this.data = data;
return this;
} }
public void setResult(Object result) { public AjaxResult<T> setE(Exception e) {
put(RESULT, result); this.e = e;
return this;
} }
public static AjaxResult with(Object result) { public String toString() {
return new AjaxResult(ResponseCode.SUCCESS, result); return "AjaxResult(code=" + this.getCode() + ", msg=" + this.getMsg() + ", data=" + this.getData() + ", e=" + this.getE() + ")";
} }
} }
...@@ -18,7 +18,7 @@ public class AdminChangeConfigServiceImpl implements AdminChangeConfigService { ...@@ -18,7 +18,7 @@ public class AdminChangeConfigServiceImpl implements AdminChangeConfigService {
@Override @Override
public AjaxResult queryChanges(ChangeConfigQueryReq changeConfigQueryReq) { public AjaxResult queryChanges(ChangeConfigQueryReq changeConfigQueryReq) {
if (changeConfigQueryReq == null){ if (changeConfigQueryReq == null){
return AjaxResult.with(ResponseCode.BAD_REQUEST); // return AjaxResult.with(ResponseCode.BAD_REQUEST);
} }
//BeanUtils.copyProperties() 参数转换器 //BeanUtils.copyProperties() 参数转换器
return null; return null;
...@@ -27,7 +27,7 @@ public class AdminChangeConfigServiceImpl implements AdminChangeConfigService { ...@@ -27,7 +27,7 @@ public class AdminChangeConfigServiceImpl implements AdminChangeConfigService {
@Override @Override
public AjaxResult queryDetail(Long id, Long sonChangeClassId) { public AjaxResult queryDetail(Long id, Long sonChangeClassId) {
if (id == null || sonChangeClassId == null){ if (id == null || sonChangeClassId == null){
return AjaxResult.with(ResponseCode.BAD_REQUEST); // return AjaxResult.with(ResponseCode.BAD_REQUEST);
} }
//尝试从reids里面 获取 如果获取到了直接返回 //尝试从reids里面 获取 如果获取到了直接返回
......
/**
* @(#)ChangeFlowController.java, 2022/11/14.
* <p/>
* Copyright 2022 Netease, Inc. All rights reserved.
* NETEASE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
package com.netease.mail.yanxuan.change.web.controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.netease.mail.yanxuan.change.biz.meta.AjaxResult;
/**
* @Author zcwang
* @Date 2022/11/14
*/
@RestController
@RequestMapping("/change/flow")
public class ChangeFlowController {
@GetMapping("/detail")
public AjaxResult<String> detail() {
}
public AjaxResult
}
\ No newline at end of file
...@@ -5,10 +5,15 @@ import com.netease.mail.yanxuan.change.dal.meta.model.po.ChangeConfigPo; ...@@ -5,10 +5,15 @@ import com.netease.mail.yanxuan.change.dal.meta.model.po.ChangeConfigPo;
import java.util.List; import java.util.List;
import lombok.Builder;
import lombok.Data;
/** /**
* @author WangJiaXiang * @author WangJiaXiang
* @date 2022/11/11/011$ * @date 2022/11/11/011$
*/ */
@Data
@Builder
public class ChangeConfigVO { public class ChangeConfigVO {
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment