bug修改,根性视频meta信息

This commit is contained in:
Jerry Yan 2025-01-09 19:34:20 +08:00
parent c27665e513
commit 5c0bf09c95
12 changed files with 101 additions and 7 deletions

View File

@ -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);
}
}

View File

@ -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);

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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<String, String> 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);
}
}

View File

@ -14,8 +14,6 @@ public class VideoTaskRepository {
private RedisTemplate<String, String> redisTemplate;
@Autowired
private TaskMapper taskMapper;
@Autowired
private VideoMapper videoMapper;
public static final String TASK_CACHE_KEY = "task:byId:%s";

View File

@ -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);

View File

@ -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;

View File

@ -37,7 +37,7 @@
</update>
<update id="setStart">
update task
set start_time = now(), worker_id = #{workerId}
set start_time = now(), end_time = null, worker_id = #{workerId}
where id = #{id}
</update>
<update id="setSuccess">

View File

@ -2,8 +2,8 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ycwl.basic.mapper.VideoMapper">
<insert id="add">
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})
</insert>
<insert id="addRelation">
replace member_video(member_id, scenic_id, face_id, template_id, task_id, video_id, is_buy, order_id)
@ -24,9 +24,19 @@
<if test="taskId!= null">task_id = #{taskId}, </if>
<if test="workerId!= null">worker_id = #{workerId}, </if>
<if test="videoUrl!= null">video_url = #{videoUrl}, </if>
<if test="height!= null">height = #{height}, </if>
<if test="width!= null">width = #{width}, </if>
<if test="duration!= null">duration = #{duration}, </if>
</set>
where id = #{id}
</update>
<update id="updateMeta">
update video
set height = #{height},
width = #{width},
duration = #{duration}
where id = #{id}
</update>
<update id="updateRelation">
update member_video
<set>
@ -67,7 +77,7 @@
<select id="getById" resultType="com.ycwl.basic.model.pc.video.resp.VideoRespVO">
select v.id, v.scenic_id, template_id, task_id, worker_id, video_url, v.create_time, v.update_time,
t.name templateName,t.price templatePrice, t.cover_url templateCoverUrl, t.slash_price slashPrice,
s.name scenicName
s.name scenicName, v.height, v.width, v.duration
from video v
left join scenic s on v.scenic_id = s.id
left join template t on v.template_id = t.id