From 42ff22d419dfa6b8a1617db48e35253d262fb21c Mon Sep 17 00:00:00 2001 From: dengbiao Date: Tue, 18 Jun 2024 18:41:12 +0800 Subject: [PATCH] =?UTF-8?q?add=20=E5=88=86=E4=BB=98=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/dao/installment_payment_list_dao.go | 1 + src/dao/installment_payment_scheme_dao.go | 5 +++- src/implement/installment_payment_list_db.go | 9 +++++++ .../installment_payment_scheme_db.go | 27 +++++++++++++++++-- 4 files changed, 39 insertions(+), 3 deletions(-) diff --git a/src/dao/installment_payment_list_dao.go b/src/dao/installment_payment_list_dao.go index a952d80..175ada5 100644 --- a/src/dao/installment_payment_list_dao.go +++ b/src/dao/installment_payment_list_dao.go @@ -8,4 +8,5 @@ import ( type InstallmentPaymentListDao interface { GetInstallmentPaymentListById(id int) (m *models.InstallmentPaymentList, err error) UpdateInstallmentPaymentListBySess(sess *xorm.Session, m *models.InstallmentPaymentList, forceColums ...string) (int64, error) + InsertInstallmentPaymentList(m *models.InstallmentPaymentList) (id int, err error) } diff --git a/src/dao/installment_payment_scheme_dao.go b/src/dao/installment_payment_scheme_dao.go index c741136..d81f5fb 100644 --- a/src/dao/installment_payment_scheme_dao.go +++ b/src/dao/installment_payment_scheme_dao.go @@ -1,5 +1,8 @@ package dao +import "code.fnuoos.com/go_rely_warehouse/zyos_model.git/src/models" + type InstallmentPaymentSchemeDao interface { - //TODO:: You can add specific method definitions here + InsertInstallmentPaymentScheme(m *models.InstallmentPaymentScheme) (id int, err error) + GetInstallmentPaymentSchemeById(id int) (m *models.InstallmentPaymentScheme, err error) } diff --git a/src/implement/installment_payment_list_db.go b/src/implement/installment_payment_list_db.go index e518590..b2e4bf9 100644 --- a/src/implement/installment_payment_list_db.go +++ b/src/implement/installment_payment_list_db.go @@ -15,6 +15,15 @@ type InstallmentPaymentListDb struct { Db *xorm.Engine } +func (i InstallmentPaymentListDb) InsertInstallmentPaymentList(m *models.InstallmentPaymentList) (id int, err error) { + _, err = i.Db.InsertOne(m) + if err != nil { + return 0, err + } + id = m.Id + return id, nil +} + func (i InstallmentPaymentListDb) UpdateInstallmentPaymentListBySess(sess *xorm.Session, m *models.InstallmentPaymentList, forceColums ...string) (int64, error) { var ( affected int64 diff --git a/src/implement/installment_payment_scheme_db.go b/src/implement/installment_payment_scheme_db.go index f795254..d7493f7 100644 --- a/src/implement/installment_payment_scheme_db.go +++ b/src/implement/installment_payment_scheme_db.go @@ -2,13 +2,36 @@ import ( "code.fnuoos.com/go_rely_warehouse/zyos_model.git/src/dao" + "code.fnuoos.com/go_rely_warehouse/zyos_model.git/src/models" + zhios_order_relate_logx "code.fnuoos.com/go_rely_warehouse/zyos_model.git/utils/logx" "xorm.io/xorm" ) +func NewInstallmentPaymentSchemeDb(engine *xorm.Engine) dao.InstallmentPaymentSchemeDao { + return &InstallmentPaymentSchemeDb{Db: engine} +} + type InstallmentPaymentSchemeDb struct { Db *xorm.Engine } -func NewInstallmentPaymentSchemeDb(engine *xorm.Engine) dao.InstallmentPaymentSchemeDao { - return &InstallmentPaymentSchemeDb{Db: engine} +func (i InstallmentPaymentSchemeDb) InsertInstallmentPaymentScheme(m *models.InstallmentPaymentScheme) (id int, err error) { + _, err = i.Db.InsertOne(m) + if err != nil { + return 0, err + } + id = m.Id + return id, nil +} + +func (i InstallmentPaymentSchemeDb) GetInstallmentPaymentSchemeById(id int) (m *models.InstallmentPaymentScheme, err error) { + m = new(models.InstallmentPaymentScheme) + has, err := i.Db.Where("id =?", id).Get(m) + if err != nil { + return nil, zhios_order_relate_logx.Error(err) + } + if has == false { + return nil, nil + } + return m, nil }