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 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 ; } }