liurunyu
昨天 83d9b0de6d127cf0f2822c51139fa4e15a3326e7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package com.dy.pipIrrRemote.video;
 
import com.dy.common.multiDataSource.DataSourceContext;
import com.dy.pipIrrGlobal.pojoVi.ViYsApp;
import com.dy.pipIrrGlobal.util.Org;
import com.dy.pipIrrGlobal.util.OrgListenerSupport;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ResourceLoader;
import org.springframework.web.bind.annotation.RestController;
 
import java.util.List;
 
/**
 * @Author: liurunyu
 * @Date: 2025/6/7 12:45
 * @Description 类名中包含Inner,表示内部应用的Controller
 */
@Slf4j
@RestController
public class YsAppCtrl extends OrgListenerSupport {
 
    @Autowired
    protected ResourceLoader resourceLoader ;
 
    @Autowired
    protected YsAppSv ysAppSv;
 
    public ViYsApp selectSingletonYsApp(){
        return ysAppSv.selectSingleton() ;
    }
 
    public Long saveAccessTokenOfYs(String accessToken, Long expireTime){
        if(Org.OrgList == null || Org.OrgList.size() == 0){
            super.init(resourceLoader);
        }
        List<Org.OrgVo> orgList = Org.OrgList ;
        if(orgList != null || orgList.size() > 0){
            for(Org.OrgVo vo : orgList){
                //遍历所有org,得到各自的萤石应用AccessToken
                DataSourceContext.set(vo.tag);//设置数据源
                ysAppSv.deleteAll();
                ysAppSv.save(accessToken, expireTime) ;
            }
        }
        return null ;
    }
}