Browse Source

update relationshipMap

tags/v0.0.2
shenjiachi 1 month ago
parent
commit
8f1366fceb
4 changed files with 7 additions and 63 deletions
  1. +0
    -2
      src/dao/public_platoon_user_relation_dao.go
  2. +1
    -2
      src/dao/user_dao.go
  3. +0
    -42
      src/implement/public_platoon_user_relation_implement.go
  4. +6
    -17
      src/implement/user_implement.go

+ 0
- 2
src/dao/public_platoon_user_relation_dao.go View File

@@ -13,8 +13,6 @@ type PublicPlatoonUserRelationDao interface {
PublicPlatoonUserRelationFindByPid(fatherUid int64, fatherName, positionName string) ([]model.PublicPlatoonUserRelation, error)
PublicPlatoonUserRelationFindCountByPosition(fatherUid int64, fatherName, positionName string, startPosition, endPosition int64) ([]model.PublicPlatoonUserRelation, int64, error)
PublicPlatoonUserRelationFindByParamsByPage(params map[string]interface{}, page, pageSize int) (*[]model.PublicPlatoonUserRelation, error)
PublicPlatoonUserRelationFind(uid int64) ([]*model.PublicPlatoonUserRelation, error)
PublicPlatoonUserRelationFindByUid(uid int64) ([]*model.PublicPlatoonUserRelation, error)
PublicPlatoonUserRelationGetOneByUid(uid int64) (*model.PublicPlatoonUserRelation, error)
PublicPlatoonUserRelationGetOneByPosition(position int64) (*model.PublicPlatoonUserRelation, error)
}

+ 1
- 2
src/dao/user_dao.go View File

@@ -4,6 +4,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)
}

+ 0
- 42
src/implement/public_platoon_user_relation_implement.go View File

@@ -120,48 +120,6 @@ func (p PublicPlatoonUserRelationDb) PublicPlatoonUserRelationFindByParamsByPage
}
}

func (p PublicPlatoonUserRelationDb) PublicPlatoonUserRelationFind(uid int64) ([]*model.PublicPlatoonUserRelation, error) {
var head model.PublicPlatoonUserRelation
if uid != 0 {
has, err1 := p.Db.Where("uid = ?", uid).Get(&head)
if err1 != nil {
return nil, zhios_order_relate_logx.Error(err1)
}
if has == false {
return nil, zhios_order_relate_logx.Error("未查询到数据")
}
} else {
has, err2 := p.Db.Where("level1 = ?", 1).Get(&head)
if err2 != nil {
return nil, err2
}
if has == false {
return nil, zhios_order_relate_logx.Error("未查询到数据")
}
}
relations, err3 := p.GetTreeBySmall(&head, 3)
if err3 != nil {
return nil, err3
}
return relations, nil
}

func (p PublicPlatoonUserRelationDb) PublicPlatoonUserRelationFindByUid(uid int64) ([]*model.PublicPlatoonUserRelation, error) {
var head model.PublicPlatoonUserRelation
has, err1 := p.Db.Where("uid = ?", uid).Get(&head)
if err1 != nil {
return nil, zhios_order_relate_logx.Error(err1)
}
if has == false {
return nil, zhios_order_relate_logx.Error("未查询到数据")
}
relations, err3 := p.GetTreeBySmall(&head, 0)
if err3 != nil {
return nil, err3
}
return relations, nil
}

func (p PublicPlatoonUserRelationDb) PublicPlatoonUserRelationGetOneByUid(uid int64) (*model.PublicPlatoonUserRelation, error) {
var parent model.PublicPlatoonUserRelation
has, err := p.Db.Where("uid = ?", uid).Get(&parent)


+ 6
- 17
src/implement/user_implement.go View File

@@ -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
}

Loading…
Cancel
Save