zhangjinli 3 years ago
parent 85d6b20470
commit 98d70aead1

@ -24,10 +24,12 @@ import com.zh.project0512.utils.result.HttpStatusEnum;
import com.zh.project0512.utils.result.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.jsoup.helper.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
@ -40,6 +42,8 @@ import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* <p>
@ -161,11 +165,28 @@ public class UtilsController {
private IVideoService videoService;
@PostMapping("/test")
@ResponseBody
public Result test() {
return Result.success();
String url ="http://www.baidu.com/#wd=%E6%88%91%E6%98%AF%E6%AD%8C%E6%89%8B&rsv_bp=0&tn=baidu&rsv_spt=3&ie=utf-8&rsv_sug3=11&rsv_sug4=643&rsv_sug1=11&inputT=5484&rsv_sug2=0";
Pattern p = Pattern.compile("(http://|https://)?([^/]*)",Pattern.CASE_INSENSITIVE);
Matcher m = p.matcher(url);
String a= m.find()?m.group(2):url;
// (https://)+\S*\s
return Result.success(a);
}
// public static void main(String[] args) {
// String url ="9.20 tRK:/ 男人第一天上班就被当成修电脑的,谁知他竟然是总经理%好剧推荐 %全集解说%幸福一家人%关于爱情%宅家dou剧 %持续关注持续精彩 https://v.kuaishou.com/Yh4DwM9/ 复制此链接打开Dou音搜索直接观看视频";
// Pattern p = Pattern.compile("((https://)+\\S*\\s)",Pattern.CASE_INSENSITIVE);
//
// Matcher m = p.matcher(url);
//System.out.println(m);
// String a= m.find()?m.group(1):url;
// System.out.println(a);
// int b = StringUtils.countOccurrencesOf(a,"https://v.douyin");
// System.out.println(b);
// }
}

@ -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("添加完成!");
}

@ -30,8 +30,9 @@ public interface CustomerActionNoteMapper extends BaseMapper<CustomerActionNote>
"from customerActionNote as t1\n" +
"LEFT JOIN user as t2 on t1.provideId = t2.id\n" +
"LEFT JOIN qywxDepartment as t4 on t4.departmentId = t2.main_department\n" +
"LEFT JOIN task as t3 on t1.taskId = t3.id\n"+
"<if test='openid!=null'>where t2.openid =#{openid} </if>" +
"LEFT JOIN task as t3 on t1.taskId = t3.id\n" +
"where 1=1 "+
"<if test='openid!=null'>and t2.openid =#{openid} </if>" +
"<if test='ew != null'>" +
"<if test='ew.nonEmptyOfWhere'>" +

@ -0,0 +1,13 @@
package com.zh.project0512.utils;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class RegexUtil {
public String httpReg(String url) {
Pattern p = Pattern.compile("((https://)+\\S*\\s)", Pattern.CASE_INSENSITIVE);
Matcher m = p.matcher(url);
String a = m.find() ? m.group(1) : null;
return a;
}
}
Loading…
Cancel
Save