zhanghua
2025-04-14 1cad14bca191807e18705c3a5526eda8151be439
ycl-platform/src/main/java/com/ycl/timer/GetDingToken.java
@@ -6,6 +6,8 @@
import com.alibaba.xxpt.gateway.shared.client.http.GetClient;
import com.alibaba.xxpt.gateway.shared.client.http.PostClient;
import com.ycl.config.DingConfig;
import com.ycl.util.DingUtil;
import com.ycl.util.VideoUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@@ -26,7 +28,7 @@
 */
@Slf4j
@Component
public class GetDingToken implements ApplicationListener<ContextRefreshedEvent> {
public class GetDingToken implements  ApplicationListener<ContextRefreshedEvent> {
    private static GetClient getTokenClient;
    @Autowired
    private StringRedisTemplate redisTemplate;
@@ -36,7 +38,8 @@
    @Resource
    private DingConfig dingConfig;
    @Autowired
    private DingUtil dingUtil;
    private String getToken() {
        //调用API
@@ -96,15 +99,15 @@
    @Value("${spring.profiles.active}")
    private String env;
        @Scheduled(cron ="0 0/2 * * * ? ")
        @Scheduled(cron ="0 0/2 * * * ?")
//    @Scheduled(cron = "0/1 * * * * ?")   // 每秒执行
    public void runAction() {
//        System.out.println("环境:" + env);
        if ("online".equals(env)) {
            //gettoken
            String getToken = getToken();
            String getToken = dingUtil.getToken();
            //jsApi
            String jsapiToken = getTiker(getToken);
            String jsapiToken = dingUtil.getTiker(getToken);
            //存储到redis
            JSONObject dingObj = new JSONObject();
            dingObj.put("token", getToken);