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