| | |
| | | "go.uber.org/zap" |
| | | "gorm.io/gorm" |
| | | "srm/global" |
| | | "srm/model/common/request" |
| | | "srm/model/common/response" |
| | | "srm/model/purchase" |
| | | purchaserequest "srm/model/purchase/request" |
| | |
| | | // @Success 200 {object} response.Response{data=response.PageResult,msg=string} "分页获取采购单列表,返回包括列表,总数,页码,每页数量" |
| | | // @Router /purchase/purchaseList [get] |
| | | func (e *PurchaseApi) GetPurchaseList(c *gin.Context) { |
| | | var pageInfo request.PageInfo |
| | | var pageInfo purchaserequest.PurchaseSearch |
| | | err := c.ShouldBindQuery(&pageInfo) |
| | | if err != nil { |
| | | response.FailWithMessage(err.Error(), c) |
| | |
| | | "github.com/shopspring/decimal" |
| | | "srm/model/common/request" |
| | | "srm/model/purchase" |
| | | "time" |
| | | ) |
| | | |
| | | type PurchaseSearch struct { |
| | | StartCreatedAt *time.Time `json:"startCreatedAt" form:"startCreatedAt"` |
| | | EndCreatedAt *time.Time `json:"endCreatedAt" form:"endCreatedAt"` |
| | | request.PageInfo |
| | | SupplierId int `json:"supplierId" form:"supplierId" gorm:"type:int(11);not null;default 0;comment:供应商id"` // 供应商id |
| | | } |
| | | |
| | | type AddPurchase struct { |
| | |
| | | "github.com/spf13/cast" |
| | | "gorm.io/gorm" |
| | | "srm/global" |
| | | "srm/model/common/request" |
| | | "srm/model/purchase" |
| | | purchaserequest "srm/model/purchase/request" |
| | | "srm/proto/qualityinspect" |
| | | "srm/service/test" |
| | | ) |
| | |
| | | //@param: info request.PageInfo |
| | | //@return: list interface{}, total int64, err error |
| | | |
| | | func (slf *PurchaseService) GetPurchaseList(info request.PageInfo) (list interface{}, total int64, err error) { |
| | | func (slf *PurchaseService) GetPurchaseList(info purchaserequest.PurchaseSearch) (list interface{}, total int64, err error) { |
| | | limit := info.PageSize |
| | | offset := info.PageSize * (info.Page - 1) |
| | | db := global.GVA_DB.Model(&purchase.Purchase{}) |
| | |
| | | } |
| | | } |
| | | |
| | | if info.SupplierId != 0 { |
| | | db = db.Where("supplier_id = ?", info.SupplierId) |
| | | } |
| | | err = db.Count(&total).Error |
| | | if err != nil { |
| | | return purchaseList, total, err |