diff --git a/server/app/goauto/shopeeproduct/handler.go b/server/app/goauto/shopeeproduct/handler.go index 9624744..51071ad 100644 --- a/server/app/goauto/shopeeproduct/handler.go +++ b/server/app/goauto/shopeeproduct/handler.go @@ -34,8 +34,18 @@ func (handler Handler) List(c *gin.Context) { if !ok { return } + var imageSearchLinked *bool + if raw := strings.TrimSpace(c.Query("imageSearchLinked")); raw != "" { + value, parseErr := strconv.ParseBool(raw) + if parseErr != nil { + writeError(c, invalidRequest("imageSearchLinked 必须是布尔值")) + return + } + imageSearchLinked = &value + } response, err := service.List(c.Request.Context(), ListRequest{ Page: page, PageSize: pageSize, Keyword: c.Query("keyword"), Status: strings.TrimSpace(c.Query("status")), + ImageSearchLinked: imageSearchLinked, }) if err != nil { writeError(c, err) diff --git a/server/app/goauto/shopeeproduct/service.go b/server/app/goauto/shopeeproduct/service.go index a351360..49bed89 100644 --- a/server/app/goauto/shopeeproduct/service.go +++ b/server/app/goauto/shopeeproduct/service.go @@ -231,7 +231,8 @@ type ListRequest struct { // Status filters by lifecycle: "" (default) live only, "deleted" soft-deleted // only. There is no "all" value: mixing live and deleted rows in one page // would defeat the point of the filter (#40 prototype: 全部(不含已删除)). - Status string + Status string + ImageSearchLinked *bool } func (service *Service) List(ctx context.Context, request ListRequest) (ListResponse, error) { @@ -257,6 +258,9 @@ func (service *Service) List(ctx context.Context, request ListRequest) (ListResp like := "%" + request.Keyword + "%" query = query.Where("shopee_item_id LIKE ? OR title LIKE ? OR shop_name LIKE ?", like, like, like) } + if request.ImageSearchLinked != nil { + query = query.Where("image_search_linked = ?", *request.ImageSearchLinked) + } var total int64 if err := query.Count(&total).Error; err != nil { return ListResponse{}, internalError(err)