Commit acad438a authored by hujiebin's avatar hujiebin

feat:userBase

parent 2d25adc7
package cp_cv package cp_cv
import "hilo-user/cv/user_cv"
// cp信息 // cp信息
type CvCp struct { type CvCp struct {
CpInfo CvCpInfo `json:"cpInfo"` // cp信息 CpInfo CvCpInfoAll `json:"cpInfo"` // cp信息
CpLevel CvCpLevel `json:"cpLevel"` // cp等级 CpLevel CvCpLevel `json:"cpLevel"` // cp等级
PrivilegeList []CvPrivilege `json:"privilegeList"` // 等级特权 MyPrivilegeList []CvPrivilege `json:"myPrivilegeList"` // 等级特权
}
type CvCpInfoAll struct {
UserInfo *user_cv.CvUserBase `json:"userInfo"` // 用户信息
CpUserInfo *user_cv.CvUserBase `json:"cpUserInfo"` // cp用户信息
} }
...@@ -111,17 +111,12 @@ func GetUserCp(c *gin.Context) (*mycontext.MyContext, error) { ...@@ -111,17 +111,12 @@ func GetUserCp(c *gin.Context) (*mycontext.MyContext, error) {
return myContext, err return myContext, err
} }
userId := req.Id userId := req.Id
userInfo, err := user_m.GetUser(model, userId)
if err != nil {
return myContext, err
}
var response cp_cv.CvCp var response cp_cv.CvCp
cpLevel := cp_e.CpLevel0 cpLevel := cp_e.CpLevel0
cpRelation, exists := cp_m.GetCpRelation(model, userId) cpRelation, exists := cp_m.GetCpRelation(model, userId)
if !exists { if !exists {
resp.ResponseOk(c, response) resp.ResponseOk(c, response)
} }
var cpUserInfo *user_m.User
var myPrivilegeList []cp_cv.CvPrivilege var myPrivilegeList []cp_cv.CvPrivilege
level := cp_m.GetCpLevel(model, cpRelation.ID) level := cp_m.GetCpLevel(model, cpRelation.ID)
if level.ExpireAt.Before(time.Now()) { if level.ExpireAt.Before(time.Now()) {
...@@ -132,10 +127,6 @@ func GetUserCp(c *gin.Context) (*mycontext.MyContext, error) { ...@@ -132,10 +127,6 @@ func GetUserCp(c *gin.Context) (*mycontext.MyContext, error) {
if cpUserId == userId { if cpUserId == userId {
cpUserId = cpRelation.UserId1 cpUserId = cpRelation.UserId1
} }
cpUserInfo, err = user_m.GetUser(model, cpUserId)
if err != nil {
return myContext, err
}
userPrivileges, err := cp_m.MGetUserSvipPrivilege(model, []uint64{userId}) userPrivileges, err := cp_m.MGetUserSvipPrivilege(model, []uint64{userId})
if err != nil { if err != nil {
return myContext, err return myContext, err
...@@ -154,16 +145,20 @@ func GetUserCp(c *gin.Context) (*mycontext.MyContext, error) { ...@@ -154,16 +145,20 @@ func GetUserCp(c *gin.Context) (*mycontext.MyContext, error) {
myPrivilegeList = append(myPrivilegeList, privilegeList[i]) myPrivilegeList = append(myPrivilegeList, privilegeList[i])
} }
} }
userBases, err := user_cv.GetUserBaseMap([]uint64{cpUserId}, userId)
if err != nil {
return myContext, err
}
// 返回值 // 返回值
response = cp_cv.CvCp{ response = cp_cv.CvCp{
CpInfo: cp_cv.CvCpInfo{ CpInfo: cp_cv.CvCpInfoAll{
UserInfo: user_cv.UserToTiny(*userInfo), //UserInfo: userBases[userId],
CpUserInfo: user_cv.UserToTiny(*cpUserInfo), CpUserInfo: userBases[cpUserId],
}, },
CpLevel: cp_cv.CvCpLevel{ CpLevel: cp_cv.CvCpLevel{
Level: cpLevel, Level: cpLevel,
}, },
PrivilegeList: myPrivilegeList, MyPrivilegeList: myPrivilegeList,
} }
resp.ResponseOk(c, response) resp.ResponseOk(c, response)
return myContext, nil return myContext, nil
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment