From ce20b73a79083685065f9dc396a4d015911a3737 Mon Sep 17 00:00:00 2001 From: dengbiao Date: Mon, 11 Nov 2024 10:33:44 +0800 Subject: [PATCH] update --- src/dao/public_platoon_user_relation_dao.go | 2 +- src/dao/user_dao.go | 4 +--- .../public_platoon_user_relation_implement.go | 8 +++---- src/implement/user_implement.go | 23 +++++-------------- src/model/admin.go | 17 +++++++------- src/model/egg_energy_basic_setting.go | 1 + src/model/public_platoon_user_relation.go | 2 +- 7 files changed, 22 insertions(+), 35 deletions(-) diff --git a/src/dao/public_platoon_user_relation_dao.go b/src/dao/public_platoon_user_relation_dao.go index 745e81e..1fec97b 100644 --- a/src/dao/public_platoon_user_relation_dao.go +++ b/src/dao/public_platoon_user_relation_dao.go @@ -6,7 +6,7 @@ import ( ) type PublicPlatoonUserRelationDao interface { - PublicPlatoonUserRelationInsert(PublicPlatoonUserRelation *model.PublicPlatoonUserRelation) (int, error) + PublicPlatoonUserRelationInsert(PublicPlatoonUserRelation *model.PublicPlatoonUserRelation) (int64, error) PublicPlatoonUserRelationUpdate(session *xorm.Session, id interface{}, PublicPlatoonUserRelation *model.PublicPlatoonUserRelation, forceColums ...string) (int64, error) PublicPlatoonUserRelationGetOneByParams(params map[string]interface{}) (*model.PublicPlatoonUserRelation, error) PublicPlatoonUserRelationGetOneByPid(recommendUid string, params map[string]interface{}) (*model.PublicPlatoonUserRelation, error) diff --git a/src/dao/user_dao.go b/src/dao/user_dao.go index 848b2a5..328b3d9 100644 --- a/src/dao/user_dao.go +++ b/src/dao/user_dao.go @@ -3,7 +3,5 @@ import "code.fnuoos.com/EggPlanet/egg_models.git/src/model" type UserDao interface { - //TODO:: You can add specific method definitions here - UserGetOneByPhone(phone int) (*model.User, error) - UserGetOneById(id int64) (*model.User, error) + UserGetOneByParams(params map[string]interface{}) (*model.User, error) } diff --git a/src/implement/public_platoon_user_relation_implement.go b/src/implement/public_platoon_user_relation_implement.go index 5c1a9fe..c8d52e8 100644 --- a/src/implement/public_platoon_user_relation_implement.go +++ b/src/implement/public_platoon_user_relation_implement.go @@ -19,7 +19,7 @@ type PublicPlatoonUserRelationDb struct { Db *xorm.Engine } -func (p PublicPlatoonUserRelationDb) PublicPlatoonUserRelationInsert(PublicPlatoonUserRelation *model.PublicPlatoonUserRelation) (int, error) { +func (p PublicPlatoonUserRelationDb) PublicPlatoonUserRelationInsert(PublicPlatoonUserRelation *model.PublicPlatoonUserRelation) (int64, error) { _, err := p.Db.InsertOne(PublicPlatoonUserRelation) if err != nil { return 0, err @@ -131,7 +131,7 @@ func (p PublicPlatoonUserRelationDb) PublicPlatoonUserRelationFind(uid int64) ([ return nil, zhios_order_relate_logx.Error("未查询到数据") } } else { - has, err2 := p.Db.Where("level1 = ?", 1).Get(&head) + has, err2 := p.Db.Where("level_total = ?", 1).Get(&head) if err2 != nil { return nil, err2 } @@ -193,12 +193,12 @@ func (p PublicPlatoonUserRelationDb) GetTreeBySmall(head *model.PublicPlatoonUse for len(queue) > 0 { node := queue[0] queue = queue[1:] - if node.Level1 > head.Level1+leveLimit { + if node.LevelTotal > head.LevelTotal+leveLimit { break } res = append(res, node) var son []*model.PublicPlatoonUserRelation - err1 := p.Db.Where("father_uid1 = ?", node.Uid).Find(son) + err1 := p.Db.Where("father_uid1 = ?", node.Uid).Find(&son) if err1 != nil { return nil, zhios_order_relate_logx.Error(err1) } diff --git a/src/implement/user_implement.go b/src/implement/user_implement.go index b144ab8..472d4b7 100644 --- a/src/implement/user_implement.go +++ b/src/implement/user_implement.go @@ -4,6 +4,7 @@ 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" ) @@ -15,23 +16,11 @@ type UserDb struct { Db *xorm.Engine } -func (p UserDb) UserGetOneByPhone(phone int) (*model.User, error) { - var user model.User - has, err := p.Db.Where("phone = ?", phone).Get(&user) - if err != nil { +func (u UserDb) UserGetOneByParams(params map[string]interface{}) (*model.User, error) { + var m model.User + var query = fmt.Sprintf("%s =?", params["key"]) + if has, err := u.Db.Where(query, params["value"]).Get(&m); err != nil || has == false { return nil, zhios_order_relate_logx.Error(err) } - if has == false { - return nil, zhios_order_relate_logx.Error("未查询到相关用户记录") - } - return &user, nil -} - -func (p UserDb) UserGetOneById(id int64) (*model.User, error) { - var user model.User - _, err := p.Db.Where("id = ?", id).Get(&user) - if err != nil { - return nil, zhios_order_relate_logx.Error(err) - } - return &user, nil + return &m, nil } diff --git a/src/model/admin.go b/src/model/admin.go index 5823f8e..125ae65 100644 --- a/src/model/admin.go +++ b/src/model/admin.go @@ -1,13 +1,12 @@ package model type Admin struct { - AdmId int `json:"adm_id" xorm:"not null comment('管理员id') INT(11)"` - Username string `json:"username" xorm:"not null default '' comment('用户名') VARCHAR(255)"` - Password string `json:"password" xorm:"not null default '' comment('密码') VARCHAR(255)"` - State int `json:"state" xorm:"not null default 1 comment('状态(1:正常 2:冻结)') TINYINT(1)"` - IsSuperAdministrator int `json:"is_super_administrator" xorm:"not null default 0 comment('是否为超级管理员(0:否 1:是)') TINYINT(1)"` - IsObserverAdministrator int `json:"is_observer_administrator" xorm:"not null default 0 comment('是否为观察者管理员(0:否 1:是)') TINYINT(1)"` - Memo string `json:"memo" xorm:"not null default '' comment('备注信息') VARCHAR(244)"` - CreateAt string `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` - UpdateAt string `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` + AdmId int `json:"adm_id" xorm:"not null comment('管理员id') INT(11)"` + Username string `json:"username" xorm:"not null default '' comment('用户名') VARCHAR(255)"` + Password string `json:"password" xorm:"not null default '' comment('密码') VARCHAR(255)"` + State int `json:"state" xorm:"not null default 1 comment('状态(1:正常 2:冻结)') TINYINT(1)"` + IsSuperAdministrator int `json:"is_super_administrator" xorm:"not null default 0 comment('是否为超级管理员(0:否 1:是)') TINYINT(1)"` + Memo string `json:"memo" xorm:"not null default '' comment('备注信息') VARCHAR(244)"` + CreateAt string `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` + UpdateAt string `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` } diff --git a/src/model/egg_energy_basic_setting.go b/src/model/egg_energy_basic_setting.go index 198bd6c..2301bec 100644 --- a/src/model/egg_energy_basic_setting.go +++ b/src/model/egg_energy_basic_setting.go @@ -24,6 +24,7 @@ type EggEnergyBasicSetting struct { DevelopmentCommittee string `json:"development_committee" xorm:"not null comment('发展委员会') DECIMAL(28,8)"` PublicWelfareAndCharity string `json:"public_welfare_and_charity" xorm:"not null comment('公益慈善') DECIMAL(28,8)"` StarLevelDividends string `json:"star_level_dividends" xorm:"not null comment('星级分红') DECIMAL(28,8)"` + CommunityDividends string `json:"community_dividends" xorm:"not null comment('社区分红') DECIMAL(28,8)"` DestructionQuantityNums string `json:"destruction_quantity_nums" xorm:"not null comment('销毁数量') DECIMAL(28,8)"` DestructionSetting string `json:"destruction_setting" xorm:"not null comment('销毁设置') TEXT"` IsLimitDividend int `json:"is_limit_dividend" xorm:"not null default 1 comment('是否限制分红(会员本人不活跃,没有星级能量分红)') TINYINT(1)"` diff --git a/src/model/public_platoon_user_relation.go b/src/model/public_platoon_user_relation.go index 8b1ca97..5cb5b0d 100644 --- a/src/model/public_platoon_user_relation.go +++ b/src/model/public_platoon_user_relation.go @@ -1,7 +1,7 @@ package model type PublicPlatoonUserRelation struct { - Id int `json:"id" xorm:"not null pk autoincr INT(11)"` + Id int64 `json:"id" xorm:"not null pk autoincr INT(11)"` Uid int64 `json:"uid" xorm:"not null default 0 comment('用户id(若为-1,则代表等待新用户填充)') index INT(11)"` RecommendUid int64 `json:"recommend_uid" xorm:"not null default 0 comment('推荐人id') INT(11)"` FatherUid string `json:"father_uid" xorm:"not null default '' comment('父级uid(123456-563464-438384)') index VARCHAR(100)"`