From 4b01cd4eacad0460f84bd22b45c2c4867c0b231e Mon Sep 17 00:00:00 2001 From: dengbiao Date: Tue, 18 Jun 2024 16:56:39 +0800 Subject: [PATCH] update --- src/dao/installment_payment_list_dao.go | 6 ++++- .../installment_payment_repaid_flow_dao.go | 10 ++++++++ src/implement/installment_payment_list_db.go | 16 +++++++++++++ .../installment_payment_repaid_flow_db.go | 23 +++++++++++++++++++ src/models/installment_payment_repaid_flow.go | 11 +++++++++ 5 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 src/dao/installment_payment_repaid_flow_dao.go create mode 100644 src/implement/installment_payment_repaid_flow_db.go create mode 100644 src/models/installment_payment_repaid_flow.go diff --git a/src/dao/installment_payment_list_dao.go b/src/dao/installment_payment_list_dao.go index 251f9fa..a952d80 100644 --- a/src/dao/installment_payment_list_dao.go +++ b/src/dao/installment_payment_list_dao.go @@ -1,7 +1,11 @@ package dao -import "code.fnuoos.com/go_rely_warehouse/zyos_model.git/src/models" +import ( + "code.fnuoos.com/go_rely_warehouse/zyos_model.git/src/models" + "xorm.io/xorm" +) type InstallmentPaymentListDao interface { GetInstallmentPaymentListById(id int) (m *models.InstallmentPaymentList, err error) + UpdateInstallmentPaymentListBySess(sess *xorm.Session, m *models.InstallmentPaymentList, forceColums ...string) (int64, error) } diff --git a/src/dao/installment_payment_repaid_flow_dao.go b/src/dao/installment_payment_repaid_flow_dao.go new file mode 100644 index 0000000..4a0930d --- /dev/null +++ b/src/dao/installment_payment_repaid_flow_dao.go @@ -0,0 +1,10 @@ +package dao + +import ( + "code.fnuoos.com/go_rely_warehouse/zyos_model.git/src/models" + "xorm.io/xorm" +) + +type InstallmentPaymentRepaidFlowDao interface { + InsertInstallmentPaymentRepaidFlowBySession(session *xorm.Session, m *models.InstallmentPaymentRepaidFlow) (id int, err error) +} diff --git a/src/implement/installment_payment_list_db.go b/src/implement/installment_payment_list_db.go index e12df4f..e518590 100644 --- a/src/implement/installment_payment_list_db.go +++ b/src/implement/installment_payment_list_db.go @@ -15,6 +15,22 @@ type InstallmentPaymentListDb struct { Db *xorm.Engine } +func (i InstallmentPaymentListDb) UpdateInstallmentPaymentListBySess(sess *xorm.Session, m *models.InstallmentPaymentList, forceColums ...string) (int64, error) { + var ( + affected int64 + err error + ) + if forceColums != nil { + affected, err = sess.Where("id=?", m.Id).Cols(forceColums...).Update(m) + } else { + affected, err = sess.Where("id=?", m.Id).Update(m) + } + if err != nil { + return 0, err + } + return affected, nil +} + func (i InstallmentPaymentListDb) GetInstallmentPaymentListById(id int) (m *models.InstallmentPaymentList, err error) { m = new(models.InstallmentPaymentList) has, err := i.Db.Where("id =?", id).Get(m) diff --git a/src/implement/installment_payment_repaid_flow_db.go b/src/implement/installment_payment_repaid_flow_db.go new file mode 100644 index 0000000..538f839 --- /dev/null +++ b/src/implement/installment_payment_repaid_flow_db.go @@ -0,0 +1,23 @@ +package implement + +import ( + "code.fnuoos.com/go_rely_warehouse/zyos_model.git/src/dao" + "code.fnuoos.com/go_rely_warehouse/zyos_model.git/src/models" + "xorm.io/xorm" +) + +func NewInstallmentPaymentRepaidFlowDb(engine *xorm.Engine) dao.InstallmentPaymentRepaidFlowDao { + return &InstallmentPaymentRepaidFlowDb{Db: engine} +} + +type InstallmentPaymentRepaidFlowDb struct { + Db *xorm.Engine +} + +func (i InstallmentPaymentRepaidFlowDb) InsertInstallmentPaymentRepaidFlowBySession(session *xorm.Session, m *models.InstallmentPaymentRepaidFlow) (id int, err error) { + _, err = session.InsertOne(m) + if err != nil { + return 0, err + } + return m.Id, nil +} diff --git a/src/models/installment_payment_repaid_flow.go b/src/models/installment_payment_repaid_flow.go new file mode 100644 index 0000000..8e374d1 --- /dev/null +++ b/src/models/installment_payment_repaid_flow.go @@ -0,0 +1,11 @@ +package models + +type InstallmentPaymentRepaidFlow struct { + Id int `json:"id" xorm:"not null pk autoincr INT(11)"` + RecordId int `json:"record_id" xorm:"not null default 0 comment('记录ID') INT(11)"` + Uid int `json:"uid" xorm:"not null default 0 comment('用户ID') INT(11)"` + Amount string `json:"amount" xorm:"not null default 0.0 comment('金额') DECIMAL(12,1)"` + WhichRepaymentPeriod int `json:"which_repayment_period" xorm:"not null default 1 comment('第x还款') TINYINT(3)"` + CreateAt string `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' comment('创建时间') DATETIME"` + UpdateAt string `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' comment('更新时间') DATETIME"` +}