Commit d3362571 by liangkaiping

copy

parent a564d591
# cloud-live
123
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>com.yizhi</groupId>
<artifactId>cloud-live</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.yizhi</groupId>
<artifactId>cloud-live-api</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<kotlin.version>1.4.10</kotlin.version>
</properties>
<dependencies>
<dependency>
<groupId>com.yizhi</groupId>
<artifactId>cloud-core</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.yizhi</groupId>
<artifactId>cloud-util</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.yizhi</groupId>
<artifactId>cloud-common-api</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>test-compile</id>
<phase>test-compile</phase>
<goals>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
<configuration>
<jvmTarget>1.8</jvmTarget>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>testCompile</id>
<phase>test-compile</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
package com.yizhi.live.application.constant;
import java.util.Arrays;
import java.util.List;
/**
* @Date 2020/9/23 8:21 下午
* @Author lvjianhui
**/
public enum EvenType {
COURSE_UP(1L, Arrays.asList(1, 2)),
COURSE_FINISH(2L, Arrays.asList(1, 2)),
ENROLL_START(3L, Arrays.asList(1, 3, 4, 5)),
TRAINING_AUDIT_PASS(4L, Arrays.asList(1, 3, 4, 5)),
TRAINING_AUDIT_FAIL(5L, Arrays.asList(1, 3, 4, 5)),
SIGN_SUCCESS(6L, Arrays.asList(1, 3, 4, 5)),
TRAINING_FINISH(7L, Arrays.asList(1, 3, 4, 5)),
ASSIGNMENT_AUDIT_FINISH(8L, Arrays.asList(1, 6, 7, 8)),
EXAM_AUDIT_FINISH(9L,Arrays.asList(1, 9, 10, 11)),
POINT_CHANGE(10L, Arrays.asList(1, 12, 13, 14));
private Long key;
private List<Integer> fieldType;
private EvenType(Long key, List<Integer> fieldType) {
this.key = key;
this.fieldType = fieldType;
}
public Long getKey() {
return this.key;
}
public List<Integer> getName() {
return this.fieldType;
}
}
package com.yizhi.live.application.constant;
public enum LiveStatusEnum {
LIVE(40,"开始直播"),
END(90,"直播结束"),
NO_START(10,"直播未开始"),
;
private int code;
private String desc;
LiveStatusEnum(int code, String desc) {
this.code = code;
this.desc = desc;
}
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
}
package com.yizhi.live.application.feign;
import com.baomidou.mybatisplus.plugins.Page;
import com.yizhi.core.application.vo.DroolsVo;
import com.yizhi.live.application.request.LiveReleaseReviewReq;
import com.yizhi.live.application.vo.*;
import com.yizhi.util.application.domain.BizResponse;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.Date;
import java.util.List;
import java.util.Map;
@FeignClient(name = "live", contextId = "LiveActivityClient")
public interface LiveActivityClient {
/**
* 获取直播的频道号
* @param id
* @return
*/
@GetMapping("/manage/live/channelNo/get")
public String getChannelNo(@RequestParam("id") Long id);
@PostMapping("/manage/live/save")
Boolean save(@RequestBody LiveActivityResultVO liveActivityResultVO);
/**
* 管理端 直播列表查询feign接口
*
* @param title 主题
* @param companyId 企业id
* @param siteId 站点id
* @param orgIds 管辖区id
* @param pageNo 分页的页数
* @param pageSize 分页的条数
* @return PageLiveVo 前台展示对象
*/
@GetMapping("/manage/live/list")
Page<PageLiveVo> list(
@RequestParam(name = "title", required = false) String title,
@RequestParam(name = "startTimeString", required = false) String startTimeString,
@RequestParam(name = "endTimeString", required = false) String endTimeString,
@RequestParam(name = "companyId", required = false) Long companyId,
@RequestParam(name = "siteId", required = false) Long siteId,
@RequestParam(name = "orgIds", required = false) List<Long> orgIds,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "20") Integer pageSize,
@RequestParam(name = "expTimeString", required = false) String expTimeString,
@RequestParam(name = "status" ,required = false) Integer status,
@RequestParam(name = "viewType", required = false) Integer viewType
);
@GetMapping("/manage/live/v2/list")
Page<PageLiveVo> listV2(
@RequestParam(name = "title", required = false) String title,
@RequestParam(name = "startTimeString", required = false) String startTimeString,
@RequestParam(name = "endTimeString", required = false) String endTimeString,
@RequestParam(name = "companyId", required = false) Long companyId,
@RequestParam(name = "siteId", required = false) Long siteId,
@RequestParam(name = "orgIds", required = false) List<Long> orgIds,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "20") Integer pageSize,
@RequestParam(name = "expTimeString", required = false) String expTimeString,
@RequestParam(name = "status" ,required = false) Integer status,
@RequestParam(name = "viewType", required = false) Integer viewType,
@RequestParam(name = "startTimeAsc",required = false) Boolean startTimeAsc,
@RequestParam(name = "endTimeAsc",required = false) Boolean endTimeAsc
);
@GetMapping("/remote/live/sevenDays/get")
List<LiveActivityVO> findWithinSevenDaysLive();
/**
* 首页配置选择直播列表
* @param title 主题
* @param startTime 开始时间
* @param endTime 结束时间
* @param companyId 企业id
* @param siteId 站点id
* @param orgIds 管辖区id
* @param pageNo 分页的页数
* @param pageSize 分页的条数
* @return PageLiveVo 前台展示对象
* @return List<PageLiveVo>
*/
@GetMapping("/manage/live/portal/list")
List<PageLiveVo> portalList(
@RequestParam(name = "title", required = false) String title,
@RequestParam(name = "startTime", required = false) Date startTime,
@RequestParam(name = "endTime", required = false) Date endTime,
@RequestParam(name = "companyId", required = false) Long companyId,
@RequestParam(name = "siteId", required = false) Long siteId,
@RequestParam(name = "orgIds", required = false) List<Long> orgIds,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "20") Integer pageSize
);
@GetMapping("/manage/live/portal/v2/list")
public Page<PageLiveVo> portalListV2(
@RequestParam(name = "title", required = false) String title,
@RequestParam(name = "startTime", required = false) Date startTime,
@RequestParam(name = "endTime", required = false) Date endTime,
@RequestParam(name = "companyId", required = false) Long companyId,
@RequestParam(name = "siteId", required = false) Long siteId,
@RequestParam(name = "orgIds", required = false) List<Long> orgIds,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "20") Integer pageSize
);
@PostMapping("/manage/live/delete")
Boolean delete(
@RequestBody LiveActivityVO liveActivity
);
@GetMapping("/manage/live/get")
LiveActivityResultVO get(@RequestParam("id") Long id);
/**
* 获取直播实体
* @param id
* @return
*/
@GetMapping("/manage/live/getLive")
LiveActivityVO getLive(@RequestParam("id") Long id);
@PostMapping("/manage/live/signature")
LiveAppIdVo signature();
@GetMapping("/manage/live/api/list")
List<PageLiveVo> apiList(
@RequestParam(name = "title", required = false) String title,
@RequestParam(name = "companyId", required = false) Long companyId,
@RequestParam(name = "siteId", required = false) Long siteId,
@RequestParam(name = "ids", required = false) List<Long> ids,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "20") Integer pageSize
);
@GetMapping("/manage/live/api/pageList")
Page<PageLiveVo> apiPageList(
@RequestParam(name = "title", required = false) String title,
@RequestParam(name = "companyId", required = false) Long companyId,
@RequestParam(name = "siteId", required = false) Long siteId,
@RequestParam(name = "ids", required = false) List<Long> ids,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "20") Integer pageSize
);
@PostMapping("/manage/live/token")
String getToken(@RequestBody LiveTokenVo liveTokenVo);
/**
* 直播指定范围保存
*
* @param scopeAuthorizations
* @return
*/
@PostMapping("/manage/live/scopeAuthorization/save")
Boolean saveScopeAuthorization(@RequestBody List<ScopeAuthorizationVO> scopeAuthorizations);
/**
* 直播指定范围保存,不删除之前的记录
*
* @param scopeAuthorizations
* @return
*/
@PostMapping("/manage/live/scopeAuthorization/insert")
Boolean insertScopeAuthorization(@RequestBody List<ScopeAuthorizationVO> scopeAuthorizations);
/**
* 已保存的指定范围集合
*
* @param liveId
* @return
*/
@GetMapping("/manage/live/scopeAuthorization/list")
List<ScopeAuthorizationVO> getScopeAuthorizationList(@RequestParam(name = "liveId") Long liveId);
/**
* 直播上架
*
* @param param 带id
* @return
*/
@PostMapping("/manage/live/up")
Boolean up(@RequestBody LiveActivityVO param);
/**
* 直播下架
*
* @param param 只带id
* @return
*/
@PostMapping("/manage/live/down")
Boolean down(@RequestBody LiveActivityVO param);
/**
* 直播修改信息
* @param liveActivityResultVO
* @return
*/
@PostMapping("/manage/live/update")
Boolean update(
@RequestBody LiveActivityResultVO liveActivityResultVO
);
/**
* 根据频道id获得直播信息
*/
@GetMapping("/manage/live/channelId/view")
LiveActivityVO viewByChannelId(@RequestParam(name = "channelId") String channelId);
/**
* 可见范围导出
* @param assignmentId
* @return
*/
@GetMapping("/manage/live/export/visiblRange")
public VisibleRangeExport exportVisibleRange(@RequestParam(name="liveId",required=true)Long liveId);
@PostMapping("/manage/live/access/lives")
public List<Long> accessLives(@RequestBody AccessLiveVO vo);
@GetMapping("/manage/live/pc/pageList")
public Page<PageLiveVo> pcPageList(@RequestParam(name = "title", required = false) String title,
@RequestParam(name = "ids", required = false) List<Long> ids,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "20") Integer pageSize);
/**
* 根据站点Id查询直播列表
* @param siteId
* @param pageNo
* @param pageSize
* @return
*/
@GetMapping("/manage/live/pc/getPage")
public Page<PageLiveVo> getPageLiveVoList(@RequestParam(name = "siteId", required = false) Long siteId,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "15") Integer pageSize);
@GetMapping("/manage/live/pc/getPage/notIds")
public Page<LiveActivityVO> getPageLiveVoListNotIds(
@RequestParam(name = "ids", required = false) List<Long> ids,
@RequestParam(name = "siteId", required = false) Long siteId,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "15") Integer pageSize);
/**
* 根据relationId 判断这个人是否可以看到这这场直播
*
* @param relationId 里面有accountId or orgId
* @param liveId 直播Id
* @return
*/
@GetMapping("/manage/live/pc/judgeScope")
public Boolean judgeScope(@RequestParam(name = "relationId", required = false) List<Long> relationId,
@RequestParam(name = "liveId", required = false) Long liveId);
/**
* 根据直播Id查看直播信息
*
* @param liveId
* @return
*/
@GetMapping("/manage/live/pc/queryLive")
public LiveActivityVO queryLive(@RequestParam(name = "liveId") Long liveId);
@GetMapping("/manage/live/pc/queryLive/byIds")
public Page<LiveActivityVO> LiveActivityByIds(@RequestParam(value="listIds",required=false)List<Long> listIds, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "15") Integer pageSize);
/**
* 根据传入的relationIds 里面有accountId、orgId
* @param relationIds
* @param pageNo
* @param pageSize
* @return
*/
@PostMapping("/manage/live/pc/queryLiveListByRelationIds")
public List<PageLiveVo> queryLiveListByRelationIds(@ApiParam(value = "relationIds 里面有accountId、orgId")
@RequestParam(value = "relationIds 里面有accountId、orgId",required = false) List<Long> relationIds,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "15") Integer pageSize);
/**
* 根据传入的频道Id,返回直播状态
* @param channelId
* @return 1--即将开始 2--live 直播中 3-end 直播结束 -1 获取状态异常
*/
@GetMapping("/manage/live/pc/getLiveStatus")
public Integer getLiveStatus(@ApiParam(value ="channelId 频道Id" )@RequestParam(value ="channelId" ) String channelId);
@GetMapping("/manage/live/by/new/server")
public List<Map<String,Object>> getServerByCompanyIdAndIds(@RequestParam("companyId")Long companyId,@RequestParam(name="ids",required=false)List<Long> ids);
@GetMapping("/manage/live/scope/message/getList")
public VisibleRangeExport getListToMessage(@RequestParam("liveId") Long liveId);
@PostMapping("/manage/live/getPageToCalendar")
public Page<PageLiveVo> getPageToCalendar(@ApiParam("paramVo") @RequestBody CalendarTaskParamVo paramVo);
@GetMapping("/manage/live/getPageByDrools")
Page<DroolsVo> getPageByDrools(@RequestParam("field") String field,
@RequestParam(value = "value", required = false) String value,
@RequestParam("pageNo") Integer pageNo,
@RequestParam("pageSize") Integer pageSize);
@GetMapping("/remote/live/statistics/online/count/realtime")
@ApiOperation(value = "实时查询直播在线人数;多个频道用逗号隔开")
public List<LiveOnlineCountVo> liveCountOnlineRealTime(@RequestParam("channelIds") String channelIds) ;
@GetMapping("/remote/live/status/callback")
@ApiOperation(value = "直播状态改变,保利威回调接口")
public BizResponse liveStatusCallback(@RequestParam(value = "channelId") String channelId
, @RequestParam(value = "status") String status
, @RequestParam(value = "timestamp") Long timestamp
, @RequestParam(value = "sign") String sign
, @RequestParam(value = "sessionId") String sessionId
, @RequestParam(value = "startTime") String startTime
, @RequestParam(value = "endTime") String endTime);
@GetMapping("/remote/live/play/review/list")
@ApiOperation(value = "查询直播回放列表")
public Page<LiveReplayVo> playReviewList(@RequestBody LiveReviewListVo liveReviewListVo) ;
@GetMapping("/remote/live/review/switch/on/live/list")
@ApiOperation(value = "查询有直播回放的直播间列表 废弃!!!")
public BizResponse<List<LiveTitleVo>> reviewLiveList(@RequestBody LiveReviewsVo liveReviewsVo);
@GetMapping("/remote/live/reviews/get")
@ApiOperation(value = "根据直播间查询上架的直播回放")
public BizResponse<List<LiveReplayVo>> reviewsList(@RequestBody LiveReviewsVo liveReviewsVo);
@GetMapping("/remote/live/review/one/get")
@ApiOperation(value = "查询直播回放详情")
public BizResponse<LiveReplayVo> getReview(@RequestParam(name = "replayId") Long replayId);
@GetMapping("/remote/live/review/switch/on/live/page/list")
@ApiOperation(value = "分页查询有直播回放的直播间列表")
public Page<LiveTitleVo> getHasReplayLiveList(@RequestBody LiveReleaseReviewReq replayVo);
@PostMapping("/remote/live/release/replay/list")
@ApiOperation(value = "查询所有上架的直播回放列表")
public Page<LiveReplayVo> getReleaseReplayList(@RequestBody LiveReleaseReviewReq reviewReq);
}
package com.yizhi.live.application.feign;
import com.baomidou.mybatisplus.plugins.Page;
import com.yizhi.live.application.vo.*;
import com.yizhi.util.application.domain.BizResponse;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
/**
* @Date 2020/12/9 1:42 下午
* @Author lvjianhui
**/
@FeignClient(name = "live", contextId = "LiveReplayClient")
public interface LiveReplayClient {
@GetMapping("/job/live/insert/replay")
@ApiOperation(value = "初始化已存在的直播回放")
public void insertLiveReplay();
@GetMapping("/remote/live/transfer/callback")
@ApiOperation(value = "直播转存成功,保利威回调接口")
public BizResponse<String> liveTransferCallback(@RequestBody PolyvLiveBackCallbackVo liveBackCallbackVo);
@PostMapping("/remote/live/replay/list")
@ApiOperation(value = "管理端根据直播间分页查询所有直播回放")
public Page<LiveReplayVo> getManageReplayList(@RequestBody LiveReviewsVo liveReviewsVo);
@PostMapping("/remote/live/replay/status/update")
@ApiOperation(value = "直播回放上架、下架")
public Boolean updateReplayStatus(@RequestBody LiveReplayOperationVo liveReplayOperationVo);
@PostMapping("/remote/live/replay/top/update")
@ApiOperation(value = "直播回放置顶")
public Boolean updateReplayTop(@RequestBody LiveReplayOperationVo liveReplayOperationVo);
@PostMapping("/remote/live/replay/info/update")
@ApiOperation(value = "直播回放信息修改")
public Boolean updateReplayInfo(@RequestBody LiveReplayInfoVo infoVo );
}
package com.yizhi.live.application.request;
import com.yizhi.core.application.context.RequestContext;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* 直播回放列表查询
*/
@Data
@Api
public class LiveReleaseReviewReq {
@ApiModelProperty(value = "直播主题、主播名称")
private String title;
@ApiModelProperty(value = "上下文")
private RequestContext requestContext;
private int pageNo;
private int pageSize;
}
package com.yizhi.live.application.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @Author: XieHaijun
* @Description:
* @Date: Created in 15:57 2018/10/29
* @Modified By
*/
@Data
public class AccessLiveVO {
@ApiModelProperty(value = "要访问的直播id")
private List<Long> liveIds;
@ApiModelProperty(value = "要访问的直播的用户的组织id以及全部的上级id")
private List<Long> orgIds;
@ApiModelProperty(value = "要访问的直播的用户id集合")
private List<Long> userIds;
}
package com.yizhi.live.application.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* @Date 2020/9/23 8:06 下午
* @Author lvjianhui
**/
@ApiModel
@Data
public class CalendarTaskParamVo {
@ApiModelProperty("时间参数")
public Date date;
@ApiModelProperty("业务类型")
public Integer taskType = 0;
@ApiModelProperty("当前页数")
public Integer pageNo;
@ApiModelProperty("页内条数")
public Integer pageSize;
}
/**
* FileName: LiveActivityResultVO
* Author: wenjunlong
* Date: 2018/6/27 20:22
* Description: 直播信息结果返回vo
* History:
* <author> <time> <version> <desc>
* 作者姓名 修改时间 版本号 描述
*/
package com.yizhi.live.application.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* 〈一句话功能简述〉<br>
* 〈直播信息结果返回vo〉
*
* @author wenjunlong
* @create 2018/6/27
* @since 1.0.0
*/
@Data
public class LiveActivityResultVO {
private LiveActivityVO liveActivity;
List<ScopeAuthorizationVO> scopeAuthorizations;
@ApiModelProperty(value = "各个业务设置提醒时的数据")
private MessageRemindVo messageRemindVo;
}
package com.yizhi.live.application.vo;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableLogic;
import com.baomidou.mybatisplus.enums.FieldFill;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* @Date 2020/9/29 6:13 下午
* @Author lvjianhui
**/
@Data
public class LiveActivityVO {
@ApiModelProperty(value = "主键")
private Long id;
@ApiModelProperty(value = "直播主题")
private String title;
@ApiModelProperty(value = "直播密码")
private String password;
@ApiModelProperty(value = "直播logo")
@TableField("logo_image")
private String logoImage;
@ApiModelProperty(value = "主播名称")
private String anchor;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@ApiModelProperty(value = "开始时间")
@TableField("start_time")
private Date startTime;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@ApiModelProperty(value = "结束时间")
@TableField("end_time")
private Date endTime;
@ApiModelProperty(value = "直播介绍")
private String description;
@ApiModelProperty(value = "可见范围 0 为站点 1 为可选范围")
private Integer scope;
@ApiModelProperty(value = "频道号")
private String channel;
@ApiModelProperty(value = "是否启用提醒 1:启用 0:关闭")
@TableField("enable_remind")
private Integer enableRemind;
@TableField(value = "create_by_id", fill = FieldFill.INSERT)
private Long createById;
@TableField(value = "create_by_name", fill = FieldFill.INSERT)
private String createByName;
@TableField(value = "create_time", fill = FieldFill.INSERT)
private Date createTime;
@ApiModelProperty(value = "企业")
@TableField("company_id")
private Long companyId;
@TableField("org_id")
private Long orgId;
@TableField("site_id")
private Long siteId;
@ApiModelProperty(value = "0 未上架 1 已上架 2 草稿")
private Integer shelves;
@ApiModelProperty(value = "secretKey")
@TableField("secret_key")
private String secretKey;
@ApiModelProperty(value = "keywords")
@TableField("keywords")
private String keywords;
@ApiModelProperty(value = "是否启用在日历任务中显示")
@TableField("enable_task")
private Integer enableTask;
@ApiModelProperty(value = "直播场景:alone: 活动拍摄 ; ppt: 三分屏; topclass: 大班课")
@TableField("scene")
private String scene;
@ApiModelProperty(value = "观看类型:0: 公开播放 ; 1: 站内授权播放; ")
@TableField("view_type")
private Integer viewType;
@TableLogic
@TableField("deleted")
private Integer deleted;
@ApiModelProperty(value = "直播回放开关状态 1: 开 0:关闭")
private Boolean replayStatus;
}
/**
* FileName: LiveAppIdVo
* Author: wenjunlong
* Date: 2018/4/24 15:12
* Description: 直播的账号
* History:
* <author> <time> <version> <desc>
* 作者姓名 修改时间 版本号 描述
*/
package com.yizhi.live.application.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 〈一句话功能简述〉<br>
* 〈直播的账号〉
*
* @author wenjunlong
* @create 2018/4/24
* @since 1.0.0
*/
@Data
public class LiveAppIdVo {
@ApiModelProperty(value = "对应app_id")
private String appId;
@ApiModelProperty(value = "对应app_secret")
private String appSecret;
}
/**
* FileName: LiveAppIdVo
* Author: wenjunlong
* Date: 2018/4/24 15:12
* Description: 直播的账号
* History:
* <author> <time> <version> <desc>
* 作者姓名 修改时间 版本号 描述
*/
package com.yizhi.live.application.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 直播在线人数
*/
@Data
public class LiveOnlineCountVo {
@ApiModelProperty(value = "channelId")
private String channelId;
@ApiModelProperty(value = "count")
private Integer count = 0;
@ApiModelProperty(value = "time")
private String time;
}
/**
* FileName: LiveQueryVO
* Author: wenjunlong
* Date: 2018/6/12 15:12
* Description: 查询对象传参
* History:
* <author> <time> <version> <desc>
* 作者姓名 修改时间 版本号 描述
*/
package com.yizhi.live.application.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
import java.util.List;
/**
* 〈一句话功能简述〉<br>
* 〈查询对象传参〉
*
* @author wenjunlong
* @create 2018/6/12
* @since 1.0.0
*/
@Data
public class LiveQueryVO {
@ApiModelProperty(value = "直播主题")
private String title;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@ApiModelProperty(value = "开始时间")
private Date startTime;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@ApiModelProperty(value = "结束时间")
private Date endTime;
@ApiModelProperty(value = "企业")
private Long companyId;
private List<Long> orgIds;
private Long siteId;
private Integer pageNo;
private Integer pageSize;
}
package com.yizhi.live.application.vo;
import com.yizhi.core.application.context.RequestContext;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
直播回放vo
*/
@Api
@Data
public class LiveReplayInfoVo {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "直播回放ID")
private Long replayId;
@ApiModelProperty(value = "是否使用本身封面;true是;false不是")
private Boolean defaultLogo;
@ApiModelProperty(value = "回放封面图")
private String replayLogoUrl;
@ApiModelProperty(value = "主播名称")
private String anchor;
@ApiModelProperty(value = "回放图片说明")
private String imageDesc;
private RequestContext context;
}
package com.yizhi.live.application.vo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
直播回放vo
*/
@Api
@Data
public class LiveReplayOperationVo {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "直播回放ID")
private Long replayId;
@ApiModelProperty(value = "操作")
private Boolean operation;
}
package com.yizhi.live.application.vo;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.enums.IdType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
直播回放vo
*/
@Api
@Data
public class LiveReplayVo {
private static final long serialVersionUID = 1L;
private Long id;
@ApiModelProperty(value = "直播ID")
private Long liveId;
@ApiModelProperty(value = "直播计划开始时间")
private Date livePlanStartAt;
@ApiModelProperty(value = "直播logo url")
private String liveLogoUrl;
@ApiModelProperty(value = "主播名称")
private String liveAnchor;
@ApiModelProperty(value = "直播观看人数")
private Integer liveViewers;
@ApiModelProperty(value = "直播系统生成的id")
private String videoId;
@ApiModelProperty(value = "点播视频ID")
private String videoPoolId;
@ApiModelProperty(value = "回放视频对应的直播频道id")
private String channelId;
@ApiModelProperty(value = "视频标题")
private String title;
@ApiModelProperty(value = "视频首图")
private String firstImage;
@ApiModelProperty(value = "时长")
private String duration;
@ApiModelProperty(value = "回放排序")
private Integer rank;
@ApiModelProperty(value = "视频播放地址,注:如果视频为加密视频,则此地址无法访问")
private String url;
@ApiModelProperty(value = "liveType alone, ppt")
private String liveType;
@ApiModelProperty(value = "直播观看类型:0: 公开播放 ; 1: 站内授权播放; ")
private Integer viewType;
@ApiModelProperty(value = "是否使用本身封面图片;true:是;false:不是")
private Boolean defaultLogo;
@ApiModelProperty(value = "回放图片说明")
private String imageDesc;
@ApiModelProperty(value = "直播开始时间")
private Date startTime;
@ApiModelProperty(value = "直播回放状态 1: 上架 0:下架")
private Boolean liveReplayStatus;
@ApiModelProperty(value = "回放置顶时间")
private Date topTime;
@ApiModelProperty(value = "直播间主题")
private String liveTitle;
@ApiModelProperty(value = "直播默认图片地址")
private String liveDefaultLogoUrl;
}
package com.yizhi.live.application.vo;
import com.yizhi.core.application.context.RequestContext;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* 直播回放列表查询
*/
@Data
@Api
public class LiveReviewListVo {
@ApiModelProperty(value = "直播主题、主播名称")
private String title;
@ApiModelProperty(value = "直播id")
private List<Long> liveIdList;
@ApiModelProperty(value = "上下文")
private RequestContext requestContext;
private int pageNo = 1;
private int pageSize = 10;
}
package com.yizhi.live.application.vo;
import com.yizhi.core.application.context.RequestContext;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 有直播回放的直播列表查询
*/
@Data
@Api
public class LiveReviewsVo {
@ApiModelProperty(value = "直播回放id")
private Long replayId;
@ApiModelProperty(value = "上下文")
private RequestContext requestContext;
@ApiModelProperty(value = "直播间id")
private Long liveId;
private int pageNo = 1;
private int pageSize = 10;
}
package com.yizhi.live.application.vo;
import lombok.Data;
/**
* 直播统计数据
*/
@Data
public class LiveStatisticDataVo {
private String channelId;
//频道名称
private String name;
//pc端播放时长,单位:分钟
private Integer pcPlayDuration;
//pc端播放流量,单位为Byte
private Integer pcFlowSize;
//pc视频播放量
private Integer pcVideoView;
//pc端唯一观众数
private Integer pcUniqueViewer;
//移动端播放时长,单位:分钟
private Integer mobilePlayDuration;
//移动端播放流量,单位为Byte
private Integer mobileFlowSize;
//移动端播放量
private Integer mobileVideoView;
//移动端唯一观众数
private Integer mobileUniqueViewer;
//PC直播播放时长,单位为分钟
private Integer livePcPlayDuration;
//PC回放播放时长,单位为分钟
private Integer playbackPcPlayDuration;
//移动端直播播放时长,单位为分钟
private Integer liveMobilePlayDuration;
//移动端回放播放时长,单位为分钟
private Integer playbackMobilePlayDuration;
//pc 其他 播放时长,单位为分钟
private Integer unknownPcPlayDuration;
//移动端其他 播放时长,单位为分钟
private Integer unknownMobilePlayDuration;
}
package com.yizhi.live.application.vo;
import lombok.Data;
@Data
public class LiveTitleVo {
private String channelId;
private Long liveId;
private String title;
}
/**
* FileName: LiveTokenVo
* Author: wenjunlong
* Date: 2018/4/26 9:44
* Description: 直播token生成记录
* History:
* <author> <time> <version> <desc>
* 作者姓名 修改时间 版本号 描述
*/
package com.yizhi.live.application.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* 〈一句话功能简述〉<br>
* 〈直播token生成记录〉
*
* @author wenjunlong
* @create 2018/4/26
* @since 1.0.0
*/
@Data
public class LiveTokenVo {
private Long createById;
private String createByName;
private Date createTime;
@ApiModelProperty(value = "频道号")
private String channel;
}
package com.yizhi.live.application.vo;
import com.yizhi.core.application.context.RequestContext;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* @Date 2020/9/23 8:14 下午
* @Author lvjianhui
**/
@Data
public class MessageRemindVo implements Serializable {
private static final long serialVersionUID = -7621642684091133619L;
@ApiModelProperty("提醒id ")
private Long id;
@ApiModelProperty("消息id")
private Long messageId;
@ApiModelProperty("消息类型:1、自定义消息;2、系统消息;3、事件触发消息")
private Integer messageType;
@ApiModelProperty("用户id 主要用于触发消息 个人完成发消息类型")
private Long accountId;
@ApiModelProperty("消息内容(完整版)")
private String messageContext;
@ApiModelProperty("关联模块类型(1:学习计划、2:考试、3:调研、4、投票5:报名、6:作业、7:签到、8:项目、9:直播、10:积分)")
private Integer relationType;
@ApiModelProperty("关联的业务id: 比如调研id")
private Long relationId;
@ApiModelProperty("发送方式:1、站内信;2、短信;3、邮件")
private Integer sendType;
@ApiModelProperty("该业务提醒是被关闭,关闭则为true,默认false")
private Boolean hasDeleted = false;
@ApiModelProperty("该业务提醒是否有变化,有则为true,默认false")
private Boolean isChangge = false;
@ApiModelProperty("专门存放提醒时间设置")
private List<MessageTaskRemindVo> messageTaskRemindVos = new ArrayList();
@ApiModelProperty("目前只有培训项目需要,计划同步项目可见范围")
private Boolean visibleRangeUpdate = false;
@ApiModelProperty("指定范围(0:全平台,1:指定用户)")
private Integer visibleRange;
@ApiModelProperty("业务参数对象")
private TaskVo taskVo;
@ApiModelProperty("触发消息专用 发送时间")
private Date sendTime;
@ApiModelProperty("是否设置为上架状态")
private Boolean hasUp = false;
@ApiModelProperty("是否是 修改业务状态 ")
private Boolean taskStatusUpdate = false;
@ApiModelProperty("业务状态 1:才允上架许发送(业务上架)0:不允许发送(业务非上架) 仅针对于系统消息")
private Integer taskStatus;
@ApiModelProperty("上下文 必传,主要需要 siteId companyId accountId accountName 都不能是空")
private RequestContext requestContext;
@ApiModelProperty("调研是否为复制类型")
private Boolean isCopy = false;
@ApiModelProperty("复制调研时,旧的调研id")
private Long oldRelationId;
}
package com.yizhi.live.application.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* @Date 2020/9/23 8:16 下午
* @Author lvjianhui
**/
@Data
public class MessageTaskRemindVo implements Serializable {
@ApiModelProperty("待发消息id")
private Long messageRemindId;
@ApiModelProperty("提醒时间事件类型 1:业务开始时间、 2:业务结束时间、3:自定义时间")
private Integer timeEventType;
@ApiModelProperty("发生时间枚举:1:五分钟前、2:十分钟前、3:三十分钟前、4:一个小时前、5:两个小时前、6:一天前、7:两天前")
private Integer timeType;
@ApiModelProperty("最终发送时间")
private Date sendTime;
}
package com.yizhi.live.application.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.util.StringUtils;
import java.util.Date;
public class PageLiveVo {
@ApiModelProperty(value = "主键")
private Long id;
@ApiModelProperty(value = "直播主题")
private String title;
@ApiModelProperty(value = "直播密码")
private String password;
@ApiModelProperty(value = "直播logo")
private String logoImage;
@ApiModelProperty(value = "主播名称")
private String anchor;
@ApiModelProperty(value = "开始时间")
private Date startTime;
@ApiModelProperty(value = "结束时间")
private Date endTime;
@ApiModelProperty(value = "直播状态 ")
private String status;
@ApiModelProperty(value = "频道号")
private String channel;
@ApiModelProperty(value = "0 未上架 1 已上架")
private Integer shelves;
@ApiModelProperty(value = "可见范围 0全平台 1指定用户")
private Integer scope;
@ApiModelProperty(value = "直播介绍")
private String description;
@ApiModelProperty(value = "0 公开直播。1:站内直播")
private Integer viewType;
@ApiModelProperty(value = "直播在学人数")
private Integer onlineCount;
private Integer liveStatus;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getLogoImage() {
return logoImage;
}
public void setLogoImage(String logoImage) {
this.logoImage = logoImage;
}
public String getAnchor() {
return anchor;
}
public void setAnchor(String anchor) {
this.anchor = anchor;
}
public Date getStartTime() {
return startTime;
}
public void setStartTime(Date startTime) {
this.startTime = startTime;
}
public Date getEndTime() {
return endTime;
}
public void setEndTime(Date endTime) {
this.endTime = endTime;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getChannel() {
return channel;
}
public void setChannel(String channel) {
this.channel = channel;
}
public Integer getShelves() {
return shelves;
}
public void setShelves(Integer shelves) {
this.shelves = shelves;
}
public Integer getScope() {
return scope;
}
public void setScope(Integer scope) {
this.scope = scope;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Integer getViewType() {
return viewType;
}
public void setViewType(Integer viewType) {
this.viewType = viewType;
}
public Integer getOnlineCount() {
return onlineCount;
}
public void setOnlineCount(Integer onlineCount) {
this.onlineCount = onlineCount;
}
public Integer getLiveStatus() {
if (StringUtils.isEmpty(this.status)){
return 10;
}else {
return Integer.valueOf(this.status);
}
}
public void setLiveStatus(Integer liveStatus) {
this.liveStatus = liveStatus;
}
}
package com.yizhi.live.application.vo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 直播回放回调
*/
@Data
@Api
public class PolyvLiveBackCallbackVo {
@ApiModelProperty(value = "频道ID")
private String channelId;
@ApiModelProperty(value = "转存成功的视频ID")
private String vid;
@ApiModelProperty(value = "视频标题")
private String title;
@ApiModelProperty(value = "视频时长 格式为 hh:mm:ss")
private String duration;
@ApiModelProperty(value = "视频文件大小,单位为byte")
private Long fileSize;
@ApiModelProperty(value = "13位的时间戳")
private long timestamp;
@ApiModelProperty(value = "校验的加密字符串,生成的规则md5(AppSecret+timestamp),AppSecret是直播系统的用密匙")
private String sign;
@ApiModelProperty(value = "录制的场次和时间对应的数组字符串,格式:[\"20190703145126,4,fdqbopvtnv\",\"20190703145126,8,fdqbopvtnv\"] ,其中:\"20190703145126,4,fdqbopvtnv\" 第一个字段是开始时间,第二个字段是直播的时长,第三个是对应的sessionId。")
private String sessionIds;
@ApiModelProperty(value = "回放对应的单个场次id")
private String sessionIs;
@ApiModelProperty(value = "转存对应的录制文件id")
private String filedId;
@ApiModelProperty(value = "转存回放唯一的id")
private String videoId;
@ApiModelProperty(value = "录制来源。manual-云录制,auto-自动录制,merge-合并,clip-裁剪")
private String origin;
@ApiModelProperty(value = "用户id")
private String userId;
@ApiModelProperty(value = "转存成功返回success")
private String status;
@ApiModelProperty(value = "录制文件地址")
private String fileUrl;
@ApiModelProperty(value = "文件类型,m3u8或者mp4")
private String format;
@ApiModelProperty(value = "录制唯一的id")
private String fileId;
@ApiModelProperty(value = "该字段只对开启云录制功能有用),值为 'Y',表示该场直播录制同时存在云录制和自动录制,值为\"N\",该场直播只有自动录制")
private String hasRtcRecord;
}
package com.yizhi.live.application.vo;
import lombok.Data;
@Data
public class PolyvResponseVo<T> {
private int code;
private String status;
private String message;
private T data;
}
package com.yizhi.live.application.vo;
import com.baomidou.mybatisplus.annotations.TableField;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @Date 2020/9/29 6:15 下午
* @Author lvjianhui
**/
@Data
public class ScopeAuthorizationVO {
@ApiModelProperty(value = "主键")
private Long id;
@ApiModelProperty(value = "账号id")
@TableField("account_id")
private Long accountId;
@ApiModelProperty(value = "直播活动id")
@TableField("live_id")
private Long liveId;
@ApiModelProperty(value = "1.部门、2.用户")
private Integer type;
@TableField("site_id")
private Long siteId;
@TableField("name")
private String name;
@ApiModelProperty(value = "用户名")
@TableField(exist = false)
private String fullName;
@ApiModelProperty(value = "工号")
@TableField(exist = false)
private String workNum;
}
package com.yizhi.live.application.vo;
import com.yizhi.live.application.constant.EvenType;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* @Date 2020/9/23 8:17 下午
* @Author lvjianhui
**/
@Data
public class TaskVo implements Serializable {
@ApiModelProperty("业务名称")
private String taskName;
@ApiModelProperty("业务开始时间")
private Date taskStratTime;
@ApiModelProperty("业务结束时间")
private Date taskEndTime;
@ApiModelProperty("业务得分")
private Double taskScore;
@ApiModelProperty("业务发生原因(主要用于积分)")
private String reason;
@ApiModelProperty("业务时间(主要用于积分)")
private Date taskTime;
@ApiModelProperty("事件类型")
private EvenType evenType;
}
package com.yizhi.live.application.vo;
import java.util.List;
import com.yizhi.core.application.context.RequestContext;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 2019/09/19
* @author wangfeida
*
*/
@Data
public class VisibleRangeExport {
@ApiModelProperty(name="bizId",value="具体业务id")
private Long bizId;
@ApiModelProperty(name="bizName",value="具体业务名字")
private String bizName;
@ApiModelProperty(name="个人ID集合",value="个人id集合")
private List<Long> accountIds;
@ApiModelProperty(name="组织ID集合",value="组织ID集合")
private List<Long> orgIds;
@ApiModelProperty(name="上下文对象",value="上下文对象")
private RequestContext context;
}
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>com.yizhi</groupId>
<artifactId>cloud-live</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.yizhi</groupId>
<artifactId>cloud-live-service</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>com.yizhi</groupId>
<artifactId>cloud-core</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.yizhi</groupId>
<artifactId>cloud-util</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.yizhi</groupId>
<artifactId>cloud-common-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.yizhi</groupId>
<artifactId>cloud-live-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.yizhi</groupId>
<artifactId>cloud-job-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.yizhi</groupId>
<artifactId>cloud-newMessage-api</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.yizhi</groupId>
<artifactId>cloud-orm</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.yizhi</groupId>
<artifactId>cloud-system-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>RELEASE</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
package com.yizhi.live.application;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.ComponentScan;
/**
*
* @author scotthu
*
* @date 2018年2月28日
*/
@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients(basePackages = {"com.yizhi"})
@ComponentScan(basePackages = {"com.yizhi"})
public class LiveApplication {
public static void main(java.lang.String[] args) {
SpringApplication.run(LiveApplication.class, args);
}
}
package com.yizhi.live.application;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
/**
* @Author: shengchenglong
* @Date: 2018/3/6 14:30
*/
@Configuration
@EnableSwagger2
public class SwaggerConfig extends WebMvcConfigurerAdapter {
@Bean
public Docket createRestApi() {
return new Docket(DocumentationType.SWAGGER_2)
.groupName("后台直播管理端")
.apiInfo(apiInfo())
.select()
.apis(RequestHandlerSelectors.basePackage("com.yizhi.live.application"))
.paths(PathSelectors.any())
.build();
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("直播管理端接口")
//版本
.version("1.0")
.build();
}
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/");
registry.addResourceHandler("docs.html").addResourceLocations("classpath:/META-INF/resources/");
registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
}
}
package com.yizhi.live.application.constant;
import com.alibaba.fastjson.JSONObject;
import lombok.Data;
import java.util.List;
/**
* @Date 2020/12/21 7:22 下午
* @Author lvjianhui
**/
@Data
public class PolyvCountVO {
private Integer pageNumber;
private Integer limit;
private Integer totalItems;
private List<JSONObject> contents;
}
package com.yizhi.live.application.constant;
import lombok.Data;
/**
* @Date 2020/12/22 2:05 上午
* @Author lvjianhui
**/
@Data
public class PolyvLiveCount {
private String channelId;
private String sessionId;
private Long startTime;
private Long endTime;
}
package com.yizhi.live.application.constant;
import com.alibaba.fastjson.JSONObject;
import lombok.Data;
/**
* @Date 2020/12/8 3:22 下午
* @Author lvjianhui
**/
@Data
public class PolyvResponseVO {
// 响应代码,成功为200,失败为400,签名错误为401,异常错误500
private Integer code;
// 成功为success,失败为error
private String status;
// 错误时为错误提示消息
private String message;
// 成功响应时业务数据
private JSONObject data;
}
package com.yizhi.live.application.constant;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @Date 2020/12/10 3:58 下午
* @Author lvjianhui
**/
@Data
public class PolyvUpdatePO {
@ApiModelProperty("对应系统的直播title")
private String name;
private String channelPasswd;
private String publisher;
private Long startTime;
private String desc;
}
package com.yizhi.live.application.constant;
public class UtilConstants {
public static final String APP_USER_ID = "ehat3jubx2";
public static final String APP_ID = "el100m1ent";
public static final String APP_SECRET = "84d3345d8de848d79635d7b16b03e028";
public static final String CREATE_CHANNEL_URL = "http://api.polyv.net/live/v2/channels/";
public static final String LIVE_STATUS_URL = "http://api.polyv.net/live/v2/channels/live-status";
public static final String LIVE_AUTH_UPDATE_URL = "http://api.polyv.net/live/v3/channel/auth/update";
public static final String LIVE_CHANNEL_SETTING_URL = "http://api.polyv.net/live/v2/channelSetting/%s/oauth-custom";
public static final String LIVE_CHANNELSETTING_URL = "http://api.polyv.net/live/v2/channelSetting/";
public static final String DEV_LIVE_CUSTOM_URI = "https://wenjl.vmceshi.com/manage/live/public/auth";
public static final String SIT_LIVE_CUSTOM_URI = "https://test.mg.kmelearning.com/web-manage/manage/live/public/auth";
public static final String UAT_LIVE_CUSTOM_URI = "https://uat.mg.kmelearning.com/web-manage/manage/live/public/auth";
public static final String PRO_LIVE_CUSTOM_URI = "https://mg.kmelearning.com/web-manage/manage/live/public/auth";
public static final String CHANNEL_TITLE_NAME_UPDATE = "http://api.polyv.net/live/v2/channels/%s/update";
public static final String CHANNEL_PASSWD_UPDATE = "http://api.polyv.net/live/v2/channels/%s/passwdSetting";
public static final String CHANNEL_ANCHOR_UPDATE = "http://api.polyv.net/live/v2/channelSetting/%s/setPublisher";
public static final String CHANNEL_DESC_UPDATE = "http://api.polyv.net/live/v2/channelSetting/%s/%s/set-menu";
public static final String CHANNEL_STARTDATE_UPDATE = "http://api.polyv.net/live/v2/channelSetting/%s/set-countdown";
public static final String CHANNEL_ALL_INFO_UPDATE = "http://api.polyv.net/live/v3/channel/basic/update?appId=%s&timestamp=%s&channelId=%s&sign=%s";
;
public static final String CHANNEL_SIMPLE_INFO_UPDATE = "http://api.polyv.net/live/v3/channel/detail/update";
public static final String LIVE_STATISTICS_BATCH_COUNT = "https://api.polyv.net/live/v2/statistics/get-realtime-viewers";
//查询直播实时在线人数
//批量查询直播实时在线人数
public static final String LIVE_STATISTICS_COUNT = "http://api.polyv.net/live/v1/statistics/%s/realtime";
//查询频道回放开关状态
public static final String LIVE_BACK_SWITCH_GET = "http://api.polyv.net/live/v3/channel/playback/get-enabled";
//查询回放视频库列表 %s=channelId
public static final String LIVE_REPLAY_LIST = "http://api.polyv.net/live/v2/channel/recordFile/%s/playback/list";
//批量查询视频某段时间内的统计数据 %s =userId
public static final String LIVE_CHANNELS_STATISTIC_DATA = "http://api.polyv.net/live/v2/statistics/%s/channel_summary";
//查询视频某段时间内的统计数据 %s =channelId
public static final String LIVE_CHANNEL_STATISTIC_DATA = "http://api.polyv.net/live/v2/statistics/%s/summary";
}
package com.yizhi.live.application.controller;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.toolkit.CollectionUtils;
import com.yizhi.application.orm.id.IdGenerator;
import com.yizhi.application.orm.util.QueryUtil;
import com.yizhi.core.application.context.ContextHolder;
import com.yizhi.core.application.context.RequestContext;
import com.yizhi.core.application.task.AbstractTaskHandler;
import com.yizhi.core.application.task.TaskExecutor;
import com.yizhi.core.application.vo.DroolsVo;
import com.yizhi.live.application.constant.UtilConstants;
import com.yizhi.live.application.domain.LiveActivity;
import com.yizhi.live.application.domain.LiveToken;
import com.yizhi.live.application.domain.ScopeAuthorization;
import com.yizhi.live.application.enums.LiveStatus;
import com.yizhi.live.application.service.ILiveActivityService;
import com.yizhi.live.application.service.ILiveTokenService;
import com.yizhi.live.application.service.IScopeAuthorizationService;
import com.yizhi.live.application.util.LiveEvenSendMessage;
import com.yizhi.live.application.vo.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.*;
import java.util.stream.Collectors;
@Api(tags = "直播接口")
@RestController
@RequestMapping("/manage/live")
public class LiveController {
private static final Logger LOG = LoggerFactory.getLogger(LiveController.class);
@Autowired
ILiveActivityService liveActivityService;
@Autowired
IdGenerator idGenerator;
@Autowired
ILiveTokenService liveTokenService;
@Autowired
IScopeAuthorizationService scopeAuthorizationService;
@Autowired
private TaskExecutor taskExecutor;
@Autowired
private LiveEvenSendMessage liveEvenSendMessage;
@GetMapping("/channelNo/get")
public String getChannelNo(@RequestParam("id") Long id) {
LiveActivity liveActivity = liveActivityService.selectById(id);
if (liveActivity != null) {
return liveActivity.getChannel();
}
return "";
}
@PostMapping("/save")
public Boolean save(
@RequestBody LiveActivityResultVO liveActivityResultVO
) {
return liveActivityService.saveLive(liveActivityResultVO);
}
@PostMapping("/update")
public Boolean update(
@RequestBody LiveActivityResultVO liveActivityResultVO
) {
return liveActivityService.updateLive(liveActivityResultVO);
}
/**
* 管理端 直播列表查询
*
* @param title 主题
* @param companyId 企业id
* @param siteId 站点id
* @param orgIds 管辖区id
* @param pageNo 分页的页数
* @param pageSize 分页的条数
* @return PageLiveVo 前台展示对象
*/
@GetMapping("/list")
public Page<PageLiveVo> list(
@RequestParam(name = "title", required = false) String title,
@RequestParam(name = "startTimeString", required = false) String startTimeString,
@RequestParam(name = "endTimeString", required = false) String endTimeString,
@RequestParam(name = "companyId", required = false) Long companyId,
@RequestParam(name = "siteId", required = false) Long siteId,
@RequestParam(name = "orgIds", required = false) List<Long> orgIds,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "20") Integer pageSize,
@RequestParam(name = "expTimeString", required = false) String expTimeString,
@RequestParam(name = "status", required = false) Integer status,
@RequestParam(name = "viewType", required = false) Integer viewType,
@RequestParam(name = "startTimeAsc",required = false) Boolean startTimeAsc,
@RequestParam(name = "endTimeAsc",required = false) Boolean endTimeAsc
) {
Page<PageLiveVo> liveActivityPage = liveActivityService.searchPage(title, startTimeString,
endTimeString, companyId, siteId, orgIds,
pageNo, pageSize, expTimeString, status, viewType,null,null);
return liveActivityPage;
}
/**
* 管理端 直播列表查询
* 新增根据时间排序功能
*
* @param title 主题
* @param companyId 企业id
* @param siteId 站点id
* @param orgIds 管辖区id
* @param pageNo 分页的页数
* @param pageSize 分页的条数
* @param startTimeAsc 按照开始时间排序 当开始和结束时间排序都不传递的时候;默认按照创建时间倒叙;
* @param endTimeAsc 按照结束时间排序;
* @return PageLiveVo 前台展示对象
*/
@GetMapping("/v2/list")
public Page<PageLiveVo> listV2(
@RequestParam(name = "title", required = false) String title,
@RequestParam(name = "startTimeString", required = false) String startTimeString,
@RequestParam(name = "endTimeString", required = false) String endTimeString,
@RequestParam(name = "companyId", required = false) Long companyId,
@RequestParam(name = "siteId", required = false) Long siteId,
@RequestParam(name = "orgIds", required = false) List<Long> orgIds,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "20") Integer pageSize,
@RequestParam(name = "expTimeString", required = false) String expTimeString,
@RequestParam(name = "status", required = false) Integer status,
@RequestParam(name = "viewType", required = false) Integer viewType,
@RequestParam(name = "startTimeAsc",required = false) Boolean startTimeAsc,
@RequestParam(name = "endTimeAsc",required = false) Boolean endTimeAsc
) {
Page<PageLiveVo> liveActivityPage = liveActivityService.searchPage(title, startTimeString,
endTimeString, companyId, siteId, orgIds,
pageNo, pageSize, expTimeString, status, viewType,startTimeAsc,endTimeAsc);
return liveActivityPage;
}
/**
* 查询近7天的已完成的直播(包含今天的)
*
* @return
*/
@GetMapping("/sevenDays/get")
public List<LiveActivity> findWithinSevenDaysLive() {
RequestContext rt = ContextHolder.get();
return liveActivityService.findWithinSevenDaysLive(rt.getCompanyId(), rt.getSiteId(), rt.getAccountId());
}
@GetMapping("/portal/list")
public List<PageLiveVo> portalList(
@RequestParam(name = "title", required = false) String title,
@RequestParam(name = "startTime", required = false) Date startTime,
@RequestParam(name = "endTime", required = false) Date endTime,
@RequestParam(name = "companyId", required = false) Long companyId,
@RequestParam(name = "siteId", required = false) Long siteId,
@RequestParam(name = "orgIds", required = false) List<Long> orgIds,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "20") Integer pageSize
) {
List<PageLiveVo> pageLiveVoList = liveActivityService.portalList(title, startTime,
endTime, companyId, siteId, orgIds,
pageNo, pageSize);
return pageLiveVoList;
}
@GetMapping("/portal/v2/list")
public Page<PageLiveVo> portalListV2(
@RequestParam(name = "title", required = false) String title,
@RequestParam(name = "startTime", required = false) Date startTime,
@RequestParam(name = "endTime", required = false) Date endTime,
@RequestParam(name = "companyId", required = false) Long companyId,
@RequestParam(name = "siteId", required = false) Long siteId,
@RequestParam(name = "orgIds", required = false) List<Long> orgIds,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "20") Integer pageSize
) {
Page<PageLiveVo> pageLiveVoList = liveActivityService.portalList2(title, startTime,
endTime, companyId, siteId, orgIds,
pageNo, pageSize);
return pageLiveVoList;
}
@PostMapping("/delete")
public Boolean delete(
@RequestBody LiveActivity liveActivity
) {
LiveActivity liveActivity1 = liveActivityService.selectById(liveActivity.getId());
Boolean f = liveActivityService.deleteChanel(liveActivity1.getChannel());
if (f) {
Boolean t = liveActivityService.deleteById(liveActivity.getId());
return t;
}
return f;
}
@GetMapping("/get")
public LiveActivityResultVO list(@RequestParam("id") Long id) {
LiveActivityResultVO liveActivityResultVO = new LiveActivityResultVO();
LiveActivity liveActivity = liveActivityService.selectById(id);
ScopeAuthorization scopeAuthorization = new ScopeAuthorization();
scopeAuthorization.setLiveId(id);
EntityWrapper<ScopeAuthorization> wrapper = new EntityWrapper<ScopeAuthorization>(scopeAuthorization);
LiveActivityVO liveactivityvo = new LiveActivityVO();
BeanUtils.copyProperties(liveActivity, liveactivityvo);
liveActivityResultVO.setLiveActivity(liveactivityvo);
List<ScopeAuthorization> scopeAuthorizations = scopeAuthorizationService.selectList(wrapper);
List<ScopeAuthorizationVO> scopeauthorizations = new ArrayList<>();
for (ScopeAuthorization authorization : scopeAuthorizations) {
ScopeAuthorizationVO scopeauthorizationvo = new ScopeAuthorizationVO();
BeanUtils.copyProperties(authorization, scopeauthorizationvo);
scopeauthorizations.add(scopeauthorizationvo);
}
liveActivityResultVO.setScopeAuthorizations(scopeauthorizations);
return liveActivityResultVO;
}
@GetMapping("/getLive")
public LiveActivity getLive(@RequestParam("id") Long id) {
return liveActivityService.selectById(id);
}
@PostMapping("/token")
public String getToken(@RequestBody LiveTokenVo liveTokenVo) {
String token = liveActivityService.setToken(liveTokenVo.getChannel());
if ("error".equals(token)) {
return token;
}
LiveToken liveTokenVO = new LiveToken();
liveTokenVO.setId(idGenerator.generate());
liveTokenVO.setCreateById(liveTokenVo.getCreateById());
liveTokenVO.setCreateByName(liveTokenVo.getCreateByName());
liveTokenVO.setToken(token);
LiveToken lt = new LiveToken();
BeanUtils.copyProperties(lt, liveTokenVO);
liveTokenService.insert(lt);
return token;
}
@PostMapping("/signature")
public LiveAppIdVo signature() {
LiveAppIdVo liveAppIdVo = new LiveAppIdVo();
liveAppIdVo.setAppId(UtilConstants.APP_ID);
liveAppIdVo.setAppSecret(UtilConstants.APP_SECRET);
return liveAppIdVo;
}
@GetMapping("/api/list")
public List<PageLiveVo> apiList(
@RequestParam(name = "title", required = false) String title,
@RequestParam(name = "companyId", required = false) Long companyId,
@RequestParam(name = "siteId", required = false) Long siteId,
@RequestParam(name = "ids", required = false) List<Long> ids,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "20") Integer pageSize
) {
List<PageLiveVo> list = liveActivityService.apiSearchHomeList(ids, title, companyId,
siteId, pageNo, pageSize);
return list;
}
@GetMapping("/api/pageList")
public Page<PageLiveVo> apiPageList(
@RequestParam(name = "title", required = false) String title,
@RequestParam(name = "companyId", required = false) Long companyId,
@RequestParam(name = "siteId", required = false) Long siteId,
@RequestParam(name = "ids", required = false) List<Long> ids,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "20") Integer pageSize
) {
Page<PageLiveVo> page = liveActivityService.apiSearchPageList(ids, title, companyId,
siteId, pageNo, pageSize);
return page;
}
/**
* 直播指定范围保存
*
* @param scopeAuthorizations
* @return
*/
@PostMapping("/scopeAuthorization/save")
public boolean saveCoursrAccount(@RequestBody List<ScopeAuthorization> scopeAuthorizations) {
Boolean f = scopeAuthorizationService.insertList(scopeAuthorizations);
return f;
}
/**
* 直播指定范围保存,不删除之前的记录
*
* @param scopeAuthorizations
* @return
*/
@PostMapping("/scopeAuthorization/insert")
Boolean insertScopeAuthorization(@RequestBody List<ScopeAuthorization> scopeAuthorizations) {
return scopeAuthorizationService.insertAllList(scopeAuthorizations);
}
/**
* 已保存的指定范围集合
*
* @param liveId
* @return
*/
@GetMapping("/scopeAuthorization/list")
public List<ScopeAuthorization> getCourseAccountList(@RequestParam(name = "liveId") Long liveId) {
ScopeAuthorization scopeAuthorization = new ScopeAuthorization();
scopeAuthorization.setLiveId(liveId);
EntityWrapper<ScopeAuthorization> wrapper = new EntityWrapper<ScopeAuthorization>(scopeAuthorization);
List<ScopeAuthorization> scopeAuthorizations = scopeAuthorizationService.selectList(wrapper);
return scopeAuthorizations;
}
/**
* 直播上架
*
* @param param 带id
* @return
*/
@PostMapping("/up")
public Boolean up(@RequestBody LiveActivity param) {
LiveActivity liveActivity = liveActivityService.selectById(param.getId());
if (liveActivity != null) {
liveActivity.setShelves(1);
boolean b = liveActivityService.updateById(liveActivity);
if (b) {
updateStatus(liveActivity, ContextHolder.get());
}
return b;
}
return Boolean.FALSE;
}
/**
* 直播下架
*
* @param param 只带id
* @return
*/
@PostMapping("/down")
public Boolean down(@RequestBody LiveActivity param) {
LiveActivity liveActivity = liveActivityService.selectById(param.getId());
if (liveActivity != null) {
liveActivity.setShelves(0);
boolean b = liveActivityService.updateById(liveActivity);
if (b) {
updateStatus(liveActivity, ContextHolder.get());
}
return b;
}
return Boolean.FALSE;
}
/**
* 发消息告知业务状态改变
*
* @param liveActivity
* @param context
*/
public void updateStatus(LiveActivity liveActivity, RequestContext context) {
try { //发消息告知业务状态有变化
if (liveActivity != null) {
if (liveActivity.getEnableRemind() == 1) {
MessageRemindVo remindVo = new MessageRemindVo();
remindVo.setTaskStatusUpdate(true);
taskExecutor.asynExecute(new AbstractTaskHandler() {
@Override
public void handle() {
liveEvenSendMessage.systemSendMessage(liveActivity, remindVo, context);
}
});
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 根据频道id获得直播信息
*/
@GetMapping("/channelId/view")
public LiveActivity viewByChannelId(@RequestParam(name = "channelId") String channelId) {
LiveActivity liveActivity = new LiveActivity();
liveActivity.setChannel(channelId);
EntityWrapper<LiveActivity> entityWrapper = new EntityWrapper<>(liveActivity);
return liveActivityService.selectOne(entityWrapper);
}
@ApiOperation(value = "可见范围导出", notes = "可见范围导出")
@GetMapping("/export/visiblRange")
public VisibleRangeExport vsibleRangeExport(@ApiParam(value = "直播的Id", name = "直播的Id", required = true) @RequestParam(name = "liveId", required = true) Long liveId) {
return liveActivityService.vsibleRangeExport(liveId);
}
@ApiOperation(value = "可见范围导出", notes = "可见范围导出")
@PostMapping("/access/lives")
public List<Long> accessLives(@RequestBody AccessLiveVO vo) {
EntityWrapper<ScopeAuthorization> ew = QueryUtil.condition(new ScopeAuthorization());
List<Long> ids = new ArrayList<>();
List<Long> orgIds = vo.getOrgIds();
if (CollectionUtils.isNotEmpty(orgIds)) {
ids.addAll(orgIds);
}
List<Long> userIds = vo.getUserIds();
if (CollectionUtils.isNotEmpty(userIds)) {
ids.addAll(userIds);
}
List<Long> liveIds = vo.getLiveIds();
if (ids.size() == 0 || CollectionUtils.isEmpty(liveIds)) {
return null;
}
ew.in("site_id", ids).in("live_id", liveIds);
List<ScopeAuthorization> data = scopeAuthorizationService.selectList(ew);
if (data == null || data.size() == 0) {
return null;
}
EntityWrapper<LiveActivity> ewLive = QueryUtil.condition(new LiveActivity());
ewLive.in("id", liveIds).eq("scope", 0);
List<LiveActivity> liveActivitys = liveActivityService.selectList(ewLive);
List<Long> retLiveIds = new ArrayList<>();
if (CollectionUtils.isNotEmpty(liveActivitys)) {
retLiveIds = liveActivitys.stream().map(obj -> obj.getId()).collect(Collectors.toList());
}
List<Long> selectLives = data.stream().map(obj -> obj.getLiveId()).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(selectLives)) {
retLiveIds.addAll(selectLives);
}
return selectLives;
}
/**
* PC端 分页查询直播列表
*
* @param title
* @param ids
* @param pageNo
* @param pageSize
* @return
*/
@GetMapping("/pc/pageList")
public Page<PageLiveVo> pcPageList(@RequestParam(name = "title", required = false) String title,
@RequestParam(name = "ids", required = false) List<Long> ids,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "20") Integer pageSize) {
RequestContext context = ContextHolder.get();
List idList = new ArrayList();
if (null != ids && ids.size() > 0) {
idList.addAll(ids);
} else {
idList.addAll(context.getRelationIds());
System.out.println("relationIds:" + context.getRelationIds());
}
Page<PageLiveVo> page = liveActivityService.pcSearchPageList(idList, title, context.getCompanyId(), context.getSiteId(), pageNo, pageSize);
List<PageLiveVo> list = page.getRecords();
if (CollectionUtils.isNotEmpty(list)) {
//按开始时间倒序
Collections.sort(list, new Comparator<PageLiveVo>() {
@Override
public int compare(PageLiveVo o1, PageLiveVo o2) {
Long diff = o2.getStartTime().getTime() - o1.getStartTime().getTime();
if (diff > 0) {
return 1;
} else if (diff < 0) {
return -1;
}
return 0;
}
});
Long currentTime = System.currentTimeMillis();
List<PageLiveVo> allList = new ArrayList<>();
List<PageLiveVo> liveList = new ArrayList<>();
List<PageLiveVo> notStartList = new ArrayList<>();
List<PageLiveVo> endList = new ArrayList<>();
//按状态 直播中》即将开始》直播结束 相同状态按 开始时间倒序
for (PageLiveVo vo : list) {
if (LiveStatus.LIVE.getName().equals(vo.getStatus())) {
liveList.add(vo);
} else if (LiveStatus.NOT_START.getName().equals(vo.getStatus())) {
notStartList.add(vo);
} else {
endList.add(vo);
}
}
allList.addAll(liveList);
allList.addAll(notStartList);
allList.addAll(endList);
page.setRecords(allList);
}
return page;
}
/**
* 根据站点Id查询直播列表
*
* @param siteId
* @param pageNo
* @param pageSize
* @return
*/
@GetMapping("/pc/getPage")
public Page<PageLiveVo> getPageLiveVoList(@RequestParam(name = "siteId", required = false) Long siteId,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "15") Integer pageSize) {
Page<PageLiveVo> pageLiveVos = liveActivityService.getPageLiveVoList(siteId, pageNo, pageSize);
if (pageLiveVos == null && pageLiveVos.getSize() == 0) {
return null;
}
return pageLiveVos;
}
@GetMapping("/pc/getPage/notIds")
public Page<LiveActivity> getPageLiveVoListNotIds(
@RequestParam(name = "ids", required = false) List<Long> ids,
@RequestParam(name = "siteId", required = false) Long siteId,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "15") Integer pageSize) {
return liveActivityService.getPageLiveVoListNotIds(ids, siteId, pageNo, pageSize);
}
/**
* 根据relationId 判断这个人是否可以看到这这场直播
*
* @param relationId 里面有accountId or orgId
* @param liveId 直播Id
* @return
*/
@GetMapping("pc/judgeScope")
public Boolean judgeScope(@RequestParam(name = "relationId", required = false) List<Long> relationId,
@RequestParam(name = "liveId", required = false) Long liveId) {
Boolean flag = liveActivityService.judgeScope(relationId, liveId);
return flag;
}
/**
* 根据直播Id查看直播信息
*
* @param liveId
* @return
*/
@GetMapping("pc/queryLive")
public LiveActivity queryLive(@RequestParam(name = "liveId") Long liveId) {
if (null != liveId) {
return liveActivityService.selectById(liveId);
}
return null;
}
@GetMapping("/pc/queryLive/byIds")
public Page<LiveActivity> LiveActivityByIds(
@RequestParam(value = "listIds", required = false) List<Long> listIds,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "15") Integer pageSize) {
return liveActivityService.LiveActivityByIds(listIds, pageNo, pageSize);
}
/**
* 根据传入的频道Id,返回直播状态
*
* @param channelId
* @return
*/
@GetMapping("/pc/getLiveStatus")
public Integer getLiveStatus(@ApiParam(value = "channelId 频道Id") @RequestParam(value = "channelId") String channelId) {
if (StringUtils.isNotBlank(channelId)) {
return liveActivityService.getLiveStatus(channelId);
}
return -1;
}
/**
* 根据传入的relationIds 里面有accountId、orgId
*
* @param relationIds
* @param pageNo
* @param pageSize
* @return
*/
@PostMapping("/pc/queryLiveListByRelationIds")
public List<PageLiveVo> queryLiveListByRelationIds(@ApiParam(value = "relationIds 里面有accountId、orgId")
@RequestParam(value = "relationIds 里面有accountId、orgId", required = false) List<Long> relationIds,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "15") Integer pageSize) {
return liveActivityService.queryLiveListByRelationIds(relationIds, pageNo, pageSize);
}
@GetMapping(value = "/by/new/server")
public List<Map<String, Object>> getServerByCompanyIdAndIds(@RequestParam("companyId") Long companyId, @RequestParam(value = "ids", required = false) List<Long> ids) {
return liveActivityService.getServerByCompanyIdAndIds(companyId, ids);
}
@PostMapping("/getPageToCalendar")
public Page<PageLiveVo> getPageToCalendar(@ApiParam("paramVo") @RequestBody CalendarTaskParamVo paramVo) {
Page<PageLiveVo> page = new Page(paramVo.getPageNo(), paramVo.getPageSize());
return liveActivityService.getPageToCalendar(paramVo.getDate(), page);
}
@GetMapping("/getPageByDrools")
Page<DroolsVo> getPageByDrools(@RequestParam("field") String field,
@RequestParam(value = "value", required = false) String value,
@RequestParam("pageNo") Integer pageNo,
@RequestParam("pageSize") Integer pageSize) {
Page<DroolsVo> page = new Page<>(pageNo, pageSize);
return liveActivityService.getPageByDrools(field, value, page);
}
}
package com.yizhi.live.application.controller;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.plugins.Page;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.yizhi.application.orm.id.IdGenerator;
import com.yizhi.core.application.context.ContextHolder;
import com.yizhi.core.application.context.RequestContext;
import com.yizhi.live.application.domain.LiveActivity;
import com.yizhi.live.application.request.LiveReleaseReviewReq;
import com.yizhi.live.application.service.ILiveActivityService;
import com.yizhi.live.application.service.ILiveReplayService;
import com.yizhi.live.application.service.ILiveTokenService;
import com.yizhi.live.application.service.IScopeAuthorizationService;
import com.yizhi.live.application.vo.*;
import com.yizhi.util.application.domain.BizResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
@Api(tags = "直播接口")
@RestController
@RequestMapping("/remote/live")
public class RemoteLiveController {
private static final Logger LOG = LoggerFactory.getLogger(RemoteLiveController.class);
@Autowired
ILiveActivityService liveActivityService;
@Autowired
IdGenerator idGenerator;
@Autowired
ILiveTokenService liveTokenService;
@Autowired
IScopeAuthorizationService scopeAuthorizationService;
@Autowired
ILiveReplayService replayService;
/**
* 查询近7天的已完成的直播(包含今天的)
*
* @return
*/
@GetMapping("/sevenDays/get")
public List<LiveActivity> findWithinSevenDaysLive() {
RequestContext rt = ContextHolder.get();
return liveActivityService.findWithinSevenDaysLive(rt.getCompanyId(), rt.getSiteId(), rt.getAccountId());
}
@GetMapping("/statistics/online/count/realtime")
@ApiOperation(value = "实时查询直播在线人数;多个频道用逗号隔开")
public List<LiveOnlineCountVo> liveCountOnlineRealTime(@RequestParam("channelIds") String channelIds) {
try {
return liveActivityService.getChannelOnlineCountRealTime(channelIds);
} catch (JsonProcessingException e) {
LOG.error("获取频道在线人数异常",e);
}
return new ArrayList<>();
}
/**
* 保利威回调接口 直播状态修改
* @param channelId 频道id
* @param status 直播状态 :live表示开始直播,end表示直播结束
*/
@GetMapping("/status/callback")
@ApiOperation(value = "直播状态改变,保利威回调接口")
public BizResponse liveStatusCallback(@RequestParam(value = "channelId") String channelId
,@RequestParam(value = "status") String status
,@RequestParam(value = "timestamp") Long timestamp
,@RequestParam(value = "sign") String sign
,@RequestParam(value = "sessionId") String sessionId
,@RequestParam(value = "startTime") String startTime
,@RequestParam(value = "endTime") String endTime) {
LOG.info("保利威直播状态回调;channelId={},status={},sign={},startTime={},endTime={},sessionId={}",channelId,status,sign,startTime,endTime,sessionId);
return liveActivityService.liveStatusCallback(channelId,status,timestamp,sign,sessionId,startTime,endTime);
}
@GetMapping("/transfer/callback")
@ApiOperation(value = "直播转存成功,保利威回调接口")
public BizResponse<String> liveTransferCallback(@RequestBody PolyvLiveBackCallbackVo liveBackCallbackVo) {
LOG.info("直播转存成功,保利威回调参数channelId = {};",liveBackCallbackVo.getChannelId());
return liveActivityService.liveTransferCallback(liveBackCallbackVo);
}
@GetMapping("/play/review/list")
@ApiOperation(value = "查询所有直播回放列表 废弃")
@Deprecated
public Page<LiveReplayVo> playReviewList(@RequestBody LiveReviewListVo liveReviewListVo) {
return null;
}
@GetMapping("/review/switch/on/live/list")
@ApiOperation(value = "查询有直播回放的直播间列表 废弃!!")
@Deprecated
public BizResponse<List<LiveTitleVo>> reviewLiveList(@RequestBody LiveReviewsVo liveReviewsVo) {
return liveActivityService.reviewLiveList(liveReviewsVo);
}
@GetMapping("/review/switch/on/live/page/list")
@ApiOperation(value = "分页查询有直播回放的直播间列表")
public Page<LiveTitleVo> getHasReplayLiveList(@RequestBody LiveReleaseReviewReq replayVo) {
return liveActivityService.getHasReplayLiveList(replayVo);
}
@GetMapping("/reviews/get")
@ApiOperation(value = "根据直播间查询上架的直播回放")
public BizResponse<List<LiveReplayVo>> reviewsList(@RequestBody LiveReviewsVo liveReviewsVo) {
return liveActivityService.reviewsList(liveReviewsVo);
}
@GetMapping("/review/one/get")
@ApiOperation(value = "查询直播回放详情")
public BizResponse<LiveReplayVo> getReview(@RequestParam(name = "replayId") Long replayId) {
return replayService.getReplay(replayId);
}
@PostMapping("/release/replay/list")
@ApiOperation(value = "查询所有上架的直播回放列表")
public Page<LiveReplayVo> getReleaseReplayList(@RequestBody LiveReleaseReviewReq reviewReq) {
return replayService.getReleaseReplayList(reviewReq);
}
@PostMapping("/replay/list")
@ApiOperation(value = "管理端根据直播间分页查询所有直播回放")
public Page<LiveReplayVo> getManageReplayList(@RequestBody LiveReviewsVo liveReviewsVo) {
Page<LiveReplayVo> page = liveActivityService.getReplayList(liveReviewsVo);
if (null == page){
return new Page<>(liveReviewsVo.getPageNo(),liveReviewsVo.getPageSize());
}
return page;
}
@PostMapping("/replay/status/update")
@ApiOperation(value = "直播回放上架、下架")
public Boolean updateReplayStatus(@RequestBody LiveReplayOperationVo liveReplayOperationVo) {
return liveActivityService.updateReplayStatus(liveReplayOperationVo.getReplayId(),liveReplayOperationVo.getOperation());
}
@PostMapping("/replay/top/update")
@ApiOperation(value = "直播回放置顶")
public Boolean updateReplayTop(@RequestBody LiveReplayOperationVo liveReplayOperationVo) {
return liveActivityService.updateReplayTop(liveReplayOperationVo.getReplayId(),liveReplayOperationVo.getOperation());
}
@PostMapping("/replay/info/update")
@ApiOperation(value = "直播回放信息修改")
public Boolean updateReplayInfo(@RequestBody LiveReplayInfoVo infoVo ) {
return liveActivityService.updateReplayInfos(infoVo);
}
}
\ No newline at end of file
package com.yizhi.live.application.controller;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.yizhi.live.application.domain.ScopeAuthorization;
import com.yizhi.live.application.service.IScopeAuthorizationService;
import com.yizhi.live.application.vo.VisibleRangeExport;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
@RestController
@RequestMapping("/manage/live/scope")
public class ScopeAuthorizationController {
@Autowired
IScopeAuthorizationService scopeAuthorizationService;
@GetMapping("/message/getList")
public VisibleRangeExport getListToMessage(@RequestParam("liveId") Long liveId) {
VisibleRangeExport vo = new VisibleRangeExport();
ScopeAuthorization range = new ScopeAuthorization();
range.setLiveId(liveId);
List<ScopeAuthorization> list = scopeAuthorizationService.selectList(new EntityWrapper<>(range));
if (!CollectionUtils.isEmpty(list)) {
List<Long> orgIds = new ArrayList<>(list.size());
List<Long> accountIds = new ArrayList<>(list.size());
for (ScopeAuthorization a : list) {
if (a.getType() == 1) {
orgIds.add(a.getAccountId());
} else {
accountIds.add(a.getAccountId());
}
}
vo.setAccountIds(accountIds);
vo.setOrgIds(orgIds);
}
return vo;
}
}
package com.yizhi.live.application.domain;
import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableLogic;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.FieldFill;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* <p>
* 直播活动表
* </p>
*
* @author fulan123
* @since 2018-04-10
*/
@Data
@Api(tags = "LiveActivity", description = "直播活动表")
@TableName("live_activity")
public class LiveActivity extends Model<LiveActivity> {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键")
private Long id;
@ApiModelProperty(value = "直播主题")
private String title;
@ApiModelProperty(value = "直播密码")
private String password;
@ApiModelProperty(value = "直播logo")
@TableField("logo_image")
private String logoImage;
@ApiModelProperty(value = "主播名称")
private String anchor;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@ApiModelProperty(value = "开始时间")
@TableField("start_time")
private Date startTime;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@ApiModelProperty(value = "结束时间")
@TableField("end_time")
private Date endTime;
@ApiModelProperty(value = "直播介绍")
private String description;
@ApiModelProperty(value = "可见范围 0 为站点 1 为可选范围")
private Integer scope;
@ApiModelProperty(value = "频道号")
private String channel;
@ApiModelProperty(value = "是否启用提醒 1:启用 0:关闭")
@TableField("enable_remind")
private Integer enableRemind;
@TableField(value = "create_by_id", fill = FieldFill.INSERT)
private Long createById;
@TableField(value = "create_by_name", fill = FieldFill.INSERT)
private String createByName;
@TableField(value = "create_time", fill = FieldFill.INSERT)
private Date createTime;
@ApiModelProperty(value = "企业")
@TableField("company_id")
private Long companyId;
@TableField("org_id")
private Long orgId;
@TableField("site_id")
private Long siteId;
@ApiModelProperty(value = "0 未上架 1 已上架 2 草稿")
private Integer shelves;
@ApiModelProperty(value = "secretKey")
@TableField("secret_key")
private String secretKey;
@ApiModelProperty(value = "keywords")
@TableField("keywords")
private String keywords;
@ApiModelProperty(value = "是否启用在日历任务中显示")
@TableField("enable_task")
private Integer enableTask;
@ApiModelProperty(value = "直播场景:alone: 活动拍摄 ; ppt: 三分屏; topclass: 大班课")
@TableField("scene")
private String scene;
@ApiModelProperty(value = "观看类型:0: 公开播放 ; 1: 站内授权播放; ")
@TableField("view_type")
private Integer viewType;
@TableLogic
@TableField("deleted")
private Integer deleted;
@ApiModelProperty(value = "排序")
@TableField("sort")
private Integer sort;
@ApiModelProperty(value = "直播状态 10:未开始 40:直播中 90:已结束")
@TableField("status")
private Integer status;
@ApiModelProperty(value = "直播回放开关状态 1: 开 0:关闭")
@TableField("replay_status")
private Boolean replayStatus;
@ApiModelProperty(value = "直播回放回调状态 1:已回调 0:未回调")
@TableField("replay_callback_status")
private Boolean replayCallbackStatus;
@Override
protected Serializable pkVal() {
return this.id;
}
@Override
public String toString() {
return "LiveActivity{" +
"id=" + id +
", title='" + title + '\'' +
", password='" + password + '\'' +
", logoImage='" + logoImage + '\'' +
", anchor='" + anchor + '\'' +
", startTime=" + startTime +
", endTime=" + endTime +
", description='" + description + '\'' +
", scope=" + scope +
", channel='" + channel + '\'' +
", createById=" + createById +
", createByName='" + createByName + '\'' +
", createTime=" + createTime +
", companyId=" + companyId +
", orgId=" + orgId +
", siteId=" + siteId +
", shelves=" + shelves +
", secretKey='" + secretKey + '\'' +
'}';
}
}
package com.yizhi.live.application.domain;
import java.io.Serializable;
import com.baomidou.mybatisplus.enums.IdType;
import java.util.Date;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* <p>
*
* </p>
*
* @author MybatisCodeGenerator123
* @since 2020-12-09
*/
@ApiModel(value = "LiveReplay", description = "直播回放表")
@TableName("live_replay")
public class LiveReplay extends Model<LiveReplay>{
private static final long serialVersionUID = 1L;
@TableId(value="id")
private Long id;
@ApiModelProperty(value = "直播ID")
@TableField("live_id")
private Long liveId;
@ApiModelProperty(value = "直播状态 10:未开始 40:直播中 90:已结束")
@TableField("live_status")
private Integer liveStatus;
@ApiModelProperty(value = "直播回放状态 1: 上架 0:下架")
@TableField("live_replay_status")
private Boolean liveReplayStatus;
@ApiModelProperty(value = "直播计划开始时间")
@TableField("live_plan_start_at")
private Date livePlanStartAt;
@ApiModelProperty(value = "直播logo url")
@TableField("live_logo_url")
private String liveLogoUrl;
@ApiModelProperty(value = "主播名称")
@TableField("live_anchor")
private String liveAnchor;
@ApiModelProperty(value = "直播观看人数")
@TableField("live_viewers")
private Integer liveViewers;
@TableField("company_id")
private Long companyId;
@TableField("site_id")
private Long siteId;
@ApiModelProperty(value = "视频列表页数(默认以12条数据为1页)")
@TableField("page_number")
private Integer pageNumber;
@ApiModelProperty(value = "回放视频总个数")
@TableField("total_items")
private Integer totalItems;
@ApiModelProperty(value = "直播系统生成的id")
@TableField("video_id")
private String videoId;
@ApiModelProperty(value = "点播视频ID")
@TableField("video_pool_id")
private String videoPoolId;
@ApiModelProperty(value = "点播后台用户id")
@TableField("user_id")
private String userId;
@ApiModelProperty(value = "回放视频对应的直播频道id")
@TableField("channel_id")
private String channelId;
@ApiModelProperty(value = "视频标题")
private String title;
@ApiModelProperty(value = "视频首图")
@TableField("first_image")
private String firstImage;
@ApiModelProperty(value = "时长")
private String duration;
@ApiModelProperty(value = "默认视频的播放清晰度,1为流畅,2为高清,3为超清")
@TableField("my_br")
private Integer myBr;
@ApiModelProperty(value = "访客信息收集id")
private String qid;
@ApiModelProperty(value = "视频加密状态,1表示为加密状态,0为非加密")
private Boolean seed;
@ApiModelProperty(value = "添加为回放视频的日期")
@TableField("created_time")
private Date createdTime;
@ApiModelProperty(value = "视频最后修改日期")
@TableField("last_modified")
private Date lastModified;
@ApiModelProperty(value = "回放排序")
private Integer rank;
@ApiModelProperty(value = "是否为默认播放视频,值为1:Y 0:N")
@TableField("as_default")
private Boolean asDefault;
@ApiModelProperty(value = "视频播放地址,注:如果视频为加密视频,则此地址无法访问")
private String url;
@ApiModelProperty(value = "文件ID")
@TableField("file_id")
private String fileId;
@ApiModelProperty(value = "文件URL")
@TableField("file_url")
private String fileUrl;
@ApiModelProperty(value = "观看URL")
@TableField("watch_url")
private String watchUrl;
@ApiModelProperty(value = "用于PPT请求数据,与PPT直播的回放相关,普通直播回放值为null")
@TableField("channel_session_id")
private String channelSessionId;
@ApiModelProperty(value = "视频合并信息,后续补充")
@TableField("merge_info")
private String mergeInfo;
@ApiModelProperty(value = "直播开始时间")
@TableField("start_time")
private Date startTime;
@ApiModelProperty(value = "liveType alone, ppt")
@TableField("live_type")
private String liveType;
@ApiModelProperty(value = "是否为第一页,值为:1:true,0:false")
@TableField("first_page")
private Boolean firstPage;
@ApiModelProperty(value = "是否为最后一页,值为:1:true,0:false")
@TableField("last_page")
private Boolean lastPage;
@ApiModelProperty(value = "下一页编号")
@TableField("next_page_number")
private Integer nextPageNumber;
@ApiModelProperty(value = "上一页编号")
@TableField("pre_page_number")
private Integer prePageNumber;
@ApiModelProperty(value = "总页数")
@TableField("total_pages")
private Integer totalPages;
@ApiModelProperty(value = "当前页第一个视频在回放视频中的位置")
@TableField("start_row")
private Integer startRow;
@ApiModelProperty(value = "当前页最后一个视频在回放视频中的位置")
@TableField("end_row")
private Integer endRow;
@TableField("created_at")
private Date createdAt;
@TableField("updated_at")
private Date updatedAt;
@ApiModelProperty(value = "回放图片说明")
@TableField("image_desc")
private String imageDesc;
@ApiModelProperty(value = "回放置顶时间")
@TableField("top_time")
private Date topTime;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getLiveId() {
return liveId;
}
public void setLiveId(Long liveId) {
this.liveId = liveId;
}
public Integer getLiveStatus() {
return liveStatus;
}
public void setLiveStatus(Integer liveStatus) {
this.liveStatus = liveStatus;
}
public Boolean getLiveReplayStatus() {
return liveReplayStatus;
}
public void setLiveReplayStatus(Boolean liveReplayStatus) {
this.liveReplayStatus = liveReplayStatus;
}
public Date getLivePlanStartAt() {
return livePlanStartAt;
}
public void setLivePlanStartAt(Date livePlanStartAt) {
this.livePlanStartAt = livePlanStartAt;
}
public String getLiveLogoUrl() {
return liveLogoUrl;
}
public void setLiveLogoUrl(String liveLogoUrl) {
this.liveLogoUrl = liveLogoUrl;
}
public String getLiveAnchor() {
return liveAnchor;
}
public void setLiveAnchor(String liveAnchor) {
this.liveAnchor = liveAnchor;
}
public Integer getLiveViewers() {
return liveViewers;
}
public void setLiveViewers(Integer liveViewers) {
this.liveViewers = liveViewers;
}
public Long getCompanyId() {
return companyId;
}
public void setCompanyId(Long companyId) {
this.companyId = companyId;
}
public Long getSiteId() {
return siteId;
}
public void setSiteId(Long siteId) {
this.siteId = siteId;
}
public Integer getPageNumber() {
return pageNumber;
}
public void setPageNumber(Integer pageNumber) {
this.pageNumber = pageNumber;
}
public Integer getTotalItems() {
return totalItems;
}
public void setTotalItems(Integer totalItems) {
this.totalItems = totalItems;
}
public String getVideoId() {
return videoId;
}
public void setVideoId(String videoId) {
this.videoId = videoId;
}
public String getVideoPoolId() {
return videoPoolId;
}
public void setVideoPoolId(String videoPoolId) {
this.videoPoolId = videoPoolId;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getChannelId() {
return channelId;
}
public void setChannelId(String channelId) {
this.channelId = channelId;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getFirstImage() {
return firstImage;
}
public void setFirstImage(String firstImage) {
this.firstImage = firstImage;
}
public String getDuration() {
return duration;
}
public void setDuration(String duration) {
this.duration = duration;
}
public Integer getMyBr() {
return myBr;
}
public void setMyBr(Integer myBr) {
this.myBr = myBr;
}
public String getQid() {
return qid;
}
public void setQid(String qid) {
this.qid = qid;
}
public Boolean getSeed() {
return seed;
}
public void setSeed(Boolean seed) {
this.seed = seed;
}
public Date getCreatedTime() {
return createdTime;
}
public void setCreatedTime(Date createdTime) {
this.createdTime = createdTime;
}
public Date getLastModified() {
return lastModified;
}
public void setLastModified(Date lastModified) {
this.lastModified = lastModified;
}
public Integer getRank() {
return rank;
}
public void setRank(Integer rank) {
this.rank = rank;
}
public Boolean getAsDefault() {
return asDefault;
}
public void setAsDefault(Boolean asDefault) {
this.asDefault = asDefault;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getFileId() {
return fileId;
}
public void setFileId(String fileId) {
this.fileId = fileId;
}
public String getFileUrl() {
return fileUrl;
}
public void setFileUrl(String fileUrl) {
this.fileUrl = fileUrl;
}
public String getWatchUrl() {
return watchUrl;
}
public void setWatchUrl(String watchUrl) {
this.watchUrl = watchUrl;
}
public String getChannelSessionId() {
return channelSessionId;
}
public void setChannelSessionId(String channelSessionId) {
this.channelSessionId = channelSessionId;
}
public String getMergeInfo() {
return mergeInfo;
}
public void setMergeInfo(String mergeInfo) {
this.mergeInfo = mergeInfo;
}
public Date getStartTime() {
return startTime;
}
public void setStartTime(Date startTime) {
this.startTime = startTime;
}
public String getLiveType() {
return liveType;
}
public void setLiveType(String liveType) {
this.liveType = liveType;
}
public Boolean getFirstPage() {
return firstPage;
}
public void setFirstPage(Boolean firstPage) {
this.firstPage = firstPage;
}
public Boolean getLastPage() {
return lastPage;
}
public void setLastPage(Boolean lastPage) {
this.lastPage = lastPage;
}
public Integer getNextPageNumber() {
return nextPageNumber;
}
public void setNextPageNumber(Integer nextPageNumber) {
this.nextPageNumber = nextPageNumber;
}
public Integer getPrePageNumber() {
return prePageNumber;
}
public void setPrePageNumber(Integer prePageNumber) {
this.prePageNumber = prePageNumber;
}
public Integer getTotalPages() {
return totalPages;
}
public void setTotalPages(Integer totalPages) {
this.totalPages = totalPages;
}
public Integer getStartRow() {
return startRow;
}
public void setStartRow(Integer startRow) {
this.startRow = startRow;
}
public Integer getEndRow() {
return endRow;
}
public void setEndRow(Integer endRow) {
this.endRow = endRow;
}
public Date getCreatedAt() {
return createdAt;
}
public void setCreatedAt(Date createdAt) {
this.createdAt = createdAt;
}
public Date getUpdatedAt() {
return updatedAt;
}
public void setUpdatedAt(Date updatedAt) {
this.updatedAt = updatedAt;
}
public String getImageDesc() {
return imageDesc;
}
public void setImageDesc(String imageDesc) {
this.imageDesc = imageDesc;
}
public Date getTopTime() {
return topTime;
}
public void setTopTime(Date topTime) {
this.topTime = topTime;
}
@Override
public String toString() {
return "LiveReplay{" +
", id=" + id +
", liveId=" + liveId +
", liveStatus=" + liveStatus +
", liveReplayStatus=" + liveReplayStatus +
", livePlanStartAt=" + livePlanStartAt +
", liveLogoUrl=" + liveLogoUrl +
", liveAnchor=" + liveAnchor +
", liveViewers=" + liveViewers +
", companyId=" + companyId +
", siteId=" + siteId +
", pageNumber=" + pageNumber +
", totalItems=" + totalItems +
", videoId=" + videoId +
", videoPoolId=" + videoPoolId +
", userId=" + userId +
", channelId=" + channelId +
", title=" + title +
", firstImage=" + firstImage +
", duration=" + duration +
", myBr=" + myBr +
", qid=" + qid +
", seed=" + seed +
", createdTime=" + createdTime +
", lastModified=" + lastModified +
", rank=" + rank +
", asDefault=" + asDefault +
", url=" + url +
", fileId=" + fileId +
", fileUrl=" + fileUrl +
", watchUrl=" + watchUrl +
", channelSessionId=" + channelSessionId +
", mergeInfo=" + mergeInfo +
", startTime=" + startTime +
", liveType=" + liveType +
", firstPage=" + firstPage +
", lastPage=" + lastPage +
", nextPageNumber=" + nextPageNumber +
", prePageNumber=" + prePageNumber +
", totalPages=" + totalPages +
", startRow=" + startRow +
", endRow=" + endRow +
", createdAt=" + createdAt +
", updatedAt=" + updatedAt +
"}";
}
/**
* 主键值
*/
@Override
protected Serializable pkVal() {
return this.id;
}
}
package com.yizhi.live.application.domain;
import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.FieldFill;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* <p>
* 直播生成的token保存
* </p>
*
* @author fulan123
* @since 2018-04-25
*/
@Data
@Api(tags = "LiveToken", description = "直播生成的token保存")
@TableName("live_token")
public class LiveToken extends Model<LiveToken> {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键")
private Long id;
@ApiModelProperty(value = "生成的token")
private String token;
@TableField(value = "create_by_id", fill = FieldFill.INSERT)
private Long createById;
@TableField(value = "create_by_name", fill = FieldFill.INSERT)
private String createByName;
@TableField(value = "create_time", fill = FieldFill.INSERT)
private Date createTime;
@Override
protected Serializable pkVal() {
return this.id;
}
}
package com.yizhi.live.application.domain;
import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableName;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* <p>
* 直播授权课件范围表
* </p>
*
* @author fulan123
* @since 2018-04-10
*/
@Data
@Api(tags = "ScopeAuthorization", description = "直播授权课件范围表")
@TableName("scope_authorization")
public class ScopeAuthorization extends Model<ScopeAuthorization> {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键")
private Long id;
@ApiModelProperty(value = "账号id")
@TableField("account_id")
private Long accountId;
@ApiModelProperty(value = "直播活动id")
@TableField("live_id")
private Long liveId;
@ApiModelProperty(value = "1.部门、2.用户")
private Integer type;
@TableField("site_id")
private Long siteId;
@TableField("name")
private String name;
@ApiModelProperty(value = "用户名")
@TableField(exist = false)
private String fullName;
@ApiModelProperty(value = "工号")
@TableField(exist = false)
private String workNum;
@Override
protected Serializable pkVal() {
return this.id;
}
}
package com.yizhi.live.application.enums;
public enum LiveStatus {
END(1L, "end"),//直播结束
LIVE(2L, "live"),//正在直播
NOT_START(3L, "notStart");//即将开始
private Long code;
private String name;
LiveStatus(Long code, String name) {
this.name = name;
this.code = code;
}
public Long getCode() {
return code;
}
public String getName() {
return name;
}
}
package com.yizhi.live.application.enums;
/**
* @Date 2020/12/21 6:22 下午
* @Author lvjianhui
**/
public enum LiveStatusV2 {
UN_START(10,"未开始"),
RUNNING(30,"直播中"),
REPLAY(40,"直播回放"),
END(90,"已结束");
private Integer code;
private String name;
LiveStatusV2(Integer code, String name) {
this.name = name;
this.code = code;
}
public Integer getCode() {
return code;
}
public String getName() {
return name;
}
}
package com.yizhi.live.application.enums;
public enum PolyvReqEnum {
APP_ID("appId","从API设置中获取,在直播系统登记的appId"),
TIMESTAMP("timestamp","当前13位毫秒级时间戳,3分钟内有效"),
SIGN("sign","签名,32位大写MD5值"),
CHANNEL_IDS("channelIds","多个频道ID,用逗号隔开"),
CHANNEL_ID("channelId","多个频道ID,用逗号隔开"),
LIVE("live","开始直播"),
END("end","直播结束"),
START_DATE("startDate","开始时间"),
END_DATE("endDate","结束时间"),
;
private String name;
private String value;
PolyvReqEnum(String name, String value) {
this.name = name;
this.value = value;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
package com.yizhi.live.application.jobhandler;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.yizhi.application.orm.id.IdGenerator;
import com.yizhi.live.application.domain.LiveActivity;
import com.yizhi.live.application.domain.LiveReplay;
import com.yizhi.live.application.service.ILiveActivityService;
import com.yizhi.live.application.service.ILiveReplayService;
import com.yizhi.live.application.util.PolyvUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* @Date 2020/12/8 2:22 下午
* @Author lvjianhui
**/
@RestController
@RequestMapping("/job/live")
public class PolyvReplayLogHandler {
@Autowired
private ILiveActivityService iLiveActivityService;
@Autowired
private ILiveReplayService iLiveReplayService;
@Autowired
IdGenerator idGenerator;
private Logger logger = LoggerFactory.getLogger(PolyvReplayLogHandler.class);
@GetMapping("/insert/replay")
public void insertLiveReplay() {
Date currencyDate = new Date();
List<LiveActivity> allLive = getAllLive();
logger.trace("直播数量为:{}", allLive.size());
allLive.stream().forEach(live -> {
List<LiveReplay> list = new ArrayList<>();
try {
list = PolyvUtils.getChannelReplay(live.getChannel());
} catch (Exception e) {
logger.error("查询视频回放出错", e);
return;
}
logger.trace("查询视频回放 :{}", list.size());
list.stream().forEach(replay -> {
LiveReplay liveReplay = iLiveReplayService.getByVideoPoolId(replay.getVideoPoolId());
if (null == liveReplay) {
replay.setId(idGenerator.generate());
replay.setChannelId(live.getChannel());
replay.setLiveId(live.getId());
replay.setLivePlanStartAt(live.getStartTime());
replay.setLiveLogoUrl(live.getLogoImage());
replay.setLiveAnchor(live.getAnchor());
replay.setCompanyId(live.getCompanyId());
replay.setSiteId(live.getSiteId());
try {
iLiveReplayService.insert(replay);
} catch (Exception e) {
logger.error("新增视频回放出错", e);
}
}else {
liveReplay.setTitle(replay.getTitle());
liveReplay.setUpdatedAt(currencyDate);
iLiveReplayService.updateById(liveReplay);
}
});
});
// 更新时间小于当前时间,证明已再保利威删除,故直接删除
iLiveReplayService.deleteByUpdateTime(new Date(currencyDate.getTime() - 5 * 60 * 1000));
}
private List<LiveActivity> getAllLive() {
LiveActivity liveActivity = new LiveActivity();
liveActivity.setDeleted(0);
EntityWrapper<LiveActivity> entityWrapper = new EntityWrapper<>(liveActivity);
return iLiveActivityService.selectList(entityWrapper);
}
}
package com.yizhi.live.application.mapper;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.yizhi.live.application.domain.LiveActivity;
import com.yizhi.live.application.vo.PageLiveVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.session.RowBounds;
import java.util.Date;
import java.util.List;
import java.util.Set;
/**
* <p>
* 直播活动表 Mapper 接口
* </p>
*
* @author fulan123
* @since 2018-04-10
*/
public interface LiveActivityMapper extends BaseMapper<LiveActivity> {
List<PageLiveVo> apiSearchPage(@Param("ids") List<Long> ids, @Param("title") String title, @Param("siteId") Long siteId,
@Param("companyId") Long companyId,
Page<PageLiveVo> page);
Integer apiSearchPageCount(@Param("ids") List<Long> ids, @Param("title") String title, @Param("siteId") Long siteId,
@Param("companyId") Long companyId);
List<PageLiveVo> portalList2(@Param("title") String title, @Param("startTime") Date startTime, @Param("endTime") Date endTime,
@Param("companyId") Long companyId, @Param("siteId") Long siteId,
@Param("orgId") List<Long> orgId, Page<PageLiveVo> page);
List<PageLiveVo> portalList(@Param("title") String title, @Param("startTime") Date startTime, @Param("endTime") Date endTime,
@Param("companyId") Long companyId, @Param("siteId") Long siteId,
@Param("orgId") List<Long> orgId, RowBounds rowBounds);
List<PageLiveVo> getPageLiveVoList(@Param("title") String title, @Param("siteId") Long siteId,
@Param("companyId") Long companyId,
RowBounds rowBounds);
Integer getPageLiveVoListCount(@Param("title") String title, @Param("siteId") Long siteId,
@Param("companyId") Long companyId);
Set<PageLiveVo> queryLiveListByRelationIds(@Param("relationIds")List<Long> relationIds,@Param("siteId")Long siteId, RowBounds rowBounds);
List<Long> getIdsByDate(@Param("currentDate") Date currentDate, @Param("siteId") Long siteId);
List<PageLiveVo> getPageToCalendar(@Param("finishTrIds") List<Long> finishTrIds,
@Param("trIds") List<Long> trIds,
@Param("currentDate") Date currentDate,
@Param("siteId") Long siteId,
Page page);
Integer getPageToCalendarNum(@Param("finishTrIds") List<Long> finishTrIds,
@Param("trIds") List<Long> trIds,
@Param("currentDate") Date currentDate,
@Param("siteId") Long siteId);
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yizhi.live.application.mapper.LiveActivityMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.yizhi.live.application.domain.LiveActivity">
<id column="id" property="id"/>
<result column="title" property="title"/>
<result column="password" property="password"/>
<result column="logo_image" property="logoImage"/>
<result column="anchor" property="anchor"/>
<result column="start_time" property="startTime"/>
<result column="end_time" property="endTime"/>
<result column="description" property="description"/>
<result column="enable_remind" property="enableRemind"/>
<result column="scope" property="scope"/>
<result column="channel" property="channel"/>
<result column="create_by_id" property="createById"/>
<result column="create_by_name" property="createByName"/>
<result column="create_time" property="createTime"/>
<result column="company_id" property="companyId"/>
<result column="org_id" property="orgId"/>
<result column="site_id" property="siteId"/>
<result column="keywords" property="keywords"/>
<result column="enable_task" property="enableTask"/>
<result column="sort" jdbcType="INTEGER" property="sort" />
<result column="status" jdbcType="INTEGER" property="status" />
<result column="replay_status" jdbcType="BIT" property="replayStatus" />
<result column="replay_callback_status" jdbcType="BIT" property="replayCallbackStatus" />
</resultMap>
<!-- 直播管理端列表 -->
<resultMap id="ManageResultMap" type="com.yizhi.live.application.vo.PageLiveVo">
<id column="id" property="id"/>
<result column="title" property="title"/>
<result column="password" property="password"/>
<result column="logo_image" property="logoImage"/>
<result column="anchor" property="anchor"/>
<result column="start_time" property="startTime"/>
<result column="end_time" property="endTime"/>
<result column="channel" property="channel"/>
<result column="shelves" property="shelves"/>
<result column="description" property="description"/>
<result column="view_type" property="viewType"/>
<result column="status" property="status"/>
</resultMap>
<select id="searchPage" resultMap="ManageResultMap">
SELECT
c.id,c.title,c.password,c.logo_image,c.anchor,c.start_time,c.end_time,c.channel,c.shelves,c.description
FROM live_activity c
<where>
<if test="companyId!=null">
AND c.`company_id` = #{companyId}
</if>
<if test="siteId!=null">
AND c.`site_id` = #{siteId}
</if>
<if test="orgId!=null">
AND c.org_id IN
<foreach collection="orgId" open="(" close=")" separator="," item="oid" index="index">
#{oid}
</foreach>
</if>
<if test="startTime!=null">
<![CDATA[ AND c.`start_time` >= #{startTime} ]]>
</if>
<if test="endTime!=null">
<![CDATA[ AND c.`start_time` <= #{endTime} ]]>
</if>
<if test="title!=null">
AND (c.`title` LIKE CONCAT('%', #{title}, '%') OR c.channel LIKE CONCAT('%', #{title}, '%'))
</if>
</where>
ORDER BY c.`create_time` desc
</select>
<select id="searchPageCount" resultType="java.lang.Integer">
SELECT
count(c.id)
FROM live_activity c
<where>
<if test="companyId!=null">
AND c.`company_id` = #{companyId}
</if>
<if test="siteId!=null">
AND c.`site_id` = #{siteId}
</if>
<if test="orgId!=null">
AND c.org_id IN
<foreach collection="orgId" open="(" close=")" separator="," item="oid" index="index">
#{oid}
</foreach>
</if>
<if test="startTime!=null">
<![CDATA[ AND c.`create_time` > #{startTime} ]]>
</if>
<if test="endTime!=null">
<![CDATA[ AND c.`create_time` > #{endTime} ]]>
</if>
<if test="title!=null">
AND c.`title` LIKE CONCAT('%', #{title}, '%')
</if>
</where>
</select>
<!-- 直播管理端列表 结束 -->
<!-- 直播app端列表 -->
<select id="apiSearchPage" resultMap="ManageResultMap">
SELECT
c.id,
c.title,
c. PASSWORD,
c.logo_image,
c.anchor,
c.start_time,
c.end_time,
c.channel,
c.shelves,
c.description,
c.view_type,
case when c.status = '90' then "end" when c.status = '40' then "live" when c.status = '10' then "not_start" else null end status
FROM
live_activity c
<where>
c.shelves = 1
<if test="companyId!=null">
AND c.`company_id` = #{companyId}
</if>
<if test="siteId!=null">
AND c.`site_id` = #{siteId}
</if>
<if test="title!=null and title != ''">
AND (c.`title` LIKE CONCAT('%', #{title}, '%')
or c.keywords LIKE CONCAT('%', #{title}, '%')
or c.channel LIKE CONCAT('%', #{title}, '%')
or c.anchor LIKE CONCAT('%', #{title}, '%')
)
</if>
AND
(c.scope = 0
<if test="ids != null and ids.size > 0">
or
(c.id in <foreach collection="ids" open="(" close=")" separator="," item="item">#{item}</foreach>)
</if>
)
</where>
ORDER BY c.create_time desc
</select>
<select id="apiSearchPageCount" resultType="java.lang.Integer">
SELECT
count(c.id)
FROM
live_activity c
<where>
c.shelves = 1
<if test="companyId!=null">
AND c.`company_id` = #{companyId}
</if>
<if test="siteId!=null">
AND c.`site_id` = #{siteId}
</if>
<if test="title !=null and title != '' ">
AND (c.`title` LIKE CONCAT('%', #{title}, '%')
or c.keywords LIKE CONCAT('%', #{title}, '%')
or c.channel LIKE CONCAT('%', #{title}, '%')
or c.anchor LIKE CONCAT('%', #{title}, '%')
)
</if>
AND
(c.scope = 0
<if test="ids != null and ids.size > 0">
or
(c.id in <foreach collection="ids" open="(" close=")" separator="," item="item">#{item}</foreach>)
</if>
)
</where>
ORDER BY c.create_time desc
</select>
<!-- 直播app端列表 结束-->
<!-- 首页配置选择列表 -->
<select id="portalList" resultMap="ManageResultMap">
SELECT
c.id,c.title,c.password,c.logo_image,c.anchor,c.start_time,c.end_time,c.channel,c.shelves
FROM live_activity c
<where>
c.shelves = 1
<if test="companyId!=null">
AND c.`company_id` = #{companyId}
</if>
<if test="siteId!=null">
AND c.`site_id` = #{siteId}
</if>
/* 分级授权修改 sql 拼接orgIds去掉(关联修改在:com.yizhi.live.application.service.impl.LiveActivityServiceImpl#portalList) */
<!-- <if test="orgId!=null">
AND c.org_id IN
<foreach collection="orgId" open="(" close=")" separator="," item="oid" index="index">
#{oid}
</foreach>
</if>-->
<if test="startTime!=null">
<![CDATA[ AND c.`start_time` >= #{startTime} ]]>
</if>
<if test="endTime!=null">
<![CDATA[ AND c.`start_time` <= #{endTime} ]]>
</if>
<if test="title!=null">
AND (c.`title` LIKE CONCAT('%', #{title}, '%') OR c.channel LIKE CONCAT('%', #{title}, '%'))
</if>
</where>
ORDER BY c.`create_time` desc
</select>
<!-- 首页配置选择列表 -->
<select id="portalList2" resultMap="ManageResultMap">
SELECT
c.id,c.title,c.password,c.logo_image,c.anchor,c.start_time,c.end_time,c.channel,c.shelves,c.view_type
FROM live_activity c
<where>
c.shelves = 1
<if test="companyId!=null">
AND c.`company_id` = #{companyId}
</if>
<if test="siteId!=null">
AND c.`site_id` = #{siteId}
</if>
<if test="startTime!=null">
<![CDATA[ AND c.`start_time` >= #{startTime} ]]>
</if>
<if test="endTime!=null">
<![CDATA[ AND c.`start_time` <= #{endTime} ]]>
</if>
<if test="title!=null">
AND (c.`title` LIKE CONCAT('%', #{title}, '%') OR c.channel LIKE CONCAT('%', #{title}, '%'))
</if>
</where>
ORDER BY c.`create_time` desc
</select>
<select id="getPageLiveVoList" resultMap="ManageResultMap">
SELECT
c.id,
c.title,
c. PASSWORD,
c.logo_image,
c.anchor,
c.start_time,
c.end_time,
c.channel,
c.shelves
FROM
live_activity c
<where>
c.shelves = 1
<if test="companyId!=null">
AND c.`company_id` = #{companyId}
</if>
<if test="siteId!=null">
AND c.`site_id` = #{siteId}
</if>
<if test="title!=null">
AND c.`title` LIKE CONCAT('%', #{title}, '%')
</if>
</where>
ORDER BY c.create_time desc
</select>
<select id="getPageLiveVoListCount" resultType="java.lang.Integer">
SELECT
count(c.id)
FROM
live_activity c
<where>
c.shelves = 1
<if test="companyId!=null">
AND c.`company_id` = #{companyId}
</if>
<if test="siteId!=null">
AND c.`site_id` = #{siteId}
</if>
<if test="title!=null">
AND c.`title` LIKE CONCAT('%', #{title}, '%')
</if>
</where>
ORDER BY c.create_time desc
</select>
<select id="queryLiveListByRelationIds" resultMap="ManageResultMap">
SELECT
c.id,
c.title,
c. PASSWORD,
c.logo_image,
c.anchor,
c.start_time,
c.end_time,
c.channel,
c.shelves
FROM
live_activity c
left join scope_authorization sc on(sc.live_id = c.id)
<where>
c.shelves = 1 and c.site_id = #{siteId}
AND
(c.scope = 0
<if test="relationIds != null and relationIds.size > 0">
or
(sc.account_id in
<foreach collection="relationIds" open="(" close=")" separator="," item="item">#{item}
</foreach>)
</if>
)
ORDER BY c.start_time desc
</where>
</select>
<select id="getIdsByDate" resultType="Long">
select id
from live_activity c
where 1=1
and c.shelves = 1
and c.enable_task = 1
and c.deleted = 0
AND c.`site_id` = #{siteId}
AND <![CDATA[ DATE_FORMAT(c.start_time, '%Y-%m-%d') <= DATE_FORMAT(#{currentDate}, '%Y-%m-%d') ]]>
AND <![CDATA[ DATE_FORMAT(c.end_time, '%Y-%m-%d') >= DATE_FORMAT(#{currentDate}, '%Y-%m-%d') ]]>
</select>
<select id="getPageToCalendar" resultType="com.yizhi.live.application.vo.PageLiveVo">
select *
from live_activity c
where 1=1
<if test="finishTrIds != null and finishTrIds.size() > 0">
and c.id not in (<foreach collection="finishTrIds" item="id" separator=",">#{id}</foreach>)
</if>
and (c.scope = 0
<if test="trIds != null and trIds.size() > 0">
or c.id in (<foreach collection="trIds" item="item" separator=",">#{item}</foreach>)
</if>)
and c.shelves = 1
and c.enable_task = 1 and c.deleted = 0
AND c.`site_id` = #{siteId}
AND <![CDATA[ DATE_FORMAT(c.start_time, '%Y-%m-%d') <= DATE_FORMAT(#{currentDate}, '%Y-%m-%d') ]]>
AND <![CDATA[ DATE_FORMAT(c.end_time, '%Y-%m-%d') >= DATE_FORMAT(#{currentDate}, '%Y-%m-%d') ]]>
order by start_time desc,end_time desc
</select>
<select id="getPageToCalendarNum" resultType="Integer">
select
count(1)
from live_activity c
where 1=1
<if test="finishTrIds != null and finishTrIds.size() > 0">
and c.id not in (<foreach collection="finishTrIds" item="id" separator=",">#{id}</foreach>)
</if>
and (c.scope = 0
<if test="trIds != null and trIds.size() > 0">
or c.id in (<foreach collection="trIds" item="item" separator=",">#{item}</foreach>)
</if>)
and c.shelves = 1
and c.enable_task = 1
AND c.`site_id` = #{siteId}
AND <![CDATA[ DATE_FORMAT(c.start_time, '%Y-%m-%d') <= DATE_FORMAT(#{currentDate}, '%Y-%m-%d') ]]>
AND <![CDATA[ DATE_FORMAT(c.end_time, '%Y-%m-%d') >= DATE_FORMAT(#{currentDate}, '%Y-%m-%d') ]]>
</select>
</mapper>
package com.yizhi.live.application.mapper;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.yizhi.live.application.domain.LiveReplay;
import com.yizhi.live.application.vo.LiveReplayVo;
import com.yizhi.live.application.vo.LiveTitleVo;
import com.yizhi.util.application.domain.BizResponse;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.Date;
import java.util.List;
public interface LiveReplayMapper extends BaseMapper<LiveReplay> {
/**
* 查询直播回放
* @param liveIdList 直播id
*/
List<LiveReplayVo> selectReplayList(@Param(value = "liveIdList") List<Long> liveIdList,@Param(value = "title") String title, Page<LiveReplayVo> page);
/**
* 查询有直播回放的直播列表
*/
List<LiveTitleVo> selectHashReviewLiveList(@Param(value = "liveIdList") List<Long> liveIdList, @Param("companyId") Long companyId, @Param("siteId") Long siteId,Page<LiveTitleVo> page);
void deleteByUpdateTime(@Param("updateTime") Date updateTime);
/**
* 根据直播查询回放列表
* @param liveId 直播id
*/
List<LiveReplayVo> selectReplayListByLiveId(@Param("liveId") Long liveId, Page<LiveReplayVo> page);
/**
* 批量删除
*/
void deleteReplayBatch(@Param("delReplayIdList") List<Long> delReplayIdList);
/**
* 更新直播回放置顶
* @param topTime 置顶时间
*/
void updateTopTime(@Param("id") Long id ,@Param("topTime") Date topTime);
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yizhi.live.application.mapper.LiveReplayMapper">
<resultMap id="BaseResultMap" type="com.yizhi.live.application.domain.LiveReplay">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="live_id" jdbcType="BIGINT" property="liveId" />
<result column="live_status" jdbcType="INTEGER" property="liveStatus" />
<result column="live_replay_status" jdbcType="BIT" property="liveReplayStatus" />
<result column="live_plan_start_at" jdbcType="TIMESTAMP" property="livePlanStartAt" />
<result column="live_logo_url" jdbcType="VARCHAR" property="liveLogoUrl" />
<result column="live_anchor" jdbcType="VARCHAR" property="liveAnchor" />
<result column="live_viewers" jdbcType="INTEGER" property="liveViewers" />
<result column="company_id" jdbcType="BIGINT" property="companyId" />
<result column="site_id" jdbcType="BIGINT" property="siteId" />
<result column="page_number" jdbcType="INTEGER" property="pageNumber" />
<result column="total_items" jdbcType="INTEGER" property="totalItems" />
<result column="video_id" jdbcType="VARCHAR" property="videoId" />
<result column="video_pool_id" jdbcType="VARCHAR" property="videoPoolId" />
<result column="user_id" jdbcType="VARCHAR" property="userId" />
<result column="channel_id" jdbcType="VARCHAR" property="channelId" />
<result column="title" jdbcType="VARCHAR" property="title" />
<result column="first_image" jdbcType="VARCHAR" property="firstImage" />
<result column="duration" jdbcType="VARCHAR" property="duration" />
<result column="my_br" jdbcType="INTEGER" property="myBr" />
<result column="seed" jdbcType="BIT" property="seed" />
<result column="created_time" jdbcType="TIMESTAMP" property="createdTime" />
<result column="last_modified" jdbcType="TIMESTAMP" property="lastModified" />
<result column="rank" jdbcType="INTEGER" property="rank" />
<result column="as_default" jdbcType="BIT" property="asDefault" />
<result column="url" jdbcType="VARCHAR" property="url" />
<result column="file_id" jdbcType="VARCHAR" property="fileId" />
<result column="file_url" jdbcType="VARCHAR" property="fileUrl" />
<result column="watch_url" jdbcType="VARCHAR" property="watchUrl" />
<result column="channel_session_id" jdbcType="VARCHAR" property="channelSessionId" />
<result column="merge_info" jdbcType="VARCHAR" property="mergeInfo" />
<result column="start_time" jdbcType="TIMESTAMP" property="startTime" />
<result column="live_type" jdbcType="VARCHAR" property="liveType" />
<result column="first_page" jdbcType="BIT" property="firstPage" />
<result column="last_page" jdbcType="BIT" property="lastPage" />
<result column="next_page_number" jdbcType="INTEGER" property="nextPageNumber" />
<result column="pre_page_number" jdbcType="INTEGER" property="prePageNumber" />
<result column="total_pages" jdbcType="INTEGER" property="totalPages" />
<result column="start_row" jdbcType="INTEGER" property="startRow" />
<result column="end_row" jdbcType="INTEGER" property="endRow" />
<result column="created_at" jdbcType="TIMESTAMP" property="createdAt" />
<result column="updated_at" jdbcType="TIMESTAMP" property="updatedAt" />
<result column="image_desc" jdbcType="VARCHAR" property="imageDesc" />
<result column="top_time" jdbcType="TIMESTAMP" property="topTime" />
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.yizhi.live.application.domain.LiveReplay">
<result column="qid" jdbcType="LONGVARCHAR" property="qid" />
</resultMap>
<sql id="Base_Column_List">
id, live_id, live_status, live_replay_status, live_plan_start_at, live_logo_url,
live_anchor, live_viewers, company_id, site_id, page_number, total_items, video_id,
video_pool_id, user_id, channel_id, title, first_image, duration, my_br, seed, created_time,
last_modified, rank, as_default, url, file_id, file_url, watch_url, lang, channel_session_id,
merge_info, start_time, live_type, first_page, last_page, next_page_number, pre_page_number,
total_pages, start_row, end_row, created_at, updated_at,top_time,image_desc
</sql>
<sql id="Blob_Column_List">
qid
</sql>
<update id="updateTopTime">
update live_replay set top_time = #{topTime} where id = #{id}
</update>
<delete id="deleteByUpdateTime">
delete from live_replay where updated_at &lt;= #{updateTime}
</delete>
<delete id="deleteReplayBatch">
<if test="delReplayIdList != null and delReplayIdList.size() > 0">
delete from live_replay where id in
<foreach collection="delReplayIdList" open="(" close=")" separator="," item="id">
#{id}
</foreach>
</if>
</delete>
<select id="selectReplayList" resultType="com.yizhi.live.application.vo.LiveReplayVo">
select replay.*
,act.view_type as viewType
from live_replay replay
left join live_activity act on replay.live_id = act.id
where replay.live_replay_status = '1'
<if test="null != title and title != ''">
and ( replay.title LIKE CONCAT('%', #{title}, '%') or replay.live_anchor LIKE CONCAT('%', #{title}, '%') )
</if>
<if test="null != liveIdList and liveIdList.size > 0">
and replay.live_id in
<foreach collection="liveIdList" open="(" close=")" separator="," item="liveId">
#{liveId}
</foreach>
</if>
ORDER BY replay.top_time desc ,replay.start_time desc
</select>
<select id="selectHashReviewLiveList" resultType="com.yizhi.live.application.vo.LiveTitleVo">
select live_id liveId, channel_id channelId, title
from live_replay
where live_replay_status = '1'
<if test="null != liveIdList and liveIdList.size > 0">
and live_id in
<foreach collection="liveIdList" open="(" close=")" separator="," item="liveId">
#{liveId}
</foreach>
</if>
GROUP BY live_id
ORDER BY live_plan_start_at desc, live_id ASC,start_time asc
</select>
<select id="selectReplayListByLiveId" resultType="com.yizhi.live.application.vo.LiveReplayVo">
select * from live_replay
where live_id = #{liveId}
order by top_time desc ,start_time desc
</select>
</mapper>
\ No newline at end of file
package com.yizhi.live.application.mapper;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.yizhi.live.application.domain.LiveToken;
/**
* <p>
* 直播生成的token保存 Mapper 接口
* </p>
*
* @author fulan123
* @since 2018-04-25
*/
public interface LiveTokenMapper extends BaseMapper<LiveToken> {
}
package com.yizhi.live.application.mapper;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.yizhi.live.application.domain.ScopeAuthorization;
import com.yizhi.live.application.vo.ScopeAuthorizationVO;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
import java.util.Set;
/**
* <p>
* 直播授权课件范围表 Mapper 接口
* </p>
*
* @author fulan123
* @since 2018-04-10
*/
public interface ScopeAuthorizationMapper extends BaseMapper<ScopeAuthorization> {
List<Long> selectLiveIdByRelationId(@Param("relationIds") List<Long> relationIds);
Boolean insertListVO(@Param("list")List<ScopeAuthorizationVO> list);
Boolean insertList(@Param("list")List<ScopeAuthorization> list);
Set<Long> selectLiveId(@Param("relationIds") List<Long> relationIds, @Param("siteId") Long siteId);
List<Long> getUsefulIds(@Param("ids") List<Long> ids,
@Param("relationIds") List<Long> relationIds,
@Param("siteId") Long siteId);
/**
* 删除可见范围
* @param liveId
*/
void deleteAuthorize(@Param("liveId") Long liveId);
/**
* 查询直播回放开启的直播间id集合
* @param authLiveIds 指定用户可见的直播id
* @return
*/
List<Long> selectReplayOnLiveIds(@RequestParam("authLiveIds") List<Long> authLiveIds,@RequestParam("companyId") Long companyId,@RequestParam("siteId") Long siteId);
}
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.yizhi.live.application.mapper.ScopeAuthorizationMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.yizhi.live.application.domain.ScopeAuthorization">
<id column="id" property="id" />
<result column="account_id" property="accountId" />
<result column="live_id" property="liveId" />
<result column="type" property="type" />
</resultMap>
<delete id="deleteAuthorize">
DELETE
FROM
scope_authorization
WHERE
live_id = #{liveId}
</delete>
<select id="selectLiveIdByRelationId" resultType="java.lang.Long">
<if test="relationIds != null">
select live_id
from scope_authorization
<where>
account_id in
<foreach collection="relationIds" open="(" close=")" item="item" separator=",">
#{item}
</foreach>
</where>
</if>
</select>
<!-- 数据批量插入 -->
<insert id="insertList" parameterType="java.util.ArrayList">
insert into scope_authorization (id,live_id,account_id,type,name,site_id) VALUES
<foreach collection="list" item="item" index="index" separator=",">
(#{item.id},#{item.liveId},#{item.accountId},#{item.type},#{item.name},#{item.siteId})
</foreach>
</insert>
<!-- 数据批量插入 -->
<insert id="insertListVO" parameterType="java.util.ArrayList">
insert into scope_authorization (id,live_id,account_id,type,name,site_id) VALUES
<foreach collection="list" item="item" index="index" separator=",">
(#{item.id},#{item.liveId},#{item.accountId},#{item.type},#{item.name},#{item.siteId})
</foreach>
</insert>
<select id="selectLiveId" resultType="java.lang.Long">
<if test="relationIds != null">
select live_id
from scope_authorization
<where>
site_id = #{siteId} and
account_id in
<foreach collection="relationIds" open="(" close=")" item="item" separator=",">
#{item}
</foreach>
</where>
</if>
</select>
<select id="getUsefulIds" resultType="java.lang.Long">
select live_id
from scope_authorization
<where>
site_id = #{siteId}
<if test="relationIds != null and relationIds.size() > 0">
and account_id in
<foreach collection="relationIds" open="(" close=")" item="item" separator=",">
#{item}
</foreach>
</if>
<if test="ids != null and ids.size()>0">
and live_id in <foreach collection="ids" open="(" close=")" item="id" separator=","> #{id} </foreach>
</if>
</where>
</select>
<select id="selectReplayOnLiveIds" resultType="java.lang.Long">
select c.id
FROM
live_activity c
<where>
c.shelves = 1 and deleted = 0 and replay_status = '1'
<if test="companyId != null">
AND c.`company_id` = #{companyId}
</if>
<if test="siteId != null">
AND c.`site_id` = #{siteId}
</if>
AND
(c.scope = 0
<if test="authLiveIds != null and authLiveIds.size > 0">
or
(c.id in
<foreach collection="authLiveIds" open="(" close=")" separator="," item="item">
#{item}
</foreach>
)
</if>
)
</where>
</select>
</mapper>
package com.yizhi.live.application.service;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.IService;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.yizhi.core.application.context.RequestContext;
import com.yizhi.core.application.vo.DroolsVo;
import com.yizhi.live.application.domain.LiveActivity;
import com.yizhi.live.application.request.LiveReleaseReviewReq;
import com.yizhi.live.application.vo.*;
import com.yizhi.util.application.domain.BizResponse;
import org.apache.xpath.operations.Bool;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* <p>
* 直播活动表 服务类
* </p>
*
* @author fulan123
* @since 2018-04-10
*/
public interface ILiveActivityService extends IService<LiveActivity> {
/**
* 创建直播间
*
* @param params
* @return
*/
String createChanel(Map<String, String> params);
Page<PageLiveVo> searchPage(String title, String startTimeString, String endTimeString,
Long companyId, Long siteId,
List<Long> orgId, int pageNo, int pageSize,
String expTimeString, Integer status , Integer viewType,Boolean startTimeAsc,Boolean endTimeAsc);
/**
* 查询近七天的已完成的直播
* @param companyId
* @param siteId
* @return
*/
List<LiveActivity> findWithinSevenDaysLive(Long companyId, Long siteId, Long accountId);
Boolean deleteChanel(String chanel);
String setToken(String chanel);
List<PageLiveVo> apiSearchHomeList(List<Long> relationIds,String title,
Long companyId, Long siteId,
int pageNo, int pageSize);
Page<PageLiveVo> apiSearchPageList(List<Long> relationIds,String title,
Long companyId, Long siteId,
int pageNo, int pageSize);
Boolean saveLive(LiveActivityResultVO liveActivityResultVO);
Boolean updateLive(LiveActivityResultVO liveActivityResultVO);
List<PageLiveVo> portalList(String title, Date startTime, Date endTime,
Long companyId, Long siteId,
List<Long> orgId, int pageNo, int pageSize);
Page<PageLiveVo> portalList2(String title, Date startTime, Date endTime,
Long companyId, Long siteId,
List<Long> orgId, int pageNo, int pageSize);
/**
* 范围人员导出 管理端-------2018/09/19
* @param assignmentId
* @return
*/
public VisibleRangeExport vsibleRangeExport(Long liveId);
/**
* 根据relationId 判断这个人是否可以看到这这场直播
* @param relationId 里面可能有accountId or orgId
* @param liveId 直播Id
* @return
*/
Boolean judgeScope (List<Long> relationId,Long liveId);
Page<PageLiveVo> getPageLiveVoList(Long siteId, Integer pageNo, Integer pageSize);
Page<LiveActivity> getPageLiveVoListNotIds(List<Long> ids, Long siteId, Integer pageNo, Integer pageSize);
Page<LiveActivity> LiveActivityByIds(List<Long> listIds, Integer pageNo, Integer pageSize);
/**
* 根据传入的频道Id,返回直播状态
* @param channelId
* @return
*/
Integer getLiveStatus(String channelId);
/**
* 根据传入的relationIds 里面有accountId、orgId
* @param relationIds
* @param pageNo
* @param pageSize
* @return
*/
List<PageLiveVo> queryLiveListByRelationIds( List<Long> relationIds, Integer pageNo, Integer pageSize);
List<Map<String, Object>> getServerByCompanyIdAndIds(Long companyId,List<Long> ids);
Page<PageLiveVo> pcSearchPageList(List<Long> relationIds, String title, Long companyId, Long siteId, int pageNo, int pageSize);
Page<PageLiveVo> getPageToCalendar(Date date, Page<PageLiveVo> page);
Page<DroolsVo> getPageByDrools(String field, String value, Page<DroolsVo> page);
/**
* 获取直播的实时在线人数
* @param channelIds 多个直播号用逗号隔开
* @return 在线人数list
*/
List<LiveOnlineCountVo> getChannelOnlineCountRealTime(String channelIds) throws JsonProcessingException;
/**
* 直播状态修改;保利威回调接口
* @param channelId 频道id
*/
BizResponse liveStatusCallback(String channelId, String status, Long timestamp, String sign, String sessionId, String startTime, String endTime);
/**
* 回放生成成功;保利威回调接口
*/
BizResponse livebackCallback(PolyvLiveBackCallbackVo liveBackCallbackVo);
/**
* 直播转存成功;保利威回调接口
*/
BizResponse<String> liveTransferCallback(PolyvLiveBackCallbackVo liveBackCallbackVo);
/**
* 查询有直播回放的直播列表
* @param liveReviewsVo 参数
*/
BizResponse<List<LiveTitleVo>> reviewLiveList(LiveReviewsVo liveReviewsVo);
/**
* 查询有直播回放的直播间
* 分页查询
* @param replayVo 入参 pageNo;pageSize
* @return 直播间列表
*/
Page<LiveTitleVo> getHasReplayLiveList(LiveReleaseReviewReq replayVo);
/**
* 查询直播间所有回放视频
* @param liveReviewsVo 参数
*/
BizResponse<List<LiveReplayVo>> reviewsList(LiveReviewsVo liveReviewsVo);
/**
* 获取开启直播回放的直播间ids
* @param context 上下文
* @return 直播间ids
*/
List<Long> getReplayOnLiveIds(RequestContext context);
/**
* 管理端查询直播下的直播回放
* @param liveReviewsVo liveId 直播id
*/
Page<LiveReplayVo> getReplayList(LiveReviewsVo liveReviewsVo);
/**
* 直播回放上架、下架
* @param replayId 回放id
* @param operation true上架;false下架
*/
Boolean updateReplayStatus(Long replayId, Boolean operation);
/**
* 直播回放上架、下架
* @param replayId 回放id
* @param top true上架;false下架
*/
Boolean updateReplayTop(Long replayId, Boolean top);
/**
* 修改回放主播名和封面
* @param infoVo 修改信息
*/
Boolean updateReplayInfos(LiveReplayInfoVo infoVo);
}
package com.yizhi.live.application.service;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.IService;
import com.yizhi.live.application.domain.LiveReplay;
import com.yizhi.live.application.request.LiveReleaseReviewReq;
import com.yizhi.live.application.vo.LiveReplayVo;
import com.yizhi.live.application.vo.LiveReviewListVo;
import com.yizhi.util.application.domain.BizResponse;
import java.util.Date;
/**
* @Date 2020/12/9 9:47 上午
* @Author lvjianhui
**/
public interface ILiveReplayService extends IService<LiveReplay> {
/**
* 查询直播回放列表
*/
Page<LiveReplayVo> getReplayList(LiveReviewListVo liveReviewListVo);
BizResponse<LiveReplayVo> getReplay(Long replayId);
/**
* 查询上架的直播回放列表
* @param reviewReq 请求入参
* @return 回放列表
*/
Page<LiveReplayVo> getReleaseReplayList(LiveReleaseReviewReq reviewReq);
LiveReplay getByVideoPoolId(String videoPoolId);
void deleteByUpdateTime(Date date);
}
package com.yizhi.live.application.service;
import com.baomidou.mybatisplus.service.IService;
import com.yizhi.live.application.domain.LiveToken;
/**
* <p>
* 直播生成的token保存 服务类
* </p>
*
* @author fulan123
* @since 2018-04-25
*/
public interface ILiveTokenService extends IService<LiveToken> {
}
package com.yizhi.live.application.service;
import com.baomidou.mybatisplus.service.IService;
import com.yizhi.live.application.domain.ScopeAuthorization;
import java.util.List;
/**
* <p>
* 直播授权课件范围表 服务类
* </p>
*
* @author fulan123
* @since 2018-04-10
*/
public interface IScopeAuthorizationService extends IService<ScopeAuthorization> {
//删除之前记录
Boolean insertList(List<ScopeAuthorization> list);
//不删除之前记录
Boolean insertAllList(List<ScopeAuthorization> list);
List<ScopeAuthorization> listScopeAuthorization(Long liveId);
}
package com.yizhi.live.application.service.impl;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.yizhi.core.application.cache.RedisCache;
import com.yizhi.core.application.context.RequestContext;
import com.yizhi.core.application.enums.InternationalEnums;
import com.yizhi.live.application.domain.LiveActivity;
import com.yizhi.live.application.domain.LiveReplay;
import com.yizhi.live.application.mapper.LiveActivityMapper;
import com.yizhi.live.application.mapper.LiveReplayMapper;
import com.yizhi.live.application.request.LiveReleaseReviewReq;
import com.yizhi.live.application.service.ILiveActivityService;
import com.yizhi.live.application.service.ILiveReplayService;
import com.yizhi.live.application.util.PolyvUtils;
import com.yizhi.live.application.vo.LiveReplayVo;
import com.yizhi.live.application.vo.LiveReviewListVo;
import com.yizhi.live.application.vo.LiveStatisticDataVo;
import com.yizhi.live.application.vo.PageLiveVo;
import com.yizhi.util.application.domain.BizResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
/**
* @Date 2020/12/9 9:47 上午
* @Author lvjianhui
**/
@Service
public class ILiveReplayServiceImpl extends ServiceImpl<LiveReplayMapper, LiveReplay> implements ILiveReplayService {
private static final Logger logger = LoggerFactory.getLogger(ILiveReplayServiceImpl.class);
@Autowired
private ILiveActivityService liveActivityService;
@Autowired
private LiveReplayMapper replayMapper;
@Autowired
private RedisCache redisCache;
@Autowired
private LiveActivityMapper liveActivityMapper;
@Override
public void deleteByUpdateTime(Date updateTime) {
replayMapper.deleteByUpdateTime(updateTime);
}
@Override
public Page<LiveReplayVo> getReplayList(LiveReviewListVo liveReviewListVo) {
Page<LiveReplayVo> page = new Page<>(liveReviewListVo.getPageNo(),liveReviewListVo.getPageSize());
/*List<LiveReplayVo> replayVoList = new ArrayList<>();
Map<String,Integer> liveViewTypeMap = new HashMap<>();
page.setRecords(replayVoList);
List<Long> liveIdList = liveReviewListVo.getLiveIdList();
if (null == liveIdList || liveIdList.isEmpty()){
liveIdList = new ArrayList<>();
RequestContext context = liveReviewListVo.getRequestContext();
Page<PageLiveVo> liveActivityPage = liveActivityService.apiSearchPageList(context.getRelationIds(), null, context.getCompanyId(), context.getSiteId(), 1, Integer.MAX_VALUE);
if (null == liveActivityPage || null == liveActivityPage.getRecords()){
logger.warn("查询直播列表为空;accountId = {},companyId = {},siteId ={}",context.getAccountId(),context.getCompanyId(),context.getSiteId());
return page;
}
List<PageLiveVo> records = liveActivityPage.getRecords();
liveIdList = records.stream().map(PageLiveVo::getId).collect(Collectors.toList());
// 获取直播类型
for (PageLiveVo pageLiveVo : records) {
String channel = pageLiveVo.getChannel();
Integer viewType = pageLiveVo.getViewType();
liveViewTypeMap.put(channel,viewType);
}
}
logger.info("直播id listSize= {}", liveIdList.size());
List<LiveReplayVo> list = replayMapper.selectReplayList(liveIdList,liveReviewListVo.getTitle(),page);
if (null == list || list.isEmpty()){
logger.info("获取到直播回放列表size为空");
return page;
}
// 查询直播观看人数
String hKey = "live:viewer";
list.forEach(liveReplayVo -> {
//redis中获取;接口有限制
String channelId = liveReplayVo.getChannelId();
Integer viewType = liveViewTypeMap.get(channelId);
liveReplayVo.setViewType(viewType);
String viewerSum = (String) redisCache.hget(hKey,channelId);
if (!StringUtils.isEmpty(viewerSum)){
liveReplayVo.setLiveViewers(Integer.valueOf(viewerSum));
}else {
Date livePlanStartAt = liveReplayVo.getLivePlanStartAt();
List<LiveStatisticDataVo> liveStatistic = PolyvUtils.getLiveStatistic(channelId, livePlanStartAt, new Date());
if (null != liveStatistic && liveStatistic.size() > 0){
for (LiveStatisticDataVo liveStatisticDataVo : liveStatistic) {
Integer mobileUniqueViewer = liveStatisticDataVo.getMobileUniqueViewer();
Integer pcUniqueViewer = liveStatisticDataVo.getPcUniqueViewer();
Integer sum = mobileUniqueViewer + pcUniqueViewer;
liveReplayVo.setLiveViewers(sum);
redisCache.hset(hKey,channelId,String.valueOf(sum));
//过期时间60s
redisCache.expire(hKey,60);
}
}
}
});
page.setRecords(list);*/
return page;
}
@Override
public BizResponse<LiveReplayVo> getReplay(Long replayId) {
if (null == replayId){
logger.error("查询直播回放详情;直播回放id为空!");
return BizResponse.fail(InternationalEnums.INTERNATIONALIZATIONWORDCONTROLLER1.getCode());
}
LiveReplay liveReplay = replayMapper.selectById(replayId);
LiveReplayVo replayVo = new LiveReplayVo();
BeanUtils.copyProperties(liveReplay,replayVo);
Long liveId = replayVo.getLiveId();
LiveActivity activity = liveActivityMapper.selectById(liveId);
if (null != activity){
replayVo.setViewType(activity.getViewType());
}
return BizResponse.ok(replayVo);
}
@Override
public LiveReplay getByVideoPoolId(String videoPoolId) {
LiveReplay lr = new LiveReplay();
lr.setVideoPoolId(videoPoolId);
return this.baseMapper.selectOne(lr);
}
@Override
public Page<LiveReplayVo> getReleaseReplayList(LiveReleaseReviewReq reviewReq) {
// 获取上架的直播间回放
int pageNo = reviewReq.getPageNo();
int pageSize = reviewReq.getPageSize();
if (pageNo == 0 || pageSize == 0){
pageNo = 1;
pageSize = Integer.MAX_VALUE;
}
Page<LiveReplayVo> page = new Page<>(pageNo,pageSize);
List<LiveReplayVo> replayVoList = new ArrayList<>();
Map<String,Integer> liveViewTypeMap = new HashMap<>();
page.setRecords(replayVoList);
RequestContext context = reviewReq.getRequestContext();
List<Long> liveIdList = liveActivityService.getReplayOnLiveIds(context);
if (null == liveIdList || liveIdList.isEmpty()){
logger.error("查询直播回放列表,直播间获取为空;companyId = {} , siteId = {} ,accountId = {}",context.getCompanyId(),context.getSiteId(),context.getAccountId());
return page;
}
logger.info("直播id listSize= {}", liveIdList.size());
List<LiveReplayVo> list = replayMapper.selectReplayList(liveIdList,reviewReq.getTitle(),page);
if (null == list || list.isEmpty()){
logger.info("获取到直播回放列表size为空");
return page;
}
// 查询直播观看人数
String hKey = "live:viewer";
list.forEach(liveReplayVo -> {
//redis中获取;接口有限制
String channelId = liveReplayVo.getChannelId();
String viewerSum = (String) redisCache.hget(hKey,channelId);
if (!StringUtils.isEmpty(viewerSum)){
liveReplayVo.setLiveViewers(Integer.valueOf(viewerSum));
}else {
Date livePlanStartAt = liveReplayVo.getLivePlanStartAt();
List<LiveStatisticDataVo> liveStatistic = PolyvUtils.getLiveStatistic(channelId, livePlanStartAt, new Date());
if (null != liveStatistic && liveStatistic.size() > 0){
for (LiveStatisticDataVo liveStatisticDataVo : liveStatistic) {
Integer mobileUniqueViewer = liveStatisticDataVo.getMobileUniqueViewer();
Integer pcUniqueViewer = liveStatisticDataVo.getPcUniqueViewer();
Integer sum = mobileUniqueViewer + pcUniqueViewer;
liveReplayVo.setLiveViewers(sum);
redisCache.hset(hKey,channelId,String.valueOf(sum));
//过期时间60s
redisCache.expire(hKey,60);
}
}
}
});
page.setRecords(list);
return page;
}
}
package com.yizhi.live.application.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.enums.SqlLike;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yizhi.application.orm.hierarchicalauthorization.HQueryUtil;
import com.yizhi.application.orm.id.IdGenerator;
import com.yizhi.application.orm.page.PageUtil;
import com.yizhi.application.orm.util.QueryUtil;
import com.yizhi.core.application.cache.RedisCache;
import com.yizhi.core.application.context.ContextHolder;
import com.yizhi.core.application.context.RequestContext;
import com.yizhi.core.application.enums.InternationalEnums;
import com.yizhi.core.application.enums.TaskParamsEnums;
import com.yizhi.core.application.task.AbstractTaskHandler;
import com.yizhi.core.application.task.TaskExecutor;
import com.yizhi.core.application.vo.DroolsVo;
import com.yizhi.live.application.constant.LiveStatusEnum;
import com.yizhi.live.application.constant.PolyvResponseVO;
import com.yizhi.live.application.constant.PolyvUpdatePO;
import com.yizhi.live.application.constant.UtilConstants;
import com.yizhi.live.application.domain.LiveActivity;
import com.yizhi.live.application.domain.LiveReplay;
import com.yizhi.live.application.domain.ScopeAuthorization;
import com.yizhi.live.application.enums.LiveStatus;
import com.yizhi.live.application.enums.LiveStatusV2;
import com.yizhi.live.application.enums.PolyvReqEnum;
import com.yizhi.live.application.mapper.LiveActivityMapper;
import com.yizhi.live.application.mapper.LiveReplayMapper;
import com.yizhi.live.application.mapper.ScopeAuthorizationMapper;
import com.yizhi.live.application.request.LiveReleaseReviewReq;
import com.yizhi.live.application.service.ILiveActivityService;
import com.yizhi.live.application.service.ILiveReplayService;
import com.yizhi.live.application.service.IScopeAuthorizationService;
import com.yizhi.live.application.util.*;
import com.yizhi.live.application.vo.*;
import com.yizhi.util.application.clazz.ClassUtil;
import com.yizhi.util.application.date.DateUtil;
import com.yizhi.util.application.domain.BizResponse;
import com.yizhi.util.application.page.PageInfo;
import com.yizhi.util.application.page.PageParam;
import jdk.nashorn.internal.codegen.ObjectClassGenerator;
import org.apache.ibatis.session.RowBounds;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMethod;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
/**
* <p>
* 直播活动表 服务实现类
* </p>
*
* @author fulan123
* @since 2018-04-10
*/
@Service
@Transactional
public class LiveActivityServiceImpl extends ServiceImpl<LiveActivityMapper, LiveActivity> implements ILiveActivityService {
private static final Logger LOG = LoggerFactory.getLogger(LiveActivityServiceImpl.class);
@Value("${ACTIVE}")
public String active;
@Autowired
LiveUtil liveUtil;
@Autowired
ScopeAuthorizationMapper scopeAuthorizationMapper;
@Autowired
IdGenerator idGenerator;
@Autowired
private LiveActivityMapper liveActivityMapper;
@Autowired
private LiveEvenSendMessage liveEvenSendMessage;
@Autowired
private TaskExecutor taskExecutor;
@Autowired
private IScopeAuthorizationService scopeAuthorizationService;
@Autowired
RedisCache redisCache;
@Autowired
LiveReplayMapper liveReplayMapper;
@Autowired
ILiveReplayService replayService;
@Override
public String createChanel(Map<String, String> params) {
String sign = liveUtil.generateSign(params, UtilConstants.APP_SECRET);
params.put("sign", sign);
String result = liveUtil.sendHttpPost(UtilConstants.CREATE_CHANNEL_URL, params);
return result;
}
@Override
public List<LiveActivity> findWithinSevenDaysLive(Long companyId, Long siteId, Long accountId) {
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.DATE, -6);
calendar.set(Calendar.HOUR_OF_DAY,0);
calendar.set(Calendar.MINUTE,0);
calendar.set(Calendar.SECOND,0);
calendar.set(Calendar.MILLISECOND,0);
// 分级授权修改
// LOG.info("分级授权开始 ------------------------------------------");
//HQueryUtil.startHQ(LiveActivity.class);
// 基础查询条件
EntityWrapper<LiveActivity> ew = QueryUtil.condition(new LiveActivity());
ew.eq("company_id",companyId).eq("site_id",siteId)
.eq("create_by_id",accountId)
.eq("shelves",1)
.between("end_time", calendar.getTime(), Calendar.getInstance().getTime());
return this.selectList(ew);
}
@Override
public Page<PageLiveVo> searchPage(String title, String startTimeString,
String endTimeString, Long companyId, Long siteId,
List<Long> orgIds, int pageNo, int pageSize,
String expTimeString, Integer status, Integer viewType,Boolean startTimeAsc,Boolean endTimeAsc) {
LOG.info("转换前直播列表 查询参数:startTimeString={},endTimeString={},expTimeString",startTimeString,endTimeString,expTimeString);
SimpleDateFormat sim = new SimpleDateFormat("yyyy-MM-dd HH:mm");
Date startTime=null;
Date endTime=null;
Date expTime=null;
try {
if(!StringUtils.isEmpty(startTimeString)) {
startTime=sim.parse(startTimeString);
}
if(!StringUtils.isEmpty(endTimeString)) {
endTime=sim.parse(endTimeString);
}
if(!StringUtils.isEmpty(expTimeString)) {
expTime=sim.parse(expTimeString);
}
} catch (ParseException e) {
LOG.info("直播列表日期转换错误",e);
}
LOG.info("转换后直播列表 查询参数:startTime={},endTime={},expTime",startTime,endTime,expTime);
Page<PageLiveVo> page = new Page<PageLiveVo>(pageNo, pageSize);
// 分页信息
PageParam<LiveActivity> pageParam = new PageInfo<>();
pageParam.setPageNo(pageNo);
pageParam.setPageSize(pageSize);
// 基础查询条件
LiveActivity liveActivityEw = new LiveActivity();
liveActivityEw.setSiteId(siteId);
liveActivityEw.setCompanyId(companyId);
EntityWrapper<LiveActivity> ew = QueryUtil.condition(liveActivityEw);
// 分级授权修改
LOG.info("分级授权开始 ------------------------------------------");
HQueryUtil.startHQ(LiveActivity.class);
LOG.info("直播列表 查询参数:startTime={},endTime={}",startTime,endTime);
if (null != startTime && null != endTime && (endTime.getTime() > startTime.getTime())) {
ew.ge("start_time", startTime).and().le("end_time", endTime);
}else {
if(expTime!=null){
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.HOUR_OF_DAY,0);
calendar.set(Calendar.MINUTE,0);
calendar.set(Calendar.SECOND,0);
calendar.set(Calendar.MILLISECOND,0);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
LOG.info("开始时间={},结束时间={}",simpleDateFormat.format(expTime),simpleDateFormat.format(calendar.getTime()));
ew.le("start_time",expTime).ge("end_time",calendar.getTime());
}
}
if(Objects.nonNull(viewType)){
ew.eq("view_type",viewType);
}
if(Objects.nonNull(status)){
ew.eq("shelves",status);
}
if(!StringUtils.isEmpty(title)){
ew.andNew().
like("title", title, SqlLike.DEFAULT)
.or().like("channel", title, SqlLike.DEFAULT)
.or().like("keywords", title);
}
if (null == startTimeAsc && null == endTimeAsc){
//当开始和结束时间排序都不传递的时候;默认按照创建时间倒叙;
ew.orderBy("create_time",false);
}else {
if (null != startTimeAsc){
ew.orderBy("start_time",startTimeAsc);
}else if (null != endTimeAsc){
ew.orderBy("end_time",endTimeAsc);
}
}
Page<LiveActivity> retList = this.selectPage(PageUtil.vice(pageParam),ew);
// 复制结果到返回变量
BeanUtils.copyProperties(retList,page,"records");
List<LiveActivity> data = retList.getRecords();
if(CollectionUtils.isEmpty(data)){
return page;
}
// 获取全部的房间号
String channelIds = data.stream().map(p -> p.getChannel()).collect(Collectors.joining(","));
// 调用第三方获取房间状态
List<PageLiveVo> retData = new ArrayList<>();
data.stream().forEach(obj -> {
PageLiveVo vo = new PageLiveVo();
BeanUtils.copyProperties(obj,vo);
retData.add(vo);
});
page.setRecords(retData);
return page;
}
@Override
public Boolean deleteChanel(String chanel) {
Map<String, String> params = new HashMap<String, String>();
params.put("appId", UtilConstants.APP_ID);
params.put("timestamp", System.currentTimeMillis() + "");
params.put("userId", UtilConstants.APP_USER_ID);
String sign = liveUtil.generateSign(params, UtilConstants.APP_SECRET);
params.put("sign", sign);
try {
String result = liveUtil.sendHttpPost(UtilConstants.CREATE_CHANNEL_URL + "/" + chanel + "/delete", params);
JSONObject obj = JSON.parseObject(result);
String code = obj.getString("code");
if ("200".equals(code)) {
return Boolean.TRUE;
}
} catch (Exception e) {
e.printStackTrace();
}
return Boolean.FALSE;
}
@Override
public String setToken(String chanel) {
UUID uuid = UUID.randomUUID();
String token = uuid.toString();
Map<String, String> params = new HashMap<String, String>();
params.put("appId", UtilConstants.APP_ID);
params.put("token", token);
params.put("timestamp", System.currentTimeMillis() + "");
String sign = liveUtil.generateSign(params, UtilConstants.APP_SECRET);
params.put("sign", sign);
try {
String result = liveUtil.sendHttpPost(UtilConstants.CREATE_CHANNEL_URL + "/" + chanel + "/set-token", params);
JSONObject obj = JSON.parseObject(result);
String code = obj.getString("code");
if ("200".equals(code)) {
return token;
}
} catch (Exception e) {
e.printStackTrace();
}
return "error";
}
@Override
public List<PageLiveVo> apiSearchHomeList(List<Long> relationIds, String title, Long companyId, Long siteId, int pageNo, int pageSize) {
List<Long> ids = null;
if (!StringUtils.isEmpty(relationIds)) {
ids = scopeAuthorizationMapper.selectLiveIdByRelationId(relationIds);
}
Page<PageLiveVo> page = new Page<PageLiveVo>(pageNo, pageSize);
List<PageLiveVo> liveActivities = this.baseMapper.apiSearchPage(ids, title, siteId, companyId, page);
String channelIds = "";
for (PageLiveVo liveActivity : liveActivities) {
if ("".equals(channelIds)) {
channelIds = liveActivity.getChannel();
} else {
channelIds = channelIds + "," + liveActivity.getChannel();
}
}
Map<String, String> statusMap = getStringStringMap(channelIds);
for (PageLiveVo liveActivity : liveActivities) {
if (statusMap.containsKey(liveActivity.getChannel())) {
liveActivity.setStatus(statusMap.get(liveActivity.getChannel()));
}
}
return liveActivities;
}
@Override
public Page<PageLiveVo> apiSearchPageList(List<Long> relationIds, String title, Long companyId, Long siteId, int pageNo, int pageSize) {
List<Long> ids = null;
if (!StringUtils.isEmpty(relationIds)) {
Long accountId= ContextHolder.get().getAccountId();
relationIds.add(accountId);
ids = scopeAuthorizationMapper.selectLiveIdByRelationId(relationIds);
}
Page<PageLiveVo> page = new Page<PageLiveVo>(pageNo, pageSize);
List<PageLiveVo> liveActivities = this.baseMapper.apiSearchPage(ids, title, siteId, companyId, page);
liveActivities = liveActivities.stream().sorted(Comparator.comparing(PageLiveVo::getStartTime).reversed()).collect(Collectors.toList());
String channelIds = "";
for (PageLiveVo liveActivity : liveActivities) {
if ("".equals(channelIds)) {
channelIds = liveActivity.getChannel();
} else {
channelIds = channelIds + "," + liveActivity.getChannel();
}
}
Map<String, String> statusMap = getStringStringMap(channelIds);
liveActivities.parallelStream().forEach(liveActivity-> {
if (statusMap.containsKey(liveActivity.getChannel())) {
// 直播回放
LiveStatusV2 status = PolyvUtils.getLiveStatus(liveActivity.getChannel(), liveActivity.getStartTime(), liveActivity.getEndTime(), null);
liveActivity.setStatus(String.valueOf(status.getCode()));
if (LiveStatusV2.RUNNING.getCode().equals(status.getCode())){
//添加直播在学人数
String channel = liveActivity.getChannel();
liveActivity.setOnlineCount(0);
try {
List<LiveOnlineCountVo> channelOnlineCountRealTime = getChannelOnlineCountRealTime(channel);
if (null != channelOnlineCountRealTime && channelOnlineCountRealTime.size() > 0){
LiveOnlineCountVo liveOnlineCountVo = channelOnlineCountRealTime.get(0);
Integer onlineCountVoCount = liveOnlineCountVo.getCount();
liveActivity.setOnlineCount(onlineCountVoCount);
}
} catch (JsonProcessingException e) {
LOG.error("查询直播在学人数异常: channel = {} ,companyId ={} ,siteId = {}",channel,companyId,siteId,e);
}
}
}
});
page.setRecords(liveActivities);
Integer count = this.baseMapper.apiSearchPageCount(ids, title, siteId, companyId);
page.setTotal(count);
return page;
}
@Override
public Boolean saveLive(LiveActivityResultVO liveActivityResultVO) {
LOG.info("后台直播创建,携带活动那个参数{},可见范围信息{}",liveActivityResultVO.getLiveActivity(),liveActivityResultVO.getScopeAuthorizations());
if (liveActivityResultVO.getLiveActivity() == null) {
LOG.info("LiveActivity直播活动表为空");
return false;
}
LiveActivityVO liveActivity = liveActivityResultVO.getLiveActivity();
liveActivity.setId(idGenerator.generate());
liveActivity.setShelves(2);
//System.out.println(liveActivity.toString());
Map<String, String> params = new HashMap<String, String>();
params.put("appId", UtilConstants.APP_ID);
params.put("timestamp", System.currentTimeMillis() + "");
params.put("userId", UtilConstants.APP_USER_ID);
params.put("channelPasswd", liveActivity.getPassword());
params.put("name", liveActivity.getTitle());
String scene = liveActivity.getScene();
if("ppt".equals(scene) || "topclass".equals(scene)){
}else {
scene = "alone";
}
params.put("scene", scene);
LOG.info("进入方法之前:参数params{},第二个参数{}",params,UtilConstants.CREATE_CHANNEL_URL);
String result = execPolyvApi(params,UtilConstants.CREATE_CHANNEL_URL);
LOG.info("进入方法之后:{}",result);
Map<String, Object> maps = new HashMap<String, Object>();
try {
maps = JsonUtil.parseJSON2Map(result);
if (maps.containsKey("data")) {
LOG.info("获取保利威直播频道号的结果={},请求参数={}",JSON.toJSONString(maps),JSON.toJSONString(params));
JSONObject jsonObject = (JSONObject) maps.get("data");
if (jsonObject.containsKey("channelId")) {
String channelId = jsonObject.get("channelId").toString();
liveActivity.setChannel(channelId);
//进行 自定义授权的配置 channelSetting(设置成授权观看)
String secretKey = channelSetting(jsonObject.get("channelId").toString());
if (StringUtils.isEmpty(secretKey)) {
LOG.info("secretKey 为空:{}",secretKey);
return Boolean.FALSE;
}
liveActivity.setSecretKey(secretKey);
Date startTime = liveActivity.getStartTime();
try {
Map<String, String> params1 = new HashMap<String, String>();
params1.put("appId",UtilConstants.APP_ID);
params1.put("timestamp", System.currentTimeMillis() + "");
// 之前未设置倒计时直播提示和直播时间的频道号,在开启倒计时开关时,必须提交countTips和startTime
//params1.put("countEnabled", "N");
params1.put("startTime", DateUtil.toSeconds(startTime));
String result1 = execPolyvApi(params1, String.format(UtilConstants.CHANNEL_STARTDATE_UPDATE,channelId));
Map<String, String> params2 = new HashMap<>();
params2.put("channelId", channelId);
//String body = "{\"authSettings\": [ {\"rank\":1,\"enabled\":\"Y\",\"authType\":\"custom\"} ] }";
if(liveActivity.getViewType() == 0){
String body = "{\"authSettings\":[{\"rank\":1,\"enabled\":\"N\"}]}";
String result2 = LiveUtilPostUrlParam.sendPost(UtilConstants.LIVE_AUTH_UPDATE_URL,body,params2);
}
} catch (Exception e) {
LOG.info("新增直播 更新时间异常={}",e);
}
}
}
} catch (Exception e) {
LOG.info("插入更新时间 异常:{}",e);
return Boolean.FALSE;
}
LiveActivity lt = new LiveActivity();
BeanUtils.copyProperties(liveActivity,lt);
if(setOptions(lt, lt,true)){
LOG.info("设在参数异常");
return Boolean.FALSE;
}
if (1 == this.baseMapper.insert(lt)) {
if (1 == liveActivity.getScope()) {
if (liveActivityResultVO.getScopeAuthorizations().size() > 0) {
for (ScopeAuthorizationVO scopeAuthorization1 : liveActivityResultVO.getScopeAuthorizations()) {
scopeAuthorization1.setLiveId(liveActivity.getId());
scopeAuthorization1.setId(idGenerator.generate());
scopeAuthorization1.setSiteId(liveActivity.getSiteId());
}
scopeAuthorizationMapper.insertListVO(liveActivityResultVO.getScopeAuthorizations());
}
}
LOG.info("直播是否设置了提醒:" + liveActivity.getEnableRemind());
if (liveActivity != null && liveActivity.getEnableRemind() == 1 && liveActivityResultVO.getMessageRemindVo() != null) {
RequestContext context = ContextHolder.get();
try {
LOG.info("直播是否设置了提醒Vo:" + liveActivityResultVO.getMessageRemindVo().toString());
taskExecutor.asynExecute(new AbstractTaskHandler() {
@Override
public void handle() {
liveEvenSendMessage.systemSendMessage(lt, liveActivityResultVO.getMessageRemindVo(), context);
}
});
} catch (Exception e) {
LOG.info("直播发消息异常:{}",e);
}
}
return Boolean.TRUE;
}
return Boolean.FALSE;
}
/**
* 调用保利威接口
* @param params
* @return
*/
private String execPolyvApi(Map<String, String> params,String apiUrl) {
String sign = getSign(params);
params.put("sign", sign);
//调用地三方接口创建直播 获得直播频道号
String result = liveUtil.sendHttpPost(apiUrl, params);
LOG.info("保利威返回 {};URL IS {}",result,apiUrl,params);
System.out.println(result);
return result;
}
@Override
@Transactional
public Boolean updateLive(LiveActivityResultVO liveActivityResultVO) {
if (liveActivityResultVO.getLiveActivity() == null) {
return false;
}
LiveActivityVO liveActivity = liveActivityResultVO.getLiveActivity();
LiveActivity updateLiveActivity = this.baseMapper.selectById(liveActivity.getId());
if(updateLiveActivity == null){
return Boolean.FALSE;
}
if (liveActivity!=null){
updateLiveActivity.setEnableTask(liveActivity.getEnableTask());
}
updateLiveActivity.setTitle(liveActivity.getTitle());//直播主题
updateLiveActivity.setLogoImage(liveActivity.getLogoImage());
updateLiveActivity.setPassword(liveActivity.getPassword());//直播密码
updateLiveActivity.setAnchor(liveActivity.getAnchor()); // 主播名称
updateLiveActivity.setStartTime(liveActivity.getStartTime()); //直播开始时间
updateLiveActivity.setEndTime(liveActivity.getEndTime());//直播结束时间
updateLiveActivity.setViewType(liveActivity.getViewType());//直播授权类型
updateLiveActivity.setDescription(liveActivity.getDescription());
updateLiveActivity.setScope(liveActivity.getScope());
updateLiveActivity.setEnableRemind(liveActivity.getEnableRemind());
updateLiveActivity.setEnableTask(liveActivity.getEnableTask());
updateLiveActivity.setKeywords(liveActivity.getKeywords());
updateLiveActivity.setReplayStatus(liveActivity.getReplayStatus());
Integer updateCount = this.baseMapper.updateById(updateLiveActivity);
if (updateCount == null || updateCount == 0 ) {
return Boolean.TRUE;
}
Integer scope = liveActivity.getScope();
if(scope != null ){
if (1 == updateLiveActivity.getScope() && liveActivityResultVO.getScopeAuthorizations().size() > 0) {
ScopeAuthorization scopeAuthorization = new ScopeAuthorization();
scopeAuthorization.setLiveId(updateLiveActivity.getId());
EntityWrapper<ScopeAuthorization> wrapper = new EntityWrapper<>(scopeAuthorization);
scopeAuthorizationMapper.delete(wrapper);
for (ScopeAuthorizationVO scopeAuthorization1 : liveActivityResultVO.getScopeAuthorizations()) {
scopeAuthorization1.setLiveId(updateLiveActivity.getId());
scopeAuthorization1.setSiteId(updateLiveActivity.getSiteId());
scopeAuthorization1.setId(idGenerator.generate());
}
return scopeAuthorizationMapper.insertListVO(liveActivityResultVO.getScopeAuthorizations());
}
}
LiveActivity activity = this.baseMapper.selectById(liveActivity.getId());
if (activity != null) {
RequestContext context = ContextHolder.get();
try {
taskExecutor.asynExecute(new AbstractTaskHandler() {
@Override
public void handle() {
liveEvenSendMessage.systemSendMessage(activity, liveActivityResultVO.getMessageRemindVo(), context);
}
});
} catch (Exception e) {
e.printStackTrace();
LOG.info("直播发消息异常");
}
}
// TODO 先修改数据库,再修改第三方,第三方修改失败需要回滚数据库数据
// 修改第三方信息
PolyvUpdatePO po = new PolyvUpdatePO();
po.setName(liveActivity.getTitle());
po.setChannelPasswd(liveActivity.getPassword());
po.setPublisher(liveActivity.getAnchor());
po.setDesc(liveActivity.getDescription());
po.setStartTime(liveActivity.getStartTime().getTime());
PolyvUtils.updateChannelParams(updateLiveActivity.getChannel(),po,true,updateLiveActivity.getSecretKey(),getRedirectUrl());
return Boolean.TRUE;
}
public static void main(String[] args) {
//String secretKey = channelSetting(jsonObject.get("channelId").toString());
Map<String, String> params2 = new HashMap<>();
params2.put("channelId", "1077706");
params2.put("customUri", UtilConstants.UAT_LIVE_CUSTOM_URI);
//LiveUtilPostUrlNotParam.sendPost()
String result2 = LiveUtilPostUrlParam.sendPost(String.format(UtilConstants.LIVE_CHANNEL_SETTING_URL,UtilConstants.APP_USER_ID),null,params2);
System.out.println(result2);
}
private boolean setOptions(final LiveActivity liveActivity, LiveActivity updateLiveActivity, boolean addFlg) {
String title = liveActivity.getTitle();
if(title != null && !org.apache.commons.lang3.StringUtils.equals(title,updateLiveActivity.getTitle())){
Map<String, String> params = new HashMap<String, String>();
params.put("appId", UtilConstants.APP_ID);
params.put("timestamp", System.currentTimeMillis() + "");
params.put("name", title);
String result = execPolyvApi(params, String.format(UtilConstants.CHANNEL_TITLE_NAME_UPDATE,
updateLiveActivity.getChannel()));
LOG.info("直播频道更新名称结果result={}",result);
if(org.apache.commons.lang3.StringUtils.isNotBlank(result) && org.apache.commons.lang3.StringUtils.indexOf(result,"success")>=0){
updateLiveActivity.setTitle(title);//直播主题
}else {
LOG.info("直播频道更新名称 失败");
return true;
}
}
String pwd = liveActivity.getPassword();
if(pwd != null && !org.apache.commons.lang3.StringUtils.equals(pwd,updateLiveActivity.getPassword())){
Map<String, String> params = new HashMap<String, String>();
params.put("channelId", updateLiveActivity.getChannel());
params.put("appId",UtilConstants.APP_ID);
params.put("timestamp", System.currentTimeMillis() + "");
params.put("passwd", pwd);
String result = execPolyvApi(params, String.format(UtilConstants.CHANNEL_PASSWD_UPDATE,UtilConstants.APP_USER_ID));
LOG.info("直播频道更新名称结果result={}",result);
if(org.apache.commons.lang3.StringUtils.isNotBlank(result) && org.apache.commons.lang3.StringUtils.indexOf(result,"success")>=0){
updateLiveActivity.setPassword(pwd);//直播密码
}else {
LOG.info("直播频道更新密码 失败");
return true;
}
}
String logo = liveActivity.getLogoImage();
if(addFlg || (logo != null && !org.apache.commons.lang3.StringUtils.equals(logo,updateLiveActivity.getLogoImage()))){
updateLiveActivity.setLogoImage(logo);// 直播logo
}
String anchor = liveActivity.getAnchor();
if(addFlg || (anchor != null && !org.apache.commons.lang3.StringUtils.equals(anchor,updateLiveActivity.getAnchor()))){
Map<String, String> params = new HashMap<String, String>();
params.put("channelId", updateLiveActivity.getChannel());
params.put("appId",UtilConstants.APP_ID);
params.put("timestamp", System.currentTimeMillis() + "");
params.put("publisher", anchor);//主持人姓名,不超过20个字符
String result = execPolyvApi(params, String.format(UtilConstants.CHANNEL_ANCHOR_UPDATE,UtilConstants.APP_USER_ID));
LOG.info("直播频道更新主播名字结果result={}",result);
if(org.apache.commons.lang3.StringUtils.isNotBlank(result) && org.apache.commons.lang3.StringUtils.indexOf(result,"success")>=0){
updateLiveActivity.setAnchor(anchor); // 主播名称
}else {
LOG.info("直播频道更新主持人姓名 失败");
return true;
}
}
Date startTime = liveActivity.getStartTime();
Date dbStartTime = updateLiveActivity.getStartTime();
dbStartTime = dbStartTime==null?(new Date()):dbStartTime;
Date endTime = liveActivity.getEndTime();
if(addFlg || (startTime != null && startTime.compareTo(dbStartTime)!=0)){
Map<String, String> params = new HashMap<String, String>();
params.put("appId",UtilConstants.APP_ID);
params.put("timestamp", System.currentTimeMillis() + "");
// 之前未设置倒计时直播提示和直播时间的频道号,在开启倒计时开关时,必须提交countTips和startTime
//params.put("countEnabled", "N");
params.put("startTime", DateUtil.toSeconds(startTime));
String result = execPolyvApi(params, String.format(UtilConstants.CHANNEL_STARTDATE_UPDATE,updateLiveActivity.getChannel()));
LOG.info("直播频道更新开始时间结果result={}",result);
if(org.apache.commons.lang3.StringUtils.isNotBlank(result) && org.apache.commons.lang3.StringUtils.indexOf(result,"success")>=0){
updateLiveActivity.setStartTime(startTime); //直播开始时间
}else {
LOG.info("直播频道更新开始时间 失败");
return true;
}
}
if(addFlg || endTime != null){
updateLiveActivity.setEndTime(endTime);//直播结束时间
}
String desc = liveActivity.getDescription();
if(addFlg || (desc != null && !org.apache.commons.lang3.StringUtils.equals(desc,updateLiveActivity.getDescription()))){
Map<String, String> params = new HashMap<String, String>();
params.put("appId",UtilConstants.APP_ID);
params.put("timestamp", System.currentTimeMillis() + "");
params.put("content", desc);
params.put("menuType", "desc");
String result = execPolyvApi(params, String.format(UtilConstants.CHANNEL_DESC_UPDATE,
UtilConstants.APP_USER_ID,updateLiveActivity.getChannel()));
LOG.info("直播频道更新说明信息结果result={}",result);
if(org.apache.commons.lang3.StringUtils.isNotBlank(result) && org.apache.commons.lang3.StringUtils.indexOf(result,"success")>=0){
updateLiveActivity.setDescription(desc);//直播介绍
}else {
LOG.info("直播频道更新说明信息 失败");
return true;
}
}
Integer scope = liveActivity.getScope();
if(scope != null){
updateLiveActivity.setScope(scope);
}
if (liveActivity.getEnableRemind()!=null){
updateLiveActivity.setEnableRemind(liveActivity.getEnableRemind());
}
if (!StringUtils.isEmpty(liveActivity.getKeywords())) {
updateLiveActivity.setKeywords(liveActivity.getKeywords());
//return true;
}
return false;
}
@Override
public Page<PageLiveVo> portalList2(String title, Date startTime, Date endTime,
Long companyId, Long siteId,
List<Long> orgId, int pageNo, int pageSize) {
Page<PageLiveVo> page = new Page<PageLiveVo>(pageNo, pageSize);
// 分级授权修改
HQueryUtil.startHQ(LiveActivity.class);
List<PageLiveVo> pageLiveVos = this.baseMapper.portalList2(title, startTime, endTime, companyId, siteId, orgId,page);
page.setRecords(pageLiveVos);
return page;
}
@Override
public List<PageLiveVo> portalList(String title, Date startTime, Date endTime,
Long companyId, Long siteId,
List<Long> orgId, int pageNo, int pageSize) {
Page<PageLiveVo> page = new Page<PageLiveVo>(pageNo, pageSize);
// 分级授权修改
HQueryUtil.startHQ(LiveActivity.class);
return this.baseMapper.portalList(title, startTime, endTime, companyId, siteId, orgId, new RowBounds(page.getOffset(), page.getLimit()));
}
private Map<String, String> getStringStringMap(String channelIds) {
Map<String, String> statusMap = new HashMap<String, String>();
try {
Map<String, String> params = new HashMap<String, String>();
params.put("appId", UtilConstants.APP_ID);
params.put("timestamp", System.currentTimeMillis() + "");
params.put("channelIds", channelIds);
String sign = liveUtil.generateSign(params, UtilConstants.APP_SECRET);
params.put("sign", sign);
String result = liveUtil.sendHttpPost(UtilConstants.LIVE_STATUS_URL, params);
if (StringUtils.isEmpty(result)){
LOG.warn("获取频道直播状态异常;channelIds ={}",channelIds);
return statusMap;
}
JSONObject obj = JSON.parseObject(result);
if ("error".equals(obj.get("status").toString())) {
return statusMap;
}
JSONArray list = (JSONArray) obj.get("data");
for (int i = 0; i < list.size(); i++) {
JSONObject job = list.getJSONObject(i); // 遍历 jsonarray 数组,把每一个对象转成 json 对象
statusMap.put(job.get("channelId").toString(), job.get("status").toString());
}
} catch (Exception e) {
LOG.error("获取直播频道状态失败", e);
}
return statusMap;
}
public String getRedirectUrl(){
if ("dev".equals(active)) {
return UtilConstants.DEV_LIVE_CUSTOM_URI;
} else if ("sit".equals(active)) {
return UtilConstants.SIT_LIVE_CUSTOM_URI;
} else if ("uat".equals(active)) {
return UtilConstants.UAT_LIVE_CUSTOM_URI;
} else {
return UtilConstants.PRO_LIVE_CUSTOM_URI;
}
}
private String channelSetting(String channelId) {
Map<String, String> map = new HashMap<>();
map.put("appId", UtilConstants.APP_ID);
map.put("timestamp", System.currentTimeMillis() + "");
if ("dev".equals(active)) {
map.put("customUri", UtilConstants.DEV_LIVE_CUSTOM_URI);
} else if ("sit".equals(active)) {
map.put("customUri", UtilConstants.SIT_LIVE_CUSTOM_URI);
} else if ("uat".equals(active)) {
map.put("customUri", UtilConstants.UAT_LIVE_CUSTOM_URI);
} else {
map.put("customUri", UtilConstants.PRO_LIVE_CUSTOM_URI);
}
map.put("channelId", channelId);
String sign = getSign(map);
map.put("sign", sign);
StringBuilder url = new StringBuilder();
url.append(UtilConstants.LIVE_CHANNELSETTING_URL);
url.append(UtilConstants.APP_USER_ID);
url.append("/oauth-custom");
String result = liveUtil.sendHttpPost(url.toString(), map);
JSONObject obj = JSON.parseObject(result);
LOG.info("channelSetting:" + result);
if ("200".equals(obj.get("code").toString())) {
JSONArray list = JSON.parseArray(obj.get("data").toString());
JSONObject data = list.getJSONObject(0);
return data.get("secretKey").toString();
}
return null;
}
private String getSign(Map<String, String> paramMap) {
String appSecret = UtilConstants.APP_SECRET;
// long ts = System.currentTimeMillis();
// 创建参数表 (创建接口需要传递的所有参数表)
// Map<String, String> paramMap = new HashMap<String, String>();
// paramMap.put("appId", appId);
// paramMap.put("customUri", UtilConstants.LIVE_CUSTOM_URI);
// paramMap.put("timestamp", Long.toString(ts));
//对参数名进行字典排序
String[] keyArray = paramMap.keySet().toArray(new String[0]);
Arrays.sort(keyArray);
//拼接有序的参数串
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(appSecret);
for (String key : keyArray) {
stringBuilder.append(key).append(paramMap.get(key));
}
stringBuilder.append(appSecret);
String signSource = stringBuilder.toString();
String sign = org.apache.commons.codec.digest.DigestUtils.md5Hex(signSource).toUpperCase();
return sign;
}
@Override
public VisibleRangeExport vsibleRangeExport(Long liveId) {
// TODO Auto-generated method stub
VisibleRangeExport visibleRangeExport=new VisibleRangeExport();
List<Long> accountIds=new ArrayList<Long>();
List<Long> orgIds=new ArrayList<Long>();
LiveActivity liveActivity=liveActivityMapper.selectById(liveId);
if(liveActivity!=null) {
visibleRangeExport.setBizId(liveActivity.getId());
visibleRangeExport.setBizName(liveActivity.getTitle());
}
List<ScopeAuthorization> listStudent=scopeAuthorizationService.listScopeAuthorization(liveId);
if(listStudent!=null&&listStudent.size()>0) {
ScopeAuthorization scopeAuthorization=null;
for (int i = 0; i < listStudent.size(); i++) {
scopeAuthorization=listStudent.get(i);
if(scopeAuthorization!=null&&scopeAuthorization.getType()!=null) {
if(scopeAuthorization.getType()==2) { //用户
accountIds.add(scopeAuthorization.getAccountId());
}
if(scopeAuthorization.getType()==1) { //部门
orgIds.add(scopeAuthorization.getAccountId());
}
}
visibleRangeExport.setAccountIds(accountIds);
visibleRangeExport.setOrgIds(orgIds);
}
}
LOG.info("直播ID:{},直播名字:{}",visibleRangeExport.getBizId(),visibleRangeExport.getBizName());
LOG.info("账号Id:{}",visibleRangeExport.getAccountIds());
LOG.info("部门Id:{}",visibleRangeExport.getOrgIds());
return visibleRangeExport;
}
@Override
public Boolean judgeScope(List<Long> relationId, Long liveId) {
//可见范围 0 全平台可见 1 为可选范围
Integer scope = null;
//里面储存了 accountId or orgId
Long accountId = 0L;
if (null != liveId) {
LiveActivity liveActivity = liveActivityMapper.selectById(liveId);
scope = liveActivity.getScope();
if (scope == 0) {
return true;
} else {
if (null != relationId) {
List<ScopeAuthorization> scopeAuthorizationList = scopeAuthorizationService.listScopeAuthorization(liveId);
if (scopeAuthorizationList.size() > 0 && null != scopeAuthorizationList) {
for (ScopeAuthorization scopeAuthorization : scopeAuthorizationList) {
accountId = scopeAuthorization.getAccountId();
if (relationId.contains(accountId)) {
return true;
}
}
}
}
}
}
return false;
}
@Override
public Page<PageLiveVo> getPageLiveVoList(Long siteId, Integer pageNo, Integer pageSize) {
Page<PageLiveVo> page = new Page<PageLiveVo>(pageNo, pageSize);
Integer count = this.baseMapper.getPageLiveVoListCount(null, siteId, null);
page.setTotal(count);
List<PageLiveVo> liveVos = this.baseMapper.getPageLiveVoList(null, siteId, null, new RowBounds(page.getOffset(), page.getLimit()));
page.setRecords(liveVos);
return page;
}
@Override
public Page<LiveActivity> getPageLiveVoListNotIds(List<Long> ids, Long siteId, Integer pageNo, Integer pageSize) {
// TODO Auto-generated method stub
Page<LiveActivity> page=new Page<LiveActivity>(pageNo,pageSize);
LiveActivity liveActivity=new LiveActivity();
liveActivity.setSiteId(siteId);
liveActivity.setShelves(1);
EntityWrapper<LiveActivity> wrapper=new EntityWrapper<LiveActivity>(liveActivity);
if(!CollectionUtils.isEmpty(ids)) {
wrapper.notIn("id", ids);
}
wrapper.orderBy("create_time", false);
HQueryUtil.startHQ(LiveActivity.class);
return this.selectPage(page, wrapper);
}
@Override
public Page<LiveActivity> LiveActivityByIds(List<Long> listIds, Integer pageNo, Integer pageSize) {
// TODO Auto-generated method stub
Page<LiveActivity> page=new Page<LiveActivity>(pageNo,pageSize);
LiveActivity liveActivity=new LiveActivity();
liveActivity.setShelves(1);
EntityWrapper<LiveActivity> wrapper=new EntityWrapper<LiveActivity>(liveActivity);
wrapper.orderBy("create_time", false);
if(!CollectionUtils.isEmpty(listIds)) {
wrapper.in("id", listIds);
}
return this.selectPage(page, wrapper);
}
@Override
public Integer getLiveStatus(String channelId) {
LiveActivity liveActivity = new LiveActivity();
liveActivity.setChannel(channelId);
LiveActivity live = liveActivityMapper.selectOne(liveActivity);
Integer liveStatus = live.getStatus();
// 获取直播状态
LiveStatusV2 liveStatusEnum = PolyvUtils.getLiveStatus(channelId, live.getStartTime(), live.getEndTime(), liveStatus);
return liveStatusEnum.getCode();
}
@Override
public List<PageLiveVo> queryLiveListByRelationIds(List<Long> relationIds, Integer pageNo, Integer pageSize) {
Page<PageLiveVo> page = new Page<PageLiveVo>(pageNo, pageSize);
RequestContext context = ContextHolder.get();
Set<PageLiveVo> set = liveActivityMapper.queryLiveListByRelationIds(relationIds,context.getSiteId(),new RowBounds(page.getOffset(),page.getLimit()));
List<PageLiveVo> list = new ArrayList<>();
list.addAll(set);
return list;
}
@Override
public List<Map<String, Object>> getServerByCompanyIdAndIds(Long companyId, List<Long> ids) {
// TODO Auto-generated method stub
List<Map<String, Object>> listMap=null;
//查询
LiveActivity live=new LiveActivity();
live.setCompanyId(companyId);
EntityWrapper<LiveActivity> wrapper=new EntityWrapper<LiveActivity>(live);
if(!CollectionUtils.isEmpty(ids)) {
wrapper.in("id", ids);
}
List<LiveActivity> listLive=this.selectList(wrapper);
//循环组装到输出对象
Map<String, Object> map=null;
if(!CollectionUtils.isEmpty(listLive)) {
listMap=new ArrayList<Map<String, Object>>();
for (LiveActivity c:listLive) {
map=new HashMap<String, Object>();
map.put("catalog", 3);
map.put("id", c.getId());
map.put("name", c.getTitle());
map.put("logo_url", c.getLogoImage());
listMap.add(map);
}
}
return listMap;
}
@Override
public Page<PageLiveVo> pcSearchPageList(List<Long> relationIds, String title, Long companyId, Long siteId, int pageNo, int pageSize) {
Set<Long> ids = null;
List<Long> idList = new ArrayList<>();
if (!StringUtils.isEmpty(relationIds)) {
ids = scopeAuthorizationMapper.selectLiveId(relationIds,siteId);//去重
for (Long a:ids) {
idList.add(a);
}
}
Page<PageLiveVo> page = new Page<PageLiveVo>(pageNo, pageSize);
List<PageLiveVo> liveActivities = this.baseMapper.apiSearchPage(idList, title, siteId, companyId, page);
String channelIds = "";
if(!CollectionUtils.isEmpty(liveActivities)){
for (PageLiveVo liveActivity : liveActivities) {
if ("".equals(channelIds)) {
channelIds = liveActivity.getChannel();
} else {
channelIds = channelIds + "," + liveActivity.getChannel();
}
}
Map<String, String> statusMap = getStringStringMap(channelIds);
liveActivities.parallelStream().forEach(liveActivity-> {
if (statusMap.containsKey(liveActivity.getChannel())) {
// 直播回放
LiveStatusV2 status = PolyvUtils.getLiveStatus(liveActivity.getChannel(), liveActivity.getStartTime(), liveActivity.getEndTime(), null);
liveActivity.setStatus(String.valueOf(status.getCode()));
if (LiveStatusV2.RUNNING.getCode().equals(status.getCode())){
//添加直播在学人数
String channel = liveActivity.getChannel();
liveActivity.setOnlineCount(0);
try {
List<LiveOnlineCountVo> channelOnlineCountRealTime = getChannelOnlineCountRealTime(channel);
if (null != channelOnlineCountRealTime && channelOnlineCountRealTime.size() > 0){
LiveOnlineCountVo liveOnlineCountVo = channelOnlineCountRealTime.get(0);
Integer onlineCountVoCount = liveOnlineCountVo.getCount();
liveActivity.setOnlineCount(onlineCountVoCount);
}
} catch (JsonProcessingException e) {
LOG.error("查询直播在学人数异常: channel = {} ,companyId ={} ,siteId = {}",channel,companyId,siteId,e);
}
}
}
});
}
page.setRecords(liveActivities);
Integer count = this.baseMapper.apiSearchPageCount(idList, title, siteId, companyId);
page.setTotal(count);
return page;
}
@Override
public Page<PageLiveVo> getPageToCalendar(Date date, Page<PageLiveVo> page) {
RequestContext context = ContextHolder.get();
List<Long> ids = liveActivityMapper.getIdsByDate(date, context.getSiteId());
if (CollectionUtils.isEmpty(ids)) {
return page;
}
//根据可见范围获取直播ids
List<Long> trIds = new ArrayList<>();
if (!CollectionUtils.isEmpty(context.getRelationIds())){
trIds = scopeAuthorizationMapper.getUsefulIds(ids, context.getRelationIds(), context.getSiteId());
}
List<PageLiveVo> liveActivities = liveActivityMapper.getPageToCalendar(null, trIds, date, context.getSiteId(), page);
if (!CollectionUtils.isEmpty(liveActivities)){
liveActivities = buildLiveStatus(liveActivities);
}
page.setRecords(liveActivities);
//page.setTotal(liveActivityMapper.getPageToCalendarNum(null, trIds, date, context.getSiteId()));
return page;
}
/**
* 获取直播状态
* @param liveActivities
* @return
*/
public List<PageLiveVo> buildLiveStatus(List<PageLiveVo> liveActivities){
String channelIds = "";
for (PageLiveVo liveActivity : liveActivities) {
if ("".equals(channelIds)) {
channelIds = liveActivity.getChannel();
} else {
channelIds = channelIds + "," + liveActivity.getChannel();
}
}
Map<String, String> statusMap = getStringStringMap(channelIds);
for (PageLiveVo liveActivity : liveActivities) {
if (statusMap.containsKey(liveActivity.getChannel())) {
LiveStatusV2 status = PolyvUtils.getLiveStatus(liveActivity.getChannel(), liveActivity.getStartTime(), liveActivity.getEndTime(), null);
liveActivity.setStatus(String.valueOf(status.getCode()));
}
}
return liveActivities;
}
@Override
public Page<DroolsVo> getPageByDrools(String field, String value, Page<DroolsVo> page) {
if (org.apache.commons.lang3.StringUtils.isBlank(field)) {
LOG.info("列名不能为空!");
return page;
}
if (field.equalsIgnoreCase(TaskParamsEnums.NAME.getCode())) {
field = "title";
return getPage(field, value, page);
} else if (field.equalsIgnoreCase(TaskParamsEnums.KEYWORD.getCode())) {
field = "keywords";
return getPage(field, value, page);
} else if (field.equalsIgnoreCase(TaskParamsEnums.CODE.getCode())) {
field = "channel";
return getPage(field, value, page);
} else if (field.equalsIgnoreCase(TaskParamsEnums.ANCHOR_NAME.getCode())) {
field = "anchor";
return getPage(field, value, page);
}
return page;
}
@Override
public List<LiveOnlineCountVo> getChannelOnlineCountRealTime(String channelIds) throws JsonProcessingException {
List<LiveOnlineCountVo> countVoList = new ArrayList<>();
if (StringUtils.isEmpty(channelIds)){
LOG.warn("查询直播实时在线人数;参数频道id为空");
return countVoList;
}
//存储获取到的频道-频道在学人数的map
Map<String,LiveOnlineCountVo> map = new HashMap<>();
//缓存数据到redis 接口请求有限制
String hKey = "live_online_";
List<String> noCacheChannelIds = new ArrayList<>();
getRedisCache(channelIds, map, hKey, noCacheChannelIds);
if (noCacheChannelIds.isEmpty()){
//全部命中缓存
map.forEach((k,v) -> {
countVoList.add(v);
});
LOG.info("全部命中缓存");
return countVoList;
}
//部门命中;调用第三方查询
String noCacheChannelIdsStr = noCacheChannelIds.stream().collect(Collectors.joining(","));
//组装参数
String result = getOnlineResult(noCacheChannelIdsStr);
LOG.info("批量获取频道实时在线人数;返回结果: {}",result);
//解析返回结果
if (StringUtils.isEmpty(result)){
LOG.error("批量获取频道实时在线人数相应值为空!");
return countVoList;
}
ObjectMapper mapper = new ObjectMapper();
PolyvResponseVo<List<LiveOnlineCountVo>> responseVo = mapper.readValue(result, new TypeReference<PolyvResponseVo<List<LiveOnlineCountVo>>>() {});
int code = responseVo.getCode();
List<LiveOnlineCountVo> data = responseVo.getData();
if (200 != code || null == data || data.isEmpty()){
LOG.error("批量获取频道实时在线人数失败;结果: {}",result);
return countVoList;
}
data.forEach(liveOnlineCountVo -> {
String channelId = liveOnlineCountVo.getChannelId();
Integer onlineCount = liveOnlineCountVo.getCount();
if (map.containsKey(channelId)){
LiveOnlineCountVo oldVo = map.get(channelId);
Integer oldCount = oldVo.getCount();
if (null != oldCount && oldCount.compareTo(onlineCount) < 0){
map.put(channelId,liveOnlineCountVo);
redisCache.set(hKey+channelId,JSONObject.toJSONString(liveOnlineCountVo),20);
//LOG.info("放入缓存");
}
}else {
map.put(channelId,liveOnlineCountVo);
//放入缓存
redisCache.set(hKey+channelId,JSONObject.toJSONString(liveOnlineCountVo),20);
//LOG.info("放入缓存");
}
});
map.forEach((k,v) -> {
countVoList.add(v);
});
return countVoList;
}
/**
* 获取在线人数请求
* @param channelIds 频道id;多个用逗号隔开
* @return 返回结果
*/
private String getOnlineResult(String channelIds) {
Map<String, String> params = new HashMap<String, String>();
params.put(PolyvReqEnum.APP_ID.getName(), UtilConstants.APP_ID);
params.put(PolyvReqEnum.TIMESTAMP.getName(), System.currentTimeMillis() + "");
params.put(PolyvReqEnum.CHANNEL_IDS.getName(), channelIds);
String sign = liveUtil.generateSign(params, UtilConstants.APP_SECRET);
params.put(PolyvReqEnum.SIGN.getName(), sign);
LOG.info("批量获取频道实时在线人数;请求入参: {}",params);
return liveUtil.sendHttpPost(UtilConstants.LIVE_STATISTICS_BATCH_COUNT, params);
}
/**
* 获取缓存中的频道在学人数
* @param channelIds 通道ids
* @param map 频道-LiveOnlineCountVo
* @param hKey redis key
* @param noCacheChannelIds 未命中缓存的频道id;多个用逗号隔开
*/
private void getRedisCache(String channelIds, Map<String, LiveOnlineCountVo> map, String hKey, List<String> noCacheChannelIds) {
String[] split = channelIds.split(",");
for (String channel : split) {
if (StringUtils.isEmpty(channel)){
continue;
}
String strValue = (String) redisCache.get(hKey + channel);
if (StringUtils.isEmpty(strValue)){
noCacheChannelIds.add(channel);
continue;
}
LiveOnlineCountVo liveOnlineCountVo = JSONObject.parseObject(strValue, LiveOnlineCountVo.class);
if (null != liveOnlineCountVo){
map.put(channel,liveOnlineCountVo);
continue;
}
noCacheChannelIds.add(channel);
}
}
@Override
public BizResponse liveStatusCallback(String channelId, String status, Long timestamp, String sign, String sessionId, String startTime, String endTime) {
String secret = UtilConstants.APP_SECRET;
//校验验签sign
String signSource = new StringBuffer().append(secret).append(timestamp).toString();
String ourSign = org.apache.commons.codec.digest.DigestUtils.md5Hex(signSource);
LOG.info("直播状态修改回调参数:channelId = {} ,sign = {},timestamp={}, 校验的生成规则为md5(AppSecret+timestamp):ourSign={}",channelId,sign,timestamp,ourSign);
if (!sign.equalsIgnoreCase(ourSign)){
LOG.warn("直播状态修改回调验签不通过!");
return BizResponse.fail("直播状态修改回调验签不通过");
}
LiveActivity select = new LiveActivity();
select.setChannel(channelId);
LiveActivity activity = baseMapper.selectOne(select);
if (null == activity ){
LOG.error("保利威直播状态回调,根据频道号没有查询到对应的直播channelId={}",channelId);
return BizResponse.fail("没有找到频道");
}
if (PolyvReqEnum.LIVE.getName().equals(status)){
activity.setStatus(LiveStatusEnum.LIVE.getCode());
}else if (PolyvReqEnum.END.getName().equals(status)){
activity.setStatus(LiveStatusEnum.END.getCode());
}
//修改直播状态
liveActivityMapper.updateById(activity);
return BizResponse.ok();
}
@Override
public BizResponse livebackCallback(PolyvLiveBackCallbackVo liveBackCallbackVo) {
String channelId = liveBackCallbackVo.getChannelId();
if (StringUtils.isEmpty(channelId)){
LOG.error("保利威直播回放完成回调接口:通道channelId 为空;");
return BizResponse.fail("保利威直播回放完成回调接口:通道channelId 为空;");
}
LiveActivity liveActivity = new LiveActivity();
liveActivity.setChannel(channelId);
EntityWrapper wrapper = new EntityWrapper(liveActivity);
List<LiveActivity> list = baseMapper.selectList(wrapper);
if (null == list || list.isEmpty()){
LOG.error("保利威直播回放完成回调接口,根据频道号没有查询到对应的直播channelId={}",channelId);
return BizResponse.fail("没有找到频道");
}
for (LiveActivity activity : list) {
activity.setReplayCallbackStatus(true);
// 查询直播回放开关状态;
Map<String, Object> params = new HashMap<String, Object>();
params.put(PolyvReqEnum.APP_ID.getName(), UtilConstants.APP_ID);
params.put(PolyvReqEnum.TIMESTAMP.getName(), System.currentTimeMillis() + "");
params.put(PolyvReqEnum.CHANNEL_ID.getName(), channelId);
PolyvResponseVo<String> polyvResponseVO = PolyvUtils.execPolyvApi(null,params, UtilConstants.LIVE_BACK_SWITCH_GET, RequestMethod.GET);
LOG.info("保利威直播回放完成回调接口,获取直播回放开关状态结果:{}",JSONObject.toJSONString(polyvResponseVO));
if (null == polyvResponseVO || 200 != polyvResponseVO.getCode()){
LOG.error("保利威直播回放完成回调接口,获取直播回放开关状态失败",channelId);
return BizResponse.fail("获取直播回放开关状态失败");
}
String data = polyvResponseVO.getData();
if (StringUtils.isEmpty(data) || "N".equals(data)){
continue;
}
//查询保利威直播回放;
List<LiveReplay> channelReplay = PolyvUtils.getChannelReplay(channelId);
if (null == channelReplay || channelReplay.isEmpty()){
continue;
}
//新增回放
for (LiveReplay liveReplay : channelReplay) {
String videoPoolId = liveReplay.getVideoPoolId();
LiveReplay query = new LiveReplay();
query.setVideoPoolId(videoPoolId);
EntityWrapper<LiveReplay> ew = new EntityWrapper<>(query);
List<LiveReplay> replayList = liveReplayMapper.selectList(ew);
if (null != replayList && replayList.size() > 0){
for (LiveReplay replay : replayList) {
Long id = replay.getId();
copyLiveProperties(liveReplay,replay,activity);
replay.setId(id);
liveReplayMapper.updateById(replay);
}
}else {
liveReplay.setCompanyId(activity.getCompanyId());
liveReplay.setSiteId(activity.getSiteId());
liveReplay.setLivePlanStartAt(activity.getStartTime());
liveReplay.setLiveType(activity.getScene());
liveReplay.setLiveId(activity.getId());
liveReplay.setChannelId(channelId);
liveReplay.setLiveStatus(activity.getStatus());
liveReplay.setLiveAnchor(activity.getAnchor());
liveReplay.setLiveLogoUrl(activity.getLogoImage());
liveReplayMapper.insert(liveReplay);
}
}
}
return BizResponse.ok();
}
private void copyLiveProperties(LiveReplay source, LiveReplay target, LiveActivity activity) {
target.setDuration(source.getDuration());
target.setTitle(source.getTitle());
target.setTotalItems(source.getTotalItems());
target.setRank(source.getRank());
target.setStartTime(source.getStartTime());
}
@Override
public BizResponse<List<LiveTitleVo>> reviewLiveList(LiveReviewsVo liveReviewsVo) {
RequestContext context = liveReviewsVo.getRequestContext();
List<LiveTitleVo> titleList = new ArrayList<>();
/*//查询直播回放表
Page<PageLiveVo> liveActivityPage = searchPage(null, null,
null, context.getCompanyId(), context.getSiteId(), context.getOrgIds(),
1, Integer.MAX_VALUE, null, null, null,null,null);
if (null == liveActivityPage || null == liveActivityPage.getRecords()){
LOG.warn("查询直播列表为空;accountId = {},companyId = {},siteId ={}",context.getAccountId(),context.getCompanyId(),context.getSiteId());
return BizResponse.ok(titleList);
}
List<PageLiveVo> records = liveActivityPage.getRecords();
List<Long> liveIdList = records.stream().map(PageLiveVo::getId).collect(Collectors.toList());
LOG.info("直播id list= {}", JSONObject.toJSONString(liveIdList));
titleList = liveReplayMapper.selectHashReviewLiveList(liveIdList);
if (null == titleList || titleList.isEmpty()){
LOG.info("查询有回放的直播列表为空;accountId = {},companyId = {},siteId ={}",context.getAccountId(),context.getCompanyId(),context.getSiteId());
return BizResponse.ok(titleList);
}*/
return BizResponse.ok(titleList);
}
@Override
public Page<LiveTitleVo> getHasReplayLiveList(LiveReleaseReviewReq replayLivesReq) {
//分页查询直播回放的直播间列表
//1.查询可见范围的并且开启直播回放的直播列表id
//2.查询上架的并且直播id in(条件1 )的直播回放列表
//3.排序:置顶-》开始时间
RequestContext context = replayLivesReq.getRequestContext();
int pageNo = replayLivesReq.getPageNo();
int pageSize = replayLivesReq.getPageSize();
if (pageNo == 0 || pageSize == 0){
pageNo = 1;
pageSize = Integer.MAX_VALUE;
}
Page<LiveTitleVo> page = new Page<>(pageNo,pageSize);
try {
//获取开启直播回放开关的直播间id
List<Long> liveIds = getReplayOnLiveIds(context);
if (null == liveIds || liveIds.isEmpty()){
LOG.error("获取全部可见的回放开关开启上架直播列表id为空. companyId = {} , siteId = {} , accountId = {} ."
,context.getCompanyCode(),context.getSiteId(),context.getAccountId());
return page;
}
List<LiveTitleVo> liveTitleVos = liveReplayMapper.selectHashReviewLiveList(liveIds, context.getCompanyId(), context.getSiteId(), page);
page.setRecords(liveTitleVos);
return page;
}catch (Exception e){
LOG.error("获取直播回放的直播间异常,companyId = {} , siteId = {} , accountId = {} . 错误信息如下:",context.getCompanyCode(),context.getSiteId(),context.getAccountId(),e);
}
return page;
}
@Override
public List<Long> getReplayOnLiveIds(RequestContext context) {
List<Long> relationIds = context.getRelationIds();
if (null == relationIds){
relationIds = new ArrayList<>();
}
relationIds.add(context.getAccountId());
//获取指定用户可见的直播id
List<Long> authLiveIds = scopeAuthorizationMapper.selectLiveIdByRelationId(relationIds);
//获取全部可见的回放开关开启上架直播
return scopeAuthorizationMapper.selectReplayOnLiveIds(authLiveIds,context.getCompanyId(),context.getSiteId());
}
@Override
public Page<LiveReplayVo> getReplayList(LiveReviewsVo liveReviewsVo) {
int pageNo = liveReviewsVo.getPageNo();
int pageSize = liveReviewsVo.getPageSize();
Page<LiveReplayVo> page = new Page<>(pageNo,pageSize);
Long liveId = liveReviewsVo.getLiveId();
RequestContext context = liveReviewsVo.getRequestContext();
if (null == liveId){
LOG.error("获取直播下所有直播回放列表,liveId is null ;accountId = {} , siteId = {}",context.getAccountId(),context.getSiteId());
return page;
}
LiveActivity activity = liveActivityMapper.selectById(liveId);
if (null == activity){
LOG.error("获取直播下所有直播回放列表;根据liveId = {} 未查询到直播信息;accountId = {} , siteId = {}",liveId,context.getAccountId(),context.getSiteId());
return page;
}
String logoImage = activity.getLogoImage();
List<LiveReplayVo> replayVoList = liveReplayMapper.selectReplayListByLiveId(liveId,page);
if (null == replayVoList || replayVoList.isEmpty()){
return page;
}
replayVoList.parallelStream().forEach(replayVo -> {
String liveLogoUrl = replayVo.getLiveLogoUrl();
replayVo.setLiveTitle(activity.getTitle());
replayVo.setLiveDefaultLogoUrl(logoImage);
if (!StringUtils.isEmpty(logoImage) && logoImage.equals(liveLogoUrl)){
replayVo.setDefaultLogo(true);
}else {
replayVo.setDefaultLogo(false);
}
});
page.setRecords(replayVoList);
return page;
}
@Override
public Boolean updateReplayStatus(Long replayId, Boolean operation) {
if (null == replayId || null == operation){
LOG.error("直播回放上架、下架失败. replayId = {} ,top ={}",replayId,operation);
return false;
}
LiveReplay liveReplay = liveReplayMapper.selectById(replayId);
if (null == liveReplay){
LOG.error("直播回放上架、下架失败. 未查询到replayId = {} 的直播回放",replayId);
return false;
}
liveReplay.setLiveReplayStatus(operation);
try {
liveReplayMapper.updateById(liveReplay);
}catch (Exception e){
LOG.error("直播回放上架、下架异常: ",e);
return false;
}
return true;
}
@Override
public Boolean updateReplayTop(Long replayId, Boolean top) {
if (null == replayId || null == top){
LOG.error("直播回放置顶、取消置顶失败. replayId = {} ,top ={}",replayId,top);
return false;
}
LiveReplay liveReplay = liveReplayMapper.selectById(replayId);
if (null == liveReplay){
LOG.error("直播回放置顶、取消置顶失败. 未查询到replayId = {} 的直播回放",replayId);
return false;
}
if (top){
liveReplay.setTopTime(new Date());
}else {
liveReplay.setTopTime(null);
}
try {
liveReplayMapper.updateTopTime(liveReplay.getId(),liveReplay.getTopTime());
}catch (Exception e){
LOG.error("直播回放置顶、取消置顶异常: ",e);
return false;
}
return true;
}
@Override
public Boolean updateReplayInfos(LiveReplayInfoVo infoVo) {
Long replayId = infoVo.getReplayId();
if (null == replayId){
LOG.error("直播回放编辑信息失败,回放id为空.infoVo = {} ",JSONObject.toJSONString(infoVo));
return false;
}
try {
LiveReplay liveReplay = liveReplayMapper.selectById(replayId);
if (null == liveReplay){
LOG.error("直播回放编辑信息失败失败. 未查询到replayId = {} 的直播回放",replayId);
return false;
}
Boolean defaultLogo = infoVo.getDefaultLogo();
if (null != defaultLogo && defaultLogo){
//使用本身图片
Long liveId = liveReplay.getLiveId();
LiveActivity activity = liveActivityMapper.selectById(liveId);
if (null == activity){
LOG.error("直播回放编辑信息失败失败. 未查询到replayId = {} ,liveId = {} 的直播",replayId,liveId);
return false;
}
liveReplay.setLiveLogoUrl(activity.getLogoImage());
}else {
String replayLogoUrl = infoVo.getReplayLogoUrl();
if (StringUtils.isEmpty(replayLogoUrl)){
LOG.error("直播回放编辑信息失败失败. replayId = {} 的直播回放,上传图片路径为空",JSONObject.toJSONString(infoVo));
return false;
}
liveReplay.setLiveLogoUrl(replayLogoUrl);
}
String anchor = infoVo.getAnchor();
if (StringUtils.isEmpty(anchor)){
LOG.error("直播回放编辑信息失败失败. replayId = {} 的直播回放,主播名为空",JSONObject.toJSONString(infoVo));
return false;
}
liveReplay.setLiveAnchor(anchor);
liveReplay.setImageDesc(infoVo.getImageDesc());
liveReplayMapper.updateById(liveReplay);
}catch (Exception e){
LOG.error("直播回放编辑信息异常: ",e);
return false;
}
return true;
}
@Override
public BizResponse<List<LiveReplayVo>> reviewsList(LiveReviewsVo liveReviewsVo) {
Long liveId = liveReviewsVo.getLiveId();
RequestContext context = liveReviewsVo.getRequestContext();
List<LiveReplayVo> replayVoList = new ArrayList<>();
if (null == liveId){
LOG.error("查询直播间下的直播回放列表;直播id为空!accountId = {},companyId ={},siteId={}",context.getAccountId(),context.getCompanyId(),context.getSiteId());
return BizResponse.ok(replayVoList);
}
LiveActivity activity = liveActivityMapper.selectById(liveId);
if (null == activity){
LOG.error("查询直播间回放列表;未查询到直播信息: liveId = {},siteId = {}",liveId,context.getSiteId());
return BizResponse.ok(replayVoList);
}
LiveReplay liveReplay = new LiveReplay();
liveReplay.setLiveId(liveId);
liveReplay.setLiveReplayStatus(true);
EntityWrapper<LiveReplay> wrapper = new EntityWrapper<>(liveReplay);
wrapper.orderBy("top_time",false);
wrapper.orderBy("start_time",false);
List<LiveReplay> liveReplays = liveReplayMapper.selectList(wrapper);
if (null == liveReplays || liveReplays.isEmpty()){
LOG.info("查询直播间liveId ={}的直播回放列表为空;accountId = {},companyId ={},siteId={}",liveId,context.getAccountId(),context.getCompanyId(),context.getSiteId());
return BizResponse.ok(replayVoList);
}
liveReplays.forEach(replay -> {
LiveReplayVo replayVo = new LiveReplayVo();
BeanUtils.copyProperties(replay,replayVo);
replayVo.setViewType(activity.getViewType());
replayVoList.add(replayVo);
});
return BizResponse.ok(replayVoList);
}
@Override
public BizResponse<String> liveTransferCallback(PolyvLiveBackCallbackVo liveBackCallbackVo) {
String channelId = liveBackCallbackVo.getChannelId();
String sign = liveBackCallbackVo.getSign();
long timestamp = liveBackCallbackVo.getTimestamp();
LOG.info("转播回放成功;保利威回调参数: channelId = {},sign= {},timestamp={}",channelId,sign,timestamp);
if (StringUtils.isEmpty(channelId) || StringUtils.isEmpty(sign)){
LOG.error("视频转存回调接口,保利威回调入参;频道号为空;验签为空");
return BizResponse.fail("channelId is null");
}
String secret = UtilConstants.APP_SECRET;
//校验验签sign
String signSource = new StringBuffer().append(secret).append(timestamp).toString();
String ourSign = org.apache.commons.codec.digest.DigestUtils.md5Hex(signSource);
LOG.info("转播回放成功;保利威回调参数:sign = {},timestamp={}, 校验的生成规则为md5(AppSecret+timestamp):ourSign={}",sign,timestamp,ourSign);
if (!sign.equalsIgnoreCase(ourSign)){
LOG.warn("转播回放成功回调验签不通过!");
return BizResponse.fail("转播回放成功回调验签不通过");
}
LiveActivity select = new LiveActivity();
select.setChannel(channelId);
LiveActivity activity = baseMapper.selectOne(select);
if (null == activity){
LOG.error("保利威视频转存回调接口,根据频道号没有查询到对应的直播channelId={}",channelId);
return BizResponse.fail("没有找到频道");
}
activity.setReplayCallbackStatus(true);
//查询保利威直播回放;
List<LiveReplay> channelReplay = PolyvUtils.getChannelReplay(channelId);
if (null == channelReplay || channelReplay.isEmpty()){
return BizResponse.ok();
}
// 查询本地数据库的channel下的回放列表 alist
// 遍历保利为的回放;根据vid查询数据库,
// 如果数据库有则更新 如果没有则新增,
// 判断alist是否包含vid;如果不包含则需要删除数据库该条
//获取保利威回放map;key=videoPoolId,value=回放id
List<String> polyvVideoPoolIdList = channelReplay.parallelStream().map(LiveReplay::getVideoPoolId).collect(Collectors.toList());
List<LiveReplay> channelOldReplayList = getOldLiveReplaysByChannelId(channelId);
List<Long> delReplayIdList = getdelReplayList(polyvVideoPoolIdList, channelOldReplayList);
for (LiveReplay liveReplay : channelReplay) {
String videoPoolId = liveReplay.getVideoPoolId();
LiveReplay oldReplay = replayService.getByVideoPoolId(videoPoolId);
if (null != oldReplay ){
//修改
Long id = oldReplay.getId();
copyLiveProperties(liveReplay,oldReplay,activity);
oldReplay.setId(id);
liveReplayMapper.updateById(oldReplay);
}else {
//新增
liveReplay.setId(idGenerator.generate());
liveReplay.setCompanyId(activity.getCompanyId());
liveReplay.setSiteId(activity.getSiteId());
liveReplay.setLivePlanStartAt(activity.getStartTime());
liveReplay.setLiveType(activity.getScene());
liveReplay.setLiveId(activity.getId());
liveReplay.setChannelId(channelId);
liveReplay.setLiveStatus(activity.getStatus());
liveReplay.setLiveAnchor(activity.getAnchor());
liveReplay.setLiveLogoUrl(activity.getLogoImage());
try {
liveReplayMapper.insert(liveReplay);
}catch (Exception e){
LOG.warn("新增直播回放异常;channelId = "+channelId+" ,videoPoolId = "+videoPoolId+" ;",e);
}
}
}
//删除保利威删除但是数据库未删除的回放记录
if (delReplayIdList.size() > 0){
try {
liveReplayMapper.deleteReplayBatch(delReplayIdList);
LOG.info("直播回放转存回调,删除数据库多余记录{}条",delReplayIdList.size());
}catch (Exception e){
LOG.error("直播回放转存回调,删除数据库多余记录异常; ",e);
}
}
return null;
}
/**
* 获取数据库要删除的回放记录
* @param polyvVideoPoolIdList 保利威的视频回放回调 key=vidPoolId
* @param channelOldReplayList 数据库中channel存在的回放视频
*/
private List<Long> getdelReplayList(List<String> polyvVideoPoolIdList, List<LiveReplay> channelOldReplayList) {
List<Long> delReplayIdList = new ArrayList<>();
if (null != channelOldReplayList && !channelOldReplayList.isEmpty()){
channelOldReplayList.parallelStream().forEach(liveReplay -> {
String videoPoolId = liveReplay.getVideoPoolId();
if (!polyvVideoPoolIdList.contains(videoPoolId)){
//需要删除的记录
delReplayIdList.add(liveReplay.getId());
}
});
}
return delReplayIdList;
}
private List<LiveReplay> getOldLiveReplaysByChannelId(String channelId) {
LiveReplay replayQuery = new LiveReplay();
replayQuery.setChannelId(channelId);
EntityWrapper<LiveReplay> queryEW = new EntityWrapper<>(replayQuery);
return liveReplayMapper.selectList(queryEW);
}
public Page getPage(String field, String value, Page<DroolsVo> page) {
RequestContext requestContext = ContextHolder.get();
Long siteId = requestContext.getSiteId();
Long companyId = requestContext.getCompanyId();
LiveActivity liveActivity = new LiveActivity();
liveActivity.setSiteId(siteId);
liveActivity.setCompanyId(companyId);
liveActivity.setShelves(1);
EntityWrapper wrapper = new EntityWrapper(liveActivity);
wrapper.setSqlSelect("distinct(" + field + "),"+"id ")
.isNotNull(field)
.like(field, value)
.addFilter(field+"!=''")
.orderBy("create_time", false);
String upperField = ClassUtil.getFieldName(field);
List<DroolsVo> voList = null;
List<LiveActivity> list = this.baseMapper.selectPage(page, wrapper);
if (CollectionUtils.isEmpty(list)) {
voList = new ArrayList<>(list.size());
for (LiveActivity a : list) {
DroolsVo vo = new DroolsVo();
vo.setTaskId(a.getId());
vo.setTaskFieldValue(ClassUtil.invokeMethod(a, upperField));
vo.setTaskParamsType(field);
voList.add(vo);
}
page.setRecords(voList);
}
return page;
}
}
package com.yizhi.live.application.service.impl;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.yizhi.live.application.domain.LiveToken;
import com.yizhi.live.application.mapper.LiveTokenMapper;
import com.yizhi.live.application.service.ILiveTokenService;
import org.springframework.stereotype.Service;
/**
* <p>
* 直播生成的token保存 服务实现类
* </p>
*
* @author fulan123
* @since 2018-04-25
*/
@Service
public class LiveTokenServiceImpl extends ServiceImpl<LiveTokenMapper, LiveToken> implements ILiveTokenService {
}
package com.yizhi.live.application.service.impl;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.yizhi.application.orm.id.IdGenerator;
import com.yizhi.live.application.domain.ScopeAuthorization;
import com.yizhi.live.application.mapper.ScopeAuthorizationMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import com.yizhi.live.application.service.IScopeAuthorizationService;
import java.util.List;
/**
* <p>
* 直播授权课件范围表 服务实现类
* </p>
*
* @author fulan123
* @since 2018-04-10
*/
@Service
@Transactional
public class ScopeAuthorizationServiceImpl extends ServiceImpl<ScopeAuthorizationMapper, ScopeAuthorization> implements IScopeAuthorizationService {
private Logger logger = LoggerFactory.getLogger(ScopeAuthorizationServiceImpl.class);
@Autowired
IdGenerator idGenerator;
@Override
public Boolean insertList(List<ScopeAuthorization> list) {
if (list.size() > 0) {
//保存之前先删除 修改时时 不用做数据对比
Long liveId = list.get(0).getLiveId();
this.baseMapper.deleteAuthorize(liveId);
//保存
for (ScopeAuthorization scopeAuthorization1 : list) {
scopeAuthorization1.setId(idGenerator.generate());
}
return this.baseMapper.insertList(list);
} else {
return Boolean.FALSE;
}
}
@Override
public Boolean insertAllList(List<ScopeAuthorization> list) {
if (!CollectionUtils.isEmpty(list)) {
Long liveId = list.get(0).getLiveId();
this.baseMapper.deleteAuthorize(liveId);
for (ScopeAuthorization scopeAuthorization1 : list) {
scopeAuthorization1.setId(idGenerator.generate());
}
return this.baseMapper.insertList(list);
} else {
logger.error("列表为空");
return Boolean.FALSE;
}
}
@Override
public List<ScopeAuthorization> listScopeAuthorization(Long liveId) {
// TODO Auto-generated method stub
ScopeAuthorization scopeAuthorization=new ScopeAuthorization();
scopeAuthorization.setLiveId(liveId);
EntityWrapper<ScopeAuthorization> wrapper=new EntityWrapper<ScopeAuthorization>(scopeAuthorization);
return this.selectList(wrapper);
}
}
package com.yizhi.live.application.util;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import java.lang.reflect.Field;
import java.util.*;
public class JsonUtil {
public static Map<String, Object> parseJSON2Map(String jsonStr) throws Exception{
Map<String, Object> map = new HashMap<String, Object>();
JSONObject json = JSONObject.parseObject(jsonStr);
for(Object k : json.keySet()){
Object v = json.get(k);
if(v instanceof JSONArray){
List<Map<String, Object>> list = new ArrayList<Map<String,Object>>();
JSONArray json2 = JSONArray.parseArray(v.toString());
for(int i=0;i<json2.size();i++){
// 遍历 jsonarray 数组,把每一个对象转成 json 对象
JSONObject job = json2.getJSONObject(i);
list.add(parseJSON2Map(job.toString()));
}
map.put(k.toString(), list);
} else {
map.put(k.toString(), v);
}
}
return map;
}
}
package com.yizhi.live.application.util;
import com.yizhi.core.application.context.RequestContext;
import com.yizhi.core.application.event.EventWrapper;
import com.yizhi.core.application.publish.CloudEventPublisher;
import com.yizhi.live.application.domain.LiveActivity;
import com.yizhi.live.application.vo.MessageRemindVo;
import com.yizhi.live.application.vo.MessageTaskRemindVo;
import com.yizhi.message.application.constans.Constans;
import com.yizhi.message.application.enums.RelationType;
import com.yizhi.message.application.vo.TaskVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.List;
@Component
public class LiveEvenSendMessage {
@Autowired
private CloudEventPublisher cloudEventPublisher;
private Logger logger = LoggerFactory.getLogger(LiveEvenSendMessage.class);
/**
* 系统模板,发消息
*
* @param liveActivity 业务参数对象
*/
public void systemSendMessage(LiveActivity liveActivity, MessageRemindVo remindVo, RequestContext context) {
com.yizhi.message.application.vo.MessageRemindVo vo = new com.yizhi.message.application.vo.MessageRemindVo();
//共用参数
vo.setMessageType(2);
vo.setRelationId(liveActivity.getId());
vo.setRelationType(RelationType.ZB.getKey());
if (context == null) {
context = new RequestContext();
context.setCompanyId(liveActivity.getCompanyId());
context.setSiteId(liveActivity.getSiteId());
context.setAccountName(liveActivity.getCreateByName());
context.setAccountId(liveActivity.getCreateById());
}
vo.setRequestContext(context);
if (vo.getMessageType() == null || vo.getRelationId() == null || vo.getRelationType() == null) {
logger.info("messageType:"+remindVo.getMessageType()+"||"+"RelationId:"+remindVo.getRelationId()
+"||"+"RelationType:"+remindVo.getRelationType());
logger.info("相关参数缺失!!");
return;
}
if (remindVo.getHasDeleted()) {
vo.setHasDeleted(remindVo.getHasDeleted());
cloudEventPublisher.publish(Constans.MESSAGE_QUEUE, new EventWrapper<com.yizhi.message.application.vo.MessageRemindVo>(null, vo));
} else {
//修改直播的状态
if (remindVo.getTaskStatusUpdate()) {
//1 为消息业务可发送状态 0 则不行
vo.setTaskStatus(liveActivity.getShelves().equals(1) ? 1 : 0);
vo.setTaskStatusUpdate(remindVo.getTaskStatusUpdate());
cloudEventPublisher.publish(Constans.MESSAGE_QUEUE, new EventWrapper<com.yizhi.message.application.vo.MessageRemindVo>(null, vo));
logger.info("发送修改业务状态消息成功=====================");
return;
}
if (liveActivity != null) {
if (!CollectionUtils.isEmpty(remindVo.getMessageTaskRemindVos())) {
com.yizhi.message.application.vo.TaskVo taskVo = new TaskVo();
taskVo.setTaskName(liveActivity.getTitle());
taskVo.setTaskStratTime(liveActivity.getStartTime());
taskVo.setTaskEndTime(liveActivity.getEndTime());
vo.setTaskStatus(liveActivity.getShelves().equals(1) ? 1 : 0);
vo.setMessageType(remindVo.getMessageType());
vo.setMessageId(remindVo.getMessageId());
vo.setIsChangge(remindVo.getIsChangge());
List<MessageTaskRemindVo> m= remindVo.getMessageTaskRemindVos();
List<com.yizhi.message.application.vo.MessageTaskRemindVo> m2=new ArrayList<>();
for (MessageTaskRemindVo m1:m
) {
com.yizhi.message.application.vo.MessageTaskRemindVo mx=new com.yizhi.message.application.vo.MessageTaskRemindVo();
BeanUtils.copyProperties(m1,mx);
m2.add(mx);
}
vo.setMessageTaskRemindVos(m2);
vo.setSendType(remindVo.getSendType());
vo.setVisibleRange(remindVo.getVisibleRange());
vo.setTaskVo(taskVo);
if (vo.getMessageId() == null || vo.getSendType() == null || vo.getVisibleRange() == null) {
logger.info("messageID:"+remindVo.getMessageId()+"||"+"sendType:"+remindVo.getSendType()
+"||"+"VisibleRange:"+remindVo.getVisibleRange());
logger.info("相关参数缺失!!!!!");
return;
}
try {
cloudEventPublisher.publish(Constans.MESSAGE_QUEUE, new EventWrapper<com.yizhi.message.application.vo.MessageRemindVo>(null, vo));
logger.info("发送消息成功=====================");
} catch (Exception e) {
e.printStackTrace();
logger.error("发送消息失败=====================", e);
}
}
}
}
}
}
package com.yizhi.live.application.util;
import org.apache.http.HttpEntity;
import org.apache.http.NameValuePair;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import org.springframework.stereotype.Component;
import java.io.IOException;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.util.*;
@Component
public class LiveUtil {
private RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(15000).setConnectTimeout(15000)
.setConnectionRequestTimeout(15000).build();
public String sendHttpPost(String httpUrl, Map<String, String> maps) {
HttpPost httpPost = new HttpPost(httpUrl);
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
for (String key : maps.keySet()) {
nameValuePairs.add(new BasicNameValuePair(key, maps.get(key)));
}
try {
httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs, "UTF-8"));
} catch (Exception e) {
e.printStackTrace();
}
return sendHttpPost(httpPost);
}
private String sendHttpPost(HttpPost httpPost) {
CloseableHttpClient httpClient = null;
CloseableHttpResponse response = null;
HttpEntity entity = null;
String responseContent = null;
try {
httpClient = HttpClients.createDefault();
httpPost.setConfig(requestConfig);
response = httpClient.execute(httpPost);
entity = response.getEntity();
responseContent = EntityUtils.toString(entity, "UTF-8");
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (response != null) {
response.close();
}
if (httpClient != null) {
httpClient.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return responseContent;
}
public String generateSign(Map<String, String> parray, String secretKey) {
Map<String, String> params = this.paraFilter(parray);
String concatedStr = this.concatParams(params);
String plain = secretKey + concatedStr + secretKey;
String encrypted = MD5Utils.getMD5String(plain);
String upperCase = encrypted.toUpperCase();
return upperCase;
}
private Map<String, String> paraFilter(Map<String, String> sArray) {
Map<String, String> result = new HashMap<String, String>();
if (sArray == null || sArray.size() <= 0) {
return result;
}
for (String key : sArray.keySet()) {
String value = sArray.get(key);
if (value == null || value.equals("") || key.equalsIgnoreCase("sign")
|| key.equalsIgnoreCase("sign_type")) {
continue;
}
result.put(key, value);
}
return result;
}
private String concatParams(Map<String, String> params) {
List<String> keys = new ArrayList<String>(params.keySet());
Collections.sort(keys);
StringBuilder sb = new StringBuilder();
for (int i = 0; i < keys.size(); i++) {
String key = keys.get(i);
String value = params.get(key);
sb.append(key).append(value);
}
return sb.toString();
}
public static String getMD5(String str) {
try {
// 生成一个MD5加密计算摘要
MessageDigest md = MessageDigest.getInstance("MD5");
// 计算md5函数
md.update(str.getBytes());
// digest()最后确定返回md5 hash值,返回值为8为字符串。因为md5 hash值是16位的hex值,实际上就是8位的字符
// BigInteger函数则将8位的字符串转换成16位hex值,用字符串来表示;得到字符串形式的hash值
String md5=new BigInteger(1, md.digest()).toString(16);
//BigInteger会把0省略掉,需补全至32位
return fillMD5(md5);
} catch (Exception e) {
throw new RuntimeException("MD5加密错误:"+e.getMessage(),e);
}
}
public static String fillMD5(String md5){
return md5.length()==32?md5:fillMD5("0"+md5);
}
}
package com.yizhi.live.application.util;
import com.yizhi.live.application.constant.UtilConstants;
import org.apache.http.HttpEntity;
import org.apache.http.NameValuePair;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import java.io.IOException;
import java.util.*;
/**
* post 请求 url 不拼参数,没有请求体
*/
public class LiveUtilPostUrlNotParam {
private static RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(15000).setConnectTimeout(15000)
.setConnectionRequestTimeout(15000).build();
/**
* 发送请求
* @param url
* @param param
* @return
*/
public static String sendPost(String url , Map<String, String> param) {
Map<String, String> map = new HashMap<>();
String timestamp = Long.toString(System.currentTimeMillis());
map.put("appId", UtilConstants.APP_ID);
map.put("timestamp", timestamp);
for(Map.Entry<String, String> item : param.entrySet()){
map.put(item.getKey(), item.getValue());
}
String sign = generateSign(map, UtilConstants.APP_SECRET);
map.put("sign", sign);
return sendHttpPost(url, map);
}
private static String sendHttpPost(String httpUrl, Map<String, String> maps) {
HttpPost httpPost = new HttpPost(httpUrl);
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
for (String key : maps.keySet()) {
nameValuePairs.add(new BasicNameValuePair(key, maps.get(key)));
}
try {
httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs, "UTF-8"));
} catch (Exception e) {
e.printStackTrace();
}
return sendHttpPost(httpPost);
}
private static String sendHttpPost(HttpPost httpPost) {
CloseableHttpClient httpClient = null;
CloseableHttpResponse response = null;
HttpEntity entity = null;
String responseContent = null;
try {
httpClient = HttpClients.createDefault();
httpPost.setConfig(requestConfig);
response = httpClient.execute(httpPost);
entity = response.getEntity();
responseContent = EntityUtils.toString(entity, "UTF-8");
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (response != null) {
response.close();
}
if (httpClient != null) {
httpClient.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return responseContent;
}
protected static String generateSign(Map<String, String> parray, String secretKey) {
Map<String, String> params = paraFilter(parray);
String concatedStr = concatParams(params);
String plain = secretKey + concatedStr + secretKey;
String encrypted = MD5Utils.getMD5String(plain);
String upperCase = encrypted.toUpperCase();
return upperCase;
}
private static Map<String, String> paraFilter(Map<String, String> sArray) {
Map<String, String> result = new HashMap<String, String>();
if (sArray == null || sArray.size() <= 0) {
return result;
}
for (String key : sArray.keySet()) {
String value = sArray.get(key);
if (value == null || value.equals("") || key.equalsIgnoreCase("sign")
|| key.equalsIgnoreCase("sign_type")) {
continue;
}
result.put(key, value);
}
return result;
}
private static String concatParams(Map<String, String> params) {
List<String> keys = new ArrayList<String>(params.keySet());
Collections.sort(keys);
StringBuilder sb = new StringBuilder();
for (int i = 0; i < keys.size(); i++) {
String key = keys.get(i);
String value = params.get(key);
sb.append(key).append(value);
}
return sb.toString();
}
}
package com.yizhi.live.application.util;
import com.yizhi.live.application.constant.UtilConstants;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpEntity;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.*;
/**
* post 请求带参数,请求体为json(不签名)
*/
public class LiveUtilPostUrlParam {
private static RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(15000).setConnectTimeout(15000)
.setConnectionRequestTimeout(15000).build();
/**
* 保利威 api 发送post的请求
* @param url api接口地址
* @param postBody 请求的post参数
* @param param 需要进行sing签名的参数,最后会根据这些参数生成sign ,然后在url后面加上key=value的&拼接的
* @return
*/
public static String sendPost(String url , String postBody, Map<String, String> param) {
//UtilConstants.APP_SECRET
//UtilConstants.APP_ID
//String url = "http://api.polyv.net/live/v3/channel/auth/update";
//String channelId = "频道号";
//String appId = "appId";
//String key = "secretKey";
Map<String, String> map = new HashMap<>();
String timestamp = Long.toString(System.currentTimeMillis());
map.put("appId", UtilConstants.APP_ID);
map.put("timestamp", timestamp);
for(Map.Entry<String, String> item : param.entrySet()){
map.put(item.getKey(), item.getValue());
}
String sign = getSign(map, UtilConstants.APP_SECRET);
map.put("sign", sign);
//String body = "{\"authSettings\":[{\"rank\":1,\"enabled\":\"N\"},{\"rank\":2,\"enabled\":\"N\"}]}";
//String content = sendHttpPost(url, map, body);
//System.out.println(content);
return sendHttpPost(url, map, postBody);
}
/**
* 发送 post请求
* @param httpUrl 地址
* @param maps 参数
*/
private static String sendHttpPost(String httpUrl, Map<String, String> maps, String body) {
StringBuilder url = new StringBuilder();
url.append(httpUrl).append("?");
for (Map.Entry<String, String> map : maps.entrySet()) {
url.append(map.getKey()).append("=").append(map.getValue()).append("&");
}
String urlStr = url.toString().substring(0, url.length() - 1);
System.out.println(urlStr);
// 创建httpPost
HttpPost httpPost = new HttpPost(urlStr);
try {
if(StringUtils.isNotBlank(body)){
StringEntity entity = new StringEntity(body, Charset.forName("UTF-8"));
httpPost.setEntity(entity);
}
} catch (Exception e) {
// ...
}
return sendHttpPost(httpPost);
}
/**
* 发送Post请求
* @param httpPost
* @return
*/
private static String sendHttpPost(HttpPost httpPost) {
CloseableHttpClient httpClient = null;
CloseableHttpResponse response = null;
HttpEntity entity;
String responseContent = null;
try {
// 创建默认的httpClient实例.
httpClient = HttpClients.createDefault();
httpPost.setConfig(requestConfig);
// 执行请求
response = httpClient.execute(httpPost);
entity = response.getEntity();
responseContent = EntityUtils.toString(entity, "UTF-8");
} catch (Exception e) {
// ...
} finally {
try {
// 关闭连接,释放资源
if (response != null) {
response.close();
}
if (null != httpPost) {
httpPost.releaseConnection();
}
if (httpClient != null) {
httpClient.close();
}
} catch (IOException e) {
// ...
}
}
return responseContent;
}
/**
* 根据map里的参数构建加密串
* @param map
* @param secretKey
* @return
*/
protected static String getSign(Map<String, String> map, String secretKey) {
Map<String, String> params = paraFilter(map);
// 处理参数,计算MD5哈希值
String concatedStr = concatParams(params);
String plain = secretKey + concatedStr + secretKey;
String encrypted = MD5Utils.getMD5String(plain);
// 32位大写MD5值
return encrypted.toUpperCase();
}
/**
* 对params根据key来排序并且以key1=value1&key2=value2的形式拼接起来
* @param params
* @return
*/
private static String concatParams(Map<String, String> params) {
List<String> keys = new ArrayList<>(params.keySet());
Collections.sort(keys);
StringBuilder sb = new StringBuilder();
for (int i = 0; i < keys.size(); i++) {
String key = keys.get(i);
String value = params.get(key);
sb.append(key).append(value);
}
return sb.toString();
}
/**
* 除去数组中的空值和签名参数
* @param sArray 签名参数组
* @return 去掉空值与签名参数后的新签名参数组
*/
private static Map<String, String> paraFilter(Map<String, String> sArray) {
Map<String, String> result = new HashMap<>();
if (sArray == null || sArray.size() <= 0) {
return result;
}
for (String key : sArray.keySet()) {
String value = sArray.get(key);
if (value == null || value.equals("") || key.equalsIgnoreCase("sign")
|| key.equalsIgnoreCase("sign_type")) {
continue;
}
result.put(key, value);
}
return result;
}
}
package com.yizhi.live.application.util;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class MD5Utils {
protected static char hexDigits[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e',
'f' };
protected static MessageDigest messagedigest = null;
static {
try {
messagedigest = MessageDigest.getInstance("MD5");
} catch (NoSuchAlgorithmException nsaex) {
nsaex.printStackTrace();
}
}
public static String getFileMD5String(File file) throws IOException {
FileInputStream in = new FileInputStream(file);
FileChannel ch = in.getChannel();
MappedByteBuffer byteBuffer = ch.map(FileChannel.MapMode.READ_ONLY, 0, file.length());
messagedigest.update(byteBuffer);
in.close();
return bufferToHex(messagedigest.digest());
}
public static String getFileMD5String(File file, String userid) throws Exception {
FileInputStream in = new FileInputStream(file);
FileChannel ch = in.getChannel();
// 避免outofmemory,最多取前1000个字节
long length = file.length() > 1000 ? 1000 : file.length();
MappedByteBuffer byteBuffer = ch.map(FileChannel.MapMode.READ_ONLY, 0, length);
messagedigest.update(byteBuffer);
String temp = bufferToHex(messagedigest.digest()) + file.length();
byte[] btemp = temp.getBytes();
String vid = bufferToHex(messagedigest.digest(btemp));
in.close();
return userid.toLowerCase() + vid.substring(userid.length(), vid.length());
}
public static String getMD5String(String s) {
return getMD5String(s.getBytes());
}
public static String getMD5String(byte[] bytes) {
messagedigest.update(bytes);
return bufferToHex(messagedigest.digest());
}
public static String getMD5String(String s, String userid) {
String md5string = getMD5String(s.getBytes());
return userid.toLowerCase() + md5string.substring(userid.length(), md5string.length());
}
private static String bufferToHex(byte bytes[]) {
return bufferToHex(bytes, 0, bytes.length);
}
private static String bufferToHex(byte bytes[], int m, int n) {
StringBuffer stringbuffer = new StringBuffer(2 * n);
int k = m + n;
for (int l = m; l < k; l++) {
appendHexPair(bytes[l], stringbuffer);
}
return stringbuffer.toString();
}
private static void appendHexPair(byte bt, StringBuffer stringbuffer) {
char c0 = hexDigits[(bt & 0xf0) >> 4];
char c1 = hexDigits[bt & 0xf];
stringbuffer.append(c0);
stringbuffer.append(c1);
}
public static boolean checkPassword(String password, String md5PwdStr) {
String s = getMD5String(password);
return s.equals(md5PwdStr);
}
}
package com.yizhi.live.application.util;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.net.URLEncoder;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yizhi.core.application.enums.InternationalEnums;
import com.yizhi.core.application.exception.BizException;
import com.yizhi.live.application.constant.*;
import com.yizhi.live.application.domain.LiveReplay;
import com.yizhi.live.application.enums.LiveStatusV2;
import com.yizhi.live.application.enums.PolyvReqEnum;
import com.yizhi.live.application.vo.LiveStatisticDataVo;
import com.yizhi.live.application.vo.PolyvResponseVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMethod;
import java.nio.charset.Charset;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* @Date 2020/12/8 2:51 下午
* @Author lvjianhui
**/
public class PolyvUtils {
public static Logger logger = LoggerFactory.getLogger(PolyvUtils.class);
public String getRedirectUrl(String active) {
if ("dev".equals(active)) {
return UtilConstants.DEV_LIVE_CUSTOM_URI;
} else if ("sit".equals(active)) {
return UtilConstants.SIT_LIVE_CUSTOM_URI;
} else if ("uat".equals(active)) {
return UtilConstants.UAT_LIVE_CUSTOM_URI;
} else {
return UtilConstants.PRO_LIVE_CUSTOM_URI;
}
}
/**
* 直播状态
* 按照时间维度(当前时间与当前直播设置的时间对比)
* 1、当前时间<开始时间
* 正在直播:进行中
* 没在直播:未开始
* 2、开始时间<当前时间<结束时间
* 正在直播:进行中
* 没在直播∩[开始时间到当前时间]没直播过:未开始
* 没在直播∩[开始时间到当前时间]直播过:直播回放
* 3、当前时间>结束时间
* 正在直播:进行中
* 没在直播∩[开始时间到当前时间]没直播过:已结束
* 没在直播∩[开始时间到当前时间]直播过:直播回放
*
* @param channelId
* @param startAt
* @param endAt
* @param liveStatus see LiveStatusEnum
* @return
*/
public static LiveStatusV2 getLiveStatus(String channelId, Date startAt, Date endAt, Integer liveStatus) {
// 直播中
if (null != liveStatus && liveStatus.equals(LiveStatusEnum.LIVE.getCode())) {
return LiveStatusV2.RUNNING;
}
if (LiveStatusV2.RUNNING.getCode().equals(getThirdLiveStatus(channelId))) {
return LiveStatusV2.RUNNING;
}
Long currentTime = System.currentTimeMillis();
// 未开始
if (startAt.getTime() > currentTime) {
return LiveStatusV2.UN_START;
}
Integer count = getCountByChannel(channelId, startAt, new Date(currentTime));
if (count > 0) {
return LiveStatusV2.REPLAY;
}
if (count <= 0 && currentTime > endAt.getTime()) {
return LiveStatusV2.END;
}
return LiveStatusV2.UN_START;
}
public static Integer getThirdLiveStatus(String channelId) {
Map<String, Object> params = new HashMap();
params.put("appId", UtilConstants.APP_ID);
params.put("timestamp", System.currentTimeMillis() + "");
params.put("channelIds", channelId);
try {
PolyvResponseVo<JSONArray> result = execPolyvApi(null, params, UtilConstants.LIVE_STATUS_URL, null);
JSONArray json = result.getData();
if (json == null || json.size() == 0) {
return LiveStatusV2.END.getCode();
}
if (JSONObject.toJSONString(json.get(0)).contains("live")) {
return LiveStatusV2.RUNNING.getCode();
}
return LiveStatusV2.END.getCode();
} catch (Exception e) {
logger.error("获取直播状态出错 channelId:{}", channelId, e);
return LiveStatusV2.END.getCode();
}
}
/**
* https://api.polyv.net/live/v3/channel/session/list
* 查询频道直播场次信息
*
* @param channelId
* @return
*/
public static Integer getCountByChannel(String channelId, Date startAt, Date endAt) {
String url = "https://api.polyv.net/live/v3/channel/session/list";
Long timeStamp = System.currentTimeMillis();
Map<String, Object> signParams = new HashMap<String, Object>();
signParams.put("appId", UtilConstants.APP_ID);
signParams.put("channelId", channelId);
signParams.put("timestamp", timeStamp);
signParams.put("endDate", DateUtil.formatDate(endAt));
signParams.put("startDate", DateUtil.formatDate(startAt));
try {
PolyvResponseVo<JSONObject> vo = execPolyvApi(null, signParams, url, RequestMethod.GET);
Integer count = vo.getData().getInteger("totalItems");
if (count > 0) {
String contents = vo.getData().getString("contents");
List<PolyvLiveCount> list = JSONObject.parseArray(contents, PolyvLiveCount.class);
for (PolyvLiveCount polyvLiveCount : list) {
if (polyvLiveCount.getStartTime() >= startAt.getTime() &&
polyvLiveCount.getEndTime() <= endAt.getTime()) {
return count;
}
}
return 0;
}
} catch (Exception e) {
logger.warn("获取直播场次出错 channelId:{}", channelId, e);
}
return 0;
}
/**
* 保利威直播参数修改
* http://api.polyv.net/live/v3/channel/basic/update
* http://api.polyv.net/live/v3/channel/basic/update?appId={{appId}}&timestamp={{timestamp}}&channelId={{channelId}}&sign={{sign}}
*
* @param needAuthView 授权观看时传 trye,esle false
* @see "https://dev.polyv.net/2019/liveproduct/l-api/zbglgn/pdcz/update-channel-detail-setting/"
*/
public static PolyvResponseVo<String> updateChannelParams(String channelId, PolyvUpdatePO params, Boolean needAuthView, String customKey, String customUri) {
Long timeStamp = System.currentTimeMillis();
Map<String, Object> signParams = new HashMap<String, Object>();
signParams.put("appId", UtilConstants.APP_ID);
signParams.put("channelId", channelId);
signParams.put("timestamp", timeStamp);
JSONObject json = new JSONObject();
JSONArray array = new JSONArray();
JSONObject authSettings = new JSONObject();
String enabled = "N";
if (needAuthView) {
enabled = "Y";
}
authSettings.put("enabled", enabled);
authSettings.put("rank", 1);
authSettings.put("authType", "custom");
authSettings.put("customUri", URLEncoder.createDefault().encode(customUri, Charset.defaultCharset()));
authSettings.put("customKey", customKey);
array.add(authSettings);
json.put("basicSetting", params);
json.put("authSettings", array);
String url = String.format(UtilConstants.CHANNEL_ALL_INFO_UPDATE, UtilConstants.APP_ID, timeStamp, channelId, getSign(signParams));
return execPolyvApi(json.toJSONString(), null, url, RequestMethod.POST);
}
/**
* 查询多个频道的时间段内的统计数据
*
* @param channelIds 多个频道
* @param startDay 开始日期 yyyy-mm-dd
* @param endDay 截至日期 yyyy-mm-dd
*/
public static List<LiveStatisticDataVo> getLiveStatistic(String channelIds, Date startDay, Date endDay) {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
if (null == startDay || null == endDay || StringUtils.isEmpty(channelIds)) {
return new ArrayList<>();
}
String startDate = format.format(startDay);
String endDate = format.format(endDay);
String url = String.format(UtilConstants.LIVE_CHANNELS_STATISTIC_DATA, UtilConstants.APP_USER_ID);
Map<String, Object> params = new HashMap<>();
params.put(PolyvReqEnum.APP_ID.getName(), UtilConstants.APP_ID);
params.put(PolyvReqEnum.TIMESTAMP.getName(), System.currentTimeMillis() + "");
params.put(PolyvReqEnum.CHANNEL_IDS.getName(), channelIds);
params.put(PolyvReqEnum.START_DATE.getName(), startDate);
params.put(PolyvReqEnum.END_DATE.getName(), endDate);
PolyvResponseVo<JSONArray> result = execPolyvApi(null, params, url, RequestMethod.GET);
JSONArray data = result.getData();
return JSONObject.parseArray(JSONObject.toJSONString(data), LiveStatisticDataVo.class);
}
public static List<LiveReplay> getChannelReplay(String channelId) {
String url = String.format(UtilConstants.LIVE_REPLAY_LIST, channelId);
Map<String, Object> params = new HashMap<>();
params.put("appId", UtilConstants.APP_ID);
params.put("timestamp", System.currentTimeMillis() + "");
params.put("page", "1");
params.put("pageSize", "100");
params.put("listType", "playback");
PolyvResponseVo<JSONObject> reslut = execPolyvApi(null, params, url, RequestMethod.GET);
JSONArray listObject = (JSONArray) reslut.getData().get("contents");
List<LiveReplay> list = JSONObject.parseArray(JSONObject.toJSONString(listObject), LiveReplay.class);
if (list == null) {
list = new ArrayList<LiveReplay>();
}
return list;
}
public static <T> PolyvResponseVo<T> execPolyvApi(String requestBody, Map<String, Object> params, String apiUrl, RequestMethod method) {
String result;
if (method == null || method == RequestMethod.GET) {
String sign = getSign(params);
params.put("sign", sign);
result = HttpUtil.get(apiUrl, params);
} else {
result = HttpUtil.post(apiUrl, requestBody);
}
logger.info("调用保利威 URL:{} params:{} requestBody:{} result:{}", apiUrl, params, requestBody, result);
try {
PolyvResponseVo<T> vo = JSONObject.parseObject(result, PolyvResponseVo.class);
if (vo.getCode() != 200) {
logger.error("调用保利威 ERROR MSG:{}", vo.getMessage());
throw new BizException(InternationalEnums.DOCUMENTRELATIONCONTROLLER6);
}
return vo;
} catch (Exception e) {
logger.error("调用保利威 ERROR MSG:" + result, e);
throw new BizException(InternationalEnums.DOCUMENTRELATIONCONTROLLER6);
}
}
public static String getSign(Map<String, Object> paramMap) {
String appSecret = UtilConstants.APP_SECRET;
//对参数名进行字典排序
String[] keyArray = paramMap.keySet().toArray(new String[0]);
Arrays.sort(keyArray);
//拼接有序的参数串
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(appSecret);
for (String key : keyArray) {
stringBuilder.append(key).append(paramMap.get(key));
}
stringBuilder.append(appSecret);
String signSource = stringBuilder.toString();
String sign = org.apache.commons.codec.digest.DigestUtils.md5Hex(signSource).toUpperCase();
return sign;
}
}
server.port=33654
spring.application.name=live
ACTIVE=${spring.profiles.active}
spring.profiles.active=sit
# nacos
spring.cloud.nacos.config.shared-dataids=common-${spring.profiles.active}.properties
spring.cloud.nacos.config.namespace=${spring.profiles.active}
spring.cloud.nacos.config.prefix=${spring.application.name}
spring.cloud.nacos.config.file-extension=properties
#spring.cloud.nacos.config.server-addr=192.168.0.203:8848
#spring.cloud.nacos.config.na
#spring.cloud.nacos.config.server-addr=192.168.1.22:3333,192.168.1.22:4444,192.168.1.22:5555
spring.cloud.nacos.config.server-addr=192.168.1.13:3333,192.168.1.24:4444,192.168.1.38:5555
#回放表新增、修改字段
ALTER TABLE `live_replay` add COLUMN top_time datetime DEFAULT NULL COMMENT '直播回放置顶时间';
ALTER TABLE `live_replay` add COLUMN image_desc varchar(255) DEFAULT NULL COMMENT '图片说明';
ALTER TABLE `live_replay` MODIFY live_replay_status bit(1) DEFAULT b'1' COMMENT '直播回放状态 1: 上架 0:下架';
ALTER TABLE `live_replay` MODIFY id bigint(20) NOT NULL COMMENT '主键';
#直播表默认回放开关状态修改
ALTER TABLE `live_activity` MODIFY replay_status bit(1) DEFAULT b'0' COMMENT '直播回放开关状态 1: 开 0:关闭';
\ No newline at end of file
#新增排序字段
ALTER TABLE live_activity add sort INT(11) DEFAULT '999' COMMENT '直播排序;默认999';
#门户装修-移动端 头部导航 新增直播功能项
INSERT INTO `cloud_portal`.`site_dic` (`id`, `parent_id`, `name`, `code`, `des`, `img_url`, `status`, `type`, `create_time`, `update_time`, `sort`, `backup_desc`) VALUES ('134', '15', '直播', 'live', '直播', NULL, '1', '29', '2020-12-03 11:05:54', '2020-12-03 11:05:54', NULL, '0');
#门户装修-pc 头部导航 新增直播功能项
INSERT INTO `cloud_portal`.`site_dic` (`id`, `parent_id`, `name`, `code`, `des`, `img_url`, `status`, `type`, `create_time`, `update_time`, `sort`, `backup_desc`) VALUES ('135', '32', '我的直播', 'live', '直播', NULL, '1', '29', '2020-12-03 18:09:10', '2020-12-03 18:09:10', NULL, '0');
#门户装修-pc 新增模块配置选项
INSERT INTO `cloud_portal`.`site_dic` (`id`, `parent_id`, `name`, `code`, `des`, `img_url`, `status`, `type`, `create_time`, `update_time`, `sort`, `backup_desc`) VALUES ('136', '7', '直播', 'live', '直播', NULL, '1', '15', '2020-12-07 15:43:50', '2020-12-07 15:43:50', NULL, '0');
/* 2:32:35 PM yz-dev-开发 cloud_live */
ALTER TABLE `live_activity` ADD `status` INT NULL DEFAULT NULL COMMENT '直播状态 10:未开始 40:直播中 90:已结束' AFTER `sort`;
/* 2:33:35 PM yz-dev-开发 cloud_live */
ALTER TABLE `live_activity` ADD `replay_status` INT NULL DEFAULT NULL COMMENT '直播回放开关状态 1: 开 0:关闭' AFTER `status`;
/* 2:36:59 PM yz-dev-开发 cloud_live */
ALTER TABLE `live_activity` CHANGE `replay_status` `replay_status` BIT(1) NULL DEFAULT 1 COMMENT '直播回放开关状态 1: 开 0:关闭';
/* 2:38:35 PM yz-dev-开发 cloud_live */
ALTER TABLE `live_activity` ADD `replay_callback_status` BIT(1) NULL DEFAULT 0 COMMENT '直播回放回调状态 1:已回调 0:未回调' AFTER `replay_status`;
#直播回放表
-- ----------------------------
-- Table structure for live_replay
-- ----------------------------
CREATE TABLE `live_replay` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`live_id` bigint(20) DEFAULT NULL COMMENT '直播ID',
`live_status` int(11) DEFAULT NULL COMMENT '直播状态 10:未开始 40:直播中 90:已结束',
`live_replay_status` bit(1) DEFAULT b'1' COMMENT '直播回放开关状态 1: 开 0:关闭',
`live_plan_start_at` datetime DEFAULT NULL COMMENT '直播计划开始时间',
`live_logo_url` varchar(128) DEFAULT NULL COMMENT '直播logo url',
`live_anchor` varchar(32) DEFAULT NULL COMMENT '主播名称',
`live_viewers` int(11) DEFAULT NULL COMMENT '直播观看人数',
`company_id` bigint(20) DEFAULT NULL,
`site_id` bigint(20) DEFAULT NULL,
`page_number` int(11) DEFAULT NULL COMMENT '视频列表页数(默认以12条数据为1页)',
`total_items` int(11) DEFAULT NULL COMMENT '回放视频总个数',
`video_id` varchar(64) DEFAULT NULL COMMENT '直播系统生成的id',
`video_pool_id` varchar(64) DEFAULT NULL COMMENT '点播视频ID',
`user_id` varchar(64) DEFAULT NULL COMMENT '点播后台用户id',
`channel_id` varchar(32) DEFAULT NULL COMMENT '回放视频对应的直播频道id',
`title` varchar(256) DEFAULT NULL COMMENT '视频标题',
`first_image` varchar(256) DEFAULT NULL COMMENT '视频首图',
`duration` varchar(32) DEFAULT NULL COMMENT '时长',
`my_br` int(11) DEFAULT NULL COMMENT '默认视频的播放清晰度,1为流畅,2为高清,3为超清',
`qid` text COMMENT '访客信息收集id',
`seed` bit(1) DEFAULT b'0' COMMENT '视频加密状态,1表示为加密状态,0为非加密',
`created_time` datetime DEFAULT NULL COMMENT '添加为回放视频的日期',
`last_modified` datetime DEFAULT NULL COMMENT '视频最后修改日期',
`rank` int(11) DEFAULT NULL COMMENT '回放排序',
`as_default` bit(11) DEFAULT b'1' COMMENT '是否为默认播放视频,值为1:Y 0:N',
`url` varchar(256) DEFAULT NULL COMMENT '视频播放地址,注:如果视频为加密视频,则此地址无法访问',
`file_id` varchar(64) DEFAULT NULL COMMENT '文件ID',
`file_url` varchar(512) DEFAULT NULL COMMENT '文件URL',
`watch_url` varchar(512) DEFAULT NULL COMMENT '观看URL',
`lang` varchar(32) DEFAULT NULL COMMENT '语言类型',
`channel_session_id` varchar(128) DEFAULT NULL COMMENT '用于PPT请求数据,与PPT直播的回放相关,普通直播回放值为null',
`merge_info` varchar(256) DEFAULT NULL COMMENT '视频合并信息,后续补充',
`start_time` datetime DEFAULT NULL COMMENT '直播开始时间',
`live_type` varchar(32) DEFAULT NULL COMMENT 'liveType alone, ppt',
`first_page` bit(11) DEFAULT b'1' COMMENT '是否为第一页,值为:1:true,0:false',
`last_page` bit(1) DEFAULT b'1' COMMENT '是否为最后一页,值为:1:true,0:false',
`next_page_number` int(11) DEFAULT NULL COMMENT '下一页编号',
`pre_page_number` int(11) DEFAULT NULL COMMENT '上一页编号',
`total_pages` int(11) DEFAULT NULL COMMENT '总页数',
`start_row` int(11) DEFAULT NULL COMMENT '当前页第一个视频在回放视频中的位置',
`end_row` int(11) DEFAULT NULL COMMENT '当前页最后一个视频在回放视频中的位置',
`created_at` datetime DEFAULT CURRENT_TIMESTAMP,
`updated_at` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE KEY `uni_video_pool_id` (`video_pool_id`),
KEY `idx_live_id` (`live_id`),
KEY `idx_cid` (`company_id`),
KEY `idx_siteId` (`site_id`),
KEY `idx_start_time` (`start_time`)
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8mb4;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.google.gson.JsonObject;
import com.yizhi.live.application.LiveApplication;
import com.yizhi.live.application.constant.PolyvResponseVO;
import com.yizhi.live.application.constant.PolyvUpdatePO;
import com.yizhi.live.application.constant.UtilConstants;
import com.yizhi.live.application.domain.LiveReplay;
import com.yizhi.live.application.enums.LiveStatusV2;
import com.yizhi.live.application.jobhandler.PolyvReplayLogHandler;
import com.yizhi.live.application.util.PolyvUtils;
import com.yizhi.live.application.vo.PolyvResponseVo;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.omg.CORBA.OBJ_ADAPTER;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @Date 2020/12/8 4:02 下午
* @Author lvjianhui
**/
//@Ignore
//@SpringBootTest(classes = LiveApplication.class)
//@RunWith(SpringRunner.class)
public class PolyvTest {
@Test
public void test() {
LiveStatusV2 status = PolyvUtils.getLiveStatus("2061401", DateUtil.parse("2020-12-22 01:45:00").toJdkDate(),DateUtil.parse("2020-12-22 01:55:00").toJdkDate(),null);
System.out.println("==========="+status.getCode());
// List<LiveReplay> list = PolyvUtils.getChannelReplay("2019615");
// System.out.println(JSONObject.toJSONString(list));
// PolyvUpdatePO po = new PolyvUpdatePO();
// po.setName("070直播修改测试22222");
// System.out.println(JSONObject.toJSONString(PolyvUtils.updateChannelParams("1820239", po,true,"","")));
//
// Map params = new HashMap<String,Object>();
// params.put("appId", UtilConstants.APP_ID);
// params.put("timestamp", System.currentTimeMillis());
// System.out.println(PolyvUtils.execPolyvApi(null, params, "http://api.polyv.net/live/v2/channels/1820239/get", null));
//
//// String url = String.format(UtilConstants.LIVE_REPLAY_LIST,2016376);
// Map<String,Object> params = new HashMap<>();
// params.put("appId",UtilConstants.APP_ID);
// params.put("timestamp",System.currentTimeMillis()+"");
// params.put("page","0");
// PolyvResponseVo<JSONObject> reslut = PolyvUtils.execPolyvApi(params,url);
//
// JSONArray listObject = (JSONArray) reslut.getData().get("contents");
//
// List<LiveReplay> list = JSONObject.parseArray(JSONObject.toJSONString(listObject),LiveReplay.class);
// System.out.println(JSONObject.toJSONString(listObject.get(0)));
// System.out.println(JSONObject.toJSONString(list.get(0)));
}
// @Autowired
// private PolyvReplayLogHandler polyvReplayLogHandler;
//
// @Test
// public void insertReplay() {
// polyvReplayLogHandler.insertLiveReplay();
// }
}
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.yizhi</groupId>
<artifactId>wmy-parent</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath/>
</parent>
<groupId>com.yizhi</groupId>
<artifactId>cloud-live</artifactId>
<version>1.0-SNAPSHOT</version>
<modules>
<module>cloud-live-api</module>
<module>cloud-live-service</module>
</modules>
<packaging>pom</packaging>
<repositories>
<repository>
<id>wmy4.0</id>
<url>http://mvn.km365.pw/nexus/content/groups/wmy4.0-group/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
</project>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment