feat 抽离response

This commit is contained in:
timerzz 2024-05-14 20:39:12 +08:00
parent f0e46a4116
commit 1452122efd
5 changed files with 7 additions and 9 deletions

2
go.mod
View File

@ -3,7 +3,7 @@ module haitao_watcher
go 1.22.2
require (
gitea.timerzz.com/kedaya_haitao/common v0.0.0-20240513121252-d83795b6d236
gitea.timerzz.com/kedaya_haitao/common v0.0.0-20240514123648-99c3e85dbc18
github.com/go-resty/resty/v2 v2.13.1
github.com/gofiber/fiber/v3 v3.0.0-beta.2
github.com/golang/glog v1.2.1

2
go.sum
View File

@ -1,6 +1,8 @@
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
gitea.timerzz.com/kedaya_haitao/common v0.0.0-20240513121252-d83795b6d236 h1:1t5dh6l20cexlTqmGesIY2ClqrLBqy+OE8LAVp//JC8=
gitea.timerzz.com/kedaya_haitao/common v0.0.0-20240513121252-d83795b6d236/go.mod h1:jQhygETzidSqipdL3N77SJBJVEcvKYxdNDUPfIuHdL8=
gitea.timerzz.com/kedaya_haitao/common v0.0.0-20240514123648-99c3e85dbc18 h1:lTARBVopKcR47VJGzumhNDTmxc0QUpzHnk9AuD/6kfs=
gitea.timerzz.com/kedaya_haitao/common v0.0.0-20240514123648-99c3e85dbc18/go.mod h1:cgLy4gB0z2UZD3kBp1IAemt28dkaKNdt4RC0LNkE1I8=
github.com/3andne/restls-client-go v0.1.6 h1:tRx/YilqW7iHpgmEL4E1D8dAsuB0tFF3uvncS+B6I08=
github.com/3andne/restls-client-go v0.1.6/go.mod h1:iEdTZNt9kzPIxjIGSMScUFSBrUH6bFRNg0BWlP4orEY=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=

View File

@ -1,6 +0,0 @@
package model
type ListResponse[E any] struct {
Total int64 `json:"total"`
List []E `json:"list"`
}

View File

@ -3,6 +3,7 @@ package pusher
import (
"context"
"fmt"
"gitea.timerzz.com/kedaya_haitao/common/pkg/web"
"github.com/golang/glog"
"gorm.io/gorm"
"gorm.io/gorm/schema"
@ -93,7 +94,7 @@ type ListPusherInfoRequest struct {
All bool `query:"all"`
}
func (c *Controller) List(req ListPusherInfoRequest) (resp model.ListResponse[model.Pusher[*options.AnPushOption]], err error) {
func (c *Controller) List(req ListPusherInfoRequest) (resp web.ListResponse[model.Pusher[*options.AnPushOption]], err error) {
tx := c.db
if req.Keyword != "" {
tx = tx.Where("name LIKE ? or remark LIKE ?", fmt.Sprintf("%%%s%%", req.Keyword), fmt.Sprintf("%%%s%%", req.Keyword))

View File

@ -4,6 +4,7 @@ import (
"context"
"fmt"
"gitea.timerzz.com/kedaya_haitao/common/pkg/proxy"
"gitea.timerzz.com/kedaya_haitao/common/pkg/web"
"github.com/golang/glog"
"gorm.io/gorm"
"gorm.io/gorm/clause"
@ -103,7 +104,7 @@ type ListWatcherInfoRequest struct {
Size int `query:"size"`
}
func (c *Controller) List(req ListWatcherInfoRequest) (resp model.ListResponse[model.Product], err error) {
func (c *Controller) List(req ListWatcherInfoRequest) (resp web.ListResponse[model.Product], err error) {
tx := c.db
if req.Keyword != "" {
tx = tx.Where("name LIKE ? or remark LIKE ?", fmt.Sprintf("%%%s%%", req.Keyword), fmt.Sprintf("%%%s%%", req.Keyword))