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/cmd/open_im_api/main.go

176 lines
8.3 KiB

4 years ago
package main
import (
apiAuth "Open_IM/internal/api/auth"
apiChat "Open_IM/internal/api/chat"
"Open_IM/internal/api/conversation"
"Open_IM/internal/api/friend"
"Open_IM/internal/api/group"
"Open_IM/internal/api/manage"
3 years ago
"Open_IM/internal/api/office"
3 years ago
"Open_IM/internal/api/organization"
apiThird "Open_IM/internal/api/third"
"Open_IM/internal/api/user"
3 years ago
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/log"
"Open_IM/pkg/utils"
4 years ago
"flag"
3 years ago
"fmt"
3 years ago
"io"
"os"
4 years ago
"strconv"
"github.com/gin-gonic/gin"
//"syscall"
3 years ago
"Open_IM/pkg/common/constant"
4 years ago
)
func main() {
3 years ago
log.NewPrivateLog(constant.LogFileName)
gin.SetMode(gin.ReleaseMode)
3 years ago
f, _ := os.Create("../logs/api.log")
gin.DefaultWriter = io.MultiWriter(f)
4 years ago
r := gin.Default()
r.Use(utils.CorsHandler())
3 years ago
log.Info("load config: ", config.Config)
4 years ago
// user routing group, which handles user registration and login services
userRouterGroup := r.Group("/user")
{
3 years ago
userRouterGroup.POST("/update_user_info", user.UpdateUserInfo) //1
3 years ago
userRouterGroup.POST("/get_users_info", user.GetUsersInfo) //1
3 years ago
userRouterGroup.POST("/get_self_user_info", user.GetSelfUserInfo) //1
4 years ago
}
//friend routing group
friendRouterGroup := r.Group("/friend")
{
3 years ago
// friendRouterGroup.POST("/get_friends_info", friend.GetFriendsInfo)
3 years ago
friendRouterGroup.POST("/add_friend", friend.AddFriend) //1
friendRouterGroup.POST("/delete_friend", friend.DeleteFriend) //1
friendRouterGroup.POST("/get_friend_apply_list", friend.GetFriendApplyList) //1
friendRouterGroup.POST("/get_self_friend_apply_list", friend.GetSelfFriendApplyList) //1
friendRouterGroup.POST("/get_friend_list", friend.GetFriendList) //1
friendRouterGroup.POST("/add_friend_response", friend.AddFriendResponse) //1
friendRouterGroup.POST("/set_friend_remark", friend.SetFriendRemark) //1
3 years ago
friendRouterGroup.POST("/add_black", friend.AddBlack) //1
friendRouterGroup.POST("/get_black_list", friend.GetBlacklist) //1
friendRouterGroup.POST("/remove_black", friend.RemoveBlack) //1
friendRouterGroup.POST("/import_friend", friend.ImportFriend) //1
friendRouterGroup.POST("/is_friend", friend.IsFriend) //1
4 years ago
}
//group related routing group
3 years ago
groupRouterGroup := r.Group("/group")
4 years ago
{
3 years ago
groupRouterGroup.POST("/create_group", group.CreateGroup) //1
groupRouterGroup.POST("/set_group_info", group.SetGroupInfo) //1
groupRouterGroup.POST("join_group", group.JoinGroup) //1
groupRouterGroup.POST("/quit_group", group.QuitGroup) //1
groupRouterGroup.POST("/group_application_response", group.ApplicationGroupResponse) //1
groupRouterGroup.POST("/transfer_group", group.TransferGroupOwner) //1
groupRouterGroup.POST("/get_recv_group_applicationList", group.GetRecvGroupApplicationList) //1
groupRouterGroup.POST("/get_user_req_group_applicationList", group.GetUserReqGroupApplicationList)
groupRouterGroup.POST("/get_groups_info", group.GetGroupsInfo) //1
groupRouterGroup.POST("/kick_group", group.KickGroupMember) //1
groupRouterGroup.POST("/get_group_member_list", group.GetGroupMemberList) //no use
groupRouterGroup.POST("/get_group_all_member_list", group.GetGroupAllMemberList) //1
groupRouterGroup.POST("/get_group_members_info", group.GetGroupMembersInfo) //1
groupRouterGroup.POST("/invite_user_to_group", group.InviteUserToGroup) //1
groupRouterGroup.POST("/get_joined_group_list", group.GetJoinedGroupList) //1
3 years ago
groupRouterGroup.POST("/dismiss_group", group.DismissGroup) //
groupRouterGroup.POST("/mute_group_member", group.MuteGroupMember)
groupRouterGroup.POST("/cancel_mute_group_member", group.CancelMuteGroupMember) //MuteGroup
groupRouterGroup.POST("/mute_group", group.MuteGroup)
groupRouterGroup.POST("/cancel_mute_group", group.CancelMuteGroup)
3 years ago
}
4 years ago
//certificate
authRouterGroup := r.Group("/auth")
{
3 years ago
authRouterGroup.POST("/user_register", apiAuth.UserRegister) //1
3 years ago
authRouterGroup.POST("/user_token", apiAuth.UserToken) //1
4 years ago
}
//Third service
thirdGroup := r.Group("/third")
{
thirdGroup.POST("/tencent_cloud_storage_credential", apiThird.TencentCloudStorageCredential)
thirdGroup.POST("/ali_oss_credential", apiThird.AliOSSCredential)
3 years ago
thirdGroup.POST("/minio_storage_credential", apiThird.MinioStorageCredential)
3 years ago
thirdGroup.POST("/minio_upload", apiThird.MinioUploadFile)
4 years ago
}
//Message
chatGroup := r.Group("/msg")
4 years ago
{
chatGroup.POST("/newest_seq", apiChat.GetSeq)
chatGroup.POST("/send_msg", apiChat.SendMsg)
chatGroup.POST("/pull_msg_by_seq", apiChat.PullMsgBySeqList)
3 years ago
chatGroup.POST("/del_msg", apiChat.DelMsg)
4 years ago
}
//Manager
managementGroup := r.Group("/manager")
{
managementGroup.POST("/delete_user", manage.DeleteUser) //1
managementGroup.POST("/send_msg", manage.ManagementSendMsg)
managementGroup.POST("/get_all_users_uid", manage.GetAllUsersUid) //1
managementGroup.POST("/account_check", manage.AccountCheck) //1
managementGroup.POST("/get_users_online_status", manage.GetUsersOnlineStatus) //1
}
//Conversation
conversationGroup := r.Group("/conversation")
3 years ago
{ //1
3 years ago
conversationGroup.POST("/get_all_conversations", conversation.GetAllConversations)
conversationGroup.POST("/get_conversation", conversation.GetConversation)
conversationGroup.POST("/get_conversations", conversation.GetConversations)
conversationGroup.POST("/set_conversation", conversation.SetConversation)
conversationGroup.POST("/batch_set_conversation", conversation.BatchSetConversations)
3 years ago
conversationGroup.POST("/set_recv_msg_opt", conversation.SetRecvMsgOpt)
3 years ago
}
// office
officeGroup := r.Group("/office")
{
3 years ago
officeGroup.POST("/get_user_tags", office.GetUserTags)
officeGroup.POST("/get_user_tag_by_id", office.GetUserTagByID)
3 years ago
officeGroup.POST("/create_tag", office.CreateTag)
officeGroup.POST("/delete_tag", office.DeleteTag)
officeGroup.POST("/set_tag", office.SetTag)
officeGroup.POST("/send_msg_to_tag", office.SendMsg2Tag)
3 years ago
officeGroup.POST("/get_send_tag_log", office.GetTagSendLogs)
3 years ago
officeGroup.POST("/create_one_work_moment", office.CreateOneWorkMoment)
officeGroup.POST("/delete_one_work_moment", office.DeleteOneWorkMoment)
officeGroup.POST("/like_one_work_moment", office.LikeOneWorkMoment)
officeGroup.POST("/comment_one_work_moment", office.CommentOneWorkMoment)
officeGroup.POST("/get_user_work_moments", office.GetUserWorkMoments)
officeGroup.POST("/get_user_friend_work_moments", office.GetUserFriendWorkMoments)
officeGroup.POST("/get_user_work_moments_comments_msg", office.GetUserWorkMomentsCommentsMsg)
officeGroup.POST("/clear_user_work_moments_comments_msg", office.ClearUserWorkMomentsCommentsMsg)
officeGroup.POST("/set_user_work_moments_level", office.SetUserWorkMomentsLevel)
}
3 years ago
organizationGroup := r.Group("/organization")
{
organizationGroup.POST("/create_department", organization.CreateDepartment)
organizationGroup.POST("/update_department", organization.UpdateDepartment)
3 years ago
organizationGroup.POST("/get_sub_department", organization.GetSubDepartment)
3 years ago
organizationGroup.POST("/delete_department", organization.DeleteDepartment)
organizationGroup.POST("/create_organization_user", organization.CreateOrganizationUser)
organizationGroup.POST("/update_organization_user", organization.UpdateOrganizationUser)
organizationGroup.POST("/create_department_member", organization.CreateDepartmentMember)
organizationGroup.POST("/get_user_in_department", organization.GetUserInDepartment)
organizationGroup.POST("/update_user_In_department", organization.UpdateUserInDepartment)
organizationGroup.POST("/delete_organization_user", organization.DeleteOrganizationUser)
organizationGroup.POST("/get_department_member", organization.GetDepartmentMember)
3 years ago
organizationGroup.POST("/delete_user_in_department", organization.DeleteUserInDepartment)
3 years ago
}
3 years ago
go apiThird.MinioInit()
4 years ago
ginPort := flag.Int("port", 10000, "get ginServerPort from cmd,default 10000 as port")
flag.Parse()
3 years ago
fmt.Println("start api server, port: ", *ginPort)
err := r.Run(":" + strconv.Itoa(*ginPort))
if err != nil {
log.Error("", "run failed ", *ginPort, err.Error())
}
4 years ago
}