Skip to content

Commit

Permalink
fix trans api
Browse files Browse the repository at this point in the history
  • Loading branch information
Pursue Wind committed Mar 6, 2024
1 parent 6d6c45a commit b440f9d
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
Binary file modified build/libs/intellij-plugin-bobobox-17.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@ abstract class AbsCodeGenerator : CodeGenerator {
action()
} catch (throwable: Throwable) {
throwable.printStackTrace()
onError(throwable)
}

private fun onError(throwable: Throwable): Nothing {
throw Exception()
throw throwable
}

protected open fun beforeAppend() = ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class GeneratePostfixTemplateProvider : BasePostfixTemplateProvider() {
GenerateSetterNoSuper(),
GenerateBuilder(),
GenerateGetSet(),
//
// 驼峰下划线转换
ToCamelCaseTemplate(),
ToUnderscoreTemplate(),
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.github.pursuewind.intellij.plugin.generate.trans

import com.google.gson.Gson
import io.github.pursuewind.intellij.plugin.generate.util.Http
import io.github.pursuewind.intellij.plugin.generate.AbsCodeGenerator
import java.util.concurrent.CompletableFuture
Expand Down Expand Up @@ -61,6 +62,8 @@ object UlCodeGenerator : AbsCodeGenerator() {


data class TranslationResponse(
val error_code: String?,
val error_msg: String?,
val from: String,
val to: String,
val trans_result: List<Translation>
Expand All @@ -80,5 +83,5 @@ fun youDaoRequest(chinese: String): String {
}

val resp = f.get(2, TimeUnit.SECONDS)
return resp?.trans_result?.first()?.dst ?: ""
return if (resp.error_code == null) resp?.trans_result?.first()?.dst.orEmpty() else ""
}

0 comments on commit b440f9d

Please sign in to comment.