From 2deb4b1095b4604480decdda1c7be2b5c5a61c45 Mon Sep 17 00:00:00 2001 From: shenjiachi Date: Fri, 13 Dec 2024 21:34:41 +0800 Subject: [PATCH 1/3] del table egg_energy_team_assistance --- src/dao/egg_energy_team_assistance_dao.go | 13 ---- .../egg_energy_team_assistance_implement.go | 66 ------------------- src/model/egg_energy_team_assistance.go | 11 ---- 3 files changed, 90 deletions(-) delete mode 100644 src/dao/egg_energy_team_assistance_dao.go delete mode 100644 src/implement/egg_energy_team_assistance_implement.go delete mode 100644 src/model/egg_energy_team_assistance.go diff --git a/src/dao/egg_energy_team_assistance_dao.go b/src/dao/egg_energy_team_assistance_dao.go deleted file mode 100644 index d48cc0f..0000000 --- a/src/dao/egg_energy_team_assistance_dao.go +++ /dev/null @@ -1,13 +0,0 @@ -package dao - -import ( - "code.fnuoos.com/EggPlanet/egg_models.git/src/model" - "xorm.io/xorm" -) - -type EggEnergyTeamAssistanceDao interface { - EggEnergyTeamAssistanceInsertBySession(session *xorm.Session, EggEnergyTeamAssistance *model.EggEnergyTeamAssistance) (int64, error) - EggEnergyTeamAssistanceUpdateBySession(session *xorm.Session, id interface{}, EggEnergyTeamAssistance *model.EggEnergyTeamAssistance, forceColums ...string) (int64, error) - EggEnergyTeamAssistanceGetOneByParamsBySession(session *xorm.Session, params map[string]interface{}) (*model.EggEnergyTeamAssistance, error) - EggEnergyTeamAssistanceGetOneBySession(session *xorm.Session, uid int64, date string) (*model.EggEnergyTeamAssistance, error) -} diff --git a/src/implement/egg_energy_team_assistance_implement.go b/src/implement/egg_energy_team_assistance_implement.go deleted file mode 100644 index 9fc4966..0000000 --- a/src/implement/egg_energy_team_assistance_implement.go +++ /dev/null @@ -1,66 +0,0 @@ -package implement - -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" -) - -func NewEggEnergyTeamAssistanceDb(engine *xorm.Engine) dao.EggEnergyTeamAssistanceDao { - return &EggEnergyTeamAssistanceDb{Db: engine} -} - -type EggEnergyTeamAssistanceDb struct { - Db *xorm.Engine -} - -func (e EggEnergyTeamAssistanceDb) EggEnergyTeamAssistanceInsertBySession(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) EggEnergyTeamAssistanceUpdateBySession(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) EggEnergyTeamAssistanceGetOneByParamsBySession(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 -} - -func (e EggEnergyTeamAssistanceDb) EggEnergyTeamAssistanceGetOneBySession(session *xorm.Session, uid int64, date string) (*model.EggEnergyTeamAssistance, error) { - var m model.EggEnergyTeamAssistance - has, err := session.Where("uid = ?", uid).And("date = ?", date).Get(&m) - if err != nil { - return nil, 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 deleted file mode 100644 index 40dd83c..0000000 --- a/src/model/egg_energy_team_assistance.go +++ /dev/null @@ -1,11 +0,0 @@ -package model - -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 string `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` - UpdateAt string `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` -} From 361b8b6b12a1ed011c8fda6b217145db3ab57c3b Mon Sep 17 00:00:00 2001 From: shenjiachi Date: Fri, 13 Dec 2024 22:34:25 +0800 Subject: [PATCH 2/3] update --- src/dao/egg_energy_team_assistance_dao.go | 13 ++++ .../egg_energy_team_assistance_implement.go | 66 +++++++++++++++++++ src/model/egg_energy_team_assistance.go | 11 ++++ 3 files changed, 90 insertions(+) create mode 100644 src/dao/egg_energy_team_assistance_dao.go create mode 100644 src/implement/egg_energy_team_assistance_implement.go create mode 100644 src/model/egg_energy_team_assistance.go diff --git a/src/dao/egg_energy_team_assistance_dao.go b/src/dao/egg_energy_team_assistance_dao.go new file mode 100644 index 0000000..d48cc0f --- /dev/null +++ b/src/dao/egg_energy_team_assistance_dao.go @@ -0,0 +1,13 @@ +package dao + +import ( + "code.fnuoos.com/EggPlanet/egg_models.git/src/model" + "xorm.io/xorm" +) + +type EggEnergyTeamAssistanceDao interface { + EggEnergyTeamAssistanceInsertBySession(session *xorm.Session, EggEnergyTeamAssistance *model.EggEnergyTeamAssistance) (int64, error) + EggEnergyTeamAssistanceUpdateBySession(session *xorm.Session, id interface{}, EggEnergyTeamAssistance *model.EggEnergyTeamAssistance, forceColums ...string) (int64, error) + EggEnergyTeamAssistanceGetOneByParamsBySession(session *xorm.Session, params map[string]interface{}) (*model.EggEnergyTeamAssistance, error) + EggEnergyTeamAssistanceGetOneBySession(session *xorm.Session, uid int64, date string) (*model.EggEnergyTeamAssistance, error) +} diff --git a/src/implement/egg_energy_team_assistance_implement.go b/src/implement/egg_energy_team_assistance_implement.go new file mode 100644 index 0000000..9fc4966 --- /dev/null +++ b/src/implement/egg_energy_team_assistance_implement.go @@ -0,0 +1,66 @@ +package implement + +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" +) + +func NewEggEnergyTeamAssistanceDb(engine *xorm.Engine) dao.EggEnergyTeamAssistanceDao { + return &EggEnergyTeamAssistanceDb{Db: engine} +} + +type EggEnergyTeamAssistanceDb struct { + Db *xorm.Engine +} + +func (e EggEnergyTeamAssistanceDb) EggEnergyTeamAssistanceInsertBySession(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) EggEnergyTeamAssistanceUpdateBySession(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) EggEnergyTeamAssistanceGetOneByParamsBySession(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 +} + +func (e EggEnergyTeamAssistanceDb) EggEnergyTeamAssistanceGetOneBySession(session *xorm.Session, uid int64, date string) (*model.EggEnergyTeamAssistance, error) { + var m model.EggEnergyTeamAssistance + has, err := session.Where("uid = ?", uid).And("date = ?", date).Get(&m) + if err != nil { + return nil, 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 new file mode 100644 index 0000000..40dd83c --- /dev/null +++ b/src/model/egg_energy_team_assistance.go @@ -0,0 +1,11 @@ +package model + +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 string `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` + UpdateAt string `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` +} From 1db189660e43415d0981ba698e57adb31e79c60f Mon Sep 17 00:00:00 2001 From: shenjiachi Date: Fri, 13 Dec 2024 22:55:11 +0800 Subject: [PATCH 3/3] update --- src/implement/egg_sign_in_implement.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/implement/egg_sign_in_implement.go b/src/implement/egg_sign_in_implement.go index 645a55a..83bcfd9 100644 --- a/src/implement/egg_sign_in_implement.go +++ b/src/implement/egg_sign_in_implement.go @@ -97,7 +97,7 @@ func (e EggSignInDb) EggSignINGetOneByTimeAndUid(startAt, endAt string, uid int6 func (e EggSignInDb) EggSignInFindByTimeAndParams(startAt, endAt string, isCompleted int, params map[string]interface{}) ([]*model.EggSignIn, error) { var m []*model.EggSignIn - session := e.Db.Where("is_completed > ?", isCompleted) + session := e.Db.Where("is_completed = ?", isCompleted) if startAt != "" { session = session.And("start_time > ?", startAt) } @@ -112,7 +112,7 @@ func (e EggSignInDb) EggSignInFindByTimeAndParams(startAt, endAt string, isCompl session = session.Where(query, params["value"]) } - err := session.Find(m) + err := session.Find(&m) if err != nil { return nil, zhios_order_relate_logx.Error(err) }