From fbb3b8c3eb3b48772dc1123561e68741d05dfffa Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期三, 30 八月 2023 13:31:35 +0800 Subject: [PATCH] 统一记录编号 --- model/receipt.go | 13 +++++++++++-- 1 files changed, 11 insertions(+), 2 deletions(-) diff --git a/model/receipt.go b/model/receipt.go index 50945d3..5c335a9 100644 --- a/model/receipt.go +++ b/model/receipt.go @@ -28,7 +28,7 @@ BankAccount BankAccount `gorm:"foreignKey:BankAccountId" json:"bankAccount"` Remark string `gorm:"column:remark;type:varchar(255);not null;default '';comment:澶囨敞" json:"remark"` // 澶囨敞 FileId int `gorm:"column:file_id;type:int;not null;default 0;comment:闄勪欢id" json:"fileId"` // 闄勪欢id - gorm.Model `json:"-"` + CrmModel } // ReceiptSearch 鏀舵鍗曟悳绱㈡潯浠� @@ -43,10 +43,19 @@ } ) -func (Receipt) TableName() string { +func (slf *Receipt) TableName() string { return "receipt" } +func (slf *Receipt) AfterFind(db *gorm.DB) (err error) { + err = slf.CrmModel.AfterFind(db) + if slf.CrmModel.ID == 0 { + slf.CrmModel.ID = uint(slf.Id) + } + slf.CrmModel.SetNumber(constvar.NumberPrefixOfReceipt) + return nil +} + func NewReceiptSearch() *ReceiptSearch { return &ReceiptSearch{ Orm: mysqlx.GetDB(), -- Gitblit v1.8.0