diff --git a/src/main/java/com/ycwl/basic/controller/mobile/AppVideoController.java b/src/main/java/com/ycwl/basic/controller/mobile/AppVideoController.java new file mode 100644 index 0000000..197e719 --- /dev/null +++ b/src/main/java/com/ycwl/basic/controller/mobile/AppVideoController.java @@ -0,0 +1,22 @@ +package com.ycwl.basic.controller.mobile; + +import com.ycwl.basic.model.task.req.VideoInfoReq; +import com.ycwl.basic.repository.VideoRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/api/mobile/video/v1") +public class AppVideoController { + @Autowired + private VideoRepository videoRepository; + + @PostMapping("/{videoId}/updateMeta") + public void updateMeta(@PathVariable("videoId") Long videoId, @RequestBody VideoInfoReq req) { + videoRepository.updateMeta(videoId, req); + } +} diff --git a/src/main/java/com/ycwl/basic/mapper/VideoMapper.java b/src/main/java/com/ycwl/basic/mapper/VideoMapper.java index 0d91dfa..e84dcf3 100644 --- a/src/main/java/com/ycwl/basic/mapper/VideoMapper.java +++ b/src/main/java/com/ycwl/basic/mapper/VideoMapper.java @@ -22,6 +22,7 @@ public interface VideoMapper { int add(VideoEntity task); int deleteById(Long id); int update(VideoEntity task); + int updateMeta(VideoEntity task); VideoEntity findByTaskId(@NonNull Long taskId); diff --git a/src/main/java/com/ycwl/basic/model/mobile/goods/VideoGoodsDetailVO.java b/src/main/java/com/ycwl/basic/model/mobile/goods/VideoGoodsDetailVO.java index e49b662..820cb00 100644 --- a/src/main/java/com/ycwl/basic/model/mobile/goods/VideoGoodsDetailVO.java +++ b/src/main/java/com/ycwl/basic/model/mobile/goods/VideoGoodsDetailVO.java @@ -50,4 +50,7 @@ public class VideoGoodsDetailVO { private Integer lensNum; private Long faceId; private boolean share = false; + private Integer height; + private Integer width; + private BigDecimal duration; } diff --git a/src/main/java/com/ycwl/basic/model/pc/video/entity/VideoEntity.java b/src/main/java/com/ycwl/basic/model/pc/video/entity/VideoEntity.java index dbdb6a3..ed996b1 100644 --- a/src/main/java/com/ycwl/basic/model/pc/video/entity/VideoEntity.java +++ b/src/main/java/com/ycwl/basic/model/pc/video/entity/VideoEntity.java @@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import java.math.BigDecimal; import java.util.Date; /** @@ -47,4 +48,8 @@ public class VideoEntity { private Integer isBuy; private Date createTime; private Date updateTime; + + private Integer height; + private Integer width; + private BigDecimal duration; } diff --git a/src/main/java/com/ycwl/basic/model/pc/video/resp/VideoRespVO.java b/src/main/java/com/ycwl/basic/model/pc/video/resp/VideoRespVO.java index 29b344d..a88e73b 100644 --- a/src/main/java/com/ycwl/basic/model/pc/video/resp/VideoRespVO.java +++ b/src/main/java/com/ycwl/basic/model/pc/video/resp/VideoRespVO.java @@ -60,4 +60,7 @@ public class VideoRespVO { private Date createTime; @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") private Date updateTime; + private Integer height; + private Integer width; + private BigDecimal duration; } diff --git a/src/main/java/com/ycwl/basic/model/task/req/VideoInfoReq.java b/src/main/java/com/ycwl/basic/model/task/req/VideoInfoReq.java index b9f6457..6ed1dc8 100644 --- a/src/main/java/com/ycwl/basic/model/task/req/VideoInfoReq.java +++ b/src/main/java/com/ycwl/basic/model/task/req/VideoInfoReq.java @@ -1,7 +1,12 @@ package com.ycwl.basic.model.task.req; +import lombok.Data; + +import java.math.BigDecimal; + +@Data public class VideoInfoReq { private Integer height; private Integer width; - private Float duration; + private BigDecimal duration; } diff --git a/src/main/java/com/ycwl/basic/repository/VideoRepository.java b/src/main/java/com/ycwl/basic/repository/VideoRepository.java new file mode 100644 index 0000000..3da72b9 --- /dev/null +++ b/src/main/java/com/ycwl/basic/repository/VideoRepository.java @@ -0,0 +1,34 @@ +package com.ycwl.basic.repository; + +import com.ycwl.basic.mapper.VideoMapper; +import com.ycwl.basic.model.pc.video.entity.VideoEntity; +import com.ycwl.basic.model.pc.video.resp.VideoRespVO; +import com.ycwl.basic.model.task.req.VideoInfoReq; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.stereotype.Component; + +import java.math.BigDecimal; + +@Component +public class VideoRepository { + @Autowired + private RedisTemplate redisTemplate; + @Autowired + private VideoMapper videoMapper; + + public void updateMeta(Long videoId, VideoInfoReq req) { + VideoRespVO video = videoMapper.getById(videoId); + if (video.getDuration() != null) { + if (video.getDuration().subtract(req.getDuration()).abs().compareTo(BigDecimal.ONE) <= 0) { + return; + } + } + VideoEntity update = new VideoEntity(); + update.setId(videoId); + update.setHeight(req.getHeight()); + update.setWidth(req.getWidth()); + update.setDuration(req.getDuration()); + videoMapper.updateMeta(update); + } +} diff --git a/src/main/java/com/ycwl/basic/repository/VideoTaskRepository.java b/src/main/java/com/ycwl/basic/repository/VideoTaskRepository.java index 8fdf9df..b1c407a 100644 --- a/src/main/java/com/ycwl/basic/repository/VideoTaskRepository.java +++ b/src/main/java/com/ycwl/basic/repository/VideoTaskRepository.java @@ -14,8 +14,6 @@ public class VideoTaskRepository { private RedisTemplate redisTemplate; @Autowired private TaskMapper taskMapper; - @Autowired - private VideoMapper videoMapper; public static final String TASK_CACHE_KEY = "task:byId:%s"; diff --git a/src/main/java/com/ycwl/basic/service/impl/mobile/GoodsServiceImpl.java b/src/main/java/com/ycwl/basic/service/impl/mobile/GoodsServiceImpl.java index 3f5acc6..813d4ee 100644 --- a/src/main/java/com/ycwl/basic/service/impl/mobile/GoodsServiceImpl.java +++ b/src/main/java/com/ycwl/basic/service/impl/mobile/GoodsServiceImpl.java @@ -196,6 +196,9 @@ public class GoodsServiceImpl implements GoodsService { goodsDetailVO.setVideoUrl(videoRespVO.getVideoUrl()); goodsDetailVO.setTemplateCoverUrl(videoRespVO.getTemplateCoverUrl()); goodsDetailVO.setCreateTime(videoRespVO.getCreateTime()); + goodsDetailVO.setHeight(videoRespVO.getHeight()); + goodsDetailVO.setWidth(videoRespVO.getWidth()); + goodsDetailVO.setDuration(videoRespVO.getDuration()); if (userId == null) { goodsDetailVO.setIsBuy(0); goodsDetailVO.setShare(true); diff --git a/src/main/java/com/ycwl/basic/service/impl/task/TaskTaskServiceImpl.java b/src/main/java/com/ycwl/basic/service/impl/task/TaskTaskServiceImpl.java index 26fccbf..c70d909 100644 --- a/src/main/java/com/ycwl/basic/service/impl/task/TaskTaskServiceImpl.java +++ b/src/main/java/com/ycwl/basic/service/impl/task/TaskTaskServiceImpl.java @@ -364,6 +364,11 @@ public class TaskTaskServiceImpl implements TaskService { VideoEntity video = videoMapper.findByTaskId(taskId); if (video != null) { video.setVideoUrl(task.getVideoUrl()); + if (req.getVideoInfo() != null) { + video.setHeight(req.getVideoInfo().getHeight()); + video.setWidth(req.getVideoInfo().getWidth()); + video.setDuration(req.getVideoInfo().getDuration()); + } videoMapper.update(video); } else { video = new VideoEntity(); @@ -374,6 +379,11 @@ public class TaskTaskServiceImpl implements TaskService { video.setWorkerId(worker.getId()); video.setVideoUrl(task.getVideoUrl()); video.setCreateTime(new Date()); + if (req.getVideoInfo() != null) { + video.setHeight(req.getVideoInfo().getHeight()); + video.setWidth(req.getVideoInfo().getWidth()); + video.setDuration(req.getVideoInfo().getDuration()); + } videoMapper.add(video); } int isBuy = 0; diff --git a/src/main/resources/mapper/TaskMapper.xml b/src/main/resources/mapper/TaskMapper.xml index 5f634a8..3b61e2c 100644 --- a/src/main/resources/mapper/TaskMapper.xml +++ b/src/main/resources/mapper/TaskMapper.xml @@ -37,7 +37,7 @@ update task - set start_time = now(), worker_id = #{workerId} + set start_time = now(), end_time = null, worker_id = #{workerId} where id = #{id} diff --git a/src/main/resources/mapper/VideoMapper.xml b/src/main/resources/mapper/VideoMapper.xml index 2fdc3cf..52cf496 100644 --- a/src/main/resources/mapper/VideoMapper.xml +++ b/src/main/resources/mapper/VideoMapper.xml @@ -2,8 +2,8 @@ - insert into video(id, scenic_id, template_id, task_id, worker_id, video_url) - values (#{id}, #{scenicId}, #{templateId}, #{taskId}, #{workerId}, #{videoUrl}) + insert into video(id, scenic_id, template_id, task_id, worker_id, video_url, height, width, duration) + values (#{id}, #{scenicId}, #{templateId}, #{taskId}, #{workerId}, #{videoUrl}, #{height}, #{width}, #{duration}) replace member_video(member_id, scenic_id, face_id, template_id, task_id, video_id, is_buy, order_id) @@ -24,9 +24,19 @@ task_id = #{taskId}, worker_id = #{workerId}, video_url = #{videoUrl}, + height = #{height}, + width = #{width}, + duration = #{duration}, where id = #{id} + + update video + set height = #{height}, + width = #{width}, + duration = #{duration} + where id = #{id} + update member_video @@ -67,7 +77,7 @@