diff --git a/cv/cp_cv/cp.go b/cv/cp_cv/cp.go index 7978fd31894360dcbf045ff99a0567d7a26660ba..c0a2a309fbb81cb50a2ef33fc9d882767a501f05 100644 --- a/cv/cp_cv/cp.go +++ b/cv/cp_cv/cp.go @@ -13,7 +13,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 1b1a5e479341c47e28c8b7983b7dfcf64611e2d4..e3062b5c24f8bfac156928fbe32f9825a4a8e2cf 100644 --- a/route/user_r/inner.go +++ b/route/user_r/inner.go @@ -195,10 +195,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 @@ -222,9 +224,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 { @@ -234,9 +243,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, } } }