🔧 chore: 初始化番茄小说 API 项目结构
新增项目基础框架,包含核心 API 实现、算法模块、HTTP 处理器等完整功能模块
This commit is contained in:
commit
6981148727
107 files changed
+12463
No files matched your search
@@ -0,0 +1,46 @@
|
||||
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)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user