提交品牌删除更新
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -33,3 +33,6 @@ backend-java/*.iml
|
|||||||
# desktop app
|
# desktop app
|
||||||
desktop/
|
desktop/
|
||||||
ERP-Demo/
|
ERP-Demo/
|
||||||
|
xlsx/
|
||||||
|
app/__pycache__
|
||||||
|
backend/__pycache__
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1 +1 @@
|
|||||||
{"version": "1.0.3"}
|
{"version": "1.0.13"}
|
||||||
@@ -124,9 +124,8 @@ public class BrandTaskController {
|
|||||||
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "404", description = "任务不存在")
|
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "404", description = "任务不存在")
|
||||||
})
|
})
|
||||||
public ApiResponse<LegacyBrandTaskDetailVo> getTask(
|
public ApiResponse<LegacyBrandTaskDetailVo> getTask(
|
||||||
@Parameter(description = "品牌任务 ID", required = true) @PathVariable Long taskId,
|
@Parameter(description = "品牌任务 ID", required = true) @PathVariable Long taskId) {
|
||||||
@Parameter(description = "用户 ID", required = true) @RequestParam Long userId) {
|
return ApiResponse.success(brandTaskService.getTaskDetailLegacy(taskId));
|
||||||
return ApiResponse.success(brandTaskService.getTaskDetailLegacy(taskId, userId));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/tasks/{taskId}/result")
|
@PostMapping("/tasks/{taskId}/result")
|
||||||
@@ -154,9 +153,8 @@ public class BrandTaskController {
|
|||||||
})
|
})
|
||||||
public ApiResponse<BrandSimpleVo> submitResult(
|
public ApiResponse<BrandSimpleVo> submitResult(
|
||||||
@Parameter(description = "品牌任务 ID", required = true) @PathVariable Long taskId,
|
@Parameter(description = "品牌任务 ID", required = true) @PathVariable Long taskId,
|
||||||
@Parameter(description = "用户 ID", required = true) @RequestParam Long userId,
|
|
||||||
@Valid @RequestBody BrandCrawlResultRequest request) {
|
@Valid @RequestBody BrandCrawlResultRequest request) {
|
||||||
brandTaskService.submitCrawlResult(taskId, userId, request);
|
brandTaskService.submitCrawlResult(taskId, request);
|
||||||
return ApiResponse.success(new BrandSimpleVo(true));
|
return ApiResponse.success(new BrandSimpleVo(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,9 +168,8 @@ public class BrandTaskController {
|
|||||||
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "400", description = "任务不存在或当前状态不可取消")
|
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "400", description = "任务不存在或当前状态不可取消")
|
||||||
})
|
})
|
||||||
public ApiResponse<BrandSimpleVo> cancelTask(
|
public ApiResponse<BrandSimpleVo> cancelTask(
|
||||||
@Parameter(description = "品牌任务 ID", required = true) @PathVariable Long taskId,
|
@Parameter(description = "品牌任务 ID", required = true) @PathVariable Long taskId) {
|
||||||
@Parameter(description = "用户 ID", required = true) @RequestParam Long userId) {
|
brandTaskService.cancelTask(taskId);
|
||||||
brandTaskService.cancelTask(taskId, userId);
|
|
||||||
return ApiResponse.success(new BrandSimpleVo(true));
|
return ApiResponse.success(new BrandSimpleVo(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -186,9 +183,8 @@ public class BrandTaskController {
|
|||||||
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "400", description = "任务不存在或正在执行中不可删除")
|
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "400", description = "任务不存在或正在执行中不可删除")
|
||||||
})
|
})
|
||||||
public ApiResponse<BrandSimpleVo> deleteTask(
|
public ApiResponse<BrandSimpleVo> deleteTask(
|
||||||
@Parameter(description = "品牌任务 ID", required = true) @PathVariable Long taskId,
|
@Parameter(description = "品牌任务 ID", required = true) @PathVariable Long taskId) {
|
||||||
@Parameter(description = "用户 ID", required = true) @RequestParam Long userId) {
|
brandTaskService.deleteTask(taskId);
|
||||||
brandTaskService.deleteTask(taskId, userId);
|
|
||||||
return ApiResponse.success(new BrandSimpleVo(true));
|
return ApiResponse.success(new BrandSimpleVo(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -202,9 +198,8 @@ public class BrandTaskController {
|
|||||||
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "404", description = "任务不存在或无结果可下载")
|
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "404", description = "任务不存在或无结果可下载")
|
||||||
})
|
})
|
||||||
public ResponseEntity<Void> download(
|
public ResponseEntity<Void> download(
|
||||||
@Parameter(description = "品牌任务 ID", required = true) @PathVariable Long taskId,
|
@Parameter(description = "品牌任务 ID", required = true) @PathVariable Long taskId) {
|
||||||
@Parameter(description = "用户 ID", required = true) @RequestParam Long userId) {
|
String url = brandTaskService.resolveDownloadUrl(taskId);
|
||||||
String url = brandTaskService.resolveDownloadUrl(taskId, userId);
|
|
||||||
return ResponseEntity.status(302)
|
return ResponseEntity.status(302)
|
||||||
.header(HttpHeaders.LOCATION, url)
|
.header(HttpHeaders.LOCATION, url)
|
||||||
.build();
|
.build();
|
||||||
|
|||||||
@@ -139,8 +139,8 @@ public class BrandTaskService {
|
|||||||
return vo;
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LegacyBrandTaskDetailVo getTaskDetailLegacy(Long taskId, Long userId) {
|
public LegacyBrandTaskDetailVo getTaskDetailLegacy(Long taskId) {
|
||||||
BrandCrawlTaskEntity task = requireTask(taskId, userId);
|
BrandCrawlTaskEntity task = requireTask(taskId);
|
||||||
LegacyBrandTaskDetailVo vo = new LegacyBrandTaskDetailVo();
|
LegacyBrandTaskDetailVo vo = new LegacyBrandTaskDetailVo();
|
||||||
vo.setTask(toLegacyTaskItem(task));
|
vo.setTask(toLegacyTaskItem(task));
|
||||||
vo.setLine_progress(buildLineProgress(taskId));
|
vo.setLine_progress(buildLineProgress(taskId));
|
||||||
@@ -204,8 +204,8 @@ public class BrandTaskService {
|
|||||||
return vo;
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void submitCrawlResult(Long taskId, Long userId, BrandCrawlResultRequest request) {
|
public void submitCrawlResult(Long taskId, BrandCrawlResultRequest request) {
|
||||||
BrandCrawlTaskEntity task = requireTask(taskId, userId);
|
BrandCrawlTaskEntity task = requireTask(taskId);
|
||||||
if (STATUS_CANCELLED.equalsIgnoreCase(blankToDefault(task.getStatus(), STATUS_PENDING))) {
|
if (STATUS_CANCELLED.equalsIgnoreCase(blankToDefault(task.getStatus(), STATUS_PENDING))) {
|
||||||
throw new BusinessException("任务已取消");
|
throw new BusinessException("任务已取消");
|
||||||
}
|
}
|
||||||
@@ -310,11 +310,10 @@ public class BrandTaskService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cancelTask(Long taskId, Long userId) {
|
public void cancelTask(Long taskId) {
|
||||||
requireTask(taskId, userId);
|
requireTask(taskId);
|
||||||
int updated = brandCrawlTaskMapper.update(null, new LambdaUpdateWrapper<BrandCrawlTaskEntity>()
|
int updated = brandCrawlTaskMapper.update(null, new LambdaUpdateWrapper<BrandCrawlTaskEntity>()
|
||||||
.eq(BrandCrawlTaskEntity::getId, taskId)
|
.eq(BrandCrawlTaskEntity::getId, taskId)
|
||||||
.eq(BrandCrawlTaskEntity::getUserId, userId)
|
|
||||||
.in(BrandCrawlTaskEntity::getStatus, STATUS_PENDING, STATUS_RUNNING)
|
.in(BrandCrawlTaskEntity::getStatus, STATUS_PENDING, STATUS_RUNNING)
|
||||||
.set(BrandCrawlTaskEntity::getStatus, STATUS_CANCELLED));
|
.set(BrandCrawlTaskEntity::getStatus, STATUS_CANCELLED));
|
||||||
if (updated == 0) {
|
if (updated == 0) {
|
||||||
@@ -323,19 +322,18 @@ public class BrandTaskService {
|
|||||||
brandTaskProgressCacheService.delete(taskId);
|
brandTaskProgressCacheService.delete(taskId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteTask(Long taskId, Long userId) {
|
public void deleteTask(Long taskId) {
|
||||||
requireTask(taskId, userId);
|
requireTask(taskId);
|
||||||
int deleted = brandCrawlTaskMapper.delete(new LambdaQueryWrapper<BrandCrawlTaskEntity>()
|
int deleted = brandCrawlTaskMapper.delete(new LambdaQueryWrapper<BrandCrawlTaskEntity>()
|
||||||
.eq(BrandCrawlTaskEntity::getId, taskId)
|
.eq(BrandCrawlTaskEntity::getId, taskId)
|
||||||
.eq(BrandCrawlTaskEntity::getUserId, userId)
|
|
||||||
.ne(BrandCrawlTaskEntity::getStatus, STATUS_RUNNING));
|
.ne(BrandCrawlTaskEntity::getStatus, STATUS_RUNNING));
|
||||||
if (deleted == 0) {
|
if (deleted == 0) {
|
||||||
throw new BusinessException("任务不存在或正在执行中无法删除");
|
throw new BusinessException("任务不存在或正在执行中无法删除");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String resolveDownloadUrl(Long taskId, Long userId) {
|
public String resolveDownloadUrl(Long taskId) {
|
||||||
BrandCrawlTaskEntity task = requireTask(taskId, userId);
|
BrandCrawlTaskEntity task = requireTask(taskId);
|
||||||
Object raw = parseJsonValue(task.getResultPaths());
|
Object raw = parseJsonValue(task.getResultPaths());
|
||||||
if (!(raw instanceof Map<?, ?> map)) {
|
if (!(raw instanceof Map<?, ?> map)) {
|
||||||
throw new BusinessException("无结果可下载");
|
throw new BusinessException("无结果可下载");
|
||||||
|
|||||||
Reference in New Issue
Block a user