Browse Source

update

master
dengbiao 6 months ago
parent
commit
d19bcfaff8
3 changed files with 40 additions and 7 deletions
  1. +1
    -0
      src/dao/happy_orchard_user_waters_dao.go
  2. +23
    -7
      src/implement/happy_orchard_user_seed_record_db.go
  3. +16
    -0
      src/implement/happy_orchard_user_waters_db.go

+ 1
- 0
src/dao/happy_orchard_user_waters_dao.go View File

@@ -7,4 +7,5 @@ import (
type HappyOrchardUserWatersDao interface {
GetHappyOrchardUserWaters(uid int) (m *models.HappyOrchardUserWaters, err error)
GetHappyOrchardUserWatersSess(uid int) (m *models.HappyOrchardUserWaters, err error)
UpdateHappyOrchardUserWaters(uid int, m *models.HappyOrchardUserWaters, forceColums ...string) (int64, error)
}

+ 23
- 7
src/implement/happy_orchard_user_seed_record_db.go View File

@@ -7,15 +7,31 @@ import (
"xorm.io/xorm"
)

type happyOrchardUserSeedRecordDb struct {
type HappyOrchardUserSeedRecordDb struct {
Db *xorm.Engine
}

func (h HappyOrchardUserSeedRecordDb) UpdateHappyOrchardUserSeedRecord(m *models.HappyOrchardUserSeedRecord, 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
}

func NewHappyOrchardUserSeedRecordDb(engine *xorm.Engine) dao.HappyOrchardUserSeedRecordDao {
return &happyOrchardUserSeedRecordDb{Db: engine}
return &HappyOrchardUserSeedRecordDb{Db: engine}
}

func (h happyOrchardUserSeedRecordDb) GetHappyOrchardUserSeedRecord(id int) (m *models.HappyOrchardUserSeedRecord, err error) {
func (h HappyOrchardUserSeedRecordDb) GetHappyOrchardUserSeedRecord(id int) (m *models.HappyOrchardUserSeedRecord, err error) {
//TODO implement me
m = new(models.HappyOrchardUserSeedRecord)
has, err := h.Db.Where("id =?", id).Get(m)
@@ -28,7 +44,7 @@ func (h happyOrchardUserSeedRecordDb) GetHappyOrchardUserSeedRecord(id int) (m *
return m, nil
}

func (h happyOrchardUserSeedRecordDb) FindHappyOrchardUserSeedRecordByUid(uid int) (mm *[]models.HappyOrchardUserSeedRecord, err error) {
func (h HappyOrchardUserSeedRecordDb) FindHappyOrchardUserSeedRecordByUid(uid int) (mm *[]models.HappyOrchardUserSeedRecord, err error) {
//TODO implement me
var m []models.HappyOrchardUserSeedRecord
if err := h.Db.Where("uid =?", uid).Desc("id").Find(&m); err != nil {
@@ -36,7 +52,7 @@ func (h happyOrchardUserSeedRecordDb) FindHappyOrchardUserSeedRecordByUid(uid in
}
return &m, nil
}
func (h happyOrchardUserSeedRecordDb) GetHappyOrchardUserSeedRecordByUidWithState(uid, state int) (m *models.HappyOrchardUserSeedRecord, err error) {
func (h HappyOrchardUserSeedRecordDb) GetHappyOrchardUserSeedRecordByUidWithState(uid, state int) (m *models.HappyOrchardUserSeedRecord, err error) {
m = new(models.HappyOrchardUserSeedRecord)
has, err := h.Db.Where("uid =? and state=?", uid, state).Get(m)
if err != nil {
@@ -47,7 +63,7 @@ func (h happyOrchardUserSeedRecordDb) GetHappyOrchardUserSeedRecordByUidWithStat
}
return m, nil
}
func (h happyOrchardUserSeedRecordDb) GetHappyOrchardUserSeedRecordByUidWithStateAndId(uid, id, state int) (m *models.HappyOrchardUserSeedRecord, err error) {
func (h HappyOrchardUserSeedRecordDb) GetHappyOrchardUserSeedRecordByUidWithStateAndId(uid, id, state int) (m *models.HappyOrchardUserSeedRecord, err error) {
m = new(models.HappyOrchardUserSeedRecord)
has, err := h.Db.Where("uid =? and state=? and id=?", uid, state, id).Get(m)
if err != nil {
@@ -58,7 +74,7 @@ func (h happyOrchardUserSeedRecordDb) GetHappyOrchardUserSeedRecordByUidWithStat
}
return m, nil
}
func (h happyOrchardUserSeedRecordDb) FindHappyOrchardUserSeedRecordAll(uid, start, limit int) (mm *[]models.HappyOrchardUserSeedRecord, err error) {
func (h HappyOrchardUserSeedRecordDb) FindHappyOrchardUserSeedRecordAll(uid, start, limit int) (mm *[]models.HappyOrchardUserSeedRecord, err error) {
var m []models.HappyOrchardUserSeedRecord
if err := h.Db.Where("uid=?", uid).OrderBy("id desc").Limit(limit, start).Find(&m); err != nil {
return nil, zhios_order_relate_logx.Error(err)


+ 16
- 0
src/implement/happy_orchard_user_waters_db.go View File

@@ -12,6 +12,22 @@ type HappyOrchardUserWatersDb struct {
Sess *xorm.Session
}

func (h HappyOrchardUserWatersDb) UpdateHappyOrchardUserWaters(uid int, m *models.HappyOrchardUserWaters, forceColums ...string) (int64, error) {
var (
affected int64
err error
)
if forceColums != nil {
affected, err = h.Db.Where("uid=?", uid).Cols(forceColums...).Update(m)
} else {
affected, err = h.Db.Where("uid=?", uid).Update(m)
}
if err != nil {
return 0, err
}
return affected, nil
}

func NewHappyOrchardUserWatersDb(engine *xorm.Engine) dao.HappyOrchardUserWatersDao {
return &HappyOrchardUserWatersDb{Db: engine}
}


Loading…
Cancel
Save