From 3a9a60112bf2778b765b6dbbf21be464d3815ad8 Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Tue, 5 Nov 2024 18:17:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/dao/yibao_merchant_dao.go | 8 +++++++ src/implement/yibao_merchant_db.go | 38 ++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 src/dao/yibao_merchant_dao.go create mode 100644 src/implement/yibao_merchant_db.go diff --git a/src/dao/yibao_merchant_dao.go b/src/dao/yibao_merchant_dao.go new file mode 100644 index 0000000..d3b83ce --- /dev/null +++ b/src/dao/yibao_merchant_dao.go @@ -0,0 +1,8 @@ +package dao + +import "code.fnuoos.com/go_rely_warehouse/zyos_model.git/src/models" + +type YibaoMerchantDao interface { + GetYibaoMerchant(merchantNo string) (m *models.YibaoMerchant, err error) + GetYibaoMerchantById(id string) (m *models.YibaoMerchant, err error) +} diff --git a/src/implement/yibao_merchant_db.go b/src/implement/yibao_merchant_db.go new file mode 100644 index 0000000..7c7dabf --- /dev/null +++ b/src/implement/yibao_merchant_db.go @@ -0,0 +1,38 @@ +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" + zhios_order_relate_logx "code.fnuoos.com/go_rely_warehouse/zyos_model.git/utils/logx" + "xorm.io/xorm" +) + +type YibaoMerchantDb struct { + Db *xorm.Engine +} + +func NewYibaoMerchantDb(engine *xorm.Engine) dao.YibaoMerchantDao { + return &YibaoMerchantDb{Db: engine} +} +func (y YibaoMerchantDb) GetYibaoMerchant(merchantNo string) (m *models.YibaoMerchant, err error) { + m = new(models.YibaoMerchant) + has, err := y.Db.Where("merchant_no = ?", merchantNo).Get(m) + if err != nil { + return nil, zhios_order_relate_logx.Error(err) + } + if has == false { + return nil, nil + } + return m, nil +} +func (y YibaoMerchantDb) GetYibaoMerchantById(id string) (m *models.YibaoMerchant, err error) { + m = new(models.YibaoMerchant) + has, err := y.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 +}