提交品牌删除更新

This commit is contained in:
super
2026-03-26 17:39:20 +08:00
parent 14269d9513
commit ea212c8931
7 changed files with 23 additions and 27 deletions

3
.gitignore vendored
View File

@@ -33,3 +33,6 @@ backend-java/*.iml
# desktop app
desktop/
ERP-Demo/
xlsx/
app/__pycache__
backend/__pycache__

View File

@@ -1 +1 @@
{"version": "1.0.3"}
{"version": "1.0.13"}

View File

@@ -124,9 +124,8 @@ public class BrandTaskController {
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "404", description = "任务不存在")
})
public ApiResponse<LegacyBrandTaskDetailVo> getTask(
@Parameter(description = "品牌任务 ID", required = true) @PathVariable Long taskId,
@Parameter(description = "用户 ID", required = true) @RequestParam Long userId) {
return ApiResponse.success(brandTaskService.getTaskDetailLegacy(taskId, userId));
@Parameter(description = "品牌任务 ID", required = true) @PathVariable Long taskId) {
return ApiResponse.success(brandTaskService.getTaskDetailLegacy(taskId));
}
@PostMapping("/tasks/{taskId}/result")
@@ -154,9 +153,8 @@ public class BrandTaskController {
})
public ApiResponse<BrandSimpleVo> submitResult(
@Parameter(description = "品牌任务 ID", required = true) @PathVariable Long taskId,
@Parameter(description = "用户 ID", required = true) @RequestParam Long userId,
@Valid @RequestBody BrandCrawlResultRequest request) {
brandTaskService.submitCrawlResult(taskId, userId, request);
brandTaskService.submitCrawlResult(taskId, request);
return ApiResponse.success(new BrandSimpleVo(true));
}
@@ -170,9 +168,8 @@ public class BrandTaskController {
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "400", description = "任务不存在或当前状态不可取消")
})
public ApiResponse<BrandSimpleVo> cancelTask(
@Parameter(description = "品牌任务 ID", required = true) @PathVariable Long taskId,
@Parameter(description = "用户 ID", required = true) @RequestParam Long userId) {
brandTaskService.cancelTask(taskId, userId);
@Parameter(description = "品牌任务 ID", required = true) @PathVariable Long taskId) {
brandTaskService.cancelTask(taskId);
return ApiResponse.success(new BrandSimpleVo(true));
}
@@ -186,9 +183,8 @@ public class BrandTaskController {
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "400", description = "任务不存在或正在执行中不可删除")
})
public ApiResponse<BrandSimpleVo> deleteTask(
@Parameter(description = "品牌任务 ID", required = true) @PathVariable Long taskId,
@Parameter(description = "用户 ID", required = true) @RequestParam Long userId) {
brandTaskService.deleteTask(taskId, userId);
@Parameter(description = "品牌任务 ID", required = true) @PathVariable Long taskId) {
brandTaskService.deleteTask(taskId);
return ApiResponse.success(new BrandSimpleVo(true));
}
@@ -202,9 +198,8 @@ public class BrandTaskController {
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "404", description = "任务不存在或无结果可下载")
})
public ResponseEntity<Void> download(
@Parameter(description = "品牌任务 ID", required = true) @PathVariable Long taskId,
@Parameter(description = "用户 ID", required = true) @RequestParam Long userId) {
String url = brandTaskService.resolveDownloadUrl(taskId, userId);
@Parameter(description = "品牌任务 ID", required = true) @PathVariable Long taskId) {
String url = brandTaskService.resolveDownloadUrl(taskId);
return ResponseEntity.status(302)
.header(HttpHeaders.LOCATION, url)
.build();

View File

@@ -139,8 +139,8 @@ public class BrandTaskService {
return vo;
}
public LegacyBrandTaskDetailVo getTaskDetailLegacy(Long taskId, Long userId) {
BrandCrawlTaskEntity task = requireTask(taskId, userId);
public LegacyBrandTaskDetailVo getTaskDetailLegacy(Long taskId) {
BrandCrawlTaskEntity task = requireTask(taskId);
LegacyBrandTaskDetailVo vo = new LegacyBrandTaskDetailVo();
vo.setTask(toLegacyTaskItem(task));
vo.setLine_progress(buildLineProgress(taskId));
@@ -204,8 +204,8 @@ public class BrandTaskService {
return vo;
}
public void submitCrawlResult(Long taskId, Long userId, BrandCrawlResultRequest request) {
BrandCrawlTaskEntity task = requireTask(taskId, userId);
public void submitCrawlResult(Long taskId, BrandCrawlResultRequest request) {
BrandCrawlTaskEntity task = requireTask(taskId);
if (STATUS_CANCELLED.equalsIgnoreCase(blankToDefault(task.getStatus(), STATUS_PENDING))) {
throw new BusinessException("任务已取消");
}
@@ -310,11 +310,10 @@ public class BrandTaskService {
}
}
public void cancelTask(Long taskId, Long userId) {
requireTask(taskId, userId);
public void cancelTask(Long taskId) {
requireTask(taskId);
int updated = brandCrawlTaskMapper.update(null, new LambdaUpdateWrapper<BrandCrawlTaskEntity>()
.eq(BrandCrawlTaskEntity::getId, taskId)
.eq(BrandCrawlTaskEntity::getUserId, userId)
.in(BrandCrawlTaskEntity::getStatus, STATUS_PENDING, STATUS_RUNNING)
.set(BrandCrawlTaskEntity::getStatus, STATUS_CANCELLED));
if (updated == 0) {
@@ -323,19 +322,18 @@ public class BrandTaskService {
brandTaskProgressCacheService.delete(taskId);
}
public void deleteTask(Long taskId, Long userId) {
requireTask(taskId, userId);
public void deleteTask(Long taskId) {
requireTask(taskId);
int deleted = brandCrawlTaskMapper.delete(new LambdaQueryWrapper<BrandCrawlTaskEntity>()
.eq(BrandCrawlTaskEntity::getId, taskId)
.eq(BrandCrawlTaskEntity::getUserId, userId)
.ne(BrandCrawlTaskEntity::getStatus, STATUS_RUNNING));
if (deleted == 0) {
throw new BusinessException("任务不存在或正在执行中无法删除");
}
}
public String resolveDownloadUrl(Long taskId, Long userId) {
BrandCrawlTaskEntity task = requireTask(taskId, userId);
public String resolveDownloadUrl(Long taskId) {
BrandCrawlTaskEntity task = requireTask(taskId);
Object raw = parseJsonValue(task.getResultPaths());
if (!(raw instanceof Map<?, ?> map)) {
throw new BusinessException("无结果可下载");