forked from openimsdk/open-im-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
router.go
84 lines (74 loc) · 3.33 KB
/
router.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
package cms_api
import (
"github.com/erbaner/be/internal/cms_api/admin"
"github.com/erbaner/be/internal/cms_api/friend"
"github.com/erbaner/be/internal/cms_api/group"
messageCMS "github.com/erbaner/be/internal/cms_api/message_cms"
"github.com/erbaner/be/internal/cms_api/middleware"
"github.com/erbaner/be/internal/cms_api/statistics"
"github.com/erbaner/be/internal/cms_api/user"
"github.com/erbaner/be/internal/demo/register"
"github.com/erbaner/be/pkg/common/config"
promePkg "github.com/erbaner/be/pkg/common/prometheus"
"github.com/gin-gonic/gin"
)
func NewGinRouter() *gin.Engine {
gin.SetMode(gin.ReleaseMode)
baseRouter := gin.New()
baseRouter.Use(gin.Recovery())
baseRouter.Use(middleware.CorsHandler())
if config.Config.Prometheus.Enable {
baseRouter.GET("/metrics", promePkg.PrometheusHandler())
}
router := baseRouter.Group("/cms")
adminRouterGroup := router.Group("/admin")
{
adminRouterGroup.POST("/login", admin.AdminLogin)
adminRouterGroup.Use(middleware.JWTAuth())
adminRouterGroup.POST("/get_user_token", admin.GetUserToken)
adminRouterGroup.POST("/add_user_register_add_friend_id", admin.AddUserRegisterAddFriendIDList)
adminRouterGroup.POST("/reduce_user_register_reduce_friend_id", admin.ReduceUserRegisterAddFriendIDList)
adminRouterGroup.POST("/get_user_register_reduce_friend_id_list", admin.GetUserRegisterAddFriendIDList)
adminRouterGroup.POST("/generate_invitation_code", register.GenerateInvitationCode)
adminRouterGroup.POST("/query_invitation_code", register.QueryInvitationCode)
adminRouterGroup.POST("/get_invitation_codes", register.GetInvitationCodes)
adminRouterGroup.POST("/query_user_ip_limit_login", register.QueryUserIDLimitLogin)
adminRouterGroup.POST("/add_user_ip_limit_login", register.AddUserIPLimitLogin)
adminRouterGroup.POST("/remove_user_ip_limit_login", register.RemoveUserIPLimitLogin)
adminRouterGroup.POST("/query_ip_register", register.QueryIPRegister)
adminRouterGroup.POST("/add_ip_limit", register.AddIPLimit)
adminRouterGroup.POST("/remove_ip_Limit", register.RemoveIPLimit)
}
r2 := router.Group("")
r2.Use(middleware.JWTAuth())
statisticsRouterGroup := r2.Group("/statistics")
{
statisticsRouterGroup.POST("/get_messages_statistics", statistics.GetMessagesStatistics)
statisticsRouterGroup.POST("/get_user_statistics", statistics.GetUserStatistics)
statisticsRouterGroup.POST("/get_group_statistics", statistics.GetGroupStatistics)
statisticsRouterGroup.POST("/get_active_user", statistics.GetActiveUser)
statisticsRouterGroup.POST("/get_active_group", statistics.GetActiveGroup)
}
groupRouterGroup := r2.Group("/group")
{
groupRouterGroup.POST("/get_groups", group.GetGroups)
groupRouterGroup.POST("/get_group_members", group.GetGroupMembers)
}
userRouterGroup := r2.Group("/user")
{
userRouterGroup.POST("/get_user_id_by_email_phone", user.GetUserIDByEmailAndPhoneNumber)
userRouterGroup.POST("/add_user", user.AddUser)
userRouterGroup.POST("/unblock_user", user.UnblockUser)
userRouterGroup.POST("/block_user", user.BlockUser)
userRouterGroup.POST("/get_block_users", user.GetBlockUsers)
}
messageCMSRouterGroup := r2.Group("/message")
{
messageCMSRouterGroup.POST("/get_chat_logs", messageCMS.GetChatLogs)
}
friendCMSRouterGroup := r2.Group("/friend")
{
friendCMSRouterGroup.POST("/get_friends", friend.GetUserFriends)
}
return baseRouter
}