diff --git a/src/main/java/com/zh/project0512/controller/UtilsController.java b/src/main/java/com/zh/project0512/controller/UtilsController.java index 640e7ff..811e4c3 100644 --- a/src/main/java/com/zh/project0512/controller/UtilsController.java +++ b/src/main/java/com/zh/project0512/controller/UtilsController.java @@ -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; /** *

@@ -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); +// } } diff --git a/src/main/java/com/zh/project0512/controller/wxApp/VideoUController.java b/src/main/java/com/zh/project0512/controller/wxApp/VideoUController.java index 8b6334f..1689cb8 100644 --- a/src/main/java/com/zh/project0512/controller/wxApp/VideoUController.java +++ b/src/main/java/com/zh/project0512/controller/wxApp/VideoUController.java @@ -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