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/rpc/user/user.go

460 lines
19 KiB

3 years ago
package user
import (
chat "Open_IM/internal/rpc/msg"
"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"
3 years ago
errors "Open_IM/pkg/common/http"
3 years ago
"Open_IM/pkg/common/log"
"Open_IM/pkg/common/token_verify"
"Open_IM/pkg/grpc-etcdv3/getcdv3"
pbFriend "Open_IM/pkg/proto/friend"
3 years ago
sdkws "Open_IM/pkg/proto/sdk_ws"
3 years ago
pbUser "Open_IM/pkg/proto/user"
"Open_IM/pkg/utils"
"context"
3 years ago
"fmt"
3 years ago
"net"
"strconv"
"strings"
3 years ago
"google.golang.org/grpc"
3 years ago
)
type userServer struct {
rpcPort int
rpcRegisterName string
etcdSchema string
etcdAddr []string
}
3 years ago
func NewUserServer(port int) *userServer {
log.NewPrivateLog("user")
return &userServer{
rpcPort: port,
rpcRegisterName: config.Config.RpcRegisterName.OpenImUserName,
etcdSchema: config.Config.Etcd.EtcdSchema,
etcdAddr: config.Config.Etcd.EtcdAddr,
}
}
3 years ago
func (s *userServer) Run() {
log.NewInfo("0", "", "rpc user 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 network failed ", err.Error(), registerAddress)
return
}
3 years ago
log.NewInfo("0", "listen network success, address ", registerAddress, listener)
3 years ago
defer listener.Close()
//grpc server
srv := grpc.NewServer()
defer srv.GracefulStop()
//Service registers with etcd
pbUser.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(), s.etcdSchema, strings.Join(s.etcdAddr, ","), ip, s.rpcPort, s.rpcRegisterName)
return
}
err = srv.Serve(listener)
if err != nil {
log.NewError("0", "Serve failed ", err.Error())
return
}
3 years ago
log.NewInfo("0", "rpc user success")
3 years ago
}
func (s *userServer) GetUserInfo(ctx context.Context, req *pbUser.GetUserInfoReq) (*pbUser.GetUserInfoResp, error) {
log.NewInfo(req.OperationID, "GetUserInfo args ", req.String())
var userInfoList []*sdkws.UserInfo
if len(req.UserIDList) > 0 {
for _, userID := range req.UserIDList {
var userInfo sdkws.UserInfo
user, err := imdb.GetUserByUserID(userID)
if err != nil {
log.NewError(req.OperationID, "GetUserByUserID failed ", err.Error(), userID)
continue
}
utils.CopyStructFields(&userInfo, user)
3 years ago
userInfo.Birth = uint32(user.Birth.Unix())
3 years ago
userInfoList = append(userInfoList, &userInfo)
}
} else {
return &pbUser.GetUserInfoResp{CommonResp: &pbUser.CommonResp{ErrCode: constant.ErrArgs.ErrCode, ErrMsg: constant.ErrArgs.ErrMsg}}, nil
}
3 years ago
log.NewInfo(req.OperationID, "GetUserInfo rpc return ", pbUser.GetUserInfoResp{CommonResp: &pbUser.CommonResp{}, UserInfoList: userInfoList})
return &pbUser.GetUserInfoResp{CommonResp: &pbUser.CommonResp{}, UserInfoList: userInfoList}, nil
3 years ago
}
func (s *userServer) SetReceiveMessageOpt(ctx context.Context, req *pbUser.SetReceiveMessageOptReq) (*pbUser.SetReceiveMessageOptResp, error) {
log.NewInfo(req.OperationID, "SetReceiveMessageOpt args ", req.String())
m := make(map[string]int, len(req.ConversationIDList))
for _, v := range req.ConversationIDList {
m[v] = int(req.Opt)
}
err := db.DB.SetMultiConversationMsgOpt(req.FromUserID, m)
if err != nil {
log.NewError(req.OperationID, "SetMultiConversationMsgOpt failed ", err.Error(), req)
return &pbUser.SetReceiveMessageOptResp{CommonResp: &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
}
resp := pbUser.SetReceiveMessageOptResp{CommonResp: &pbUser.CommonResp{}}
for _, v := range req.ConversationIDList {
resp.ConversationOptResultList = append(resp.ConversationOptResultList, &pbUser.OptResult{ConversationID: v, Result: req.Opt})
3 years ago
}
3 years ago
chat.SetReceiveMessageOptNotification(req.OperationID, req.OpUserID, req.FromUserID)
3 years ago
log.NewInfo(req.OperationID, "SetReceiveMessageOpt rpc return ", resp.String())
return &resp, nil
}
func (s *userServer) GetReceiveMessageOpt(ctx context.Context, req *pbUser.GetReceiveMessageOptReq) (*pbUser.GetReceiveMessageOptResp, error) {
log.NewInfo(req.OperationID, "GetReceiveMessageOpt args ", req.String())
m, err := db.DB.GetMultiConversationMsgOpt(req.FromUserID, req.ConversationIDList)
3 years ago
if err != nil {
log.NewError(req.OperationID, "GetMultiConversationMsgOpt failed ", err.Error(), req.FromUserID, req.ConversationIDList)
3 years ago
return &pbUser.GetReceiveMessageOptResp{CommonResp: &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
}
resp := pbUser.GetReceiveMessageOptResp{CommonResp: &pbUser.CommonResp{}}
for k, v := range m {
resp.ConversationOptResultList = append(resp.ConversationOptResultList, &pbUser.OptResult{ConversationID: k, Result: int32(v)})
3 years ago
}
log.NewInfo(req.OperationID, "GetReceiveMessageOpt rpc return ", resp.String())
return &resp, nil
}
func (s *userServer) GetAllConversationMsgOpt(ctx context.Context, req *pbUser.GetAllConversationMsgOptReq) (*pbUser.GetAllConversationMsgOptResp, error) {
log.NewInfo(req.OperationID, "GetAllConversationMsgOpt args ", req.String())
m, err := db.DB.GetAllConversationMsgOpt(req.FromUserID)
3 years ago
if err != nil {
log.NewError(req.OperationID, "GetAllConversationMsgOpt failed ", err.Error(), req.FromUserID)
3 years ago
return &pbUser.GetAllConversationMsgOptResp{CommonResp: &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
}
resp := pbUser.GetAllConversationMsgOptResp{CommonResp: &pbUser.CommonResp{}}
for k, v := range m {
resp.ConversationOptResultList = append(resp.ConversationOptResultList, &pbUser.OptResult{ConversationID: k, Result: int32(v)})
3 years ago
}
log.NewInfo(req.OperationID, "GetAllConversationMsgOpt rpc return ", resp.String())
return &resp, nil
}
func (s *userServer) DeleteUsers(_ context.Context, req *pbUser.DeleteUsersReq) (*pbUser.DeleteUsersResp, error) {
log.NewInfo(req.OperationID, "DeleteUsers args ", req.String())
if !token_verify.IsMangerUserID(req.OpUserID) {
3 years ago
log.NewError(req.OperationID, "IsMangerUserID false ", req.OpUserID)
return &pbUser.DeleteUsersResp{CommonResp: &pbUser.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: constant.ErrAccess.ErrMsg}, FailedUserIDList: req.DeleteUserIDList}, nil
}
var common pbUser.CommonResp
resp := pbUser.DeleteUsersResp{CommonResp: &common}
for _, userID := range req.DeleteUserIDList {
3 years ago
i := imdb.DeleteUser(userID)
if i == 0 {
3 years ago
log.NewError(req.OperationID, "delete user error", userID)
3 years ago
common.ErrCode = 201
common.ErrMsg = "some uid deleted failed"
resp.FailedUserIDList = append(resp.FailedUserIDList, userID)
}
}
log.NewInfo(req.OperationID, "DeleteUsers rpc return ", resp.String())
return &resp, nil
}
func (s *userServer) GetAllUserID(_ context.Context, req *pbUser.GetAllUserIDReq) (*pbUser.GetAllUserIDResp, error) {
3 years ago
log.NewInfo(req.OperationID, "GetAllUserID args ", req.String())
if !token_verify.IsMangerUserID(req.OpUserID) {
3 years ago
log.NewError(req.OperationID, "IsMangerUserID false ", req.OpUserID)
return &pbUser.GetAllUserIDResp{CommonResp: &pbUser.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: constant.ErrAccess.ErrMsg}}, nil
}
uidList, err := imdb.SelectAllUserID()
if err != nil {
log.NewError(req.OperationID, "SelectAllUserID false ", err.Error())
return &pbUser.GetAllUserIDResp{CommonResp: &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
} else {
log.NewInfo(req.OperationID, "GetAllUserID rpc return ", pbUser.GetAllUserIDResp{CommonResp: &pbUser.CommonResp{}, UserIDList: uidList})
return &pbUser.GetAllUserIDResp{CommonResp: &pbUser.CommonResp{}, UserIDList: uidList}, nil
}
}
func (s *userServer) AccountCheck(_ context.Context, req *pbUser.AccountCheckReq) (*pbUser.AccountCheckResp, error) {
3 years ago
log.NewInfo(req.OperationID, "AccountCheck args ", req.String())
if !token_verify.IsMangerUserID(req.OpUserID) {
3 years ago
log.NewError(req.OperationID, "IsMangerUserID false ", req.OpUserID)
return &pbUser.AccountCheckResp{CommonResp: &pbUser.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: constant.ErrAccess.ErrMsg}}, nil
}
uidList, err := imdb.SelectSomeUserID(req.CheckUserIDList)
log.NewDebug(req.OperationID, "from db uid list is:", uidList)
3 years ago
if err != nil {
log.NewError(req.OperationID, "SelectSomeUserID failed ", err.Error(), req.CheckUserIDList)
return &pbUser.AccountCheckResp{CommonResp: &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
} else {
var r []*pbUser.AccountCheckResp_SingleUserStatus
for _, v := range req.CheckUserIDList {
temp := new(pbUser.AccountCheckResp_SingleUserStatus)
temp.UserID = v
if utils.IsContain(v, uidList) {
temp.AccountStatus = constant.Registered
} else {
temp.AccountStatus = constant.UnRegistered
}
r = append(r, temp)
}
resp := pbUser.AccountCheckResp{CommonResp: &pbUser.CommonResp{ErrCode: 0, ErrMsg: ""}, ResultList: r}
log.NewInfo(req.OperationID, "AccountCheck rpc return ", resp.String())
return &resp, nil
}
}
func (s *userServer) UpdateUserInfo(ctx context.Context, req *pbUser.UpdateUserInfoReq) (*pbUser.UpdateUserInfoResp, error) {
3 years ago
log.NewInfo(req.OperationID, "UpdateUserInfo args ", req.String())
if !token_verify.CheckAccess(req.OpUserID, req.UserInfo.UserID) {
3 years ago
log.NewError(req.OperationID, "CheckAccess false ", req.OpUserID, req.UserInfo.UserID)
return &pbUser.UpdateUserInfoResp{CommonResp: &pbUser.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: constant.ErrAccess.ErrMsg}}, nil
}
3 years ago
var user db.User
3 years ago
utils.CopyStructFields(&user, req.UserInfo)
3 years ago
if req.UserInfo.Birth != 0 {
3 years ago
user.Birth = utils.UnixSecondToTime(int64(req.UserInfo.Birth))
3 years ago
}
3 years ago
err := imdb.UpdateUserInfo(user)
if err != nil {
log.NewError(req.OperationID, "UpdateUserInfo failed ", err.Error(), user)
return &pbUser.UpdateUserInfoResp{CommonResp: &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
}
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
client := pbFriend.NewFriendClient(etcdConn)
newReq := &pbFriend.GetFriendListReq{
3 years ago
CommID: &pbFriend.CommID{OperationID: req.OperationID, FromUserID: req.UserInfo.UserID, OpUserID: req.OpUserID},
3 years ago
}
RpcResp, err := client.GetFriendList(context.Background(), newReq)
if err != nil {
log.NewError(req.OperationID, "GetFriendList failed ", err.Error(), newReq)
return &pbUser.UpdateUserInfoResp{CommonResp: &pbUser.CommonResp{}}, nil
}
3 years ago
for _, v := range RpcResp.FriendInfoList {
3 years ago
log.Info(req.OperationID, "UserInfoUpdatedNotification ", req.UserInfo.UserID, v.FriendUser.UserID)
3 years ago
chat.UserInfoUpdatedNotification(req.OperationID, req.UserInfo.UserID, v.FriendUser.UserID)
3 years ago
}
3 years ago
chat.UserInfoUpdatedNotification(req.OperationID, req.UserInfo.UserID, req.OpUserID)
3 years ago
log.Info(req.OperationID, "UserInfoUpdatedNotification ", req.UserInfo.UserID, req.OpUserID)
3 years ago
return &pbUser.UpdateUserInfoResp{CommonResp: &pbUser.CommonResp{}}, nil
}
3 years ago
3 years ago
func (s *userServer) GetUsersByName(ctx context.Context, req *pbUser.GetUsersByNameReq) (*pbUser.GetUsersByNameResp, error) {
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req:", req.String())
resp := &pbUser.GetUsersByNameResp{}
users, err := imdb.GetUserByName(req.UserName, req.Pagination.ShowNumber, req.Pagination.PageNumber)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUserByName failed", err.Error())
3 years ago
return resp, errors.WrapError(constant.ErrDB)
3 years ago
}
for _, user := range users {
isBlock, err := imdb.UserIsBlock(user.UserID)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
continue
}
resp.Users = append(resp.Users, &pbUser.User{
ProfilePhoto: user.FaceURL,
Nickname: user.Nickname,
UserId: user.UserID,
CreateTime: user.CreateTime.String(),
IsBlock: isBlock,
})
}
3 years ago
user := db.User{Nickname: req.UserName}
3 years ago
userNums, err := imdb.GetUsersCount(user)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "", err.Error())
3 years ago
return resp, errors.WrapError(constant.ErrDB)
3 years ago
}
resp.UserNums = userNums
resp.Pagination = &sdkws.ResponsePagination{
CurrentPage: req.Pagination.PageNumber,
ShowNumber: req.Pagination.ShowNumber,
}
3 years ago
return resp, nil
3 years ago
}
3 years ago
func (s *userServer) GetUserById(ctx context.Context, req *pbUser.GetUserByIdReq) (*pbUser.GetUserByIdResp, error) {
3 years ago
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req:", req.String())
3 years ago
resp := &pbUser.GetUserByIdResp{User: &pbUser.User{}}
3 years ago
user, err := imdb.GetUserByUserID(req.UserId)
if err != nil {
3 years ago
log.NewError(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
return resp, errors.WrapError(constant.ErrDB)
3 years ago
}
3 years ago
isBlock, err := imdb.UserIsBlock(req.UserId)
if err != nil {
3 years ago
log.NewError(req.OperationID, utils.GetSelfFuncName(), "req", req.String())
return resp, errors.WrapError(constant.ErrDB)
3 years ago
}
3 years ago
resp.User = &pbUser.User{
ProfilePhoto: user.FaceURL,
Nickname: user.Nickname,
UserId: user.UserID,
CreateTime: user.CreateTime.String(),
3 years ago
IsBlock: isBlock,
3 years ago
}
3 years ago
return resp, nil
}
func (s *userServer) GetUsers(ctx context.Context, req *pbUser.GetUsersReq) (*pbUser.GetUsersResp, error) {
3 years ago
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
3 years ago
resp := &pbUser.GetUsersResp{User: []*pbUser.User{}}
3 years ago
users, err := imdb.GetUsers(req.Pagination.ShowNumber, req.Pagination.PageNumber)
if err != nil {
3 years ago
return resp, errors.WrapError(constant.ErrDB)
3 years ago
}
for _, v := range users {
3 years ago
isBlock, err := imdb.UserIsBlock(v.UserID)
if err == nil {
user := &pbUser.User{
ProfilePhoto: v.FaceURL,
UserId: v.UserID,
CreateTime: v.CreateTime.String(),
Nickname: v.Nickname,
3 years ago
IsBlock: isBlock,
3 years ago
}
resp.User = append(resp.User, user)
}
3 years ago
}
3 years ago
user := db.User{}
3 years ago
nums, err := imdb.GetUsersCount(user)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUsersCount failed", err.Error())
3 years ago
return resp, errors.WrapError(constant.ErrDB)
3 years ago
}
resp.UserNums = nums
3 years ago
resp.Pagination = &sdkws.ResponsePagination{ShowNumber: req.Pagination.ShowNumber, CurrentPage: req.Pagination.PageNumber}
3 years ago
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) {
3 years ago
log.NewInfo(req.OperationID, "AlterUser args ", req.String())
3 years ago
resp := &pbUser.AlterUserResp{}
3 years ago
user := db.User{
3 years ago
PhoneNumber: strconv.FormatInt(req.PhoneNumber, 10),
Nickname: req.Nickname,
Email: req.Email,
UserID: req.UserId,
}
if err := imdb.UpdateUserInfo(user); err != nil {
3 years ago
log.NewError(req.OperationID, utils.GetSelfFuncName(), "UpdateUserInfo", err.Error())
return resp, errors.WrapError(constant.ErrDB)
3 years ago
}
3 years ago
chat.UserInfoUpdatedNotification(req.OperationID, req.UserId, req.OpUserId)
3 years ago
return resp, nil
3 years ago
}
func (s *userServer) AddUser(ctx context.Context, req *pbUser.AddUserReq) (*pbUser.AddUserResp, error) {
3 years ago
log.NewInfo(req.OperationID, "AddUser args ", req.String())
resp := &pbUser.AddUserResp{}
err := imdb.AddUser(req.UserId, req.PhoneNumber, req.Name)
if err != nil {
3 years ago
log.NewError(req.OperationID, utils.GetSelfFuncName(), "AddUser", err.Error())
return resp, errors.WrapError(constant.ErrDB)
3 years ago
}
return resp, nil
3 years ago
}
func (s *userServer) BlockUser(ctx context.Context, req *pbUser.BlockUserReq) (*pbUser.BlockUserResp, error) {
3 years ago
log.NewInfo(req.OperationID, "BlockUser args ", req.String())
fmt.Println("BlockUser args ", req.String())
resp := &pbUser.BlockUserResp{}
err := imdb.BlockUser(req.UserId, req.EndDisableTime)
if err != nil {
3 years ago
log.NewError(req.OperationID, utils.GetSelfFuncName(), "BlockUser", err.Error())
return resp, errors.WrapError(constant.ErrDB)
3 years ago
}
return resp, nil
3 years ago
}
func (s *userServer) UnBlockUser(ctx context.Context, req *pbUser.UnBlockUserReq) (*pbUser.UnBlockUserResp, error) {
3 years ago
log.NewInfo(req.OperationID, "UnBlockUser args ", req.String())
resp := &pbUser.UnBlockUserResp{}
err := imdb.UnBlockUser(req.UserId)
if err != nil {
3 years ago
log.NewError(req.OperationID, utils.GetSelfFuncName(), "unBlockUser", err.Error())
return resp, errors.WrapError(constant.ErrDB)
3 years ago
}
return resp, nil
3 years ago
}
func (s *userServer) GetBlockUsers(ctx context.Context, req *pbUser.GetBlockUsersReq) (*pbUser.GetBlockUsersResp, error) {
3 years ago
log.NewInfo(req.OperationID, "GetBlockUsers args ", req.String())
resp := &pbUser.GetBlockUsersResp{}
3 years ago
blockUsers, err := imdb.GetBlockUsers(req.Pagination.ShowNumber, req.Pagination.PageNumber)
3 years ago
if err != nil {
3 years ago
log.Error(req.OperationID, utils.GetSelfFuncName(), "GetBlockUsers", err.Error())
return resp, errors.WrapError(constant.ErrDB)
3 years ago
}
for _, v := range blockUsers {
3 years ago
resp.BlockUsers = append(resp.BlockUsers, &pbUser.BlockUser{
User: &pbUser.User{
ProfilePhoto: v.User.FaceURL,
Nickname: v.User.Nickname,
UserId: v.User.UserID,
IsBlock: true,
},
BeginDisableTime: (v.BeginDisableTime).String(),
3 years ago
EndDisableTime: (v.EndDisableTime).String(),
3 years ago
})
}
resp.Pagination = &sdkws.ResponsePagination{}
resp.Pagination.ShowNumber = req.Pagination.ShowNumber
resp.Pagination.CurrentPage = req.Pagination.PageNumber
3 years ago
nums, err := imdb.GetBlockUsersNumCount()
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetBlockUsersNumCount failed", err.Error())
3 years ago
return resp, errors.WrapError(constant.ErrDB)
3 years ago
}
resp.UserNums = nums
3 years ago
return resp, nil
3 years ago
}
3 years ago
3 years ago
func (s *userServer) GetBlockUserById(_ context.Context, req *pbUser.GetBlockUserByIdReq) (*pbUser.GetBlockUserByIdResp, error) {
3 years ago
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "GetBlockUserById args ", req.String())
3 years ago
resp := &pbUser.GetBlockUserByIdResp{}
3 years ago
user, err := imdb.GetBlockUserById(req.UserId)
if err != nil {
3 years ago
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetBlockUserById", err)
return resp, errors.WrapError(constant.ErrDB)
3 years ago
}
3 years ago
resp.BlockUser = &pbUser.BlockUser{
User: &pbUser.User{
ProfilePhoto: user.User.FaceURL,
Nickname: user.User.Nickname,
UserId: user.User.UserID,
IsBlock: true,
},
BeginDisableTime: (user.BeginDisableTime).String(),
EndDisableTime: (user.EndDisableTime).String(),
}
3 years ago
return resp, nil
3 years ago
}
3 years ago
3 years ago
func (s *userServer) DeleteUser(_ context.Context, req *pbUser.DeleteUserReq) (*pbUser.DeleteUserResp, error) {
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req.String())
resp := &pbUser.DeleteUserResp{}
if row := imdb.DeleteUser(req.UserId); row == 0 {
3 years ago
log.NewError(req.OperationID, utils.GetSelfFuncName(), "delete failed", "delete rows:", row)
3 years ago
return resp, errors.WrapError(constant.ErrDB)
3 years ago
}
return resp, nil
3 years ago
}