一、在ec-common-core 下增加 com.yhh.common.base.ret.ApiResult

  1. package com.yhh.common.base.ret;
  2. import lombok.Data;
  3. import java.io.Serializable;
  4. import java.util.HashMap;
  5. import java.util.Map;
  6. @Data
  7. public class ApiResult implements Serializable {
  8. public static final int SUCCESS_CODE=200;
  9. public static final int ERROR_CODE=200;
  10. public static final int ILLEGAL_CODE=200;
  11. public static final String SUCCESS_MSG="操作成功";
  12. public static final String ERROR_MSG="服务器异常";
  13. public static final String ILLEGAL_MSG="参数非法";
  14. private int code;
  15. private String message;
  16. private Map<String,Object> result = new HashMap<>();
  17. private ApiResult(){}
  18. /**
  19. * 操作成功
  20. * @return
  21. */
  22. public static ApiResult success(){
  23. ApiResult ret = new ApiResult();
  24. ret.code = SUCCESS_CODE;
  25. ret.message = SUCCESS_MSG;
  26. return ret;
  27. }
  28. /**
  29. * 服务器异常
  30. * @return
  31. */
  32. public static ApiResult error(){
  33. ApiResult ret = new ApiResult();
  34. ret.code = ERROR_CODE;
  35. ret.message = ERROR_MSG;
  36. return ret;
  37. }
  38. /**
  39. * 参数非法
  40. * @return
  41. */
  42. public static ApiResult illegal(){
  43. ApiResult ret = new ApiResult();
  44. ret.code = ILLEGAL_CODE;
  45. ret.message = ILLEGAL_MSG;
  46. return ret;
  47. }
  48. public ApiResult put(String key, Object value){
  49. this.result.put(key, value);
  50. return this;
  51. }
  52. public ApiResult setMsg(String msg){
  53. this.message = msg;
  54. return this;
  55. }
  56. }

二、改写sendRegCode 方法

image.png