From 6380c884a38ba5cc22f8a20bf0851259e50d1391 Mon Sep 17 00:00:00 2001 From: dengbiao Date: Mon, 12 Aug 2024 14:34:22 +0800 Subject: [PATCH] update --- src/dao/honey_dividend_basic_dao.go | 4 ++- src/dao/honey_dividends_records_dao.go | 9 +++++ .../honey_dividends_records_with_flow_dao.go | 10 ++++++ src/implement/honey_dividend_basic_db.go | 34 +++++++++++++++++-- src/implement/honey_dividends_records_db.go | 31 +++++++++++++++++ .../honey_dividends_records_with_flow_db.go | 23 +++++++++++++ 6 files changed, 107 insertions(+), 4 deletions(-) create mode 100644 src/dao/honey_dividends_records_dao.go create mode 100644 src/dao/honey_dividends_records_with_flow_dao.go create mode 100644 src/implement/honey_dividends_records_db.go create mode 100644 src/implement/honey_dividends_records_with_flow_db.go diff --git a/src/dao/honey_dividend_basic_dao.go b/src/dao/honey_dividend_basic_dao.go index 06aec7f..539eff1 100644 --- a/src/dao/honey_dividend_basic_dao.go +++ b/src/dao/honey_dividend_basic_dao.go @@ -1,4 +1,4 @@ -package dao +package dao import ( "code.fnuoos.com/go_rely_warehouse/zyos_model.git/src/models" @@ -8,4 +8,6 @@ import ( type HoneyDividendBasicDao interface { GetHoneyDividendBasicByCoinId(coinId int) (m *models.HoneyDividendBasic, err error) GetHoneyDividendBasicByCoinIdSess(sess *xorm.Session, coinId int) (m *models.HoneyDividendBasic, err error) + GetHoneyDividendBasic() (m *models.HoneyDividendBasic, err error) + UpdateHoneyDividendBasic(m *models.HoneyDividendBasic, forceColums ...string) (int64, error) } diff --git a/src/dao/honey_dividends_records_dao.go b/src/dao/honey_dividends_records_dao.go new file mode 100644 index 0000000..57a3f32 --- /dev/null +++ b/src/dao/honey_dividends_records_dao.go @@ -0,0 +1,9 @@ +package dao + +import ( + "code.fnuoos.com/go_rely_warehouse/zyos_model.git/src/models" +) + +type HoneyDividendsRecordsDao interface { + UpdateHoneyDividendsRecords(m *models.HoneyDividendsRecords, forceColums ...string) (int64, error) +} diff --git a/src/dao/honey_dividends_records_with_flow_dao.go b/src/dao/honey_dividends_records_with_flow_dao.go new file mode 100644 index 0000000..009d913 --- /dev/null +++ b/src/dao/honey_dividends_records_with_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 HoneyDividendsRecordsWithFlowDao interface { + HoneyDividendsRecordsWithFlowInsert(session *xorm.Session, honeyDividendsRecordsWithFlow *models.HoneyDividendsRecordsWithFlow) (int64, error) +} diff --git a/src/implement/honey_dividend_basic_db.go b/src/implement/honey_dividend_basic_db.go index 92ecb0d..1d224c3 100644 --- a/src/implement/honey_dividend_basic_db.go +++ b/src/implement/honey_dividend_basic_db.go @@ -1,4 +1,4 @@ -package implement +package implement import ( "code.fnuoos.com/go_rely_warehouse/zyos_model.git/src/dao" @@ -7,12 +7,40 @@ import ( "xorm.io/xorm" ) +func NewHoneyDividendBasicDb(engine *xorm.Engine) dao.HoneyDividendBasicDao { + return &HoneyDividendBasicDb{Db: engine} +} + type HoneyDividendBasicDb struct { Db *xorm.Engine } -func NewHoneyDividendBasicDb(engine *xorm.Engine) dao.HoneyDividendBasicDao { - return &HoneyDividendBasicDb{Db: engine} +func (i HoneyDividendBasicDb) UpdateHoneyDividendBasic(m *models.HoneyDividendBasic, forceColums ...string) (int64, error) { + var ( + affected int64 + err error + ) + if forceColums != nil { + affected, err = i.Db.Where("id=?", m.Id).Cols(forceColums...).Update(m) + } else { + affected, err = i.Db.Where("id=?", m.Id).Update(m) + } + if err != nil { + return 0, err + } + return affected, nil +} + +func (i HoneyDividendBasicDb) GetHoneyDividendBasic() (m *models.HoneyDividendBasic, err error) { + m = new(models.HoneyDividendBasic) + has, err := i.Db.Where("is_open = 1").Get(m) + if err != nil { + return nil, zhios_order_relate_logx.Error(err) + } + if has == false { + return nil, nil + } + return m, nil } func (i HoneyDividendBasicDb) GetHoneyDividendBasicByCoinIdSess(sess *xorm.Session, coinId int) (m *models.HoneyDividendBasic, err error) { diff --git a/src/implement/honey_dividends_records_db.go b/src/implement/honey_dividends_records_db.go new file mode 100644 index 0000000..b98cea0 --- /dev/null +++ b/src/implement/honey_dividends_records_db.go @@ -0,0 +1,31 @@ +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 NewHoneyDividendsRecordsDb(engine *xorm.Engine) dao.HoneyDividendsRecordsDao { + return &HoneyDividendsRecordsDb{Db: engine} +} + +type HoneyDividendsRecordsDb struct { + Db *xorm.Engine +} + +func (h HoneyDividendsRecordsDb) UpdateHoneyDividendsRecords(m *models.HoneyDividendsRecords, forceColums ...string) (int64, error) { + var ( + affected int64 + err error + ) + if forceColums != nil { + affected, err = h.Db.Where("id=?", m.Id).Cols(forceColums...).Update(m) + } else { + affected, err = h.Db.Where("id=?", m.Id).Update(m) + } + if err != nil { + return 0, err + } + return affected, nil +} diff --git a/src/implement/honey_dividends_records_with_flow_db.go b/src/implement/honey_dividends_records_with_flow_db.go new file mode 100644 index 0000000..ea6939f --- /dev/null +++ b/src/implement/honey_dividends_records_with_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 NewHoneyDividendsRecordsWithFlowDb(engine *xorm.Engine) dao.HoneyDividendsRecordsWithFlowDao { + return &HoneyDividendsRecordsWithFlowDb{Db: engine} +} + +type HoneyDividendsRecordsWithFlowDb struct { + Db *xorm.Engine +} + +func (h HoneyDividendsRecordsWithFlowDb) HoneyDividendsRecordsWithFlowInsert(session *xorm.Session, honeyDividendsRecordsWithFlow *models.HoneyDividendsRecordsWithFlow) (int64, error) { + _, err := session.InsertOne(honeyDividendsRecordsWithFlow) + if err != nil { + return 0, err + } + return honeyDividendsRecordsWithFlow.Id, nil +}