|
@@ -7,6 +7,7 @@ import com.liangjian11.ymall.model.UserAccount;
|
|
import com.liangjian11.ymall.model.video.*;
|
|
import com.liangjian11.ymall.model.video.*;
|
|
import com.liangjian11.ymall.service.UserAccountService;
|
|
import com.liangjian11.ymall.service.UserAccountService;
|
|
import com.liangjian11.ymall.service.video.*;
|
|
import com.liangjian11.ymall.service.video.*;
|
|
|
|
+import com.liangjian11.ymall.utils.MongoDBUtil;
|
|
import com.liangjian11.ymall.utils.RequestUtil;
|
|
import com.liangjian11.ymall.utils.RequestUtil;
|
|
import com.liangjian11.ymall.utils.video.DTO.DoctorDTO;
|
|
import com.liangjian11.ymall.utils.video.DTO.DoctorDTO;
|
|
import com.liangjian11.ymall.utils.video.DTO.PageResultInfo;
|
|
import com.liangjian11.ymall.utils.video.DTO.PageResultInfo;
|
|
@@ -16,6 +17,7 @@ import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiParam;
|
|
import io.swagger.annotations.ApiParam;
|
|
import org.apache.commons.lang.StringUtils;
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
|
+import org.bson.Document;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
@@ -49,14 +51,26 @@ public class VideoUserController {
|
|
private VideoHotsearchService videoHotsearchService;
|
|
private VideoHotsearchService videoHotsearchService;
|
|
|
|
|
|
public String getUser(HttpServletRequest request) {
|
|
public String getUser(HttpServletRequest request) {
|
|
- String userId =null;
|
|
|
|
|
|
+ String userId = null;
|
|
Cookie[] cookies = request.getCookies();
|
|
Cookie[] cookies = request.getCookies();
|
|
- for (Cookie cookie : cookies) {
|
|
|
|
- if (cookie.getName().equals("loginTokenAccount")) {
|
|
|
|
- userId = cookie.getValue();
|
|
|
|
|
|
+ if (cookies != null) {
|
|
|
|
+ for (Cookie cookie : cookies) {
|
|
|
|
+ if (cookie.getName().equals("loginTokenAccount")) {
|
|
|
|
+ userId = cookie.getValue();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ String token = RequestUtil.getRequest().getHeader("token");
|
|
|
|
+ Document document = MongoDBUtil.queryVLoginTokenByToken(token);
|
|
|
|
+ if (!Objects.isNull(document)) {
|
|
|
|
+ Date expirationDate = (Date) document.get("ExpirationDate");
|
|
|
|
+ if (expirationDate.compareTo(new Date()) <= 0) {
|
|
|
|
+ return "timeout";
|
|
|
|
+ }
|
|
|
|
+ userId = (String) document.get("AccountId");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if(!StringUtils.isEmpty(userId) && userAccountService.count(new QueryWrapper<UserAccount>().eq("id::varchar(100)",userId))>0){
|
|
|
|
|
|
+ if (!StringUtils.isEmpty(userId) && userAccountService.count(new QueryWrapper<UserAccount>().eq("id::varchar(100)", userId)) > 0) {
|
|
return userId;
|
|
return userId;
|
|
}
|
|
}
|
|
return null;
|
|
return null;
|
|
@@ -69,6 +83,8 @@ public class VideoUserController {
|
|
String userId = getUser(RequestUtil.getRequest());
|
|
String userId = getUser(RequestUtil.getRequest());
|
|
if (StringUtils.isEmpty(userId)) {
|
|
if (StringUtils.isEmpty(userId)) {
|
|
return PageResultInfo.createFail("token不能为空");
|
|
return PageResultInfo.createFail("token不能为空");
|
|
|
|
+ }else if("timeout".equals(userId)){
|
|
|
|
+ return PageResultInfo.createTimeOutFail("token/cookies过期,请重新请求授权");
|
|
}
|
|
}
|
|
return videoService.listVideoByHome(userId, selectDTO);
|
|
return videoService.listVideoByHome(userId, selectDTO);
|
|
}
|
|
}
|
|
@@ -87,6 +103,8 @@ public class VideoUserController {
|
|
String userId = getUser(RequestUtil.getRequest());
|
|
String userId = getUser(RequestUtil.getRequest());
|
|
if (StringUtils.isEmpty(userId)) {
|
|
if (StringUtils.isEmpty(userId)) {
|
|
return PageResultInfo.createFail("token不能为空");
|
|
return PageResultInfo.createFail("token不能为空");
|
|
|
|
+ }else if("timeout".equals(userId)){
|
|
|
|
+ return PageResultInfo.createTimeOutFail("token/cookies过期,请重新请求授权");
|
|
}
|
|
}
|
|
return videoService.listVideoByHomePage(userId, selectDTO);
|
|
return videoService.listVideoByHomePage(userId, selectDTO);
|
|
}
|
|
}
|
|
@@ -99,6 +117,8 @@ public class VideoUserController {
|
|
String userId = getUser(RequestUtil.getRequest());
|
|
String userId = getUser(RequestUtil.getRequest());
|
|
if (StringUtils.isEmpty(userId)) {
|
|
if (StringUtils.isEmpty(userId)) {
|
|
return PageResultInfo.createFail("token不能为空");
|
|
return PageResultInfo.createFail("token不能为空");
|
|
|
|
+ }else if("timeout".equals(userId)){
|
|
|
|
+ return PageResultInfo.createTimeOutFail("token/cookies过期,请重新请求授权");
|
|
}
|
|
}
|
|
if (video.getId() != null) {
|
|
if (video.getId() != null) {
|
|
video = videoService.getPlayInfo(video.getId(), userId);
|
|
video = videoService.getPlayInfo(video.getId(), userId);
|
|
@@ -113,8 +133,10 @@ public class VideoUserController {
|
|
String userId = getUser(RequestUtil.getRequest());
|
|
String userId = getUser(RequestUtil.getRequest());
|
|
if (StringUtils.isEmpty(userId)) {
|
|
if (StringUtils.isEmpty(userId)) {
|
|
return PageResultInfo.createFail("token不能为空");
|
|
return PageResultInfo.createFail("token不能为空");
|
|
|
|
+ }else if("timeout".equals(userId)){
|
|
|
|
+ return PageResultInfo.createTimeOutFail("token/cookies过期,请重新请求授权");
|
|
}
|
|
}
|
|
- if(!StringUtils.isEmpty(selectDTO.getName())){
|
|
|
|
|
|
+ if (!StringUtils.isEmpty(selectDTO.getName())) {
|
|
VideoHotsearch videoHotsearch = new VideoHotsearch();
|
|
VideoHotsearch videoHotsearch = new VideoHotsearch();
|
|
videoHotsearch.setSuperiorName(selectDTO.getName());
|
|
videoHotsearch.setSuperiorName(selectDTO.getName());
|
|
videoHotsearch.setSubordinateID(userId);
|
|
videoHotsearch.setSubordinateID(userId);
|
|
@@ -136,6 +158,8 @@ public class VideoUserController {
|
|
String userId = getUser(RequestUtil.getRequest());
|
|
String userId = getUser(RequestUtil.getRequest());
|
|
if (StringUtils.isEmpty(userId)) {
|
|
if (StringUtils.isEmpty(userId)) {
|
|
return PageResultInfo.createFail("token不能为空");
|
|
return PageResultInfo.createFail("token不能为空");
|
|
|
|
+ }else if("timeout".equals(userId)){
|
|
|
|
+ return PageResultInfo.createTimeOutFail("token/cookies过期,请重新请求授权");
|
|
}
|
|
}
|
|
return videoService.getDoctorVideoPage(userId, selectDTO);
|
|
return videoService.getDoctorVideoPage(userId, selectDTO);
|
|
}
|
|
}
|
|
@@ -154,6 +178,8 @@ public class VideoUserController {
|
|
String userId = getUser(RequestUtil.getRequest());
|
|
String userId = getUser(RequestUtil.getRequest());
|
|
if (StringUtils.isEmpty(userId)) {
|
|
if (StringUtils.isEmpty(userId)) {
|
|
return PageResultInfo.createFail("token不能为空");
|
|
return PageResultInfo.createFail("token不能为空");
|
|
|
|
+ }else if("timeout".equals(userId)){
|
|
|
|
+ return PageResultInfo.createTimeOutFail("token/cookies过期,请重新请求授权");
|
|
}
|
|
}
|
|
return videoUserAttentionService.getUserFollowList(userId, selectDTO);
|
|
return videoUserAttentionService.getUserFollowList(userId, selectDTO);
|
|
}
|
|
}
|
|
@@ -164,6 +190,8 @@ public class VideoUserController {
|
|
String userId = getUser(RequestUtil.getRequest());
|
|
String userId = getUser(RequestUtil.getRequest());
|
|
if (StringUtils.isEmpty(userId)) {
|
|
if (StringUtils.isEmpty(userId)) {
|
|
return PageResultInfo.createFail("token不能为空");
|
|
return PageResultInfo.createFail("token不能为空");
|
|
|
|
+ }else if("timeout".equals(userId)){
|
|
|
|
+ return PageResultInfo.createTimeOutFail("token/cookies过期,请重新请求授权");
|
|
}
|
|
}
|
|
return videoService.getMyLikeList(userId, selectDTO);
|
|
return videoService.getMyLikeList(userId, selectDTO);
|
|
}
|
|
}
|
|
@@ -175,10 +203,12 @@ public class VideoUserController {
|
|
String userId = getUser(RequestUtil.getRequest());
|
|
String userId = getUser(RequestUtil.getRequest());
|
|
if (StringUtils.isEmpty(userId)) {
|
|
if (StringUtils.isEmpty(userId)) {
|
|
return PageResultInfo.createFail("token不能为空");
|
|
return PageResultInfo.createFail("token不能为空");
|
|
|
|
+ }else if("timeout".equals(userId)){
|
|
|
|
+ return PageResultInfo.createTimeOutFail("token/cookies过期,请重新请求授权");
|
|
}
|
|
}
|
|
VideoStatisticsIntermediate oldPlayLog = videoStatisticsIntermediateService.getOne(new QueryWrapper<VideoStatisticsIntermediate>().eq("superior_id", video.getId()).eq("subordinate_id", userId));
|
|
VideoStatisticsIntermediate oldPlayLog = videoStatisticsIntermediateService.getOne(new QueryWrapper<VideoStatisticsIntermediate>().eq("superior_id", video.getId()).eq("subordinate_id", userId));
|
|
- VideoStatisticsIntermediate playLog = null;
|
|
|
|
- if(Objects.isNull(oldPlayLog)){
|
|
|
|
|
|
+ VideoStatisticsIntermediate playLog = null;
|
|
|
|
+ if (Objects.isNull(oldPlayLog)) {
|
|
playLog = new VideoStatisticsIntermediate();
|
|
playLog = new VideoStatisticsIntermediate();
|
|
playLog.setSuperiorID(video.getId());
|
|
playLog.setSuperiorID(video.getId());
|
|
playLog.setSubordinateID(userId);
|
|
playLog.setSubordinateID(userId);
|
|
@@ -188,7 +218,7 @@ public class VideoUserController {
|
|
playLog.setType(7);
|
|
playLog.setType(7);
|
|
playLog.setCreateTime(new Date());
|
|
playLog.setCreateTime(new Date());
|
|
playLog.setUpdateTime(playLog.getCreateTime());
|
|
playLog.setUpdateTime(playLog.getCreateTime());
|
|
- }else{
|
|
|
|
|
|
+ } else {
|
|
playLog = oldPlayLog;
|
|
playLog = oldPlayLog;
|
|
playLog.setUpdateTime(new Date());
|
|
playLog.setUpdateTime(new Date());
|
|
}
|
|
}
|
|
@@ -206,8 +236,10 @@ public class VideoUserController {
|
|
String userId = getUser(RequestUtil.getRequest());
|
|
String userId = getUser(RequestUtil.getRequest());
|
|
if (StringUtils.isEmpty(userId)) {
|
|
if (StringUtils.isEmpty(userId)) {
|
|
return PageResultInfo.createFail("token不能为空");
|
|
return PageResultInfo.createFail("token不能为空");
|
|
|
|
+ }else if("timeout".equals(userId)){
|
|
|
|
+ return PageResultInfo.createTimeOutFail("token/cookies过期,请重新请求授权");
|
|
}
|
|
}
|
|
- if(videoLikeIntermediateService.count(new QueryWrapper<VideoLikeIntermediate>().eq("superior_id",video.getId()).eq("subordinate_id",userId))>0){
|
|
|
|
|
|
+ if (videoLikeIntermediateService.count(new QueryWrapper<VideoLikeIntermediate>().eq("superior_id", video.getId()).eq("subordinate_id", userId)) > 0) {
|
|
return PageResultInfo.createFail("保存失败,已有用户点赞记录");
|
|
return PageResultInfo.createFail("保存失败,已有用户点赞记录");
|
|
}
|
|
}
|
|
VideoLikeIntermediate likeLog = new VideoLikeIntermediate();
|
|
VideoLikeIntermediate likeLog = new VideoLikeIntermediate();
|
|
@@ -234,6 +266,8 @@ public class VideoUserController {
|
|
String userId = getUser(RequestUtil.getRequest());
|
|
String userId = getUser(RequestUtil.getRequest());
|
|
if (StringUtils.isEmpty(userId)) {
|
|
if (StringUtils.isEmpty(userId)) {
|
|
return PageResultInfo.createFail("token不能为空");
|
|
return PageResultInfo.createFail("token不能为空");
|
|
|
|
+ }else if("timeout".equals(userId)){
|
|
|
|
+ return PageResultInfo.createTimeOutFail("token/cookies过期,请重新请求授权");
|
|
}
|
|
}
|
|
if (videoLikeIntermediateService.remove(new QueryWrapper<VideoLikeIntermediate>().eq("superior_id", video.getId()).eq("subordinate_id", userId))) {
|
|
if (videoLikeIntermediateService.remove(new QueryWrapper<VideoLikeIntermediate>().eq("superior_id", video.getId()).eq("subordinate_id", userId))) {
|
|
return PageResultInfo.createSuccess("用户取消点赞成功", null);
|
|
return PageResultInfo.createSuccess("用户取消点赞成功", null);
|
|
@@ -249,6 +283,8 @@ public class VideoUserController {
|
|
String userId = getUser(RequestUtil.getRequest());
|
|
String userId = getUser(RequestUtil.getRequest());
|
|
if (StringUtils.isEmpty(userId)) {
|
|
if (StringUtils.isEmpty(userId)) {
|
|
return PageResultInfo.createFail("token不能为空");
|
|
return PageResultInfo.createFail("token不能为空");
|
|
|
|
+ }else if("timeout".equals(userId)){
|
|
|
|
+ return PageResultInfo.createTimeOutFail("token/cookies过期,请重新请求授权");
|
|
}
|
|
}
|
|
VideoStatisticsIntermediate shareLog = new VideoStatisticsIntermediate();
|
|
VideoStatisticsIntermediate shareLog = new VideoStatisticsIntermediate();
|
|
shareLog.setSuperiorID(video.getId());
|
|
shareLog.setSuperiorID(video.getId());
|
|
@@ -273,8 +309,10 @@ public class VideoUserController {
|
|
String userId = getUser(RequestUtil.getRequest());
|
|
String userId = getUser(RequestUtil.getRequest());
|
|
if (StringUtils.isEmpty(userId)) {
|
|
if (StringUtils.isEmpty(userId)) {
|
|
return PageResultInfo.createFail("token不能为空");
|
|
return PageResultInfo.createFail("token不能为空");
|
|
|
|
+ }else if("timeout".equals(userId)){
|
|
|
|
+ return PageResultInfo.createTimeOutFail("token/cookies过期,请重新请求授权");
|
|
}
|
|
}
|
|
- if(videoUserAttentionService.count(new QueryWrapper<VideoUserAttention>().eq("superior_id",doctor.getId()).eq("subordinate_id",userId))>0){
|
|
|
|
|
|
+ if (videoUserAttentionService.count(new QueryWrapper<VideoUserAttention>().eq("superior_id", doctor.getId()).eq("subordinate_id", userId)) > 0) {
|
|
return PageResultInfo.createFail("保存失败,已有用户关注该医生记录");
|
|
return PageResultInfo.createFail("保存失败,已有用户关注该医生记录");
|
|
}
|
|
}
|
|
VideoUserAttention attentionLog = new VideoUserAttention();
|
|
VideoUserAttention attentionLog = new VideoUserAttention();
|
|
@@ -300,6 +338,8 @@ public class VideoUserController {
|
|
String userId = getUser(RequestUtil.getRequest());
|
|
String userId = getUser(RequestUtil.getRequest());
|
|
if (StringUtils.isEmpty(userId)) {
|
|
if (StringUtils.isEmpty(userId)) {
|
|
return PageResultInfo.createFail("token不能为空");
|
|
return PageResultInfo.createFail("token不能为空");
|
|
|
|
+ }else if("timeout".equals(userId)){
|
|
|
|
+ return PageResultInfo.createTimeOutFail("token/cookies过期,请重新请求授权");
|
|
}
|
|
}
|
|
if (videoUserAttentionService.remove(new QueryWrapper<VideoUserAttention>().eq("superior_id", doctor.getId()).eq("subordinate_id", userId))) {
|
|
if (videoUserAttentionService.remove(new QueryWrapper<VideoUserAttention>().eq("superior_id", doctor.getId()).eq("subordinate_id", userId))) {
|
|
return PageResultInfo.createSuccess("用户取关医生成功", null);
|
|
return PageResultInfo.createSuccess("用户取关医生成功", null);
|
|
@@ -315,6 +355,8 @@ public class VideoUserController {
|
|
String userId = getUser(RequestUtil.getRequest());
|
|
String userId = getUser(RequestUtil.getRequest());
|
|
if (StringUtils.isEmpty(userId)) {
|
|
if (StringUtils.isEmpty(userId)) {
|
|
return PageResultInfo.createFail("token不能为空");
|
|
return PageResultInfo.createFail("token不能为空");
|
|
|
|
+ }else if("timeout".equals(userId)){
|
|
|
|
+ return PageResultInfo.createTimeOutFail("token/cookies过期,请重新请求授权");
|
|
}
|
|
}
|
|
if (videoCommentDTO.getVideoID() == null || StringUtils.isEmpty(videoCommentDTO.getContent())) {
|
|
if (videoCommentDTO.getVideoID() == null || StringUtils.isEmpty(videoCommentDTO.getContent())) {
|
|
return PageResultInfo.createFail("缺少参数");
|
|
return PageResultInfo.createFail("缺少参数");
|