diff --git a/cv/cp_cv/cp.go b/cv/cp_cv/cp.go index 4525dd34ec16b217c40fc2b06f59d98eefb2e7fe..0fcb0eb8cfb39ddd7060d1b79d1e91222e728c51 100644 --- a/cv/cp_cv/cp.go +++ b/cv/cp_cv/cp.go @@ -11,7 +11,8 @@ type CvCp struct { // cp关系 type CvCpRelation struct { - CpId uint64 `json:"cpId"` - UserId uint64 `json:"userId"` - CpUserId uint64 `json:"cpUserId"` + CpId uint64 `json:"cpId"` + UserId uint64 `json:"userId"` + CpUserId uint64 `json:"cpUserId"` + CpUserAvatar string `json:"cpUserAvatar,omitempty"` } diff --git a/route/user_r/inner.go b/route/user_r/inner.go index 7bee448aef23a1e04be71b117bbfe3b706f59780..c379bcce18b5b542d4b06c61b7afbb4b8977d285 100644 --- a/route/user_r/inner.go +++ b/route/user_r/inner.go @@ -193,10 +193,12 @@ func GetUserCpRelation(c *gin.Context) (*mycontext.MyContext, error) { if cpUserId == userId { cpUserId = cpRelation.UserId1 } + cpUser, _ := user_m.GetUser(model, cpUserId) response = cp_cv.CvCpRelation{ - CpId: cpRelation.ID, - UserId: userId, - CpUserId: cpUserId, + CpId: cpRelation.ID, + UserId: userId, + CpUserId: cpUserId, + CpUserAvatar: cpUser.Avatar, } resp.ResponseOk(c, response) return myContext, nil @@ -220,9 +222,16 @@ func MGetUserCpRelation(c *gin.Context) (*mycontext.MyContext, error) { } cpRelations := cp_m.MGetCpRelation(model, req.Ids) var m = make(map[uint64]cp_m.CpRelationTmp) + var userIds []uint64 for i, v := range cpRelations { m[v.UserId1] = cpRelations[i] m[v.UserId2] = cpRelations[i] + userIds = append(userIds, v.UserId1) + userIds = append(userIds, v.UserId2) + } + users, err := user_m.GetUserMapByIds(model, userIds) + if err != nil { + return myContext, err } var response = make(map[uint64]cp_cv.CvCpRelation) for _, uid := range req.Ids { @@ -232,9 +241,10 @@ func MGetUserCpRelation(c *gin.Context) (*mycontext.MyContext, error) { cpUserId = cpRelation.UserId1 } response[uid] = cp_cv.CvCpRelation{ - CpId: cpRelation.ID, - UserId: uid, - CpUserId: cpUserId, + CpId: cpRelation.ID, + UserId: uid, + CpUserId: cpUserId, + CpUserAvatar: users[cpUserId].Avatar, } } }