refactor: isbn=0时只输出收到请求isbn=0, 忽略详细参数日志
This commit is contained in:
parent
aa8bcae334
commit
4f1307b49e
Binary file not shown.
@ -40,8 +40,6 @@ func (h *GoodsHandler) QueryGoods(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
// 读取原始body用于调试
|
||||
bodyBytes, _ := io.ReadAll(r.Body)
|
||||
bodyStr := string(bodyBytes)
|
||||
log.Printf("[QueryGoods] 原始请求 Body: [%s], Content-Type: [%s]", bodyStr, r.Header.Get("Content-Type"))
|
||||
|
||||
// 重新创建body供ParseForm使用
|
||||
r.Body = io.NopCloser(bytes.NewBuffer(bodyBytes))
|
||||
@ -57,6 +55,17 @@ func (h *GoodsHandler) QueryGoods(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
isbn := r.FormValue("isbn")
|
||||
if isbn == "0" {
|
||||
log.Printf("[QueryGoods] 收到请求 isbn=0")
|
||||
var req service.QueryRequest
|
||||
req.ISBN = isbn
|
||||
resp := h.goodsService.QueryGoods(&req)
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
json.NewEncoder(w).Encode(resp)
|
||||
return
|
||||
}
|
||||
|
||||
bookName := r.FormValue("book_name")
|
||||
author := r.FormValue("author")
|
||||
publishing := r.FormValue("publishing")
|
||||
|
||||
@ -67,7 +67,7 @@ type QueryResponse struct {
|
||||
// QueryGoods 查询商品信息
|
||||
func (s *GoodsService) QueryGoods(req *QueryRequest) *QueryResponse {
|
||||
if req.ISBN == "0" {
|
||||
log.Printf("[QueryGoods] ISBN为0, 跳过处理")
|
||||
log.Printf("[QueryGoods] 收到请求 isbn=0")
|
||||
return &QueryResponse{
|
||||
Code: 200,
|
||||
Message: "success",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user