BLOG-105 Implement CRUD functionality for Labels #107
Loading…
x
Reference in New Issue
Block a user
No description provided.
Delete Branch "BLOG-105_lable_create_and_update_routes"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Description
This PR introduces full CRUD (Create, Read, Update) functionality for post labels, implemented by following the existing Clean Architecture.
Backend
New API Endpoints for Label Management:
POST /label
: Create a new label (authentication required).PUT /label/{id}
: Update a label by its ID (authentication required).GET /label
: Get all labels.Architectural Implementation:
CreateLabelRequestDto
,UpdateLabelRequestDto
, and updatedPostController
with methods to handle label-related operations.CreateLabelUseCase
,UpdateLabelUseCase
,GetAllLabelsUseCase
) to handle business logic.LabelRepository
andLabelDbService
to manage database interactions, including creating, updating, and querying labels.Route Adjustment:
GET /post/all
toGET /post
to be more RESTful.Frontend
/post/all
to/post
.Package Changes
No response
Screenshots
No response
Reference
Resolves #105
Checklist
/improve
PR Code Suggestions ✨
Remove redundant database existence check
The
update_label
method inLabelDbServiceImpl
already handles the case where thelabel is not found by checking
rows_affected
and returningPostError::NotFound
.Therefore, the preceding
get_label_by_id
call inUpdateLabelUseCaseImpl::execute
isredundant. Removing this call will eliminate an unnecessary database query,
improving performance.
backend/feature/post/src/application/use_case/update_label_use_case.rs [27-30]
Suggestion importance[1-10]: 8
__
Why: The
update_label
method inLabelDbServiceImpl
correctly handles thePostError::NotFound
case by checkingrows_affected
. Therefore, the precedingget_label_by_id
call inUpdateLabelUseCaseImpl
is redundant, and removing it improves performance by eliminating an unnecessary database query.Addressed in
234b337519
.