diff --git a/doctor-modules/doctor-health/src/main/java/doctor/controller/HealthUserVideoController.java b/doctor-modules/doctor-health/src/main/java/doctor/controller/HealthUserVideoController.java index a1f6684..5d9d1aa 100644 --- a/doctor-modules/doctor-health/src/main/java/doctor/controller/HealthUserVideoController.java +++ b/doctor-modules/doctor-health/src/main/java/doctor/controller/HealthUserVideoController.java @@ -26,9 +26,13 @@ public class HealthUserVideoController{ } @GetMapping("/findVideoVoList") - public HealthR> findVideoVoList(@RequestParam Integer categoryId,@RequestParam Integer page,@RequestParam Integer count){ + public HealthR> findVideoVoList(@RequestParam Integer categoryId, + @RequestParam Integer page, + @RequestParam Integer count, + @RequestHeader Integer userId, + @RequestHeader String sessionId){ startPage(page,count); - List List = healthUserVideoService.findVideoVoList(categoryId); + List List = healthUserVideoService.findVideoVoList(categoryId,userId); return HealthR.ok(List); } diff --git a/doctor-modules/doctor-health/src/main/java/doctor/controller/VideoController.java b/doctor-modules/doctor-health/src/main/java/doctor/controller/VideoController.java index da6a8d4..3ee1af5 100644 --- a/doctor-modules/doctor-health/src/main/java/doctor/controller/VideoController.java +++ b/doctor-modules/doctor-health/src/main/java/doctor/controller/VideoController.java @@ -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> findVideoCommentList(@RequestParam Integer videoId) { List videoCommentVoList = videoService.findVideoCommentList(videoId); diff --git a/doctor-modules/doctor-health/src/main/java/doctor/domain/entity/UserVideoBuyEntity.java b/doctor-modules/doctor-health/src/main/java/doctor/domain/entity/UserVideoBuyEntity.java index d6e4cf0..606ec9c 100644 --- a/doctor-modules/doctor-health/src/main/java/doctor/domain/entity/UserVideoBuyEntity.java +++ b/doctor-modules/doctor-health/src/main/java/doctor/domain/entity/UserVideoBuyEntity.java @@ -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; } diff --git a/doctor-modules/doctor-health/src/main/java/doctor/domain/entity/UserVideoCollectionEntity.java b/doctor-modules/doctor-health/src/main/java/doctor/domain/entity/UserVideoCollectionEntity.java index a00ae93..667b98f 100644 --- a/doctor-modules/doctor-health/src/main/java/doctor/domain/entity/UserVideoCollectionEntity.java +++ b/doctor-modules/doctor-health/src/main/java/doctor/domain/entity/UserVideoCollectionEntity.java @@ -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() { diff --git a/doctor-modules/doctor-health/src/main/java/doctor/domain/entity/VideoCommentEntity.java b/doctor-modules/doctor-health/src/main/java/doctor/domain/entity/VideoCommentEntity.java index 9ab5ec2..162e516 100644 --- a/doctor-modules/doctor-health/src/main/java/doctor/domain/entity/VideoCommentEntity.java +++ b/doctor-modules/doctor-health/src/main/java/doctor/domain/entity/VideoCommentEntity.java @@ -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() { diff --git a/doctor-modules/doctor-health/src/main/java/doctor/domain/entity/VideoEntity.java b/doctor-modules/doctor-health/src/main/java/doctor/domain/entity/VideoEntity.java index b11e957..d95dba9 100644 --- a/doctor-modules/doctor-health/src/main/java/doctor/domain/entity/VideoEntity.java +++ b/doctor-modules/doctor-health/src/main/java/doctor/domain/entity/VideoEntity.java @@ -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; } diff --git a/doctor-modules/doctor-health/src/main/java/doctor/mapper/HealthUserVideoMapper.java b/doctor-modules/doctor-health/src/main/java/doctor/mapper/HealthUserVideoMapper.java index ed4ed72..10f6f0a 100644 --- a/doctor-modules/doctor-health/src/main/java/doctor/mapper/HealthUserVideoMapper.java +++ b/doctor-modules/doctor-health/src/main/java/doctor/mapper/HealthUserVideoMapper.java @@ -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 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); } diff --git a/doctor-modules/doctor-health/src/main/java/doctor/service/HealthUserVideoService.java b/doctor-modules/doctor-health/src/main/java/doctor/service/HealthUserVideoService.java index 56e0b1e..b5fa359 100644 --- a/doctor-modules/doctor-health/src/main/java/doctor/service/HealthUserVideoService.java +++ b/doctor-modules/doctor-health/src/main/java/doctor/service/HealthUserVideoService.java @@ -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 findVideoCategoryList(); - List findVideoVoList(Integer categoryId); + List findVideoVoList(Integer categoryId, Integer userId); } diff --git a/doctor-modules/doctor-health/src/main/java/doctor/service/impl/HealthUserVideoServiceImpl.java b/doctor-modules/doctor-health/src/main/java/doctor/service/impl/HealthUserVideoServiceImpl.java index bc727ab..bd32a87 100644 --- a/doctor-modules/doctor-health/src/main/java/doctor/service/impl/HealthUserVideoServiceImpl.java +++ b/doctor-modules/doctor-health/src/main/java/doctor/service/impl/HealthUserVideoServiceImpl.java @@ -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 findVideoVoList(Integer categoryId) { + public List findVideoVoList(Integer categoryId, Integer userId) { List videoVoList = healthUserVideoMapper.findVideoVoList(categoryId); List 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; diff --git a/doctor-modules/doctor-health/src/main/resources/mapper/doctor/HealthUserVideoMapper.xml b/doctor-modules/doctor-health/src/main/resources/mapper/doctor/HealthUserVideoMapper.xml index 3746683..d306ca1 100644 --- a/doctor-modules/doctor-health/src/main/resources/mapper/doctor/HealthUserVideoMapper.xml +++ b/doctor-modules/doctor-health/src/main/resources/mapper/doctor/HealthUserVideoMapper.xml @@ -17,5 +17,8 @@ +