Skip to content

Commit

Permalink
[Bug] [dinky-web] Issue with creating a new task with a subdirectory …
Browse files Browse the repository at this point in the history
…of the same name (#3993)

Co-authored-by: yuhang2.zhang <[email protected]>
  • Loading branch information
Jam804 and yuhang2.zhang authored Dec 1, 2024
1 parent 780e8df commit 4585355
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ public Result<String> upload(MultipartFile file, @PathVariable Integer id) {
dataType = "Catalogue",
dataTypeClass = Catalogue.class)
public Result<Void> saveOrUpdateCatalogue(@RequestBody Catalogue catalogue) {
if (catalogueService.checkNameIsExistByParentId(catalogue)) {
return Result.failed(Status.NAME_IS_EXIST);
}
if (catalogueService.saveOrUpdateOrRename(catalogue)) {
return Result.succeed(Status.SAVE_SUCCESS);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,13 @@ public interface CatalogueService extends ISuperService<Catalogue> {
*/
Boolean saveOrUpdateOrRename(Catalogue catalogue);

/**
* Check if the catalogue name is exist
* @param catalogue catalogue
* @return true if the catalogue name is exist
*/
Boolean checkNameIsExistByParentId(Catalogue catalogue);

/**
* Check if the catalogue task name is exist
* @param name catalogue task name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,19 @@ public Boolean saveOrUpdateOrRename(Catalogue catalogue) {
return saveOrUpdate(catalogue);
}

/**
* Check if the catalogue name is exist
* @param catalogue catalogue
* @return true if the catalogue name is exist
*/
@Override
public Boolean checkNameIsExistByParentId(Catalogue catalogue) {
return getBaseMapper()
.exists(new LambdaQueryWrapper<Catalogue>()
.eq(Catalogue::getName, catalogue.getName())
.ne(catalogue.getParentId() != null, Catalogue::getParentId, catalogue.getParentId()));
}

private CatalogueTaskDTO getCatalogueTaskDTO(String name, Integer parentId) {
CatalogueTaskDTO catalogueTaskDTO = new CatalogueTaskDTO();
catalogueTaskDTO.setName(UUID.randomUUID().toString().substring(0, 6) + name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ public enum Status {
CATALOGUE_NOT_EXIST(12017, "catalogue.not.exist"),
CATALOGUE_IS_EXIST(12018, "catalogue.is.exist"),
TASK_NAME_NOT_MATCH_CATALOGUE_NAME(12019, "task.name.not.match.catalogue.name"),
NAME_IS_EXIST(12021, "A task and a directory cannot have the same name under the same parent directory."),

/**
* alert instance
Expand Down

0 comments on commit 4585355

Please sign in to comment.