Commit a7e75e691c3a3787f2f981c2a81a13749b2ef66c

Authored by 王言钊
1 parent 7d17caf4

根据阿里巴巴开发手册、优化编码规范

src/main/java/com/cnlive/shenhe/api/CommentsControllerApi.java
@@ -70,7 +70,6 @@ public class CommentsControllerApi { @@ -70,7 +70,6 @@ public class CommentsControllerApi {
70 try { 70 try {
71 spId = json.getInteger("spId"); 71 spId = json.getInteger("spId");
72 } catch (Exception e) { 72 } catch (Exception e) {
73 - spId = null;  
74 } 73 }
75 //存在则更新 74 //存在则更新
76 if (commentsList.size() > 0) { 75 if (commentsList.size() > 0) {
src/main/java/com/cnlive/shenhe/api/ContentControllerApi.java
@@ -203,7 +203,7 @@ public class ContentControllerApi { @@ -203,7 +203,7 @@ public class ContentControllerApi {
203 shyContent1.setShenhe_type(shenheType); 203 shyContent1.setShenhe_type(shenheType);
204 //朋友圈内容创建时间 204 //朋友圈内容创建时间
205 String contentTime = json.getString("createTime"); 205 String contentTime = json.getString("createTime");
206 - shyContent1.setContent_time(new Date(Long.valueOf(contentTime))); 206 + shyContent1.setContent_time(new Date(Long.parseLong(contentTime)));
207 shyContent1.setCreate_date(CommonUtils.getCurrentTime()); 207 shyContent1.setCreate_date(CommonUtils.getCurrentTime());
208 //回调地址 208 //回调地址
209 shyContent1.setCallback(json.getString("callbackUrl")); 209 shyContent1.setCallback(json.getString("callbackUrl"));
@@ -243,7 +243,7 @@ public class ContentControllerApi { @@ -243,7 +243,7 @@ public class ContentControllerApi {
243 shyContent.setContent_status(1); 243 shyContent.setContent_status(1);
244 //创建时间 244 //创建时间
245 String contentTime = json.getString("createTime"); 245 String contentTime = json.getString("createTime");
246 - shyContent.setContent_time(new Date(Long.valueOf(contentTime))); 246 + shyContent.setContent_time(new Date(Long.parseLong(contentTime)));
247 shyContent.setCreate_date(CommonUtils.getCurrentTime()); 247 shyContent.setCreate_date(CommonUtils.getCurrentTime());
248 //回调地址 248 //回调地址
249 shyContent.setCallback(json.getString("callbackUrl")); 249 shyContent.setCallback(json.getString("callbackUrl"));
src/main/java/com/cnlive/shenhe/api/LiveApplyControllerApi.java
@@ -48,7 +48,6 @@ public class LiveApplyControllerApi { @@ -48,7 +48,6 @@ public class LiveApplyControllerApi {
48 try { 48 try {
49 spId = json.getInteger("spId"); 49 spId = json.getInteger("spId");
50 } catch (Exception e) { 50 } catch (Exception e) {
51 - spId = null;  
52 } 51 }
53 //直播发起人 52 //直播发起人
54 String sender = json.getString("sender"); 53 String sender = json.getString("sender");
@@ -84,13 +83,13 @@ public class LiveApplyControllerApi { @@ -84,13 +83,13 @@ public class LiveApplyControllerApi {
84 String startTime = json.getString("preStartTime"); 83 String startTime = json.getString("preStartTime");
85 Date timestampStart = null; 84 Date timestampStart = null;
86 if (CommonUtils.isNotEmpty(startTime)) { 85 if (CommonUtils.isNotEmpty(startTime)) {
87 - timestampStart = new Timestamp(Long.valueOf(startTime)); 86 + timestampStart = new Timestamp(Long.parseLong(startTime));
88 } 87 }
89 //预计结束时间 88 //预计结束时间
90 String endTime = json.getString("preEndTime"); 89 String endTime = json.getString("preEndTime");
91 Date timestampEnd = null; 90 Date timestampEnd = null;
92 if (CommonUtils.isNotEmpty(endTime)) { 91 if (CommonUtils.isNotEmpty(endTime)) {
93 - timestampEnd = new Timestamp(Long.valueOf(endTime)); 92 + timestampEnd = new Timestamp(Long.parseLong(endTime));
94 } 93 }
95 ShyLiveapply shyliveApply1 = new ShyLiveapply(); 94 ShyLiveapply shyliveApply1 = new ShyLiveapply();
96 //得到直播活动id去查询是否已有 95 //得到直播活动id去查询是否已有
src/main/java/com/cnlive/shenhe/api/LiveControllerApi.java
@@ -73,13 +73,13 @@ public class LiveControllerApi { @@ -73,13 +73,13 @@ public class LiveControllerApi {
73 73
74 Date timestampStart = null; 74 Date timestampStart = null;
75 if (CommonUtils.isNotEmpty(startTime)) { 75 if (CommonUtils.isNotEmpty(startTime)) {
76 - timestampStart = new Timestamp(Long.valueOf(startTime)); 76 + timestampStart = new Timestamp(Long.parseLong(startTime));
77 } 77 }
78 //结束时间 78 //结束时间
79 String endTime = json.getString("endTime"); 79 String endTime = json.getString("endTime");
80 Date timestampEnd = null; 80 Date timestampEnd = null;
81 if (CommonUtils.isNotEmpty(endTime)) { 81 if (CommonUtils.isNotEmpty(endTime)) {
82 - timestampEnd = new Timestamp(Long.valueOf(endTime)); 82 + timestampEnd = new Timestamp(Long.parseLong(endTime));
83 } 83 }
84 84
85 //预计开始时间 85 //预计开始时间
@@ -87,13 +87,13 @@ public class LiveControllerApi { @@ -87,13 +87,13 @@ public class LiveControllerApi {
87 87
88 Date preTimestampStart = null; 88 Date preTimestampStart = null;
89 if (CommonUtils.isNotEmpty(preStartTime)) { 89 if (CommonUtils.isNotEmpty(preStartTime)) {
90 - preTimestampStart = new Timestamp(Long.valueOf(preStartTime)); 90 + preTimestampStart = new Timestamp(Long.parseLong(preStartTime));
91 } 91 }
92 //预计结束时间 92 //预计结束时间
93 String preEndTime = json.getString("preEndTime"); 93 String preEndTime = json.getString("preEndTime");
94 Date preTimestampEnd = null; 94 Date preTimestampEnd = null;
95 if (CommonUtils.isNotEmpty(preEndTime)) { 95 if (CommonUtils.isNotEmpty(preEndTime)) {
96 - preTimestampEnd = new Timestamp(Long.valueOf(preEndTime)); 96 + preTimestampEnd = new Timestamp(Long.parseLong(preEndTime));
97 } 97 }
98 98
99 ShyLive shylive1 = new ShyLive(); 99 ShyLive shylive1 = new ShyLive();
src/main/java/com/cnlive/shenhe/api/TopicControllerApi.java
@@ -48,7 +48,6 @@ public class TopicControllerApi { @@ -48,7 +48,6 @@ public class TopicControllerApi {
48 try { 48 try {
49 spId = json.getInteger("spId"); 49 spId = json.getInteger("spId");
50 } catch (Exception e) { 50 } catch (Exception e) {
51 - spId = null;  
52 } 51 }
53 //话题标题 52 //话题标题
54 String topicTitle = json.getString("topicTitle"); 53 String topicTitle = json.getString("topicTitle");
src/main/java/com/cnlive/shenhe/api/VideosControllerApi.java
@@ -64,7 +64,9 @@ public class VideosControllerApi { @@ -64,7 +64,9 @@ public class VideosControllerApi {
64 //目击者类型 0-目击者 1-童声共济 2-全民健身 3-目击者政府监督 64 //目击者类型 0-目击者 1-童声共济 2-全民健身 3-目击者政府监督
65 String source = json.getString("source"); 65 String source = json.getString("source");
66 Integer duration = json.getInteger("duration"); 66 Integer duration = json.getInteger("duration");
67 - if (CommonUtils.isNotNull(duration)) duration = duration / 1000; 67 + if (CommonUtils.isNotNull(duration)) {
  68 + duration = duration / 1000;
  69 + }
68 //获取栏目分类 70 //获取栏目分类
69 String category = CommonUtils.isEmpty(json.getString("multiplecategory")) ? "" : json.getString("multiplecategory"); 71 String category = CommonUtils.isEmpty(json.getString("multiplecategory")) ? "" : json.getString("multiplecategory");
70 //获取上传人的id 72 //获取上传人的id
@@ -113,8 +115,8 @@ public class VideosControllerApi { @@ -113,8 +115,8 @@ public class VideosControllerApi {
113 shyVideos.setUpdated_at(CommonUtils.getCurrentTime()); 115 shyVideos.setUpdated_at(CommonUtils.getCurrentTime());
114 //获取审核类型 116 //获取审核类型
115 videosService.getShenheType(shyVideos); 117 videosService.getShenheType(shyVideos);
116 - boolean YorN = videosService.updateshyVideos(shyVideos);  
117 - if (YorN == true) { 118 + boolean yorN = videosService.updateshyVideos(shyVideos);
  119 + if (yorN) {
118 return new ResponseBean(ErrorEnum.SUCCESS); 120 return new ResponseBean(ErrorEnum.SUCCESS);
119 } else { 121 } else {
120 return new ResponseBean(ErrorEnum.ERROR); 122 return new ResponseBean(ErrorEnum.ERROR);
@@ -170,15 +172,15 @@ public class VideosControllerApi { @@ -170,15 +172,15 @@ public class VideosControllerApi {
170 //获取审核类型 172 //获取审核类型
171 videosService.getShenheType(shyVideos1); 173 videosService.getShenheType(shyVideos1);
172 174
173 - if (shyVideos1.getShenhe_type() != CommonConst.AUDIT_TYPE_FREE) { 175 + if (!shyVideos1.getShenhe_type().equals(CommonConst.AUDIT_TYPE_FREE)) {
174 //如果审核类型是人工审核,按照原有规则 176 //如果审核类型是人工审核,按照原有规则
175 - if (shyVideos1.getShenhe_type() == CommonConst.AUDIT_TYPE_USER) { 177 + if (shyVideos1.getShenhe_type().equals(CommonConst.AUDIT_TYPE_USER)) {
176 if (CommonUtils.isNotNull(duration) && duration > 80) { 178 if (CommonUtils.isNotNull(duration) && duration > 80) {
177 //视频至少可以抽8张,请求抽帧 179 //视频至少可以抽8张,请求抽帧
178 shyVideos1 = avsample(shyVideos1); 180 shyVideos1 = avsample(shyVideos1);
179 } 181 }
180 //如果审核类型是机审 182 //如果审核类型是机审
181 - } else if (shyVideos1.getShenhe_type() == CommonConst.AUDIT_TYPE_MACHANE) { 183 + } else if (shyVideos1.getShenhe_type().equals(CommonConst.AUDIT_TYPE_MACHANE)) {
182 //"目击者"视频,小于300秒的抽帧 184 //"目击者"视频,小于300秒的抽帧
183 if (CommonUtils.isNotNull(duration) && duration < 300) { 185 if (CommonUtils.isNotNull(duration) && duration < 300) {
184 shyVideos1 = avsample(shyVideos1); 186 shyVideos1 = avsample(shyVideos1);
@@ -191,7 +193,7 @@ public class VideosControllerApi { @@ -191,7 +193,7 @@ public class VideosControllerApi {
191 logger.info("当前视频类型是:" + shyVideos1.getShenhe_type()); 193 logger.info("当前视频类型是:" + shyVideos1.getShenhe_type());
192 boolean result = videosService.impotVideo(shyVideos1); 194 boolean result = videosService.impotVideo(shyVideos1);
193 195
194 - if (result == true) { 196 + if (result) {
195 return new ResponseBean(ErrorEnum.SUCCESS); 197 return new ResponseBean(ErrorEnum.SUCCESS);
196 } else { 198 } else {
197 return new ResponseBean(ErrorEnum.ERROR); 199 return new ResponseBean(ErrorEnum.ERROR);
@@ -249,11 +251,11 @@ public class VideosControllerApi { @@ -249,11 +251,11 @@ public class VideosControllerApi {
249 } 251 }
250 logger.info("抽帧attach参数:attach:{}", attach); 252 logger.info("抽帧attach参数:attach:{}", attach);
251 extParam.put("domain", domainName); 253 extParam.put("domain", domainName);
252 - if (CommonConst.KS_PLAT == plat) { 254 + if (CommonConst.KS_PLAT.equals(plat)) {
253 //金山 255 //金山
254 params.put("plat", 0); 256 params.put("plat", 0);
255 params.put("dstBucket", ks_bucket); 257 params.put("dstBucket", ks_bucket);
256 - } else if (CommonConst.QINIU_PLAT == plat) { 258 + } else if (CommonConst.QINIU_PLAT.equals(plat)) {
257 //七牛 259 //七牛
258 params.put("plat", 1); 260 params.put("plat", 1);
259 params.put("dstBucket", qn_bucket); 261 params.put("dstBucket", qn_bucket);
@@ -296,6 +298,4 @@ public class VideosControllerApi { @@ -296,6 +298,4 @@ public class VideosControllerApi {
296 } 298 }
297 return video; 299 return video;
298 } 300 }
299 -  
300 -  
301 } 301 }
src/main/java/com/cnlive/shenhe/config/SessionFilter.java
@@ -48,19 +48,16 @@ public class SessionFilter implements Filter { @@ -48,19 +48,16 @@ public class SessionFilter implements Filter {
48 48
49 if (isInclude(url)) { 49 if (isInclude(url)) {
50 chain.doFilter(httpRequest, httpResponse); 50 chain.doFilter(httpRequest, httpResponse);
51 - return;  
52 } else { 51 } else {
53 HttpSession session = httpRequest.getSession(); 52 HttpSession session = httpRequest.getSession();
54 if (session.getAttribute(SessionUser.getSessionKey()) != null) { 53 if (session.getAttribute(SessionUser.getSessionKey()) != null) {
55 // session存在 54 // session存在
56 chain.doFilter(httpRequest, httpResponse); 55 chain.doFilter(httpRequest, httpResponse);
57 - return;  
58 } else { 56 } else {
59 // session不存在 准备跳转失败 57 // session不存在 准备跳转失败
60 RequestDispatcher dispatcher = request.getRequestDispatcher("/users/login"); 58 RequestDispatcher dispatcher = request.getRequestDispatcher("/users/login");
61 dispatcher.forward(request, response); 59 dispatcher.forward(request, response);
62 //chain.doFilter(httpRequest, httpResponse); 60 //chain.doFilter(httpRequest, httpResponse);
63 - return;  
64 } 61 }
65 } 62 }
66 63
src/main/java/com/cnlive/shenhe/serviceImpl/AudioServiceImpl.java
@@ -373,7 +373,7 @@ public class AudioServiceImpl { @@ -373,7 +373,7 @@ public class AudioServiceImpl {
373 } 373 }
374 } 374 }
375 //默认按上传时间倒序排序 375 //默认按上传时间倒序排序
376 - //example.setOrderByClause("video_upload_time desc"); 376 + example.setOrderByClause("createTime desc");
377 List<ShyAudio> shyAudioList = shyAudioMapper.selectByExample(example); 377 List<ShyAudio> shyAudioList = shyAudioMapper.selectByExample(example);
378 return shyAudioList; 378 return shyAudioList;
379 } 379 }
src/main/java/com/cnlive/shenhe/serviceImpl/CommentsServiceImpl.java
@@ -112,9 +112,9 @@ public class CommentsServiceImpl { @@ -112,9 +112,9 @@ public class CommentsServiceImpl {
112 if (CommonUtils.isNotNull(commentsDTO.getComment_user_id())) { 112 if (CommonUtils.isNotNull(commentsDTO.getComment_user_id())) {
113 criteria.andEqualTo("comment_user_id", commentsDTO.getComment_user_id()); 113 criteria.andEqualTo("comment_user_id", commentsDTO.getComment_user_id());
114 } 114 }
115 - if (CommonUtils.isNotEmpty(commentsDTO.getType()) && Integer.valueOf(commentsDTO.getType()) == 0) { 115 + if (CommonUtils.isNotEmpty(commentsDTO.getType()) && Integer.parseInt(commentsDTO.getType()) == 0) {
116 criteria.andEqualTo("type", CommonConst.CATEGORY_TOPIC); 116 criteria.andEqualTo("type", CommonConst.CATEGORY_TOPIC);
117 - } else if (CommonUtils.isNotEmpty(commentsDTO.getType()) && Integer.valueOf(commentsDTO.getType()) == 1) { 117 + } else if (CommonUtils.isNotEmpty(commentsDTO.getType()) && Integer.parseInt(commentsDTO.getType()) == 1) {
118 criteria.andEqualTo("type", CommonConst.CATEGORY_ELSE); 118 criteria.andEqualTo("type", CommonConst.CATEGORY_ELSE);
119 } 119 }
120 if (CommonUtils.isNotEmpty(commentsDTO.getActivity_id())) { 120 if (CommonUtils.isNotEmpty(commentsDTO.getActivity_id())) {
@@ -169,9 +169,9 @@ public class CommentsServiceImpl { @@ -169,9 +169,9 @@ public class CommentsServiceImpl {
169 if (CommonUtils.isNotNull(commentsDTO.getIs_hot())) { 169 if (CommonUtils.isNotNull(commentsDTO.getIs_hot())) {
170 criteria.andEqualTo("is_hot", commentsDTO.getIs_hot()); 170 criteria.andEqualTo("is_hot", commentsDTO.getIs_hot());
171 } 171 }
172 - if (CommonUtils.isNotEmpty(commentsDTO.getType()) && Integer.valueOf(commentsDTO.getType()) == 0) { 172 + if (CommonUtils.isNotEmpty(commentsDTO.getType()) && Integer.parseInt(commentsDTO.getType()) == 0) {
173 criteria.andEqualTo("type", CommonConst.CATEGORY_TOPIC); 173 criteria.andEqualTo("type", CommonConst.CATEGORY_TOPIC);
174 - } else if (CommonUtils.isNotEmpty(commentsDTO.getType()) && Integer.valueOf(commentsDTO.getType()) == 1) { 174 + } else if (CommonUtils.isNotEmpty(commentsDTO.getType()) && Integer.parseInt(commentsDTO.getType()) == 1) {
175 criteria.andIsNull("type"); 175 criteria.andIsNull("type");
176 } 176 }
177 if (CommonUtils.isNotEmpty(commentsDTO.getActivity_id())) { 177 if (CommonUtils.isNotEmpty(commentsDTO.getActivity_id())) {
src/main/java/com/cnlive/shenhe/serviceImpl/LiveApplyServiceImpl.java
@@ -77,19 +77,6 @@ public class LiveApplyServiceImpl { @@ -77,19 +77,6 @@ public class LiveApplyServiceImpl {
77 } 77 }
78 78
79 /** 79 /**
80 - * 根据活动id查询直播申请对象  
81 - *  
82 - * @param activity_id  
83 - * @return  
84 - */  
85 - public ShyLiveapply queryshyLiveApply(String activity_id) {  
86 - ShyLiveapply shyLiveApply = new ShyLiveapply();  
87 - shyLiveApply.setActivity_id(activity_id);  
88 - List<ShyLiveapply> shyLiveApplylist = shyLiveApplyMapper.select(shyLiveApply);  
89 - return shyLiveApplylist.get(0);  
90 - }  
91 -  
92 - /**  
93 * 修改直播申请对象 返回布尔类型 80 * 修改直播申请对象 返回布尔类型
94 * 81 *
95 * @param shyLiveApply 82 * @param shyLiveApply
src/main/java/com/cnlive/shenhe/serviceImpl/VideosServiceImpl.java
@@ -441,9 +441,8 @@ public class VideosServiceImpl { @@ -441,9 +441,8 @@ public class VideosServiceImpl {
441 * 441 *
442 * @param video 442 * @param video
443 * @param dianboState 视频状态,1通过,2不通过 443 * @param dianboState 视频状态,1通过,2不通过
444 - * @return  
445 */ 444 */
446 - public int updateDianboAndShenhe(ShyVideos video, int dianboState) { 445 + public void updateDianboAndShenhe(ShyVideos video, int dianboState) {
447 //修改点播云的视频状态 446 //修改点播云的视频状态
448 JSONObject result = pass.auditPass(video.getVideo_id(), dianboState, video.getMsg(), video.getMsg(), video.getCallback()); 447 JSONObject result = pass.auditPass(video.getVideo_id(), dianboState, video.getMsg(), video.getMsg(), video.getCallback());
449 logger.error("点播回调result:{}", result); 448 logger.error("点播回调result:{}", result);
@@ -461,7 +460,6 @@ public class VideosServiceImpl { @@ -461,7 +460,6 @@ public class VideosServiceImpl {
461 if (i != 1) { 460 if (i != 1) {
462 logger.error("点播视频更改失败,activity_id:{}", video.getVideo_id()); 461 logger.error("点播视频更改失败,activity_id:{}", video.getVideo_id());
463 } 462 }
464 - return i;  
465 } else { 463 } else {
466 video.setMsg("点播视频回调失败," + video.getMsg()); 464 video.setMsg("点播视频回调失败," + video.getMsg());
467 videosService.updateVideo(video.getId(), null, video.getUpdater(), "", CommonConst.AUDIT_CALLBACK_FAIL, video.getMsg()); 465 videosService.updateVideo(video.getId(), null, video.getUpdater(), "", CommonConst.AUDIT_CALLBACK_FAIL, video.getMsg());
@@ -477,14 +475,12 @@ public class VideosServiceImpl { @@ -477,14 +475,12 @@ public class VideosServiceImpl {
477 if (i != 1) { 475 if (i != 1) {
478 logger.error("点播视频更改失败,activity_id:{}", video.getVideo_id()); 476 logger.error("点播视频更改失败,activity_id:{}", video.getVideo_id());
479 } 477 }
480 - return i;  
481 } else { 478 } else {
482 video.setMsg("点播视频回调失败," + video.getMsg()); 479 video.setMsg("点播视频回调失败," + video.getMsg());
483 videosService.updateVideo(video.getId(), null, video.getUpdater(), "", CommonConst.AUDIT_CALLBACK_FAIL, video.getMsg()); 480 videosService.updateVideo(video.getId(), null, video.getUpdater(), "", CommonConst.AUDIT_CALLBACK_FAIL, video.getMsg());
484 logger.error("点播视频回调失败,activity_id:{},code:{},msg:{}", video.getVideo_id(), code, result.getString("msg")); 481 logger.error("点播视频回调失败,activity_id:{},code:{},msg:{}", video.getVideo_id(), code, result.getString("msg"));
485 } 482 }
486 } 483 }
487 - return 0;  
488 } 484 }
489 485
490 486
@@ -499,7 +495,7 @@ public class VideosServiceImpl { @@ -499,7 +495,7 @@ public class VideosServiceImpl {
499 logger.info("====sites:{}", sites.toString()); 495 logger.info("====sites:{}", sites.toString());
500 String source = shyVideo.getSource(); 496 String source = shyVideo.getSource();
501 // 根据source 查询审核类型 source有传空的时候 默认给0 497 // 根据source 查询审核类型 source有传空的时候 默认给0
502 - Integer shType = shyActivityImpl.selectBySource(StringUtils.isEmpty(source) ? 0 : Integer.valueOf(source)); 498 + Integer shType = shyActivityImpl.selectBySource(StringUtils.isEmpty(source) ? Integer.valueOf(0) : Integer.valueOf(source));
503 logger.info("审核类型为:{}", shType); 499 logger.info("审核类型为:{}", shType);
504 ShyUsersfree shyUserfree = null; 500 ShyUsersfree shyUserfree = null;
505 //如果用户id存在 501 //如果用户id存在