Skip to content

Commit

Permalink
Merge pull request #15 from laigeoffer/dev
Browse files Browse the repository at this point in the history
fix/修改企微机器人通知配置
  • Loading branch information
freestylefly authored Apr 2, 2024
2 parents b41fdf4 + a881ce9 commit d7698ea
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
2 changes: 2 additions & 0 deletions pmhub-admin/src/main/resources/application-local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ pmhub:
profile: ./upload
# 企微相关
workWx:
# 项目启动成功机器人通知(默认本地关闭线上部署开启,开启可修改ExitRunner逻辑即可)
robert-url: 替换成自己的企微机器人webhook地址
host: https://laigeoffer.cn
corpid: wx123a99282131
corpsecret: 231asdad
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@ public class ExitRunner implements DisposableBean {

@Value("${spring.profiles.active}")
String activeStr;
@Value("${pmhub.workWx.robert-url}")
String robert_url;

@Override
public void destroy() throws Exception {
LogFactory.get().info("开始关闭,发送企微机器人通知");
String message = String.format("项目管理系统【%s】开始关闭! %s ",activeStr, DateUtil.now());
String message = String.format("PmHub系统【%s】开始关闭! %s ",activeStr, DateUtil.now());
// 屏蔽local
if (!"local".equals(activeStr)){
WxBotUtils.sendMessage(message);
WxBotUtils.sendMessage(message,robert_url);
}
LogFactory.get().info(message);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,16 @@ public class StarterRunner implements CommandLineRunner {
@Value("${spring.profiles.active}")
String activeStr;

@Value("${pmhub.workWx.robert-url}")
String robert_url;

@Override
public void run(String... args) throws Exception {
LogFactory.get().info("启动完成,发送企微机器人通知");
String message = String.format("项目管理系统【%s】分支服务已于: %s 启动完成!",activeStr, DateUtil.now());
String message = String.format("PmHub系统【%s】分支服务已于: %s 启动完成!",activeStr, DateUtil.now());
// 屏蔽local
if (!"local".equals(activeStr)){
WxBotUtils.sendMessage(message);
WxBotUtils.sendMessage(message,robert_url);
}
LogFactory.get().info(message);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,17 @@
*/
public class WxBotUtils {

private static final String URL = "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=dbfaae98-6faf-4f52-98d1-ae166a2e1fda";


/**
* 发送企微机器人消息
* */
public static String sendMessage(String msg){
public static String sendMessage(String msg, String url){
JSONObject jsonObject = new JSONObject();
JSONObject jsonMsg = new JSONObject();
jsonObject.set("msgtype","text");
jsonMsg.set("content",msg);
jsonObject.set("text",jsonMsg);
String result2 = HttpRequest.post(URL)
String result2 = HttpRequest.post(url)
.body(jsonObject.toString())
.execute().body();
return result2;
Expand Down

0 comments on commit d7698ea

Please sign in to comment.