group create

This commit is contained in:
withchao
2023-07-04 17:16:25 +08:00
parent bb667238f2
commit f80372ded4
8 changed files with 94 additions and 1 deletions
+4
View File
@@ -114,3 +114,7 @@ func (o *GroupApi) GetJoinedSuperGroupList(c *gin.Context) {
func (o *GroupApi) GetSuperGroupsInfo(c *gin.Context) {
a2r.Call(group.GroupClient.GetSuperGroupsInfo, o.Client, c)
}
func (o *GroupApi) GroupCreateCount(c *gin.Context) {
a2r.Call(group.GroupClient.GroupCreateCount, o.Client, c)
}
+1
View File
@@ -154,6 +154,7 @@ func NewGinRouter(discov discoveryregistry.SvcDiscoveryRegistry, rdb redis.Unive
{
statisticsGroup.POST("/user/register", u.UserRegisterCount)
statisticsGroup.POST("/user/active", m.GetActiveUser)
statisticsGroup.POST("/group/create", g.GroupCreateCount)
}
return r
}
+28
View File
@@ -0,0 +1,28 @@
package group
import (
"context"
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/group"
"time"
)
func (s *groupServer) GroupCreateCount(ctx context.Context, req *group.GroupCreateCountReq) (*group.GroupCreateCountResp, error) {
if req.Start > req.End {
return nil, errs.ErrArgs.Wrap("start > end")
}
total, err := s.GroupDatabase.CountTotal(ctx, nil)
if err != nil {
return nil, err
}
start := time.UnixMilli(req.Start)
before, err := s.GroupDatabase.CountTotal(ctx, &start)
if err != nil {
return nil, err
}
count, err := s.GroupDatabase.CountRangeEverydayTotal(ctx, start, time.UnixMilli(req.End))
if err != nil {
return nil, err
}
return &group.GroupCreateCountResp{Total: total, Before: before, Count: count}, nil
}