Commit 30a13de318666fe899bd2638879e37e453cec2b4
Merge branch 'dev'
Showing
7 changed files
with
288 additions
and
458 deletions
src/main/java/com/cnlive/shenhe/api/ChannelControllerApi.java
| ... | ... | @@ -45,7 +45,6 @@ public class ChannelControllerApi { |
| 45 | 45 | ShyChannel shyChannel = new ShyChannel(); |
| 46 | 46 | shyChannel.setChannel_id(json.getString("channelId")); |
| 47 | 47 | List<ShyChannel> channelList = channelService.findshyChannel(shyChannel); |
| 48 | - shyChannel.setCreated_at(CommonUtils.getCurrentTime()); | |
| 49 | 48 | Integer spId; |
| 50 | 49 | try { |
| 51 | 50 | spId = json.getInteger("spId"); |
| ... | ... | @@ -58,6 +57,8 @@ public class ChannelControllerApi { |
| 58 | 57 | yorN = saveOrUpdateChannel(shyChannel1, json, spId); |
| 59 | 58 | logger.info("频道修改操作"); |
| 60 | 59 | } else { |
| 60 | + // 创建频道时间 | |
| 61 | + shyChannel.setCreated_at(CommonUtils.getCurrentTime()); | |
| 61 | 62 | // 不存在则保存 |
| 62 | 63 | yorN = saveOrUpdateChannel(shyChannel, json, spId); |
| 63 | 64 | logger.info("频道保存操作"); | ... | ... |
src/main/java/com/cnlive/shenhe/api/CommentsControllerApi.java
| ... | ... | @@ -39,10 +39,6 @@ public class CommentsControllerApi { |
| 39 | 39 | logger.info("评论入库,param=====" + param); |
| 40 | 40 | JSONObject json = JSONObject.parseObject(param); |
| 41 | 41 | boolean yorN; |
| 42 | - //评论类型,topic:话题 | |
| 43 | - String type = json.getString("type") == null ? "else" : json.getString("type"); | |
| 44 | - //评论的级别 | |
| 45 | - Integer level = json.getInteger("level") == null ? 1 : json.getInteger("level"); | |
| 46 | 42 | String commentTime = json.getString("commentTime"); |
| 47 | 43 | Date timestamp = null; |
| 48 | 44 | if (CommonUtils.isNotEmpty(commentTime)) { |
| ... | ... | @@ -52,7 +48,6 @@ public class CommentsControllerApi { |
| 52 | 48 | ShyComments shyComments = new ShyComments(); |
| 53 | 49 | shyComments.setActivity_id(json.getString("activityId")); |
| 54 | 50 | List<ShyComments> commentsList = commentsService.findshyComments(shyComments); |
| 55 | - | |
| 56 | 51 | Integer spId = null; |
| 57 | 52 | try { |
| 58 | 53 | spId = json.getInteger("spId"); |
| ... | ... | @@ -61,11 +56,11 @@ public class CommentsControllerApi { |
| 61 | 56 | if (commentsList.size() > 0) { |
| 62 | 57 | //存在则更新 |
| 63 | 58 | ShyComments shyComments1 = commentsList.get(0); |
| 64 | - yorN = saveOrUpdateComments(json, shyComments1, type, level, spId, timestamp); | |
| 59 | + yorN = saveOrUpdateComments(json, shyComments1, spId, timestamp); | |
| 65 | 60 | logger.info("评论修改"); |
| 66 | 61 | } else { |
| 67 | 62 | // 不存在就保存 |
| 68 | - yorN = saveOrUpdateComments(json, shyComments, type, level, spId, timestamp); | |
| 63 | + yorN = saveOrUpdateComments(json, shyComments, spId, timestamp); | |
| 69 | 64 | logger.info("评论保存"); |
| 70 | 65 | } |
| 71 | 66 | if (yorN) { |
| ... | ... | @@ -82,7 +77,7 @@ public class CommentsControllerApi { |
| 82 | 77 | * @param shyComments |
| 83 | 78 | * @return |
| 84 | 79 | */ |
| 85 | - private boolean saveOrUpdateComments(JSONObject json, ShyComments shyComments, String type, Integer level, Integer spId, Date timestamp) { | |
| 80 | + private boolean saveOrUpdateComments(JSONObject json, ShyComments shyComments, Integer spId, Date timestamp) { | |
| 86 | 81 | shyComments.setState(CommonConst.AUDIT_INTT); |
| 87 | 82 | shyComments.setProgram_id(json.getString("programId")); |
| 88 | 83 | shyComments.setComment_original_url(json.getString("originalUrl")); |
| ... | ... | @@ -93,8 +88,8 @@ public class CommentsControllerApi { |
| 93 | 88 | shyComments.setComment_user_ip(json.getString("commentUserIP")); |
| 94 | 89 | shyComments.setComment_content(json.getString("commentContent")); |
| 95 | 90 | shyComments.setComment_time(timestamp); |
| 96 | - shyComments.setType(type); | |
| 97 | - shyComments.setLevel(level); | |
| 91 | + shyComments.setType(json.getString("type") == null ? "else" : json.getString("type")); | |
| 92 | + shyComments.setLevel(json.getInteger("level") == null ? 1 : json.getInteger("level")); | |
| 98 | 93 | shyComments.setSpid(spId); |
| 99 | 94 | shyComments.setApp_id(json.getString("appId")); |
| 100 | 95 | shyComments.setPlatform(json.getString("platform")); | ... | ... |
src/main/java/com/cnlive/shenhe/api/ContentControllerApi.java
| ... | ... | @@ -143,8 +143,6 @@ public class ContentControllerApi { |
| 143 | 143 | //朋友圈标签 |
| 144 | 144 | shyContent.setContent_tag("moment"); |
| 145 | 145 | List<ShyContent> contentList = contentService.findshyContent(shyContent); |
| 146 | - //当前朋友圈内容的审核状态,先发后审 | |
| 147 | - shyContent.setContent_status(1); | |
| 148 | 146 | //获取审核类型 |
| 149 | 147 | Integer shenheType = contentService.getShenheType(json.getInteger("spId"), "moment"); |
| 150 | 148 | //获取生活圈内容的类型 1:图片 2:视频 3:分享 |
| ... | ... | @@ -169,6 +167,8 @@ public class ContentControllerApi { |
| 169 | 167 | yorN = saveOrUpdateMoment(json, shyContent1, shenheType, contentImageUrl); |
| 170 | 168 | logger.info("朋友圈接口更新操作:{}", momentId); |
| 171 | 169 | } else { |
| 170 | + //当前朋友圈内容的审核状态,先发后审 | |
| 171 | + shyContent.setContent_status(1); | |
| 172 | 172 | //朋友圈不存在直接保存 |
| 173 | 173 | yorN = saveOrUpdateMoment(json, shyContent, shenheType, contentImageUrl); |
| 174 | 174 | logger.info("朋友圈接口保存操作:{}", momentId); | ... | ... |
src/main/java/com/cnlive/shenhe/api/LiveApplyControllerApi.java
| ... | ... | @@ -35,8 +35,7 @@ public class LiveApplyControllerApi { |
| 35 | 35 | JSONObject map = new JSONObject(); |
| 36 | 36 | JSONObject result = new JSONObject(); |
| 37 | 37 | //初始化一个请求数据库返回结果 |
| 38 | - boolean yorN = true; | |
| 39 | - | |
| 38 | + boolean yorN; | |
| 40 | 39 | logger.info("直播申请入库,param=====" + param); |
| 41 | 40 | JSONObject json = JSONObject.parseObject(param); |
| 42 | 41 | //获取所有参数 |
| ... | ... | @@ -49,36 +48,6 @@ public class LiveApplyControllerApi { |
| 49 | 48 | spId = json.getInteger("spId"); |
| 50 | 49 | } catch (Exception e) { |
| 51 | 50 | } |
| 52 | - //直播发起人 | |
| 53 | - String sender = json.getString("sender"); | |
| 54 | - //联系方式 | |
| 55 | - String mobile = json.getString("mobile"); | |
| 56 | - //回调地址 | |
| 57 | - String callback = json.getString("callback"); | |
| 58 | - //直播发起单位 | |
| 59 | - String organization = json.getString("organization"); | |
| 60 | - //直播主题 | |
| 61 | - String theme = json.getString("theme"); | |
| 62 | - //商务模式:0免费 1收费 | |
| 63 | - Integer businessModel = json.getInteger("businessModel"); | |
| 64 | - //内容属性:1商业类活动 0非商业活动 | |
| 65 | - Integer contentProperty = json.getInteger("contentProperty"); | |
| 66 | - //内容简述 | |
| 67 | - String simpleContent = json.getString("simpleContent"); | |
| 68 | - //直播类型 | |
| 69 | - String liveType = json.getString("liveType"); | |
| 70 | - //要点报备:0品牌植入 1广告植入 2商品推销 3网家家独家麦标 | |
| 71 | - String keys = json.getString("keys").equals("") ? "无" : json.getString("keys"); | |
| 72 | - //直播地点 | |
| 73 | - String livePlace = json.getString("livePlace"); | |
| 74 | - //推流地址 | |
| 75 | - String pushUrl = json.getString("pushUrl"); | |
| 76 | - //拉流地址 | |
| 77 | - String pullUrl = json.getString("pullUrl").equals("") ? "无拉流地址" : json.getString("pullUrl"); | |
| 78 | - //拉流来源 | |
| 79 | - String pullSource = json.getString("pullSource").equals("") ? "无来源" : json.getString("pullSource"); | |
| 80 | - //播出平台及通道:0网家家 1CNLive网站 2@TV互动电视 | |
| 81 | - String platforms = json.getString("platforms"); | |
| 82 | 51 | //预计开始时间 |
| 83 | 52 | String startTime = json.getString("preStartTime"); |
| 84 | 53 | Date timestampStart = null; |
| ... | ... | @@ -91,131 +60,99 @@ public class LiveApplyControllerApi { |
| 91 | 60 | if (CommonUtils.isNotEmpty(endTime)) { |
| 92 | 61 | timestampEnd = new Timestamp(Long.parseLong(endTime)); |
| 93 | 62 | } |
| 94 | - ShyLiveapply shyliveApply1 = new ShyLiveapply(); | |
| 63 | + ShyLiveapply shyliveApply = new ShyLiveapply(); | |
| 95 | 64 | //得到直播活动id去查询是否已有 |
| 96 | - shyliveApply1.setActivity_id(activityId); | |
| 65 | + shyliveApply.setActivity_id(activityId); | |
| 97 | 66 | //查询一下 存在,更新 没有,插入 |
| 98 | - List<ShyLiveapply> listshyLiveApply = liveApplyServiceImpl.findshyLiveApply(shyliveApply1); | |
| 67 | + List<ShyLiveapply> listshyLiveApply = liveApplyServiceImpl.findshyLiveApply(shyliveApply); | |
| 99 | 68 | |
| 100 | 69 | if (listshyLiveApply.size() > 0) { |
| 101 | - ShyLiveapply shyliveApply = listshyLiveApply.get(0); | |
| 102 | - //封装数据入库 | |
| 103 | - //设置spid | |
| 104 | - shyliveApply.setSp_id(spId); | |
| 105 | - //设置发送者 | |
| 106 | - shyliveApply.setSender(sender); | |
| 107 | - //设置联系方式 | |
| 108 | - shyliveApply.setMobile(mobile); | |
| 109 | - //设置直播发起单位 | |
| 110 | - shyliveApply.setOrganization(organization); | |
| 111 | - //直播主题 | |
| 112 | - shyliveApply.setTheme(theme); | |
| 113 | - //直播类型 | |
| 114 | - shyliveApply.setLive_type(liveType); | |
| 115 | - //预计开始时间 | |
| 116 | - shyliveApply.setPre_start_time(timestampStart); | |
| 117 | - //预计结束时间 | |
| 118 | - shyliveApply.setPre_end_time(timestampEnd); | |
| 119 | - //商务模式:0免费 1收费 | |
| 120 | - shyliveApply.setBusiness_model(businessModel); | |
| 121 | - //内容属性:1商业类活动 0非商业活动 | |
| 122 | - shyliveApply.setContent_property(contentProperty); | |
| 123 | - //内容简述 | |
| 124 | - shyliveApply.setSimple_content(simpleContent); | |
| 125 | - //要点报备:0品牌植入 1广告植入 2商品推销 3网家家独家麦标 | |
| 126 | - shyliveApply.setPoint_key(keys); | |
| 127 | - //直播地点 | |
| 128 | - shyliveApply.setLive_place(livePlace); | |
| 129 | - //推流地址 | |
| 130 | - shyliveApply.setPush_url(pushUrl); | |
| 131 | - //拉流地址 | |
| 132 | - shyliveApply.setPull_url(pullUrl); | |
| 133 | - //拉流来源 | |
| 134 | - shyliveApply.setPull_source(pullSource); | |
| 135 | - //播出平台及通道:0网家家 1CNLive网站 2@TV互动电视 | |
| 136 | - shyliveApply.setPlatforms(platforms); | |
| 137 | - //设置回调地址 | |
| 138 | - shyliveApply.setCallback(callback); | |
| 139 | - shyliveApply.setReceive(CommonConst.RECEIVE_BEFORE); | |
| 140 | - shyliveApply.setShenhe_state(CommonConst.AUDIT_INTT); | |
| 141 | - shyliveApply.setEmail_notice_state(CommonConst.NOTICE_INTT); | |
| 142 | - shyliveApply.setUpdater(null); | |
| 143 | - shyliveApply.setAuditor(null); | |
| 144 | - //更新时间 | |
| 145 | - shyliveApply.setUpdated_at(CommonUtils.getCurrentTime()); | |
| 146 | - | |
| 147 | - //获取审核类型 | |
| 148 | - liveApplyServiceImpl.getShenheType(shyliveApply); | |
| 149 | - yorN = liveApplyServiceImpl.updateshyLiveApply(shyliveApply); | |
| 70 | + ShyLiveapply shyliveApply1 = listshyLiveApply.get(0); | |
| 71 | + yorN = saveOrUpdateLiveApply(shyliveApply1, spId, json, timestampStart, timestampEnd); | |
| 150 | 72 | } else { |
| 151 | 73 | //查了,没有,直接插入数据库 |
| 152 | 74 | //设置频道id |
| 153 | - shyliveApply1.setChannel_id(channelId); | |
| 154 | - //设置spid | |
| 155 | - shyliveApply1.setSp_id(spId); | |
| 156 | - //设置发送者 | |
| 157 | - shyliveApply1.setSender(sender); | |
| 158 | - //设置联系方式 | |
| 159 | - shyliveApply1.setMobile(mobile); | |
| 160 | - //设置直播发起单位 | |
| 161 | - shyliveApply1.setOrganization(organization); | |
| 162 | - //直播主题 | |
| 163 | - shyliveApply1.setTheme(theme); | |
| 164 | - //直播类型 | |
| 165 | - shyliveApply1.setLive_type(liveType); | |
| 166 | - //预计开始时间 | |
| 167 | - shyliveApply1.setPre_start_time(timestampStart); | |
| 168 | - //预计结束时间 | |
| 169 | - shyliveApply1.setPre_end_time(timestampEnd); | |
| 170 | - //商务模式:0免费 1收费 | |
| 171 | - shyliveApply1.setBusiness_model(businessModel); | |
| 172 | - //内容属性:1商业类活动 0非商业活动 | |
| 173 | - shyliveApply1.setContent_property(contentProperty); | |
| 174 | - //内容简述 | |
| 175 | - shyliveApply1.setSimple_content(simpleContent); | |
| 176 | - //要点报备:0品牌植入 1广告植入 2商品推销 3网家家独家麦标 | |
| 177 | - shyliveApply1.setPoint_key(keys); | |
| 178 | - //直播地点 | |
| 179 | - shyliveApply1.setLive_place(livePlace); | |
| 180 | - //推流地址 | |
| 181 | - shyliveApply1.setPush_url(pushUrl); | |
| 182 | - //拉流地址 | |
| 183 | - shyliveApply1.setPull_url(pullUrl); | |
| 184 | - //拉流来源 | |
| 185 | - shyliveApply1.setPull_source(pullSource); | |
| 186 | - //播出平台及通道:0网家家 1CNLive网站 2@TV互动电视 | |
| 187 | - shyliveApply1.setPlatforms(platforms); | |
| 188 | - //设置回调地址 | |
| 189 | - shyliveApply1.setCallback(callback); | |
| 190 | - //获取审核类型 | |
| 191 | - liveApplyServiceImpl.getShenheType(shyliveApply1); | |
| 192 | - shyliveApply1.setReceive(CommonConst.RECEIVE_BEFORE); | |
| 193 | - shyliveApply1.setShenhe_state(CommonConst.AUDIT_INTT); | |
| 194 | - shyliveApply1.setEmail_notice_state(CommonConst.NOTICE_INTT); | |
| 195 | - shyliveApply1.setUpdater(null); | |
| 196 | - shyliveApply1.setAuditor(null); | |
| 197 | - shyliveApply1.setShenhe_msg(null); | |
| 198 | - shyliveApply1.setEmail_notice_msg(""); | |
| 75 | + shyliveApply.setChannel_id(channelId); | |
| 76 | + shyliveApply.setShenhe_msg(null); | |
| 77 | + shyliveApply.setEmail_notice_msg(""); | |
| 199 | 78 | //创建时间 |
| 200 | - shyliveApply1.setCreated_at(CommonUtils.getCurrentTime()); | |
| 201 | - //更新时间 | |
| 202 | - shyliveApply1.setUpdated_at(CommonUtils.getCurrentTime()); | |
| 203 | - | |
| 204 | - yorN = liveApplyServiceImpl.impotLiveApply(shyliveApply1); | |
| 79 | + shyliveApply.setCreated_at(CommonUtils.getCurrentTime()); | |
| 80 | + yorN = saveOrUpdateLiveApply(shyliveApply, spId, json, timestampStart, timestampEnd); | |
| 205 | 81 | } |
| 206 | - | |
| 207 | 82 | if (yorN) { |
| 208 | 83 | result.put("errorCode", "0"); |
| 209 | 84 | result.put("errorMessage", "直播申请审核请求收到成功"); |
| 210 | 85 | map.put("statusCode", "200"); |
| 211 | - map.put("result", result); | |
| 212 | 86 | } else { |
| 213 | 87 | result.put("errorCode", "-1"); |
| 214 | 88 | result.put("errorMessage", "直播申请审核入库失败"); |
| 215 | 89 | map.put("statusCode", "300"); |
| 216 | - map.put("result", result); | |
| 217 | 90 | } |
| 91 | + map.put("result", result); | |
| 218 | 92 | return map; |
| 219 | 93 | } |
| 220 | 94 | |
| 95 | + /** | |
| 96 | + * 直播申请 保存和更新 | |
| 97 | + * | |
| 98 | + * @param shyliveApply | |
| 99 | + * @param spId | |
| 100 | + * @param json | |
| 101 | + * @param timestampStart | |
| 102 | + * @param timestampEnd | |
| 103 | + * @return | |
| 104 | + */ | |
| 105 | + private boolean saveOrUpdateLiveApply(ShyLiveapply shyliveApply, Integer spId, JSONObject json, Date timestampStart, Date timestampEnd) { | |
| 106 | + //封装数据 | |
| 107 | + //设置spid | |
| 108 | + shyliveApply.setSp_id(spId); | |
| 109 | + //设置发送者 | |
| 110 | + shyliveApply.setSender(json.getString("sender")); | |
| 111 | + //设置联系方式 | |
| 112 | + shyliveApply.setMobile(json.getString("mobile")); | |
| 113 | + //设置直播发起单位 | |
| 114 | + shyliveApply.setOrganization(json.getString("organization")); | |
| 115 | + //直播主题 | |
| 116 | + shyliveApply.setTheme(json.getString("theme")); | |
| 117 | + //直播类型 | |
| 118 | + shyliveApply.setLive_type(json.getString("liveType")); | |
| 119 | + //预计开始时间 | |
| 120 | + shyliveApply.setPre_start_time(timestampStart); | |
| 121 | + //预计结束时间 | |
| 122 | + shyliveApply.setPre_end_time(timestampEnd); | |
| 123 | + //商务模式:0免费 1收费 | |
| 124 | + shyliveApply.setBusiness_model(json.getInteger("businessModel")); | |
| 125 | + //内容属性:1商业类活动 0非商业活动 | |
| 126 | + shyliveApply.setContent_property(json.getInteger("contentProperty")); | |
| 127 | + //内容简述 | |
| 128 | + shyliveApply.setSimple_content(json.getString("simpleContent")); | |
| 129 | + //要点报备:0品牌植入 1广告植入 2商品推销 3网家家独家麦标 | |
| 130 | + shyliveApply.setPoint_key(json.getString("keys").equals("") ? "无" : json.getString("keys")); | |
| 131 | + //直播地点 | |
| 132 | + shyliveApply.setLive_place(json.getString("livePlace")); | |
| 133 | + //推流地址 | |
| 134 | + shyliveApply.setPush_url(json.getString("pushUrl")); | |
| 135 | + //拉流地址 | |
| 136 | + shyliveApply.setPull_url(json.getString("pullUrl").equals("") ? "无拉流地址" : json.getString("pullUrl")); | |
| 137 | + //拉流来源 | |
| 138 | + shyliveApply.setPull_source(json.getString("pullSource").equals("") ? "无来源" : json.getString("pullSource")); | |
| 139 | + //播出平台及通道:0网家家 1CNLive网站 2@TV互动电视 | |
| 140 | + shyliveApply.setPlatforms(json.getString("platforms")); | |
| 141 | + //设置回调地址 | |
| 142 | + shyliveApply.setCallback(json.getString("callback")); | |
| 143 | + shyliveApply.setReceive(CommonConst.RECEIVE_BEFORE); | |
| 144 | + shyliveApply.setShenhe_state(CommonConst.AUDIT_INTT); | |
| 145 | + shyliveApply.setEmail_notice_state(CommonConst.NOTICE_INTT); | |
| 146 | + shyliveApply.setUpdater(null); | |
| 147 | + shyliveApply.setAuditor(null); | |
| 148 | + //更新时间 | |
| 149 | + shyliveApply.setUpdated_at(CommonUtils.getCurrentTime()); | |
| 150 | + //获取审核类型 | |
| 151 | + liveApplyServiceImpl.getShenheType(shyliveApply); | |
| 152 | + if (shyliveApply.getId() == null) { | |
| 153 | + return liveApplyServiceImpl.impotLiveApply(shyliveApply); | |
| 154 | + } else { | |
| 155 | + return liveApplyServiceImpl.updateshyLiveApply(shyliveApply); | |
| 156 | + } | |
| 157 | + } | |
| 221 | 158 | } | ... | ... |
src/main/java/com/cnlive/shenhe/api/LiveControllerApi.java
| ... | ... | @@ -37,8 +37,7 @@ public class LiveControllerApi { |
| 37 | 37 | JSONObject map = new JSONObject(); |
| 38 | 38 | JSONObject result = new JSONObject(); |
| 39 | 39 | //初始化一个请求数据库返回结果 |
| 40 | - boolean yorN = true; | |
| 41 | - | |
| 40 | + boolean yorN; | |
| 42 | 41 | logger.info("直播入库,param=====" + param); |
| 43 | 42 | JSONObject json = JSONObject.parseObject(param); |
| 44 | 43 | //获取所有参数 |
| ... | ... | @@ -70,7 +69,6 @@ public class LiveControllerApi { |
| 70 | 69 | String playbackUrl = json.getString("playbackUrl"); |
| 71 | 70 | //开始时间 |
| 72 | 71 | String startTime = json.getString("startTime"); |
| 73 | - | |
| 74 | 72 | Date timestampStart = null; |
| 75 | 73 | if (CommonUtils.isNotEmpty(startTime)) { |
| 76 | 74 | timestampStart = new Timestamp(Long.parseLong(startTime)); |
| ... | ... | @@ -81,10 +79,8 @@ public class LiveControllerApi { |
| 81 | 79 | if (CommonUtils.isNotEmpty(endTime)) { |
| 82 | 80 | timestampEnd = new Timestamp(Long.parseLong(endTime)); |
| 83 | 81 | } |
| 84 | - | |
| 85 | 82 | //预计开始时间 |
| 86 | 83 | String preStartTime = json.getString("preStartTime"); |
| 87 | - | |
| 88 | 84 | Date preTimestampStart = null; |
| 89 | 85 | if (CommonUtils.isNotEmpty(preStartTime)) { |
| 90 | 86 | preTimestampStart = new Timestamp(Long.parseLong(preStartTime)); |
| ... | ... | @@ -95,186 +91,129 @@ public class LiveControllerApi { |
| 95 | 91 | if (CommonUtils.isNotEmpty(preEndTime)) { |
| 96 | 92 | preTimestampEnd = new Timestamp(Long.parseLong(preEndTime)); |
| 97 | 93 | } |
| 98 | - | |
| 99 | - ShyLive shylive1 = new ShyLive(); | |
| 94 | + ShyLive shyLive = new ShyLive(); | |
| 100 | 95 | //得到直播活动id去查询是否已有 |
| 101 | - shylive1.setActivity_id(activityId); | |
| 96 | + shyLive.setActivity_id(activityId); | |
| 102 | 97 | //查询一下 存在,更新 没有,插入 |
| 103 | - List<ShyLive> listshyLive = liveService.findshyLive(shylive1); | |
| 104 | - //更新 | |
| 105 | - if (listshyLive.size() > 0) { | |
| 106 | - | |
| 107 | - ShyLive shyLive = listshyLive.get(0); | |
| 108 | - //拒绝状态等于4 | |
| 109 | - if (activityStatus == 4) { | |
| 110 | - //领取状态改为未领 | |
| 111 | - shyLive.setShenhe_state(CommonConst.RECEIVE_BEFORE); | |
| 112 | - } | |
| 113 | - //封装数据入库 | |
| 114 | - //设置spid | |
| 115 | - shyLive.setSp_id(spId); | |
| 116 | - //设置直播活动名称 | |
| 117 | - shyLive.setActivity_name(activityName); | |
| 118 | - //设置直播活动状态 | |
| 119 | - shyLive.setActivity_status(activityStatus); | |
| 120 | - shyLive.setPre_start_time(preTimestampStart); | |
| 121 | - shyLive.setPre_end_time(preTimestampEnd); | |
| 122 | - | |
| 123 | - //直播活动状态,1:直播中,2:直播完成,3:待直播,0:直播撤销(手动),4:直播下线(强制) | |
| 124 | - //发布直播 | |
| 125 | - if (activityStatus.equals(CommonConstStates.ZHIBO_DENGDAI)) { | |
| 126 | - shyLive.setActivity_start_time(null); | |
| 127 | - shyLive.setActivity_end_time(null); | |
| 128 | - //是否是热点: 1:不是 ,2: 是 | |
| 129 | - shyLive.setIs_hot(CommonConstStates.SHIFOU_REDIANYES); | |
| 130 | - //启动直播 | |
| 131 | - } else if (activityStatus.equals(CommonConstStates.ZHIBO_ZHENGZAI)) { | |
| 132 | - shyLive.setActivity_start_time(timestampStart); | |
| 133 | - shyLive.setActivity_end_time(null); | |
| 134 | - //是否是热点: 1:不是 ,2: 是 | |
| 135 | - shyLive.setIs_hot(CommonConstStates.SHIFOU_REDIANYES); | |
| 136 | - //停止直播 | |
| 137 | - } else if (activityStatus.equals(CommonConstStates.ZHIBO_JIESHU)) { | |
| 138 | - shyLive.setActivity_start_time(timestampStart); | |
| 139 | - shyLive.setActivity_end_time(timestampEnd); | |
| 140 | - //回放地址 | |
| 141 | - shyLive.setPlayback_url(playbackUrl); | |
| 142 | - //状态 0:未认领 1.已领未审,2:已审 | |
| 143 | - shyLive.setShenhe_state(CommonConst.RECEIVE_AUDIT); | |
| 144 | - //直播完成后自动通过 | |
| 145 | - shyLive.setUpdater("自动通过"); | |
| 146 | - //是否是热点: 1:不是 ,2: 是 | |
| 147 | - shyLive.setIs_hot(CommonConstStates.SHIFOU_REDIANNO); | |
| 148 | - //审核强制下线 | |
| 149 | - } else if (activityStatus.equals(CommonConstStates.ZHIBO_XIAXIAN)) { | |
| 150 | - shyLive.setActivity_start_time(timestampStart); | |
| 151 | - shyLive.setActivity_end_time(timestampEnd); | |
| 152 | - //回放地址 | |
| 153 | - shyLive.setPlayback_url(playbackUrl); | |
| 154 | - //是否是热点: 1:不是 ,2: 是 | |
| 155 | - shyLive.setIs_hot(CommonConstStates.SHIFOU_REDIANNO); | |
| 156 | - } | |
| 157 | - //直播活动简介 | |
| 158 | - shyLive.setActivity_intro(activityIntro); | |
| 159 | - shyLive.setLive_type(liveType); | |
| 160 | - //m3u8直播流 | |
| 161 | - shyLive.setM3u8_url(hlsUrl); | |
| 162 | - //rtmp直播流 | |
| 163 | - shyLive.setRtmp_url(mp4Url); | |
| 164 | - //回调地址 | |
| 165 | - shyLive.setCallback(callback); | |
| 166 | - //封面 | |
| 167 | - shyLive.setCover_img_url(coverImgUrl); | |
| 168 | - //审核类型,1:免审,2:机审,3:人工审 | |
| 169 | - shyLive.setShenhe_type(CommonConst.AUDIT_TYPE_USER); | |
| 170 | - //抽帧状态 1:不抽帧 2:待抽帧 3:抽帧中 4:抽帧完成 5:抽帧失败 | |
| 171 | - shyLive.setAvsample_state(1); | |
| 172 | - //直播撤销 | |
| 173 | - if (activityStatus.equals(CommonConstStates.ZHIBO_CHEXIAO)) { | |
| 174 | - //是否显示 0:不显示 1:显示 | |
| 175 | - shyLive.setIs_show(CommonConstStates.SHIFOU_XIANSHINO); | |
| 176 | - //是否是热点: 1:不是 ,2: 是 | |
| 177 | - shyLive.setIs_hot(CommonConstStates.SHIFOU_REDIANNO); | |
| 178 | - } else { | |
| 179 | - shyLive.setIs_show(CommonConstStates.SHIFOU_XIANSHIYES); | |
| 180 | - } | |
| 181 | - //更新时间 | |
| 182 | - shyLive.setUpdated_at(CommonUtils.getCurrentTime()); | |
| 183 | - | |
| 184 | - yorN = liveService.updateshyLive(shyLive); | |
| 185 | - // 插入 | |
| 98 | + List<ShyLive> shyLiveList = liveService.findshyLive(shyLive); | |
| 99 | + if (shyLiveList.size() > 0) { | |
| 100 | + //更新 | |
| 101 | + ShyLive shyLive1 = shyLiveList.get(0); | |
| 102 | + yorN = saveOrUpdateLive(shyLive1, json, activityStatus, preTimestampStart, preTimestampEnd, timestampStart, timestampEnd); | |
| 186 | 103 | } else { |
| 187 | - //查了,没有,直接插入数据库 | |
| 188 | - //设置直播活动id | |
| 189 | - shylive1.setActivity_id(activityId); | |
| 190 | - //设置直播活动名称 | |
| 191 | - shylive1.setActivity_name(activityName); | |
| 192 | - //设置直播活动状态 | |
| 193 | - shylive1.setActivity_status(activityStatus); | |
| 104 | + // 插入 | |
| 194 | 105 | //设置直播频道 |
| 195 | - shylive1.setChannel_id(channelId); | |
| 196 | - //设置spid | |
| 197 | - shylive1.setSp_id(spId); | |
| 106 | + shyLive.setChannel_id(channelId); | |
| 198 | 107 | //状态 0:未认领 1.已领未审,2:已审 |
| 199 | - shylive1.setShenhe_state(CommonConst.RECEIVE_BEFORE); | |
| 200 | - //是否是热点: 1:不是 ,2: 是 | |
| 201 | - shylive1.setIs_hot(CommonConstStates.SHIFOU_REDIANYES); | |
| 202 | - shylive1.setPre_start_time(preTimestampStart); | |
| 203 | - shylive1.setPre_end_time(preTimestampEnd); | |
| 204 | - //发布直播 | |
| 205 | - if (activityStatus.equals(CommonConstStates.ZHIBO_DENGDAI)) { | |
| 206 | - shylive1.setActivity_start_time(null); | |
| 207 | - shylive1.setActivity_end_time(null); | |
| 208 | - } else if (activityStatus.equals(CommonConstStates.ZHIBO_ZHENGZAI)) { | |
| 209 | - //启动直播 | |
| 210 | - shylive1.setActivity_start_time(timestampStart); | |
| 211 | - shylive1.setActivity_end_time(null); | |
| 212 | - //停止直播 | |
| 213 | - } else if (activityStatus.equals(CommonConstStates.ZHIBO_JIESHU)) { | |
| 214 | - shylive1.setActivity_start_time(timestampStart); | |
| 215 | - shylive1.setActivity_end_time(timestampEnd); | |
| 216 | - //回放地址 | |
| 217 | - shylive1.setPlayback_url(playbackUrl); | |
| 218 | - //状态 0:未认领 1.已领未审,2:已审 | |
| 219 | - shylive1.setShenhe_state(CommonConst.RECEIVE_AUDIT); | |
| 220 | - //直播完成后自动通过 | |
| 221 | - shylive1.setUpdater("自动通过"); | |
| 222 | - //是否是热点: 1:不是 ,2: 是 | |
| 223 | - shylive1.setIs_hot(CommonConstStates.SHIFOU_REDIANNO); | |
| 224 | - //审核强制下线 | |
| 225 | - } else if (activityStatus.equals(CommonConstStates.ZHIBO_XIAXIAN)) { | |
| 226 | - shylive1.setActivity_start_time(timestampStart); | |
| 227 | - shylive1.setActivity_end_time(timestampEnd); | |
| 228 | - //回放地址 | |
| 229 | - shylive1.setPlayback_url(playbackUrl); | |
| 230 | - //状态 0:未认领 1.已领未审,2:已审 | |
| 231 | - shylive1.setShenhe_state(CommonConst.RECEIVE_AUDIT); | |
| 232 | - //是否是热点: 1:不是 ,2: 是 | |
| 233 | - shylive1.setIs_hot(CommonConstStates.SHIFOU_REDIANNO); | |
| 234 | - } | |
| 235 | - //直播活动简介 | |
| 236 | - shylive1.setActivity_intro(activityIntro); | |
| 237 | - shylive1.setLive_type(liveType); | |
| 238 | - //m3u8直播流 | |
| 239 | - shylive1.setM3u8_url(hlsUrl); | |
| 240 | - //rtmp直播流 | |
| 241 | - shylive1.setRtmp_url(mp4Url); | |
| 242 | - //回调地址 | |
| 243 | - shylive1.setCallback(callback); | |
| 244 | - //封面 | |
| 245 | - shylive1.setCover_img_url(coverImgUrl); | |
| 246 | - //审核类型,1:免审,2:机审,3:人工审 | |
| 247 | - shylive1.setShenhe_type(CommonConst.AUDIT_TYPE_USER); | |
| 248 | - //抽帧状态 1:不抽帧 2:待抽帧 3:抽帧中 4:抽帧完成 5:抽帧失败 | |
| 249 | - shylive1.setAvsample_state(1); | |
| 250 | - //直播撤销 | |
| 251 | - if (activityStatus.equals(CommonConstStates.ZHIBO_CHEXIAO)) { | |
| 252 | - //是否显示 0:不显示 1:显示 | |
| 253 | - shylive1.setIs_show(CommonConstStates.SHIFOU_XIANSHINO); | |
| 254 | - //是否是热点: 1:不是 ,2: 是 | |
| 255 | - shylive1.setIs_hot(CommonConstStates.SHIFOU_REDIANNO); | |
| 256 | - } else { | |
| 257 | - shylive1.setIs_show(CommonConstStates.SHIFOU_XIANSHIYES); | |
| 258 | - } | |
| 259 | - | |
| 108 | + shyLive.setShenhe_state(CommonConst.RECEIVE_BEFORE); | |
| 260 | 109 | //创建时间 |
| 261 | - shylive1.setCreated_at(CommonUtils.getCurrentTime()); | |
| 262 | - //更新时间 | |
| 263 | - shylive1.setUpdated_at(CommonUtils.getCurrentTime()); | |
| 264 | - yorN = liveService.impotVideo(shylive1); | |
| 110 | + shyLive.setCreated_at(CommonUtils.getCurrentTime()); | |
| 111 | + yorN = saveOrUpdateLive(shyLive, json, activityStatus, preTimestampStart, preTimestampEnd, timestampStart, timestampEnd); | |
| 265 | 112 | } |
| 266 | - | |
| 267 | 113 | if (yorN) { |
| 268 | 114 | result.put("errorCode", "0"); |
| 269 | 115 | result.put("errorMessage", "直播审核请求收到成功"); |
| 270 | 116 | map.put("statusCode", "200"); |
| 271 | - map.put("result", result); | |
| 272 | 117 | } else { |
| 273 | 118 | result.put("errorCode", "-1"); |
| 274 | 119 | result.put("errorMessage", "直播审核入库失败"); |
| 275 | 120 | map.put("statusCode", "300"); |
| 276 | - map.put("result", result); | |
| 277 | 121 | } |
| 122 | + map.put("result", result); | |
| 278 | 123 | return map; |
| 279 | 124 | } |
| 125 | + | |
| 126 | + /** | |
| 127 | + * 保存和更新 直播 | |
| 128 | + * | |
| 129 | + * @param shyLive | |
| 130 | + * @param json | |
| 131 | + * @param activityStatus | |
| 132 | + * @param preTimestampStart | |
| 133 | + * @param preTimestampEnd | |
| 134 | + * @param timestampStart | |
| 135 | + * @param timestampEnd | |
| 136 | + * @return | |
| 137 | + */ | |
| 138 | + private boolean saveOrUpdateLive(ShyLive shyLive, JSONObject json, Integer activityStatus, Date preTimestampStart, Date preTimestampEnd, Date timestampStart, Date timestampEnd) { | |
| 139 | + //封装数据入库 | |
| 140 | + //设置spid | |
| 141 | + shyLive.setSp_id(json.getInteger("spId")); | |
| 142 | + //设置直播活动名称 | |
| 143 | + shyLive.setActivity_name(json.getString("activityName")); | |
| 144 | + //设置直播活动状态 | |
| 145 | + shyLive.setActivity_status(activityStatus); | |
| 146 | + shyLive.setPre_start_time(preTimestampStart); | |
| 147 | + shyLive.setPre_end_time(preTimestampEnd); | |
| 148 | + //是否是热点: 1:不是 ,2: 是 | |
| 149 | + shyLive.setIs_hot(CommonConstStates.SHIFOU_REDIANYES); | |
| 150 | + //直播活动状态,1:直播中,2:直播完成,3:待直播,0:直播撤销(手动),4:直播下线(强制) | |
| 151 | + //发布直播 | |
| 152 | + if (activityStatus.equals(CommonConstStates.ZHIBO_DENGDAI)) { | |
| 153 | + shyLive.setActivity_start_time(null); | |
| 154 | + shyLive.setActivity_end_time(null); | |
| 155 | + //启动直播 | |
| 156 | + } else if (activityStatus.equals(CommonConstStates.ZHIBO_ZHENGZAI)) { | |
| 157 | + shyLive.setActivity_start_time(timestampStart); | |
| 158 | + shyLive.setActivity_end_time(null); | |
| 159 | + //停止直播 | |
| 160 | + } else if (activityStatus.equals(CommonConstStates.ZHIBO_JIESHU)) { | |
| 161 | + shyLive.setActivity_start_time(timestampStart); | |
| 162 | + shyLive.setActivity_end_time(timestampEnd); | |
| 163 | + //回放地址 | |
| 164 | + shyLive.setPlayback_url(json.getString("playbackUrl")); | |
| 165 | + //状态 0:未认领 1.已领未审,2:已审 | |
| 166 | + shyLive.setShenhe_state(CommonConst.RECEIVE_AUDIT); | |
| 167 | + //直播完成后自动通过 | |
| 168 | + shyLive.setUpdater("自动通过"); | |
| 169 | + //是否是热点: 1:不是 ,2: 是 | |
| 170 | + shyLive.setIs_hot(CommonConstStates.SHIFOU_REDIANNO); | |
| 171 | + //审核强制下线 | |
| 172 | + } else if (activityStatus.equals(CommonConstStates.ZHIBO_XIAXIAN)) { | |
| 173 | + shyLive.setActivity_start_time(timestampStart); | |
| 174 | + shyLive.setActivity_end_time(timestampEnd); | |
| 175 | + //回放地址 | |
| 176 | + shyLive.setPlayback_url(json.getString("playbackUrl")); | |
| 177 | + if (shyLive.getId() == null) { | |
| 178 | + //状态 0:未认领 1.已领未审,2:已审 | |
| 179 | + shyLive.setShenhe_state(CommonConst.RECEIVE_AUDIT); | |
| 180 | + } else { | |
| 181 | + //领取状态改为未领 | |
| 182 | + shyLive.setShenhe_state(CommonConst.RECEIVE_BEFORE); | |
| 183 | + } | |
| 184 | + //是否是热点: 1:不是 ,2: 是 | |
| 185 | + shyLive.setIs_hot(CommonConstStates.SHIFOU_REDIANNO); | |
| 186 | + } | |
| 187 | + //直播活动简介 | |
| 188 | + shyLive.setActivity_intro(json.getString("activityIntro")); | |
| 189 | + shyLive.setLive_type(json.getString("liveType")); | |
| 190 | + //m3u8直播流 | |
| 191 | + shyLive.setM3u8_url(json.getString("hlsUrl")); | |
| 192 | + //rtmp直播流 | |
| 193 | + shyLive.setRtmp_url(json.getString("mp4Url")); | |
| 194 | + //回调地址 | |
| 195 | + shyLive.setCallback(json.getString("callback")); | |
| 196 | + //封面 | |
| 197 | + shyLive.setCover_img_url(json.getString("coverImgUrl")); | |
| 198 | + //审核类型,1:免审,2:机审,3:人工审 | |
| 199 | + shyLive.setShenhe_type(CommonConst.AUDIT_TYPE_USER); | |
| 200 | + //抽帧状态 1:不抽帧 2:待抽帧 3:抽帧中 4:抽帧完成 5:抽帧失败 | |
| 201 | + shyLive.setAvsample_state(1); | |
| 202 | + //直播撤销 | |
| 203 | + if (activityStatus.equals(CommonConstStates.ZHIBO_CHEXIAO)) { | |
| 204 | + //是否显示 0:不显示 1:显示 | |
| 205 | + shyLive.setIs_show(CommonConstStates.SHIFOU_XIANSHINO); | |
| 206 | + //是否是热点: 1:不是 ,2: 是 | |
| 207 | + shyLive.setIs_hot(CommonConstStates.SHIFOU_REDIANNO); | |
| 208 | + } else { | |
| 209 | + shyLive.setIs_show(CommonConstStates.SHIFOU_XIANSHIYES); | |
| 210 | + } | |
| 211 | + //更新时间 | |
| 212 | + shyLive.setUpdated_at(CommonUtils.getCurrentTime()); | |
| 213 | + if (shyLive.getId() == null) { | |
| 214 | + return liveService.impotVideo(shyLive); | |
| 215 | + } else { | |
| 216 | + return liveService.updateshyLive(shyLive); | |
| 217 | + } | |
| 218 | + } | |
| 280 | 219 | } | ... | ... |
src/main/java/com/cnlive/shenhe/api/TopicControllerApi.java
| ... | ... | @@ -41,6 +41,7 @@ public class TopicControllerApi { |
| 41 | 41 | public ResponseBean impotTopic(@RequestBody String param) { |
| 42 | 42 | logger.info("话题入库,param=====" + param); |
| 43 | 43 | JSONObject json = JSONObject.parseObject(param); |
| 44 | + boolean yorN; | |
| 44 | 45 | //获取所有参数 |
| 45 | 46 | //话题id |
| 46 | 47 | String topicId = json.getString("topicId"); |
| ... | ... | @@ -49,86 +50,63 @@ public class TopicControllerApi { |
| 49 | 50 | spId = json.getInteger("spId"); |
| 50 | 51 | } catch (Exception e) { |
| 51 | 52 | } |
| 52 | - //话题标题 | |
| 53 | - String topicTitle = json.getString("topicTitle"); | |
| 54 | - //话题图片 | |
| 55 | - String topicPic = json.getString("topicPic"); | |
| 56 | - //话题内容 | |
| 57 | - String topicText = json.getString("topicMsg"); | |
| 58 | - //话题创建时间 | |
| 59 | - String topicTime = json.getString("createTime"); | |
| 60 | - | |
| 61 | - //话题标签 | |
| 62 | - String topicTag = json.getString("topicTag"); | |
| 63 | - //话题url | |
| 64 | - String topicUrl = json.getString("topicUrl"); | |
| 65 | - | |
| 66 | 53 | //判断是否存在 |
| 67 | 54 | ShyTopic shyTopic = new ShyTopic(); |
| 68 | 55 | shyTopic.setTopic_id(topicId); |
| 69 | 56 | List<ShyTopic> topicList = topicService.findshyTopic(shyTopic); |
| 70 | - | |
| 71 | 57 | //获取审核类型 |
| 72 | 58 | Integer shenheType = topicService.getShenheType(spId); |
| 73 | - //存在则更新 | |
| 74 | 59 | if (topicList.size() > 0) { |
| 60 | + //存在则更新 | |
| 75 | 61 | ShyTopic shyTopic1 = topicList.get(0); |
| 76 | - //话题标题 | |
| 77 | - shyTopic1.setTitle(topicTitle); | |
| 78 | - //话题图片 | |
| 79 | - shyTopic1.setTopic_image(topicPic); | |
| 80 | - //审核类型 | |
| 81 | - shyTopic1.setShenhe_type(shenheType); | |
| 82 | - //话题内容 | |
| 83 | - shyTopic1.setTopic_text(topicText); | |
| 84 | - //话题标签 | |
| 85 | - shyTopic1.setTopic_tag(topicTag); | |
| 86 | - //话题url | |
| 87 | - shyTopic1.setTopic_url(topicUrl); | |
| 88 | - //话题创建时间 | |
| 89 | - shyTopic1.setTopic_time(topicTime); | |
| 90 | - //spid | |
| 91 | - shyTopic1.setSp_id(spId); | |
| 92 | - //当前话题的审核状态 | |
| 93 | - shyTopic1.setShenhe_status(CommonConst.AUDIT_INTT); | |
| 94 | - //最后一次更新时间 | |
| 95 | - shyTopic1.setUpdate_date(CommonUtils.getCurrentTime()); | |
| 96 | - | |
| 97 | - boolean yorN = topicService.updateshyTopic(shyTopic1); | |
| 98 | - if (yorN) { | |
| 99 | - return new ResponseBean(ErrorEnum.SUCCESS, new JSONObject().put("topic_id", topicId)); | |
| 100 | - } else { | |
| 101 | - return new ResponseBean(ErrorEnum.ERROR, new JSONObject().put("topic_id", topicId)); | |
| 102 | - } | |
| 62 | + yorN = saveOrUpdateTopic(json, shyTopic1, shenheType, spId); | |
| 63 | + } else { | |
| 64 | + //送审时间 | |
| 65 | + shyTopic.setCreate_date(CommonUtils.getCurrentTime()); | |
| 66 | + //如果不存在直接插入 | |
| 67 | + yorN = saveOrUpdateTopic(json, shyTopic, shenheType, spId); | |
| 103 | 68 | } |
| 104 | - //如果不存在直接插入 | |
| 69 | + if (yorN) { | |
| 70 | + return new ResponseBean(ErrorEnum.SUCCESS, new JSONObject().put("topic_id", topicId)); | |
| 71 | + } else { | |
| 72 | + return new ResponseBean(ErrorEnum.ERROR, new JSONObject().put("topic_id", topicId)); | |
| 73 | + } | |
| 74 | + } | |
| 75 | + | |
| 76 | + /** | |
| 77 | + * 话题 保存和更新 | |
| 78 | + * | |
| 79 | + * @param json | |
| 80 | + * @param shyTopic | |
| 81 | + * @param shenheType | |
| 82 | + * @param spId | |
| 83 | + * @return | |
| 84 | + */ | |
| 85 | + private boolean saveOrUpdateTopic(JSONObject json, ShyTopic shyTopic, Integer shenheType, Integer spId) { | |
| 105 | 86 | //话题标题 |
| 106 | - shyTopic.setTitle(topicTitle); | |
| 87 | + shyTopic.setTitle(json.getString("topicTitle")); | |
| 107 | 88 | //话题图片 |
| 108 | - shyTopic.setTopic_image(topicPic); | |
| 89 | + shyTopic.setTopic_image(json.getString("topicPic")); | |
| 109 | 90 | //审核类型 |
| 110 | 91 | shyTopic.setShenhe_type(shenheType); |
| 111 | 92 | //话题内容 |
| 112 | - shyTopic.setTopic_text(topicText); | |
| 93 | + shyTopic.setTopic_text(json.getString("topicMsg")); | |
| 113 | 94 | //话题标签 |
| 114 | - shyTopic.setTopic_tag(topicTag); | |
| 95 | + shyTopic.setTopic_tag(json.getString("topicTag")); | |
| 115 | 96 | //话题url |
| 116 | - shyTopic.setTopic_url(topicUrl); | |
| 97 | + shyTopic.setTopic_url(json.getString("topicUrl")); | |
| 117 | 98 | //话题创建时间 |
| 118 | - shyTopic.setTopic_time(topicTime); | |
| 99 | + shyTopic.setTopic_time(json.getString("createTime")); | |
| 119 | 100 | //spid |
| 120 | 101 | shyTopic.setSp_id(spId); |
| 121 | 102 | //当前话题的审核状态 |
| 122 | 103 | shyTopic.setShenhe_status(CommonConst.AUDIT_INTT); |
| 123 | 104 | //最后一次更新时间 |
| 124 | 105 | shyTopic.setUpdate_date(CommonUtils.getCurrentTime()); |
| 125 | - //送审时间 | |
| 126 | - shyTopic.setCreate_date(CommonUtils.getCurrentTime()); | |
| 127 | - boolean yorN = topicService.impotshyTopic(shyTopic); | |
| 128 | - if (yorN) { | |
| 129 | - return new ResponseBean(ErrorEnum.SUCCESS, new JSONObject().put("topic_id", topicId)); | |
| 106 | + if (shyTopic.getId() == null) { | |
| 107 | + return topicService.impotshyTopic(shyTopic); | |
| 130 | 108 | } else { |
| 131 | - return new ResponseBean(ErrorEnum.ERROR, new JSONObject().put("topic_id", topicId)); | |
| 109 | + return topicService.updateshyTopic(shyTopic); | |
| 132 | 110 | } |
| 133 | 111 | } |
| 134 | 112 | ... | ... |
src/main/java/com/cnlive/shenhe/api/VideosControllerApi.java
| ... | ... | @@ -61,6 +61,7 @@ public class VideosControllerApi { |
| 61 | 61 | public ResponseBean impotVideo(String param) { |
| 62 | 62 | logger.info("点播入库,param====={}", param); |
| 63 | 63 | JSONObject json = JSONObject.parseObject(param); |
| 64 | + boolean yorN; | |
| 64 | 65 | //目击者类型 0-目击者 1-童声共济 2-全民健身 3-目击者政府监督 |
| 65 | 66 | String source = json.getString("source"); |
| 66 | 67 | Integer duration = json.getInteger("duration"); |
| ... | ... | @@ -75,129 +76,108 @@ public class VideosControllerApi { |
| 75 | 76 | sid = CommonUtils.isEmpty(sid) ? "" : sid.split("_")[2]; |
| 76 | 77 | logger.info("sid:" + sid); |
| 77 | 78 | //查询一下 存在,更新 没有,插入 |
| 78 | - ShyVideos shyVideos1 = new ShyVideos(); | |
| 79 | + ShyVideos shyVideos = new ShyVideos(); | |
| 79 | 80 | //g得到id去查询是否已有 |
| 80 | 81 | String videoId = json.getString("videoId"); |
| 81 | - shyVideos1.setVideo_id(videoId); | |
| 82 | - List<ShyVideos> shyVideosList = videosService.findshyVideo(shyVideos1); | |
| 82 | + shyVideos.setVideo_id(videoId); | |
| 83 | + List<ShyVideos> shyVideosList = videosService.findshyVideo(shyVideos); | |
| 83 | 84 | if (shyVideosList.size() > 0) { |
| 84 | 85 | logger.info("点播入库更新开始............................"); |
| 85 | - ShyVideos shyVideos = shyVideosList.get(0); | |
| 86 | + ShyVideos shyVideos1 = shyVideosList.get(0); | |
| 87 | + shyVideos1.setReceive(CommonConst.RECEIVE_BEFORE); | |
| 88 | + shyVideos1.setReceive_user_id(null); | |
| 89 | + shyVideos1.setUpdated_at(CommonUtils.getCurrentTime()); | |
| 86 | 90 | //封装数据入库 |
| 87 | - shyVideos.setVideo_id(videoId); | |
| 88 | - shyVideos.setSource(source); | |
| 89 | - shyVideos.setVideo_title(json.getString("videoTitle")); | |
| 90 | - shyVideos.setVideo_url(json.getString("videoUrl")); | |
| 91 | - String videoCoverUrl = json.getString("videoCoverUrl"); | |
| 92 | - shyVideos.setVideo_imgs(videoCoverUrl); | |
| 93 | - if (CommonUtils.isNotEmpty(videoCoverUrl)) { | |
| 94 | - String poster = json.getJSONObject("videoCoverUrl").getString("224*126"); | |
| 95 | - shyVideos.setVideo_poster(poster); | |
| 96 | - } | |
| 97 | - shyVideos.setVideo_desc(json.getString("videoIntro")); | |
| 98 | - shyVideos.setVideo_tags(json.getString("videoTag")); | |
| 99 | - shyVideos.setVideo_keyword(json.getString("videoKeyword")); | |
| 100 | - shyVideos.setVideo_md5(json.getString("videoMD5")); | |
| 101 | - shyVideos.setVideo_upload_time(json.getDate(" uploadTime")); | |
| 102 | - shyVideos.setVideo_priority(json.getString("priority")); | |
| 103 | - shyVideos.setCallback(json.getString("callback")); | |
| 104 | - shyVideos.setSpid(json.getInteger("spId")); | |
| 105 | - shyVideos.setState(CommonConst.AUDIT_INTT); | |
| 106 | - shyVideos.setBucket(json.getString("bucketName")); | |
| 107 | - shyVideos.setPlat(json.getInteger("bucketType")); | |
| 108 | - shyVideos.setDuration(duration); | |
| 109 | - //传入栏目分类 | |
| 110 | - shyVideos.setCategory(category); | |
| 111 | - //传入sid | |
| 112 | - shyVideos.setVideo_user_id(sid); | |
| 113 | - shyVideos.setReceive(CommonConst.RECEIVE_BEFORE); | |
| 114 | - shyVideos.setReceive_user_id(null); | |
| 115 | - shyVideos.setUpdated_at(CommonUtils.getCurrentTime()); | |
| 116 | - //获取审核类型 | |
| 117 | - videosService.getShenheType(shyVideos); | |
| 118 | - boolean yorN = videosService.updateshyVideos(shyVideos); | |
| 119 | - if (yorN) { | |
| 120 | - return new ResponseBean(ErrorEnum.SUCCESS); | |
| 121 | - } else { | |
| 122 | - return new ResponseBean(ErrorEnum.ERROR); | |
| 123 | - } | |
| 91 | + yorN = saveOrUpdateVideo(json, shyVideos1, source, duration, category, sid); | |
| 92 | + } else { | |
| 93 | + logger.info("点播入库保存开始............................"); | |
| 94 | + yorN = saveOrUpdateVideo(json, shyVideos, source, duration, category, sid); | |
| 95 | + } | |
| 96 | + if (yorN) { | |
| 97 | + return new ResponseBean(ErrorEnum.SUCCESS); | |
| 98 | + } else { | |
| 99 | + return new ResponseBean(ErrorEnum.ERROR); | |
| 124 | 100 | } |
| 125 | - return saveVideo(json, shyVideos1, source, duration, category, sid); | |
| 126 | - | |
| 127 | 101 | } |
| 128 | 102 | |
| 129 | 103 | /** |
| 130 | - * 保存视频 | |
| 104 | + * 保存 和更新 点播视频 | |
| 131 | 105 | * |
| 132 | 106 | * @param json |
| 133 | - * @param shyVideos1 | |
| 107 | + * @param shyVideos | |
| 134 | 108 | * @param source |
| 135 | 109 | * @param duration |
| 136 | 110 | * @param category |
| 137 | 111 | * @param sid |
| 138 | 112 | * @return |
| 139 | 113 | */ |
| 140 | - private ResponseBean saveVideo(JSONObject json, ShyVideos shyVideos1, String source, Integer duration, String category, String sid) { | |
| 141 | - //查了,没有,直接插入数据库 | |
| 142 | - logger.info("点播入库保存视频开始............................"); | |
| 143 | - shyVideos1.setSource(source); | |
| 144 | - shyVideos1.setVideo_title(json.getString("videoTitle")); | |
| 145 | - shyVideos1.setVideo_url(json.getString("videoUrl")); | |
| 114 | + private boolean saveOrUpdateVideo(JSONObject json, ShyVideos shyVideos, String source, Integer duration, String category, String sid) { | |
| 115 | + shyVideos.setSource(source); | |
| 116 | + shyVideos.setVideo_title(json.getString("videoTitle")); | |
| 117 | + shyVideos.setVideo_url(json.getString("videoUrl")); | |
| 146 | 118 | String videoCoverUrl = json.getString("videoCoverUrl"); |
| 147 | - shyVideos1.setVideo_imgs(videoCoverUrl); | |
| 119 | + shyVideos.setVideo_imgs(videoCoverUrl); | |
| 148 | 120 | if (CommonUtils.isNotEmpty(videoCoverUrl)) { |
| 149 | 121 | String poster = json.getJSONObject("videoCoverUrl").getString("224*126"); |
| 150 | 122 | if (CommonUtils.isEmpty(poster)) { |
| 151 | 123 | //ugc短视频只有一张图片 |
| 152 | 124 | poster = json.getJSONObject("videoCoverUrl").getString("key"); |
| 153 | 125 | } |
| 154 | - shyVideos1.setVideo_poster(poster); | |
| 126 | + shyVideos.setVideo_poster(poster); | |
| 155 | 127 | } |
| 156 | - shyVideos1.setVideo_desc(json.getString("videoIntro")); | |
| 157 | - shyVideos1.setVideo_tags(json.getString("videoTag")); | |
| 158 | - shyVideos1.setVideo_keyword(json.getString("videoKeyword")); | |
| 159 | - shyVideos1.setVideo_upload_time(json.getDate("uploadTime")); | |
| 160 | - shyVideos1.setVideo_priority(json.getString("priority")); | |
| 161 | - shyVideos1.setCallback(json.getString("callback")); | |
| 162 | - shyVideos1.setSpid(json.getInteger("spId")); | |
| 163 | - shyVideos1.setVideo_md5(json.getString("videoMD5")); | |
| 164 | - shyVideos1.setState(CommonConst.AUDIT_INTT); | |
| 165 | - shyVideos1.setBucket(json.getString("bucketName")); | |
| 166 | - shyVideos1.setPlat(json.getInteger("bucketType")); | |
| 167 | - shyVideos1.setDuration(duration); | |
| 128 | + shyVideos.setVideo_desc(json.getString("videoIntro")); | |
| 129 | + shyVideos.setVideo_tags(json.getString("videoTag")); | |
| 130 | + shyVideos.setVideo_keyword(json.getString("videoKeyword")); | |
| 131 | + shyVideos.setVideo_upload_time(json.getDate("uploadTime")); | |
| 132 | + shyVideos.setVideo_priority(json.getString("priority")); | |
| 133 | + shyVideos.setCallback(json.getString("callback")); | |
| 134 | + shyVideos.setSpid(json.getInteger("spId")); | |
| 135 | + shyVideos.setVideo_md5(json.getString("videoMD5")); | |
| 136 | + shyVideos.setState(CommonConst.AUDIT_INTT); | |
| 137 | + shyVideos.setBucket(json.getString("bucketName")); | |
| 138 | + shyVideos.setPlat(json.getInteger("bucketType")); | |
| 139 | + shyVideos.setDuration(duration); | |
| 168 | 140 | //传入栏目分类 |
| 169 | - shyVideos1.setCategory(category); | |
| 141 | + shyVideos.setCategory(category); | |
| 170 | 142 | //传入sid |
| 171 | - shyVideos1.setVideo_user_id(sid); | |
| 143 | + shyVideos.setVideo_user_id(sid); | |
| 172 | 144 | //获取审核类型 |
| 173 | - videosService.getShenheType(shyVideos1); | |
| 145 | + videosService.getShenheType(shyVideos); | |
| 146 | + if (shyVideos.getId() == null) { | |
| 147 | + shenHeRule(shyVideos, duration); | |
| 148 | + logger.info("当前视频类型是:" + shyVideos.getShenhe_type()); | |
| 149 | + return videosService.impotVideo(shyVideos); | |
| 150 | + } else { | |
| 151 | + logger.info("当前视频类型是:" + shyVideos.getShenhe_type()); | |
| 152 | + return videosService.updateshyVideos(shyVideos); | |
| 153 | + } | |
| 154 | + } | |
| 174 | 155 | |
| 175 | - if (!shyVideos1.getShenhe_type().equals(CommonConst.AUDIT_TYPE_FREE)) { | |
| 156 | + /** | |
| 157 | + * 点播视频保存审核规则 | |
| 158 | + * | |
| 159 | + * @param shyVideos | |
| 160 | + * @param duration | |
| 161 | + */ | |
| 162 | + private void shenHeRule(ShyVideos shyVideos, Integer duration) { | |
| 163 | + if (!shyVideos.getShenhe_type().equals(CommonConst.AUDIT_TYPE_FREE)) { | |
| 176 | 164 | //如果审核类型是人工审核,按照原有规则 |
| 177 | - if (shyVideos1.getShenhe_type().equals(CommonConst.AUDIT_TYPE_USER)) { | |
| 165 | + if (shyVideos.getShenhe_type().equals(CommonConst.AUDIT_TYPE_USER)) { | |
| 178 | 166 | if (CommonUtils.isNotNull(duration) && duration > 80) { |
| 179 | 167 | //视频至少可以抽8张,请求抽帧 |
| 180 | - shyVideos1 = avsample(shyVideos1); | |
| 168 | + avsample(shyVideos); | |
| 181 | 169 | } |
| 182 | 170 | //如果审核类型是机审 |
| 183 | - } else if (shyVideos1.getShenhe_type().equals(CommonConst.AUDIT_TYPE_MACHANE)) { | |
| 171 | + } else if (shyVideos.getShenhe_type().equals(CommonConst.AUDIT_TYPE_MACHANE)) { | |
| 184 | 172 | //"目击者"视频,小于300秒的抽帧 |
| 185 | 173 | if (CommonUtils.isNotNull(duration) && duration < 300) { |
| 186 | - shyVideos1 = avsample(shyVideos1); | |
| 174 | + avsample(shyVideos); | |
| 187 | 175 | } else { |
| 188 | 176 | //机审超过300秒的改为人工审核 |
| 189 | - shyVideos1.setShenhe_type(CommonConst.AUDIT_TYPE_USER); | |
| 177 | + shyVideos.setShenhe_type(CommonConst.AUDIT_TYPE_USER); | |
| 190 | 178 | } |
| 191 | 179 | } |
| 192 | 180 | } |
| 193 | - logger.info("当前视频类型是:" + shyVideos1.getShenhe_type()); | |
| 194 | - boolean result = videosService.impotVideo(shyVideos1); | |
| 195 | - | |
| 196 | - if (result) { | |
| 197 | - return new ResponseBean(ErrorEnum.SUCCESS); | |
| 198 | - } else { | |
| 199 | - return new ResponseBean(ErrorEnum.ERROR); | |
| 200 | - } | |
| 201 | 181 | } |
| 202 | 182 | |
| 203 | 183 | /** | ... | ... |