pull/131/head
wangchuxiao 3 years ago
parent d58bcd136a
commit 1607853393

@ -1 +1,15 @@
package open_im_cms_api
package main
import (
"Open_IM/internal/cms_api"
"Open_IM/pkg/utils"
"github.com/gin-gonic/gin"
)
func main() {
gin.SetMode(gin.ReleaseMode)
router := cms_api.NewGinRouter()
router.Use(utils.CorsHandler())
router.Run(":" + "8000")
}

@ -8,7 +8,7 @@ etcd:
etcdAddr: [ 127.0.0.1:2379 ]
mysql:
dbMysqlAddress: [ 127.0.0.1:13306 ]
dbMysqlAddress: [ 43.128.5.63:13306 ]
dbMysqlUserName: root
dbMysqlPassword: openIM
dbMysqlDatabaseName: openIM
@ -19,7 +19,7 @@ mysql:
dbMaxLifeTime: 120
mongo:
dbAddress: [ 127.0.0.1:37017 ]
dbAddress: [ 43.128.5.63:37017 ]
dbDirect: false
dbTimeout: 10
dbDatabase: openIM
@ -70,6 +70,8 @@ endpoints:
api:
openImApiPort: [ 10000 ]
cmsapi:
openImCMSPort: [ 8000 ]
sdk:
openImSdkWsPort: [ 30000 ]

@ -47,6 +47,7 @@ require (
golang.org/x/image v0.0.0-20210220032944-ac19c3e999fb
golang.org/x/net v0.0.0-20210917221730-978cfadd31cf
google.golang.org/grpc v1.40.0
google.golang.org/protobuf v1.27.1
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22

@ -1,21 +1,15 @@
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) {

@ -1,10 +1,6 @@
package message
import (
"net/http"
"Open_IM_CMS/test"
"github.com/gin-gonic/gin"
)
@ -13,13 +9,11 @@ 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) {

@ -1,52 +1,19 @@
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) {

@ -8,10 +8,10 @@ import (
"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()
@ -70,7 +70,7 @@ func NewGinRouter() *gin.Engine {
groupRouterGroup.POST("/withdraw_message", group.Withdraw)
groupRouterGroup.POST("/search_group_message", group.SearchMessage)
}
userRouterGroup := router.Group("/users")
userRouterGroup := router.Group("/user")
{
userRouterGroup.POST("/resign", user.ResignUser)
userRouterGroup.GET("/get_user", user.GetUser)

@ -1,80 +1,25 @@
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})
}

@ -1,76 +1,216 @@
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/constant"
openIMHttp "Open_IM/pkg/common/http"
"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"
commonPb "Open_IM/pkg/proto/sdk_ws"
pb "Open_IM/pkg/proto/user"
"Open_IM/pkg/utils"
"context"
"github.com/gin-gonic/gin"
"fmt"
"net/http"
"strings"
"github.com/gin-gonic/gin"
)
func GetUser(c *gin.Context) {
var (
req cms_api_struct.RequestPagination
resp cms_api_struct.GetUsersResponse
reqPb rpc.GetUserInfoReq
respPb *rpc.GetUserInfoResp
req cms_api_struct.GetUserRequest
resp cms_api_struct.GetUserResponse
reqPb pb.GetUserReq
respPb *pb.GetUserResp
)
if err := c.BindJSON(&req); err != nil {
if err := c.ShouldBindQuery(&req); err != nil {
log.NewError("0", "BindJSON failed ", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": http.StatusBadRequest, "errMsg": err.Error()})
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
utils.CopyStructFields(req, &req)
utils.CopyStructFields(&reqPb, 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)
client := pb.NewUserClient(etcdConn)
respPb, err := client.GetUser(context.Background(), &reqPb)
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call rpc server failed"})
log.NewError("s", "GetUserInfo failed ", err.Error())
openIMHttp.RespHttp200(c, err.(constant.ErrInfo), nil)
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)
// resp.UserId = resp.UserId
// resp.Nickname = resp.UserId
// resp.ProfilePhoto = resp.ProfilePhoto
// resp.UserResponse =
utils.CopyStructFields(&resp, respPb)
openIMHttp.RespHttp200(c, constant.OK, resp)
}
func ResignUser(c *gin.Context) {
func GetUsers(c *gin.Context) {
var (
req cms_api_struct.GetUsersRequest
resp cms_api_struct.GetUsersResponse
reqPb pb.GetUsersReq
respPb *pb.GetUsersResp
)
reqPb.Pagination = &commonPb.RequestPagination{}
if err := c.ShouldBindQuery(&req); err != nil {
log.NewError("0", "BindJSON failed ", err.Error())
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
utils.CopyStructFields(&reqPb.Pagination, &req)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
client := pb.NewUserClient(etcdConn)
respPb, err := client.GetUsers(context.Background(), &reqPb)
for _, v := range respPb.User {
resp.Users = append(resp.Users, &cms_api_struct.UserResponse{
ProfilePhoto: v.ProfilePhoto,
Nickname: v.Nickname,
UserId: v.UserID,
CreateTime: v.CreateTime,
})
}
if err != nil {
openIMHttp.RespHttp200(c, err.(constant.ErrInfo), resp)
}
fmt.Println(resp)
openIMHttp.RespHttp200(c, constant.OK, resp)
}
func ResignUser(c *gin.Context) {
var (
req cms_api_struct.ResignUserRequest
resp cms_api_struct.ResignUserResponse
reqPb pb.ResignUserReq
)
if err := c.ShouldBind(&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(&reqPb, &req)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
client := pb.NewUserClient(etcdConn)
_, err := client.ResignUser(context.Background(), &reqPb)
if err != nil {
openIMHttp.RespHttp200(c, constant.ErrDB, resp)
}
openIMHttp.RespHttp200(c, constant.OK, resp)
}
func AlterUser(c *gin.Context) {
var (
req cms_api_struct.AlterUserRequest
resp cms_api_struct.AlterUserResponse
reqPb pb.AlterUserReq
respPb *pb.AlterUserResp
)
if err := c.ShouldBind(&req); err != nil {
log.NewError("0", "BindJSON failed ", err.Error())
openIMHttp.RespHttp200(c, constant.ErrArgs, resp)
return
}
utils.CopyStructFields(&reqPb, &req)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
client := pb.NewUserClient(etcdConn)
respPb, err := client.AlterUser(context.Background(), &reqPb)
fmt.Println(respPb)
if err != nil {
openIMHttp.RespHttp200(c, err.(constant.ErrInfo), resp)
}
openIMHttp.RespHttp200(c, constant.OK, resp)
}
func AddUser(c *gin.Context) {
var (
req cms_api_struct.AddUserRequest
resp cms_api_struct.AddUserResponse
reqPb pb.AddUserReq
respPb *pb.AddUserResp
)
if err := c.ShouldBind(&req); err != nil {
log.NewError("0", "BindJSON failed ", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": http.StatusBadRequest, "errMsg": err.Error()})
return
}
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
client := pb.NewUserClient(etcdConn)
respPb, err := client.AddUser(context.Background(), &reqPb)
fmt.Println(respPb)
if err != nil {
}
openIMHttp.RespHttp200(c, constant.OK, resp)
}
func BlockUser(c *gin.Context) {
var (
req cms_api_struct.BlockUserRequest
resp cms_api_struct.BlockUserResponse
reqPb pb.BlockUserReq
respPb *pb.BlockUserResp
)
if err := c.ShouldBind(&req); err != nil {
log.NewError("0", "BindJSON failed ", err.Error())
openIMHttp.RespHttp200(c, constant.ErrArgs, resp)
return
}
utils.CopyStructFields(&reqPb, req)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
client := pb.NewUserClient(etcdConn)
respPb, err := client.BlockUser(context.Background(), &reqPb)
if err != nil {
openIMHttp.RespHttp200(c, err.(constant.ErrInfo), resp)
}
fmt.Println(respPb)
openIMHttp.RespHttp200(c, constant.OK, resp)
}
func UnblockUser(c *gin.Context) {
var (
req cms_api_struct.UnblockUserRequest
resp cms_api_struct.UnBlockUserResponse
reqPb pb.UnBlockUserReq
respPb *pb.UnBlockUserResp
)
utils.CopyStructFields(&reqPb, req)
if err := c.ShouldBind(&req); err != nil {
log.NewError("0", "BindJSON failed ", err.Error())
c.JSON(http.StatusBadRequest, gin.H{"errCode": http.StatusBadRequest, "errMsg": err.Error()})
return
}
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
client := pb.NewUserClient(etcdConn)
respPb, err := client.UnBlockUser(context.Background(), &reqPb)
if err != nil {
openIMHttp.RespHttp200(c, err.(constant.ErrInfo), resp)
}
fmt.Println(respPb)
openIMHttp.RespHttp200(c, constant.OK, resp)
}
func GetBlockUsers(c *gin.Context) {
var (
req cms_api_struct.GetBlockUsersRequest
resp cms_api_struct.GetOrganizationsResponse
reqPb pb.GetBlockUsersReq
respPb *pb.GetBlockUsersResp
)
if err := c.ShouldBindQuery(&req); err != nil {
log.NewError("0", "BindJSON failed ", err.Error())
openIMHttp.RespHttp200(c, constant.ErrArgs, resp)
return
}
utils.CopyStructFields(&reqPb, &req)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
client := pb.NewUserClient(etcdConn)
respPb, err := client.GetBlockUsers(context.Background(), &reqPb)
if err != nil {
openIMHttp.RespHttp200(c, err.(constant.ErrInfo), resp)
}
fmt.Println(respPb)
openIMHttp.RespHttp200(c, constant.OK, resp)
}

@ -14,10 +14,11 @@ import (
pbUser "Open_IM/pkg/proto/user"
"Open_IM/pkg/utils"
"context"
"google.golang.org/grpc"
"net"
"strconv"
"strings"
"google.golang.org/grpc"
)
type userServer struct {
@ -240,3 +241,63 @@ func (s *userServer) UpdateUserInfo(ctx context.Context, req *pbUser.UpdateUserI
chat.UserInfoUpdatedNotification(req.OperationID, req.UserInfo.UserID, req.OpUserID)
return &pbUser.UpdateUserInfoResp{CommonResp: &pbUser.CommonResp{}}, nil
}
func (s *userServer) GetUser(ctx context.Context, req *pbUser.GetUserReq) (*pbUser.GetUserResp, error) {
log.NewInfo(req.OperationID, "GetAllUserID args ", req.String())
resp := &pbUser.GetUserResp{}
user, err := imdb.GetUserByUserID(req.UserId)
if err != nil {
log.NewError(req.OperationID, "SelectAllUserID false ", err.Error())
return resp, nil
}
resp.User.CreateTime = user.CreateTime.String()
resp.User.ProfilePhoto = ""
resp.User.Nickname = user.Nickname
resp.User.UserID = user.UserID
return resp, nil
}
func (s *userServer) GetUsers(ctx context.Context, req *pbUser.GetUsersReq) (*pbUser.GetUsersResp, error) {
log.NewInfo(req.OperationID, "GetUsers args ", req.String())
resp := &pbUser.GetUsersResp{}
users, err := imdb.GetUsers(req.Pagination.ShowNumber, req.Pagination.PageNumber)
if err != nil {
log.NewError(req.OperationID, "SelectAllUserID false ", err.Error())
return resp, nil
}
for _, v := range users {
resp.User = append(resp.User, &pbUser.User{
ProfilePhoto: "",
UserID: v.UserID,
CreateTime: v.CreateTime.String(),
Nickname: v.Nickname,
})
}
return resp, nil
}
func (s *userServer) ResignUser(ctx context.Context, req *pbUser.ResignUserReq) (*pbUser.ResignUserResp, error) {
log.NewInfo(req.OperationID, "ResignUser args ", req.String())
return &pbUser.ResignUserResp{}, nil
}
func (s *userServer) AlterUser(ctx context.Context, req *pbUser.AlterUserReq) (*pbUser.AlterUserResp, error) {
return &pbUser.AlterUserResp{}, nil
}
func (s *userServer) AddUser(ctx context.Context, req *pbUser.AddUserReq) (*pbUser.AddUserResp, error) {
return &pbUser.AddUserResp{}, nil
}
func (s *userServer) BlockUser(ctx context.Context, req *pbUser.BlockUserReq) (*pbUser.BlockUserResp, error) {
return &pbUser.BlockUserResp{}, nil
}
func (s *userServer) UnBlockUser(ctx context.Context, req *pbUser.UnBlockUserReq) (*pbUser.UnBlockUserResp, error) {
return &pbUser.UnBlockUserResp{}, nil
}
func (s *userServer) GetBlockUsers(ctx context.Context, req *pbUser.GetBlockUsersReq) (*pbUser.GetBlockUsersResp, error) {
return &pbUser.GetBlockUsersResp{}, nil
}

@ -1,10 +1,6 @@
package cms_api_struct
type RequestPagination struct {
PageNumber int `json:"page_number"`
ShowNumber int `json:"show_number"`
PageNumber int `form:"page_number" binding:"required"`
ShowNumber int `form:"show_number" binding:"required"`
}

@ -1,7 +1,65 @@
package cms_api_struct
type UserResponse struct {
ProfilePhoto string `json:"profile_photo"`
Nickname string `json:"nick_name"`
UserId string `json:"user_id"`
CreateTime string `json:"create_time"`
}
type GetUserRequest struct {
UserId string `form:"user_id"`
}
type GetUserResponse struct {
UserResponse
}
type GetUsersRequest struct {
RequestPagination
}
type GetUsersResponse struct {
Users []*UserResponse `json:"users"`
}
type ResignUserRequest struct {
UserId string `json:"user_id"`
}
type ResignUserResponse struct {
}
type AlterUserRequest struct {
UserId string `json:"user_id"`
}
type AlterUserResponse struct {
}
type AddUserRequest struct {
}
type AddUserResponse struct {
}
type BlockUserRequest struct {
UserId string `json:"user_id"`
}
type BlockUserResponse struct {
}
type UnblockUserRequest struct {
UserId string `json:"user_id"`
}
type UnBlockUserResponse struct {
}
type GetBlockUsersRequest struct {
RequestPagination
}
type GetBlockUsersResponse struct {
}

@ -78,6 +78,10 @@ const (
IntentionalError = 10007
)
func (e *ErrInfo) Error() string {
func (e ErrInfo) Error() string {
return e.ErrMsg
}
func (e *ErrInfo) Code() int32 {
return e.ErrCode
}

@ -6,8 +6,9 @@ import (
"Open_IM/pkg/common/db"
"Open_IM/pkg/utils"
"fmt"
_ "github.com/jinzhu/gorm/dialects/mysql"
"time"
_ "github.com/jinzhu/gorm/dialects/mysql"
)
func init() {
@ -50,17 +51,17 @@ func UserRegister(user db.User) error {
return nil
}
//type User struct {
// UserID string `gorm:"column:user_id;primaryKey;"`
// Nickname string `gorm:"column:name"`
// FaceUrl string `gorm:"column:icon"`
// Gender int32 `gorm:"column:gender"`
// PhoneNumber string `gorm:"column:phone_number"`
// Birth string `gorm:"column:birth"`
// Email string `gorm:"column:email"`
// Ex string `gorm:"column:ex"`
// CreateTime time.Time `gorm:"column:create_time"`
//}
type User struct {
UserID string `gorm:"column:user_id;primaryKey;"`
Nickname string `gorm:"column:name"`
FaceUrl string `gorm:"column:icon"`
Gender int32 `gorm:"column:gender"`
PhoneNumber string `gorm:"column:phone_number"`
Birth string `gorm:"column:birth"`
Email string `gorm:"column:email"`
Ex string `gorm:"column:ex"`
CreateTime time.Time `gorm:"column:create_time"`
}
func DeleteUser(userID string) (i int64) {
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
@ -121,3 +122,17 @@ func SelectSomeUserID(userIDList []string) ([]string, error) {
}
return resultArr, nil
}
func GetUsers(showNumber, pageNumber int32) ([]User, error) {
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
dbConn.LogMode(true)
var users []User
if err != nil {
return users, err
}
err = dbConn.Limit(showNumber).Offset(pageNumber).Find(&users).Error
if err != nil {
return users, err
}
return users, nil
}

@ -1 +1,23 @@
package http
import (
"Open_IM/pkg/common/constant"
"net/http"
"github.com/gin-gonic/gin"
)
type BaseResp struct {
Code int32 `json:"code"`
ErrMsg string `json:"err_msg"`
Data interface{} `json:"data"`
}
func RespHttp200(ctx *gin.Context, err constant.ErrInfo, data interface{}) {
resp := BaseResp{
Code: err.Code(),
ErrMsg: err.Error(),
Data: data,
}
ctx.JSON(http.StatusOK, resp)
}

@ -7,7 +7,7 @@ for ((i = 0; i < ${#all_proto[*]}; i++)); do
protoc -I ../../../ -I ./ --go_out=plugins=grpc:. $proto
s=`echo $proto | sed 's/ //g'`
v=${s//proto/pb.go}
protoc-go-inject-tag -input=./$v
# protoc-go-inject-tag -input=./$v
echo "protoc --go_out=plugins=grpc:." $proto
done
echo "proto file generate success..."

@ -1,11 +1,11 @@
all_proto=(
auth/auth.proto
friend/friend.proto
group/group.proto
# auth/auth.proto
# friend/friend.proto
# group/group.proto
user/user.proto
chat/chat.proto
push/push.proto
relay/relay.proto
# chat/chat.proto
# push/push.proto
# relay/relay.proto
sdk_ws/ws.proto
)

File diff suppressed because it is too large Load Diff

@ -1,4 +1,5 @@
syntax = "proto3";
option go_package = "./sdk_ws;server_api_params";
package server_api_params;//The package name to which the proto file belongs
//option go_package = "./sdk_ws;open_im_sdk";//The generated go pb file is in the current directory, and the package name is open_im_sdk
@ -330,3 +331,9 @@ message FriendInfoChangedTips{
message UserInfoUpdatedTips{
string userID = 1;
}
///cms
message RequestPagination {
int32 pageNumber = 1;
int32 showNumber = 2;
}

File diff suppressed because it is too large Load Diff

@ -13,6 +13,7 @@ message DeleteUsersReq{
string OpUserID = 3;
string OperationID = 4;
}
message DeleteUsersResp{
CommonResp CommonResp = 1;
repeated string FailedUserIDList = 2;
@ -121,11 +122,14 @@ message GetUserReq{
}
message User{
string ProfilePhoto = 1;
string Nickname = 2;
string UserID = 3;
string CreateTime = 4;
}
message GetUserResp{
User user = 1
User user = 1;
}
message AlterUserReq{
@ -134,16 +138,17 @@ message AlterUserReq{
}
message AlterUserResp{
CommonResp commonResp = 1;
CommonResp CommonResp = 1;
}
message GetUserReq{
message GetUsersReq {
string OperationID = 1;
server_api_params.RequestPagination Pagination = 2;
}
message GetUsersResp{
string OperationID = 1;
repeated Users User = 2;
repeated User user = 2;
}
message AddUserReq{
@ -151,9 +156,36 @@ message AddUserReq{
}
message AddUserResp{
CommonResp commonResp = 1;
}
message BlockUserReq{
string UserID = 1;
string OperationID = 2;
}
message BlockUserResp{
}
message UnBlockUserReq{
string UserID = 1;
string OperationID = 2;
}
message UnBlockUserResp{
}
message GetBlockUsersReq{
server_api_params.RequestPagination Pagination =1;
string OperationID = 2;
}
message GetBlockUsersResp{
repeated User user = 2;
}
service user {
rpc GetUserInfo(GetUserInfoReq) returns(GetUserInfoResp);
rpc UpdateUserInfo(UpdateUserInfoReq) returns(UpdateUserInfoResp);
@ -164,8 +196,8 @@ service user {
rpc GetAllConversationMsgOpt(GetAllConversationMsgOptReq)returns(GetAllConversationMsgOptResp);
rpc AccountCheck(AccountCheckReq)returns(AccountCheckResp);
rpc ResignUser(ResignUserReq) returns (ResignUserResp);
rpc GetUser(GetUserReq) returns (GetUserResp);
rpc ResignUser(ResignUserReq) returns (ResignUserResp);
rpc AlterUser(AlterUserReq) returns (AlterUserResp);
rpc GetUsers(GetUsersReq) returns (GetUsersResp);
rpc AddUser(AddUserReq) returns (AddUserResp);

Loading…
Cancel
Save