Skip to content

Commit

Permalink
refactor(category): change sort field to sort_id in category update
Browse files Browse the repository at this point in the history
- Update API and service to use SortID instead of Sort
- Modify front-end to send sort_id instead of sort
- This change improves consistency in field naming related to sorting
  • Loading branch information
ch3nnn committed Jan 31, 2025
1 parent fd1c6bb commit 3d88517
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion api/v1/category.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ type (
Name *string `form:"name"` // 菜单名称
Icon *string `form:"icon"` // 图标
IsUsed *bool `form:"used"` // 是否启用
Sort *int `form:"sort"` // 排序
SortID *int `form:"sort_id"` // 排序 ID
}

CategoryUpdateResp struct {
Expand Down
4 changes: 2 additions & 2 deletions internal/service/category/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ func (s *service) Update(ctx context.Context, req *v1.CategoryUpdateReq) (*v1.Ca
if req.Icon != nil {
update["icon"] = req.Icon
}
if req.Sort != nil {
update["sort"] = req.Sort
if req.SortID != nil {
update["sort"] = req.SortID
}
if req.IsUsed != nil {
update["is_used"] = req.IsUsed
Expand Down
2 changes: 1 addition & 1 deletion web/templates/category/category_view.html
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@
AjaxForm(
"PUT",
"/api/admin/category/update",
{id: id, sort: val},
{id: id, sort_id: val},
function () {
},
function () {
Expand Down

0 comments on commit 3d88517

Please sign in to comment.