Skip to content

Commit

Permalink
fix delete bug
Browse files Browse the repository at this point in the history
Signed-off-by: fanyinbo <[email protected]>
  • Loading branch information
fanyinbo committed Dec 18, 2023
1 parent a87fadd commit 657988d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
10 changes: 6 additions & 4 deletions backend/src/main/java/ai/basic/x1/usecase/DataInfoUseCase.java
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,14 @@ public void deleteBatch(Long datasetId, List<Long> ids) {
if (count > 0) {
throw new UsecaseException(UsecaseCode.DATASET_DATA_OTHERS_ANNOTATING);
}
var dataInfoDeleteLambdaQueryWrapper = Wrappers.lambdaQuery(DataInfo.class);
dataInfoDeleteLambdaQueryWrapper.eq(DataInfo::getDatasetId, datasetId);
dataInfoDeleteLambdaQueryWrapper.nested(wq -> wq.in(DataInfo::getId, ids)

var dataInfoLambdaUpdateWrapper = Wrappers.lambdaUpdate(DataInfo.class);
dataInfoLambdaUpdateWrapper.setSql("del_unique_key=id,is_deleted=1");
dataInfoLambdaUpdateWrapper.eq(DataInfo::getDatasetId, datasetId);
dataInfoLambdaUpdateWrapper.nested(wq -> wq.in(DataInfo::getId, ids)
.or()
.in(DataInfo::getParentId, ids));
dataInfoDAO.remove(dataInfoDeleteLambdaQueryWrapper);
dataInfoDAO.update(dataInfoLambdaUpdateWrapper);

executorService.execute(Objects.requireNonNull(TtlRunnable.get(() -> {
var dataAnnotationObjectLambdaUpdateWrapper = Wrappers.lambdaUpdate(DataAnnotationObject.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -830,9 +830,9 @@ private void createUploadThumbnail(Long userId, List<FileBO> fileBOS, String roo
var suffix = FileUtil.getSuffix(fileName);
suffix = suffix.equalsIgnoreCase(TIFF_SUFFIX) || suffix.equalsIgnoreCase(TIF_SUFFIX) ? "jpg" : suffix;
var prefix = FileUtil.getPrefix(fileName);
var largeFile = FileUtil.file(basePath, String.format("%s_%s.%s", prefix, large, suffix));
var mediumFile = FileUtil.file(basePath, String.format("%s_%s.%s", prefix, medium, suffix));
var smallFile = FileUtil.file(basePath, String.format("%s_%s.%s", prefix, small, suffix));
var largeFile = FileUtil.file(tempPath, String.format("%s_%s.%s", prefix, large, suffix));
var mediumFile = FileUtil.file(tempPath, String.format("%s_%s.%s", prefix, medium, suffix));
var smallFile = FileUtil.file(tempPath, String.format("%s_%s.%s", prefix, small, suffix));
Thumbnails.of(file).size(largeFileSize, largeFileSize).toFile(largeFile);
Thumbnails.of(largeFile).size(mediumFileSize, mediumFileSize).toFile(mediumFile);
Thumbnails.of(largeFile).size(smallFileSize, smallFileSize).toFile(smallFile);
Expand Down
2 changes: 1 addition & 1 deletion deploy/mysql/migration/V1__Create_tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ CREATE TABLE `data`
`updated_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'Update time',
`updated_by` bigint(20) DEFAULT NULL COMMENT 'Modify person id',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE KEY `uk_dataset_id_type_prent_id_name` (`dataset_id`, `type`, `parent_id`, `name`, `del_unique_key`) USING BTREE,
UNIQUE KEY `uk_dataset_id_type_parent_id_name` (`dataset_id`, `type`, `parent_id`, `name`, `del_unique_key`) USING BTREE,
KEY `idx_dataset_id_created_at` (`dataset_id`, `created_at`) USING BTREE
) ENGINE = InnoDB
AUTO_INCREMENT = 1
Expand Down

0 comments on commit 657988d

Please sign in to comment.