diff --git a/src/main/java/com/zh/project0512/controller/UtilsController.java b/src/main/java/com/zh/project0512/controller/UtilsController.java index 1b10246..031b5c6 100644 --- a/src/main/java/com/zh/project0512/controller/UtilsController.java +++ b/src/main/java/com/zh/project0512/controller/UtilsController.java @@ -189,19 +189,15 @@ public class UtilsController { @PostMapping("/test") @ResponseBody public Result test() { - 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); + return Result.success(); } public static void main(String[] args) { - String url = "4.38 wfb:/ 复制打开抖音身 https://v.douyin.com/YT98hjf/,看看【酸味真火的作品】坚持总会有收获的# 意想不到的情侣健身 https://v.douyin.com/YT982Sf/"; - System.out.println( RegexUtils.get("(https://)(.*?)(/)(.*?)(/)",url,0)); + File file = new File("/Users/apple/Pictures/ss/tt/default (10).xlsx"); + file.delete(); + +// String url = "4.38 wfb:/ 复制打开抖音身 https://v.douyin.com/YT98hjf/,看看【酸味真火的作品】坚持总会有收获的# 意想不到的情侣健身 https://v.douyin.com/YT982Sf/"; +// System.out.println( RegexUtils.get("(https://)(.*?)(/)(.*?)(/)",url,0)); // String a = m.find() ? m.group(1) : url; // System.out.println(a); // int b = StringUtils.countOccurrencesOf(a, "https://v.douyin"); diff --git a/src/main/java/com/zh/project0512/controller/manage/ReferenceController.java b/src/main/java/com/zh/project0512/controller/manage/ReferenceController.java index 5dbea99..0b81d07 100644 --- a/src/main/java/com/zh/project0512/controller/manage/ReferenceController.java +++ b/src/main/java/com/zh/project0512/controller/manage/ReferenceController.java @@ -12,10 +12,7 @@ import com.zh.project0512.annotation.AdminCheckAuthorityAnnotation; import com.zh.project0512.annotation.AdminTokenValid; import com.zh.project0512.model.*; import com.zh.project0512.model.vo.FileUploadParamVo; -import com.zh.project0512.service.IReferenceBrandService; -import com.zh.project0512.service.IReferenceService; -import com.zh.project0512.service.IReferenceTagService; -import com.zh.project0512.service.ITopicActivityService; +import com.zh.project0512.service.*; import com.zh.project0512.utils.FileTypeUtil; import com.zh.project0512.utils.MybatisPlusUtil; import com.zh.project0512.utils.result.HttpStatusEnum; @@ -25,6 +22,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.beans.factory.annotation.Value; import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; @@ -32,6 +30,7 @@ import org.springframework.web.bind.annotation.*; import javax.validation.constraints.Min; import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; +import java.io.File; import java.sql.Ref; import java.time.LocalDateTime; import java.util.ArrayList; @@ -54,11 +53,15 @@ public class ReferenceController { @Autowired private IReferenceService referenceService; @Autowired + private ITaskReferenceService taskReferenceService; + @Autowired private IReferenceTagService referenceTagService; @Autowired private IReferenceBrandService referenceBrandService; @Autowired private ITopicActivityService topicActivityService; + @Value("${web.uploadPath}") + private String path; @Data static class AddRParam { @@ -188,12 +191,28 @@ public class ReferenceController { private List idList; } - @Operation(summary = "删除素材(软删除)") + @Operation(summary = "删除素材(软删除),文件会清除") @PostMapping("/del") @AdminTokenValid @AdminCheckAuthorityAnnotation(jurisdictionId = "109") public Result del(@Validated @RequestBody DelRParam param) { - return MybatisPlusUtil.sqlResult(referenceService.update(new UpdateWrapper().in("id", param.getIdList()).set("isDeleted", 1)), "删除"); + List rList = referenceService.list(new QueryWrapper().in("id", param.getIdList())); + // 删除素材字段 + referenceService.update(new UpdateWrapper().in("id", param.getIdList()).set("isDeleted", 1)); + //删除素材文件 + for (Reference r : rList) { + if (path != null) { + if (r.getFileUrl() != null) { + new File(path + "/upload" + r.getFileUrl()).delete(); + } + if (r.getCoverUrl() != null) { + new File(path + "/upload" + r.getCoverUrl()).delete(); + } + } + } + //删除素材任务关联 + taskReferenceService.remove(new UpdateWrapper().in("referenceId", param.getIdList())); + return Result.success(); }