5 changed files with 12 additions and 117 deletions
@ -1,50 +0,0 @@ |
|||||
package com.bnyer.common.core.client; |
|
||||
|
|
||||
import com.bnyer.common.core.dto.TextTranslateDto; |
|
||||
import com.bnyer.common.core.vo.TextTranslateVo; |
|
||||
import com.google.gson.JsonSyntaxException; |
|
||||
import com.google.gson.reflect.TypeToken; |
|
||||
import com.tencentcloudapi.common.AbstractClient; |
|
||||
import com.tencentcloudapi.common.Credential; |
|
||||
import com.tencentcloudapi.common.JsonResponseModel; |
|
||||
import com.tencentcloudapi.common.exception.TencentCloudSDKException; |
|
||||
import com.tencentcloudapi.common.profile.ClientProfile; |
|
||||
|
|
||||
import java.lang.reflect.Type; |
|
||||
|
|
||||
/** |
|
||||
* 翻译方法类 |
|
||||
*/ |
|
||||
public class TmtClient extends AbstractClient { |
|
||||
private static String endpoint = "tmt.tencentcloudapi.com"; |
|
||||
private static String service = "tmt"; |
|
||||
private static String version = "2018-03-21"; |
|
||||
|
|
||||
public TmtClient(Credential credential, String region) { |
|
||||
this(credential, region, new ClientProfile()); |
|
||||
} |
|
||||
|
|
||||
public TmtClient(Credential credential, String region, ClientProfile profile) { |
|
||||
super(TmtClient.endpoint, TmtClient.version, credential, region, profile); |
|
||||
} |
|
||||
|
|
||||
/** |
|
||||
* 汉译英 |
|
||||
* @param req TextTranslateRequest |
|
||||
* @return TextTranslateResponse |
|
||||
* @throws TencentCloudSDKException |
|
||||
*/ |
|
||||
public TextTranslateVo TextTranslate(TextTranslateDto req) throws TencentCloudSDKException { |
|
||||
JsonResponseModel<TextTranslateVo> rsp = null; |
|
||||
String rspStr = ""; |
|
||||
try { |
|
||||
Type type = new TypeToken<JsonResponseModel<TextTranslateVo>>() { |
|
||||
}.getType(); |
|
||||
rspStr = this.internalRequest(req, "TextTranslate"); |
|
||||
rsp = gson.fromJson(rspStr, type); |
|
||||
} catch (JsonSyntaxException e) { |
|
||||
throw new TencentCloudSDKException("response message: " + rspStr + ".\n Error message: " + e.getMessage()); |
|
||||
} |
|
||||
return rsp.response; |
|
||||
} |
|
||||
} |
|
||||
@ -1,31 +0,0 @@ |
|||||
package com.bnyer.common.core.dto; |
|
||||
|
|
||||
import com.tencentcloudapi.common.AbstractModel; |
|
||||
import lombok.Data; |
|
||||
|
|
||||
import java.util.HashMap; |
|
||||
|
|
||||
/** |
|
||||
* 翻译接收参数类 |
|
||||
*/ |
|
||||
@Data |
|
||||
public class TextTranslateDto extends AbstractModel { |
|
||||
|
|
||||
//翻译文本
|
|
||||
|
|
||||
private String SourceText; |
|
||||
|
|
||||
//源翻译语言
|
|
||||
private String Source; |
|
||||
|
|
||||
//目标翻译语言
|
|
||||
private String Target; |
|
||||
|
|
||||
//项目id
|
|
||||
private Long ProjectId; |
|
||||
|
|
||||
@Override |
|
||||
protected void toMap(HashMap<String, String> hashMap, String s) { |
|
||||
|
|
||||
} |
|
||||
} |
|
||||
@ -1,23 +0,0 @@ |
|||||
package com.bnyer.common.core.vo; |
|
||||
|
|
||||
import lombok.Data; |
|
||||
|
|
||||
/** |
|
||||
* 翻译接收响应类 |
|
||||
*/ |
|
||||
@Data |
|
||||
public class TextTranslateVo { |
|
||||
|
|
||||
//翻译后的文本
|
|
||||
private String TargetText; |
|
||||
|
|
||||
//源翻译语言
|
|
||||
private String Source; |
|
||||
|
|
||||
//目标翻译语言
|
|
||||
private String Target; |
|
||||
|
|
||||
//请求id
|
|
||||
private String RequestId; |
|
||||
|
|
||||
} |
|
||||
Loading…
Reference in new issue