|
|
@@ -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);
|
|
|
}
|