Unverified Commit 3b9f06f7 authored by gitjxm's avatar gitjxm Committed by GitHub

fix[admin]: Task note modify name is exists and note echo issue (#2903)

* fix: Task note modify name is exists and note echo issue * style --------- Co-authored-by: 's avatarjxm <jiangxinmiao@aliyun.com>
parent 90fb89c1
...@@ -147,7 +147,7 @@ public class CatalogueController { ...@@ -147,7 +147,7 @@ public class CatalogueController {
dataType = "CatalogueTaskDTO", dataType = "CatalogueTaskDTO",
dataTypeClass = CatalogueTaskDTO.class) dataTypeClass = CatalogueTaskDTO.class)
public Result<Catalogue> createTask(@RequestBody CatalogueTaskDTO catalogueTaskDTO) { public Result<Catalogue> createTask(@RequestBody CatalogueTaskDTO catalogueTaskDTO) {
if (catalogueService.checkCatalogueTaskNameIsExist(catalogueTaskDTO.getName())) { if (catalogueService.checkCatalogueTaskNameIsExistById(catalogueTaskDTO.getName(), catalogueTaskDTO.getId())) {
return Result.failed(Status.TASK_IS_EXIST); return Result.failed(Status.TASK_IS_EXIST);
} }
Catalogue catalogue = catalogueService.saveOrUpdateCatalogueAndTask(catalogueTaskDTO); Catalogue catalogue = catalogueService.saveOrUpdateCatalogueAndTask(catalogueTaskDTO);
......
...@@ -65,8 +65,16 @@ public class Catalogue extends SuperEntity<Catalogue> { ...@@ -65,8 +65,16 @@ public class Catalogue extends SuperEntity<Catalogue> {
@TableField(exist = false) @TableField(exist = false)
private Task task; private Task task;
@TableField(exist = false)
private String note;
public Catalogue() {} public Catalogue() {}
public void setTaskAndNote(Task task) {
this.task = task;
this.note = task.getNote();
}
public Catalogue(String name, Integer taskId, String type, Integer parentId, Boolean isLeaf) { public Catalogue(String name, Integer taskId, String type, Integer parentId, Boolean isLeaf) {
this.setName(name); this.setName(name);
this.taskId = taskId; this.taskId = taskId;
......
...@@ -135,7 +135,8 @@ public interface CatalogueService extends ISuperService<Catalogue> { ...@@ -135,7 +135,8 @@ public interface CatalogueService extends ISuperService<Catalogue> {
/** /**
* Check if the catalogue task name is exist * Check if the catalogue task name is exist
* @param name catalogue task name * @param name catalogue task name
* @param id catalogue task id
* @return true if the catalogue task name is exist * @return true if the catalogue task name is exist
*/ */
boolean checkCatalogueTaskNameIsExist(String name); boolean checkCatalogueTaskNameIsExistById(String name, Integer id);
} }
...@@ -142,7 +142,7 @@ public class CatalogueServiceImpl extends SuperServiceImpl<CatalogueMapper, Cata ...@@ -142,7 +142,7 @@ public class CatalogueServiceImpl extends SuperServiceImpl<CatalogueMapper, Cata
taskList.stream() taskList.stream()
.filter(t -> t.getId().equals(tChild.getTaskId())) .filter(t -> t.getId().equals(tChild.getTaskId()))
.findFirst() .findFirst()
.ifPresent(tChild::setTask); .ifPresent(tChild::setTaskAndNote);
} }
} }
} }
...@@ -186,11 +186,15 @@ public class CatalogueServiceImpl extends SuperServiceImpl<CatalogueMapper, Cata ...@@ -186,11 +186,15 @@ public class CatalogueServiceImpl extends SuperServiceImpl<CatalogueMapper, Cata
/** /**
* check catalogue task name is exist * check catalogue task name is exist
* @param name name * @param name name
* @param id id
* @return true if exist , otherwise false * @return true if exist , otherwise false
*/ */
@Override @Override
public boolean checkCatalogueTaskNameIsExist(String name) { public boolean checkCatalogueTaskNameIsExistById(String name, Integer id) {
return getBaseMapper().exists(new LambdaQueryWrapper<Catalogue>().eq(Catalogue::getName, name)); return getBaseMapper()
.exists(new LambdaQueryWrapper<Catalogue>()
.eq(Catalogue::getName, name)
.ne(id != null, Catalogue::getId, id));
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment