admin
2021-07-30 a66b556036c2b3936a51fd7b7e54a204eb31dc14
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
package com.yeshi.buwan.job;
 
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import com.yeshi.buwan.domain.live.TVLiveChannel;
import com.yeshi.buwan.domain.live.TVLiveChannelResourceMap;
import com.yeshi.buwan.domain.live.TVLiveResource;
import com.yeshi.buwan.live.migu.MiGuLiveListInfo;
import com.yeshi.buwan.live.migu.MiguLiveApiUtil;
import com.yeshi.buwan.service.inter.live.MiGuLiveService;
import com.yeshi.buwan.service.inter.live.TVLiveChannelResourceService;
import com.yeshi.buwan.service.inter.live.TVLiveChannelService;
import com.yeshi.buwan.service.inter.system.SystemConfigService;
import com.yeshi.buwan.util.factory.live.TVLiveChannelFactory;
import net.sf.json.JSONArray;
import org.springframework.stereotype.Component;
 
import javax.annotation.Resource;
import java.util.List;
 
//10409568
@Component
public class LiveJob {
    @Resource
    private SystemConfigService systemConfigService;
 
    @Resource
    private MiGuLiveService miGuLiveService;
 
    @Resource
    private TVLiveChannelService tvLiveService;
 
    @Resource
    private TVLiveChannelResourceService tvLiveChannelResourceService;
 
    //打开华为应用市场的广告
    @XxlJob("live-update-migu")
    public ReturnT<String> updateMiGu(String params) throws Exception {
        String value = systemConfigService.getConfigValueByKeyCache("miguLiveCategory");
        JSONArray array = JSONArray.fromObject(value);
        for (int i = 0; i < array.size(); i++) {
            String vomsID = array.optJSONObject(i).optString("vomsID");
            List<MiGuLiveListInfo> mList = MiguLiveApiUtil.getLiveList(vomsID);
            for (MiGuLiveListInfo info : mList) {
                miGuLiveService.saveChannelInfo(info);
                TVLiveChannel channel = TVLiveChannelFactory.create(info);
                //添加到频道
                tvLiveService.save(channel);
 
                TVLiveChannelResourceMap map = new TVLiveChannelResourceMap();
                map.setChannelId(channel.getId());
                map.setId(TVLiveChannelResourceMap.createId(channel.getId(), TVLiveResource.migu));
                map.setResource(TVLiveResource.migu);
                map.setRid(info.getId());
                map.setWeight(1);
                tvLiveChannelResourceService.add(map);
            }
        }
 
 
        return ReturnT.SUCCESS;
    }
 
 
}