|
|
@@ -2,6 +2,7 @@ package repo |
|
|
|
|
|
|
|
import ( |
|
|
|
"gim/internal/logic/domain/group/model" |
|
|
|
"strconv" |
|
|
|
) |
|
|
|
|
|
|
|
type groupRepo struct{} |
|
|
@@ -37,16 +38,15 @@ func (*groupRepo) Get(groupId int64) (*model.Group, error) { |
|
|
|
|
|
|
|
// GetLimit 获取群组信息(限量) |
|
|
|
func (*groupRepo) GetLimit(groupId, limit int64) (*model.Group, error) { |
|
|
|
//group, err := GroupCache.GetLimit(strconv.FormatInt(limit, 10), groupId) |
|
|
|
//if err != nil { |
|
|
|
// return nil, err |
|
|
|
//} |
|
|
|
//if group != nil { |
|
|
|
// return group, nil |
|
|
|
//} |
|
|
|
var group *model.Group |
|
|
|
group, err := GroupCache.GetLimit(strconv.FormatInt(limit, 10), groupId) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
if group != nil { |
|
|
|
return group, nil |
|
|
|
} |
|
|
|
|
|
|
|
group, err := GroupDao.Get(groupId) |
|
|
|
group, err = GroupDao.Get(groupId) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
@@ -56,10 +56,12 @@ func (*groupRepo) GetLimit(groupId, limit int64) (*model.Group, error) { |
|
|
|
} |
|
|
|
group.Members = members |
|
|
|
|
|
|
|
//err = GroupCache.SetLimit(strconv.FormatInt(limit, 10), group) |
|
|
|
//if err != nil { |
|
|
|
// return nil, err |
|
|
|
//} |
|
|
|
if len(members) == int(limit) { |
|
|
|
err = GroupCache.SetLimit(strconv.FormatInt(limit, 10), group) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
} |
|
|
|
return group, nil |
|
|
|
} |
|
|
|
|
|
|
|