|
|
|
@@ -0,0 +1,67 @@ |
|
|
|
package com.iformall.controller; |
|
|
|
|
|
|
|
import cn.binarywang.wx.miniapp.api.WxMaService; |
|
|
|
import com.iformall.annotation.RedisCache; |
|
|
|
import com.iformall.common.ErrorCode; |
|
|
|
import com.iformall.common.ResultData; |
|
|
|
import com.iformall.domain.po.*; |
|
|
|
import com.iformall.exception.MallinkException; |
|
|
|
import io.swagger.annotations.Api; |
|
|
|
import io.swagger.annotations.ApiOperation; |
|
|
|
import me.chanjar.weixin.common.error.WxErrorException; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
@RestController |
|
|
|
@RequestMapping("/api/live") |
|
|
|
@Api(tags = "微信直播相关接口") |
|
|
|
public class WxLiveController extends BaseController { |
|
|
|
private final Logger logger = LoggerFactory.getLogger(this.getClass()); |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取所有直播间和商品信息(没有分页直接获取全部) |
|
|
|
* |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@ApiOperation("获取所有直播间和商品信息") |
|
|
|
@RedisCache |
|
|
|
@GetMapping("/roomList") |
|
|
|
public ResultData getLiveinfos(String appId) { |
|
|
|
ResultData resultData = new ResultData(); |
|
|
|
try { |
|
|
|
WxMaService wxMaService = getWeappService(appId); |
|
|
|
resultData.data = wxMaService.getLiveService().getLiveinfos(); |
|
|
|
} catch (WxErrorException e) { |
|
|
|
logger.error("getLiveinfos error", e); |
|
|
|
throw new MallinkException(ErrorCode.SYS_SERVER_ERROR); |
|
|
|
} |
|
|
|
return resultData; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取直播房间回放数据信息. |
|
|
|
* <p> |
|
|
|
* 获取回放 (默认:get_replay) |
|
|
|
* |
|
|
|
* @param room_id 直播间 id |
|
|
|
* @param start 起始拉取视频,start = 0 表示从第 1 个视频片段开始拉取 |
|
|
|
* @param limit 每次拉取的个数上限,不要设置过大,建议 100 以内 |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@ApiOperation("获取直播房间回放数据和商品信息") |
|
|
|
@RedisCache |
|
|
|
@GetMapping("/replayList") |
|
|
|
public ResultData getLiveReplay(Integer room_id, Integer start, Integer limit) { |
|
|
|
ResultData resultData = new ResultData(); |
|
|
|
WxCUser user = getUser(); |
|
|
|
try { |
|
|
|
WxMaService wxMaService = getWeappService(user.getAppId()); |
|
|
|
resultData.data = wxMaService.getLiveService().getLiveReplay(room_id,start,limit); |
|
|
|
} catch (WxErrorException e) { |
|
|
|
logger.error("getLiveReplay error", e); |
|
|
|
throw new MallinkException(ErrorCode.SYS_SERVER_ERROR); |
|
|
|
} |
|
|
|
return resultData; |
|
|
|
} |
|
|
|
} |