Commit a7e75e691c3a3787f2f981c2a81a13749b2ef66c

Authored by 王言钊
1 parent 7d17caf4

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

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