Skip to content

Commit 4585355

Browse files
[Bug] [dinky-web] Issue with creating a new task with a subdirectory of the same name (#3993)
Co-authored-by: yuhang2.zhang <yuhang2.zhang@ly.com>
1 parent 780e8df commit 4585355

File tree

4 files changed

+24
-0
lines changed

4 files changed

+24
-0
lines changed

dinky-admin/src/main/java/org/dinky/controller/CatalogueController.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,9 @@ public Result<String> upload(MultipartFile file, @PathVariable Integer id) {
128128
dataType = "Catalogue",
129129
dataTypeClass = Catalogue.class)
130130
public Result<Void> saveOrUpdateCatalogue(@RequestBody Catalogue catalogue) {
131+
if (catalogueService.checkNameIsExistByParentId(catalogue)) {
132+
return Result.failed(Status.NAME_IS_EXIST);
133+
}
131134
if (catalogueService.saveOrUpdateOrRename(catalogue)) {
132135
return Result.succeed(Status.SAVE_SUCCESS);
133136
} else {

dinky-admin/src/main/java/org/dinky/service/catalogue/CatalogueService.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,13 @@ public interface CatalogueService extends ISuperService<Catalogue> {
144144
*/
145145
Boolean saveOrUpdateOrRename(Catalogue catalogue);
146146

147+
/**
148+
* Check if the catalogue name is exist
149+
* @param catalogue catalogue
150+
* @return true if the catalogue name is exist
151+
*/
152+
Boolean checkNameIsExistByParentId(Catalogue catalogue);
153+
147154
/**
148155
* Check if the catalogue task name is exist
149156
* @param name catalogue task name

dinky-admin/src/main/java/org/dinky/service/catalogue/impl/CatalogueServiceImpl.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,19 @@ public Boolean saveOrUpdateOrRename(Catalogue catalogue) {
582582
return saveOrUpdate(catalogue);
583583
}
584584

585+
/**
586+
* Check if the catalogue name is exist
587+
* @param catalogue catalogue
588+
* @return true if the catalogue name is exist
589+
*/
590+
@Override
591+
public Boolean checkNameIsExistByParentId(Catalogue catalogue) {
592+
return getBaseMapper()
593+
.exists(new LambdaQueryWrapper<Catalogue>()
594+
.eq(Catalogue::getName, catalogue.getName())
595+
.ne(catalogue.getParentId() != null, Catalogue::getParentId, catalogue.getParentId()));
596+
}
597+
585598
private CatalogueTaskDTO getCatalogueTaskDTO(String name, Integer parentId) {
586599
CatalogueTaskDTO catalogueTaskDTO = new CatalogueTaskDTO();
587600
catalogueTaskDTO.setName(UUID.randomUUID().toString().substring(0, 6) + name);

dinky-common/src/main/java/org/dinky/data/enums/Status.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ public enum Status {
196196
CATALOGUE_NOT_EXIST(12017, "catalogue.not.exist"),
197197
CATALOGUE_IS_EXIST(12018, "catalogue.is.exist"),
198198
TASK_NAME_NOT_MATCH_CATALOGUE_NAME(12019, "task.name.not.match.catalogue.name"),
199+
NAME_IS_EXIST(12021, "A task and a directory cannot have the same name under the same parent directory."),
199200

200201
/**
201202
* alert instance

0 commit comments

Comments
 (0)