diff --git a/cv/cp_cv/cp.go b/cv/cp_cv/cp.go index 0a0c5d6059dd38d72bfd515e7e44dc5a61970e6b..8e5939f18cdaa5370d05f2386c68d1b02deda998 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 9cf44477623aae25e9a6fa65823538c5195c1a10..95e88050a463d2b9ca183492a39948c7e1d2476e 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