This commit is contained in:
2025-03-28 17:51:34 +08:00
parent da612380e0
commit 5c8802d2f0
68 changed files with 3422 additions and 630 deletions

View File

@@ -8,6 +8,7 @@ import (
"management/internal/db/model/dto"
db "management/internal/db/sqlc"
"management/internal/pkg/convertor"
"management/internal/router/manage/util"
categoryservice "management/internal/service/category"
"management/internal/tpl"
@@ -28,12 +29,12 @@ func (h *CategoryHandler) List(w http.ResponseWriter, r *http.Request) {
func (h *CategoryHandler) PostList(w http.ResponseWriter, r *http.Request) {
var q dto.SearchDto
q.SearchStatus = util.ConvertInt(r.PostFormValue("SearchStatus"), 9999)
q.SearchParentID = util.ConvertInt(r.PostFormValue("SearchParentID"), 0)
q.SearchName = r.PostFormValue("SearchName")
q.SearchKey = r.PostFormValue("SearchKey")
q.Page = util.ConvertInt(r.PostFormValue("page"), 1)
q.Rows = util.ConvertInt(r.PostFormValue("rows"), 10)
q.SearchStatus = convertor.ConvertInt(r.PostFormValue("status"), 9999)
q.SearchParentID = convertor.ConvertInt(r.PostFormValue("parentId"), 0)
q.SearchName = r.PostFormValue("name")
q.SearchID = convertor.ConvertInt[int64](r.PostFormValue("id"), 0)
q.Page = convertor.ConvertInt(r.PostFormValue("page"), 1)
q.Rows = convertor.ConvertInt(r.PostFormValue("rows"), 10)
res, count, err := categoryservice.ListCategoriesCondition(r.Context(), q)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
@@ -194,19 +195,32 @@ func (h *CategoryHandler) DTree(w http.ResponseWriter, r *http.Request) {
}
func (h *CategoryHandler) XmSelect(w http.ResponseWriter, r *http.Request) {
all, err := categoryservice.ListByLetter(r.Context(), r.URL.Query().Get("letter"))
letter := r.URL.Query().Get("letter")
ctx := r.Context()
if len(letter) > 0 {
all, err := categoryservice.ListByLetter(ctx, letter)
if err != nil {
tpl.JSONERR(w, err.Error())
return
}
var res []*dto.XmSelectStrDto
for _, v := range all {
res = append(res, &dto.XmSelectStrDto{
Name: v.Name,
Value: strconv.FormatInt(int64(v.ID), 10),
})
}
tpl.JSON(w, res)
return
}
res, err := categoryservice.XmSelectCategory(ctx, 0)
if err != nil {
tpl.JSONERR(w, err.Error())
return
}
var res []*dto.XmSelectStrDto
for _, v := range all {
res = append(res, &dto.XmSelectStrDto{
Name: v.Name,
Value: strconv.FormatInt(int64(v.ID), 10),
})
}
tpl.JSON(w, res)
}