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 com.zh.project0512.utils.result.Result;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; 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.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
@ -40,6 +42,8 @@ import java.time.LocalDateTime;
import java.time.ZoneOffset; import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/** /**
* <p> * <p>
@ -161,11 +165,28 @@ public class UtilsController {
private IVideoService videoService; private IVideoService videoService;
@PostMapping("/test") @PostMapping("/test")
@ResponseBody @ResponseBody
public Result test() { 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.service.IVideoService;
import com.zh.project0512.utils.JwtUtil; import com.zh.project0512.utils.JwtUtil;
import com.zh.project0512.utils.MybatisPlusUtil; 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.HttpStatusEnum;
import com.zh.project0512.utils.result.Result; import com.zh.project0512.utils.result.Result;
import io.jsonwebtoken.Claims; 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 io.swagger.v3.oas.annotations.tags.Tag;
import lombok.Data; import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -94,8 +96,16 @@ public class VideoUController {
if (videoService.getMap(queryWrapper) != null) { if (videoService.getMap(queryWrapper) != null) {
return Result.fail(HttpStatusEnum.CUSTOM_EXCEPTION, "已提交过该平台视频"); 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("添加完成!"); return Result.success("添加完成!");
} }

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