@@ -2,6 +2,7 @@ package dao | |||||
import ( | import ( | ||||
"code.fnuoos.com/go_rely_warehouse/zyos_model.git/src/models" | "code.fnuoos.com/go_rely_warehouse/zyos_model.git/src/models" | ||||
"xorm.io/xorm" | |||||
) | ) | ||||
type HappyOrchardRewardExchangeRecordsDao interface { | type HappyOrchardRewardExchangeRecordsDao interface { | ||||
@@ -10,4 +11,6 @@ type HappyOrchardRewardExchangeRecordsDao interface { | |||||
GetHappyOrchardRewardExchangeRecordsByRecordId(id int) (m *models.HappyOrchardRewardExchangeRecords, err error) | GetHappyOrchardRewardExchangeRecordsByRecordId(id int) (m *models.HappyOrchardRewardExchangeRecords, err error) | ||||
GetHappyOrchardRewardExchangeRecordsByUidWithState(uid, state int) (m *models.HappyOrchardRewardExchangeRecords, err error) | GetHappyOrchardRewardExchangeRecordsByUidWithState(uid, state int) (m *models.HappyOrchardRewardExchangeRecords, err error) | ||||
GetHappyOrchardRewardExchangeRecordsByUidWithStateAndId(uid, id, state int) (m *models.HappyOrchardRewardExchangeRecords, err error) | GetHappyOrchardRewardExchangeRecordsByUidWithStateAndId(uid, id, state int) (m *models.HappyOrchardRewardExchangeRecords, err error) | ||||
InsertHappyOrchardRewardExchangeRecordsBySess(sess *xorm.Session, m *models.HappyOrchardRewardExchangeRecords) (int, error) | |||||
UpdateHappyOrchardRewardExchangeRecordsBySess(sess *xorm.Session, m *models.HappyOrchardRewardExchangeRecords, forceColums ...string) (int64, error) | |||||
} | } |
@@ -7,12 +7,36 @@ import ( | |||||
"xorm.io/xorm" | "xorm.io/xorm" | ||||
) | ) | ||||
func NewHappyOrchardRewardExchangeRecordsDb(engine *xorm.Engine) dao.HappyOrchardRewardExchangeRecordsDao { | |||||
return &HappyOrchardRewardExchangeRecordsDb{Db: engine} | |||||
} | |||||
type HappyOrchardRewardExchangeRecordsDb struct { | type HappyOrchardRewardExchangeRecordsDb struct { | ||||
Db *xorm.Engine | Db *xorm.Engine | ||||
} | } | ||||
func NewHappyOrchardRewardExchangeRecordsDb(engine *xorm.Engine) dao.HappyOrchardRewardExchangeRecordsDao { | |||||
return &HappyOrchardRewardExchangeRecordsDb{Db: engine} | |||||
func (h HappyOrchardRewardExchangeRecordsDb) UpdateHappyOrchardRewardExchangeRecordsBySess(sess *xorm.Session, m *models.HappyOrchardRewardExchangeRecords, 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 (h HappyOrchardRewardExchangeRecordsDb) InsertHappyOrchardRewardExchangeRecordsBySess(sess *xorm.Session, m *models.HappyOrchardRewardExchangeRecords) (int, error) { | |||||
_, err := sess.InsertOne(m) | |||||
if err != nil { | |||||
return 0, err | |||||
} | |||||
return m.Id, nil | |||||
} | } | ||||
func (h HappyOrchardRewardExchangeRecordsDb) GetHappyOrchardRewardExchangeRecords(id int) (m *models.HappyOrchardRewardExchangeRecords, err error) { | func (h HappyOrchardRewardExchangeRecordsDb) GetHappyOrchardRewardExchangeRecords(id int) (m *models.HappyOrchardRewardExchangeRecords, err error) { | ||||