Commit 729c0d4f authored by hujiebin's avatar hujiebin

Merge branch 'feature/cp-new' into feature/3.9.0

parents 9f9b92a7 c1a7417e
......@@ -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"`
}
......@@ -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,
}
}
}
......
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