diff --git a/internal/logic/api/logic_ext.go b/internal/logic/api/logic_ext.go index ca3991d..92ed053 100644 --- a/internal/logic/api/logic_ext.go +++ b/internal/logic/api/logic_ext.go @@ -248,11 +248,15 @@ func (*LogicExtServer) GetGroup(ctx context.Context, in *pb.GetGroupReq) (*pb.Ge return &pb.GetGroupResp{Group: group, MemberType: memberType, GroupUserStatusType: userStatusType}, err } groupNotice, err := repo.GroupRepo.GetGroupNotice(in.GroupId) - return &pb.GetGroupResp{Group: group, MemberType: memberType, GroupUserStatusType: userStatusType, GroupNotice: &pb.GroupNotice{ - Content: groupNotice.Content, - PublishType: pb.GroupNoticePublishType(groupNotice.PublishType), - PublishTime: groupNotice.UpdateTime.Format("2006-01-02 15:04:05"), - }}, err + var groupNoticeInfo = pb.GroupNotice{} + if groupNotice == nil { + groupNoticeInfo = pb.GroupNotice{ + Content: groupNotice.Content, + PublishType: pb.GroupNoticePublishType(groupNotice.PublishType), + PublishTime: groupNotice.UpdateTime.Format("2006-01-02 15:04:05"), + } + } + return &pb.GetGroupResp{Group: group, MemberType: memberType, GroupUserStatusType: userStatusType, GroupNotice: &groupNoticeInfo}, err } // GetGroups 获取用户加入的所有群组 diff --git a/internal/logic/domain/group/repo/group_repo.go b/internal/logic/domain/group/repo/group_repo.go index 86df007..065789c 100644 --- a/internal/logic/domain/group/repo/group_repo.go +++ b/internal/logic/domain/group/repo/group_repo.go @@ -56,6 +56,9 @@ func (*groupRepo) GetGroupNotice(groupId int64) (*model.GroupNotice, error) { if err != nil { return nil, err } + if group == nil { + return nil, nil + } err = GroupNoticeCache.Set(group) if err != nil { return nil, err