package com.yeshi.buwan.controller.api;
|
|
import com.google.gson.*;
|
import com.yeshi.buwan.domain.live.*;
|
import com.yeshi.buwan.domain.user.LoginUser;
|
import com.yeshi.buwan.domain.vip.*;
|
import com.yeshi.buwan.dto.order.PPTVVideoPrice;
|
import com.yeshi.buwan.dto.order.PayWayInfoDTO;
|
import com.yeshi.buwan.exception.PPTVException;
|
import com.yeshi.buwan.exception.goldcorn.GoldCornException;
|
import com.yeshi.buwan.exception.order.OrderException;
|
import com.yeshi.buwan.exception.order.PayException;
|
import com.yeshi.buwan.exception.vip.VIPException;
|
import com.yeshi.buwan.exception.vip.VideoBuyRecordException;
|
import com.yeshi.buwan.live.migu.MiGuLiveListInfo;
|
import com.yeshi.buwan.live.migu.MiguLiveApiUtil;
|
import com.yeshi.buwan.service.inter.LoginUserService;
|
import com.yeshi.buwan.service.inter.juhe.PPTVService;
|
import com.yeshi.buwan.service.inter.live.*;
|
import com.yeshi.buwan.service.inter.order.OrderService;
|
import com.yeshi.buwan.service.inter.system.SystemConfigService;
|
import com.yeshi.buwan.service.inter.vip.VIPPriceService;
|
import com.yeshi.buwan.service.inter.vip.VIPService;
|
import com.yeshi.buwan.util.*;
|
import com.yeshi.buwan.videos.pptv.entity.PPTVSeries;
|
import com.yeshi.buwan.videos.pptv.entity.VideoPPTVMap;
|
import com.yeshi.buwan.vo.AcceptData;
|
import com.yeshi.buwan.vo.client.user.UserInfoVO;
|
import com.yeshi.buwan.vo.order.OrderInfoVO;
|
import com.yeshi.buwan.vo.tvlive.TVLiveChannelVO;
|
import net.sf.json.JSONObject;
|
import org.slf4j.Logger;
|
import org.slf4j.LoggerFactory;
|
import org.springframework.stereotype.Controller;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.yeshi.utils.annotation.RequestSerializableByKey;
|
|
import javax.annotation.Resource;
|
import javax.servlet.http.HttpServletRequest;
|
import java.lang.reflect.Type;
|
import java.math.BigDecimal;
|
import java.math.RoundingMode;
|
import java.util.ArrayList;
|
import java.util.Date;
|
import java.util.List;
|
|
/**
|
* 电视直播
|
*/
|
@Controller
|
@RequestMapping("api/v2/tvlive")
|
public class TVLiveController {
|
|
Logger logger = LoggerFactory.getLogger(TVLiveController.class);
|
|
|
@Resource
|
private TVLiveCategoryService tvLiveCategoryService;
|
|
@Resource
|
private TVLiveCategoryChannelService tvLiveCategoryChannelService;
|
|
@Resource
|
private TVLiveChannelResourceService tvLiveChannelResourceService;
|
|
@Resource
|
private MiGuLiveService miGuLiveService;
|
|
|
@RequestMapping("getCategory")
|
@ResponseBody
|
public String getCategory(AcceptData acceptData) {
|
Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
|
List<SuperTVLiveCategory> superList = tvLiveCategoryService.listSuper(acceptData.getDetailSystem().getId(), 1, 20);
|
List<String> channelIds = new ArrayList<>();
|
for (SuperTVLiveCategory category : superList) {
|
channelIds.add(category.getCid());
|
}
|
List<TVLiveCategory> categoryList = tvLiveCategoryService.listByIds(channelIds);
|
JSONObject data = new JSONObject();
|
data.put("count", categoryList.size());
|
data.put("data", gson.toJson(categoryList));
|
return JsonUtilV2.loadTrueJson(data.toString());
|
}
|
|
|
@RequestMapping("getChannelList")
|
@ResponseBody
|
public String getChannelList(AcceptData acceptData, String cid, int page) {
|
|
if (StringUtil.isNullOrEmpty(cid)) {
|
return JsonUtilV2.loadFalseJson("cid为空");
|
}
|
|
List<TVLiveChannel> channelList = tvLiveCategoryChannelService.listChannelByCid(cid, null, page, Constant.pageCount);
|
long count = tvLiveCategoryChannelService.countChannelByCid(cid, null);
|
|
List<TVLiveChannelVO> voList = new ArrayList<>();
|
for (TVLiveChannel channel : channelList) {
|
voList.add(TVLiveChannelVO.create(channel));
|
}
|
JSONObject root = new JSONObject();
|
root.put("list", new Gson().toJson(voList));
|
root.put("count", count);
|
return JsonUtilV2.loadTrueJson(root.toString());
|
}
|
|
@RequestMapping("getPlayUrl")
|
@ResponseBody
|
public String getPlayUrl(AcceptData acceptData, String id) {
|
|
if (StringUtil.isNullOrEmpty(id)) {
|
return JsonUtilV2.loadFalseJson("id为空");
|
}
|
|
//获取播放链接
|
|
List<TVLiveChannelResourceMap> mapList = tvLiveChannelResourceService.listByChannelId(id);
|
if (mapList == null || mapList.size() == 0) {
|
return JsonUtilV2.loadFalseJson("暂无播放源");
|
}
|
|
TVLiveChannelResourceMap map = mapList.get(0);
|
String playUrl = null;
|
if (map.getResource() == TVLiveResource.migu) {
|
MiGuLiveListInfo info = miGuLiveService.selectByPrimaryKey(map.getRid());
|
playUrl = MiguLiveApiUtil.getPlayUrl(info.getPID());
|
} else if (map.getResource() == TVLiveResource.other) {
|
|
}
|
JSONObject root = new JSONObject();
|
root.put("playUrl", playUrl);
|
return JsonUtilV2.loadTrueJson(root.toString());
|
}
|
|
|
}
|