|
|
|
@ -11,6 +11,7 @@ import com.zh.project0512.service.IUserTaskService;
|
|
|
|
|
import com.zh.project0512.service.IVideoService;
|
|
|
|
|
import com.zh.project0512.utils.JwtUtil;
|
|
|
|
|
import com.zh.project0512.utils.MybatisPlusUtil;
|
|
|
|
|
import com.zh.project0512.utils.RegexUtil;
|
|
|
|
|
import com.zh.project0512.utils.result.HttpStatusEnum;
|
|
|
|
|
import com.zh.project0512.utils.result.Result;
|
|
|
|
|
import io.jsonwebtoken.Claims;
|
|
|
|
@ -20,6 +21,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
|
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
|
|
import lombok.Data;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
|
@ -74,13 +76,13 @@ public class VideoUController {
|
|
|
|
|
return Result.fail(HttpStatusEnum.CUSTOM_EXCEPTION, "未找到该用户");
|
|
|
|
|
}
|
|
|
|
|
Integer userAccountStatus = userAccountService.userAccountStatus(useId, param.getType());
|
|
|
|
|
if(userAccountStatus ==null){
|
|
|
|
|
if (userAccountStatus == null) {
|
|
|
|
|
return Result.fail(HttpStatusEnum.CUSTOM_EXCEPTION, "请先申请关联账号");
|
|
|
|
|
}else if(userAccountStatus != 1){
|
|
|
|
|
} else if (userAccountStatus != 1) {
|
|
|
|
|
return Result.fail(HttpStatusEnum.CUSTOM_EXCEPTION, "账号不可用");
|
|
|
|
|
}
|
|
|
|
|
// 校验任务状态
|
|
|
|
|
Integer taskStatus = userTaskService.userTaskStatus(useId,taskId);
|
|
|
|
|
Integer taskStatus = userTaskService.userTaskStatus(useId, taskId);
|
|
|
|
|
if (taskStatus == null) {
|
|
|
|
|
return Result.fail(HttpStatusEnum.CUSTOM_EXCEPTION, "用户未接受任务");
|
|
|
|
|
} else if (taskStatus == 0) {
|
|
|
|
@ -90,12 +92,20 @@ public class VideoUController {
|
|
|
|
|
}
|
|
|
|
|
// 不支持重复提交
|
|
|
|
|
QueryWrapper<Video> queryWrapper = new QueryWrapper<>();
|
|
|
|
|
queryWrapper.eq("userId",useId).eq("taskId",taskId).eq("type",param.getType());
|
|
|
|
|
if(videoService.getMap(queryWrapper)!=null){
|
|
|
|
|
queryWrapper.eq("userId", useId).eq("taskId", taskId).eq("type", param.getType());
|
|
|
|
|
if (videoService.getMap(queryWrapper) != null) {
|
|
|
|
|
return Result.fail(HttpStatusEnum.CUSTOM_EXCEPTION, "已提交过该平台视频");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
videoService.save(new Video().setUserId(useId).setTaskId(taskId).setType(param.getType()).setUrl(param.getUrl()).setCreatAt(LocalDateTime.now()).setUpdateAt(LocalDateTime.now()));
|
|
|
|
|
// 校验并提取链接
|
|
|
|
|
String s = new RegexUtil().httpReg(param.getUrl());
|
|
|
|
|
if(null == s){
|
|
|
|
|
return Result.fail(HttpStatusEnum.CUSTOM_EXCEPTION, "视频链接有误");
|
|
|
|
|
}else if(param.getType() == 1&&0==StringUtils.countOccurrencesOf(s,"https://v.douyin")){
|
|
|
|
|
return Result.fail(HttpStatusEnum.CUSTOM_EXCEPTION, "请确认平台是否选择正确");
|
|
|
|
|
}else if(param.getType() == 2&&0==StringUtils.countOccurrencesOf(s,"https://v.kuaishou")){
|
|
|
|
|
return Result.fail(HttpStatusEnum.CUSTOM_EXCEPTION, "请确认平台是否选择正确");
|
|
|
|
|
}
|
|
|
|
|
videoService.save(new Video().setUserId(useId).setTaskId(taskId).setType(param.getType()).setUrl(s).setCreatAt(LocalDateTime.now()).setUpdateAt(LocalDateTime.now()));
|
|
|
|
|
return Result.success("添加完成!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|