diff --git a/src/dao/egg_energy_team_assistance_dao.go b/src/dao/egg_energy_team_assistance_dao.go index dacbd8a..750f04f 100644 --- a/src/dao/egg_energy_team_assistance_dao.go +++ b/src/dao/egg_energy_team_assistance_dao.go @@ -1,5 +1,12 @@ package dao +import ( + "code.fnuoos.com/EggPlanet/egg_models.git/src/model" + "xorm.io/xorm" +) + type EggEnergyTeamAssistanceDao interface { - //TODO:: You can add specific method definitions here + EggStarLevelDividendsRecordsInsertBySession(session *xorm.Session, EggEnergyTeamAssistance *model.EggEnergyTeamAssistance) (int64, error) + EggStarLevelDividendsRecordsUpdateBySession(session *xorm.Session, id interface{}, EggEnergyTeamAssistance *model.EggEnergyTeamAssistance, forceColums ...string) (int64, error) + EggStarLevelDividendsRecordsGetOneByParamsBySession(session *xorm.Session, params map[string]interface{}) (*model.EggEnergyTeamAssistance, error) } diff --git a/src/implement/egg_energy_team_assistance_implement.go b/src/implement/egg_energy_team_assistance_implement.go index 98ed395..45e3c96 100644 --- a/src/implement/egg_energy_team_assistance_implement.go +++ b/src/implement/egg_energy_team_assistance_implement.go @@ -2,6 +2,9 @@ import ( "code.fnuoos.com/EggPlanet/egg_models.git/src/dao" + "code.fnuoos.com/EggPlanet/egg_models.git/src/model" + zhios_order_relate_logx "code.fnuoos.com/EggPlanet/egg_models.git/utils/logx" + "fmt" "xorm.io/xorm" ) @@ -12,3 +15,40 @@ func NewEggEnergyTeamAssistanceDb(engine *xorm.Engine) dao.EggEnergyTeamAssistan type EggEnergyTeamAssistanceDb struct { Db *xorm.Engine } + +func (e EggEnergyTeamAssistanceDb) EggStarLevelDividendsRecordsInsertBySession(session *xorm.Session, EggEnergyTeamAssistance *model.EggEnergyTeamAssistance) (int64, error) { + _, err := session.InsertOne(EggEnergyTeamAssistance) + if err != nil { + return 0, err + } + return EggEnergyTeamAssistance.Id, nil +} + +func (e EggEnergyTeamAssistanceDb) EggStarLevelDividendsRecordsUpdateBySession(session *xorm.Session, id interface{}, EggEnergyTeamAssistance *model.EggEnergyTeamAssistance, forceColums ...string) (int64, error) { + var ( + affected int64 + err error + ) + if forceColums != nil { + affected, err = session.Where("id=?", id).Cols(forceColums...).Update(EggEnergyTeamAssistance) + } else { + affected, err = session.Where("id=?", id).Update(EggEnergyTeamAssistance) + } + if err != nil { + return 0, err + } + return affected, nil +} + +func (e EggEnergyTeamAssistanceDb) EggStarLevelDividendsRecordsGetOneByParamsBySession(session *xorm.Session, params map[string]interface{}) (*model.EggEnergyTeamAssistance, error) { + var m model.EggEnergyTeamAssistance + var query = fmt.Sprintf("%s =?", params["key"]) + has, err := session.Where(query, params["value"]).Get(&m) + if err != nil { + return nil, zhios_order_relate_logx.Error(err) + } + if has == false { + return nil, nil + } + return &m, nil +} diff --git a/src/model/egg_energy_team_assistance.go b/src/model/egg_energy_team_assistance.go index 2df255b..40dd83c 100644 --- a/src/model/egg_energy_team_assistance.go +++ b/src/model/egg_energy_team_assistance.go @@ -1,15 +1,11 @@ package model -import ( - "time" -) - type EggEnergyTeamAssistance struct { - Id int64 `json:"id" xorm:"pk autoincr BIGINT(20)"` - Uid int64 `json:"uid" xorm:"not null default 0 comment('用户 ID') BIGINT(20)"` - AssistedNum int `json:"assisted_num" xorm:"not null default 0 comment('助力人数') INT(11)"` - RewardScore string `json:"reward_score" xorm:"not null default 0.00000000 comment('奖励积分数量') DECIMAL(20,8)"` - Date string `json:"date" xorm:"not null default '0000-00-00' comment('日期') CHAR(50)"` - CreateAt time.Time `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` - UpdateAt time.Time `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` + Id int64 `json:"id" xorm:"pk autoincr BIGINT(20)"` + Uid int64 `json:"uid" xorm:"not null default 0 comment('用户 ID') BIGINT(20)"` + AssistedNum int `json:"assisted_num" xorm:"not null default 0 comment('助力人数') INT(11)"` + RewardScore string `json:"reward_score" xorm:"not null default 0.00000000 comment('奖励积分数量') DECIMAL(20,8)"` + Date string `json:"date" xorm:"not null default '0000-00-00' comment('日期') CHAR(50)"` + CreateAt string `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` + UpdateAt string `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` }