feat: add department name uniqueness check and corresponding error message
This commit is contained in:
@@ -60,7 +60,15 @@ public class DepartmentService {
|
||||
}
|
||||
|
||||
public Department editDepartment(Long id, DepartmentRequest request) {
|
||||
if (departmentManager.existsByName(request.name())) {
|
||||
throw new BizException(HttpStatus.CONFLICT, MessageName.REQUEST_CREATE_DEPARTMENT_NAME_DUPLICATED);
|
||||
}
|
||||
|
||||
return departmentManager.fullUpdateById(id, Department.builder()
|
||||
.name(request.name())
|
||||
.parentId(request.parentId())
|
||||
.sort(request.sort())
|
||||
.status(request.status())
|
||||
.build());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user