10 changed files with 172 additions and 1 deletions
			
			
		| @ -0,0 +1,13 @@ | |||||
|  | package com.epmet.service; | ||||
|  | 
 | ||||
|  | import com.epmet.commons.tools.utils.Result; | ||||
|  | 
 | ||||
|  | /** | ||||
|  |  * @Author zxc | ||||
|  |  * @CreateTime 2020/7/20 10:21 | ||||
|  |  */ | ||||
|  | public interface ComponentAccessTokenService { | ||||
|  | 
 | ||||
|  |     Result componentAccessTokenJob(); | ||||
|  | 
 | ||||
|  | } | ||||
| @ -0,0 +1,13 @@ | |||||
|  | package com.epmet.service; | ||||
|  | 
 | ||||
|  | import com.epmet.commons.tools.utils.Result; | ||||
|  | 
 | ||||
|  | /** | ||||
|  |  * @Author zxc | ||||
|  |  * @CreateTime 2020/7/20 10:44 | ||||
|  |  */ | ||||
|  | public interface RefreshAuthAccessTokenService { | ||||
|  | 
 | ||||
|  |     Result refreshAuthorizerAccessTokenJob(); | ||||
|  | 
 | ||||
|  | } | ||||
| @ -0,0 +1,25 @@ | |||||
|  | package com.epmet.service.impl; | ||||
|  | 
 | ||||
|  | import com.epmet.commons.tools.utils.Result; | ||||
|  | import com.epmet.feign.EpmetThirdFeignClient; | ||||
|  | import com.epmet.service.ComponentAccessTokenService; | ||||
|  | import lombok.extern.slf4j.Slf4j; | ||||
|  | import org.springframework.beans.factory.annotation.Autowired; | ||||
|  | import org.springframework.stereotype.Service; | ||||
|  | 
 | ||||
|  | /** | ||||
|  |  * @Author zxc | ||||
|  |  * @CreateTime 2020/7/20 10:22 | ||||
|  |  */ | ||||
|  | @Slf4j | ||||
|  | @Service | ||||
|  | public class ComponentAccessTokenServiceImpl implements ComponentAccessTokenService { | ||||
|  | 
 | ||||
|  |     @Autowired | ||||
|  |     private EpmetThirdFeignClient epmetThirdFeignClient; | ||||
|  | 
 | ||||
|  |     @Override | ||||
|  |     public Result componentAccessTokenJob() { | ||||
|  |         return epmetThirdFeignClient.getComponentAccessTokenJob(); | ||||
|  |     } | ||||
|  | } | ||||
| @ -0,0 +1,23 @@ | |||||
|  | package com.epmet.service.impl; | ||||
|  | 
 | ||||
|  | import com.epmet.commons.tools.utils.Result; | ||||
|  | import com.epmet.feign.EpmetThirdFeignClient; | ||||
|  | import com.epmet.service.RefreshAuthAccessTokenService; | ||||
|  | import org.springframework.beans.factory.annotation.Autowired; | ||||
|  | import org.springframework.stereotype.Service; | ||||
|  | 
 | ||||
|  | /** | ||||
|  |  * @Author zxc | ||||
|  |  * @CreateTime 2020/7/20 10:44 | ||||
|  |  */ | ||||
|  | @Service | ||||
|  | public class RefreshAuthAccessTokenServiceImpl implements RefreshAuthAccessTokenService { | ||||
|  | 
 | ||||
|  |     @Autowired | ||||
|  |     private EpmetThirdFeignClient epmetThirdFeignClient; | ||||
|  | 
 | ||||
|  |     @Override | ||||
|  |     public Result refreshAuthorizerAccessTokenJob() { | ||||
|  |         return epmetThirdFeignClient.refreshAuthorizerAccessTokenJob(); | ||||
|  |     } | ||||
|  | } | ||||
| @ -0,0 +1,34 @@ | |||||
|  | package com.epmet.task; | ||||
|  | 
 | ||||
|  | import com.epmet.commons.tools.utils.Result; | ||||
|  | import com.epmet.service.ComponentAccessTokenService; | ||||
|  | import org.slf4j.Logger; | ||||
|  | import org.slf4j.LoggerFactory; | ||||
|  | import org.springframework.beans.factory.annotation.Autowired; | ||||
|  | import org.springframework.stereotype.Component; | ||||
|  | 
 | ||||
|  | 
 | ||||
|  | /** | ||||
|  |  * @Author zxc | ||||
|  |  * @CreateTime 2020/7/20 10:28 | ||||
|  |  */ | ||||
|  | @Component("componentAccessToken") | ||||
|  | public class ComponentAccessTokenTask implements ITask{ | ||||
|  | 
 | ||||
|  |     @Autowired | ||||
|  |     private ComponentAccessTokenService componentAccessTokenService; | ||||
|  | 
 | ||||
|  |     private Logger logger = LoggerFactory.getLogger(getClass()); | ||||
|  | 
 | ||||
|  | 
 | ||||
|  |     @Override | ||||
|  |     public void run(String params) { | ||||
|  |         logger.info("ComponentAccessTokenTask正在执行定时任务,参数为{}",params); | ||||
|  |         Result result = componentAccessTokenService.componentAccessTokenJob(); | ||||
|  |         if (result.success()){ | ||||
|  |             logger.info("ComponentAccessTokenTask定时任务执行成功"); | ||||
|  |         }else { | ||||
|  |             logger.error("ComponentAccessTokenTask定时任务执行失败:" + result.getMsg()); | ||||
|  |         } | ||||
|  |     } | ||||
|  | } | ||||
| @ -0,0 +1,32 @@ | |||||
|  | package com.epmet.task; | ||||
|  | 
 | ||||
|  | import com.epmet.commons.tools.utils.Result; | ||||
|  | import com.epmet.service.RefreshAuthAccessTokenService; | ||||
|  | import org.slf4j.Logger; | ||||
|  | import org.slf4j.LoggerFactory; | ||||
|  | import org.springframework.beans.factory.annotation.Autowired; | ||||
|  | import org.springframework.stereotype.Component; | ||||
|  | 
 | ||||
|  | /** | ||||
|  |  * @Author zxc | ||||
|  |  * @CreateTime 2020/7/20 10:46 | ||||
|  |  */ | ||||
|  | @Component("refreshAuthAccessTokenTask") | ||||
|  | public class RefreshAuthAccessTokenTask implements ITask { | ||||
|  | 
 | ||||
|  |     private Logger logger = LoggerFactory.getLogger(getClass()); | ||||
|  | 
 | ||||
|  |     @Autowired | ||||
|  |     private RefreshAuthAccessTokenService refreshAuthAccessTokenService; | ||||
|  | 
 | ||||
|  |     @Override | ||||
|  |     public void run(String params) { | ||||
|  |         logger.info("RefreshAuthAccessTokenTask正在执行定时任务,参数为{}",params); | ||||
|  |         Result result = refreshAuthAccessTokenService.refreshAuthorizerAccessTokenJob(); | ||||
|  |         if (result.success()){ | ||||
|  |             logger.info("RefreshAuthAccessTokenTask定时任务执行成功"); | ||||
|  |         }else { | ||||
|  |             logger.error("RefreshAuthAccessTokenTask定时任务执行失败:" + result.getMsg()); | ||||
|  |         } | ||||
|  |     } | ||||
|  | } | ||||
					Loading…
					
					
				
		Reference in new issue