From 9867f6d5c5bccfe52b878c344c536905dd6b309e Mon Sep 17 00:00:00 2001 From: riku <risaku@163.com> Date: 星期四, 09 六月 2022 08:48:06 +0800 Subject: [PATCH] 1. 接口文档自动输出 --- src/main/kotlin/cn/flightfeather/supervision/common/api2word/utils/ResponseUtils.java | 44 + src/main/kotlin/cn/flightfeather/supervision/lightshare/web/ComplaintController.kt | 8 src/main/kotlin/cn/flightfeather/supervision/lightshare/web/ItemevaluationController.kt | 29 src/main/kotlin/cn/flightfeather/supervision/lightshare/web/OpenApiWordController.java | 93 ++ src/main/kotlin/cn/flightfeather/supervision/lightshare/web/HazardousWasteController.kt | 7 src/main/kotlin/cn/flightfeather/supervision/lightshare/web/ProblemController.kt | 7 src/main/kotlin/cn/flightfeather/supervision/lightshare/web/NotificationController.kt | 21 src/main/kotlin/cn/flightfeather/supervision/common/score/item/ScoreItem_11.kt | 2 pom.xml | 6 src/main/kotlin/cn/flightfeather/supervision/SupervisionApplication.kt | 2 src/main/kotlin/cn/flightfeather/supervision/config/Swagger2Configuration.kt | 31 src/main/kotlin/cn/flightfeather/supervision/lightshare/web/LedgerController.kt | 53 src/main/kotlin/cn/flightfeather/supervision/common/score/item/ScoreItem_7.kt | 2 src/main/kotlin/cn/flightfeather/supervision/lightshare/service/OpenApiWordService.java | 18 src/main/kotlin/cn/flightfeather/supervision/lightshare/web/VersionController.kt | 12 src/main/kotlin/cn/flightfeather/supervision/common/api2word/model/Table.java | 168 +++ src/main/kotlin/cn/flightfeather/supervision/common/api2word/JavaConfig.java | 47 + src/main/kotlin/cn/flightfeather/supervision/common/api2word/utils/RequestUtils.java | 29 src/main/kotlin/cn/flightfeather/supervision/lightshare/web/EvaluationController.kt | 55 src/main/resources/application-dev.yml | 2 src/main/kotlin/cn/flightfeather/supervision/lightshare/web/DeviceController.kt | 25 src/main/kotlin/cn/flightfeather/supervision/common/api2word/utils/ModelAttrUtils.java | 71 + src/main/kotlin/cn/flightfeather/supervision/common/api2word/model/Request.java | 87 ++ src/main/kotlin/cn/flightfeather/supervision/common/api2word/utils/JsonUtils.java | 66 + src/test/kotlin/cn/flightfeather/supervision/common/score/AutoScoreTest.kt | 2 src/main/kotlin/cn/flightfeather/supervision/lightshare/web/LawController.kt | 28 src/main/kotlin/cn/flightfeather/supervision/lightshare/web/MeetingInfoController.kt | 172 ++- src/main/kotlin/cn/flightfeather/supervision/common/score/item/ScoreItem_5.kt | 4 src/main/kotlin/cn/flightfeather/supervision/lightshare/web/CommitmentController.kt | 17 src/main/kotlin/cn/flightfeather/supervision/lightshare/web/EvaluationruleController.kt | 23 src/main/kotlin/cn/flightfeather/supervision/common/score/AutoScore.kt | 4 src/main/kotlin/cn/flightfeather/supervision/lightshare/service/Impl/OpenApiWordServiceImpl.java | 887 ++++++++++++++++++++ src/main/kotlin/cn/flightfeather/supervision/lightshare/web/UserinfoController.kt | 53 src/main/kotlin/cn/flightfeather/supervision/common/score/item/ScoreItem_8.kt | 2 src/main/kotlin/cn/flightfeather/supervision/common/api2word/model/Response.java | 48 + src/main/kotlin/cn/flightfeather/supervision/common/score/Info.kt | 4 src/main/resources/templates/word.html | 212 ++++ src/main/kotlin/cn/flightfeather/supervision/common/score/item/ScoreItem_6.kt | 6 src/main/kotlin/cn/flightfeather/supervision/lightshare/web/MediafileController.kt | 42 src/main/kotlin/cn/flightfeather/supervision/lightshare/web/EvaluationsubruleController.kt | 15 src/main/kotlin/cn/flightfeather/supervision/common/api2word/model/ModelAttr.java | 107 ++ src/main/kotlin/cn/flightfeather/supervision/lightshare/web/ConsultationController.kt | 7 src/main/resources/application.yml | 5 src/main/kotlin/cn/flightfeather/supervision/common/api2word/utils/MenuUtils.java | 25 44 files changed, 2,309 insertions(+), 239 deletions(-) diff --git a/pom.xml b/pom.xml index 77065b5..eeefac9 100644 --- a/pom.xml +++ b/pom.xml @@ -289,6 +289,12 @@ <version>3.0</version> </dependency> + <dependency> + <groupId>io.springfox</groupId> + <artifactId>springfox-staticdocs</artifactId> + <version>2.6.1</version> + </dependency> + </dependencies> <build> diff --git a/src/main/kotlin/cn/flightfeather/supervision/SupervisionApplication.kt b/src/main/kotlin/cn/flightfeather/supervision/SupervisionApplication.kt index c77e4fc..c339a5a 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/SupervisionApplication.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/SupervisionApplication.kt @@ -21,7 +21,7 @@ @Bean fun runner() = ApplicationRunner { webSocketServer.start() - taskController.run() +// taskController.run() } } diff --git a/src/main/kotlin/cn/flightfeather/supervision/common/api2word/JavaConfig.java b/src/main/kotlin/cn/flightfeather/supervision/common/api2word/JavaConfig.java new file mode 100644 index 0000000..858793e --- /dev/null +++ b/src/main/kotlin/cn/flightfeather/supervision/common/api2word/JavaConfig.java @@ -0,0 +1,47 @@ +package cn.flightfeather.supervision.common.api2word; + +import org.apache.http.conn.ssl.SSLConnectionSocketFactory; +import org.apache.http.conn.ssl.TrustStrategy; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; +import org.springframework.http.converter.StringHttpMessageConverter; +import org.springframework.web.client.RestTemplate; + +import javax.net.ssl.SSLContext; +import java.nio.charset.StandardCharsets; +import java.security.KeyManagementException; +import java.security.KeyStoreException; +import java.security.NoSuchAlgorithmException; +import java.security.cert.X509Certificate; + +/** + * Created by XiuYin.Cui on 2018/6/21. + */ +@Configuration +public class JavaConfig { + + @Bean + public RestTemplate restTemplate() throws KeyStoreException, NoSuchAlgorithmException, KeyManagementException { + TrustStrategy acceptingTrustStrategy = (X509Certificate[] chain, String authType) -> true; + SSLContext sslContext = org.apache.http.ssl.SSLContexts.custom() + .loadTrustMaterial(null, acceptingTrustStrategy) + .build(); + SSLConnectionSocketFactory csf = new SSLConnectionSocketFactory(sslContext); + CloseableHttpClient httpClient = HttpClients.custom() + .setSSLSocketFactory(csf) + .build(); + HttpComponentsClientHttpRequestFactory requestFactory = + new HttpComponentsClientHttpRequestFactory(); + requestFactory.setHttpClient(httpClient); + + //60s + requestFactory.setConnectTimeout(60 * 1000); + requestFactory.setReadTimeout(60 * 1000); + RestTemplate restTemplate = new RestTemplate(requestFactory); + restTemplate.getMessageConverters().set(1, new StringHttpMessageConverter(StandardCharsets.UTF_8)); + return restTemplate; + } +} diff --git a/src/main/kotlin/cn/flightfeather/supervision/common/api2word/model/ModelAttr.java b/src/main/kotlin/cn/flightfeather/supervision/common/api2word/model/ModelAttr.java new file mode 100644 index 0000000..63a078c --- /dev/null +++ b/src/main/kotlin/cn/flightfeather/supervision/common/api2word/model/ModelAttr.java @@ -0,0 +1,107 @@ +package cn.flightfeather.supervision.common.api2word.model; + +import org.apache.commons.lang3.StringUtils; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +/** + * 杩斿洖灞炴�� + * + * @author kevin + */ +public class ModelAttr implements Serializable { + + public String getClassName() { + return className; + } + + public void setClassName(String className) { + this.className = className; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public Boolean getRequire() { + return require; + } + + public void setRequire(Boolean require) { + this.require = require; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public List<ModelAttr> getProperties() { + return properties; + } + + public void setProperties(List<ModelAttr> properties) { + this.properties = properties; + } + + public boolean isCompleted() { + return isCompleted; + } + + public void setCompleted(boolean isCompleted) { + this.isCompleted = isCompleted; + } + + public static long getSerialversionuid() { + return serialVersionUID; + } + + private static final long serialVersionUID = -4074067438450613643L; + + /** + * 绫诲悕 + */ + private String className = StringUtils.EMPTY; + /** + * 灞炴�у悕 + */ + private String name = StringUtils.EMPTY; + /** + * 绫诲瀷 + */ + private String type = StringUtils.EMPTY; + /** + * 鏄惁蹇呭~ + */ + private Boolean require = false; + /** + * 灞炴�ф弿杩� + */ + private String description; + /** + * 宓屽灞炴�у垪琛� + */ + private List<ModelAttr> properties = new ArrayList<>(); + + /** + * 鏄惁鍔犺浇瀹屾垚锛岄伩鍏嶅惊鐜紩鐢� + */ + private boolean isCompleted = false; +} diff --git a/src/main/kotlin/cn/flightfeather/supervision/common/api2word/model/Request.java b/src/main/kotlin/cn/flightfeather/supervision/common/api2word/model/Request.java new file mode 100644 index 0000000..4fc44a8 --- /dev/null +++ b/src/main/kotlin/cn/flightfeather/supervision/common/api2word/model/Request.java @@ -0,0 +1,87 @@ +package cn.flightfeather.supervision.common.api2word.model; + +import java.io.Serializable; + +/** + * Created by XiuYin.Cui on 2018/1/11. + */ +public class Request implements Serializable{ + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getParamType() { + return paramType; + } + + public void setParamType(String paramType) { + this.paramType = paramType; + } + + public Boolean getRequire() { + return require; + } + + public void setRequire(Boolean require) { + this.require = require; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + + public ModelAttr getModelAttr() { + return modelAttr; + } + + public void setModelAttr(ModelAttr modelAttr) { + this.modelAttr = modelAttr; + } + + /** + * 鍙傛暟鍚� + */ + private String name; + + /** + * 鏁版嵁绫诲瀷 + */ + private String type; + + /** + * 鍙傛暟绫诲瀷 + */ + private String paramType; + + /** + * 鏄惁蹇呭~ + */ + private Boolean require; + + /** + * 璇存槑 + */ + private String remark; + + /** + * 澶嶆潅瀵硅薄寮曠敤 + */ + private ModelAttr modelAttr; +} diff --git a/src/main/kotlin/cn/flightfeather/supervision/common/api2word/model/Response.java b/src/main/kotlin/cn/flightfeather/supervision/common/api2word/model/Response.java new file mode 100644 index 0000000..6dc3a1a --- /dev/null +++ b/src/main/kotlin/cn/flightfeather/supervision/common/api2word/model/Response.java @@ -0,0 +1,48 @@ +package cn.flightfeather.supervision.common.api2word.model; + +import java.io.Serializable; + +/** + * Created by XiuYin.Cui on 2018/1/11. + */ +public class Response implements Serializable{ + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + + /** + * 杩斿洖鍙傛暟 + */ + private String description; + + /** + * 鍙傛暟鍚� + */ + private String name; + + /** + * 澶囨敞 + */ + private String remark; +} diff --git a/src/main/kotlin/cn/flightfeather/supervision/common/api2word/model/Table.java b/src/main/kotlin/cn/flightfeather/supervision/common/api2word/model/Table.java new file mode 100644 index 0000000..424a390 --- /dev/null +++ b/src/main/kotlin/cn/flightfeather/supervision/common/api2word/model/Table.java @@ -0,0 +1,168 @@ +package cn.flightfeather.supervision.common.api2word.model; + + +import cn.flightfeather.supervision.common.api2word.model.ModelAttr; +import cn.flightfeather.supervision.common.api2word.model.Request; +import cn.flightfeather.supervision.common.api2word.model.Response; + +import java.util.List; + +/** + * Created by XiuYin.Cui on 2018/1/11. + */ +public class Table { + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getTag() { + return tag; + } + + public void setTag(String tag) { + this.tag = tag; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getRequestForm() { + return requestForm; + } + + public void setRequestForm(String requestForm) { + this.requestForm = requestForm; + } + + public String getResponseForm() { + return responseForm; + } + + public void setResponseForm(String responseForm) { + this.responseForm = responseForm; + } + + public String getRequestType() { + return requestType; + } + + public void setRequestType(String requestType) { + this.requestType = requestType; + } + + public List<Request> getRequestList() { + return requestList; + } + + public void setRequestList(List<Request> requestList) { + this.requestList = requestList; + } + + public List<Response> getResponseList() { + return responseList; + } + + public void setResponseList(List<Response> responseList) { + this.responseList = responseList; + } + + public String getRequestParam() { + return requestParam; + } + + public void setRequestParam(String requestParam) { + this.requestParam = requestParam; + } + + public String getResponseParam() { + return responseParam; + } + + public void setResponseParam(String responseParam) { + this.responseParam = responseParam; + } + + public ModelAttr getModelAttr() { + return modelAttr; + } + + public void setModelAttr(ModelAttr modelAttr) { + this.modelAttr = modelAttr; + } + + /** + * 澶ф爣棰� + */ + private String title; + /** + * 灏忔爣棰� + */ + private String tag; + /** + * url + */ + private String url; + + /** + * 鎻忚堪 + */ + private String description; + + /** + * 璇锋眰鍙傛暟鏍煎紡 + */ + private String requestForm; + + /** + * 鍝嶅簲鍙傛暟鏍煎紡 + */ + private String responseForm; + + /** + * 璇锋眰鏂瑰紡 + */ + private String requestType; + + /** + * 璇锋眰浣� + */ + private List<Request> requestList; + + /** + * 杩斿洖浣� + */ + private List<Response> responseList; + + /** + * 璇锋眰鍙傛暟 + */ + private String requestParam; + + /** + * 杩斿洖鍙傛暟 + */ + private String responseParam; + + /** + * 杩斿洖灞炴�у垪琛� + */ + private ModelAttr modelAttr = new ModelAttr(); +} diff --git a/src/main/kotlin/cn/flightfeather/supervision/common/api2word/utils/JsonUtils.java b/src/main/kotlin/cn/flightfeather/supervision/common/api2word/utils/JsonUtils.java new file mode 100644 index 0000000..1999749 --- /dev/null +++ b/src/main/kotlin/cn/flightfeather/supervision/common/api2word/utils/JsonUtils.java @@ -0,0 +1,66 @@ +package cn.flightfeather.supervision.common.api2word.utils; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.JavaType; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.node.ObjectNode; + +import java.io.IOException; +import java.util.List; + +/** + * @author cuixiuyin + * @Date: 2018/11/05 + */ + +public class JsonUtils { + + private static ObjectMapper objectMapper = new ObjectMapper(); + + static { + objectMapper.setSerializationInclusion(JsonInclude.Include.ALWAYS); + objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + objectMapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true); + objectMapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_CONTROL_CHARS, true); + objectMapper.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true); + } + + public static <T> T readValue(String jsonStr, Class<T> clazz) throws IOException { + return objectMapper.readValue(jsonStr, clazz); + } + + public static <T> List<T> readListValue(String jsonStr, Class<T> clazz) throws IOException { + JavaType javaType = objectMapper.getTypeFactory().constructParametricType(List.class, clazz); + return objectMapper.readValue(jsonStr, javaType); + } + + public static ArrayNode readArray(String jsonStr) throws IOException { + JsonNode node = objectMapper.readTree(jsonStr); + if (node.isArray()) { + return (ArrayNode) node; + } + return null; + } + + public static JsonNode readNode(String jsonStr) throws IOException { + return objectMapper.readTree(jsonStr); + } + + public static String writeJsonStr(Object obj) throws JsonProcessingException { + return objectMapper.writeValueAsString(obj); + } + + public static ObjectNode createObjectNode() { + return objectMapper.createObjectNode(); + } + + public static ArrayNode createArrayNode() { + return objectMapper.createArrayNode(); + } + +} diff --git a/src/main/kotlin/cn/flightfeather/supervision/common/api2word/utils/MenuUtils.java b/src/main/kotlin/cn/flightfeather/supervision/common/api2word/utils/MenuUtils.java new file mode 100644 index 0000000..7e8eb99 --- /dev/null +++ b/src/main/kotlin/cn/flightfeather/supervision/common/api2word/utils/MenuUtils.java @@ -0,0 +1,25 @@ +package cn.flightfeather.supervision.common.api2word.utils; + +/** + * @author : cuixiuyin + * @date : 2019/8/31 + */ +public class MenuUtils { + + public static Integer count = 0; + public static String menuStr = "null"; + + public static boolean isMenu(String tags) { + if (menuStr.equals(tags)) { + count++; + } else { + menuStr = tags; + count = 0; + } + if (count == 0) { + return true; + } else { + return false; + } + } +} diff --git a/src/main/kotlin/cn/flightfeather/supervision/common/api2word/utils/ModelAttrUtils.java b/src/main/kotlin/cn/flightfeather/supervision/common/api2word/utils/ModelAttrUtils.java new file mode 100644 index 0000000..aa0c95c --- /dev/null +++ b/src/main/kotlin/cn/flightfeather/supervision/common/api2word/utils/ModelAttrUtils.java @@ -0,0 +1,71 @@ +package cn.flightfeather.supervision.common.api2word.utils; + +import cn.flightfeather.supervision.common.api2word.model.ModelAttr; +import org.apache.commons.lang3.StringUtils; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +/** + * @author ivenhan + * @Date: 2020/10/15 + */ + +public class ModelAttrUtils { + + // 灏佽schema - properties涓嬫煇涓叿浣損roperty瀵硅薄 + public static ModelAttr propertyModelAttr(Map<String, Map<String, Object>> property) { + ModelAttr modeAttr = new ModelAttr(); + + Map<String, Object> modeProperties = (Map<String, Object>) property.get("properties"); + ArrayList modeRequired = (ArrayList) property.get("required"); + List<ModelAttr> attrList = new ArrayList<>(); + + if (modeProperties != null) { + Iterator<Entry<String, Object>> mIt = modeProperties.entrySet().iterator(); + + //瑙f瀽灞炴�� + while (mIt.hasNext()) { + Entry<String, Object> mEntry = mIt.next(); + Map<String, Object> attrInfoMap = (Map<String, Object>) mEntry.getValue(); + ModelAttr child = new ModelAttr(); + child.setName(mEntry.getKey()); + child.setType((String) attrInfoMap.get("type")); + if (attrInfoMap.get("format") != null) { + child.setType(child.getType() + "(" + attrInfoMap.get("format") + ")"); + } + child.setType(StringUtils.defaultIfBlank(child.getType(), "object")); + + Object ref = attrInfoMap.get("$ref"); + Object items = attrInfoMap.get("items"); + + if (items != null && ((Map) items).get("$ref") == null) { + ModelAttr refModel = propertyModelAttr((Map<String, Map<String, Object>>)items); + if (refModel != null) { + child.setProperties(refModel.getProperties()); + } + child.setType(child.getType()); + } + + child.setDescription((String) attrInfoMap.get("description")); + + child.setRequire(false); + if (modeRequired != null && modeRequired.contains(mEntry.getKey())) { + child.setRequire(true); + } + + attrList.add(child); + } + } + + Object title = property.get("title"); + Object description = property.get("description"); + modeAttr.setClassName(title == null ? "" : title.toString()); + modeAttr.setDescription(description == null ? "" : description.toString()); + modeAttr.setProperties(attrList); + return modeAttr; + } +} \ No newline at end of file diff --git a/src/main/kotlin/cn/flightfeather/supervision/common/api2word/utils/RequestUtils.java b/src/main/kotlin/cn/flightfeather/supervision/common/api2word/utils/RequestUtils.java new file mode 100644 index 0000000..6a6b644 --- /dev/null +++ b/src/main/kotlin/cn/flightfeather/supervision/common/api2word/utils/RequestUtils.java @@ -0,0 +1,29 @@ +package cn.flightfeather.supervision.common.api2word.utils; + +import com.fasterxml.jackson.core.JsonProcessingException; + +import java.util.Map; + + +/** + * @author : ivenhan + * @date : 2020/10/16 + */ +public class RequestUtils { + + public static void validateRequestKey(Map<String, Map> content) throws JsonProcessingException { + Map<String, Map> applicationJSON = content.get("application/json"); + if (applicationJSON == null) { + throw new JsonProcessingException("content瀛楁 缂哄皯 application/json 瀛楁") {}; + } + + Map<String, Map> schema = applicationJSON.get("schema"); + if (schema == null) { + throw new JsonProcessingException("content瀛楁 application/json 缂哄皯 schema 瀛楁") {}; + } + + if (schema.get("type") == null) { + throw new JsonProcessingException("content瀛楁 application/json 瀛楁 schema 瀛楁 缂哄皯 type瀛楁") {}; + } + } +} \ No newline at end of file diff --git a/src/main/kotlin/cn/flightfeather/supervision/common/api2word/utils/ResponseUtils.java b/src/main/kotlin/cn/flightfeather/supervision/common/api2word/utils/ResponseUtils.java new file mode 100644 index 0000000..a574eb9 --- /dev/null +++ b/src/main/kotlin/cn/flightfeather/supervision/common/api2word/utils/ResponseUtils.java @@ -0,0 +1,44 @@ +package cn.flightfeather.supervision.common.api2word.utils; + +import com.fasterxml.jackson.core.JsonProcessingException; + +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +/** + * @author : ivenhan + * @date : 2020/10/16 + */ +public class ResponseUtils { + + public static void validateResponseKey(Map<String, Map> content) throws JsonProcessingException { + Map<String, Map> applicationJSON = content.get("application/json"); + if (applicationJSON == null) { + throw new JsonProcessingException("content 瀛楁缂哄皯 application/json 瀛楁") {}; + } + + Map<String, Map> schema = applicationJSON.get("schema"); + if (schema == null) { + throw new JsonProcessingException("content 瀛楁 application/json 瀛楁 缂哄皯 schema 瀛楁") {}; + } + + if (schema.get("type") == null) { + throw new JsonProcessingException("content 瀛楁 application/json 瀛楁 schema 瀛楁 缂哄皯 type瀛楁") {}; + } + + Map items = schema.get("items"); + Map properties = schema.get("properties"); + if (items == null && properties == null) { + throw new JsonProcessingException("content 瀛楁 application/json 瀛楁 schema 瀛楁 缂哄皯 properties 鎴栬�� items 瀛楁") {}; + } + + + Set<Entry<String, Map>> contentValues = content.entrySet(); + + int size = contentValues.size(); + if ((applicationJSON.get("examples") != null && size > 2) || (applicationJSON.get("examples") == null && size > 1) ) { + throw new JsonProcessingException("content 瀛楁瀛樺湪闄� application/json 鎴栬�� examples 瀛楁涔嬪鐨勫叾浠栧瓧娈�") {}; + } + } +} \ No newline at end of file diff --git a/src/main/kotlin/cn/flightfeather/supervision/common/score/AutoScore.kt b/src/main/kotlin/cn/flightfeather/supervision/common/score/AutoScore.kt index e8a889e..d0305c5 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/common/score/AutoScore.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/common/score/AutoScore.kt @@ -105,6 +105,7 @@ // FIXME: 2021/4/28 鍦烘櫙绫诲瀷 // 姹戒慨绫诲瀷 .andEqualTo("extension2", SCENE_TYPE.value.toString()) + .andEqualTo("isenable", true) // 椁愰ギ绫诲瀷 // .andEqualTo("extension2", SCENE_TYPE.value.toString()) // orderBy("workno") @@ -166,7 +167,8 @@ it.realname, SCENE_TYPE, year, - month + month, + now ) var score = 0 diff --git a/src/main/kotlin/cn/flightfeather/supervision/common/score/Info.kt b/src/main/kotlin/cn/flightfeather/supervision/common/score/Info.kt index 1796410..9c93373 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/common/score/Info.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/common/score/Info.kt @@ -1,6 +1,7 @@ package cn.flightfeather.supervision.common.score import cn.flightfeather.supervision.domain.enumeration.SceneType +import java.time.LocalDate class Info( val userId: String?, @@ -8,5 +9,6 @@ val userName: String?, var sceneType: SceneType, var year: Int, - val month: Int + val month: Int, + val now:LocalDate ) \ No newline at end of file diff --git a/src/main/kotlin/cn/flightfeather/supervision/common/score/item/ScoreItem_11.kt b/src/main/kotlin/cn/flightfeather/supervision/common/score/item/ScoreItem_11.kt index 9808a1c..549f69c 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/common/score/item/ScoreItem_11.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/common/score/item/ScoreItem_11.kt @@ -60,7 +60,7 @@ true } else { val latestTime = LocalDateTime.ofInstant(c[0].cmCreateTime.toInstant(), ZoneId.systemDefault()) - val now = LocalDateTime.of(info.year, eMonth + 1, 1, 0, 0, 0) + val now = LocalDateTime.of(info.year, eMonth, 1, 0, 0, 0).plusMonths(1) now.minusYears(1).isAfter(latestTime) } } diff --git a/src/main/kotlin/cn/flightfeather/supervision/common/score/item/ScoreItem_5.kt b/src/main/kotlin/cn/flightfeather/supervision/common/score/item/ScoreItem_5.kt index 6f1cf1a..acef8d3 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/common/score/item/ScoreItem_5.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/common/score/item/ScoreItem_5.kt @@ -7,6 +7,7 @@ import org.springframework.stereotype.Component import tk.mybatis.mapper.entity.Example import java.time.LocalDate +import java.time.LocalDateTime import java.time.ZoneId import java.util.* import javax.annotation.PostConstruct @@ -33,7 +34,8 @@ override fun calScore(): Pair<Int, Int> { val startTime = LocalDate.of(info.year, sMonth, 1).atStartOfDay(ZoneId.systemDefault()) - val lastTime = LocalDate.of(info.year, eMonth + 1, 1).atStartOfDay(ZoneId.systemDefault()) + val lastTime = LocalDate.of(info.year, eMonth, 1).plusMonths(1).atStartOfDay(ZoneId.systemDefault()) + LocalDateTime.now() val s = Date.from(startTime.toInstant()) val e = Date.from(lastTime.toInstant()) diff --git a/src/main/kotlin/cn/flightfeather/supervision/common/score/item/ScoreItem_6.kt b/src/main/kotlin/cn/flightfeather/supervision/common/score/item/ScoreItem_6.kt index 02e381c..d4557b5 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/common/score/item/ScoreItem_6.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/common/score/item/ScoreItem_6.kt @@ -6,6 +6,8 @@ import org.springframework.beans.factory.annotation.Autowired import org.springframework.stereotype.Component import tk.mybatis.mapper.entity.Example +import java.time.LocalDate +import java.time.ZoneId import javax.annotation.PostConstruct @Component @@ -32,6 +34,8 @@ override var maxScore: Int = 10 override fun calScore(): Pair<Int, Int> { + val startTime = LocalDate.of(info.year, sMonth, 1).atStartOfDay(ZoneId.systemDefault()) + val lastTime = LocalDate.of(info.year, eMonth, 1).plusMonths(1).atStartOfDay(ZoneId.systemDefault()) // FIXME: 2021/4/26 娑夋墽娉曟剰瑙併�佽矗浠ゆ暣鏀规垨琛屾斂澶勭綒,鎵i櫎鍏ㄩ儴鍒嗘暟 val r5 = scoreItem5.execute(info) if (r5.first != 0) { @@ -40,6 +44,8 @@ val complaints = complaintMapper.selectByExample(Example(Complaint::class.java).apply { createCriteria().andEqualTo("cpSceneid", info.userId) + .andGreaterThanOrEqualTo("cpTime", startTime) + .andLessThan("cpTime", lastTime) }) return if (condition1(complaints)) { diff --git a/src/main/kotlin/cn/flightfeather/supervision/common/score/item/ScoreItem_7.kt b/src/main/kotlin/cn/flightfeather/supervision/common/score/item/ScoreItem_7.kt index ea6c3d6..525427a 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/common/score/item/ScoreItem_7.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/common/score/item/ScoreItem_7.kt @@ -40,7 +40,7 @@ } val startTime = LocalDate.of(info.year, sMonth, 1).atStartOfDay(ZoneId.systemDefault()) - val lastTime = LocalDate.of(info.year, eMonth + 1, 1).atStartOfDay(ZoneId.systemDefault()) + val lastTime = LocalDate.of(info.year, eMonth, 1).plusMonths(1).atStartOfDay(ZoneId.systemDefault()) val s = Date.from(startTime.toInstant()) val e = Date.from(lastTime.toInstant()) diff --git a/src/main/kotlin/cn/flightfeather/supervision/common/score/item/ScoreItem_8.kt b/src/main/kotlin/cn/flightfeather/supervision/common/score/item/ScoreItem_8.kt index fcbfe1c..a543e49 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/common/score/item/ScoreItem_8.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/common/score/item/ScoreItem_8.kt @@ -36,7 +36,7 @@ override fun calScore(): Pair<Int, Int> { val startTime = LocalDate.of(info.year, sMonth, 1).atStartOfDay(ZoneId.systemDefault()) - val lastTime = LocalDate.of(info.year, eMonth + 1, 1).atStartOfDay(ZoneId.systemDefault()) + val lastTime = LocalDate.of(info.year, eMonth, 1).plusMonths(1).atStartOfDay(ZoneId.systemDefault()) val s = Date.from(startTime.toInstant()) val e = Date.from(lastTime.toInstant()) diff --git a/src/main/kotlin/cn/flightfeather/supervision/config/Swagger2Configuration.kt b/src/main/kotlin/cn/flightfeather/supervision/config/Swagger2Configuration.kt index ee7b9bf..9e5e1a0 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/config/Swagger2Configuration.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/config/Swagger2Configuration.kt @@ -3,9 +3,14 @@ import org.springframework.beans.factory.annotation.Value import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration +import org.springframework.http.HttpMethod import springfox.documentation.builders.ApiInfoBuilder import springfox.documentation.builders.PathSelectors import springfox.documentation.builders.RequestHandlerSelectors +import springfox.documentation.oas.annotations.EnableOpenApi +import springfox.documentation.schema.ModelReference +import springfox.documentation.service.Header +import springfox.documentation.service.Response import springfox.documentation.spi.DocumentationType import springfox.documentation.spring.web.plugins.Docket import springfox.documentation.swagger2.annotations.EnableSwagger2 @@ -15,7 +20,7 @@ * Date: 2020/8/28 */ @Configuration -@EnableSwagger2 +@EnableOpenApi class Swagger2Configuration { companion object { @@ -29,19 +34,19 @@ @Bean fun createRestApi(): Docket = - Docket(DocumentationType.SWAGGER_2) - .enable(swagger2Enable) - .apiInfo(apiInfo()) - .select() - .apis(RequestHandlerSelectors.basePackage(SWAGGER_SCAN_BASE_PACKAGE)) - .paths(PathSelectors.any()) - .build() + Docket(DocumentationType.OAS_30) + .enable(swagger2Enable) + .apiInfo(apiInfo()) + .select() + .apis(RequestHandlerSelectors.basePackage(SWAGGER_SCAN_BASE_PACKAGE)) + .paths(PathSelectors.any()) + .build() private fun apiInfo() = - ApiInfoBuilder() - .title("椋炵窘鏅鸿兘鐜鏈嶅姟") - .description("椋炵窘鏅鸿兘鐜鏈嶅姟 API 鎺ュ彛鏂囨。") - .version(VERSION) - .build() + ApiInfoBuilder() + .title("椋炵窘鏅鸿兘鐜鏈嶅姟") + .description("椋炵窘鏅鸿兘鐜鏈嶅姟 API 鎺ュ彛鏂囨。") + .version(VERSION) + .build() } \ No newline at end of file diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/Impl/OpenApiWordServiceImpl.java b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/Impl/OpenApiWordServiceImpl.java new file mode 100644 index 0000000..cf4de7c --- /dev/null +++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/Impl/OpenApiWordServiceImpl.java @@ -0,0 +1,887 @@ +package cn.flightfeather.supervision.lightshare.service.Impl; + +import cn.flightfeather.supervision.common.api2word.model.Table; +import cn.flightfeather.supervision.common.api2word.model.ModelAttr; +import cn.flightfeather.supervision.common.api2word.model.Request; +import cn.flightfeather.supervision.common.api2word.model.Response; +import cn.flightfeather.supervision.common.api2word.utils.JsonUtils; +import cn.flightfeather.supervision.common.api2word.utils.RequestUtils; +import cn.flightfeather.supervision.common.api2word.utils.ResponseUtils; +import cn.flightfeather.supervision.lightshare.service.OpenApiWordService; +import com.fasterxml.jackson.core.JsonProcessingException; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; +import org.springframework.web.client.RestTemplate; +import org.springframework.web.multipart.MultipartFile; + +import java.io.IOException; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.*; +import java.util.Map.Entry; +import java.util.stream.Collectors; + +/** + * @Author XiuYin.Cui + * @Date 2018/1/12 + **/ +@SuppressWarnings({"unchecked", "rawtypes"}) +@Service +public class OpenApiWordServiceImpl implements OpenApiWordService { + + @Autowired + private RestTemplate restTemplate; + + @Override + public Map<String, Object> tableList(String swaggerUrl) { + Map<String, Object> resultMap = new HashMap<>(); + try { + String jsonStr = restTemplate.getForObject(swaggerUrl, String.class); + resultMap = tableListFromString(jsonStr); + // log.debug(JsonUtils.writeJsonStr(resultMap)); + } catch (Exception e) { + } + return resultMap; + } + + @Override + public Map<String, Object> tableListFromString(String jsonStr) throws IOException { + Map<String, Object> resultMap = new HashMap<>(); + List<Table> result = new ArrayList<>(); + try { + Map<String, Object> map = getResultFromString(result, jsonStr); + Map<String, List<Table>> tableMap = result.stream().parallel().collect(Collectors.groupingBy(Table::getTitle)); + resultMap.put("tableMap", new TreeMap<>(tableMap)); + resultMap.put("info", map.get("info")); + + // log.debug(JsonUtils.writeJsonStr(resultMap)); + } catch (Exception e) { + throw e; + } + return resultMap; + } + + @Override + public Map<String, Object> tableList(MultipartFile jsonFile) throws IOException { + Map<String, Object> resultMap = new HashMap<>(); + try { + String jsonStr = new String(jsonFile.getBytes()); + resultMap = tableListFromString(jsonStr); + // log.debug(JsonUtils.writeJsonStr(resultMap)); + } catch (Exception e) { + throw e; + } + return resultMap; + } + + private Map<String, Object> getResultFromString(List<Table> result, String jsonStr) throws IOException { + // convert JSON string to Map + Map<String, Object> map = JsonUtils.readValue(jsonStr, HashMap.class); + + //瑙f瀽model + Map<String, ModelAttr> definitinMap = parseComponents(map); + + //瑙f瀽paths + Map<String, Map<String, Object>> paths = (Map<String, Map<String, Object>>) map.get("paths"); + + //鑾峰彇鍏ㄥ眬璇锋眰鍙傛暟鏍煎紡浣滀负榛樿璇锋眰鍙傛暟鏍煎紡 + List<String> defaultConsumes = (List) map.get("consumes"); + + //鑾峰彇鍏ㄥ眬鍝嶅簲鍙傛暟鏍煎紡浣滀负榛樿鍝嶅簲鍙傛暟鏍煎紡 + List<String> defaultProduces = (List) map.get("produces"); + + if (paths != null) { + + Iterator<Entry<String, Map<String, Object>>> it = paths.entrySet().iterator(); + while (it.hasNext()) { + Entry<String, Map<String, Object>> path = it.next(); + + // 0. 鑾峰彇璇ヨ矾鐢变笅鎵�鏈夎姹傛柟寮忕殑鍏叡鍙傛暟 + Map<String, Object> methods = (Map<String, Object>) path.getValue(); + List<LinkedHashMap> commonParameters = (ArrayList) methods.get("parameters"); + + Iterator<Entry<String, Object>> it2 = path.getValue().entrySet().iterator(); + // 1.璇锋眰璺緞 + String url = path.getKey(); + String requestType = null; + while (it2.hasNext()) { + try { + Entry<String, Object> request = it2.next(); + + // 2.璇锋眰鏂瑰紡锛岀被浼间负 get,post,delete,put 杩欐牱 + requestType = request.getKey(); + + if ("parameters".equals(requestType)) { + continue; + } + + Map<String, Object> content = (Map<String, Object>) request.getValue(); + + // 4. 澶ф爣棰橈紙绫昏鏄庯級 + String title = String.valueOf(((List) content.get("tags")).get(0)); + + // 5.灏忔爣棰� 锛堟柟娉曡鏄庯級 + String tag = String.valueOf(content.get("summary")); + + // 6.鎺ュ彛鎻忚堪 + Object descObj = content.get("description"); + String description = descObj == null ? tag : descObj.toString(); + + // 7. 璇锋眰浣� + List<LinkedHashMap> parameters = (ArrayList) content.get("parameters"); + + if (!CollectionUtils.isEmpty(parameters)) { + if (commonParameters != null) { + parameters.addAll(commonParameters); + } + } else { + if (commonParameters != null) { + parameters = commonParameters; + } + } + + // 8.杩斿洖浣� + Map<String, Object> responses = (LinkedHashMap) content.get("responses"); + + // 9.璇锋眰鍙傛暟鏍煎紡锛岀被浼间簬 multipart/form-data + List<String> requestParamsFormates = getRequestParamsFormate(content); + String requestForm = StringUtils.join(requestParamsFormates, ","); + + // 鍙栧嚭鏉ョ姸鎬佹槸200鏃剁殑杩斿洖鍊� + Map<String, Object> obj = (Map<String, Object>) responses.get("200"); + Map<String, Object> requestBody = (Map<String, Object>) content.get("requestBody"); + + // 10.杩斿洖鍙傛暟鏍煎紡锛岀被浼间簬 application/json + List<String> responseParamsFormates = getResponseParamsFormate(obj); + String responseForm = StringUtils.join(responseParamsFormates, ","); + + //灏佽Table + Table table = new Table(); + + table.setTitle(title); + table.setUrl(url); + table.setTag(tag); + table.setDescription(description); + table.setRequestForm(requestForm); + table.setResponseForm(responseForm); + table.setRequestType(requestType); + table.setRequestList(processRequestList(parameters, requestBody, definitinMap)); + + table.setResponseList(processResponseCodeList(responses, definitinMap)); + if (obj != null && obj.get("content") != null) { + table.setModelAttr(processResponseModelAttrs(obj, definitinMap)); + } + + //绀轰緥 + table.setRequestParam(processRequestParam(table.getRequestList())); + table.setResponseParam(processResponseParam1(obj, definitinMap)); + + result.add(table); + } catch (Exception e) { + e.printStackTrace(); +// StringWriter sw = new StringWriter(); +// PrintWriter pw = new PrintWriter(sw); +// e.printStackTrace(pw); +// throw new JsonProcessingException(url + "鎺ュ彛鏍煎紡涓嶆纭�: " + requestType + "璇锋眰 " + e.getMessage()) {}; + } + } + } + } + return map; + } + + /** + * 璇锋眰鍙傛暟鏍煎紡锛� 绫讳技浜� multipart/form-data + */ + private List<String> getRequestParamsFormate(Map<String, Object> obj) { + Map<String, Object> requestBody = (LinkedHashMap) obj.get("requestBody"); + List<String> requestTypes = new ArrayList(); + if (requestBody != null) { + Map<String, Map> content = (LinkedHashMap) requestBody.get("content"); + Set keys = content.keySet(); + return new ArrayList<String>(keys); + } + return requestTypes; + } + + /** + * 杩斿洖鍙傛暟鏍煎紡锛岀被浼间簬 application/json + * @throws Exception + */ + private List<String> getResponseParamsFormate(Map<String, Object> responseObj) { + Map<String, Map> content = (LinkedHashMap) responseObj.get("content"); + List<String> responseTypes = new ArrayList(); + if (content != null) { + Set keys = content.keySet(); + return new ArrayList<String>(keys); + } + return responseTypes; + } + + /** + * 澶勭悊璇锋眰鍙傛暟鍒楄〃 + * + * @param parameters + * @param definitinMap + * @return + * @throws JsonProcessingException + */ + private List<Request> processRequestList(List<LinkedHashMap> parameters, Map<String, Object> requestBody, Map<String, ModelAttr> definitinMap) { + List<Request> requestList = new ArrayList<>(); + if (!CollectionUtils.isEmpty(parameters)) { + for (Map<String, Object> param : parameters) { + Object in = param.get("in"); + Request request = new Request(); + request.setName(String.valueOf(param.get("name"))); + + Map<String, String> schema1 = (Map) param.get("schema"); + + request.setType(schema1 == null ? " " : schema1.get("type").toString()); + // request.setType(param.get("type") == null ? "object" : param.get("type").toString()); + if (param.get("format") != null) { + request.setType(request.getType() + "(" + param.get("format") + ")"); + } + request.setParamType(String.valueOf(in)); + // 鑰冭檻瀵硅薄鍙傛暟绫诲瀷 + if (in != null && "body".equals(in)) { + Map<String, Object> schema = (Map) param.get("schema"); + Object ref = schema.get("$ref"); + // 鏁扮粍鎯呭喌鍙﹀澶勭悊 + if (schema.get("type") != null && "array".equals(schema.get("type"))) { + ref = ((Map) schema.get("items")).get("$ref"); + request.setType("array"); + } + if (ref != null) { + request.setType(request.getType() + ":" + ref.toString().replaceAll("#/definitions/", "")); + request.setModelAttr(definitinMap.get(ref)); + } + } + // 鏄惁蹇呭~ + request.setRequire(false); + if (param.get("required") != null) { + request.setRequire((Boolean) param.get("required")); + } + // 鍙傛暟璇存槑 + request.setRemark(String.valueOf(param.get("description"))); + requestList.add(request); + } + } + + if (requestBody != null) { + Map<String, Map> content = (LinkedHashMap) requestBody.get("content"); + +// try { +// RequestUtils.validateRequestKey(content); +// } catch(Exception e) { +// throw new JsonProcessingException("requestybody 瀛楁 " + e.getMessage()) {}; +// } + + Iterator<Entry<String, Map>> applications = content.entrySet().iterator(); + while (applications.hasNext()) { + Entry<String, Map> application = applications.next(); + + if (application.getValue() != null) { + Request request = new Request(); + + Map<String, Object> schema = (Map<String, Object>) application.getValue().get("schema"); + request.setName(" "); + request.setType(schema == null ? " " : (schema.get("type") == null ? " " : schema.get("type").toString())); + request.setParamType("body"); + + Object ref = schema.get("$ref"); + + if (schema.get("type") != null && "array".equals(schema.get("type"))) { + ref = ((Map) schema.get("items")).get("$ref"); + request.setType("array"); + } + if (ref != null) { + // request.setType(request.getType() + ":" + ref.toString().replaceAll("#/definitions/", "")); + request.setType("object"); + request.setModelAttr(definitinMap.get(ref)); + } + if (schema.get("properties") != null) { + ArrayList<String> requiredArr = new ArrayList<String>(); + if (schema.get("required") != null) { + requiredArr = (ArrayList<String>) schema.get("required"); + } + request.setModelAttr(getRequestSchemaModelAttr(schema, requiredArr)); + } + + // 鏄惁蹇呭~ + request.setRequire(true); + + // 鍙傛暟璇存槑 + requestList.add(request); + } + } + } + return requestList; + } + + + /** + * 澶勭悊杩斿洖鐮佸垪琛� + * + * @param responses 鍏ㄩ儴鐘舵�佺爜杩斿洖瀵硅薄 + * @return + */ + private List<Response> processResponseCodeList(Map<String, Object> responses, Map<String, ModelAttr> definitinMap ) { + List<Response> responseList = new ArrayList<>(); + Iterator<Entry<String, Object>> resIt = responses.entrySet().iterator(); + while (resIt.hasNext()) { + Entry<String, Object> entry = resIt.next(); + Response response = new Response(); + // 鐘舵�佺爜 200 201 401 403 404 杩欐牱 + response.setName(entry.getKey()); + LinkedHashMap<String, Object> statusCodeInfo = (LinkedHashMap) entry.getValue(); + response.setDescription(String.valueOf(statusCodeInfo.get("description"))); + + Map<String, Map> content = (Map) statusCodeInfo.get("content"); + + if (content != null) { +// try { +// ResponseUtils.validateResponseKey(content); +// } catch(Exception e) { +// throw new JsonProcessingException("response瀛楁 " + entry.getKey() + "瀛楁 " + e.getMessage()) {}; +// } + // responses鍐呭application澶氫釜閬嶅巻澶勭悊 + Iterator<Entry<String, Map>> applications = content.entrySet().iterator(); + + while (applications.hasNext()) { + Entry<String, Map> application = applications.next(); + + if (application.getValue() != null) { + Object schema = application.getValue().get("schema"); + if (schema != null) { + Object originalRef = ((LinkedHashMap) schema).get("originalRef"); + response.setRemark(originalRef == null ? "" : originalRef.toString()); + } + responseList.add(response); + } + } + } else { + String ref = String.valueOf(statusCodeInfo.get("$ref")); + + if (ref != "null" && ref != "") { + ModelAttr modelAttr = definitinMap.get(ref); + response.setDescription(modelAttr.getDescription()); + } + + responseList.add(response); + } + } + return responseList; + } + + /** + * 澶勭悊杩斿洖灞炴�у垪琛� + * + * @param responseObj + * @param definitinMap + * @return + */ + private ModelAttr processResponseModelAttrs(Map<String, Object> responseObj, Map<String, ModelAttr> definitinMap) { + Map<String, Map> content = (Map) responseObj.get("content"); + //鍏朵粬绫诲瀷 + ModelAttr modelAttr = new ModelAttr(); + + Iterator<Entry<String, Map>> applications = content.entrySet().iterator(); + + while (applications.hasNext()) { + Entry<String, Map> application = applications.next(); + + if (application.getValue() != null) { + + Map<String, Object> schema = (Map<String, Object>) application.getValue().get("schema"); + String type = (String) schema.get("type"); + String ref = null; + //鏁扮粍 + if ("array".equals(type)) { + Map<String, Object> items = (Map<String, Object>) schema.get("items"); + if (items != null && items.get("$ref") != null) { + ref = (String) items.get("$ref"); + } + } + //瀵硅薄 + if (schema.get("$ref") != null) { + ref = (String) schema.get("$ref"); + } + + //鍏朵粬绫诲瀷 + modelAttr.setType(StringUtils.defaultIfBlank(type, StringUtils.EMPTY)); + + if (StringUtils.isNotBlank(ref) && definitinMap.get(ref) != null) { + modelAttr = definitinMap.get(ref); + } + + // 鏈娇鐢╮ef鏂瑰紡 浣跨敤properties鏂瑰紡 + if (schema.get("properties") != null) { + modelAttr = getSchemaModelAttr(schema); + } + } + } + return modelAttr; + } + + /** + * 瑙f瀽components + * + * @param map + * @return + */ + private Map<String, ModelAttr> parseComponents(Map<String, Object> map) { + Map<String, Object> definitions = (Map<String, Object>) map.get("components"); + Map<String, ModelAttr> definitinMap = new HashMap<>(256); + if (definitions != null) { + Iterator<String> modelNameIt = definitions.keySet().iterator(); + /** + "components": { + "requestBodies": {}, + "schemas": {} + } + */ + while (modelNameIt.hasNext()) { + String modeName = modelNameIt.next(); + /** + "schemas": { + "cat":{}, + "dog":{}, + } + */ + Map<String, Map<String, Object>> modeContent = (Map<String, Map<String, Object>>) definitions.get(modeName); + + if (modeContent != null) { + Iterator<String> modeContentIt = modeContent.keySet().iterator(); + + while (modeContentIt.hasNext()) { + String componentsGrandChildName = modeContentIt.next(); + + getAndPutModelAttr(modeContent, definitinMap, modeName, componentsGrandChildName); + } + } + } + } + return definitinMap; + } + + /** + * 閫掑綊鐢熸垚ModelAttr + * 瀵�$ref绫诲瀷璁剧疆鍏蜂綋灞炴�� + */ + private ModelAttr getAndPutModelAttr(Map<String, Map<String, Object>> swaggerMap, Map<String, ModelAttr> resMap, String parentName, String modeName) { + ModelAttr modeAttr; + if ((modeAttr = resMap.get("#/components/" + parentName + "/" + modeName)) == null) { + modeAttr = new ModelAttr(); + resMap.put("#/components/" + parentName + "/" + modeName, modeAttr); + } else if (resMap.get("#/components/" + parentName + "/" + modeName) != null) { + return resMap.get("#/components/" + parentName + "/" + modeName); + } + Map<String, Object> modeProperties = (Map<String, Object>) swaggerMap.get(modeName).get("properties"); + List<ModelAttr> attrList = new ArrayList<>(); + // 鑾峰彇required瀛楁锛岄亶鍘唒roperties娣诲姞鏄惁蹇呭~灞炴�� + ArrayList modeRequired = (ArrayList) swaggerMap.get(modeName).get("required"); + + if (modeProperties != null) { + Iterator<Entry<String, Object>> mIt = modeProperties.entrySet().iterator(); + + //瑙f瀽灞炴�� + while (mIt.hasNext()) { + Entry<String, Object> mEntry = mIt.next(); + Map<String, Object> attrInfoMap = (Map<String, Object>) mEntry.getValue(); + ModelAttr child = new ModelAttr(); + child.setName(mEntry.getKey()); + child.setType((String) attrInfoMap.get("type")); + if (attrInfoMap.get("format") != null) { + child.setType(child.getType() + "(" + attrInfoMap.get("format") + ")"); + } + child.setType(StringUtils.defaultIfBlank(child.getType(), "object")); + + Object ref = attrInfoMap.get("$ref"); + Object items = attrInfoMap.get("items"); + if (ref != null || (items != null && (ref = ((Map) items).get("$ref")) != null)) { + String refName = ref.toString(); + //鎴彇 #/components/ 鍚庨潰鐨� + String clsName = refName.substring(21); + ModelAttr refModel = getAndPutModelAttr(swaggerMap, resMap, parentName, clsName); + if (refModel != null) { + child.setProperties(refModel.getProperties()); + } + child.setType(child.getType() + ":" + clsName); + } + child.setDescription((String) attrInfoMap.get("description")); + + child.setRequire(false); + if (modeRequired != null && modeRequired.contains(mEntry.getKey())) { + child.setRequire(true); + } + + attrList.add(child); + } + } + + Object title = swaggerMap.get(modeName).get("title"); + Object description = swaggerMap.get(modeName).get("description"); + modeAttr.setClassName(title == null ? "" : title.toString()); + modeAttr.setDescription(description == null ? "" : description.toString()); + modeAttr.setProperties(attrList); + return modeAttr; + } + + /** + * 閫掑綊鐢熸垚ModelAttr + * 澶勭悊schema瀵硅薄 + * 澶勭悊requestBody鐩存帴杩斿洖灞炴�у�兼儏鍐� + */ + private ModelAttr getRequestSchemaModelAttr(Map<String, Object> schemaMap, ArrayList requiredArr) { + ModelAttr modeAttr = new ModelAttr(); + Map<String, Object> modeProperties = (Map<String, Object>) schemaMap.get("properties"); + + if ("array".equals(schemaMap.get("type"))) { + Map items = (Map<String, Object>) schemaMap.get("items"); + + if (items != null) { + modeProperties = (Map<String, Object>) items.get("properties"); + } + } + + if (modeProperties == null) { + return null; + } + Iterator<Entry<String, Object>> mIt = modeProperties.entrySet().iterator(); + + List<ModelAttr> attrList = new ArrayList<>(); + //瑙f瀽灞炴�� + while (mIt.hasNext()) { + Entry<String, Object> mEntry = mIt.next(); + Map<String, Object> attrInfoMap = (Map<String, Object>) mEntry.getValue(); + ModelAttr child = new ModelAttr(); + child.setName(mEntry.getKey()); + child.setType((String) attrInfoMap.get("type")); + if (attrInfoMap.get("format") != null) { + child.setType(child.getType() + "(" + attrInfoMap.get("format") + ")"); + } + child.setType(StringUtils.defaultIfBlank(child.getType(), "object")); + + Object properties = attrInfoMap.get("properties"); + Object ref = attrInfoMap.get("$ref"); + Object items = attrInfoMap.get("items"); + if (properties != null || (items != null)) { + ArrayList<String> childRequiredArr = new ArrayList<String>(); + if (attrInfoMap.get("required") != null) { + childRequiredArr = (ArrayList<String>) attrInfoMap.get("required"); + } + ModelAttr refModel = getRequestSchemaModelAttr(attrInfoMap, childRequiredArr); + if (refModel != null) { + child.setProperties(refModel.getProperties()); + } + child.setType((String) attrInfoMap.get("type")); + } + child.setRequire(true); + if (!requiredArr.contains(mEntry.getKey())) { + child.setRequire(false); + } + child.setDescription((String) attrInfoMap.get("description")); + attrList.add(child); + } + modeAttr.setClassName(""); + modeAttr.setDescription(""); + modeAttr.setProperties(attrList); + return modeAttr; + } + + /** + * 閫掑綊鐢熸垚ModelAttr + * 澶勭悊schema瀵硅薄 + * 澶勭悊responseData鐩存帴杩斿洖灞炴�у�兼儏鍐� + */ + private ModelAttr getSchemaModelAttr(Map<String, Object> schemaMap) { + ModelAttr modeAttr = new ModelAttr(); + Map<String, Object> modeProperties = (Map<String, Object>) schemaMap.get("properties"); + + if ("array".equals(schemaMap.get("type"))) { + Map items = (Map<String, Object>) schemaMap.get("items"); + + if (items != null) { + modeProperties = (Map<String, Object>) items.get("properties"); + } + } + + if (modeProperties == null) { + return null; + } + Iterator<Entry<String, Object>> mIt = modeProperties.entrySet().iterator(); + + List<ModelAttr> attrList = new ArrayList<>(); + //瑙f瀽灞炴�� + while (mIt.hasNext()) { + Entry<String, Object> mEntry = mIt.next(); + Map<String, Object> attrInfoMap = (Map<String, Object>) mEntry.getValue(); + ModelAttr child = new ModelAttr(); + child.setName(mEntry.getKey()); + + child.setType((String) attrInfoMap.get("type")); + if (attrInfoMap.get("format") != null) { + child.setType(child.getType() + "(" + attrInfoMap.get("format") + ")"); + } + child.setType(StringUtils.defaultIfBlank(child.getType(), "object")); + + Object properties = attrInfoMap.get("properties"); + Object ref = attrInfoMap.get("$ref"); + Object items = attrInfoMap.get("items"); + if (properties != null || (items != null)) { + ModelAttr refModel = getSchemaModelAttr(attrInfoMap); + if (refModel != null) { + child.setProperties(refModel.getProperties()); + } + child.setType((String) attrInfoMap.get("type")); + } + child.setDescription((String) attrInfoMap.get("description")); + attrList.add(child); + } + modeAttr.setClassName(""); + modeAttr.setDescription(""); + modeAttr.setProperties(attrList); + return modeAttr; + } + + /** + * 澶勭悊杩斿洖鍊� + * + * @param responseObj + * @return + */ + private String processResponseParam(Map<String, Object> responseObj, Map<String, ModelAttr> definitinMap) throws JsonProcessingException { + Map<String, Map> content = (Map) responseObj.get("content"); + if (content != null) { + Iterator<Entry<String, Map>> applications = content.entrySet().iterator(); + while (applications.hasNext()) { + Entry<String, Map> application = applications.next(); + + if (application.getValue() != null) { + Map<String, Object> applicationContent = (Map<String, Object>) application.getValue(); + if (applicationContent != null) { + Map<String, Object> schema = (Map<String, Object>) applicationContent.get("schema"); + String type = (String) schema.get("type"); + String ref = null; + // 鏁扮粍 + if ("array".equals(type)) { + Map<String, Object> items = (Map<String, Object>) schema.get("items"); + if (items != null && items.get("$ref") != null) { + ref = (String) items.get("$ref"); + } + } + // 瀵硅薄ref + if (schema.get("$ref") != null) { + ref = (String) schema.get("$ref"); + } + if (StringUtils.isNotEmpty(ref)) { + ModelAttr modelAttr = definitinMap.get(ref); + if (modelAttr != null && !CollectionUtils.isEmpty(modelAttr.getProperties())) { + Map<String, Object> responseMap = new HashMap<>(8); + for (ModelAttr subModelAttr : modelAttr.getProperties()) { + responseMap.put(subModelAttr.getName(), getValue(subModelAttr.getType(), subModelAttr)); + } + return JsonUtils.writeJsonStr(responseMap); + } + } + if (schema.get("properties") != null) { + ModelAttr modelAttr = getSchemaModelAttr(schema); + if (modelAttr != null) { + Map<String, Object> responseMap = new HashMap<>(8); + for (ModelAttr subModelAttr : modelAttr.getProperties()) { + responseMap.put(subModelAttr.getName(), getValue(subModelAttr.getType(), subModelAttr)); + } + return JsonUtils.writeJsonStr(responseMap); + } + } + } + } + } + } + return StringUtils.EMPTY; + } + + private String processResponseParam1(Map<String, Object> responseObj, Map<String, ModelAttr> definitinMap) { + Map<String, Map> content = (Map) responseObj.get("content"); + // if (responseObj != null && content.get("application/json") != null) { + if (content != null) { + Iterator<Entry<String, Map>> applications = content.entrySet().iterator(); + while (applications.hasNext()) { + Entry<String, Map> application = applications.next(); + + if (application.getValue() != null) { + Map<String, Map<String, Map>> applicationContent = (Map<String, Map<String, Map>>) application.getValue(); + if (applicationContent != null) { + Map<String, Map> examples = (Map<String, Map>) applicationContent.get("examples"); + + if (examples != null) { + Map<String, Object> responseData = examples.get("response"); + + if (responseData != null) { + Object value = responseData.get("value"); + try { + return JsonUtils.writeJsonStr(value); + } catch (JsonProcessingException e) { + e.printStackTrace(); + } + } + } else { + return ""; + } + + } + } + } + } + return StringUtils.EMPTY; + } + + /** + * 灏佽璇锋眰浣� + * + * @param list + * @return + */ + private String processRequestParam(List<Request> list) { + Map<String, Object> headerMap = new LinkedHashMap<>(); + Map<String, Object> queryMap = new LinkedHashMap<>(); + Map<String, Object> jsonMap = new LinkedHashMap<>(); + if (list != null && list.size() > 0) { + for (Request request : list) { + String name = request.getName(); + String paramType = request.getParamType(); + Object value = getValue(request.getType(), request.getModelAttr()); + switch (paramType) { + case "header": + headerMap.put(name, value); + break; + case "query": + queryMap.put(name, value); + break; + case "path": + queryMap.put(name, value); + break; + case "body": + //TODO 鏍规嵁content-type搴忓垪鍖栨垚涓嶅悓鏍煎紡锛岀洰鍓嶅彧鐢ㄤ簡json + jsonMap.put(name, value); + break; + default: + break; + + } + } + } + String res = ""; + if (!queryMap.isEmpty()) { + res += getUrlParamsByMap(queryMap); + } + if (!headerMap.isEmpty()) { + res += " " + getHeaderByMap(headerMap); + } + if (!jsonMap.isEmpty()) { + if (jsonMap.size() == 1) { + for (Entry<String, Object> entry : jsonMap.entrySet()) { + try { + res += " '" + JsonUtils.writeJsonStr(entry.getValue()) + "'"; + } catch (JsonProcessingException e) { + e.printStackTrace(); + } + } + } else { + try { + res += " '" + JsonUtils.writeJsonStr(jsonMap) + "'"; + } catch (JsonProcessingException e) { + e.printStackTrace(); + } + } + } + return res; + } + + /** + * 渚嬪瓙涓紝瀛楁鐨勯粯璁ゅ�� + * + * @param type 绫诲瀷 + * @param modelAttr 寮曠敤鐨勭被鍨� + * @return + */ + private Object getValue(String type, ModelAttr modelAttr) { + int pos; + if ((pos = type.indexOf(":")) != -1) { + type = type.substring(0, pos); + } + switch (type) { + case "string": + return "string"; + case "string(date-time)": + return "2020/01/01 00:00:00"; + case "integer": + case "integer(int64)": + case "integer(int32)": + return 0; + case "number": + return 0.0; + case "boolean": + return true; + case "file": + return "(binary)"; + case "array": + List list = new ArrayList(); + Map<String, Object> map = new LinkedHashMap<>(); + if (modelAttr != null && !CollectionUtils.isEmpty(modelAttr.getProperties())) { + for (ModelAttr subModelAttr : modelAttr.getProperties()) { + map.put(subModelAttr.getName(), getValue(subModelAttr.getType(), subModelAttr)); + } + } + list.add(map); + return list; + case "object": + map = new LinkedHashMap<>(); + if (modelAttr != null && !CollectionUtils.isEmpty(modelAttr.getProperties())) { + for (ModelAttr subModelAttr : modelAttr.getProperties()) { + map.put(subModelAttr.getName(), getValue(subModelAttr.getType(), subModelAttr)); + } + } + return map; + default: + return null; + } + } + + /** + * 灏唌ap杞崲鎴恥rl + */ + public static String getUrlParamsByMap(Map<String, Object> map) { + if (map == null || map.isEmpty()) { + return ""; + } + StringBuffer sb = new StringBuffer(); + for (Entry<String, Object> entry : map.entrySet()) { + sb.append(entry.getKey() + "=" + entry.getValue()); + sb.append("&"); + } + String s = sb.toString(); + if (s.endsWith("&")) { + s = StringUtils.substringBeforeLast(s, "&"); + } + return s; + } + + /** + * 灏唌ap杞崲鎴恏eader + */ + public static String getHeaderByMap(Map<String, Object> map) { + if (map == null || map.isEmpty()) { + return ""; + } + StringBuffer sb = new StringBuffer(); + for (Entry<String, Object> entry : map.entrySet()) { + sb.append("--header '"); + sb.append(entry.getKey() + ":" + entry.getValue()); + sb.append("'"); + } + return sb.toString(); + } +} \ No newline at end of file diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/OpenApiWordService.java b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/OpenApiWordService.java new file mode 100644 index 0000000..b52c4f8 --- /dev/null +++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/OpenApiWordService.java @@ -0,0 +1,18 @@ +package cn.flightfeather.supervision.lightshare.service; + +import org.springframework.web.multipart.MultipartFile; + +import java.io.IOException; +import java.util.Map; + +/** + * Created by XiuYin.Cui on 2018/1/12. + */ +public interface OpenApiWordService { + + Map<String,Object> tableList(String swaggerUrl); + + Map<String, Object> tableListFromString(String jsonStr) throws IOException; + + Map<String, Object> tableList(MultipartFile jsonFile) throws IOException; +} \ No newline at end of file diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/CommitmentController.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/CommitmentController.kt index a35178d..17184e8 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/CommitmentController.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/CommitmentController.kt @@ -3,6 +3,8 @@ import cn.flightfeather.supervision.lightshare.service.CommitmentService import io.swagger.annotations.Api import io.swagger.annotations.ApiOperation +import io.swagger.annotations.ApiParam +import io.swagger.annotations.ApiResponse import org.springframework.web.bind.annotation.* import org.springframework.web.multipart.MultipartFile import javax.servlet.http.HttpServletResponse @@ -19,16 +21,17 @@ @ApiOperation(value = "鑾峰彇鐢ㄦ埛鎵胯涔�") @GetMapping("/letter") fun getLetterOfCommitment( - @RequestParam("userId") userId: String, - @RequestParam("page") page: Int, - @RequestParam("per_page") perPage: Int, - response: HttpServletResponse + @ApiParam(value = "鐢ㄦ埛id") @RequestParam("userId") userId: String, + @ApiParam(value = "椤电爜") @RequestParam("page") page: Int, + @ApiParam(value = "鍗曢〉鏁版嵁閲�") @RequestParam("per_page") perPage: Int, + response: HttpServletResponse ) = commitmentService.getLetterOfCommitment(userId, page, perPage, response) + @ApiOperation(value = "涓婁紶鎵胯涔�") @PostMapping("/letter/upload") fun uploadLetterOfCommitment( - @RequestParam userId: String, - @RequestParam("params") commitmentVoList: String, - @RequestPart("images") files: Array<MultipartFile> + @ApiParam(value = "鐢ㄦ埛id") @RequestParam userId: String, + @ApiParam(value = "鎵胯涔︿俊鎭痡son") @RequestParam("params") commitmentVoList: String, + @ApiParam(value = "鎵胯涔﹀浘鐗�") @RequestPart("images") files: Array<MultipartFile> ) = commitmentService.uploadLetterOfCommitment(userId, commitmentVoList, files) } \ No newline at end of file diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/ComplaintController.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/ComplaintController.kt index fbb1315..008fec5 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/ComplaintController.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/ComplaintController.kt @@ -3,6 +3,8 @@ import cn.flightfeather.supervision.lightshare.service.ComplaintService import cn.flightfeather.supervision.lightshare.service.ProblemService import io.swagger.annotations.Api +import io.swagger.annotations.ApiOperation +import io.swagger.annotations.ApiParam import org.springframework.web.bind.annotation.GetMapping import org.springframework.web.bind.annotation.RequestMapping import org.springframework.web.bind.annotation.RequestParam @@ -13,13 +15,15 @@ @RequestMapping("/complaint") class ComplaintController(val complaintService: ComplaintService) { + @ApiOperation(value = "鑾峰彇淇¤鎶曡瘔淇℃伅") @GetMapping("") fun getComplaints( - @RequestParam("userId") userId: String + @ApiParam(value = "鐢ㄦ埛id") @RequestParam("userId") userId: String ) = complaintService.getComplaints(userId) + @ApiOperation(value = "鑾峰彇琛屾斂澶勭綒淇℃伅") @GetMapping("/punishment") fun getPunishment( - @RequestParam("userId") userId: String + @ApiParam(value = "鐢ㄦ埛id") @RequestParam("userId") userId: String ) = complaintService.getPunishment(userId) } \ No newline at end of file diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/ConsultationController.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/ConsultationController.kt index d38442d..a21506b 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/ConsultationController.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/ConsultationController.kt @@ -3,6 +3,8 @@ import cn.flightfeather.supervision.domain.entity.OnLineQuestion import cn.flightfeather.supervision.lightshare.service.OnLineQuestionService import io.swagger.annotations.Api +import io.swagger.annotations.ApiOperation +import io.swagger.annotations.ApiParam import org.springframework.web.bind.annotation.* @Api(tags = ["鍦ㄧ嚎鍜ㄨAPI鎺ュ彛"]) @@ -10,9 +12,10 @@ @RequestMapping("/consultation") class ConsultationController(val onLineQuestionService: OnLineQuestionService) { + @ApiOperation(value = "鎻愬嚭鍜ㄨ闂") @PostMapping("/add/{userId}") fun add( - @PathVariable userId: String, - @RequestBody questions: List<OnLineQuestion> + @ApiParam(value = "鐢ㄦ埛id") @PathVariable userId: String, + @ApiParam(value = "鍜ㄨ闂") @RequestBody questions: List<OnLineQuestion> ) = onLineQuestionService.addQuestions(userId, questions) } \ No newline at end of file diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/DeviceController.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/DeviceController.kt index 418d5a7..5f77ef5 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/DeviceController.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/DeviceController.kt @@ -15,46 +15,47 @@ @ApiOperation(value = "鑾峰彇鍑�鍖栬澶囦俊鎭�") @GetMapping("/purify/info") fun getPurifyDeviceInfo( - @RequestParam("userId") userId: String + @ApiParam(value = "鐢ㄦ埛id") @RequestParam("userId") userId: String ) = deviceService.getPurifyDeviceInfo(userId) @ApiOperation(value = "鑾峰彇鐩戞祴璁惧淇℃伅") @GetMapping("/monitor/info") fun getMonitorDeviceInfo( - @RequestParam("userId") userId: String + @ApiParam(value = "鐢ㄦ埛id") @RequestParam("userId") userId: String ) = deviceService.getMonitorDeviceInfo(userId) @ApiOperation(value = "鑾峰彇鐢ㄦ埛鐩戞祴璁惧鐨勫垎閽熸暟鎹�", notes = "鐩墠榛樿杩斿洖鏈�鏂扮殑15鏉℃暟鎹紝鎸夋椂闂村崌搴忔帓鍒�") @GetMapping("/min/value") fun getLatestMinuteValue( - @ApiParam(value = "鐢ㄦ埛id") @RequestParam("userId") userId: String + @ApiParam(value = "鐢ㄦ埛id") @RequestParam("userId") userId: String ) = deviceService.getLatestMinuteValue(userId) @ApiOperation(value = "鑾峰彇鐢ㄦ埛鐩戞祴璁惧鐨勫皬鏃舵暟鎹�", notes = "榛樿杩斿洖鏈�鏂扮殑15灏忔椂鏁版嵁, 鎸夋椂闂村崌搴忔帓鍒�") @GetMapping("/hour/value") fun getLatestHourValue( - @ApiParam(value = "鐢ㄦ埛id") @RequestParam("userId") userId: String + @ApiParam(value = "鐢ㄦ埛id") @RequestParam("userId") userId: String ) = deviceService.getLatestHourValue(userId) + @ApiOperation(value = "鑾峰彇鏈堝害鍧囧�兼暟鎹�") @PostMapping("/avg/mon/value") fun getMonAvgData( - @ApiParam(value = "鐢ㄦ埛id") @RequestParam("userId") userId: String, - @ApiParam(value = "鏃堕棿") @RequestBody timeList: List<DateVo> + @ApiParam(value = "鐢ㄦ埛id") @RequestParam("userId") userId: String, + @ApiParam(value = "鏃堕棿") @RequestBody timeList: List<DateVo> ) = deviceService.getMonAvgData(userId, timeList) @ApiOperation(value = "鑾峰彇鐢ㄦ埛鐩戞祴璁惧鐨勫巻鍙叉暟鎹�", notes = "") @GetMapping("/history/value") fun getHistoryValue( - @ApiParam(value = "鐢ㄦ埛id") @RequestParam("userId") userId: String, - @ApiParam(value = "寮�濮嬫椂闂�", example = "yyyy-MM-dd HH:mm") @RequestParam("startTime") startTime: String, - @ApiParam(value = "缁撴潫鏃堕棿", example = "yyyy-MM-dd HH:mm") @RequestParam("endTime") endTime: String, - @ApiParam(value = "閲囨牱鍛ㄦ湡, 0锛氬垎閽熷潎鍊�;1锛氬皬鏃跺潎鍊�;(鐩墠鍙敮鎸佸垎閽熷潎鍊�)", allowableValues = "0") @RequestParam("period") period: Byte + @ApiParam(value = "鐢ㄦ埛id") @RequestParam("userId") userId: String, + @ApiParam(value = "寮�濮嬫椂闂�", example = "yyyy-MM-dd HH:mm") @RequestParam("startTime") startTime: String, + @ApiParam(value = "缁撴潫鏃堕棿", example = "yyyy-MM-dd HH:mm") @RequestParam("endTime") endTime: String, + @ApiParam(value = "閲囨牱鍛ㄦ湡", example = "0锛氬垎閽熷潎鍊硷紱1锛氬皬鏃跺潎鍊�;(鐩墠鍙敮鎸佸垎閽熷潎鍊�)") @RequestParam("period") period: Byte ) = deviceService.getHistoryValue(userId, startTime, endTime, period) @ApiOperation(value = "鑾峰彇姣忎釜鐩戞祴璁惧鐨勬渶鏂板垎閽熸暟鎹�", notes = "") @GetMapping("/min/value/real_time") fun getRealTimeData( - @ApiParam(value = "椤垫暟") @RequestParam("page") page: Int, - @ApiParam(value = "姣忛〉鏁版嵁閲�") @RequestParam("per_page") perPage: Int + @ApiParam(value = "椤垫暟") @RequestParam("page") page: Int, + @ApiParam(value = "姣忛〉鏁版嵁閲�") @RequestParam("per_page") perPage: Int ) = deviceService.getRealTimeData(page, perPage) } \ No newline at end of file diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/EvaluationController.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/EvaluationController.kt index 0fc9347..bf504b5 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/EvaluationController.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/EvaluationController.kt @@ -4,6 +4,8 @@ import cn.flightfeather.supervision.lightshare.service.EvaluationService import cn.flightfeather.supervision.lightshare.vo.AssessmentSearchCondition import io.swagger.annotations.Api +import io.swagger.annotations.ApiOperation +import io.swagger.annotations.ApiParam import org.springframework.web.bind.annotation.* import javax.servlet.http.HttpServletResponse @@ -11,52 +13,63 @@ @RestController @RequestMapping("/evaluation") class EvaluationController(val evaluationService: EvaluationService) { + @ApiOperation(value = "鑾峰彇鎵�鏈夎瘎浼版�诲垎") @GetMapping fun getAll() = evaluationService.findAll() + @ApiOperation(value = "涓婁紶涓�鏉¤瘎浼版�诲垎璁板綍") @PutMapping - fun add(@RequestBody evaluation: Evaluation) = evaluationService.save(evaluation) + fun add( + @ApiParam(value = "璇勪及鏁版嵁") @RequestBody evaluation: Evaluation + ) = evaluationService.save(evaluation) + @ApiOperation(value = "鏇存柊涓�鏉¤瘎浼版�诲垎璁板綍") @PostMapping - fun update(@RequestBody evaluation: Evaluation) = evaluationService.update(evaluation) + fun update(@ApiParam(value = "璇勪及鏁版嵁") @RequestBody evaluation: Evaluation) = evaluationService.update(evaluation) + @ApiOperation(value = "鏌ユ壘涓�鏉¤瘎浼版�诲垎璁板綍") @GetMapping("/{id}") - fun getById(@PathVariable id: String) = evaluationService.findOne(id) + fun getById(@ApiParam(value = "璇勪及淇℃伅涓婚敭id") @PathVariable id: String) = evaluationService.findOne(id) + @ApiOperation(value = "鍒犻櫎涓�鏉¤瘎浼版�诲垎璁板綍") @DeleteMapping("/{id}") - fun delete(@PathVariable id: String) = evaluationService.delete(id) + fun delete(@ApiParam(value = "璇勪及淇℃伅涓婚敭id") @PathVariable id: String) = evaluationService.delete(id) + @ApiOperation(value = "鏍规嵁鏉′欢鏌ヨ璇勪及鎬诲垎") @GetMapping("/totalPoint/{userId}") fun getT( - @PathVariable("userId") userId: String, - @RequestParam("evaluatorType") evaluatorType: Int, - @RequestParam("startTime") startTime: String, - @RequestParam("endTime") endTime: String, - @RequestParam("sceneTypeId", required = false) sceneTypeId: Int?, - @RequestParam("erGuid", required = false) erGuid: String?, - @RequestParam("eId", required = false) eId: String? + @ApiParam(value = "鐢ㄦ埛id") @PathVariable("userId") userId: String, + @ApiParam(value = "璇勪及绫诲瀷") @RequestParam("evaluatorType") evaluatorType: Int, + @ApiParam(value = "寮�濮嬫椂闂�") @RequestParam("startTime") startTime: String, + @ApiParam(value = "缁撴潫鏃堕棿") @RequestParam("endTime") endTime: String, + @ApiParam(value = "鍦烘櫙绫诲瀷id") @RequestParam("sceneTypeId", required = false) sceneTypeId: Int?, + @ApiParam(value = "瀛愪换鍔d") @RequestParam("erGuid", required = false) erGuid: String?, + @ApiParam(value = "璇勪及淇℃伅涓婚敭id") @RequestParam("eId", required = false) eId: String? ) = evaluationService.getTotalPoints(userId, evaluatorType, startTime, endTime, sceneTypeId, erGuid, eId) + @ApiOperation(value = "鑾峰彇鐢ㄦ埛璇勪及鎬诲垎") @GetMapping("/historyPoint/{userId}") fun getHistoryPoint( - @PathVariable("userId") userId: String, - @RequestParam(value = "page") page: Int, - @RequestParam(value = "per_page") perPage: Int, - response: HttpServletResponse + @ApiParam(value = "鐢ㄦ埛id") @PathVariable("userId") userId: String, + @ApiParam(value = "椤电爜") @RequestParam(value = "page") page: Int, + @ApiParam(value = "鍗曢〉鏁版嵁閲�") @RequestParam(value = "per_page") perPage: Int, + response: HttpServletResponse ) = evaluationService.getHistoryPoint(userId, page, perPage, response) + @ApiOperation(value = "鑾峰彇淇$敤璇勪及缁撴灉") @GetMapping("/creditInfo") fun getCreditInfo( - @RequestParam("userId") userId: String + @ApiParam(value = "鐢ㄦ埛id") @RequestParam("userId") userId: String ) = evaluationService.getCreditInfo(userId) + @ApiOperation(value = "鑾峰彇鏌愪釜鐢ㄦ埛鐨勪俊鐢ㄨ瘎浼扮粨鏋�") @PostMapping("/search/{userId}") fun getAssessments( - @PathVariable("userId") userId: String, - @RequestBody condition: AssessmentSearchCondition, - @RequestParam(value = "page") page: Int, - @RequestParam(value = "per_page") perPage: Int, - response: HttpServletResponse + @ApiParam(value = "鐢ㄦ埛id") @PathVariable("userId") userId: String, + @ApiParam(value = "鏌ヨ鏉′欢") @RequestBody condition: AssessmentSearchCondition, + @ApiParam(value = "椤电爜") @RequestParam(value = "page") page: Int, + @ApiParam(value = "鍗曢〉鏁版嵁閲�") @RequestParam(value = "per_page") perPage: Int, + response: HttpServletResponse ) = evaluationService.getAssessments(userId, condition, page, perPage, response) fun autoScore( diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/EvaluationruleController.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/EvaluationruleController.kt index 65d5dbf..9cbde86 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/EvaluationruleController.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/EvaluationruleController.kt @@ -3,33 +3,42 @@ import cn.flightfeather.supervision.domain.entity.Evaluationrule import cn.flightfeather.supervision.lightshare.service.EvaluationruleService import io.swagger.annotations.Api +import io.swagger.annotations.ApiOperation import io.swagger.annotations.ApiParam import org.springframework.web.bind.annotation.* +import springfox.documentation.annotations.ApiIgnore @Api(tags = ["璇勫垎鎬昏鍒橝PI鎺ュ彛"]) @RestController @RequestMapping("/evaluationrule") class EvaluationruleController (val evaluationruleService: EvaluationruleService){ + @ApiOperation(value = "鑾峰彇璇勫垎瑙勫垯琛�") @GetMapping("/rule") fun getRules( - @RequestParam(value = "erGuid", required = false) erGuid: String?, - @RequestParam(value = "sceneTypeId", required = true) sceneTypeId: Int, - @ApiParam(value = "璇勫垎琛ㄧ被鍨�", allowableValues = "null/0: 鎵嬪姩璇勫垎锛�1锛氳嚜鍔ㄨ瘎鍒�") @RequestParam(value = "erType", required = false) erType: Int?) - = evaluationruleService.getRule(erGuid, sceneTypeId, erType) + @ApiParam(value = "瑙勫垯涓婚敭id") @RequestParam(value = "erGuid", required = false) erGuid: String?, + @ApiParam(value = "鍦烘櫙绫诲瀷id") @RequestParam(value = "sceneTypeId", required = true) sceneTypeId: Int, + @ApiParam(value = "璇勫垎琛ㄧ被鍨�", allowableValues = "null, 0, 1") @RequestParam(value = "erType", required = false) erType: Int?) + = evaluationruleService.getRule(erGuid, sceneTypeId, erType) + @ApiOperation(value = "鑾峰彇鎵�鏈夎瘎鍒嗚鍒欒〃") @GetMapping fun getAll() = evaluationruleService.findAll() + @ApiOperation(value = "涓婁紶璇勫垎瑙勫垯琛�") @PutMapping - fun add(@RequestBody evaluationrule: Evaluationrule) = evaluationruleService.save(evaluationrule) + fun add(@ApiParam(value = "璇勫垎瑙勫垯") @RequestBody evaluationrule: Evaluationrule) = evaluationruleService.save(evaluationrule) + @ApiOperation(value = "鏇存柊璇勫垎瑙勫垯琛�") @PostMapping - fun update(@RequestBody evaluationrule: Evaluationrule) = evaluationruleService.update(evaluationrule) + fun update(@ApiParam(value = "璇勫垎瑙勫垯") @RequestBody evaluationrule: Evaluationrule) = evaluationruleService.update(evaluationrule) + @ApiOperation(value = "鏌ユ壘璇勫垎瑙勫垯琛�") @GetMapping("/{id}") - fun getById(@PathVariable id:String) = evaluationruleService.findOne(id) + fun getById(@ApiParam(value = "璇勫垎瑙勫垯琛╥d") @PathVariable id:String) = evaluationruleService.findOne(id) + @ApiIgnore + @ApiOperation(value = "鍒犻櫎璇勫垎瑙勫垯琛�") @DeleteMapping("/{id}") fun delete (@PathVariable id: String) = evaluationruleService.delete(id) } \ No newline at end of file diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/EvaluationsubruleController.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/EvaluationsubruleController.kt index b5bb823..19e0088 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/EvaluationsubruleController.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/EvaluationsubruleController.kt @@ -3,24 +3,33 @@ import cn.flightfeather.supervision.domain.entity.Evaluationsubrule import cn.flightfeather.supervision.lightshare.service.EvaluationsubruleService import io.swagger.annotations.Api +import io.swagger.annotations.ApiOperation +import io.swagger.annotations.ApiParam import org.springframework.web.bind.annotation.* +import springfox.documentation.annotations.ApiIgnore @Api(tags = ["璇勫垎瀛愯鍒橝PI鎺ュ彛"]) @RestController @RequestMapping("/evaluationsubrule") class EvaluationsubruleController (val evaluationsubruleService: EvaluationsubruleService) { + @ApiOperation(value = "鑾峰彇鎵�鏈夎瘎鍒嗚鍒欏瓙椤硅〃") @GetMapping fun getAll() = evaluationsubruleService.findAll() + @ApiOperation(value = "涓婁紶璇勫垎瑙勫垯瀛愰」琛�") @PutMapping - fun add(@RequestBody evaluationsubrule: Evaluationsubrule) = evaluationsubruleService.save(evaluationsubrule) + fun add(@ApiParam(value = "璇勫垎瑙勫垯瀛愰」琛�") @RequestBody evaluationsubrule: Evaluationsubrule) = evaluationsubruleService.save(evaluationsubrule) + @ApiOperation(value = "鏇存柊璇勫垎瑙勫垯瀛愰」琛�") @PostMapping - fun update(@RequestBody evaluationsubrule: Evaluationsubrule) = evaluationsubruleService.update(evaluationsubrule) + fun update(@ApiParam(value = "璇勫垎瑙勫垯瀛愰」琛�") @RequestBody evaluationsubrule: Evaluationsubrule) = evaluationsubruleService.update(evaluationsubrule) + @ApiOperation(value = "鏌ユ壘璇勫垎瑙勫垯瀛愰」琛�") @GetMapping("/{ruleId}") - fun getById(@PathVariable ruleId:String) = evaluationsubruleService.findByRuleId(ruleId) + fun getById(@ApiParam(value = "璇勫垎瑙勫垯瀛愰」琛╥d") @PathVariable ruleId:String) = evaluationsubruleService.findByRuleId(ruleId) + @ApiIgnore + @ApiOperation(value = "鍒犻櫎璇勫垎瑙勫垯瀛愰」琛�") @DeleteMapping("/{id}") fun delete (@PathVariable id: String) = evaluationsubruleService.delete(id) diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/HazardousWasteController.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/HazardousWasteController.kt index 518698d..3339361 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/HazardousWasteController.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/HazardousWasteController.kt @@ -3,6 +3,7 @@ import cn.flightfeather.supervision.lightshare.service.HazardousWasteService import io.swagger.annotations.Api import io.swagger.annotations.ApiOperation +import io.swagger.annotations.ApiParam import org.springframework.web.bind.annotation.GetMapping import org.springframework.web.bind.annotation.RequestMapping import org.springframework.web.bind.annotation.RequestParam @@ -15,12 +16,12 @@ @ApiOperation(value = "鑾峰彇鐢ㄦ埛鎵�灞炰紒涓氱殑鍗卞簾澶囨淇℃伅") @GetMapping("/file") - fun getFile(@RequestParam("userId") userId: String) = hazardousWasteService.getFile(userId) + fun getFile(@ApiParam(value = "鐢ㄦ埛id") @RequestParam("userId") userId: String) = hazardousWasteService.getFile(userId) @ApiOperation(value = "鑾峰彇鐢ㄦ埛鎵�灞炰紒涓氱殑鍗卞簾澶勭疆璁板綍") @GetMapping("/record") fun getRecord( - @RequestParam("userId") userId: String, - @RequestParam(value = "year", required = false) year: String? + @ApiParam(value = "鐢ㄦ埛id") @RequestParam("userId") userId: String, + @ApiParam(value = "骞翠唤") @RequestParam(value = "year", required = false) year: String? ) = hazardousWasteService.getRecord(userId, year) } \ No newline at end of file diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/ItemevaluationController.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/ItemevaluationController.kt index 8906b93..c8eada3 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/ItemevaluationController.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/ItemevaluationController.kt @@ -3,36 +3,49 @@ import cn.flightfeather.supervision.domain.entity.Itemevaluation import cn.flightfeather.supervision.lightshare.service.ItemevaluationService import io.swagger.annotations.Api +import io.swagger.annotations.ApiOperation +import io.swagger.annotations.ApiParam import org.springframework.web.bind.annotation.* +import springfox.documentation.annotations.ApiIgnore @Api(tags = ["璇勫垎瀛愰」寰楀垎API鎺ュ彛"]) @RestController @RequestMapping("/itemevaluation") class ItemevaluationController (val itemevaluationService: ItemevaluationService){ + @ApiOperation(value = "鑾峰彇鎵�鏈夎瘎鍒嗗瓙椤瑰緱鍒嗚褰�") @GetMapping fun getAll() = itemevaluationService.findAll() + @ApiOperation(value = "鏍规嵁瀛愪换鍔d鑾峰彇璇勫垎瀛愰」寰楀垎璁板綍") @GetMapping("/subtask/{id}") - fun getBySubtaskId(@PathVariable id:String) = itemevaluationService.findBySubTaskID(id) + fun getBySubtaskId(@ApiParam(value = "瀛愪换鍔d") @PathVariable id:String) = itemevaluationService.findBySubTaskID(id) + @ApiOperation(value = "涓婁紶涓�涓瘎鍒嗗瓙椤瑰緱鍒嗚褰�") @PutMapping - fun add(@RequestBody itemevaluation: Itemevaluation) = itemevaluationService.save(itemevaluation) + fun add(@ApiParam(value = "璇勫垎瀛愰」寰楀垎璁板綍") @RequestBody itemevaluation: Itemevaluation) = itemevaluationService.save(itemevaluation) + @ApiOperation(value = "涓婁紶涓�缁勮瘎鍒嗗瓙椤瑰緱鍒嗚褰�") @PutMapping("/addlist") - fun addList(@RequestBody itemevaluationlist: List<Itemevaluation>) = itemevaluationService.savelist(itemevaluationlist) + fun addList(@ApiParam(value = "璇勫垎瀛愰」寰楀垎璁板綍鏁扮粍") @RequestBody itemevaluationlist: List<Itemevaluation>) = itemevaluationService.savelist(itemevaluationlist) + @ApiOperation(value = "鏇存柊涓�鏉¤瘎鍒嗗瓙椤瑰緱鍒嗚褰�") @PostMapping - fun update(@RequestBody itemevaluation: Itemevaluation) = itemevaluationService.update(itemevaluation) + fun update(@ApiParam(value = "璇勫垎瀛愰」寰楀垎璁板綍") @RequestBody itemevaluation: Itemevaluation) = itemevaluationService.update(itemevaluation) + @ApiOperation(value = "鏇存柊涓�缁勮瘎鍒嗗瓙椤瑰緱鍒嗚褰�") @PostMapping("/uplist") - fun updatelist(@RequestBody itemevaluationlist: List<Itemevaluation>) = itemevaluationService.updatelist(itemevaluationlist) + fun updatelist(@ApiParam(value = "璇勫垎瀛愰」寰楀垎璁板綍鏁扮粍") @RequestBody itemevaluationlist: List<Itemevaluation>) = itemevaluationService.updatelist(itemevaluationlist) + @ApiOperation(value = "鏌ユ壘璇勫垎瀛愰」寰楀垎璁板綍") @GetMapping("/{id}") - fun getById(@PathVariable id:String) = itemevaluationService.findOne(id) + fun getById(@ApiParam(value = "璇勫垎瀛愰」寰楀垎璁板綍id") @PathVariable id:String) = itemevaluationService.findOne(id) + @ApiIgnore + @ApiOperation(value = "鍒犻櫎璇勫垎瀛愰」寰楀垎璁板綍") @DeleteMapping("/{id}") - fun delete (@PathVariable id: String) = itemevaluationService.delete(id) + fun delete (@ApiParam(value = "璇勫垎瀛愰」寰楀垎璁板綍id") @PathVariable id: String) = itemevaluationService.delete(id) + @ApiOperation(value = "鏍规嵁鎬诲垎id鑾峰彇瀵瑰簲璇勫垎瀛愰」寰楀垎璁板綍") @GetMapping("/pointId/{evaluationId}") - fun getItemEvaluationList(@PathVariable evaluationId: String) = itemevaluationService.getItemEvaluationList(evaluationId) + fun getItemEvaluationList(@ApiParam(value = "鎬诲垎璁板綍id") @PathVariable evaluationId: String) = itemevaluationService.getItemEvaluationList(evaluationId) } \ No newline at end of file diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/LawController.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/LawController.kt index 4968b37..0b9ecf7 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/LawController.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/LawController.kt @@ -3,6 +3,8 @@ import cn.flightfeather.supervision.lightshare.service.LawService import cn.flightfeather.supervision.lightshare.vo.LawsRegulationsCondition import io.swagger.annotations.Api +import io.swagger.annotations.ApiOperation +import io.swagger.annotations.ApiParam import org.springframework.web.bind.annotation.* import javax.servlet.http.HttpServletResponse @@ -11,30 +13,34 @@ @RequestMapping("/laws") class LawController(val lawService: LawService) { + @ApiOperation(value = "鑾峰彇鎵�鏈夋硶寰嬫硶瑙�") @GetMapping fun getLaws( - @RequestParam(value = "page") page: Int, - @RequestParam(value = "per_page") perPage: Int, - response: HttpServletResponse + @ApiParam(value = "椤电爜") @RequestParam(value = "page") page: Int, + @ApiParam(value = "鍗曢〉鏁版嵁閲�") @RequestParam(value = "per_page") perPage: Int, + response: HttpServletResponse ) = lawService.getLaws(page, perPage, response) + @ApiOperation(value = "鏍规嵁id鏌ユ壘娉曞緥娉曡") @GetMapping("/text") fun getLawText( - @RequestParam(value = "id") lawId: String + @ApiParam(value = "娉曞緥娉曡璁板綍id") @RequestParam(value = "id") lawId: String ) = lawService.getLawText(lawId) + @ApiOperation(value = "鏌ユ壘娉曞緥娉曡") @PostMapping("/condition/{userId}") fun getLawsRegulations( - @PathVariable userId: String, - @RequestBody condition: LawsRegulationsCondition, - @RequestParam(value = "page") page: Int, - @RequestParam(value = "per_page") perPage: Int, - response: HttpServletResponse + @ApiParam(value = "鐢ㄦ埛鐨刬d") @PathVariable userId: String, + @ApiParam(value = "鏌ユ壘鏉′欢") @RequestBody condition: LawsRegulationsCondition, + @ApiParam(value = "椤电爜") @RequestParam(value = "page") page: Int, + @ApiParam(value = "鍗曢〉鏁版嵁閲�") @RequestParam(value = "per_page") perPage: Int, + response: HttpServletResponse ) = lawService.getLawsRegulations(condition, page, perPage, response) + @ApiOperation(value = "鏍规嵁琛屼笟绫诲瀷鏌ユ壘鐩稿叧娉曞緥娉曡") @PostMapping("/eachType/{userId}") fun getLawsRegulationsWithEachType( - @PathVariable userId: String, - @RequestBody condition: LawsRegulationsCondition + @ApiParam(value = "鐢ㄦ埛id") @PathVariable userId: String, + @ApiParam(value = "鏌ユ壘鏉′欢") @RequestBody condition: LawsRegulationsCondition ) = lawService.getLawsRegulationsWithEachType(condition) } \ No newline at end of file diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/LedgerController.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/LedgerController.kt index 42d1ee6..f26771b 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/LedgerController.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/LedgerController.kt @@ -9,6 +9,7 @@ import org.springframework.web.bind.annotation.* import org.springframework.web.multipart.MultipartFile import org.synchronoss.cloud.nio.multipart.Multipart +import springfox.documentation.annotations.ApiIgnore import javax.servlet.http.HttpServletResponse @Api(tags = ["鍙拌处API鎺ュ彛"]) @@ -16,56 +17,62 @@ @RequestMapping("/ledger") class LedgerController(val ledgerService: LedgerService) { + @ApiOperation(value = "鑾峰彇鍙拌处绫诲瀷") @GetMapping("/type") fun getLedgerType( - @RequestParam(value = "sceneType") sceneType: Int + @ApiParam("鍦烘櫙绫诲瀷id") @RequestParam(value = "sceneType") sceneType: Int ) = ledgerService.getLedgerType(sceneType) @ApiOperation(value = "鑾峰彇鐢ㄦ埛鏌愪釜鏃堕棿鐐逛笅搴旇鎻愪氦鐨勬墍鏈夊彴璐﹀強瀵瑰簲鐨勬彁浜ょ姸鎬併�佸鏍哥姸鎬佺瓑淇℃伅") @GetMapping("/{userId}/summary") fun getUserLedgerSummary( - @ApiParam("鐢ㄦ埛id") @PathVariable userId: String, - @ApiParam("鍦烘櫙绫诲瀷id") @RequestParam(value = "sceneType") sceneType: Int, - @ApiParam(value = "鏃堕棿", example = "yyyy-MM-dd") @RequestParam(value = "time")time: String + @ApiParam("鐢ㄦ埛id") @PathVariable userId: String, + @ApiParam("鍦烘櫙绫诲瀷id") @RequestParam(value = "sceneType") sceneType: Int, + @ApiParam(value = "鏃堕棿", example = "yyyy-MM-dd") @RequestParam(value = "time")time: String ) = ledgerService.getUserLedgerSummary(userId, sceneType, time) + @ApiOperation(value = "鑾峰彇鍙拌处璇︽儏") @GetMapping("/{userId}/detail") fun getLedgerDetail( - @PathVariable userId: String, - @RequestParam(value = "ledgerSubTypeId", required = false) ledgerSubTypeId: Int?, - @RequestParam(value = "sceneType") sceneType: Int, - @RequestParam(value = "startTime") startTime: String, - @RequestParam(value = "endTime") endTime: String, - @RequestParam(value = "page", required = false) page: Int?, - @RequestParam(value = "per_page") perPage: Int, - response: HttpServletResponse + @ApiParam("鐢ㄦ埛id") @PathVariable userId: String, + @ApiParam("鍙拌处绫诲瀷id") @RequestParam(value = "ledgerSubTypeId", required = false) ledgerSubTypeId: Int?, + @ApiParam("鍦烘櫙绫诲瀷id") @RequestParam(value = "sceneType") sceneType: Int, + @ApiParam("涓婁紶寮�濮嬫椂闂�") @RequestParam(value = "startTime") startTime: String, + @ApiParam("涓婁紶缁撴潫鏃堕棿") @RequestParam(value = "endTime") endTime: String, + @ApiParam("椤电爜") @RequestParam(value = "page", required = false) page: Int?, + @ApiParam("鍗曢〉鏁版嵁閲�") @RequestParam(value = "per_page") perPage: Int, + response: HttpServletResponse ) = ledgerService.getLedgerDetail(userId, ledgerSubTypeId, sceneType, startTime, endTime, page, perPage, response) @ApiOperation(value = "鑾峰彇鐢ㄦ埛鏌愮被鍙拌处璇︽儏鎴栬�呮墍鏈夊彴璐︾殑璇︽儏") @GetMapping("/{userId}/detail2") fun getLedgerDetail2( - @ApiParam("鐢ㄦ埛id") @PathVariable userId: String, - @ApiParam(value = "鍙拌处瀛愮被鍨媔d锛� 濡傛灉涓嶄紶锛屽垯榛樿鏍规嵁鍦烘櫙绫诲瀷鑾峰彇鎵�鏈夊彴璐�", required = false) @RequestParam(value = "ledgerSubTypeId", required = false) ledgerSubTypeId: Int?, - @ApiParam("鍦烘櫙绫诲瀷id") @RequestParam(value = "sceneType") sceneType: Int, - @ApiParam(value = "鏃堕棿", example = "yyyy-MM-dd") @RequestParam(value = "time") time: String + @ApiParam("鐢ㄦ埛id") @PathVariable userId: String, + @ApiParam(value = "鍙拌处瀛愮被鍨媔d锛� 濡傛灉涓嶄紶锛屽垯榛樿鏍规嵁鍦烘櫙绫诲瀷鑾峰彇鎵�鏈夊彴璐�", required = false) @RequestParam(value = "ledgerSubTypeId", required = false) ledgerSubTypeId: Int?, + @ApiParam("鍦烘櫙绫诲瀷id") @RequestParam(value = "sceneType") sceneType: Int, + @ApiParam(value = "鏃堕棿", example = "yyyy-MM-dd") @RequestParam(value = "time") time: String ) = ledgerService.getLedgerDetail2(userId, ledgerSubTypeId, sceneType, time) + @ApiOperation(value = "涓婁紶鍙拌处淇℃伅") @PostMapping("/{userId}/upload") fun uploadLedger( - @PathVariable userId: String, - @RequestParam("params") ledgerVoList: String, - @RequestPart("images") files:Array<MultipartFile> + @ApiParam("鐢ㄦ埛id") @PathVariable userId: String, + @ApiParam("鍙拌处淇℃伅json") @RequestParam("params") ledgerVoList: String, + @ApiParam("鍙拌处鍥剧墖") @RequestPart("images") files:Array<MultipartFile> ) = ledgerService.uploadLedger(userId, ledgerVoList, files) + @ApiOperation(value = "鑾峰彇鏌愪釜鍙拌处鏄剧ず鍥炬爣url") @GetMapping("/{userId}/img") fun getLedgerImg( - @PathVariable userId: String, - @RequestParam("ledgerType") ledgerType: Int + @ApiParam("鐢ㄦ埛id") @PathVariable userId: String, + @ApiParam("鍙拌处绫诲瀷id") @RequestParam("ledgerType") ledgerType: Int ) = ledgerService.getLedgerImg(userId, ledgerType) + @ApiIgnore("璇ユ帴鍙f湭浣跨敤锛岃�冭檻鍚庣画鍒犻櫎") + @ApiOperation(value = "鑾峰彇澶氫釜鍙拌处鍥炬爣淇℃伅") @GetMapping("/{userId}/imgs") fun getLedgerImgs( - @PathVariable userId: String, - @RequestParam("ledgerTypes") ledgerTypes: List<Int> + @ApiParam("鐢ㄦ埛id") @PathVariable userId: String, + @ApiParam("鍙拌处绫诲瀷id鏁扮粍") @RequestParam("ledgerTypes") ledgerTypes: List<Int> ) = ledgerService.getLedgerImgs(userId, ledgerTypes) } \ No newline at end of file diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/MediafileController.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/MediafileController.kt index 3903a77..825ac72 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/MediafileController.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/MediafileController.kt @@ -2,32 +2,58 @@ import cn.flightfeather.supervision.domain.entity.Mediafile import cn.flightfeather.supervision.lightshare.service.MediafileService +import io.swagger.annotations.Api +import io.swagger.annotations.ApiOperation +import io.swagger.annotations.ApiParam import org.springframework.web.bind.annotation.* import org.springframework.web.multipart.MultipartFile +import springfox.documentation.annotations.ApiIgnore +@Api(tags = ["澶氬獟浣撴枃浠禔PI鎺ュ彛"]) @RestController @RequestMapping("/mediafile") class MediafileController (val mediafileService: MediafileService){ + @ApiOperation(value = "鑾峰彇鎵�鏈夊濯掍綋鏂囦欢淇℃伅") @GetMapping fun getAll() = mediafileService.findAll() + @ApiOperation(value = "涓婁紶涓�涓濯掍綋鏂囦欢淇℃伅") @PutMapping - fun add(@RequestBody mediafile: Mediafile) = mediafileService.save(mediafile) + fun add( + @ApiParam("澶氬獟浣撴枃浠朵俊鎭�") @RequestBody mediafile: Mediafile) + = mediafileService.save(mediafile) + @ApiOperation(value = "鏇存柊涓�涓濯掍綋鏂囦欢淇℃伅") @PostMapping - fun update(@RequestBody mediafile: Mediafile) = mediafileService.update(mediafile) + fun update( + @ApiParam("澶氬獟浣撴枃浠朵俊鎭�") @RequestBody mediafile: Mediafile) + = mediafileService.update(mediafile) + @ApiOperation(value = "鏌ユ壘涓�涓濯掍綋鏂囦欢淇℃伅") @GetMapping("/{id}") - fun getById(@PathVariable id:String) = mediafileService.findOne(id) + fun getById( + @ApiParam("澶氬獟浣撴枃浠朵俊鎭痠d") @PathVariable id:String) + = mediafileService.findOne(id) + @ApiIgnore("椋炵窘鐩戠鍚庡彴绉绘鐨刟pi锛岃�冭檻鍚庣画鍒犻櫎") + @ApiOperation(value = "鏍规嵁瀛愪换鍔d鍙婁笟鍔$被鍨婭D鏌ヨ") @GetMapping("/{id}/{btid}") - fun getBySubtaskId(@PathVariable id:String,@PathVariable btid:String) = mediafileService.findBysubtaskbtid(id,btid) + fun getBySubtaskId( + @ApiParam("瀛愪换鍔d") @PathVariable id:String, + @ApiParam("涓氬姟绫诲瀷ID") @PathVariable btid:String) + = mediafileService.findBysubtaskbtid(id,btid) + @ApiIgnore + @ApiOperation(value = "鍒犻櫎涓�涓濯掍綋鏂囦欢淇℃伅") @DeleteMapping("/{id}") - fun delete (@PathVariable id: String) = mediafileService.delete(id) + fun delete ( + @ApiParam("澶氬獟浣撴枃浠朵俊鎭痠d") @PathVariable id: String) + = mediafileService.delete(id) + @ApiOperation(value = "涓婁紶澶氬獟浣撴枃浠朵俊鎭�") @PostMapping("/add") - fun addProblem(@RequestParam("mediafileVoList") mediafileVoList: String, @RequestPart("Photos") files: Array<MultipartFile>) { - mediafileService.addMedifile(mediafileVoList,files) - } + fun addProblem( + @ApiParam("澶氬獟浣撴枃浠朵俊鎭痡son") @RequestParam("mediafileVoList") mediafileVoList: String, + @ApiParam("澶氬獟浣撴枃浠�") @RequestPart("Photos") files: Array<MultipartFile> + ) = mediafileService.addMedifile(mediafileVoList, files) } \ No newline at end of file diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/MeetingInfoController.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/MeetingInfoController.kt index cef639c..f5f57a0 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/MeetingInfoController.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/MeetingInfoController.kt @@ -8,6 +8,8 @@ import cn.flightfeather.supervision.lightshare.vo.UserStatusVo import cn.flightfeather.supervision.websocket.Processor import io.swagger.annotations.Api +import io.swagger.annotations.ApiOperation +import io.swagger.annotations.ApiParam import org.springframework.web.bind.annotation.* import org.springframework.web.multipart.MultipartFile import javax.servlet.http.HttpServletResponse @@ -18,169 +20,191 @@ class MeetingInfoController(val meetingInfoService: MeetingInfoService) { /*****************************浼氳********************************************/ + @ApiOperation(value = "鑾峰彇鐢ㄦ埛鐨勪細璁俊鎭�") @GetMapping("/info/{userId}") fun getMeetingInfo( - @PathVariable userId: String, - @RequestParam(value = "status") status: Int, - @RequestParam(value = "page") page: Int, - @RequestParam(value = "per_page") perPage: Int, - response: HttpServletResponse + @ApiParam("鐢ㄦ埛id") @PathVariable userId: String, + @ApiParam(value = "鏌ヨ绫诲瀷", allowableValues = "1,2,3,4,5") @RequestParam(value = "status") status: Int, + @ApiParam("椤电爜") @RequestParam(value = "page") page: Int, + @ApiParam("鍗曢〉鏁版嵁閲�") @RequestParam(value = "per_page") perPage: Int, + response: HttpServletResponse ) = meetingInfoService.getMeetingInfo(userId, status, page, perPage, response) + @ApiOperation(value = "鏍规嵁id鏌ユ壘浼氳淇℃伅") @GetMapping("/info/meetingId/{userId}") fun getMeetingInfoById( - @PathVariable userId: String, - @RequestParam(value = "meetingId") meetingId: String + @ApiParam("鐢ㄦ埛id") @PathVariable userId: String, + @ApiParam("浼氳id") @RequestParam(value = "meetingId") meetingId: String ) = meetingInfoService.getMeetingInfoById(userId, meetingId) + @ApiOperation(value = "涓婁紶浼氳淇℃伅") @PostMapping("/info/{userId}") fun addMeetingInfo( - @PathVariable userId: String, - @RequestBody meetingInfo: MeetingInfo + @ApiParam("鐢ㄦ埛id") @PathVariable userId: String, + @ApiParam("浼氳淇℃伅") @RequestBody meetingInfo: MeetingInfo ) = meetingInfoService.addMeetingInfo(userId, meetingInfo) + @ApiOperation(value = "鏇存柊浼氳淇℃伅") @PutMapping("/info/{userId}") fun updateMeeting( - @PathVariable userId: String, - @RequestBody meetingInfo: MeetingInfo + @ApiParam("鐢ㄦ埛id") @PathVariable userId: String, + @ApiParam("浼氳淇℃伅") @RequestBody meetingInfo: MeetingInfo ) = meetingInfoService.updateMeetingInfo(userId, meetingInfo) + @ApiOperation(value = "鍒犻櫎浼氳") @PostMapping("/delete/{userId}") fun deleteMeeting( - @PathVariable userId: String, - @RequestParam(value = "meetingId") meetingId: String + @ApiParam("鐢ㄦ埛id") @PathVariable userId: String, + @ApiParam("浼氳id") @RequestParam(value = "meetingId") meetingId: String ) = meetingInfoService.deleteMeetingInfo(userId, meetingId) + @ApiOperation(value = "鑾峰彇鐢ㄦ埛浼氳绛惧埌鐘舵��") @GetMapping("/registerStatus/{userId}") fun getMeetingRegisterStatus( - @PathVariable userId: String, - @RequestParam("meetingId") meetingId: String, - @RequestParam("roomId") roomId: String? + @ApiParam("鐢ㄦ埛id") @PathVariable userId: String, + @ApiParam("浼氳id") @RequestParam("meetingId") meetingId: String, + @ApiParam(value = "浼氳瀹d", required = false) @RequestParam("roomId") roomId: String? ) = meetingInfoService.getMeetingRegisterStatus(userId, meetingId, roomId) + @ApiOperation(value = "鑾峰彇浼氳绛惧埌璁板綍") @GetMapping("/registerRecord/{userId}") fun getMeetingRegisterRecord( - @PathVariable userId: String, - @RequestParam("meetingId") meetingId: String, - @RequestParam("roomId") roomId: String? + @ApiParam("鐢ㄦ埛id") @PathVariable userId: String, + @ApiParam("浼氳id") @RequestParam("meetingId") meetingId: String, + @ApiParam(value = "浼氳瀹d", required = false) @RequestParam("roomId") roomId: String? ) = meetingInfoService.getMeetingRegisterRecord(userId, meetingId, roomId) + @ApiOperation(value = "浼氳绛惧埌") @PostMapping("/register/{userId}") fun meetingRegister( - @PathVariable userId: String, - @RequestParam("meetingId") meetingId: String, - @RequestParam("roomId") roomId: String? + @ApiParam("鐢ㄦ埛id") @PathVariable userId: String, + @ApiParam("浼氳id") @RequestParam("meetingId") meetingId: String, + @ApiParam(value = "浼氳瀹d", required = false) @RequestParam("roomId") roomId: String? ) = meetingInfoService.meetingRegister(userId, meetingId, roomId) + @ApiOperation(value = "鑾峰彇浼氳鐨勪細璁") @GetMapping("/room/{userId}") fun getMeetingRoom( - @PathVariable userId: String, - @RequestParam("meetingId") meetingId: String + @ApiParam("鐢ㄦ埛id") @PathVariable userId: String, + @ApiParam("浼氳id") @RequestParam("meetingId") meetingId: String ) = meetingInfoService.getMeetingRoom(userId, meetingId) /*****************************鍙備細浜哄憳********************************************/ + @ApiOperation(value = "娣诲姞浼氳鍙備細浜哄憳") @PostMapping("/participant/{userId}") fun addParticipant( - @PathVariable userId: String, - @RequestBody participantList: List<Participant> + @ApiParam("鐢ㄦ埛id") @PathVariable userId: String, + @ApiParam("鍙備細浜哄憳鍒楄〃") @RequestBody participantList: List<Participant> ) = meetingInfoService.addParticipant(userId, participantList) + @ApiOperation(value = "鍒犻櫎浼氳鍙備細浜哄憳") @PostMapping("/participant/{userId}/delete") fun deleteParticipant( - @PathVariable userId: String, - @RequestParam(value = "meetingId") meetingId: String, - @RequestBody participantList: List<Participant> + @ApiParam("鐢ㄦ埛id") @PathVariable userId: String, + @ApiParam("浼氳id") @RequestParam(value = "meetingId") meetingId: String, + @ApiParam("寰呭垹闄ゅ弬浼氫汉鍛樺垪琛�") @RequestBody participantList: List<Participant> ) = meetingInfoService.deleteParticipant(userId, meetingId, participantList) + @ApiOperation(value = "鑾峰彇浼氳鐨勫弬浼氫汉鍛�") @GetMapping("/participant/{userId}") fun getParticipant( - @PathVariable userId: String, - @RequestParam("meetingId") meetingId: String, - @RequestParam("roomId") roomId: String?, - @RequestParam("participantType") participantType: Int + @ApiParam("鐢ㄦ埛id") @PathVariable userId: String, + @ApiParam("浼氳id") @RequestParam("meetingId") meetingId: String, + @ApiParam("浼氳瀹d") @RequestParam("roomId") roomId: String?, + @ApiParam(value = "鍙備細浜哄憳绫诲瀷", name = "0:涓绘寔浜�,1:浼氳鍢夊,2:浼佷笟浠h〃,3:涓�鑸笌浼氫汉,99:鍏朵粬,-1:鍏ㄩ儴", allowableValues = "0,1,2,3,99,-1") @RequestParam("participantType") participantType: Int ) = meetingInfoService.getParticipant(userId, meetingId, roomId, participantType) + @ApiOperation(value = "鑾峰彇浼氳鍦ㄧ嚎浜哄憳") @GetMapping("/participant/{userId}/onlineCount") fun getOnlineUsers( - @PathVariable userId: String, - @RequestParam("meetingId") meetingId: String, - @RequestParam("roomId") roomId: String + @ApiParam("鐢ㄦ埛id") @PathVariable userId: String, + @ApiParam("浼氳id") @RequestParam("meetingId") meetingId: String, + @ApiParam("浼氳瀹d") @RequestParam("roomId") roomId: String ) = meetingInfoService.getOnlineUsers(userId, meetingId, roomId) + @ApiOperation(value = "璁剧疆鐢ㄦ埛鐨勭瑷�鐘舵��") @PostMapping("/participant/{userId}/setMute") fun setMuteStatus( - @PathVariable userId: String, - @RequestParam("meetingId") meetingId: String, - @RequestParam("roomId") roomId: String, - @RequestBody userStatusList: List<UserStatusVo> + @ApiParam("鐢ㄦ埛id") @PathVariable userId: String, + @ApiParam("浼氳id") @RequestParam("meetingId") meetingId: String, + @ApiParam("浼氳瀹d") @RequestParam("roomId") roomId: String, + @ApiParam("鐢ㄦ埛鐘舵��") @RequestBody userStatusList: List<UserStatusVo> ) = meetingInfoService.setMuteStatus(userId, meetingId, roomId, userStatusList) /*****************************浼氳鏂囦欢********************************************/ + @ApiOperation(value = "涓婁紶浼氳鏂囦欢") @PostMapping("/uploadFile/{userId}") fun uploadFiles( - @PathVariable userId: String, - @RequestParam("meetingId") meetingId: String, - @RequestParam("roomId") roomId: String, - @RequestParam("documentType") documentType: Int, - @RequestParam("params") msgVo: String, - @RequestPart("files") files: Array<MultipartFile> + @ApiParam("鐢ㄦ埛id") @PathVariable userId: String, + @ApiParam("浼氳id") @RequestParam("meetingId") meetingId: String, + @ApiParam("浼氳瀹d") @RequestParam("roomId") roomId: String, + @ApiParam("鏂囦欢绫诲瀷") @RequestParam("documentType") documentType: Int, + @ApiParam("鏂囦欢淇℃伅") @RequestParam("params") msgVo: String, + @ApiParam("鏂囦欢") @RequestPart("files") files: Array<MultipartFile> ) = meetingInfoService.uploadFile(userId, meetingId, roomId, msgVo, files, documentType) + @ApiOperation(value = "鑾峰彇浼氳瀹ゆ枃浠�") @GetMapping("/material/{userId}") fun getMeetingMaterials( - @PathVariable userId: String, - @RequestParam("meetingId") meetingId: String, - @RequestParam("mediaType") mediaType: Int, - @RequestParam(value = "page") page: Int, - @RequestParam(value = "per_page") perPage: Int, - response: HttpServletResponse + @ApiParam("鐢ㄦ埛id") @PathVariable userId: String, + @ApiParam("浼氳id") @RequestParam("meetingId") meetingId: String, + @ApiParam("浼氳瀹d") @RequestParam("mediaType") mediaType: Int, + @ApiParam("椤电爜") @RequestParam(value = "page") page: Int, + @ApiParam("鍗曢〉鏁版嵁閲�") @RequestParam(value = "per_page") perPage: Int, + response: HttpServletResponse ) = meetingInfoService.getMeetingMaterials(userId, meetingId, mediaType, page, perPage, response) + @ApiOperation(value = "鏇存柊浼氳鏂囦欢绛炬敹鐘舵��") @PostMapping("/material/sign/{userId}") fun updateSignState( - @PathVariable userId: String, - @RequestBody signStateList: List<MeetingMaterialVo> + @ApiParam("鐢ㄦ埛id") @PathVariable userId: String, + @ApiParam("浼氳鏂囦欢绛炬敹鐘舵��") @RequestBody signStateList: List<MeetingMaterialVo> ) = meetingInfoService.updateSignState(userId, signStateList) + @ApiOperation(value = "鑾峰彇浼氳鏂囦欢鏁伴噺") @GetMapping("/count/material/{userId}") fun getMaterialCount( - @PathVariable userId: String, - @RequestParam("meetingId") meetingId: String, - @RequestParam("mediaType") mediaType: Int, - @RequestParam("meetingFileType") meetingFileType: Int + @ApiParam("鐢ㄦ埛id") @PathVariable userId: String, + @ApiParam("浼氳id") @RequestParam("meetingId") meetingId: String, + @ApiParam("澶氬獟浣撴枃浠剁被鍨�") @RequestParam("mediaType") mediaType: Int, + @ApiParam("浼氳鏂囦欢绫诲瀷") @RequestParam("meetingFileType") meetingFileType: Int ) = meetingInfoService.getMaterialCount(userId, meetingId, mediaType, meetingFileType) + @ApiOperation(value = "鍒犻櫎浼氳鏂囦欢") @PostMapping("/material/delete/{userId}") fun deleteFiles( - @PathVariable userId: String, - @RequestParam("meetingId") meetingId: String, - @RequestBody fileList: List<MeetingMaterialVo> + @ApiParam("鐢ㄦ埛id") @PathVariable userId: String, + @ApiParam("浼氳id") @RequestParam("meetingId") meetingId: String, + @ApiParam("寰呭垹闄や細璁枃浠�") @RequestBody fileList: List<MeetingMaterialVo> ) = meetingInfoService.deleteFiles(userId, meetingId, fileList) + @ApiOperation(value = "鑾峰彇浼氳鎵�鏈夋枃浠剁鏀剁姸鎬�") @GetMapping("/count/all/material/{userId}") fun getAllMaterialSignStatus( - @PathVariable userId: String, - @RequestParam("meetingId") meetingId: String + @ApiParam("鐢ㄦ埛id") @PathVariable userId: String, + @ApiParam("浼氳id") @RequestParam("meetingId") meetingId: String ) = meetingInfoService.getAllMaterialSignStatus(userId, meetingId) /*****************************浼氳鑱婂ぉ璁板綍********************************************/ + @ApiOperation(value = "鑾峰彇浼氳鑱婂ぉ璁板綍") @GetMapping("/comment/{userId}") fun getMeetingRecords( - @PathVariable userId: String, - @RequestParam("meetingId") meetingId: String, - @RequestParam("roomId") roomId: String, - @RequestParam(value = "page") page: Int, - @RequestParam(value = "per_page") perPage: Int, - response: HttpServletResponse + @ApiParam("鐢ㄦ埛id") @PathVariable userId: String, + @ApiParam("浼氳id") @RequestParam("meetingId") meetingId: String, + @ApiParam("浼氳瀹d") @RequestParam("roomId") roomId: String, + @ApiParam("椤电爜") @RequestParam(value = "page") page: Int, + @ApiParam("鍗曢〉鏁版嵁閲�") @RequestParam(value = "per_page") perPage: Int, + response: HttpServletResponse ) = meetingInfoService.getMeetingRecords(userId, meetingId, roomId, page, perPage, response) /*****************************浼氳鎺ㄩ�侀�氱煡********************************************/ + @ApiOperation(value = "鎺ㄩ�佷細璁�氱煡") @PostMapping("/push/{userId}") fun pushMeetingInfo( - @PathVariable userId: String, - @RequestParam("meetingId") meetingId: String, - @RequestParam("roomId") roomId: String?, - @RequestParam("title") title: String, - @RequestParam("body") body: String + @ApiParam("鐢ㄦ埛id") @PathVariable userId: String, + @ApiParam("浼氳id") @RequestParam("meetingId") meetingId: String, + @ApiParam("浼氳瀹d") @RequestParam("roomId") roomId: String?, + @ApiParam("閫氱煡鏍囬") @RequestParam("title") title: String, + @ApiParam("閫氱煡鍐呭") @RequestParam("body") body: String ) = meetingInfoService.pushMeetingInfo(userId, meetingId, roomId, title, body) } \ No newline at end of file diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/NotificationController.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/NotificationController.kt index b47b946..0382f15 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/NotificationController.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/NotificationController.kt @@ -5,6 +5,7 @@ import cn.flightfeather.supervision.lightshare.vo.NotificationVo import io.swagger.annotations.Api import io.swagger.annotations.ApiOperation +import io.swagger.annotations.ApiParam import org.springframework.web.bind.annotation.* import javax.servlet.http.HttpServletResponse @@ -16,35 +17,35 @@ @ApiOperation(value = "鑾峰彇鐢ㄦ埛鏈閫氱煡") @GetMapping fun getNotificationUnRead( - @RequestParam(value = "userId") userId: String, - @RequestParam(value = "page") page: Int, - @RequestParam(value = "per_page") perPage: Int, - response: HttpServletResponse + @ApiParam("鐢ㄦ埛id") @RequestParam(value = "userId") userId: String, + @ApiParam("椤电爜") @RequestParam(value = "page") page: Int, + @ApiParam("鍗曢〉鏁版嵁閲�") @RequestParam(value = "per_page") perPage: Int, + response: HttpServletResponse ) = notificationService.getNotificationUnRead(userId, page, perPage, response) @ApiOperation(value = "鏇存柊閫氱煡璇诲彇鐘舵��") @PostMapping("/{userId}/readState") fun updateReadState( - @PathVariable("userId") userId: String, - @RequestBody readStates: List<NoticeReadStateVo> + @ApiParam("鐢ㄦ埛id") @PathVariable("userId") userId: String, + @ApiParam("閫氱煡璇诲彇鐘舵��") @RequestBody readStates: List<NoticeReadStateVo> ) = notificationService.updateReadState(userId, readStates) @ApiOperation(value = "鑾峰彇閫氱煡闀挎枃鏈唴瀹�") @GetMapping("/text") fun getNotificationText( - @RequestParam(value = "id") notificationId: String + @ApiParam("閫氱煡id") @RequestParam(value = "id") notificationId: String ) = notificationService.getNotificationText(notificationId) @ApiOperation(value = "鑾峰彇鎬绘湭璇婚�氱煡鏁伴噺") @GetMapping("/{userId}/unread") fun getUnReadNoticeNum( - @PathVariable("userId") userId: String + @ApiParam("鐢ㄦ埛id") @PathVariable("userId") userId: String ) = notificationService.getUnReadNoticeNum(userId) @ApiOperation(value = "鍙戝竷閫氱煡") @PostMapping("{userId}/release") fun releaseNotice( - @PathVariable("userId") userId: String, - @RequestBody notice: NotificationVo + @ApiParam("鐢ㄦ埛id") @PathVariable("userId") userId: String, + @ApiParam("閫氱煡") @RequestBody notice: NotificationVo ) = notificationService.releaseNotice(userId, notice) } \ No newline at end of file diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/OpenApiWordController.java b/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/OpenApiWordController.java new file mode 100644 index 0000000..5c19761 --- /dev/null +++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/OpenApiWordController.java @@ -0,0 +1,93 @@ +package cn.flightfeather.supervision.lightshare.web; + +import cn.flightfeather.supervision.lightshare.service.OpenApiWordService; +import io.swagger.annotations.*; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.multipart.MultipartFile; +import org.thymeleaf.context.Context; +import org.thymeleaf.spring5.SpringTemplateEngine; + +import javax.servlet.http.HttpServletResponse; +import javax.validation.Valid; +import java.io.BufferedOutputStream; +import java.io.IOException; +import java.net.URLEncoder; +import java.util.Map; + +@Controller +@Api(tags = "OpenAPI") +public class OpenApiWordController { + + @Value("${swagger.url}") + private String swaggerUrl; + + @Autowired + private OpenApiWordService openApiWordService; + @Autowired + private SpringTemplateEngine springTemplateEngine; + + private String fileName; + + /** + * 灏� swagger json鏂囦欢杞崲鎴� word鏂囨。骞朵笅杞� + * + * @param model + * @param jsonFile 闇�瑕佽浆鎹㈡垚 word 鏂囨。鐨剆wagger json鏂囦欢 + * @param response + * @return + * @throws Exception + */ + @ApiOperation(value = "灏� swagger json鏂囦欢杞崲鎴� word鏂囨。骞朵笅杞�", notes = "") + @ApiResponses(value = {@ApiResponse(code = 200, message = "璇锋眰鎴愬姛銆�")}) + @RequestMapping(value = "/OpenApiFileToWord", method = {RequestMethod.POST}) + public void getWord(Model model, @ApiParam("swagger json file") @Valid @RequestPart("jsonFile") MultipartFile jsonFile, HttpServletResponse response) throws Exception { + generateModelData(model, jsonFile); + writeContentToResponse(model, response); + } + + private void generateModelData(Model model, MultipartFile jsonFile) throws IOException { + Map<String, Object> result = openApiWordService.tableList(jsonFile); + fileName = jsonFile.getOriginalFilename(); + + if (fileName != null) { + fileName = fileName.replaceAll(".json", ""); + } else { + fileName = "toWord"; + } + + model.addAttribute("url", "http://"); + model.addAttribute("download", 0); + model.addAllAttributes(result); + } + + private void generateModelData(Model model, String url, Integer download) { + url = StringUtils.defaultIfBlank(url, swaggerUrl); + Map<String, Object> result = openApiWordService.tableList(url); + model.addAttribute("url", url); + model.addAttribute("download", download); + model.addAllAttributes(result); + } + + private void writeContentToResponse(Model model, HttpServletResponse response) { + Context context = new Context(); + context.setVariables(model.asMap()); + String content = springTemplateEngine.process("word", context); + response.setContentType("application/octet-stream;charset=utf-8"); + response.setCharacterEncoding("utf-8"); + try (BufferedOutputStream bos = new BufferedOutputStream(response.getOutputStream())) { + response.setHeader("Content-disposition", "attachment;filename=" + URLEncoder.encode(fileName + ".doc", "utf-8")); + byte[] bytes = content.getBytes(); + bos.write(bytes, 0, bytes.length); + bos.flush(); + } catch (IOException e) { + e.printStackTrace(); + } + } +} \ No newline at end of file diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/ProblemController.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/ProblemController.kt index 21a30f3..db1faf6 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/ProblemController.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/ProblemController.kt @@ -3,6 +3,7 @@ import cn.flightfeather.supervision.lightshare.service.ProblemService import io.swagger.annotations.Api import io.swagger.annotations.ApiOperation +import io.swagger.annotations.ApiParam import org.springframework.web.bind.annotation.GetMapping import org.springframework.web.bind.annotation.RequestMapping import org.springframework.web.bind.annotation.RequestParam @@ -16,8 +17,8 @@ @ApiOperation(value = "鏍规嵁骞存湀鑾峰彇鐢ㄦ埛鐨勯棶棰�") @GetMapping("/list") fun getProblemsByPeriod( - @RequestParam("userId") userId: String, - @RequestParam("year") year: Int, - @RequestParam("month") month: Int + @ApiParam("鐢ㄦ埛id") @RequestParam("userId") userId: String, + @ApiParam("骞翠唤") @RequestParam("year") year: Int, + @ApiParam("鏈堜唤") @RequestParam("month") month: Int ) = problemService.getProblemsByPeriod(userId, year, month) } \ No newline at end of file diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/UserinfoController.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/UserinfoController.kt index b315421..bdd9749 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/UserinfoController.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/UserinfoController.kt @@ -18,59 +18,74 @@ // @GetMapping("") // fun getAll() = userinfoService.findAll() + @ApiOperation(value = "鏍规嵁鐢ㄦ埛id鑾峰彇鐢ㄦ埛淇℃伅") @GetMapping("/{id}") - fun getById(@PathVariable id: String) = userinfoService.findOne(id) + fun getById( + @ApiParam("鐢ㄦ埛id") @PathVariable id: String + ) = userinfoService.findOne(id) + @ApiOperation(value = "涓婁紶鐢ㄦ埛淇℃伅") @PutMapping("") - fun add(@RequestBody userinfo: Userinfo) = userinfoService.save(userinfo) + fun add( + @ApiParam("鐢ㄦ埛淇℃伅") @RequestBody userinfo: Userinfo + ) = userinfoService.save(userinfo) + @ApiOperation(value = "鏇存柊鐢ㄦ埛淇℃伅") @PostMapping("") - fun update(@RequestBody userinfo: Userinfo) = userinfoService.update(userinfo) + fun update( + @ApiParam("鐢ㄦ埛淇℃伅") @RequestBody userinfo: Userinfo + ) = userinfoService.update(userinfo) // @DeleteMapping("/{id}") // fun delete(@PathVariable id: String) = userinfoService.delete(id) @ApiOperation(value = "鐧诲綍") @PostMapping("/login") - fun login(@RequestBody loginRequestVo: LoginRequestVo) = userinfoService.login(loginRequestVo) + fun login( + @ApiParam("鐧诲綍淇℃伅") @RequestBody loginRequestVo: LoginRequestVo + ) = userinfoService.login(loginRequestVo) @ApiOperation(value = "娉ㄥ唽") @PostMapping("/register") - fun register(@RequestBody loginRequestVo: LoginRequestVo) = userinfoService.register(loginRequestVo) + fun register( + @ApiParam("娉ㄥ唽淇℃伅") @RequestBody loginRequestVo: LoginRequestVo + ) = userinfoService.register(loginRequestVo) @ApiOperation(value = "鑾峰彇鐢ㄦ埛閫氳褰�") @GetMapping("/addressBook") - fun getAddressBook(@RequestParam("userId") userId: String) = userinfoService.getAddressBook(userId) + fun getAddressBook( + @ApiParam("鐢ㄦ埛id") @RequestParam("userId") userId: String + ) = userinfoService.getAddressBook(userId) @ApiOperation(value = "涓婁紶鐢ㄦ埛澶村儚") @PostMapping("/accountPic/upLoad") fun upLoadUserAccountPic( - @RequestParam("userId") userId: String, - @RequestPart("images") files: Array<MultipartFile> + @ApiParam("鐢ㄦ埛id") @RequestParam("userId") userId: String, + @ApiParam("鍥剧墖") @RequestPart("images") files: Array<MultipartFile> ) = userinfoService.upLoadAccountPic(userId, files) @ApiOperation(value = "淇敼瀵嗙爜") @PostMapping("/password/change/{userId}") fun changePassword( - @RequestParam("userId") userId: String, - @RequestParam("oldPassword") oldPassword: String, - @RequestParam("newPassword") newPassword: String + @ApiParam("鐢ㄦ埛id") @RequestParam("userId") userId: String, + @ApiParam("鏃у瘑鐮�") @RequestParam("oldPassword") oldPassword: String, + @ApiParam("鏂板瘑鐮�") @RequestParam("newPassword") newPassword: String ) = userinfoService.changePassword(userId, oldPassword, newPassword) @ApiOperation(value = "鏍规嵁鏌ヨ鑰咃紝鎵惧埌鍚屽尯鍘跨殑鐢ㄦ埛") @PostMapping("/searchUser/{userId}") fun searchUser( - @PathVariable("userId") userId: String, - @RequestBody condition: UserSearchCondition, - @RequestParam(value = "page") page: Int, - @RequestParam(value = "per_page") perPage: Int, - response: HttpServletResponse + @ApiParam("鐢ㄦ埛id") @PathVariable("userId") userId: String, + @ApiParam("鏌ヨ鏉′欢") @RequestBody condition: UserSearchCondition, + @ApiParam("椤电爜") @RequestParam(value = "page") page: Int, + @ApiParam("鍗曢〉鏁版嵁閲�") @RequestParam(value = "per_page") perPage: Int, + response: HttpServletResponse ) = userinfoService.searchUser(userId, condition, page, perPage, response) @ApiOperation(value = "鑾峰彇鐢ㄦ埛鍩烘湰淇℃伅") @GetMapping("/baseInfo") fun getBaseInfo( - @RequestParam("userId") userId: String + @ApiParam("鐢ㄦ埛id") @RequestParam("userId") userId: String ) = userinfoService.getBaseInfo(userId) @ApiOperation(value = "鏍规嵁缁欏畾鏉′欢锛屾悳绱㈢敤鎴�") @@ -79,7 +94,7 @@ @ApiParam("鍖哄幙", example = "寰愭眹鍖�") @RequestParam("district", required = false) district: String, @ApiParam("鍦烘櫙绫诲瀷", example = "1", allowableValues = "0,1,2,3,4,5,6,7") @RequestParam("sceneType", required = false) sceneType: Int, @ApiParam("鐢ㄦ埛绫诲瀷", example = "0", allowableValues = "0,1,2,3") @RequestParam("userType", required = false) userType: Int, - @RequestParam(value = "page") page: Int, - @RequestParam(value = "per_page") perPage: Int, + @ApiParam("椤电爜") @RequestParam(value = "page") page: Int, + @ApiParam("鍗曢〉鏁版嵁閲�") @RequestParam(value = "per_page") perPage: Int, ) = userinfoService.search(district, sceneType, userType, page, perPage) } \ No newline at end of file diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/VersionController.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/VersionController.kt index 60b5133..0178ada 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/VersionController.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/VersionController.kt @@ -3,30 +3,38 @@ import cn.flightfeather.supervision.domain.entity.Version import cn.flightfeather.supervision.lightshare.service.VersionService import io.swagger.annotations.Api +import io.swagger.annotations.ApiOperation +import io.swagger.annotations.ApiParam import org.springframework.web.bind.annotation.* import org.springframework.web.multipart.MultipartFile +import springfox.documentation.annotations.ApiIgnore @Api(tags = ["绯荤粺鐩稿叧API鎺ュ彛"]) @RestController @RequestMapping("/version") class VersionController(val versionService: VersionService) { + @ApiIgnore @PutMapping("") fun add(@RequestBody version: Version) = versionService.save(version) + @ApiIgnore @PostMapping("") fun update(@RequestBody version: Version) = versionService.update(version) + @ApiIgnore @DeleteMapping("/{id}") fun delete(@PathVariable id: String) = versionService.delete(id) + @ApiOperation(value = "鑾峰彇鏈�鏂癮pp鐗堟湰淇℃伅") @GetMapping("/latest") fun getLatestVersion() = versionService.getLatestVersion() + @ApiOperation(value = "涓婁紶閿欒鏃ュ織") @PostMapping("/crashInfo/upLoad") fun upLoadCrashInfo( - @RequestParam("userId") userId: String, - @RequestPart("files") files: Array<MultipartFile> + @ApiParam("鐢ㄦ埛id") @RequestParam("userId") userId: String, + @ApiParam("閿欒鏃ュ織") @RequestPart("files") files: Array<MultipartFile> ) = versionService.upLoadCrashInfo(userId, files) } \ No newline at end of file diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index f03bef2..645715d 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -3,5 +3,3 @@ swagger: v2: enabled: true - - diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 34d07b4..af25bea 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -77,4 +77,7 @@ documentation: swagger: v2: - enabled: false + enabled: true +# Swagger json url address +# etc. https://petstore.swagger.io/ +swagger.url: http://localhost:8080/v3/swagger.json \ No newline at end of file diff --git a/src/main/resources/templates/word.html b/src/main/resources/templates/word.html new file mode 100644 index 0000000..b055562 --- /dev/null +++ b/src/main/resources/templates/word.html @@ -0,0 +1,212 @@ +<!DOCTYPE html> +<html xmlns:th="http://www.thymeleaf.org"> +<head> + <meta http-equiv="Content-Type" content="application/msword; charset=utf-8"/> + <title>toWord</title> + <style type="text/css"> + .bg { + font-size: 14.5px; + font-weight: bold; + color: #000; + background-color: #D7D7D7; + } + + table { + border-width: 1px; + border-style: solid; + border-color: black; + table-layout: fixed; + } + + tr { + height: 32px; + font-size: 12px; + } + + td { + padding-left: 10px; + border-width: 1px; + border-style: solid; + border-color: black; + height: 32px; + overflow: hidden; + word-break: break-all; + word-wrap: break-word; + font-size: 14.5px; + } + + .bg td { + font-size: 14.5px; + } + + tr td { + font-size: 14.5px; + } + + .specialHeight { + height: 40px; + } + + .first_title { + height: 60px; + line-height: 60px; + margin: 0; + font-weight: bold; + font-size: 21px; + } + + .second_title { + height: 40px; + line-height: 40px; + margin: 0; + font-size: 18.5px; + } + + .doc_title { + font-size: 42.5px; + text-align: center; + } + + .download_btn { + float: right; + } + + body { + font-family: 鎬濇簮榛戜綋 Normal; + } + </style> +</head> + +<body> +<div style="width:800px; margin: 0 auto"> + <div> + <p class="doc_title" th:text="${info.title +'锛�'+ info.version +'锛�'}"></p> + <a class="download_btn" th:if="${download == 1}" th:href="${'/downloadWord?url='+ url}">涓嬭浇鏂囨。</a> + <br> + </div> + <div th:each="tableMap:${tableMap}" style="margin-bottom:20px;"> + <!--杩欎釜鏄被鐨勮鏄�--> + <h4 class="first_title" th:text="${tableMap.count} + '. ' + ${tableMap.key}"></h4> + <div th:each="table,tableStat:${tableMap.value}"> + + <!--杩欎釜鏄瘡涓姹傜殑璇存槑锛屾柟渚跨敓鎴愭枃妗e悗杩涜鏁寸悊--> + <h5 class="second_title" th:text="${tableStat.count} + '锛�' + ${table.tag}"></h5> + + <table border="1" cellspacing="0" cellpadding="0" width="100%"> + <tr class="bg"> + <td colspan="5" th:text="${table.tag}"></td> + </tr> + <tr> + <td width="25%">鎺ュ彛鎻忚堪</td> + <td colspan="4" th:text="${table.description}"></td> + </tr> + <tr> + <td>URL</td> + <td colspan="4" th:text="${table.url}"></td> + </tr> + <tr> + <td>璇锋眰鏂瑰紡</td> + <td colspan="4" th:text="${#strings.toUpperCase(table.requestType)}"></td> + </tr> + <tr> + <td>璇锋眰绫诲瀷</td> + <td colspan="4" th:text="${table.requestForm}"></td> + </tr> + <tr> + <td>杩斿洖绫诲瀷</td> + <td colspan="4" th:text="${table.responseForm}"></td> + </tr> + + <tr class="bg"> + <td>鍙傛暟鍚�</td> + <td width="15%">鏁版嵁绫诲瀷</td> + <td width="15%">鍙傛暟绫诲瀷</td> + <td width="15%">鏄惁蹇呭~</td> + <td width="29%">璇存槑</td> + </tr> + + <th:block th:each="request, c:${table.requestList}"> + <tr> + <td align="left" th:text="${c.count} + '.' + ${request.name}"></td> + <td th:text="${request.type}"></td> + <td th:text="${request.paramType}"></td> + <td th:if="${request.require}" th:text="Y"></td> + <td th:if="${!request.require}" th:text="N"></td> + <td th:text="${request.remark}"></td> + <!-- <td th:if="${request.modelAttr}" th:text="asdfagadfg"></td>--> + </tr> + <th:block th:if="${request.modelAttr}"> + <tbody th:include="this::request(${request.modelAttr.properties},${c.count} + '.', 1)"/> + </th:block> + + + </th:block> + + <tr class="bg"> + <td>鐘舵�佺爜</td> + <td colspan="2">鎻忚堪</td> + <td colspan="2">璇存槑</td> + </tr> + + <tr th:each="response:${table.responseList}"> + <td th:text="${response.name}"></td> + <td colspan="2" th:text="${response.description}"></td> + <td colspan="2" th:text="${response.remark}"></td> + </tr> + + <tr class="bg"> + <td>杩斿洖灞炴�у悕</td> + <td colspan="2">绫诲瀷</td> + <td colspan="2">璇存槑</td> + </tr> + + <!-- 瀵硅繑鍥炲弬鏁� 閫掑綊鐢熸垚琛�--> + <tbody th:include="this::response(${table.modelAttr.properties},'', 1)"/> + +<!-- <tr class="bg">--> +<!-- <td colspan="5">绀轰緥</td>--> +<!-- </tr>--> +<!-- <tr class="specialHeight">--> +<!-- <td class="bg">璇锋眰鍙傛暟</td>--> +<!-- <td colspan="4" th:text="${table.requestParam}"></td>--> +<!-- </tr>--> +<!-- <tr class="specialHeight">--> +<!-- <td class="bg">杩斿洖鍊�</td>--> +<!-- <td colspan="4" th:text="${table.responseParam}"></td>--> +<!-- </tr>--> + + </table> + </div> + </div> +</div> + +<th:block th:fragment="request(properties,count, lv)"> + <th:block th:each="p,c : ${properties}"> + <tr> + <td align="left" th:text="${count} + '' + ${c.count} + '.' + ${p.name}" + th:style="|padding-left:${10*lv}px|"></td> + <td th:text="${p.type}"></td> + <td></td> + <td th:if="${p.require}" th:text="Y"></td> + <td th:if="${!p.require}" th:text="N"></td> + <td th:text="${p.description}"></td> + </tr> + <th:block th:unless="${#lists.isEmpty(p.properties)}" + th:include="this::request(${p.properties},${count} + '' + ${c.count} + '.',${lv+1})"/> + </th:block> +</th:block> + +<th:block th:fragment="response(properties,count, lv)"> + <th:block th:each="p,c : ${properties}"> + <tr> + <td align="left" th:text="${count} + '' + ${c.count} + '.' + ${p.name}" + th:style="|padding-left:${10*lv}px|"></td> + <td colspan="2" th:text="${p.type}"></td> + <td colspan="2" th:text="${p.description}"></td> + </tr> + <th:block th:unless="${#lists.isEmpty(p.properties)}" + th:include="this::response(${p.properties},${count} + '' + ${c.count} + '.',${lv+1})"/> + </th:block> +</th:block> +</body> +</html> diff --git a/src/test/kotlin/cn/flightfeather/supervision/common/score/AutoScoreTest.kt b/src/test/kotlin/cn/flightfeather/supervision/common/score/AutoScoreTest.kt index 87d2e00..9cb93d3 100644 --- a/src/test/kotlin/cn/flightfeather/supervision/common/score/AutoScoreTest.kt +++ b/src/test/kotlin/cn/flightfeather/supervision/common/score/AutoScoreTest.kt @@ -20,6 +20,6 @@ @Test fun go() { - autoScore.go(2021, 10) + autoScore.go(2022, 1) } } \ No newline at end of file -- Gitblit v1.9.3