ApiInfo.java 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. package org.ssssssss.magicapi.model;
  2. import com.fasterxml.jackson.databind.ObjectMapper;
  3. import java.util.Map;
  4. import java.util.Objects;
  5. /**
  6. * 接口信息
  7. */
  8. public class ApiInfo {
  9. public static final String WRAP_REQUEST_PARAMETER = "wrap_request_parameter";
  10. /**
  11. * 接口ID
  12. */
  13. private String id;
  14. /**
  15. * 请求方法
  16. */
  17. private String method;
  18. /**
  19. * 请求路径
  20. */
  21. private String path;
  22. /**
  23. * 脚本内容
  24. */
  25. private String script;
  26. /**
  27. * 接口名称
  28. */
  29. private String name;
  30. /**
  31. * 分组ID
  32. */
  33. private String groupId;
  34. /**
  35. * 设置的请求参数
  36. */
  37. private String parameter;
  38. /**
  39. * 设置的接口选项
  40. */
  41. private String option;
  42. /**
  43. * 输出结果
  44. */
  45. private String responseBody;
  46. /**
  47. * 输出Header
  48. */
  49. private String responseHeader;
  50. /**
  51. * 接口描述
  52. */
  53. private String description;
  54. /**
  55. * 接口选项json->map
  56. */
  57. private Map optionMap;
  58. public String getId() {
  59. return id;
  60. }
  61. public void setId(String id) {
  62. this.id = id;
  63. }
  64. public String getMethod() {
  65. return method;
  66. }
  67. public void setMethod(String method) {
  68. this.method = method;
  69. }
  70. public String getPath() {
  71. return path;
  72. }
  73. public void setPath(String path) {
  74. this.path = path;
  75. }
  76. public String getScript() {
  77. return script;
  78. }
  79. public void setScript(String script) {
  80. this.script = script;
  81. }
  82. public String getName() {
  83. return name;
  84. }
  85. public void setName(String name) {
  86. this.name = name;
  87. }
  88. public String getParameter() {
  89. return parameter;
  90. }
  91. public void setParameter(String parameter) {
  92. this.parameter = parameter;
  93. }
  94. public String getResponseBody() {
  95. return responseBody;
  96. }
  97. public void setResponseBody(String responseBody) {
  98. this.responseBody = responseBody;
  99. }
  100. public String getResponseHeader() {
  101. return responseHeader;
  102. }
  103. public void setResponseHeader(String responseHeader) {
  104. this.responseHeader = responseHeader;
  105. }
  106. public String getGroupId() {
  107. return groupId;
  108. }
  109. public void setGroupId(String groupId) {
  110. this.groupId = groupId;
  111. }
  112. public Map getOptionMap() {
  113. return optionMap;
  114. }
  115. public void setOptionMap(Map optionMap) {
  116. this.optionMap = optionMap;
  117. }
  118. public String getDescription() {
  119. return description;
  120. }
  121. public void setDescription(String description) {
  122. this.description = description;
  123. }
  124. public String getOption() {
  125. return option;
  126. }
  127. public void setOptionValue(String optionValue) {
  128. this.setOption(optionValue);
  129. }
  130. public void setOption(String option) {
  131. this.option = option;
  132. try {
  133. this.optionMap = new ObjectMapper().readValue(option, Map.class);
  134. } catch (Throwable ignored) {
  135. }
  136. }
  137. public Object getOptionValue(String key) {
  138. return this.optionMap != null ? this.optionMap.get(key) : null;
  139. }
  140. @Override
  141. public boolean equals(Object o) {
  142. if (this == o) return true;
  143. if (o == null || getClass() != o.getClass()) return false;
  144. ApiInfo apiInfo = (ApiInfo) o;
  145. return Objects.equals(id, apiInfo.id) &&
  146. Objects.equals(method, apiInfo.method) &&
  147. Objects.equals(path, apiInfo.path) &&
  148. Objects.equals(script, apiInfo.script) &&
  149. Objects.equals(name, apiInfo.name) &&
  150. Objects.equals(groupId, apiInfo.groupId) &&
  151. Objects.equals(parameter, apiInfo.parameter) &&
  152. Objects.equals(option, apiInfo.option) &&
  153. Objects.equals(responseBody, apiInfo.responseBody) &&
  154. Objects.equals(responseHeader, apiInfo.responseHeader);
  155. }
  156. @Override
  157. public int hashCode() {
  158. return Objects.hash(id, method, path, script, name, groupId, parameter, option, responseBody, responseHeader);
  159. }
  160. }