Commit c1ade4081a7c8fab10b0d8c6f0f84557d4a546a1

Authored by 王言钊
1 parent ad09c3c6

优化直播、直播申请api

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/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 }
... ...