47 lines
1.2 KiB
Go
47 lines
1.2 KiB
Go
package handlers
|
|
|
|
import (
|
|
"fanqie/internal/fqapi"
|
|
"fmt"
|
|
"net/http"
|
|
)
|
|
|
|
// HandleCategoryFront 分类列表处理
|
|
func HandleCategoryFront(w http.ResponseWriter, r *http.Request) {
|
|
incrementTotal()
|
|
incrementCategory()
|
|
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
|
|
|
tab := r.URL.Query().Get("tab")
|
|
|
|
result, err := fqapi.HandleCategoryFront(tab)
|
|
if err != nil {
|
|
fmt.Fprintf(w, `{"code": -1, "msg": "获取分类列表失败: %s"}`, err.Error())
|
|
return
|
|
}
|
|
|
|
fmt.Fprint(w, result)
|
|
}
|
|
|
|
// HandleCategoryLanding 分类详情处理
|
|
func HandleCategoryLanding(w http.ResponseWriter, r *http.Request) {
|
|
incrementTotal()
|
|
incrementCategory()
|
|
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
|
|
|
categoryID := r.URL.Query().Get("category_id")
|
|
offset := r.URL.Query().Get("offset")
|
|
wordNumber := r.URL.Query().Get("word_number")
|
|
bookStatus := r.URL.Query().Get("book_status")
|
|
sortBy := r.URL.Query().Get("sort_by")
|
|
|
|
result, err := fqapi.HandleCategoryLanding(categoryID, offset, wordNumber, bookStatus, sortBy)
|
|
if err != nil {
|
|
fmt.Fprintf(w, `{"code": -1, "msg": "获取分类详情失败: %s"}`, err.Error())
|
|
return
|
|
}
|
|
|
|
fmt.Fprint(w, result)
|
|
}
|
|
|