mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-07 18:45:58 +08:00
add
This commit is contained in:
@@ -7,18 +7,18 @@ import (
|
||||
)
|
||||
|
||||
// register
|
||||
func UserLogin(c *gin.Context) {
|
||||
func AdminLogin(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, gin.H{"message": "someJSON", "status": 200})
|
||||
}
|
||||
|
||||
func UserRegister(c *gin.Context) {
|
||||
func AdminRegister(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, gin.H{"message": "someJSON", "status": 200})
|
||||
}
|
||||
|
||||
func GetUserSettings(c *gin.Context) {
|
||||
func GetAdminSettings(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, gin.H{"message": "someJSON", "status": 200})
|
||||
}
|
||||
|
||||
func AlterUserSettings(c *gin.Context) {
|
||||
func AlterAdminSettings(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, gin.H{"message": "someJSON", "status": 200})
|
||||
}
|
||||
|
||||
@@ -18,6 +18,34 @@ import (
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func GetGroupById(c *gin.Context) {
|
||||
var (
|
||||
req cms_api_struct.GetGroupByIdRequest
|
||||
resp cms_api_struct.GetGroupByIdResponse
|
||||
reqPb pbGroup.GetGroupByIdReq
|
||||
)
|
||||
if err := c.ShouldBindQuery(&req); err != nil {
|
||||
log.NewError("0", "ShouldBindQuery failed ", err.Error())
|
||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||
return
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := pbGroup.NewGroupClient(etcdConn)
|
||||
respPb, err := client.GetGroupById(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(utils.GetSelfFuncName(), "GetUserInfo failed ", err.Error())
|
||||
openIMHttp.RespHttp200(c, constant.ErrServer, nil)
|
||||
return
|
||||
}
|
||||
resp.GroupMasterId = respPb.GroupInfo.OwnerUserID
|
||||
resp.GroupName = respPb.GroupInfo.GroupName
|
||||
resp.GroupID = respPb.GroupInfo.GroupID
|
||||
resp.CreateTime = (utils.UnixSecondToTime(int64(respPb.GroupInfo.CreateTime))).String()
|
||||
resp.ProfilePhoto = respPb.GroupInfo.FaceURL
|
||||
resp.GroupMasterName = respPb.GroupInfo.OwnerUserID
|
||||
openIMHttp.RespHttp200(c, constant.OK, nil)
|
||||
}
|
||||
|
||||
func GetGroups(c *gin.Context) {
|
||||
var (
|
||||
req cms_api_struct.GetGroupsRequest
|
||||
@@ -57,7 +85,7 @@ func GetGroups(c *gin.Context) {
|
||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||
}
|
||||
|
||||
func GetGroup(c *gin.Context) {
|
||||
func GetGroupByName(c *gin.Context) {
|
||||
var (
|
||||
req cms_api_struct.GetGroupRequest
|
||||
resp cms_api_struct.GetGroupResponse
|
||||
@@ -69,6 +97,8 @@ func GetGroup(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
reqPb.GroupName = req.GroupName
|
||||
reqPb.Pagination = &commonPb.RequestPagination{}
|
||||
utils.CopyStructFields(&reqPb.Pagination, req)
|
||||
fmt.Println(reqPb)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := pbGroup.NewGroupClient(etcdConn)
|
||||
@@ -90,6 +120,8 @@ func GetGroup(c *gin.Context) {
|
||||
ProfilePhoto: v.FaceURL,
|
||||
})
|
||||
}
|
||||
resp.CurrentPage = int(respPb.Pagination.PageNumber)
|
||||
resp.ShowNumber = int(respPb.Pagination.ShowNumber)
|
||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||
}
|
||||
|
||||
@@ -104,24 +136,30 @@ func CreateGroup(c *gin.Context) {
|
||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||
return
|
||||
}
|
||||
reqPb.GroupInfo = &commonPb.GroupInfo{}
|
||||
reqPb.GroupInfo.GroupName = req.GroupName
|
||||
reqPb.GroupInfo.CreatorUserID = ""
|
||||
reqPb.GroupInfo.CreatorUserID = req.GroupMasterId
|
||||
for _, v := range req.GroupMembers {
|
||||
reqPb.InitMemberList = append(reqPb.InitMemberList, &pbGroup.GroupAddMemberInfo{
|
||||
UserID: v,
|
||||
RoleLevel: 1,
|
||||
})
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := pbGroup.NewGroupClient(etcdConn)
|
||||
respPb, err := client.CreateGroup(context.Background(), &reqPb)
|
||||
_, err := client.CreateGroup(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError("s", "GetUserInfo failed ", err.Error())
|
||||
openIMHttp.RespHttp200(c, constant.ErrServer, nil)
|
||||
return
|
||||
}
|
||||
fmt.Println(respPb)
|
||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||
}
|
||||
|
||||
func BanGroupChat(c *gin.Context) {
|
||||
var (
|
||||
req cms_api_struct.BanGroupChatRequest
|
||||
reqPb pbGroup.BanGroupChatReq
|
||||
reqPb pbGroup.OperateGroupStatusReq
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError("0", "ShouldBindQuery failed ", err.Error())
|
||||
@@ -129,9 +167,10 @@ func BanGroupChat(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
reqPb.GroupId = req.GroupId
|
||||
reqPb.Status = constant.GroupBanChat
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := pbGroup.NewGroupClient(etcdConn)
|
||||
_, err := client.BanGroupChat(context.Background(), &reqPb)
|
||||
_, err := client.OperateGroupStatus(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError("s", "GetUserInfo failed ", err.Error())
|
||||
openIMHttp.RespHttp200(c, constant.ErrServer, nil)
|
||||
@@ -144,7 +183,7 @@ func BanGroupChat(c *gin.Context) {
|
||||
func BanPrivateChat(c *gin.Context) {
|
||||
var (
|
||||
req cms_api_struct.BanPrivateChatRequest
|
||||
reqPb pbGroup.BanPrivateChatReq
|
||||
reqPb pbGroup.OperateGroupStatusReq
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
@@ -152,9 +191,10 @@ func BanPrivateChat(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
reqPb.GroupId = req.GroupId
|
||||
reqPb.Status = constant.GroupBanPrivateChat
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := pbGroup.NewGroupClient(etcdConn)
|
||||
_, err := client.BanPrivateChat(context.Background(), &reqPb)
|
||||
_, err := client.OperateGroupStatus(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError("s", "GetUserInfo failed ", err.Error())
|
||||
openIMHttp.RespHttp200(c, constant.ErrServer, nil)
|
||||
@@ -163,6 +203,53 @@ func BanPrivateChat(c *gin.Context) {
|
||||
openIMHttp.RespHttp200(c, constant.OK, nil)
|
||||
}
|
||||
|
||||
func OpenGroupChat(c *gin.Context) {
|
||||
var (
|
||||
req cms_api_struct.BanPrivateChatRequest
|
||||
reqPb pbGroup.OperateGroupStatusReq
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||
return
|
||||
}
|
||||
reqPb.GroupId = req.GroupId
|
||||
reqPb.Status = constant.GroupOk
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := pbGroup.NewGroupClient(etcdConn)
|
||||
_, err := client.OperateGroupStatus(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError("s", "GetUserInfo failed ", err.Error())
|
||||
openIMHttp.RespHttp200(c, constant.ErrServer, nil)
|
||||
return
|
||||
}
|
||||
openIMHttp.RespHttp200(c, constant.OK, nil)
|
||||
}
|
||||
|
||||
func OpenPrivateChat(c *gin.Context) {
|
||||
var (
|
||||
req cms_api_struct.BanPrivateChatRequest
|
||||
reqPb pbGroup.OperateGroupStatusReq
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||
return
|
||||
}
|
||||
reqPb.GroupId = req.GroupId
|
||||
reqPb.Status = constant.GroupOk
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := pbGroup.NewGroupClient(etcdConn)
|
||||
_, err := client.OperateGroupStatus(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError("s", "GetUserInfo failed ", err.Error())
|
||||
openIMHttp.RespHttp200(c, constant.ErrServer, nil)
|
||||
return
|
||||
}
|
||||
openIMHttp.RespHttp200(c, constant.OK, nil)
|
||||
}
|
||||
|
||||
|
||||
func GetGroupsMember(c *gin.Context) {
|
||||
var (
|
||||
req cms_api_struct.GetGroupMembersRequest
|
||||
@@ -175,10 +262,6 @@ func GetGroupsMember(c *gin.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
func InquireMember(c *gin.Context) {
|
||||
|
||||
}
|
||||
|
||||
func InquireGroup(c *gin.Context) {
|
||||
|
||||
}
|
||||
|
||||
+14
-12
@@ -20,16 +20,16 @@ func NewGinRouter() *gin.Engine {
|
||||
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)
|
||||
adminRouterGroup.POST("/register", admin.AdminRegister)
|
||||
adminRouterGroup.POST("/login", admin.AdminLogin)
|
||||
adminRouterGroup.GET("/get_user_settings", admin.GetAdminSettings)
|
||||
adminRouterGroup.POST("/alter_user_settings", admin.AlterAdminSettings)
|
||||
}
|
||||
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_messages_statistics", statistics.GetMessagesStatistics)
|
||||
statisticsRouterGroup.GET("/get_users_statistics", statistics.GetUsersStatistics)
|
||||
statisticsRouterGroup.GET("/get_groups_statistics", statistics.GetGroupsStatistics)
|
||||
statisticsRouterGroup.GET("/get_active_user", statistics.GetActiveUser)
|
||||
statisticsRouterGroup.GET("/get_active_group", statistics.GetActiveGroup)
|
||||
}
|
||||
@@ -57,18 +57,20 @@ func NewGinRouter() *gin.Engine {
|
||||
}
|
||||
groupRouterGroup := router.Group("/group")
|
||||
{
|
||||
groupRouterGroup.GET("/get_group_by_id", group.GetGroupById)
|
||||
groupRouterGroup.GET("/get_groups", group.GetGroups)
|
||||
groupRouterGroup.GET("/get_group", group.GetGroup)
|
||||
groupRouterGroup.GET("/search_groups_member", group.GetGroupsMember)
|
||||
groupRouterGroup.GET("/get_group_by_name", group.GetGroupByName)
|
||||
groupRouterGroup.GET("/get_group_members", group.GetGroupsMember)
|
||||
groupRouterGroup.POST("/create_group", group.CreateGroup)
|
||||
groupRouterGroup.GET("/inquire_group", group.InquireGroup)
|
||||
groupRouterGroup.GET("/inquire_member_by_group", group.InquireMember)
|
||||
groupRouterGroup.POST("/add_members", group.AddMembers)
|
||||
groupRouterGroup.POST("/remove_user", group.RemoveUser)
|
||||
groupRouterGroup.POST("/ban_private_chat", group.BanPrivateChat)
|
||||
groupRouterGroup.POST("/remove_member", group.RemoveUser)
|
||||
groupRouterGroup.POST("/ban_group_private_chat", group.BanPrivateChat)
|
||||
groupRouterGroup.POST("/open_group_private_chat", group.OpenPrivateChat)
|
||||
groupRouterGroup.POST("/withdraw_message", group.Withdraw)
|
||||
groupRouterGroup.POST("/search_group_message", group.SearchMessage)
|
||||
groupRouterGroup.POST("/ban_group_chat", group.BanGroupChat)
|
||||
groupRouterGroup.POST("/open_group_chat", group.OpenGroupChat)
|
||||
}
|
||||
userRouterGroup := router.Group("/user")
|
||||
{
|
||||
|
||||
@@ -1,18 +1,24 @@
|
||||
package statistics
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/cms_api_struct"
|
||||
"github.com/gin-gonic/gin"
|
||||
statisticsPb "Open_IM/pkg/proto/statistics"
|
||||
)
|
||||
|
||||
func MessagesStatistics(c *gin.Context) {
|
||||
func GetMessagesStatistics(c *gin.Context) {
|
||||
var (
|
||||
req cms_api_struct.GetGroupMembersRequest
|
||||
resp cms_api_struct.GetGroupMembersResponse
|
||||
reqPb statisticsPb.GetMessageStatisticsReq
|
||||
)
|
||||
}
|
||||
|
||||
func GetUsersStatistics(c *gin.Context) {
|
||||
|
||||
}
|
||||
|
||||
func UsersStatistics(c *gin.Context) {
|
||||
|
||||
}
|
||||
|
||||
func GroupsStatistics(c *gin.Context) {
|
||||
func GetGroupsStatistics(c *gin.Context) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
+34
-18
@@ -640,6 +640,28 @@ func (s *groupServer) TransferGroupOwner(_ context.Context, req *pbGroup.Transfe
|
||||
|
||||
}
|
||||
|
||||
func (s *groupServer) GetGroupById(_ context.Context, req *pbGroup.GetGroupByIdReq) (*pbGroup.GetGroupByIdResp, error) {
|
||||
log.NewInfo(req.OperationID, "GetGroup ", req.String())
|
||||
resp := &pbGroup.GetGroupByIdResp{}
|
||||
group, err := imdb.GetGroupsById(req.GroupId)
|
||||
if err != nil {
|
||||
return resp, err
|
||||
}
|
||||
resp.GroupInfo = &open_im_sdk.GroupInfo{
|
||||
GroupID: group.GroupID,
|
||||
GroupName: group.GroupName,
|
||||
FaceURL: group.FaceUrl,
|
||||
OwnerUserID: group.CreatorUserID,
|
||||
MemberCount: 0,
|
||||
Status: group.Status,
|
||||
CreatorUserID: group.CreatorUserID,
|
||||
GroupType: group.GroupType,
|
||||
}
|
||||
|
||||
resp.GroupInfo.CreatorUserID = group.CreatorUserID
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (s *groupServer) GetGroup(_ context.Context, req *pbGroup.GetGroupReq) (*pbGroup.GetGroupResp, error) {
|
||||
log.NewInfo(req.OperationID, "GetGroup ", req.String())
|
||||
resp := &pbGroup.GetGroupResp{
|
||||
@@ -649,6 +671,10 @@ func (s *groupServer) GetGroup(_ context.Context, req *pbGroup.GetGroupReq) (*pb
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp.Pagination = &open_im_sdk.RequestPagination{
|
||||
PageNumber: req.Pagination.PageNumber,
|
||||
ShowNumber: req.Pagination.ShowNumber,
|
||||
}
|
||||
for _, v := range groups {
|
||||
resp.GroupInfo = append(resp.GroupInfo, &open_im_sdk.GroupInfo{
|
||||
GroupID: v.GroupID,
|
||||
@@ -659,7 +685,6 @@ func (s *groupServer) GetGroup(_ context.Context, req *pbGroup.GetGroupReq) (*pb
|
||||
CreatorUserID: v.CreatorUserID,
|
||||
})
|
||||
}
|
||||
utils.CopyStructFields(resp.GroupInfo, groups)
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
@@ -695,26 +720,17 @@ func (s *groupServer) GetGroups(_ context.Context, req *pbGroup.GetGroupsReq) (*
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (s *groupServer) BanGroupChat(_ context.Context, req *pbGroup.BanGroupChatReq) (*pbGroup.BanGroupChatResp, error) {
|
||||
log.NewInfo(req.OperationID, "BanGroupChat ", req.String())
|
||||
resp := &pbGroup.BanGroupChatResp{}
|
||||
if err := imdb.BanGroupChat(req.GroupId); err != nil {
|
||||
return resp, err
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (s *groupServer) BanPrivateChat(_ context.Context, req *pbGroup.BanPrivateChatReq) (*pbGroup.BanPrivateChatResp, error) {
|
||||
log.NewInfo(req.OperationID, "BanPrivateChat ", req.String())
|
||||
resp := &pbGroup.BanPrivateChatResp{}
|
||||
if err := imdb.BanPrivateChat(req.GroupId); err != nil {
|
||||
func (s *groupServer) OperateGroupStatus(_ context.Context, req *pbGroup.OperateGroupStatusReq) (*pbGroup.OperateGroupStatusResp, error) {
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req.String())
|
||||
resp := &pbGroup.OperateGroupStatusResp{}
|
||||
if err := imdb.OperateGroupStatus(req.GroupId, req.Status); err != nil {
|
||||
return resp, err
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (s *groupServer) DeleteGroup(_ context.Context, req *pbGroup.DeleteGroupReq) (*pbGroup.DeleteGroupResp, error) {
|
||||
log.NewInfo(req.OperationID, "DeleteGroup ", req.String())
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req.String())
|
||||
resp := &pbGroup.DeleteGroupResp{}
|
||||
if err := imdb.DeleteGroup(req.GroupId); err != nil {
|
||||
return resp, err
|
||||
@@ -722,10 +738,10 @@ func (s *groupServer) DeleteGroup(_ context.Context, req *pbGroup.DeleteGroupReq
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (s *groupServer) SetMaster(_ context.Context, req *pbGroup.SetMasterReq) (*pbGroup.SetMasterResp, error) {
|
||||
func (s *groupServer) OperateUserRole(_ context.Context, req *pbGroup.OperateUserRoleReq) (*pbGroup.OperateUserRoleResp, error) {
|
||||
log.NewInfo(req.OperationID, "DeleteGroup ", req.String())
|
||||
resp := &pbGroup.SetMasterResp{}
|
||||
if err := imdb.SetGroupMaster(req.UserId, req.GroupId); err != nil {
|
||||
resp := &pbGroup.OperateUserRoleResp{}
|
||||
if err := imdb.OperateGroupRole(req.UserId, req.GroupId, req.RoleLevel); err != nil {
|
||||
return resp, err
|
||||
}
|
||||
return resp, nil
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
package statistics
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
//"Open_IM/pkg/common/constant"
|
||||
//"Open_IM/pkg/common/db"
|
||||
//imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||
"Open_IM/pkg/common/log"
|
||||
//cp "Open_IM/pkg/common/utils"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbStatistics "Open_IM/pkg/proto/statistics"
|
||||
//open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||
"Open_IM/pkg/utils"
|
||||
//"context"
|
||||
"net"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
type statisticsServer struct {
|
||||
rpcPort int
|
||||
rpcRegisterName string
|
||||
etcdSchema string
|
||||
etcdAddr []string
|
||||
}
|
||||
|
||||
func NewStatisticsGroupServer(port int) *statisticsServer {
|
||||
log.NewPrivateLog("group")
|
||||
return &statisticsServer{
|
||||
rpcPort: port,
|
||||
rpcRegisterName: config.Config.RpcRegisterName.OpenImGroupName,
|
||||
etcdSchema: config.Config.Etcd.EtcdSchema,
|
||||
etcdAddr: config.Config.Etcd.EtcdAddr,
|
||||
}
|
||||
}
|
||||
|
||||
func (s *statisticsServer) Run() {
|
||||
log.NewInfo("0", "group rpc start ")
|
||||
ip := utils.ServerIP
|
||||
registerAddress := ip + ":" + strconv.Itoa(s.rpcPort)
|
||||
//listener network
|
||||
listener, err := net.Listen("tcp", registerAddress)
|
||||
if err != nil {
|
||||
log.NewError("0", "Listen failed ", err.Error(), registerAddress)
|
||||
return
|
||||
}
|
||||
log.NewInfo("0", "listen network success, ", registerAddress, listener)
|
||||
defer listener.Close()
|
||||
//grpc server
|
||||
srv := grpc.NewServer()
|
||||
defer srv.GracefulStop()
|
||||
//Service registers with etcd
|
||||
pbStatistics.RegisterUserServer(srv, s)
|
||||
err = getcdv3.RegisterEtcd(s.etcdSchema, strings.Join(s.etcdAddr, ","), ip, s.rpcPort, s.rpcRegisterName, 10)
|
||||
if err != nil {
|
||||
log.NewError("0", "RegisterEtcd failed ", err.Error())
|
||||
return
|
||||
}
|
||||
err = srv.Serve(listener)
|
||||
if err != nil {
|
||||
log.NewError("0", "Serve failed ", err.Error())
|
||||
return
|
||||
}
|
||||
log.NewInfo("0", "group rpc success")
|
||||
}
|
||||
@@ -250,11 +250,16 @@ func (s *userServer) GetUser(ctx context.Context, req *pbUser.GetUserReq) (*pbUs
|
||||
if err != nil {
|
||||
return resp, nil
|
||||
}
|
||||
isBlock, err := imdb.UserIsBlock(req.UserId)
|
||||
if err != nil {
|
||||
return resp, err
|
||||
}
|
||||
resp.User = &pbUser.User{
|
||||
ProfilePhoto: user.FaceURL,
|
||||
Nickname: user.Nickname,
|
||||
UserId: user.UserID,
|
||||
CreateTime: user.CreateTime.String(),
|
||||
IsBlock: isBlock,
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user