From b94d80f6b9a17e220d25940a3c22db8ef4c868e3 Mon Sep 17 00:00:00 2001 From: 3y Date: Sun, 7 Aug 2022 15:01:32 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96=E5=AE=A2=E6=88=B7?= =?UTF-8?q?=E7=AB=AF=E7=9A=84=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- austin-client/pom.xml | 31 +++++++++ .../austin/client/service/AustinService.java | 63 +++++++++++++++++++ .../controller/MessageTemplateController.java | 2 +- docker/Dockerfile | 4 +- pom.xml | 1 + 5 files changed, 98 insertions(+), 3 deletions(-) create mode 100644 austin-client/pom.xml create mode 100644 austin-client/src/main/java/com/java3y/austin/client/service/AustinService.java diff --git a/austin-client/pom.xml b/austin-client/pom.xml new file mode 100644 index 0000000..e0766b9 --- /dev/null +++ b/austin-client/pom.xml @@ -0,0 +1,31 @@ + + + + austin + com.java3y.austin + 0.0.1-SNAPSHOT + + 4.0.0 + + austin-client + + + 8 + 8 + + + + + com.java3y.austin + austin-service-api + 0.0.1-SNAPSHOT + + + cn.hutool + hutool-all + + + + \ No newline at end of file diff --git a/austin-client/src/main/java/com/java3y/austin/client/service/AustinService.java b/austin-client/src/main/java/com/java3y/austin/client/service/AustinService.java new file mode 100644 index 0000000..847fe8b --- /dev/null +++ b/austin-client/src/main/java/com/java3y/austin/client/service/AustinService.java @@ -0,0 +1,63 @@ +package com.java3y.austin.client.service; + + +import cn.hutool.core.util.StrUtil; +import cn.hutool.http.HttpUtil; +import cn.hutool.json.JSON; +import cn.hutool.json.JSONUtil; +import com.java3y.austin.service.api.domain.MessageParam; +import com.java3y.austin.service.api.domain.SendRequest; +import com.java3y.austin.service.api.domain.SendResponse; +import com.java3y.austin.service.api.enums.BusinessCode; + +/** + * 对外提供的接口 + * + * @author 3y + */ +public class AustinService { + + private static final String SEND_PATH = "/send"; + private static final String RECALL_PATH = "/messageTemplate/recall"; + + /** + * 发送消息 + * + * @param host 调用的接口host + * @param sendRequest 发送消息入参 + * @return + * @throws Exception + */ + public static SendResponse send(String host, SendRequest sendRequest) throws Exception { + String url = host + SEND_PATH; + String result = HttpUtil.post(url, JSONUtil.toJsonStr(sendRequest)); + return JSONUtil.toBean(result, SendResponse.class); + } + + /** + * 根据模板ID撤回消息 + * + * @param host 调用的接口host + * @param id 撤回消息的模板ID + * @return + * @throws Exception + */ + public static SendResponse recall(String host, String id) throws Exception { + String url = host + RECALL_PATH + StrUtil.SLASH + id; + String result = HttpUtil.post(url, id); + return JSONUtil.toBean(result, SendResponse.class); + } + + public static void main(String[] args) { + SendRequest request = SendRequest.builder().code(BusinessCode.COMMON_SEND.getCode()) + .messageTemplateId(68L) + .messageParam(MessageParam.builder().receiver("phone").build()).build(); + + try { + AustinService.send("url", request); + } catch (Exception e) { + System.out.println(e); + + } + } +} diff --git a/austin-web/src/main/java/com/java3y/austin/web/controller/MessageTemplateController.java b/austin-web/src/main/java/com/java3y/austin/web/controller/MessageTemplateController.java index 7b6dc3d..f115be1 100644 --- a/austin-web/src/main/java/com/java3y/austin/web/controller/MessageTemplateController.java +++ b/austin-web/src/main/java/com/java3y/austin/web/controller/MessageTemplateController.java @@ -136,7 +136,7 @@ public class MessageTemplateController { } /** - * 测试发送接口 + * 撤回接口 */ @PostMapping("recall/{id}") @ApiOperation("/撤回消息接口") diff --git a/docker/Dockerfile b/docker/Dockerfile index c815681..80b7b27 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -13,5 +13,5 @@ EXPOSE 8080 # 运行jar包 ENTRYPOINT ["sh","-c","java -jar $JAVA_OPTS austin.jar $PARAMS"] - -# docker run -e PARAMS="--austin.database.ip= --austin.database.port=3306 --austin.redis.ip= --austin.mq.pipeline=eventbus " -p 8080:8080 --name austin:1.0 +# docker build -t austin:0.1 . +# docker run -e PARAMS="--austin.database.ip= --austin.database.port=3306 --austin.redis.ip= --austin.mq.pipeline=eventbus " -p 8080:8080 --name austin:0.1 diff --git a/pom.xml b/pom.xml index 8fca343..141317c 100644 --- a/pom.xml +++ b/pom.xml @@ -13,6 +13,7 @@ austin-handler austin-cron austin-stream + austin-client