From 6aa75c2a266a2522ae713b13dc702b5ad0a08f87 Mon Sep 17 00:00:00 2001 From: liujiandao <274878379@qq.com> Date: 星期二, 24 十月 2023 13:50:23 +0800 Subject: [PATCH] 编码规则需求功能开发 --- model/salesDetails.go | 25 +++++++++++++++++++++++++ 1 files changed, 25 insertions(+), 0 deletions(-) diff --git a/model/salesDetails.go b/model/salesDetails.go index b82e761..bf371e3 100644 --- a/model/salesDetails.go +++ b/model/salesDetails.go @@ -40,6 +40,7 @@ AmountUnInvoiced decimal.Decimal `gorm:"column:amount_not_invoiced;type:decimal(12,2);comment:鏈紑绁ㄩ噾棰�" json:"amountUnInvoiced"` // 鏈紑绁ㄩ噾棰� AmountTotal decimal.Decimal `gorm:"column:amount_total;type:decimal(12,2);comment:浠风◣鍚堣" json:"amountTotal"` // 浠风◣鍚堣 CodeStandID string `json:"codeStandID" gorm:"column:code_stand_id;type:varchar(255);comment:缂栫爜id"` + DeliverType int `json:"deliverType" gorm:"column:deliver_type;type:int;comment:浜や粯绫诲瀷(1.涓�娆″彂璐�,2.澶氭鍙戣揣)"` CrmModel } @@ -133,6 +134,30 @@ return db.Updates(record).Error } +func (slf *SalesDetailsSearch) Count() (int64, error) { + var db = slf.build() + var total int64 + err := db.Count(&total).Error + return total, err +} + +func (slf *SalesDetailsSearch) MaxAutoIncr() (int, error) { + type Result struct { + Max int + } + + var ( + result Result + db = slf.build() + ) + + err := db.Select("MAX(id) as max").Scan(&result).Error + if err != nil { + return result.Max, fmt.Errorf("max err: %v", err) + } + return result.Max, nil +} + func (slf *SalesDetailsSearch) SetId(id int) *SalesDetailsSearch { slf.Id = id return slf -- Gitblit v1.8.0