From d58bcd136aed32af497a16100b66ca3cff79b945 Mon Sep 17 00:00:00 2001 From: wangchuxiao Date: Fri, 21 Jan 2022 18:39:57 +0800 Subject: [PATCH] pb api --- cmd/open_im_cms_api/Makefile | 0 cmd/open_im_cms_api/main.go | 1 + internal/cms_api/admin/admin.go | 24 ++++++ internal/cms_api/group/group.go | 67 +++++++++++++++ internal/cms_api/message/message.go | 31 +++++++ internal/cms_api/middleware/cors.go | 23 +++++ internal/cms_api/middleware/jwt_auth.go | 11 +++ internal/cms_api/organization/organization.go | 82 ++++++++++++++++++ internal/cms_api/router.go | 85 +++++++++++++++++++ internal/cms_api/statistics/statistics.go | 80 +++++++++++++++++ internal/cms_api/user/user.go | 76 +++++++++++++++++ pkg/cms_api_struct/admin.go | 1 + pkg/cms_api_struct/common.go | 10 +++ pkg/cms_api_struct/group.go | 20 +++++ pkg/cms_api_struct/message.go | 27 ++++++ pkg/cms_api_struct/organization.go | 25 ++++++ pkg/cms_api_struct/statistics.go | 69 +++++++++++++++ pkg/cms_api_struct/user.go | 7 ++ pkg/common/http/http_resp.go | 1 + pkg/proto/user/user.proto | 56 ++++++++++++ 20 files changed, 696 insertions(+) create mode 100644 cmd/open_im_cms_api/Makefile create mode 100644 cmd/open_im_cms_api/main.go create mode 100644 internal/cms_api/admin/admin.go create mode 100644 internal/cms_api/group/group.go create mode 100644 internal/cms_api/message/message.go create mode 100644 internal/cms_api/middleware/cors.go create mode 100644 internal/cms_api/middleware/jwt_auth.go create mode 100644 internal/cms_api/organization/organization.go create mode 100644 internal/cms_api/router.go create mode 100644 internal/cms_api/statistics/statistics.go create mode 100644 internal/cms_api/user/user.go create mode 100644 pkg/cms_api_struct/admin.go create mode 100644 pkg/cms_api_struct/common.go create mode 100644 pkg/cms_api_struct/group.go create mode 100644 pkg/cms_api_struct/message.go create mode 100644 pkg/cms_api_struct/organization.go create mode 100644 pkg/cms_api_struct/statistics.go create mode 100644 pkg/cms_api_struct/user.go create mode 100644 pkg/common/http/http_resp.go diff --git a/cmd/open_im_cms_api/Makefile b/cmd/open_im_cms_api/Makefile new file mode 100644 index 000000000..e69de29bb diff --git a/cmd/open_im_cms_api/main.go b/cmd/open_im_cms_api/main.go new file mode 100644 index 000000000..c81a6080c --- /dev/null +++ b/cmd/open_im_cms_api/main.go @@ -0,0 +1 @@ +package open_im_cms_api diff --git a/internal/cms_api/admin/admin.go b/internal/cms_api/admin/admin.go new file mode 100644 index 000000000..7a0e0a575 --- /dev/null +++ b/internal/cms_api/admin/admin.go @@ -0,0 +1,24 @@ +package admin + +import ( + "net/http" + + "github.com/gin-gonic/gin" +) + +// register +func UserLogin(c *gin.Context) { + c.JSON(http.StatusOK, gin.H{"message": "someJSON", "status": 200}) +} + +func UserRegister(c *gin.Context) { + c.JSON(http.StatusOK, gin.H{"message": "someJSON", "status": 200}) +} + +func GetUserSettings(c *gin.Context) { + c.JSON(http.StatusOK, gin.H{"message": "someJSON", "status": 200}) +} + +func AlterUserSettings(c *gin.Context) { + c.JSON(http.StatusOK, gin.H{"message": "someJSON", "status": 200}) +} diff --git a/internal/cms_api/group/group.go b/internal/cms_api/group/group.go new file mode 100644 index 000000000..03cfdeb18 --- /dev/null +++ b/internal/cms_api/group/group.go @@ -0,0 +1,67 @@ +package group + +import ( + _ "Open_IM_CMS/pkg/req_resp" + "Open_IM_CMS/test" + "net/http" + + "github.com/gin-gonic/gin" +) + +func SearchGroups(c *gin.Context) { + fake := test.GetSearchGroupsResponseFake() + c.JSON(http.StatusOK, gin.H{"code": "0", "data": fake}) +} + +func SearchGroupsMember(c *gin.Context) { + fake := test.GetSearchMemberResponseFake() + c.JSON(http.StatusOK, gin.H{"code": "0", "data": fake}) +} + +func CreateGroup(c *gin.Context) { + +} + +func AddUsers(c *gin.Context) { + +} + +func InquireMember(c *gin.Context) { + +} + +func InquireGroup(c *gin.Context) { + +} + +func AddGroupMember(c *gin.Context) { + +} + +func AddMembers(c *gin.Context) { + +} + +func SetMaster(c *gin.Context) { + +} + +func BlockUser(c *gin.Context) { + +} + +func RemoveUser(c *gin.Context) { + +} + +func BanPrivateChat(c *gin.Context) { + +} + +func Withdraw(c *gin.Context) { + +} + +func SearchMessage(g *gin.Context) { + +} diff --git a/internal/cms_api/message/message.go b/internal/cms_api/message/message.go new file mode 100644 index 000000000..cc2e361cb --- /dev/null +++ b/internal/cms_api/message/message.go @@ -0,0 +1,31 @@ +package message + +import ( + "net/http" + + "Open_IM_CMS/test" + + "github.com/gin-gonic/gin" +) + +func Broadcast(c *gin.Context) { + +} + +func SearchMessageByUser(c *gin.Context) { + fake := test.GetSearchUserMsgFake() + c.JSON(http.StatusOK, gin.H{"code": "0", "data": fake}) +} + +func SearchMessageByGroup(c *gin.Context) { + fake := test.GetSearchGroupMsgFake() + c.JSON(http.StatusOK, gin.H{"code": "0", "data": fake}) +} + +func MassSendMassage(c *gin.Context) { + +} + +func Withdraw(c *gin.Context) { + +} diff --git a/internal/cms_api/middleware/cors.go b/internal/cms_api/middleware/cors.go new file mode 100644 index 000000000..139a001af --- /dev/null +++ b/internal/cms_api/middleware/cors.go @@ -0,0 +1,23 @@ +package middleware + +import ( + "github.com/gin-gonic/gin" + "net/http" +) + +func CorsHandler() gin.HandlerFunc { + return func(context *gin.Context) { + context.Writer.Header().Set("Access-Control-Allow-Origin", "*") + context.Header("Access-Control-Allow-Methods", "*") + context.Header("Access-Control-Allow-Headers", "*") + context.Header("Access-Control-Expose-Headers", "Content-Length, Access-Control-Allow-Origin, Access-Control-Allow-Headers,Cache-Control,Content-Language,Content-Type,Expires,Last-Modified,Pragma,FooBar") // 跨域关键设置 让浏览器可以解析 + context.Header("Access-Control-Max-Age", "172800") // 缓存请求信息 单位为秒 + context.Header("Access-Control-Allow-Credentials", "false") // 跨域请求是否需要带cookie信息 默认设置为true + context.Header("content-type", "application/json") // 设置返回格式是json + //Release all option pre-requests + if context.Request.Method == http.MethodOptions { + context.JSON(http.StatusOK, "Options Request!") + } + context.Next() + } +} diff --git a/internal/cms_api/middleware/jwt_auth.go b/internal/cms_api/middleware/jwt_auth.go new file mode 100644 index 000000000..ccdacc00b --- /dev/null +++ b/internal/cms_api/middleware/jwt_auth.go @@ -0,0 +1,11 @@ +package middleware + +import ( + "github.com/gin-gonic/gin" +) + +func JWTAuth() gin.HandlerFunc { + return func(c *gin.Context) { + + } +} diff --git a/internal/cms_api/organization/organization.go b/internal/cms_api/organization/organization.go new file mode 100644 index 000000000..a389de1e5 --- /dev/null +++ b/internal/cms_api/organization/organization.go @@ -0,0 +1,82 @@ +package organization + +import ( + "Open_IM_CMS/pkg/common/config" + "Open_IM_CMS/pkg/errno" + "Open_IM_CMS/pkg/etcdv3" + commonProto "Open_IM_CMS/pkg/proto/common" + proto "Open_IM_CMS/pkg/proto/organization" + "Open_IM_CMS/pkg/req_resp" + "Open_IM_CMS/test" + "context" + "fmt" + "net/http" + "strings" + + "github.com/gin-gonic/gin" +) + +func GetStaffs(c *gin.Context) { + var ( + req req_resp.GetStaffsResponse + resp req_resp.GetStaffsResponse + reqPb commonProto.Pagination + respPb *proto.GetStaffsResp + ) + fmt.Println(resp, req) + fakeData := test.GetStaffsResponseFake() + etcdConn := etcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCMSApiOrganizationName) + client := proto.NewOrganizationClient(etcdConn) + fmt.Println(client, reqPb) + respPb, err := client.GetStaffs(context.Background(), &reqPb) + fmt.Println(respPb, err) + fmt.Println(etcdConn) + req_resp.RespHttp200(c, errno.RespOK, fakeData) +} + +func GetOrganizations(c *gin.Context) { + var ( + req req_resp.GetOrganizationsResponse + resp req_resp.GetStaffsResponse + ) + fmt.Println(resp, req) + fakeData := test.GetOrganizationsResponseFake() + c.JSON(http.StatusOK, gin.H{"code": "0", "data": fakeData}) +} + +func GetSquads(c *gin.Context) { + fakeData := test.GetSquadResponseFake() + c.JSON(http.StatusOK, gin.H{"code": "0", "data": fakeData}) +} + +func AlterStaff(c *gin.Context) { + +} + +func AddOrganization(c *gin.Context) { + +} + +func InquireOrganization(g *gin.Context) { + +} + +func AlterOrganization(c *gin.Context) { + +} + +func DeleteOrganization(g *gin.Context) { + +} + +func GetOrganizationSquads(c *gin.Context) { + +} + +func AlterStaffsInfo(c *gin.Context) { + +} + +func AddChildOrganization(c *gin.Context) { + +} diff --git a/internal/cms_api/router.go b/internal/cms_api/router.go new file mode 100644 index 000000000..2a150d8fc --- /dev/null +++ b/internal/cms_api/router.go @@ -0,0 +1,85 @@ +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" + "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") + { + adminRouterGroup.POST("/register", admin.UserRegister) + adminRouterGroup.POST("/login", admin.UserLogin) + adminRouterGroup.GET("/get_user_settings", admin.GetUserSettings) + adminRouterGroup.POST("/alter_user_settings", admin.AlterUserSettings) + } + statisticsRouterGroup := router.Group("/statistics") + { + statisticsRouterGroup.GET("/get_messages_statistics", statistics.MessagesStatistics) + statisticsRouterGroup.GET("/get_users_statistics", statistics.UsersStatistics) + statisticsRouterGroup.GET("/get_groups_statistics", statistics.GroupsStatistics) + 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") + { + messageRouterGroup.POST("/broadcast", message.Broadcast) + messageRouterGroup.GET("/search_message_by_user", message.SearchMessageByUser) + messageRouterGroup.POST("/message_mass_send", message.MassSendMassage) + messageRouterGroup.GET("/search_message_by_group", message.SearchMessageByGroup) + messageRouterGroup.POST("/withdraw_message", message.Withdraw) + } + groupRouterGroup := router.Group("/groups") + { + groupRouterGroup.GET("/search_groups", group.SearchGroups) + groupRouterGroup.GET("/search_groups_member", group.SearchGroupsMember) + groupRouterGroup.POST("/create_group", group.CreateGroup) + groupRouterGroup.GET("/inquire_group", group.InquireGroup) + groupRouterGroup.GET("/inquireMember_by_group", group.InquireMember) + groupRouterGroup.POST("/add_members", group.AddMembers) + groupRouterGroup.POST("/set_master", group.SetMaster) + groupRouterGroup.POST("/block_user", group.BlockUser) + groupRouterGroup.POST("/remove_user", group.RemoveUser) + groupRouterGroup.POST("/ban_private_chat", group.BanPrivateChat) + groupRouterGroup.POST("/withdraw_message", group.Withdraw) + groupRouterGroup.POST("/search_group_message", group.SearchMessage) + } + userRouterGroup := router.Group("/users") + { + userRouterGroup.POST("/resign", user.ResignUser) + userRouterGroup.GET("/get_user", user.GetUser) + 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) + userRouterGroup.GET("/block_users", user.GetBlockUsers) + } + return baseRouter +} diff --git a/internal/cms_api/statistics/statistics.go b/internal/cms_api/statistics/statistics.go new file mode 100644 index 000000000..c6bbd9e1b --- /dev/null +++ b/internal/cms_api/statistics/statistics.go @@ -0,0 +1,80 @@ +package statistics + +import ( + "net/http" + + "Open_IM/pkg/req_resp" + + "Open_IM/test" + + "github.com/gin-gonic/gin" +) + +func MessagesStatistics(c *gin.Context) { + var ( + req req_resp.StatisticsRequest + //resp req_resp.MessageStatisticsResponse + ) + if err := c.ShouldBindUri(&req); err != nil { + c.JSON(http.StatusBadRequest, gin.H{}) + return + } + if _, err := test.RpcFake(); err != nil { + c.JSON(http.StatusOK, gin.H{}) + return + } + fakeData := test.GetUserStatisticsResponseFake() + c.JSON(http.StatusOK, gin.H{"code": "0", "data": fakeData}) +} + +func UsersStatistics(c *gin.Context) { + var ( + req req_resp.StatisticsRequest + //resp req_resp.MessageStatisticsResponse + ) + if err := c.ShouldBindUri(&req); err != nil { + c.JSON(http.StatusBadRequest, gin.H{}) + return + } + if _, err := test.RpcFake(); err != nil { + c.JSON(http.StatusOK, gin.H{}) + return + } + fakeData := test.GetUserStatisticsResponseFake() + c.JSON(http.StatusOK, gin.H{"code": "0", "data": fakeData}) +} + +func GroupsStatistics(c *gin.Context) { + var ( + req req_resp.StatisticsRequest + //resp req_resp.MessageStatisticsResponse + ) + if err := c.ShouldBindUri(&req); err != nil { + c.JSON(http.StatusBadRequest, gin.H{}) + return + } + if _, err := test.RpcFake(); err != nil { + c.JSON(http.StatusOK, gin.H{}) + return + } + fakeData := test.GetUserStatisticsResponseFake() + c.JSON(http.StatusOK, gin.H{"code": "0", "data": fakeData}) +} + +func GetActiveUser(c *gin.Context) { + if _, err := test.RpcFake(); err != nil { + c.JSON(http.StatusOK, gin.H{}) + return + } + fakeData := test.GetActiveUserResponseFake() + c.JSON(http.StatusOK, gin.H{"code": "0", "data": fakeData}) +} + +func GetActiveGroup(c *gin.Context) { + if _, err := test.RpcFake(); err != nil { + c.JSON(http.StatusOK, gin.H{}) + return + } + fakeData := test.GetActiveGroupResponseFake() + c.JSON(http.StatusOK, gin.H{"code": "0", "data": fakeData}) +} diff --git a/internal/cms_api/user/user.go b/internal/cms_api/user/user.go new file mode 100644 index 000000000..bb199a1f1 --- /dev/null +++ b/internal/cms_api/user/user.go @@ -0,0 +1,76 @@ +package user + +import ( + jsonData "Open_IM/internal/utils" + api "Open_IM/pkg/base_info" + "Open_IM/pkg/cms_api_struct" + "Open_IM/pkg/common/config" + "Open_IM/pkg/common/log" + "Open_IM/pkg/grpc-etcdv3/getcdv3" + open_im_sdk "Open_IM/pkg/proto/sdk_ws" + rpc "Open_IM/pkg/proto/user" + "Open_IM/pkg/utils" + "context" + "github.com/gin-gonic/gin" + "net/http" + "strings" +) + +func GetUser(c *gin.Context) { + var ( + req cms_api_struct.RequestPagination + resp cms_api_struct.GetUsersResponse + reqPb rpc.GetUserInfoReq + respPb *rpc.GetUserInfoResp + ) + + if err := c.BindJSON(&req); err != nil { + log.NewError("0", "BindJSON failed ", err.Error()) + c.JSON(http.StatusBadRequest, gin.H{"errCode": http.StatusBadRequest, "errMsg": err.Error()}) + return + } + utils.CopyStructFields(req, &req) + + etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName) + client := rpc.NewUserClient(etcdConn) + respPb, err := client.GetUserInfo(context.Background(), &reqPb) + if err != nil { + c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call rpc server failed"}) + return + } + //for _, v := range RpcResp.UserInfoList { + // publicUserInfoList = append(publicUserInfoList, + // &open_im_sdk.PublicUserInfo{UserID: v.UserID, Nickname: v.Nickname, FaceURL: v.FaceURL, Gender: v.Gender, AppMangerLevel: v.AppMangerLevel}) + //} + + //resp := api.GetUsersInfoResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}, UserInfoList: publicUserInfoList} + //resp.Data = jsonData.JsonDataList(resp.UserInfoList) + //log.NewInfo(req.OperationID, "GetUserInfo api return ", resp) + c.JSON(http.StatusOK, resp) +} + +func ResignUser(c *gin.Context) { + +} + + + +func AlterUser(c *gin.Context) { + +} + +func AddUser(c *gin.Context) { + +} + +func BlockUser(c *gin.Context) { + +} + +func UnblockUser(c *gin.Context) { + +} + +func GetBlockUsers(c *gin.Context) { + +} diff --git a/pkg/cms_api_struct/admin.go b/pkg/cms_api_struct/admin.go new file mode 100644 index 000000000..ffc2484b0 --- /dev/null +++ b/pkg/cms_api_struct/admin.go @@ -0,0 +1 @@ +package cms_api_struct diff --git a/pkg/cms_api_struct/common.go b/pkg/cms_api_struct/common.go new file mode 100644 index 000000000..9d9eca316 --- /dev/null +++ b/pkg/cms_api_struct/common.go @@ -0,0 +1,10 @@ +package cms_api_struct + + +type RequestPagination struct { + PageNumber int `json:"page_number"` + ShowNumber int `json:"show_number"` +} + + + diff --git a/pkg/cms_api_struct/group.go b/pkg/cms_api_struct/group.go new file mode 100644 index 000000000..99820d9e8 --- /dev/null +++ b/pkg/cms_api_struct/group.go @@ -0,0 +1,20 @@ +package cms_api_struct + +type SearchGroupsResponse struct { + GroupList []struct { + GroupNickName string `json:"group_nick_name"` + GroupID int `json:"group_id"` + MasterName string `json:"master_name"` + MasterId int `json:"master_id"` + CreatTime string `json:"creat_time"` + } `json:"group_list"` +} + +type SearchGroupMemberResponse struct { + GroupMemberList []struct { + MemberPosition int `json:"member_position"` + MemberNickName string `json:"member_nick_name"` + MemberId int `json:"member_id"` + JoinTime string `json:"join_time"` + } `json:"group_member_list"` +} diff --git a/pkg/cms_api_struct/message.go b/pkg/cms_api_struct/message.go new file mode 100644 index 000000000..5637b4eb0 --- /dev/null +++ b/pkg/cms_api_struct/message.go @@ -0,0 +1,27 @@ +package cms_api_struct + +type SearchMessageByUserResponse struct { + MessageList []struct { + ChatType int `json:"chat_type"` + MessageType int `json:"message_type"` + SenderNickName string `json:"sender_nick_name"` + SenderId int `json:"sender_id"` + ReceiverNickName string `json:"receiver_nick_name"` + ReceiverID int `json:"receiver_id"` + SearchContent string `json:"search_content"` + WholeContent string `json:"whole_content"` + Date string `json:"date"` + } `json:"massage_list"` +} + +type SearchMessageByGroupResponse struct { + MessageList []struct { + ChatType int `json:"chat_type"` + MessageType int `json:"message_type"` + SenderNickName string `json:"sender_nick_name"` + SenderId int `json:"sender_id"` + SearchContent string `json:"search_content"` + WholeContent string `json:"whole_content"` + Date string `json:"date"` + } `json:"massage_list"` +} diff --git a/pkg/cms_api_struct/organization.go b/pkg/cms_api_struct/organization.go new file mode 100644 index 000000000..825d41aa1 --- /dev/null +++ b/pkg/cms_api_struct/organization.go @@ -0,0 +1,25 @@ +package cms_api_struct + +type GetStaffsResponse struct { + StaffsList []struct { + ProfilePhoto string `json:"profile_photo"` + NickName string `json:"nick_name"` + StaffId int `json:"staff_id"` + Position string `json:"position"` + EntryTime string `json:"entry_time"` + } `json:"staffs_list"` +} + +type GetOrganizationsResponse struct { + OrganizationList []struct { + OrganizationId int `json:"organization_id"` + OrganizationName string `json:"organization_name"` + } `json:"organization_list"` +} + +type SquadResponse struct { + SquadList []struct { + SquadId int `json:"squad_id"` + SquadName string `json:"squad_name"` + } `json:"squad_list"` +} diff --git a/pkg/cms_api_struct/statistics.go b/pkg/cms_api_struct/statistics.go new file mode 100644 index 000000000..376932f85 --- /dev/null +++ b/pkg/cms_api_struct/statistics.go @@ -0,0 +1,69 @@ +package cms_api_struct + +type StatisticsRequest struct { + From string `json:"from"` + To string `json:"to"` +} + +// 单聊 +type MessageStatisticsResponse struct { + PrivateMessageNum int `json:"private_message_num"` + GroupMessageNum int `json:"group_message_num"` + PrivateMessageNumList []struct { + Date string `json:"date"` + MessageNum int `json:"message_num"` + } `json:"private_message_num_list"` + GroupMessageNumList []struct { + Date string `json:"date"` + MessageNum int `json:"message_num"` + } `json:"group_message_num_list"` +} + +// 用户统计 +type UserStatisticsResponse struct { + IncreaseUserNum int `json:"increase_user_num"` + ActiveUserNum int `json:"active_user_num"` + TotalUserNum int `json:"total_user_num"` + IncreaseUserNumList []struct { + Date string `json:"date"` + IncreaseUserNum int `json:"increase_user_num"` + } `json:"increase_user_num_list"` + ActiveUserNumList []struct { + Date string `json:"date"` + ActiveUserNum int `json:"active_user_num"` + } `json:"active_user_num_list"` + TotalUserNumList []struct { + Date string `json:"date"` + TotalUserNum string `json:"total_user_num"` + } `json:"total_user_num_list"` +} + +// 群聊统计 +type GroupMessageStatisticsResponse struct { + IncreaseGroupNum int `json:"increase_group_num"` + TotalGroupNum int `json:"total_group_num"` + IncreaseGroupNumList []struct { + Date string `json:"date"` + IncreaseGroupNum int `json:"increase_group_num"` + } `json:"increase_group_num_list"` + TotalGroupNumList []struct { + Date string `json:"date"` + TotalGroupNum string `json:"total_group_num"` + } `json:"total_group_num_list"` +} + +type ActiveUserStatisticsResponse struct { + ActiveUserList []struct { + NickName string `json:"nick_name"` + Id int `json:"id"` + MessageNum int `json:"message_num"` + } `json:"active_user_list"` +} + +type ActiveGroupStatisticsResponse struct { + ActiveGroupList []struct { + GroupNickName string `json:"group_nick_name"` + GroupId int `json:"group_id"` + MessageNum int `json:"message_num"` + } `json:"active_group_list"` +} diff --git a/pkg/cms_api_struct/user.go b/pkg/cms_api_struct/user.go new file mode 100644 index 000000000..013065c4e --- /dev/null +++ b/pkg/cms_api_struct/user.go @@ -0,0 +1,7 @@ +package cms_api_struct + +type GetUsersResponse struct { + +} + + diff --git a/pkg/common/http/http_resp.go b/pkg/common/http/http_resp.go new file mode 100644 index 000000000..d02cfda64 --- /dev/null +++ b/pkg/common/http/http_resp.go @@ -0,0 +1 @@ +package http diff --git a/pkg/proto/user/user.proto b/pkg/proto/user/user.proto index 75455f7a0..18ecff94c 100644 --- a/pkg/proto/user/user.proto +++ b/pkg/proto/user/user.proto @@ -106,6 +106,53 @@ message GetAllConversationMsgOptResp{ repeated OptResult conversationOptResultList = 3; } +message ResignUserReq{ + string UserId = 1; + string OperationID = 2; +} + +message ResignUserResp{ + CommonResp commonResp = 1; +} + +message GetUserReq{ + string UserId = 1; + string OperationID = 2; +} + +message User{ + +} + +message GetUserResp{ + User user = 1 +} + +message AlterUserReq{ + string UserId = 1; + string OperationID = 2; +} + +message AlterUserResp{ + CommonResp commonResp = 1; +} + +message GetUserReq{ + string OperationID = 1; +} + +message GetUsersResp{ + string OperationID = 1; + repeated Users User = 2; +} + +message AddUserReq{ + string OperationID = 1; +} + +message AddUserResp{ + CommonResp commonResp = 1; +} service user { rpc GetUserInfo(GetUserInfoReq) returns(GetUserInfoResp); @@ -116,4 +163,13 @@ service user { rpc GetReceiveMessageOpt(GetReceiveMessageOptReq)returns(GetReceiveMessageOptResp); rpc GetAllConversationMsgOpt(GetAllConversationMsgOptReq)returns(GetAllConversationMsgOptResp); rpc AccountCheck(AccountCheckReq)returns(AccountCheckResp); + + rpc ResignUser(ResignUserReq) returns (ResignUserResp); + rpc GetUser(GetUserReq) returns (GetUserResp); + rpc AlterUser(AlterUserReq) returns (AlterUserResp); + rpc GetUsers(GetUsersReq) returns (GetUsersResp); + rpc AddUser(AddUserReq) returns (AddUserResp); + rpc BlockUser(BlockUserReq) returns (BlockUserResp); + rpc UnBlockUser(UnBlockUserReq) returns (UnBlockUserResp); + rpc GetBlockUsers(GetBlockUsersReq) returns (GetBlockUsersResp); }