You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
63 lines
1.9 KiB
63 lines
1.9 KiB
2 years ago
|
package cmsapi
|
||
3 years ago
|
|
||
|
import (
|
||
|
"Open_IM/internal/cms_api/admin"
|
||
2 years ago
|
"Open_IM/internal/cms_api/friend"
|
||
3 years ago
|
"Open_IM/internal/cms_api/group"
|
||
3 years ago
|
messageCMS "Open_IM/internal/cms_api/message_cms"
|
||
3 years ago
|
"Open_IM/internal/cms_api/middleware"
|
||
|
"Open_IM/internal/cms_api/statistics"
|
||
|
"Open_IM/internal/cms_api/user"
|
||
2 years ago
|
"Open_IM/pkg/common/config"
|
||
3 years ago
|
|
||
2 years ago
|
promePkg "Open_IM/pkg/common/prometheus"
|
||
|
|
||
3 years ago
|
"github.com/gin-gonic/gin"
|
||
|
)
|
||
|
|
||
|
func NewGinRouter() *gin.Engine {
|
||
|
gin.SetMode(gin.ReleaseMode)
|
||
2 years ago
|
baseRouter := gin.New()
|
||
2 years ago
|
baseRouter.Use(gin.Recovery())
|
||
|
baseRouter.Use(middleware.CorsHandler())
|
||
2 years ago
|
if config.Config.Prometheus.Enable {
|
||
2 years ago
|
baseRouter.GET("/metrics", promePkg.PrometheusHandler())
|
||
2 years ago
|
}
|
||
2 years ago
|
router := baseRouter.Group("/cms")
|
||
3 years ago
|
adminRouterGroup := router.Group("/admin")
|
||
|
{
|
||
3 years ago
|
adminRouterGroup.POST("/login", admin.AdminLogin)
|
||
2 years ago
|
adminRouterGroup.Use(middleware.JWTAuth())
|
||
2 years ago
|
adminRouterGroup.POST("/get_user_token", admin.GetUserToken)
|
||
3 years ago
|
}
|
||
3 years ago
|
r2 := router.Group("")
|
||
|
r2.Use(middleware.JWTAuth())
|
||
|
statisticsRouterGroup := r2.Group("/statistics")
|
||
3 years ago
|
{
|
||
2 years ago
|
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)
|
||
3 years ago
|
}
|
||
3 years ago
|
groupRouterGroup := r2.Group("/group")
|
||
3 years ago
|
{
|
||
2 years ago
|
groupRouterGroup.POST("/get_groups", group.GetGroups)
|
||
|
groupRouterGroup.POST("/get_group_members", group.GetGroupMembers)
|
||
3 years ago
|
}
|
||
3 years ago
|
userRouterGroup := r2.Group("/user")
|
||
3 years ago
|
{
|
||
2 years ago
|
userRouterGroup.POST("/get_user_id_by_email_phone", user.GetUserIDByEmailAndPhoneNumber)
|
||
3 years ago
|
}
|
||
3 years ago
|
messageCMSRouterGroup := r2.Group("/message")
|
||
3 years ago
|
{
|
||
2 years ago
|
messageCMSRouterGroup.POST("/get_chat_logs", messageCMS.GetChatLogs)
|
||
3 years ago
|
}
|
||
2 years ago
|
friendCMSRouterGroup := r2.Group("/friend")
|
||
2 years ago
|
{
|
||
|
friendCMSRouterGroup.POST("/get_friends", friend.GetUserFriends)
|
||
|
}
|
||
2 years ago
|
|
||
3 years ago
|
return baseRouter
|
||
|
}
|