Commit ebcc6fd1abb0438e38ebc40a3b9ede1b9b7e9b0c
1 parent
3964eb4c
直播开发测试
Showing
6 changed files
with
529 additions
and
53 deletions
src/main/java/com/cnlive/shenhe/api/LiveControllerApi.java
| @@ -5,15 +5,23 @@ import com.alibaba.fastjson.JSONArray; | @@ -5,15 +5,23 @@ import com.alibaba.fastjson.JSONArray; | ||
| 5 | import com.alibaba.fastjson.JSONObject; | 5 | import com.alibaba.fastjson.JSONObject; |
| 6 | import com.cnlive.shenhe.bean.ErrorEnum; | 6 | import com.cnlive.shenhe.bean.ErrorEnum; |
| 7 | import com.cnlive.shenhe.bean.ResponseBean; | 7 | import com.cnlive.shenhe.bean.ResponseBean; |
| 8 | +import com.cnlive.shenhe.entity.ShyLive; | ||
| 9 | +import com.cnlive.shenhe.entity.ShyVideos; | ||
| 10 | +import com.cnlive.shenhe.serviceImpl.LiveServiceImpl; | ||
| 11 | +import com.cnlive.shenhe.serviceImpl.VideosServiceImpl; | ||
| 8 | import com.cnlive.shenhe.utils.AntiFraudUtil; | 12 | import com.cnlive.shenhe.utils.AntiFraudUtil; |
| 13 | +import com.cnlive.shenhe.utils.CommonUtils; | ||
| 9 | 14 | ||
| 15 | +import java.util.Date; | ||
| 10 | import java.util.HashMap; | 16 | import java.util.HashMap; |
| 17 | +import java.util.List; | ||
| 11 | import java.util.Map; | 18 | import java.util.Map; |
| 12 | import java.util.UUID; | 19 | import java.util.UUID; |
| 13 | 20 | ||
| 14 | import org.apache.commons.lang3.StringUtils; | 21 | import org.apache.commons.lang3.StringUtils; |
| 15 | import org.slf4j.Logger; | 22 | import org.slf4j.Logger; |
| 16 | import org.slf4j.LoggerFactory; | 23 | import org.slf4j.LoggerFactory; |
| 24 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 17 | import org.springframework.stereotype.Controller; | 25 | import org.springframework.stereotype.Controller; |
| 18 | import org.springframework.web.bind.annotation.PostMapping; | 26 | import org.springframework.web.bind.annotation.PostMapping; |
| 19 | import org.springframework.web.bind.annotation.RequestBody; | 27 | import org.springframework.web.bind.annotation.RequestBody; |
| @@ -27,27 +35,132 @@ import com.cnlive.shenhe.utils.AntiFraudUtil; | @@ -27,27 +35,132 @@ import com.cnlive.shenhe.utils.AntiFraudUtil; | ||
| 27 | @Controller | 35 | @Controller |
| 28 | @RequestMapping("/api/live") | 36 | @RequestMapping("/api/live") |
| 29 | public class LiveControllerApi { | 37 | public class LiveControllerApi { |
| 30 | - private static Logger logger = LoggerFactory.getLogger(LiveControllerApi.class); | ||
| 31 | - | ||
| 32 | - | 38 | + private static Logger logger = LoggerFactory.getLogger(LiveControllerApi.class); |
| 39 | + | ||
| 40 | + @Autowired | ||
| 41 | + LiveServiceImpl liveService; | ||
| 33 | 42 | ||
| 34 | @RequestMapping("/import") | 43 | @RequestMapping("/import") |
| 35 | @ResponseBody | 44 | @ResponseBody |
| 36 | - public JSONObject impotVideo(String param) { | 45 | + public JSONObject impotVideo(String data) { |
| 37 | JSONObject map = new JSONObject(); | 46 | JSONObject map = new JSONObject(); |
| 38 | JSONObject result = new JSONObject(); | 47 | JSONObject result = new JSONObject(); |
| 48 | + boolean YorN =true;//初始化一个请求数据库返回结果 | ||
| 39 | 49 | ||
| 50 | + logger.info("直播入库,data=====" + data); | ||
| 51 | + JSONObject json = JSONObject.parseObject(data); | ||
| 52 | + //获取所有参数 | ||
| 53 | + String activityId = json.getString("activityId");//直播活动id | ||
| 54 | + String activityName = json.getString("activityName");//直播活动名称 | ||
| 55 | + Integer activityStatus = Integer.parseInt(json.getString("activityStatus"));//直播活动状态 | ||
| 56 | + String channelId = json.getString("channelId");//直播频道id | ||
| 57 | + String mp4Url = json.getString("mp4Url");//rtmp直播流 | ||
| 58 | + String hlsUrl = json.getString("hlsUrl");//m3u8直播流 | ||
| 59 | + Integer spId = Integer.parseInt(json.getString("spId"));//spid | ||
| 60 | + String callback = json.getString("callback");//回调地址 | ||
| 61 | + Integer is_hot = Integer.parseInt(json.getString("priority"));//优先级 | ||
| 62 | + String coverImgUrl = json.getString("coverImgUrl");//封面 | ||
| 63 | + String activityIntro = json.getString("activityIntro");//活动描述 | ||
| 64 | + String playbackUrl = json.getString("playbackUrl");//回放地址 | ||
| 65 | + String startTime = json.getString("startTime");//开始时间 | ||
| 66 | + Date timestamp_start =null; | ||
| 67 | + if (CommonUtils.isNotEmpty(startTime)) { | ||
| 68 | + timestamp_start = CommonUtils.getTimestamp(startTime, "yyyy-MM-dd HH:mm:ss"); | ||
| 69 | + } | ||
| 70 | + String endTime = json.getString("endTime");//结束时间 | ||
| 71 | + Date timestamp_end =null; | ||
| 72 | + if (CommonUtils.isNotEmpty(endTime)) { | ||
| 73 | + timestamp_end = CommonUtils.getTimestamp(endTime, "yyyy-MM-dd HH:mm:ss"); | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | + ShyLive shylive1 = new ShyLive(); | ||
| 77 | + //得到直播活动id去查询是否已有 | ||
| 78 | + shylive1.setActivity_id(activityId); | ||
| 79 | + //查询一下 存在,更新 没有,插入 | ||
| 80 | + List<ShyLive> listshyLive = liveService.findshyLive(shylive1); | ||
| 40 | 81 | ||
| 82 | + if (listshyLive.size() > 0) { | ||
| 83 | + ShyLive shyLive = listshyLive.get(0); | ||
| 84 | + //封装数据入库 | ||
| 85 | + shyLive.setActivity_name(activityName);//设置直播活动名称 | ||
| 86 | + shyLive.setActivity_status(activityStatus);//设置直播活动状态 | ||
| 87 | + if(activityStatus==3){//发布直播 | ||
| 88 | + shyLive.setActivity_start_time(timestamp_start); | ||
| 89 | + shyLive.setAvsample_end_time(timestamp_end); | ||
| 90 | + }else if(activityStatus==1){//启动直播 | ||
| 91 | + shyLive.setActivity_start_time(CommonUtils.getCurrentTime()); | ||
| 92 | + }else if(activityStatus==2){//停止直播 | ||
| 93 | + shyLive.setAvsample_end_time(CommonUtils.getCurrentTime()); | ||
| 94 | + shyLive.setPlayback_url(playbackUrl);//回放地址 | ||
| 95 | + shyLive.setShenhe_state(3);//状态 1:未认领 2.已领未审,3:已审通过,4:已审拒绝 | ||
| 96 | + } | ||
| 97 | + shyLive.setActivity_intro(activityIntro);//直播活动简介 | ||
| 98 | + shyLive.setM3u8_url(hlsUrl);//m3u8直播流 | ||
| 99 | + shyLive.setRtmp_url(mp4Url);//rtmp直播流 | ||
| 100 | + shyLive.setCallback(callback);//回调地址 | ||
| 101 | + shyLive.setCover_img_url(coverImgUrl);//封面 | ||
| 102 | + shyLive.setIs_hot(is_hot);//是否热点(优先级) | ||
| 103 | + shyLive.setShenhe_type(3);//审核类型,1:免审,2:机审,3:人工审 | ||
| 104 | + shyLive.setAvsample_state(1);//抽帧状态 1:不抽帧 2:待抽帧 3:抽帧中 4:抽帧完成 5:抽帧失败 | ||
| 105 | + if(activityStatus==0){//直播撤销 | ||
| 106 | + shyLive.setIs_show(0);//是否显示 0:不显示 1:显示 | ||
| 107 | + }else{ | ||
| 108 | + shyLive.setIs_show(1); | ||
| 109 | + } | ||
| 110 | + shyLive.setUpdated_at(CommonUtils.getCurrentTime());//更新时间 | ||
| 111 | + | ||
| 112 | + YorN = liveService.updateshyLive(shyLive); | ||
| 113 | + }else{ | ||
| 114 | + //查了,没有,直接插入数据库 | ||
| 115 | + shylive1.setActivity_id(activityId);//设置直播活动id | ||
| 116 | + shylive1.setActivity_name(activityName);//设置直播活动名称 | ||
| 117 | + shylive1.setActivity_status(activityStatus);//设置直播活动状态 | ||
| 118 | + shylive1.setChannel_id(channelId);//设置直播频道 | ||
| 119 | + shylive1.setShenhe_state(1);//状态 1:未认领 2.已领未审,3:已审通过,4:已审拒绝 | ||
| 120 | + if(activityStatus==3){//发布直播 | ||
| 121 | + shylive1.setActivity_start_time(timestamp_start); | ||
| 122 | + shylive1.setAvsample_end_time(timestamp_end); | ||
| 123 | + }else if(activityStatus==1){//启动直播 | ||
| 124 | + shylive1.setActivity_start_time(CommonUtils.getCurrentTime()); | ||
| 125 | + shylive1.setAvsample_end_time(timestamp_end); | ||
| 126 | + }else if(activityStatus==2){//停止直播 | ||
| 127 | + shylive1.setActivity_start_time(timestamp_start); | ||
| 128 | + shylive1.setAvsample_end_time(CommonUtils.getCurrentTime()); | ||
| 129 | + shylive1.setPlayback_url(playbackUrl);//回放地址 | ||
| 130 | + shylive1.setShenhe_state(3);//状态 1:未认领 2.已领未审,3:已审通过,4:已审拒绝 | ||
| 131 | + } | ||
| 132 | + shylive1.setActivity_intro(activityIntro);//直播活动简介 | ||
| 133 | + shylive1.setM3u8_url(hlsUrl);//m3u8直播流 | ||
| 134 | + shylive1.setRtmp_url(mp4Url);//rtmp直播流 | ||
| 135 | + shylive1.setCallback(callback);//回调地址 | ||
| 136 | + shylive1.setCover_img_url(coverImgUrl);//封面 | ||
| 137 | + shylive1.setIs_hot(is_hot);//是否热点(优先级) | ||
| 138 | + shylive1.setShenhe_type(3);//审核类型,1:免审,2:机审,3:人工审 | ||
| 139 | + shylive1.setAvsample_state(1);//抽帧状态 1:不抽帧 2:待抽帧 3:抽帧中 4:抽帧完成 5:抽帧失败 | ||
| 140 | + if(activityStatus==0){//直播撤销 | ||
| 141 | + shylive1.setIs_show(0);//是否显示 0:不显示 1:显示 | ||
| 142 | + }else{ | ||
| 143 | + shylive1.setIs_show(1); | ||
| 144 | + } | ||
| 145 | + | ||
| 146 | + shylive1.setCreated_at(CommonUtils.getCurrentTime());//创建时间 | ||
| 147 | + shylive1.setUpdated_at(CommonUtils.getCurrentTime());//更新时间 | ||
| 148 | + | ||
| 149 | + YorN = liveService.impotVideo(shylive1); | ||
| 150 | + } | ||
| 41 | 151 | ||
| 42 | - | ||
| 43 | - | ||
| 44 | - | ||
| 45 | - result.put("errorCode", "0"); | ||
| 46 | - result.put("errorMessage", "直播审核请求收到成功"); | ||
| 47 | - map.put("statusCode", "200"); | ||
| 48 | - map.put("result", result); | ||
| 49 | - | ||
| 50 | - return map; | 152 | + if (YorN == true) { |
| 153 | + result.put("errorCode", "0"); | ||
| 154 | + result.put("errorMessage", "直播审核请求收到成功"); | ||
| 155 | + map.put("statusCode", "200"); | ||
| 156 | + map.put("result", result); | ||
| 157 | + } else { | ||
| 158 | + result.put("errorCode", "-1"); | ||
| 159 | + result.put("errorMessage", "直播审核入库失败"); | ||
| 160 | + map.put("statusCode", "300"); | ||
| 161 | + map.put("result", result); | ||
| 162 | + } | ||
| 163 | + return map; | ||
| 51 | } | 164 | } |
| 52 | 165 | ||
| 53 | 166 |
src/main/java/com/cnlive/shenhe/controller/VideosStreamController.java renamed to src/main/java/com/cnlive/shenhe/controller/LiveController.java
| @@ -9,9 +9,11 @@ import com.alibaba.fastjson.JSONObject; | @@ -9,9 +9,11 @@ import com.alibaba.fastjson.JSONObject; | ||
| 9 | import com.cnlive.shenhe.bean.ErrorEnum; | 9 | import com.cnlive.shenhe.bean.ErrorEnum; |
| 10 | import com.cnlive.shenhe.bean.ResponseBean; | 10 | import com.cnlive.shenhe.bean.ResponseBean; |
| 11 | import com.cnlive.shenhe.bean.SessionUser; | 11 | import com.cnlive.shenhe.bean.SessionUser; |
| 12 | +import com.cnlive.shenhe.entity.ShyLive; | ||
| 12 | import com.cnlive.shenhe.entity.ShySites; | 13 | import com.cnlive.shenhe.entity.ShySites; |
| 13 | import com.cnlive.shenhe.entity.ShyUsers; | 14 | import com.cnlive.shenhe.entity.ShyUsers; |
| 14 | import com.cnlive.shenhe.entity.ShyVideos; | 15 | import com.cnlive.shenhe.entity.ShyVideos; |
| 16 | +import com.cnlive.shenhe.serviceImpl.LiveServiceImpl; | ||
| 15 | import com.cnlive.shenhe.serviceImpl.SitesServiceImpl; | 17 | import com.cnlive.shenhe.serviceImpl.SitesServiceImpl; |
| 16 | import com.cnlive.shenhe.serviceImpl.UsersServiceImpl; | 18 | import com.cnlive.shenhe.serviceImpl.UsersServiceImpl; |
| 17 | import com.cnlive.shenhe.serviceImpl.VideosServiceImpl; | 19 | import com.cnlive.shenhe.serviceImpl.VideosServiceImpl; |
| @@ -38,8 +40,8 @@ import java.util.List; | @@ -38,8 +40,8 @@ import java.util.List; | ||
| 38 | 40 | ||
| 39 | @Controller | 41 | @Controller |
| 40 | @RequestMapping("/live") | 42 | @RequestMapping("/live") |
| 41 | -public class VideosStreamController { | ||
| 42 | - private static Logger logger = LoggerFactory.getLogger(VideosStreamController.class); | 43 | +public class LiveController { |
| 44 | + private static Logger logger = LoggerFactory.getLogger(LiveController.class); | ||
| 43 | @Autowired | 45 | @Autowired |
| 44 | AuditPass Pass; | 46 | AuditPass Pass; |
| 45 | @Autowired | 47 | @Autowired |
| @@ -48,6 +50,8 @@ public class VideosStreamController { | @@ -48,6 +50,8 @@ public class VideosStreamController { | ||
| 48 | UsersServiceImpl usersService; | 50 | UsersServiceImpl usersService; |
| 49 | @Autowired | 51 | @Autowired |
| 50 | SitesServiceImpl sitesService; | 52 | SitesServiceImpl sitesService; |
| 53 | + @Autowired | ||
| 54 | + LiveServiceImpl liveService; | ||
| 51 | 55 | ||
| 52 | @Value("${qn_domain}") | 56 | @Value("${qn_domain}") |
| 53 | String qn_domain; | 57 | String qn_domain; |
| @@ -367,7 +371,7 @@ public class VideosStreamController { | @@ -367,7 +371,7 @@ public class VideosStreamController { | ||
| 367 | } | 371 | } |
| 368 | 372 | ||
| 369 | /** | 373 | /** |
| 370 | - * 打回(审核拒绝,应要求不加权限、状态等限制) | 374 | + * 打回(审核拒绝) |
| 371 | * | 375 | * |
| 372 | * @param ids | 376 | * @param ids |
| 373 | * @param msg | 377 | * @param msg |
| @@ -380,32 +384,32 @@ public class VideosStreamController { | @@ -380,32 +384,32 @@ public class VideosStreamController { | ||
| 380 | SessionUser sessionUser = (SessionUser) session.getAttribute(SessionUser.getSessionKey()); | 384 | SessionUser sessionUser = (SessionUser) session.getAttribute(SessionUser.getSessionKey()); |
| 381 | String userId = sessionUser.getUserId(); | 385 | String userId = sessionUser.getUserId(); |
| 382 | ResponseBean responseBean = new ResponseBean(); | 386 | ResponseBean responseBean = new ResponseBean(); |
| 383 | - String[] shyVideoIds = ids.split(","); | 387 | + String[] shyLiveIds = ids.split(","); |
| 384 | String showMsg = ""; | 388 | String showMsg = ""; |
| 385 | - for (String shyVideoId : shyVideoIds) { | ||
| 386 | - ShyVideos shyVideos = videosService.selectByPrimaryKey(Integer.parseInt(shyVideoId)); | 389 | + for (String shyLiveId : shyLiveIds) { |
| 390 | + ShyLive shyLive = liveService.selectByPrimaryKey(Integer.parseInt(shyLiveId)); | ||
| 387 | JSONObject result = null; | 391 | JSONObject result = null; |
| 388 | try { | 392 | try { |
| 389 | - result = Pass.auditPass(shyVideos.getVideo_id(), 4, msg, msg, shyVideos.getCallback()); | 393 | + result = Pass.auditPass(shyLive.getActivity_id(), 6, msg, msg, shyLive.getCallback()); |
| 390 | } catch (Exception e) { | 394 | } catch (Exception e) { |
| 391 | - logger.error("视频审核失败,id==" + shyVideoId, e); | ||
| 392 | - showMsg = showMsg + "," + shyVideos.getVideo_title() + " 拒绝请求失败"; | 395 | + logger.error("直播视频审核失败,id==" + shyLiveId, e); |
| 396 | + showMsg = showMsg + "," + shyLive.getActivity_id() + " 拒绝请求失败"; | ||
| 393 | break; | 397 | break; |
| 394 | } | 398 | } |
| 395 | if (result == null) { | 399 | if (result == null) { |
| 396 | - logger.error("视频审核失败且接口错误没有返回信息,id==" + shyVideoId); | ||
| 397 | - showMsg = showMsg + "," + shyVideos.getVideo_title() + " 拒绝请求失败"; | 400 | + logger.error("直播视频审核失败且接口错误没有返回信息,id==" + shyLiveId); |
| 401 | + showMsg = showMsg + "," + shyLive.getActivity_id() + " 拒绝请求失败"; | ||
| 398 | break; | 402 | break; |
| 399 | } | 403 | } |
| 400 | Integer code = result.getInteger("code"); | 404 | Integer code = result.getInteger("code"); |
| 401 | if (code != 0) { | 405 | if (code != 0) { |
| 402 | - logger.error("视频审核失败,id:{},code:{}", shyVideoId, code); | ||
| 403 | - showMsg = showMsg + "," + shyVideos.getVideo_title() + " " + result.getString("msg"); | 406 | + logger.error("直播视频审核失败,id:{},code:{}", shyLiveId, code); |
| 407 | + showMsg = showMsg + "," + shyLive.getActivity_id() + " " + result.getString("msg"); | ||
| 404 | break; | 408 | break; |
| 405 | } | 409 | } |
| 406 | - int i = videosService.updateVideo(Integer.parseInt(shyVideoId), userId,null,"", 2, msg); | 410 | + int i = liveService.updateLive(Integer.parseInt(shyLiveId), userId,null,"", 4, msg); |
| 407 | if (i == 0) { | 411 | if (i == 0) { |
| 408 | - showMsg = showMsg + "," + shyVideos.getVideo_title() + " 更新失败"; | 412 | + showMsg = showMsg + "," + shyLive.getActivity_id() + " 更新失败"; |
| 409 | break; | 413 | break; |
| 410 | } | 414 | } |
| 411 | } | 415 | } |
src/main/java/com/cnlive/shenhe/entity/ShyLive.java
| @@ -29,14 +29,14 @@ public class ShyLive { | @@ -29,14 +29,14 @@ public class ShyLive { | ||
| 29 | private String activity_name; | 29 | private String activity_name; |
| 30 | 30 | ||
| 31 | /** | 31 | /** |
| 32 | - * 直播活动状态,1:直播中,2:直播完成,3:待直播,4:直播撤销 | 32 | + * 直播活动状态,1:直播中,2:直播完成,3:待直播,0:直播撤销 |
| 33 | */ | 33 | */ |
| 34 | - private Boolean activity_status; | 34 | + private Integer activity_status; |
| 35 | 35 | ||
| 36 | /** | 36 | /** |
| 37 | * 直播活动开始时间 | 37 | * 直播活动开始时间 |
| 38 | */ | 38 | */ |
| 39 | - private String activity_start_time; | 39 | + private Date activity_start_time; |
| 40 | 40 | ||
| 41 | /** | 41 | /** |
| 42 | * 直播活动结束时间 | 42 | * 直播活动结束时间 |
| @@ -76,17 +76,17 @@ public class ShyLive { | @@ -76,17 +76,17 @@ public class ShyLive { | ||
| 76 | /** | 76 | /** |
| 77 | * 是否是热点: 0:全部 ,1:不是 ,2: 是 | 77 | * 是否是热点: 0:全部 ,1:不是 ,2: 是 |
| 78 | */ | 78 | */ |
| 79 | - private Boolean is_hot; | 79 | + private Integer is_hot; |
| 80 | 80 | ||
| 81 | /** | 81 | /** |
| 82 | * 审核类型,1:免审,2:机审,3:人工审 | 82 | * 审核类型,1:免审,2:机审,3:人工审 |
| 83 | */ | 83 | */ |
| 84 | - private Boolean shenhe_type; | 84 | + private Integer shenhe_type; |
| 85 | 85 | ||
| 86 | /** | 86 | /** |
| 87 | * 状态 1:未认领 2.已领未审,3:已审通过,4:已审拒绝 | 87 | * 状态 1:未认领 2.已领未审,3:已审通过,4:已审拒绝 |
| 88 | */ | 88 | */ |
| 89 | - private Boolean shenhe_state; | 89 | + private Integer shenhe_state; |
| 90 | 90 | ||
| 91 | /** | 91 | /** |
| 92 | * 更新者 | 92 | * 更新者 |
| @@ -104,6 +104,11 @@ public class ShyLive { | @@ -104,6 +104,11 @@ public class ShyLive { | ||
| 104 | private String shenhe_msg; | 104 | private String shenhe_msg; |
| 105 | 105 | ||
| 106 | /** | 106 | /** |
| 107 | + * 抽帧状态 1:不抽帧 2:待抽帧 3:抽帧中 4:抽帧完成 5:抽帧失败 | ||
| 108 | + */ | ||
| 109 | + private Integer avsample_state; | ||
| 110 | + | ||
| 111 | + /** | ||
| 107 | * 抽帧开始时间 | 112 | * 抽帧开始时间 |
| 108 | */ | 113 | */ |
| 109 | private Date avsample_start_time; | 114 | private Date avsample_start_time; |
| @@ -116,7 +121,7 @@ public class ShyLive { | @@ -116,7 +121,7 @@ public class ShyLive { | ||
| 116 | /** | 121 | /** |
| 117 | * 是否显示 0:不显示 1:显示 | 122 | * 是否显示 0:不显示 1:显示 |
| 118 | */ | 123 | */ |
| 119 | - private Boolean is_show; | 124 | + private Integer is_show; |
| 120 | 125 | ||
| 121 | private Date created_at; | 126 | private Date created_at; |
| 122 | 127 | ||
| @@ -223,7 +228,7 @@ public class ShyLive { | @@ -223,7 +228,7 @@ public class ShyLive { | ||
| 223 | * | 228 | * |
| 224 | * @return activity_status - 直播活动状态,1:直播中,2:直播完成,3:待直播,4:直播撤销 | 229 | * @return activity_status - 直播活动状态,1:直播中,2:直播完成,3:待直播,4:直播撤销 |
| 225 | */ | 230 | */ |
| 226 | - public Boolean getActivity_status() { | 231 | + public Integer getActivity_status() { |
| 227 | return activity_status; | 232 | return activity_status; |
| 228 | } | 233 | } |
| 229 | 234 | ||
| @@ -232,7 +237,7 @@ public class ShyLive { | @@ -232,7 +237,7 @@ public class ShyLive { | ||
| 232 | * | 237 | * |
| 233 | * @param activity_status 直播活动状态,1:直播中,2:直播完成,3:待直播,4:直播撤销 | 238 | * @param activity_status 直播活动状态,1:直播中,2:直播完成,3:待直播,4:直播撤销 |
| 234 | */ | 239 | */ |
| 235 | - public void setActivity_status(Boolean activity_status) { | 240 | + public void setActivity_status(Integer activity_status) { |
| 236 | this.activity_status = activity_status; | 241 | this.activity_status = activity_status; |
| 237 | } | 242 | } |
| 238 | 243 | ||
| @@ -241,7 +246,7 @@ public class ShyLive { | @@ -241,7 +246,7 @@ public class ShyLive { | ||
| 241 | * | 246 | * |
| 242 | * @return activity_start_time - 直播活动开始时间 | 247 | * @return activity_start_time - 直播活动开始时间 |
| 243 | */ | 248 | */ |
| 244 | - public String getActivity_start_time() { | 249 | + public Date getActivity_start_time() { |
| 245 | return activity_start_time; | 250 | return activity_start_time; |
| 246 | } | 251 | } |
| 247 | 252 | ||
| @@ -250,7 +255,7 @@ public class ShyLive { | @@ -250,7 +255,7 @@ public class ShyLive { | ||
| 250 | * | 255 | * |
| 251 | * @param activity_start_time 直播活动开始时间 | 256 | * @param activity_start_time 直播活动开始时间 |
| 252 | */ | 257 | */ |
| 253 | - public void setActivity_start_time(String activity_start_time) { | 258 | + public void setActivity_start_time(Date activity_start_time) { |
| 254 | this.activity_start_time = activity_start_time; | 259 | this.activity_start_time = activity_start_time; |
| 255 | } | 260 | } |
| 256 | 261 | ||
| @@ -385,7 +390,7 @@ public class ShyLive { | @@ -385,7 +390,7 @@ public class ShyLive { | ||
| 385 | * | 390 | * |
| 386 | * @return is_hot - 是否是热点: 0:全部 ,1:不是 ,2: 是 | 391 | * @return is_hot - 是否是热点: 0:全部 ,1:不是 ,2: 是 |
| 387 | */ | 392 | */ |
| 388 | - public Boolean getIs_hot() { | 393 | + public Integer getIs_hot() { |
| 389 | return is_hot; | 394 | return is_hot; |
| 390 | } | 395 | } |
| 391 | 396 | ||
| @@ -394,7 +399,7 @@ public class ShyLive { | @@ -394,7 +399,7 @@ public class ShyLive { | ||
| 394 | * | 399 | * |
| 395 | * @param is_hot 是否是热点: 0:全部 ,1:不是 ,2: 是 | 400 | * @param is_hot 是否是热点: 0:全部 ,1:不是 ,2: 是 |
| 396 | */ | 401 | */ |
| 397 | - public void setIs_hot(Boolean is_hot) { | 402 | + public void setIs_hot(Integer is_hot) { |
| 398 | this.is_hot = is_hot; | 403 | this.is_hot = is_hot; |
| 399 | } | 404 | } |
| 400 | 405 | ||
| @@ -403,7 +408,7 @@ public class ShyLive { | @@ -403,7 +408,7 @@ public class ShyLive { | ||
| 403 | * | 408 | * |
| 404 | * @return shenhe_type - 审核类型,1:免审,2:机审,3:人工审 | 409 | * @return shenhe_type - 审核类型,1:免审,2:机审,3:人工审 |
| 405 | */ | 410 | */ |
| 406 | - public Boolean getShenhe_type() { | 411 | + public Integer getShenhe_type() { |
| 407 | return shenhe_type; | 412 | return shenhe_type; |
| 408 | } | 413 | } |
| 409 | 414 | ||
| @@ -412,7 +417,7 @@ public class ShyLive { | @@ -412,7 +417,7 @@ public class ShyLive { | ||
| 412 | * | 417 | * |
| 413 | * @param shenhe_type 审核类型,1:免审,2:机审,3:人工审 | 418 | * @param shenhe_type 审核类型,1:免审,2:机审,3:人工审 |
| 414 | */ | 419 | */ |
| 415 | - public void setShenhe_type(Boolean shenhe_type) { | 420 | + public void setShenhe_type(Integer shenhe_type) { |
| 416 | this.shenhe_type = shenhe_type; | 421 | this.shenhe_type = shenhe_type; |
| 417 | } | 422 | } |
| 418 | 423 | ||
| @@ -421,7 +426,7 @@ public class ShyLive { | @@ -421,7 +426,7 @@ public class ShyLive { | ||
| 421 | * | 426 | * |
| 422 | * @return shenhe_state - 状态 1:未认领 2.已领未审,3:已审通过,4:已审拒绝 | 427 | * @return shenhe_state - 状态 1:未认领 2.已领未审,3:已审通过,4:已审拒绝 |
| 423 | */ | 428 | */ |
| 424 | - public Boolean getShenhe_state() { | 429 | + public Integer getShenhe_state() { |
| 425 | return shenhe_state; | 430 | return shenhe_state; |
| 426 | } | 431 | } |
| 427 | 432 | ||
| @@ -430,7 +435,7 @@ public class ShyLive { | @@ -430,7 +435,7 @@ public class ShyLive { | ||
| 430 | * | 435 | * |
| 431 | * @param shenhe_state 状态 1:未认领 2.已领未审,3:已审通过,4:已审拒绝 | 436 | * @param shenhe_state 状态 1:未认领 2.已领未审,3:已审通过,4:已审拒绝 |
| 432 | */ | 437 | */ |
| 433 | - public void setShenhe_state(Boolean shenhe_state) { | 438 | + public void setShenhe_state(Integer shenhe_state) { |
| 434 | this.shenhe_state = shenhe_state; | 439 | this.shenhe_state = shenhe_state; |
| 435 | } | 440 | } |
| 436 | 441 | ||
| @@ -489,6 +494,24 @@ public class ShyLive { | @@ -489,6 +494,24 @@ public class ShyLive { | ||
| 489 | } | 494 | } |
| 490 | 495 | ||
| 491 | /** | 496 | /** |
| 497 | + * 获取抽帧状态 1:不抽帧 2:待抽帧 3:抽帧中 4:抽帧完成 5:抽帧失败 | ||
| 498 | + * | ||
| 499 | + * @return avsample_state - 抽帧状态 1:不抽帧 2:待抽帧 3:抽帧中 4:抽帧完成 5:抽帧失败 | ||
| 500 | + */ | ||
| 501 | + public Integer getAvsample_state() { | ||
| 502 | + return avsample_state; | ||
| 503 | + } | ||
| 504 | + | ||
| 505 | + /** | ||
| 506 | + * 设置抽帧状态 1:不抽帧 2:待抽帧 3:抽帧中 4:抽帧完成 5:抽帧失败 | ||
| 507 | + * | ||
| 508 | + * @param avsample_state 抽帧状态 1:不抽帧 2:待抽帧 3:抽帧中 4:抽帧完成 5:抽帧失败 | ||
| 509 | + */ | ||
| 510 | + public void setAvsample_state(Integer avsample_state) { | ||
| 511 | + this.avsample_state = avsample_state; | ||
| 512 | + } | ||
| 513 | + | ||
| 514 | + /** | ||
| 492 | * 获取抽帧开始时间 | 515 | * 获取抽帧开始时间 |
| 493 | * | 516 | * |
| 494 | * @return avsample_start_time - 抽帧开始时间 | 517 | * @return avsample_start_time - 抽帧开始时间 |
| @@ -529,7 +552,7 @@ public class ShyLive { | @@ -529,7 +552,7 @@ public class ShyLive { | ||
| 529 | * | 552 | * |
| 530 | * @return is_show - 是否显示 0:不显示 1:显示 | 553 | * @return is_show - 是否显示 0:不显示 1:显示 |
| 531 | */ | 554 | */ |
| 532 | - public Boolean getIs_show() { | 555 | + public Integer getIs_show() { |
| 533 | return is_show; | 556 | return is_show; |
| 534 | } | 557 | } |
| 535 | 558 | ||
| @@ -538,7 +561,7 @@ public class ShyLive { | @@ -538,7 +561,7 @@ public class ShyLive { | ||
| 538 | * | 561 | * |
| 539 | * @param is_show 是否显示 0:不显示 1:显示 | 562 | * @param is_show 是否显示 0:不显示 1:显示 |
| 540 | */ | 563 | */ |
| 541 | - public void setIs_show(Boolean is_show) { | 564 | + public void setIs_show(Integer is_show) { |
| 542 | this.is_show = is_show; | 565 | this.is_show = is_show; |
| 543 | } | 566 | } |
| 544 | 567 |
src/main/java/com/cnlive/shenhe/serviceImpl/LiveServiceImpl.java
0 → 100644
| 1 | +package com.cnlive.shenhe.serviceImpl; | ||
| 2 | + | ||
| 3 | +import com.alibaba.fastjson.JSON; | ||
| 4 | +import com.alibaba.fastjson.JSONArray; | ||
| 5 | +import com.alibaba.fastjson.JSONObject; | ||
| 6 | +import com.cnlive.shenhe.bean.ErrorEnum; | ||
| 7 | +import com.cnlive.shenhe.bean.ResponseBean; | ||
| 8 | +import com.cnlive.shenhe.entity.ShyLive; | ||
| 9 | +import com.cnlive.shenhe.entity.ShySites; | ||
| 10 | +import com.cnlive.shenhe.entity.ShyUsers; | ||
| 11 | +import com.cnlive.shenhe.entity.ShyUsersfree; | ||
| 12 | +import com.cnlive.shenhe.entity.ShyVideofilter; | ||
| 13 | +import com.cnlive.shenhe.entity.ShyVideos; | ||
| 14 | +import com.cnlive.shenhe.job.VideosJob; | ||
| 15 | +import com.cnlive.shenhe.mapper.ShyLiveMapper; | ||
| 16 | +import com.cnlive.shenhe.mapper.ShySitesMapper; | ||
| 17 | +import com.cnlive.shenhe.mapper.ShyUsersMapper; | ||
| 18 | +import com.cnlive.shenhe.mapper.ShyVideosMapper; | ||
| 19 | +import com.cnlive.shenhe.utils.AntiFraudUtil; | ||
| 20 | +import com.cnlive.shenhe.utils.AuditPass; | ||
| 21 | +import com.cnlive.shenhe.utils.CommonConst; | ||
| 22 | +import com.cnlive.shenhe.utils.CommonUtils; | ||
| 23 | +import com.github.pagehelper.PageHelper; | ||
| 24 | +import com.github.pagehelper.PageInfo; | ||
| 25 | + | ||
| 26 | + | ||
| 27 | +import org.apache.ibatis.session.RowBounds; | ||
| 28 | +import org.slf4j.Logger; | ||
| 29 | +import org.slf4j.LoggerFactory; | ||
| 30 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 31 | +import org.springframework.beans.factory.annotation.Value; | ||
| 32 | +import org.springframework.stereotype.Service; | ||
| 33 | +import tk.mybatis.mapper.entity.Example; | ||
| 34 | + | ||
| 35 | +import java.sql.Timestamp; | ||
| 36 | +import java.text.ParseException; | ||
| 37 | +import java.util.ArrayList; | ||
| 38 | +import java.util.Arrays; | ||
| 39 | +import java.util.HashMap; | ||
| 40 | +import java.util.List; | ||
| 41 | +import java.util.Map; | ||
| 42 | + | ||
| 43 | +/** | ||
| 44 | + * @Auther: chenhao | ||
| 45 | + * @Date: 2018/11/30 14:23 | ||
| 46 | + * @Description: | ||
| 47 | + */ | ||
| 48 | +@Service | ||
| 49 | +public class LiveServiceImpl { | ||
| 50 | + private static Logger logger = LoggerFactory.getLogger(LiveServiceImpl.class); | ||
| 51 | + @Autowired | ||
| 52 | + ShyVideosMapper shyVideosMapper; | ||
| 53 | + @Autowired | ||
| 54 | + ShyLiveMapper shyLiveMapper; | ||
| 55 | + @Autowired | ||
| 56 | + ShySitesMapper shySitesMapper; | ||
| 57 | + @Autowired | ||
| 58 | + ShyUsersMapper shyUsersMapper; | ||
| 59 | + | ||
| 60 | + @Autowired | ||
| 61 | + LiveServiceImpl videosService; | ||
| 62 | + @Autowired | ||
| 63 | + SitesServiceImpl sitesService; | ||
| 64 | + | ||
| 65 | + @Autowired | ||
| 66 | + UsersfreeServiceImpl usersfreeServiceImpl; | ||
| 67 | + | ||
| 68 | + @Autowired | ||
| 69 | + VideofilterServiceImpl videofilterServiceImpl; | ||
| 70 | + | ||
| 71 | + @Value("${qn_domain}") | ||
| 72 | + String qn_domain; | ||
| 73 | + | ||
| 74 | + @Value("${ks_domain}") | ||
| 75 | + String ks_domain; | ||
| 76 | + | ||
| 77 | + @Autowired | ||
| 78 | + AuditPass Pass; | ||
| 79 | + | ||
| 80 | + //============== | ||
| 81 | + public boolean impotVideo(ShyLive shyLive) { | ||
| 82 | + int result = shyLiveMapper.insertSelective(shyLive); | ||
| 83 | + if (result == 0) { | ||
| 84 | + return false; | ||
| 85 | + } | ||
| 86 | + return true; | ||
| 87 | + } | ||
| 88 | + | ||
| 89 | + //============== | ||
| 90 | + public ShyLive selectByPrimaryKey(Integer id) { | ||
| 91 | + ShyLive shyLive = shyLiveMapper.selectByPrimaryKey(id); | ||
| 92 | + return shyLive; | ||
| 93 | + } | ||
| 94 | + | ||
| 95 | + //============= | ||
| 96 | + public List<ShyLive> findshyLive(ShyLive shyLive) { | ||
| 97 | + List<ShyLive> shyLivelist = shyLiveMapper.selectByRowBounds(shyLive, new RowBounds(0, 100)); | ||
| 98 | + return shyLivelist; | ||
| 99 | + } | ||
| 100 | + | ||
| 101 | + //============== | ||
| 102 | + public boolean updateshyLive(ShyLive shyLive) { | ||
| 103 | + int i = shyLiveMapper.updateByPrimaryKey(shyLive); | ||
| 104 | + if (i == 0) { | ||
| 105 | + return false; | ||
| 106 | + } | ||
| 107 | + return true; | ||
| 108 | + } | ||
| 109 | + | ||
| 110 | + //============== | ||
| 111 | + public int updateLive(Integer id, String auditor_id,String updater,String attr_tags, Integer state, String msg) { | ||
| 112 | + ShyLive shyLive = shyLiveMapper.selectByPrimaryKey(id); | ||
| 113 | + shyLive.setAuditor(auditor_id); | ||
| 114 | + shyLive.setShenhe_state(state); | ||
| 115 | + shyLive.setShenhe_msg(msg); | ||
| 116 | + shyLive.setUpdater(updater); | ||
| 117 | + return shyLiveMapper.updateByPrimaryKey(shyLive); | ||
| 118 | + } | ||
| 119 | + | ||
| 120 | + public PageInfo<ShyVideos> getListContent(String video_title, String start_date, String end_date, Integer state, Integer receive, Integer page, Integer pageSize, String video_priority, String orderByClause, Integer spid, String userId) { | ||
| 121 | + Example example = new Example(ShyVideos.class); | ||
| 122 | + Example.Criteria criteria = example.createCriteria(); | ||
| 123 | + Example.Criteria criteria2 = example.createCriteria(); | ||
| 124 | + if (CommonUtils.isNotEmpty(orderByClause)) { | ||
| 125 | + example.setOrderByClause(orderByClause); | ||
| 126 | + } | ||
| 127 | + if (CommonUtils.isNotEmpty(start_date) && CommonUtils.isNotEmpty(end_date)) { | ||
| 128 | + Timestamp startdate = null; | ||
| 129 | + Timestamp enddate = null; | ||
| 130 | + try { | ||
| 131 | +// startdate = CommonUtils.parseDate(start_date, "yyyy-MM-dd HH:mm:ss"); | ||
| 132 | +// enddate = CommonUtils.parseDate(end_date, "yyyy-MM-dd HH:mm:ss"); | ||
| 133 | + startdate = CommonUtils.parseDate(start_date, "yyyy-MM-dd"); | ||
| 134 | + enddate = CommonUtils.parseDate(end_date, "yyyy-MM-dd"); | ||
| 135 | + } catch (ParseException e) { | ||
| 136 | + e.printStackTrace(); | ||
| 137 | + } | ||
| 138 | + criteria.andGreaterThanOrEqualTo("created_at", startdate); | ||
| 139 | + criteria2.andGreaterThanOrEqualTo("created_at", startdate); | ||
| 140 | + criteria.andLessThanOrEqualTo("created_at", enddate); | ||
| 141 | + criteria2.andLessThanOrEqualTo("created_at", enddate); | ||
| 142 | + } | ||
| 143 | + if (CommonUtils.isNotEmpty(video_title)) { | ||
| 144 | + criteria.andLike("video_title", "%" + video_title + "%"); | ||
| 145 | + criteria2.andLike("video_title", "%" + video_title + "%"); | ||
| 146 | + } | ||
| 147 | + | ||
| 148 | + if (CommonUtils.isNotEmpty(video_priority)) { | ||
| 149 | + criteria.andEqualTo("video_priority", video_priority); | ||
| 150 | + criteria2.andEqualTo("video_priority", video_priority); | ||
| 151 | + } | ||
| 152 | + if (CommonUtils.isNotNull(spid)) { | ||
| 153 | + criteria.andEqualTo("spid", spid); | ||
| 154 | + criteria2.andEqualTo("spid", spid); | ||
| 155 | + } | ||
| 156 | + if (CommonUtils.isNotNull(receive)) { | ||
| 157 | + criteria.andEqualTo("receive", receive); | ||
| 158 | + criteria2.andEqualTo("receive", receive); | ||
| 159 | + if (receive == CommonConst.RECEIVE_AFTER) { | ||
| 160 | + criteria.andEqualTo("receive_user_id", userId); | ||
| 161 | + criteria2.andEqualTo("receive_user_id", userId); | ||
| 162 | + } | ||
| 163 | + } | ||
| 164 | + if (CommonUtils.isNotNull(state) && state == 0) { | ||
| 165 | + criteria.andEqualTo("state", state); | ||
| 166 | + } else if (CommonUtils.isNotNull(state) && state == 1) { | ||
| 167 | + criteria.andEqualTo("state", state); | ||
| 168 | + criteria2.andEqualTo("state", 2); | ||
| 169 | + example.or(criteria2); | ||
| 170 | + } | ||
| 171 | + //默认按上传时间倒序排序 | ||
| 172 | + example.setOrderByClause("created_at desc"); | ||
| 173 | + PageHelper.startPage(page, pageSize, true); | ||
| 174 | + List<ShyVideos> shyVideosList = shyVideosMapper.selectByExample(example); | ||
| 175 | + PageInfo<ShyVideos> pageInfo = new PageInfo<>(shyVideosList); | ||
| 176 | + return pageInfo; | ||
| 177 | + } | ||
| 178 | + | ||
| 179 | + public ShyVideos getDetailsContent(Integer id) { | ||
| 180 | + ShyVideos shyVideos = shyVideosMapper.selectByPrimaryKey(id); | ||
| 181 | + if (shyVideos.getState() != CommonConst.AUDIT_INTT) { | ||
| 182 | + String updater = CommonUtils.isEmpty(shyVideos.getUpdater()) || "null".equals(shyVideos.getUpdater())? "白名单":shyVideos.getUpdater(); | ||
| 183 | + String auditor_id = shyVideos.getAuditor_id(); | ||
| 184 | + if (CommonUtils.isNotEmpty(auditor_id)) { | ||
| 185 | + ShyUsers user = new ShyUsers(); | ||
| 186 | + user.setUser_id(auditor_id); | ||
| 187 | + user = shyUsersMapper.selectOne(user); | ||
| 188 | + String email = CommonUtils.isEmpty(user.getEmail()) || "null".equals(user.getEmail())? "" : user.getEmail(); | ||
| 189 | + String userName = CommonUtils.isEmpty(user.getUsername()) ? email: user.getUsername(); | ||
| 190 | + updater = userName; | ||
| 191 | + } | ||
| 192 | + shyVideos.setUpdater(updater); | ||
| 193 | + } | ||
| 194 | + return shyVideos; | ||
| 195 | + } | ||
| 196 | + | ||
| 197 | + public Integer receive(String ids, Integer num, String userId, Integer spid) { | ||
| 198 | + Integer n = 0; | ||
| 199 | + if (CommonUtils.isNotEmpty(ids)) { | ||
| 200 | + String[] cids = ids.split(","); | ||
| 201 | + for (String cid : cids) { | ||
| 202 | + ShyVideos shyVideos = shyVideosMapper.selectByPrimaryKey(Integer.parseInt(cid)); | ||
| 203 | + if (CommonUtils.isNotNull(shyVideos) && shyVideos.getState() == CommonConst.AUDIT_INTT && shyVideos.getReceive()==CommonConst.RECEIVE_BEFORE) { | ||
| 204 | + shyVideos.setReceive_user_id(userId); | ||
| 205 | + shyVideos.setReceive(CommonConst.RECEIVE_AFTER); | ||
| 206 | + shyVideosMapper.updateByPrimaryKeySelective(shyVideos); | ||
| 207 | + n++; | ||
| 208 | + } | ||
| 209 | + } | ||
| 210 | + } else if (CommonUtils.isNotNull(num) && num > 0) { | ||
| 211 | + Example example = new Example(ShyVideos.class); | ||
| 212 | + example.setOrderByClause("created_at desc"); | ||
| 213 | + example.and().andEqualTo("state", CommonConst.AUDIT_INTT); | ||
| 214 | + example.and().andEqualTo("receive", CommonConst.RECEIVE_BEFORE); | ||
| 215 | + if (CommonUtils.isNotNull(spid) && spid != 0) example.and().andEqualTo("spid", spid); | ||
| 216 | + List<ShyVideos> shyCommentsList = shyVideosMapper.selectByExampleAndRowBounds(example, new RowBounds(0, num)); | ||
| 217 | + if (!shyCommentsList.isEmpty()) { | ||
| 218 | + for (ShyVideos shyComments : shyCommentsList) { | ||
| 219 | + shyComments.setReceive_user_id(userId); | ||
| 220 | + shyComments.setReceive(CommonConst.RECEIVE_AFTER); | ||
| 221 | + shyVideosMapper.updateByPrimaryKeySelective(shyComments); | ||
| 222 | + n++; | ||
| 223 | + } | ||
| 224 | + } | ||
| 225 | + } | ||
| 226 | + return n; | ||
| 227 | + } | ||
| 228 | + | ||
| 229 | + public ResponseBean retReceive(String ids, String userId) { | ||
| 230 | + boolean result = true; | ||
| 231 | + String[] cids = ids.split(","); | ||
| 232 | + for (String cid : cids) { | ||
| 233 | + ShyVideos shyVideos = shyVideosMapper.selectByPrimaryKey(Integer.parseInt(cid)); | ||
| 234 | + if (shyVideos.getState() == CommonConst.AUDIT_INTT && shyVideos.getReceive()==CommonConst.RECEIVE_AFTER && shyVideos.getReceive_user_id().equals(userId)) { | ||
| 235 | + shyVideos.setReceive(CommonConst.RECEIVE_BEFORE); | ||
| 236 | + shyVideos.setReceive_user_id(null); | ||
| 237 | + int i = shyVideosMapper.updateByPrimaryKey(shyVideos); | ||
| 238 | + if (i != 1) { | ||
| 239 | + return new ResponseBean(ErrorEnum.ERROR.getErrorCode(), "退领失败,请重试"); | ||
| 240 | + } | ||
| 241 | + } else { | ||
| 242 | + return new ResponseBean(ErrorEnum.ERROR.getErrorCode(), "退领失败,您选中的内容包含已退领的或已经审核的"); | ||
| 243 | + } | ||
| 244 | + } | ||
| 245 | + return new ResponseBean(ErrorEnum.SUCCESS.getErrorCode(), "已退领"); | ||
| 246 | + } | ||
| 247 | + | ||
| 248 | + /** | ||
| 249 | + * 根据条件导出数据excel | ||
| 250 | + * | ||
| 251 | + * @param video_title | ||
| 252 | + * @param start_date | ||
| 253 | + * @param end_date | ||
| 254 | + * @param state | ||
| 255 | + * @param receive | ||
| 256 | + * @param video_priority | ||
| 257 | + * @param orderByClause | ||
| 258 | + * @param spid | ||
| 259 | + * @param userId | ||
| 260 | + * @return | ||
| 261 | + */ | ||
| 262 | + public List<ShyVideos> findByCondition(String video_title, String start_date, String end_date, Integer state, Integer receive, String video_priority, String orderByClause, Integer spid, String userId) { | ||
| 263 | + Example example = new Example(ShyVideos.class); | ||
| 264 | + Example.Criteria criteria = example.createCriteria(); | ||
| 265 | + Example.Criteria criteria2 = example.createCriteria(); | ||
| 266 | + if (CommonUtils.isNotEmpty(orderByClause)) { | ||
| 267 | + example.setOrderByClause(orderByClause); | ||
| 268 | + } | ||
| 269 | + if (CommonUtils.isNotEmpty(start_date) && CommonUtils.isNotEmpty(end_date)) { | ||
| 270 | + Timestamp startdate = null; | ||
| 271 | + Timestamp enddate = null; | ||
| 272 | + try { | ||
| 273 | +// startdate = CommonUtils.parseDate(start_date, "yyyy-MM-dd HH:mm:ss"); | ||
| 274 | +// enddate = CommonUtils.parseDate(end_date, "yyyy-MM-dd HH:mm:ss"); | ||
| 275 | + startdate = CommonUtils.parseDate(start_date, "yyyy-MM-dd"); | ||
| 276 | + enddate = CommonUtils.parseDate(end_date, "yyyy-MM-dd"); | ||
| 277 | + } catch (ParseException e) { | ||
| 278 | + e.printStackTrace(); | ||
| 279 | + } | ||
| 280 | + criteria.andGreaterThanOrEqualTo("created_at", startdate); | ||
| 281 | + criteria.andLessThanOrEqualTo("created_at", enddate); | ||
| 282 | + } | ||
| 283 | + if (CommonUtils.isNotEmpty(video_title)) { | ||
| 284 | + criteria.andLike("video_title", "%" + video_title + "%"); | ||
| 285 | + } | ||
| 286 | + if (CommonUtils.isNotNull(state) && state == 0) { | ||
| 287 | + criteria.andEqualTo("state", state); | ||
| 288 | + } else if (CommonUtils.isNotNull(state) && state == 1) { | ||
| 289 | + criteria.andEqualTo("state", state); | ||
| 290 | + criteria2.andEqualTo("state", 2); | ||
| 291 | + example.or(criteria2); | ||
| 292 | + } | ||
| 293 | + if (CommonUtils.isNotEmpty(video_priority)) { | ||
| 294 | + criteria.andEqualTo("video_priority", video_priority); | ||
| 295 | + } | ||
| 296 | + if (CommonUtils.isNotNull(spid)) { | ||
| 297 | + criteria.andEqualTo("spid", spid); | ||
| 298 | + } | ||
| 299 | + if (CommonUtils.isNotNull(receive)) { | ||
| 300 | + criteria.andEqualTo("receive", receive); | ||
| 301 | + if (receive == CommonConst.RECEIVE_AFTER) { | ||
| 302 | + criteria.andEqualTo("receive_user_id", userId); | ||
| 303 | + } | ||
| 304 | + } | ||
| 305 | + //默认按上传时间倒序排序 | ||
| 306 | + //example.setOrderByClause("video_upload_time desc"); | ||
| 307 | + List<ShyVideos> shyVideosList = shyVideosMapper.selectByExample(example); | ||
| 308 | + return shyVideosList; | ||
| 309 | + } | ||
| 310 | + | ||
| 311 | + | ||
| 312 | + | ||
| 313 | + | ||
| 314 | +} |
src/main/java/com/cnlive/shenhe/utils/AuditPass.java
| @@ -56,6 +56,27 @@ public class AuditPass { | @@ -56,6 +56,27 @@ public class AuditPass { | ||
| 56 | Map<String, String> post = httpUtil.post(URL); | 56 | Map<String, String> post = httpUtil.post(URL); |
| 57 | return JSONObject.parseObject(post.get("result")); | 57 | return JSONObject.parseObject(post.get("result")); |
| 58 | } | 58 | } |
| 59 | + /** | ||
| 60 | + * 直播视频回调 | ||
| 61 | + * | ||
| 62 | + * @param activity_id | ||
| 63 | + * @param state | ||
| 64 | + * @param attr_tags | ||
| 65 | + * @param msg | ||
| 66 | + * @return | ||
| 67 | + */ | ||
| 68 | + public JSONObject livePass(String activity_id, int state, String attr_tags, String msg, String callBack) { | ||
| 69 | + logger.info("点播回调:activity_id:{},state:{},attr_tags:{},msg:{}", activity_id, state, attr_tags, msg); | ||
| 70 | + JSONObject params = new JSONObject(); | ||
| 71 | + params.put("activity_id", activity_id); | ||
| 72 | + params.put("state", state); | ||
| 73 | + params.put("attr_tags", attr_tags); | ||
| 74 | + params.put("msg", msg); | ||
| 75 | + HttpUtil httpUtil = HttpUtil.init(); | ||
| 76 | + httpUtil.setParam("param", params.toJSONString()); | ||
| 77 | + Map<String, String> post = httpUtil.post(callBack); | ||
| 78 | + return JSONObject.parseObject(post.get("result")); | ||
| 79 | + } | ||
| 59 | 80 | ||
| 60 | /** | 81 | /** |
| 61 | * 评论打回回调 | 82 | * 评论打回回调 |
src/main/resources/mapper/ShyLiveMapper.xml
| @@ -10,8 +10,8 @@ | @@ -10,8 +10,8 @@ | ||
| 10 | <result column="channel_id" jdbcType="VARCHAR" property="channel_id" /> | 10 | <result column="channel_id" jdbcType="VARCHAR" property="channel_id" /> |
| 11 | <result column="activity_id" jdbcType="VARCHAR" property="activity_id" /> | 11 | <result column="activity_id" jdbcType="VARCHAR" property="activity_id" /> |
| 12 | <result column="activity_name" jdbcType="VARCHAR" property="activity_name" /> | 12 | <result column="activity_name" jdbcType="VARCHAR" property="activity_name" /> |
| 13 | - <result column="activity_status" jdbcType="BIT" property="activity_status" /> | ||
| 14 | - <result column="activity_start_time" jdbcType="VARCHAR" property="activity_start_time" /> | 13 | + <result column="activity_status" jdbcType="INTEGER" property="activity_status" /> |
| 14 | + <result column="activity_start_time" jdbcType="TIMESTAMP" property="activity_start_time" /> | ||
| 15 | <result column="activity_end_time" jdbcType="VARCHAR" property="activity_end_time" /> | 15 | <result column="activity_end_time" jdbcType="VARCHAR" property="activity_end_time" /> |
| 16 | <result column="activity_intro" jdbcType="VARCHAR" property="activity_intro" /> | 16 | <result column="activity_intro" jdbcType="VARCHAR" property="activity_intro" /> |
| 17 | <result column="m3u8_url" jdbcType="VARCHAR" property="m3u8_url" /> | 17 | <result column="m3u8_url" jdbcType="VARCHAR" property="m3u8_url" /> |
| @@ -19,15 +19,16 @@ | @@ -19,15 +19,16 @@ | ||
| 19 | <result column="callback" jdbcType="VARCHAR" property="callback" /> | 19 | <result column="callback" jdbcType="VARCHAR" property="callback" /> |
| 20 | <result column="cover_img_url" jdbcType="VARCHAR" property="cover_img_url" /> | 20 | <result column="cover_img_url" jdbcType="VARCHAR" property="cover_img_url" /> |
| 21 | <result column="playback_url" jdbcType="VARCHAR" property="playback_url" /> | 21 | <result column="playback_url" jdbcType="VARCHAR" property="playback_url" /> |
| 22 | - <result column="is_hot" jdbcType="BIT" property="is_hot" /> | ||
| 23 | - <result column="shenhe_type" jdbcType="BIT" property="shenhe_type" /> | ||
| 24 | - <result column="shenhe_state" jdbcType="BIT" property="shenhe_state" /> | 22 | + <result column="is_hot" jdbcType="INTEGER" property="is_hot" /> |
| 23 | + <result column="shenhe_type" jdbcType="INTEGER" property="shenhe_type" /> | ||
| 24 | + <result column="shenhe_state" jdbcType="INTEGER" property="shenhe_state" /> | ||
| 25 | <result column="updater" jdbcType="VARCHAR" property="updater" /> | 25 | <result column="updater" jdbcType="VARCHAR" property="updater" /> |
| 26 | <result column="auditor" jdbcType="VARCHAR" property="auditor" /> | 26 | <result column="auditor" jdbcType="VARCHAR" property="auditor" /> |
| 27 | <result column="shenhe_msg" jdbcType="VARCHAR" property="shenhe_msg" /> | 27 | <result column="shenhe_msg" jdbcType="VARCHAR" property="shenhe_msg" /> |
| 28 | + <result column="avsample_state" jdbcType="INTEGER" property="avsample_state" /> | ||
| 28 | <result column="avsample_start_time" jdbcType="TIMESTAMP" property="avsample_start_time" /> | 29 | <result column="avsample_start_time" jdbcType="TIMESTAMP" property="avsample_start_time" /> |
| 29 | <result column="avsample_end_time" jdbcType="TIMESTAMP" property="avsample_end_time" /> | 30 | <result column="avsample_end_time" jdbcType="TIMESTAMP" property="avsample_end_time" /> |
| 30 | - <result column="is_show" jdbcType="BIT" property="is_show" /> | 31 | + <result column="is_show" jdbcType="INTEGER" property="is_show" /> |
| 31 | <result column="created_at" jdbcType="TIMESTAMP" property="created_at" /> | 32 | <result column="created_at" jdbcType="TIMESTAMP" property="created_at" /> |
| 32 | <result column="updated_at" jdbcType="TIMESTAMP" property="updated_at" /> | 33 | <result column="updated_at" jdbcType="TIMESTAMP" property="updated_at" /> |
| 33 | <result column="avsample_imgs" jdbcType="LONGVARCHAR" property="avsample_imgs" /> | 34 | <result column="avsample_imgs" jdbcType="LONGVARCHAR" property="avsample_imgs" /> |