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.
Open-IM-Server/internal/cms_api/router.go

87 lines
4.0 KiB

3 years ago
package cms_api
import (
"Open_IM/internal/cms_api/admin"
"Open_IM/internal/cms_api/group"
"Open_IM/internal/cms_api/message"
"Open_IM/internal/cms_api/middleware"
"Open_IM/internal/cms_api/organization"
"Open_IM/internal/cms_api/statistics"
"Open_IM/internal/cms_api/user"
3 years ago
3 years ago
"github.com/gin-gonic/gin"
)
func NewGinRouter() *gin.Engine {
gin.SetMode(gin.ReleaseMode)
baseRouter := gin.Default()
router := baseRouter.Group("/api")
router.Use(middleware.JWTAuth())
router.Use(middleware.CorsHandler())
adminRouterGroup := router.Group("/admin")
{
3 years ago
adminRouterGroup.POST("/register", admin.AdminRegister)
adminRouterGroup.GET("/get_user_settings", admin.GetAdminSettings)
adminRouterGroup.POST("/alter_user_settings", admin.AlterAdminSettings)
3 years ago
}
statisticsRouterGroup := router.Group("/statistics")
{
3 years ago
statisticsRouterGroup.GET("/get_messages_statistics", statistics.GetMessagesStatistics)
3 years ago
statisticsRouterGroup.GET("/get_user_statistics", statistics.GetUserStatistics)
statisticsRouterGroup.GET("/get_group_statistics", statistics.GetGroupStatistics)
3 years ago
statisticsRouterGroup.GET("/get_active_user", statistics.GetActiveUser)
statisticsRouterGroup.GET("/get_active_group", statistics.GetActiveGroup)
}
organizationRouterGroup := router.Group("/organization")
{
organizationRouterGroup.GET("/get_staffs", organization.GetStaffs)
organizationRouterGroup.GET("/get_organizations", organization.GetOrganizations)
organizationRouterGroup.GET("/get_squad", organization.GetSquads)
organizationRouterGroup.POST("/add_organization", organization.AddOrganization)
organizationRouterGroup.POST("/alter_staff", organization.AlterStaff)
organizationRouterGroup.GET("/inquire_organization", organization.InquireOrganization)
organizationRouterGroup.POST("/alter_organization", organization.AlterOrganization)
organizationRouterGroup.POST("/delete_organization", organization.DeleteOrganization)
organizationRouterGroup.POST("/get_organization_squad", organization.GetOrganizationSquads)
organizationRouterGroup.PATCH("/alter_corps_info", organization.AlterStaffsInfo)
organizationRouterGroup.POST("/add_child_org", organization.AddChildOrganization)
}
messageRouterGroup := router.Group("/message")
{
3 years ago
messageRouterGroup.POST("/broadcast_message", message.BroadcastMessage)
messageRouterGroup.POST("/mass_send_message", message.MassSendMassage)
messageRouterGroup.POST("/withdraw_message", message.WithdrawMessage)
3 years ago
}
3 years ago
groupRouterGroup := router.Group("/group")
3 years ago
{
3 years ago
groupRouterGroup.GET("/get_group_by_id", group.GetGroupById)
3 years ago
groupRouterGroup.GET("/get_groups", group.GetGroups)
3 years ago
groupRouterGroup.GET("/get_group_by_name", group.GetGroupByName)
groupRouterGroup.GET("/get_group_members", group.GetGroupsMember)
3 years ago
groupRouterGroup.POST("/create_group", group.CreateGroup)
groupRouterGroup.GET("/inquire_group", group.InquireGroup)
groupRouterGroup.POST("/add_members", group.AddMembers)
3 years ago
groupRouterGroup.POST("/remove_member", group.RemoveUser)
groupRouterGroup.POST("/ban_group_private_chat", group.BanPrivateChat)
groupRouterGroup.POST("/open_group_private_chat", group.OpenPrivateChat)
3 years ago
groupRouterGroup.POST("/withdraw_message", group.Withdraw)
groupRouterGroup.POST("/search_group_message", group.SearchMessage)
3 years ago
groupRouterGroup.POST("/ban_group_chat", group.BanGroupChat)
3 years ago
groupRouterGroup.POST("/open_group_chat", group.OpenGroupChat)
3 years ago
}
3 years ago
userRouterGroup := router.Group("/user")
3 years ago
{
userRouterGroup.POST("/resign", user.ResignUser)
3 years ago
userRouterGroup.GET("/get_user_by_id", user.GetUserById)
3 years ago
userRouterGroup.POST("/alter_user", user.AlterUser)
userRouterGroup.GET("/get_users", user.GetUsers)
userRouterGroup.POST("/add_user", user.AddUser)
userRouterGroup.POST("/unblock_user", user.UnblockUser)
userRouterGroup.POST("/block_user", user.BlockUser)
3 years ago
userRouterGroup.GET("/get_block_users", user.GetBlockUsers)
3 years ago
userRouterGroup.GET("/get_block_user_by_id", user.GetBlockUserById)
userRouterGroup.POST("/delete_user", user.DeleteUser)
3 years ago
}
return baseRouter
}