1 changed files with 58 additions and 0 deletions
			
			
		@ -0,0 +1,58 @@ | 
				
			|||||
 | 
					/** | 
				
			||||
 | 
					 * Copyright (c) 2018 人人开源 All rights reserved. | 
				
			||||
 | 
					 * <p> | 
				
			||||
 | 
					 * https://www.renren.io
 | 
				
			||||
 | 
					 * <p> | 
				
			||||
 | 
					 * 版权所有,侵权必究! | 
				
			||||
 | 
					 */ | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					package com.epmet.commons.tools.aspect; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					import com.epmet.commons.tools.dto.form.DingTalkTextMsg; | 
				
			||||
 | 
					import com.epmet.commons.tools.enums.EnvEnum; | 
				
			||||
 | 
					import com.epmet.commons.tools.utils.HttpClientManager; | 
				
			||||
 | 
					import com.epmet.commons.tools.utils.Result; | 
				
			||||
 | 
					import org.apache.logging.log4j.LogManager; | 
				
			||||
 | 
					import org.apache.logging.log4j.Logger; | 
				
			||||
 | 
					import org.springframework.beans.factory.annotation.Value; | 
				
			||||
 | 
					import org.springframework.boot.ApplicationArguments; | 
				
			||||
 | 
					import org.springframework.boot.ApplicationRunner; | 
				
			||||
 | 
					import org.springframework.core.annotation.Order; | 
				
			||||
 | 
					import org.springframework.stereotype.Component; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					/** | 
				
			||||
 | 
					 * 应用 启动健康检查 通知类 | 
				
			||||
 | 
					 * CustomerApplicationRunner | 
				
			||||
 | 
					 * | 
				
			||||
 | 
					 * @author Mark sunlightcs@gmail.com | 
				
			||||
 | 
					 * @since 1.0.0 | 
				
			||||
 | 
					 */ | 
				
			||||
 | 
					@Component | 
				
			||||
 | 
					@Order(value = 99) | 
				
			||||
 | 
					public class CustomerApplicationRunner implements ApplicationRunner { | 
				
			||||
 | 
					    private static Logger logger = LogManager.getLogger(CustomerApplicationRunner.class); | 
				
			||||
 | 
					    @Value("${spring.application.name}") | 
				
			||||
 | 
					    private String appName; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					    @Override | 
				
			||||
 | 
					    public void run(ApplicationArguments args) { | 
				
			||||
 | 
					        //发送启动成功消息
 | 
				
			||||
 | 
					        EnvEnum currentEnv = EnvEnum.getCurrentEnv(); | 
				
			||||
 | 
					        if (!EnvEnum.DEV.getCode().equals(currentEnv.getCode())) { | 
				
			||||
 | 
					            //开发小组 群机器人地址
 | 
				
			||||
 | 
					            String url = "https://oapi.dingtalk.com/robot/send?access_token=ffd7c972b0525e249283df1a16b65a8b9d0012601f3a458dfc588c2eac497bb5"; | 
				
			||||
 | 
					            StringBuilder stringBuilder = new StringBuilder(EnvEnum.getCurrentEnv().getName()); | 
				
			||||
 | 
					            stringBuilder.append(" 应用:【") | 
				
			||||
 | 
					                    .append(appName) | 
				
			||||
 | 
					                    .append("】 ") | 
				
			||||
 | 
					                    .append("started!"); | 
				
			||||
 | 
					            DingTalkTextMsg msg = new DingTalkTextMsg(); | 
				
			||||
 | 
					            msg.setWebHook(url); | 
				
			||||
 | 
					            msg.setAtAll(true); | 
				
			||||
 | 
					            msg.setContent(stringBuilder.toString()); | 
				
			||||
 | 
					            Result<String> stringResult = HttpClientManager.getInstance().sendPostByJSON(url, msg.getMsgContent()); | 
				
			||||
 | 
					            logger.info(stringResult); | 
				
			||||
 | 
					        } | 
				
			||||
 | 
					    } | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					} | 
				
			||||
					Loading…
					
					
				
		Reference in new issue