From acad438a89d857e775332fe795c7c721c9cb5c0c Mon Sep 17 00:00:00 2001 From: hujiebin Date: Fri, 9 Jun 2023 15:03:58 +0800 Subject: [PATCH] feat:userBase --- cv/cp_cv/cp.go | 13 ++++++++++--- route/user_r/inner.go | 21 ++++++++------------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/cv/cp_cv/cp.go b/cv/cp_cv/cp.go index 0a0c5d6..8e5939f 100644 --- a/cv/cp_cv/cp.go +++ b/cv/cp_cv/cp.go @@ -1,8 +1,15 @@ package cp_cv +import "hilo-user/cv/user_cv" + // cp信息 type CvCp struct { - CpInfo CvCpInfo `json:"cpInfo"` // cp信息 - CpLevel CvCpLevel `json:"cpLevel"` // cp等级 - PrivilegeList []CvPrivilege `json:"privilegeList"` // 等级特权 + CpInfo CvCpInfoAll `json:"cpInfo"` // cp信息 + CpLevel CvCpLevel `json:"cpLevel"` // cp等级 + MyPrivilegeList []CvPrivilege `json:"myPrivilegeList"` // 等级特权 +} + +type CvCpInfoAll struct { + UserInfo *user_cv.CvUserBase `json:"userInfo"` // 用户信息 + CpUserInfo *user_cv.CvUserBase `json:"cpUserInfo"` // cp用户信息 } diff --git a/route/user_r/inner.go b/route/user_r/inner.go index 9cf4447..95e8805 100644 --- a/route/user_r/inner.go +++ b/route/user_r/inner.go @@ -111,17 +111,12 @@ func GetUserCp(c *gin.Context) (*mycontext.MyContext, error) { return myContext, err } userId := req.Id - userInfo, err := user_m.GetUser(model, userId) - if err != nil { - return myContext, err - } var response cp_cv.CvCp cpLevel := cp_e.CpLevel0 cpRelation, exists := cp_m.GetCpRelation(model, userId) if !exists { resp.ResponseOk(c, response) } - var cpUserInfo *user_m.User var myPrivilegeList []cp_cv.CvPrivilege level := cp_m.GetCpLevel(model, cpRelation.ID) if level.ExpireAt.Before(time.Now()) { @@ -132,10 +127,6 @@ func GetUserCp(c *gin.Context) (*mycontext.MyContext, error) { if cpUserId == userId { cpUserId = cpRelation.UserId1 } - cpUserInfo, err = user_m.GetUser(model, cpUserId) - if err != nil { - return myContext, err - } userPrivileges, err := cp_m.MGetUserSvipPrivilege(model, []uint64{userId}) if err != nil { return myContext, err @@ -154,16 +145,20 @@ func GetUserCp(c *gin.Context) (*mycontext.MyContext, error) { myPrivilegeList = append(myPrivilegeList, privilegeList[i]) } } + userBases, err := user_cv.GetUserBaseMap([]uint64{cpUserId}, userId) + if err != nil { + return myContext, err + } // 返回值 response = cp_cv.CvCp{ - CpInfo: cp_cv.CvCpInfo{ - UserInfo: user_cv.UserToTiny(*userInfo), - CpUserInfo: user_cv.UserToTiny(*cpUserInfo), + CpInfo: cp_cv.CvCpInfoAll{ + //UserInfo: userBases[userId], + CpUserInfo: userBases[cpUserId], }, CpLevel: cp_cv.CvCpLevel{ Level: cpLevel, }, - PrivilegeList: myPrivilegeList, + MyPrivilegeList: myPrivilegeList, } resp.ResponseOk(c, response) return myContext, nil -- 2.22.0