admin
2024-09-05 ab35ac8b769b2d9816dffb33a64f2c6f7bd5dd6e
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package com.yeshi.buwan.util.JuHe;
 
import com.yeshi.buwan.domain.system.DetailSystem;
import com.yeshi.buwan.service.imp.DetailSystemConfigService;
import com.yeshi.buwan.service.inter.video.VideoResourcePlayVersionMapService;
import com.yeshi.buwan.service.inter.video.VideoResourceVersionMapService;
import com.yeshi.buwan.util.config.SystemConfigUtil;
import com.yeshi.buwan.videos.funtv.FunTVUtil;
import net.sf.json.JSONObject;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Component;
 
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
 
@Component
public class VideoResourceUtil {
    @Resource
    private VideoResourceVersionMapService videoResourceVersionMapService;
 
    @Resource
    private VideoResourcePlayVersionMapService videoResourcePlayVersionMapService;
 
    @Resource
    private DetailSystemConfigService detailSystemConfigService;
 
    @Cacheable(value = "homeCache", key = "'getAvailableResourceIds-'+'-'+#detailSystem.id+'-'+#versionCode+'-'+#channel")
    public List<Long> getAvailableResourceIds(DetailSystem detailSystem, int versionCode,String channel) {
        List<String> ridList = videoResourceVersionMapService.listResourceId(detailSystem.getId(), versionCode,channel.toLowerCase());
//        if (detailSystem.getId().equalsIgnoreCase("43") && versionCode > 83) {
//            ridList = new ArrayList<>();
////            ridList.add("19");
////            ridList.add("24");
//            ridList.add("25");
//        }
        ridList.remove(25+"");
        ridList.remove(28+"");
        //TODO 没有上线需要清除
        ridList.add(FunTVUtil.RESOURCE_ID+"");
        //是否是首次上线
        String firstOnLineValue =  detailSystemConfigService.getConfigValueByKey("first_online_versions",detailSystem.getId(), versionCode);
        if( SystemConfigUtil.isFirstOnLine(firstOnLineValue, channel, versionCode)){
            // 首次上线要打开风行
            ridList.add(FunTVUtil.RESOURCE_ID+"");
        }
        //韩剧上线的时候需要打开
//        if(detailSystem.getId().equalsIgnoreCase("51")){
//            ridList.add("28");
//        }
 
//        ridList.clear();
//        ridList.add("13");
//        ridList.add("22");
 
        List<Long> ids = new ArrayList<>();
        if (ridList != null) {
            for (String id : ridList) {
                ids.add(Long.parseLong(id));
            }
        }
 
        return ids;
    }
 
 
    @Cacheable(value = "homeCache", key = "'getAvailablePlayResourceIds-'+'-'+#detailSystem.id+'-'+#versionCode+'-'+#channel")
    public List<Long> getAvailablePlayResourceIds(DetailSystem detailSystem, int versionCode,String channel) {
        List<String> ridList = videoResourcePlayVersionMapService.listResourceId(detailSystem.getId(), versionCode,channel.toLowerCase());
        // 韩剧上线需要打开注释
//        if(detailSystem.getId().equalsIgnoreCase("51")){
//            ridList.add("28");
//        }
        // 首次上线要打开风行
        //TODO 没有上线需要清除
        ridList.add(FunTVUtil.RESOURCE_ID+"");
        String firstOnLineValue =  detailSystemConfigService.getConfigValueByKey("first_online_versions",detailSystem.getId(), versionCode);
        if( SystemConfigUtil.isFirstOnLine(firstOnLineValue, channel, versionCode)){
            ridList.add(FunTVUtil.RESOURCE_ID+"");
        }
 
        List<Long> ids = new ArrayList<>();
        if (ridList != null) {
            for (String id : ridList) {
                ids.add(Long.parseLong(id));
            }
        }
 
        return ids;
    }
 
 
}