cbx
zmyYYDS 2024-01-14 20:40:25 +08:00
parent c21ad2de7c
commit 0d1707aa56
10 changed files with 46 additions and 64 deletions

View File

@ -26,9 +26,13 @@ public class HealthUserVideoController{
}
@GetMapping("/findVideoVoList")
public HealthR<List<VideoVo>> findVideoVoList(@RequestParam Integer categoryId,@RequestParam Integer page,@RequestParam Integer count){
public HealthR<List<VideoVo>> findVideoVoList(@RequestParam Integer categoryId,
@RequestParam Integer page,
@RequestParam Integer count,
@RequestHeader Integer userId,
@RequestHeader String sessionId){
startPage(page,count);
List<VideoVo> List = healthUserVideoService.findVideoVoList(categoryId);
List<VideoVo> List = healthUserVideoService.findVideoVoList(categoryId,userId);
return HealthR.ok(List);
}

View File

@ -23,7 +23,7 @@ public class VideoController {
private VideoService videoService;
//收藏健康讲堂视频列表
@PostMapping("/verify/v1/addUserVideoCollection/{videoId}")
public HealthR addUserVideoCollection(@RequestParam Integer videoId){
public HealthR addUserVideoCollection(@PathVariable Integer videoId){
videoService.addUserVideoCollection(videoId);
return HealthR.ok();
}
@ -34,6 +34,7 @@ public class VideoController {
return HealthR.ok();
}
//评论列表
@GetMapping("/v1/findVideoCommentList")
public HealthR<List<VideoCommentVo>> findVideoCommentList(@RequestParam Integer videoId) {
List<VideoCommentVo> videoCommentVoList = videoService.findVideoCommentList(videoId);

View File

@ -1,56 +1,27 @@
package doctor.domain.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
/**
* @ClassName : UserVideoBuyEntity
* @Description :
* @Author : FJJ
* @Date: 2024-01-10 15:20
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class UserVideoBuyEntity {
private Integer id;
private Integer userId;
private Integer videoId;
private Long createTime;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getUserId() {
return userId;
}
public void setUserId(Integer userId) {
this.userId = userId;
}
public Integer getVideoId() {
return videoId;
}
public void setVideoId(Integer videoId) {
this.videoId = videoId;
}
public Long getCreateTime() {
return createTime;
}
public void setCreateTime(Long createTime) {
this.createTime = createTime;
}
public UserVideoBuyEntity(Integer id, Integer userId, Integer videoId, Long createTime) {
this.id = id;
this.userId = userId;
this.videoId = videoId;
this.createTime = createTime;
}
public UserVideoBuyEntity() {
}
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
private Date createTime;
}

View File

@ -1,5 +1,8 @@
package doctor.domain.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
/**
@ -13,6 +16,8 @@ public class UserVideoCollectionEntity {
private Integer id;
private Integer userId;
private Integer videoId;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
private Date createTime;
public Integer getId() {

View File

@ -1,5 +1,8 @@
package doctor.domain.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
/**
@ -14,6 +17,8 @@ public class VideoCommentEntity {
private Integer userId;
private Integer videoId;
private String content;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
private Date createTime;
public Integer getId() {

View File

@ -26,5 +26,7 @@ public class VideoEntity {
private String originalUrl;
private Integer duration;
private Integer price;
private Long createTime;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
private Date createTime;
}

View File

@ -1,12 +1,10 @@
package doctor.mapper;
import doctor.domain.dto.VideoDto;
import doctor.domain.entity.UserVideoBuyEntity;
import doctor.domain.entity.UserVideoCollectionEntity;
import doctor.domain.entity.VideoCategoryEntity;
import doctor.domain.entity.VideoEntity;
import doctor.domain.vo.VideoCategoryVo;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@ -16,7 +14,9 @@ public interface HealthUserVideoMapper {
List<VideoEntity> findVideoVoList(@Param("categoryId") Integer categoryId);
UserVideoCollectionEntity selectWhetherCollectionByUserIdAndVideoId(@Param("userId") Long userId, @Param("id") Integer id);
UserVideoCollectionEntity selectWhetherCollectionByUserIdAndVideoId(@Param("userId") Integer userId, @Param("id") Integer id);
UserVideoBuyEntity selectWhetherBuyByUserIdAndVideoId(@Param("userId") Long userId, @Param("id") Integer id);
UserVideoBuyEntity selectWhetherBuyByUserIdAndVideoId(@Param("userId") Integer userId, @Param("id") Integer id);
Integer selectVideoBuyNum(@Param("id") Integer id);
}

View File

@ -2,9 +2,6 @@ package doctor.service;
import doctor.domain.dto.VideoDto;
import doctor.domain.entity.VideoCategoryEntity;
import doctor.domain.entity.VideoEntity;
import doctor.domain.vo.VideoCategoryVo;
import doctor.domain.vo.VideoVo;
@ -13,5 +10,5 @@ import java.util.List;
public interface HealthUserVideoService {
List<VideoCategoryVo> findVideoCategoryList();
List<VideoVo> findVideoVoList(Integer categoryId);
List<VideoVo> findVideoVoList(Integer categoryId, Integer userId);
}

View File

@ -1,10 +1,8 @@
package doctor.service.impl;
import doctor.common.core.utils.JwtUtils;
import doctor.common.security.service.TokenService;
import doctor.common.security.utils.SecurityUtils;
import doctor.domain.dto.VideoDto;
import doctor.domain.entity.UserVideoBuyEntity;
import doctor.domain.entity.UserVideoCollectionEntity;
import doctor.domain.entity.VideoCategoryEntity;
@ -13,9 +11,7 @@ import doctor.domain.vo.VideoCategoryVo;
import doctor.domain.vo.VideoVo;
import doctor.mapper.HealthUserVideoMapper;
import doctor.service.HealthUserVideoService;
import doctor.system.api.model.LoginUser;
import doctor.util.ConvertUtil;
import io.netty.util.internal.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -27,9 +23,6 @@ public class HealthUserVideoServiceImpl implements HealthUserVideoService {
@Autowired
private HealthUserVideoMapper healthUserVideoMapper;
@Autowired
private HttpServletRequest request;
@Autowired
private TokenService tokenService;
@ -42,10 +35,9 @@ public class HealthUserVideoServiceImpl implements HealthUserVideoService {
}
@Override
public List<VideoVo> findVideoVoList(Integer categoryId) {
public List<VideoVo> findVideoVoList(Integer categoryId, Integer userId) {
List<VideoEntity> videoVoList = healthUserVideoMapper.findVideoVoList(categoryId);
List<VideoVo> videoVos = ConvertUtil.entityToVoList(videoVoList, VideoVo.class);
Long userId = SecurityUtils.getUserId();
videoVos.forEach(video -> {
UserVideoCollectionEntity userVideoCollection = healthUserVideoMapper.selectWhetherCollectionByUserIdAndVideoId(userId,video.getId());
if(userVideoCollection!=null){
@ -59,6 +51,8 @@ public class HealthUserVideoServiceImpl implements HealthUserVideoService {
}else {
video.setWhetherBuy(2);
}
Integer buyNum = healthUserVideoMapper.selectVideoBuyNum(video.getId());
video.setBuyNum(buyNum);
});
return videoVos;

View File

@ -17,5 +17,8 @@
<select id="selectWhetherBuyByUserIdAndVideoId" resultType="doctor.domain.entity.UserVideoBuyEntity">
select * from user_video_buy where user_id=#{userId} and video_id=#{id}
</select>
<select id="selectVideoBuyNum" resultType="java.lang.Integer">
select count(*) buyNum from user_video_buy where video_id=#{id}
</select>
</mapper>