Browse Source

upgrade version

Bay 5 years ago
parent
commit
8ff647e206

+ 1 - 1
pom.xml

@@ -6,7 +6,7 @@
 
     <groupId>cn.seecoder</groupId>
     <artifactId>seecoder-bok</artifactId>
-    <version>0.0.1</version>
+    <version>0.0.2</version>
     <modules>
         <module>seecoder-bok-client</module>
         <module>seecoder-bok-common</module>

+ 2 - 2
seecoder-bok-client/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>seecoder-bok</artifactId>
         <groupId>cn.seecoder</groupId>
-        <version>0.0.1</version>
+        <version>0.0.2</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 
@@ -44,7 +44,7 @@
         <dependency>
             <groupId>cn.seecoder</groupId>
             <artifactId>seecoder-bok-common</artifactId>
-            <version>0.0.1</version>
+            <version>0.0.2</version>
             <scope>compile</scope>
         </dependency>
     </dependencies>

+ 42 - 3
seecoder-bok-client/src/main/java/cn/seecoder/bok/client/SeecoderBokClient.java

@@ -28,7 +28,7 @@ import java.util.function.Function;
 public class SeecoderBokClient
         implements SeecoderBokQuestionApi, SeecoderBokQuestionQueryApi,
         SeecoderBokRecordApi, SeecoderBokUserInteractiveApi,
-        SeecoderBokKnowledgeApi {
+        SeecoderBokKnowledgeApi, SeecoderBokCodeQuestionApi {
 
     private final Logger logger = LoggerFactory.getLogger(getClass());
 
@@ -58,7 +58,8 @@ public class SeecoderBokClient
         HttpUrl httpUrl = createUrlBuilder("/api/knowledge")
                 .addQueryParameter("name", name).build();
         Response response = get(httpUrl);
-        return getResponseBody(response, new TypeReference<List<KnowledgeNodeVO>>() {})
+        return getResponseBody(response, new TypeReference<List<KnowledgeNodeVO>>() {
+        })
                 .orElse(Collections.emptyList());
     }
 
@@ -105,7 +106,8 @@ public class SeecoderBokClient
                 .addQueryParameter("id", joinComma(ids))
                 .build();
         Response response = get(httpUrl);
-        return getResponseBody(response, new TypeReference<List<QuestionVO>>() {})
+        return getResponseBody(response, new TypeReference<List<QuestionVO>>() {
+        })
                 .orElse(Collections.emptyList());
     }
 
@@ -209,6 +211,43 @@ public class SeecoderBokClient
                 .orElse(Collections.emptyList());
     }
 
+
+    public Page<CodeQuestionVO> getCodeQuestions(String title, Pageable pageable) {
+        HttpUrl.Builder urlBuilder = createUrlBuilder("/api/codeQuestion")
+                .addQueryParameter("title", title);
+        HttpUrl httpUrl = addPageableToParams(urlBuilder, pageable).build();
+        Response response = get(httpUrl);
+        return getResponseBody(response, new TypeReference<Page<CodeQuestionVO>>() {})
+                .map(codeQuestionVOS ->
+                        new PageImpl<>(
+                                codeQuestionVOS.getContent(),
+                                parseBokToPageable(codeQuestionVOS.getNumber(), codeQuestionVOS.getSize(), pageable),
+                                codeQuestionVOS.getTotalElements()))
+                .orElse(new PageImpl<>(Collections.emptyList()));
+    }
+
+    @Override
+    public Optional<CodeQuestionVO> getCodeQuestionById(@NotBlank String id) {
+        HttpUrl httpUrl = createUrlBuilder(MessageFormat.format("/api/codeQuestion/{0}", id)).build();
+        Response response = get(httpUrl);
+        return getResponseBody(response, CodeQuestionVO.class);
+    }
+
+    @Override
+    public CodeQuestionVO createCodeQuestion(@NotNull CodeQuestionVO codeQuestionVO) {
+        HttpUrl httpUrl = createUrlBuilder("/api/codeQuestion").build();
+        Response response = post(httpUrl, writeRequestBody(codeQuestionVO));
+        return getResponseBody(response, CodeQuestionVO.class).orElseThrow(() -> SeecoderBokException.UNWRAP_EXCEPTION);
+    }
+
+    @Override
+    public CodeQuestionVO updateCodeQuestion(@NotNull CodeQuestionVO codeQuestionVO) {
+        HttpUrl httpUrl = createUrlBuilder(
+                MessageFormat.format("/api/codeQuestion/{0}", codeQuestionVO.getId())).build();
+        Response response = put(httpUrl, writeRequestBody(codeQuestionVO));
+        return getResponseBody(response, CodeQuestionVO.class).orElseThrow(() -> SeecoderBokException.UNWRAP_EXCEPTION);
+    }
+
     private Response get(HttpUrl httpUrl) {
         return requestWithMethod("GET", httpUrl, null);
     }

+ 22 - 0
seecoder-bok-client/src/main/java/cn/seecoder/bok/client/SeecoderBokCodeQuestionApi.java

@@ -0,0 +1,22 @@
+package cn.seecoder.bok.client;
+
+import cn.seecoder.bok.common.vo.CodeQuestionVO;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+import java.util.Optional;
+
+/**
+ * @author Kunduin
+ */
+public interface SeecoderBokCodeQuestionApi {
+    Page<CodeQuestionVO> getCodeQuestions(String title, Pageable pageable);
+
+    Optional<CodeQuestionVO> getCodeQuestionById(@NotBlank String id);
+
+    CodeQuestionVO createCodeQuestion(@NotNull CodeQuestionVO codeQuestionVO);
+
+    CodeQuestionVO updateCodeQuestion(@NotNull CodeQuestionVO codeQuestionVO);
+}

+ 1 - 1
seecoder-bok-common/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>seecoder-bok</artifactId>
         <groupId>cn.seecoder</groupId>
-        <version>0.0.1</version>
+        <version>0.0.2</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 

+ 122 - 0
seecoder-bok-common/src/main/java/cn/seecoder/bok/common/vo/CodeQuestionVO.java

@@ -0,0 +1,122 @@
+package cn.seecoder.bok.common.vo;
+
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+
+/**
+ * @author Kunduin
+ */
+public class CodeQuestionVO {
+
+    String id;
+    private List<String> languages;
+    private String title;
+
+    private String description;
+    private String inputDescription;
+    private String outputDescription;
+
+    private Integer limitedMemory;
+    private Integer limitMillSeconds;
+
+    private HashMap<String, String> inputOutputMapping;
+
+    private Date lastModifiedAt;
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public List<String> getLanguages() {
+        return languages;
+    }
+
+    public void setLanguages(List<String> languages) {
+        this.languages = languages;
+    }
+
+    public String getTitle() {
+        return title;
+    }
+
+    public void setTitle(String title) {
+        this.title = title;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+    public String getInputDescription() {
+        return inputDescription;
+    }
+
+    public void setInputDescription(String inputDescription) {
+        this.inputDescription = inputDescription;
+    }
+
+    public String getOutputDescription() {
+        return outputDescription;
+    }
+
+    public void setOutputDescription(String outputDescription) {
+        this.outputDescription = outputDescription;
+    }
+
+    public Integer getLimitedMemory() {
+        return limitedMemory;
+    }
+
+    public void setLimitedMemory(int limitedMemory) {
+        this.limitedMemory = limitedMemory;
+    }
+
+    public Integer getLimitMillSeconds() {
+        return limitMillSeconds;
+    }
+
+    public void setLimitMillSeconds(int limitMillSeconds) {
+        this.limitMillSeconds = limitMillSeconds;
+    }
+
+    public HashMap<String, String> getInputOutputMapping() {
+        return inputOutputMapping;
+    }
+
+    public void setInputOutputMapping(HashMap<String, String> inputOutputMapping) {
+        this.inputOutputMapping = inputOutputMapping;
+    }
+
+    public Date getLastModifiedAt() {
+        return lastModifiedAt;
+    }
+
+    public void setLastModifiedAt(Date lastModifiedAt) {
+        this.lastModifiedAt = lastModifiedAt;
+    }
+
+    @Override
+    public String toString() {
+        return "CodeQuestionVO{" +
+                "id='" + id + '\'' +
+                ", languages=" + languages +
+                ", title='" + title + '\'' +
+                ", description='" + description + '\'' +
+                ", inputDescription='" + inputDescription + '\'' +
+                ", outputDescription='" + outputDescription + '\'' +
+                ", limitedMemory=" + limitedMemory +
+                ", limitMillSeconds=" + limitMillSeconds +
+                ", inputOutputMapping=" + inputOutputMapping +
+                ", lastModifiedAt=" + lastModifiedAt +
+                '}';
+    }
+}