Commit 38b232e1 by Li Feifei

Merge branch 'develop' of http://gitlab.offcncloud.com/lff58407/im-microservice into develop

parents f48c57a6 0a75f2bf
......@@ -52,6 +52,6 @@ type ImUser struct {
Createtime string
Updatetime string
LoginStatus int64
Platfrom string
Platform string
Edition string
}
......@@ -8,15 +8,14 @@ package pb
import (
context "context"
reflect "reflect"
sync "sync"
proto "github.com/golang/protobuf/proto"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
const (
......@@ -40,7 +39,7 @@ type ImUserRequest struct {
Name string `protobuf:"bytes,2,opt,name=Name,proto3" json:"Name,omitempty"`
Mobile string `protobuf:"bytes,3,opt,name=Mobile,proto3" json:"Mobile,omitempty"`
Code string `protobuf:"bytes,4,opt,name=Code,proto3" json:"Code,omitempty"`
Platfrom string `protobuf:"bytes,5,opt,name=Platfrom,proto3" json:"Platfrom,omitempty"`
Platform string `protobuf:"bytes,5,opt,name=Platform,proto3" json:"Platform,omitempty"`
}
func (x *ImUserRequest) Reset() {
......@@ -103,9 +102,9 @@ func (x *ImUserRequest) GetCode() string {
return ""
}
func (x *ImUserRequest) GetPlatfrom() string {
func (x *ImUserRequest) GetPlatform() string {
if x != nil {
return x.Platfrom
return x.Platform
}
return ""
}
......@@ -387,7 +386,7 @@ type ImUserOneReply struct {
Createtime string `protobuf:"bytes,9,opt,name=Createtime,proto3" json:"Createtime,omitempty"`
Updatetime string `protobuf:"bytes,10,opt,name=Updatetime,proto3" json:"Updatetime,omitempty"`
LoginStatus int64 `protobuf:"varint,11,opt,name=LoginStatus,proto3" json:"LoginStatus,omitempty"`
Platfrom string `protobuf:"bytes,12,opt,name=Platfrom,proto3" json:"Platfrom,omitempty"`
Platform string `protobuf:"bytes,12,opt,name=Platform,proto3" json:"Platform,omitempty"`
Edition string `protobuf:"bytes,13,opt,name=Edition,proto3" json:"Edition,omitempty"`
}
......@@ -500,9 +499,9 @@ func (x *ImUserOneReply) GetLoginStatus() int64 {
return 0
}
func (x *ImUserOneReply) GetPlatfrom() string {
func (x *ImUserOneReply) GetPlatform() string {
if x != nil {
return x.Platfrom
return x.Platform
}
return ""
}
......@@ -531,7 +530,7 @@ type ImUserListRequest struct {
Createtime string `protobuf:"bytes,9,opt,name=Createtime,proto3" json:"Createtime,omitempty"`
Updatetime string `protobuf:"bytes,10,opt,name=Updatetime,proto3" json:"Updatetime,omitempty"`
LoginStatus int64 `protobuf:"varint,11,opt,name=LoginStatus,proto3" json:"LoginStatus,omitempty"`
Platfrom string `protobuf:"bytes,12,opt,name=Platfrom,proto3" json:"Platfrom,omitempty"`
Platform string `protobuf:"bytes,12,opt,name=Platform,proto3" json:"Platform,omitempty"`
Edition string `protobuf:"bytes,13,opt,name=Edition,proto3" json:"Edition,omitempty"`
}
......@@ -644,9 +643,9 @@ func (x *ImUserListRequest) GetLoginStatus() int64 {
return 0
}
func (x *ImUserListRequest) GetPlatfrom() string {
func (x *ImUserListRequest) GetPlatform() string {
if x != nil {
return x.Platfrom
return x.Platform
}
return ""
}
......@@ -727,8 +726,8 @@ var file_u_proto_im_user_proto_rawDesc = []byte{
0x6f, 0x62, 0x69, 0x6c, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x4d, 0x6f, 0x62,
0x69, 0x6c, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28,
0x09, 0x52, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x50, 0x6c, 0x61, 0x74, 0x66,
0x72, 0x6f, 0x6d, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x50, 0x6c, 0x61, 0x74, 0x66,
0x72, 0x6f, 0x6d, 0x22, 0x23, 0x0a, 0x0b, 0x49, 0x6d, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x70,
0x6f, 0x72, 0x6d, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x50, 0x6c, 0x61, 0x74, 0x66,
0x6f, 0x72, 0x6d, 0x22, 0x23, 0x0a, 0x0b, 0x49, 0x6d, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x70,
0x6c, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x41, 0x63, 0x63, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28,
0x09, 0x52, 0x05, 0x41, 0x63, 0x63, 0x69, 0x64, 0x22, 0x4c, 0x0a, 0x10, 0x49, 0x6d, 0x55, 0x73,
0x65, 0x72, 0x4f, 0x75, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x22, 0x0a, 0x06,
......@@ -768,8 +767,8 @@ var file_u_proto_im_user_proto_rawDesc = []byte{
0x65, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x53, 0x74,
0x61, 0x74, 0x75, 0x73, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0b, 0x4c, 0x6f, 0x67, 0x69,
0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x50, 0x6c, 0x61, 0x74, 0x66,
0x72, 0x6f, 0x6d, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x50, 0x6c, 0x61, 0x74, 0x66,
0x72, 0x6f, 0x6d, 0x12, 0x18, 0x0a, 0x07, 0x45, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x0d,
0x6f, 0x72, 0x6d, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x50, 0x6c, 0x61, 0x74, 0x66,
0x6f, 0x72, 0x6d, 0x12, 0x18, 0x0a, 0x07, 0x45, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x0d,
0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x45, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x87, 0x03,
0x0a, 0x11, 0x49, 0x6d, 0x55, 0x73, 0x65, 0x72, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75,
0x65, 0x73, 0x74, 0x12, 0x22, 0x0a, 0x06, 0x43, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x18, 0x01, 0x20,
......@@ -792,8 +791,8 @@ var file_u_proto_im_user_proto_rawDesc = []byte{
0x01, 0x28, 0x09, 0x52, 0x0a, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x74, 0x69, 0x6d, 0x65, 0x12,
0x20, 0x0a, 0x0b, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x0b,
0x20, 0x01, 0x28, 0x03, 0x52, 0x0b, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75,
0x73, 0x12, 0x1a, 0x0a, 0x08, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x72, 0x6f, 0x6d, 0x18, 0x0c, 0x20,
0x01, 0x28, 0x09, 0x52, 0x08, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x72, 0x6f, 0x6d, 0x12, 0x18, 0x0a,
0x73, 0x12, 0x1a, 0x0a, 0x08, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x18, 0x0c, 0x20,
0x01, 0x28, 0x09, 0x52, 0x08, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x12, 0x18, 0x0a,
0x07, 0x45, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07,
0x45, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x5f, 0x0a, 0x0f, 0x49, 0x6d, 0x55, 0x73, 0x65,
0x72, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x26, 0x0a, 0x04, 0x4c, 0x69,
......
......@@ -2,10 +2,11 @@ package im_user
import (
"context"
"errors"
"im-microservice/db"
"im-microservice/helper"
"im-microservice/pb"
"google.golang.org/grpc/status"
)
type ImUserServer struct {
......@@ -16,7 +17,7 @@ type ImUser struct {
Name string `validate:"required"`
Mobile string `validate:"required,numeric,len=11"`
Code string `validate:"required"`
Platfrom string `validate:"required"`
Platform string `validate:"required"`
}
type ImUserSet struct {
......@@ -34,7 +35,7 @@ func (u *ImUserServer) ImUserRegister(ctx context.Context, in *pb.ImUserRequest)
Name: in.GetName(),
Mobile: in.GetMobile(),
Code: in.GetCode(),
Platfrom: in.GetPlatfrom(),
Platform: in.GetPlatform(),
}
// 参数验证是否合法
......@@ -49,18 +50,19 @@ func (u *ImUserServer) ImUserRegister(ctx context.Context, in *pb.ImUserRequest)
}
//对比验证码
if cache_code != imUser.Code {
err = errors.New("验证码不匹配")
err = status.Error(302, "验证码不匹配")
return
}
reply = &pb.ImUserReply{}
// 是否已经注册过, 如果已经注册返回用户信息
if c_user, _ := GetImUserByMobile(imUser.Mobile); c_user.Accid != "" {
reply.Accid = c_user.Accid
err = status.Error(10438, "手机号已注册")
return
}
// 企业用户注册失败
c_user, err := CreateImUser(imUser.Name, imUser.Mobile)
if err != nil {
err = status.Error(500, "注册失败")
return
}
reply.Accid = c_user.Accid
......@@ -73,7 +75,7 @@ func (u *ImUserServer) ImUserLogin(ctx context.Context, in *pb.ImUserRequest) (r
Name: in.GetName(),
Mobile: in.GetMobile(),
Code: in.GetCode(),
Platfrom: in.GetPlatfrom(),
Platform: in.GetPlatform(),
}
// 参数验证是否合法
......@@ -88,18 +90,18 @@ func (u *ImUserServer) ImUserLogin(ctx context.Context, in *pb.ImUserRequest) (r
}
//对比验证码
if cache_code != imUser.Code {
err = errors.New("验证码不匹配")
err = status.Error(302, "验证码不匹配")
return
}
reply = &pb.ImUserReply{}
c_user, _ := GetImUserByMobile(imUser.Mobile)
if c_user.Accid == "" {
err = errors.New("用户不存在")
err = status.Error(404, "用户不存在")
return
}
//更新用户登录时间
if res, _ := SaveUpdatetime(imUser.Mobile, imUser.Platfrom); res != 1 {
err = errors.New("用户登录时间更新失败")
if res, _ := SaveUpdatetime(imUser.Mobile, imUser.Platform); res != 1 {
err = status.Error(500, "用户登录时间更新失败")
return
}
reply.Accid = c_user.Accid
......@@ -118,7 +120,7 @@ func (u *ImUserServer) ImUserLoginOut(ctx context.Context, in *pb.ImUserOutReque
m := make(map[string]interface{})
m["login_status"] = 0
if res, _ := UpdateImUser(imUserOut.Accid, m); res != 1 {
err = errors.New("用户更改登录状态信息失败")
err = status.Error(500, "用户更改登录状态信息失败")
return
}
reply = &pb.ImUserSetReply{}
......@@ -134,7 +136,7 @@ func (u *ImUserServer) ImUserForbiddenWords(ctx context.Context, in *pb.ImUserSe
m := make(map[string]interface{})
m["mute_estoppel"] = mute
if res, _ := UpdateImUser(in.GetAccid(), m); res != 1 {
err = errors.New("用户禁言失败")
err = status.Error(500, "用户禁言失败")
return
}
reply = &pb.ImUserSetReply{}
......@@ -150,7 +152,7 @@ func (u *ImUserServer) ImUserForbiddenAV(ctx context.Context, in *pb.ImUserSetRe
m := make(map[string]interface{})
m["mute_audio_video"] = mute
if res, _ := UpdateImUser(in.GetAccid(), m); res != 1 {
err = errors.New("用户禁言失败")
err = status.Error(500, "用户禁音视频失败")
return
}
......@@ -189,7 +191,7 @@ func getImUser(imuser db.ImUser) *pb.ImUserOneReply {
Createtime: imuser.Createtime,
Updatetime: imuser.Updatetime,
LoginStatus: int64(imuser.LoginStatus),
Platfrom: imuser.Platfrom,
Platform: imuser.Platform,
Edition: imuser.Edition,
}
}
......
......@@ -62,12 +62,12 @@ func CreateImUser(name string, mobile string) (db.ImUser, error) {
}
//用户登录更新登录信息
func SaveUpdatetime(mobile string, platfrom string) (int64, error) {
func SaveUpdatetime(mobile string, platform string) (int64, error) {
updatetime := helper.GetNowTime()
orm_params := make(orm.Params)
orm_params["login_status"] = 1
orm_params["updatetime"] = updatetime
orm_params["platfrom"] = platfrom
orm_params["platform"] = platform
res, err := db.MysqlClient.QueryTable(u_table_name).Filter("mobile", mobile).Update(orm_params)
if err != nil {
return 0, err
......@@ -119,7 +119,7 @@ func GetImUserList(request *pb.ImUserListRequest) (results map[string]interface{
mute_audio_video = request.GetMuteAudioVideo()
ext = request.GetExt()
login_status = request.GetLoginStatus()
platfrom = request.GetPlatfrom()
platform = request.GetPlatform()
page = request.GetPage()
edition = request.GetEdition()
)
......@@ -148,8 +148,8 @@ func GetImUserList(request *pb.ImUserListRequest) (results map[string]interface{
if login_status != 0 {
count_db = count_db.Filter("login_status", login_status)
}
if platfrom != "" {
count_db = count_db.Filter("platfrom", platfrom)
if platform != "" {
count_db = count_db.Filter("platform", platform)
}
if edition != "" {
count_db = count_db.Filter("edition", edition)
......
......@@ -10,7 +10,7 @@ message ImUserRequest {
string Name = 2;
string Mobile = 3;
string Code = 4;
string Platfrom = 5;
string Platform = 5;
}
message ImUserReply{
......@@ -51,7 +51,7 @@ message ImUserOneReply {
string Createtime = 9;
string Updatetime = 10;
int64 LoginStatus = 11;
string Platfrom = 12;
string Platform = 12;
string Edition = 13;
}
......@@ -68,7 +68,7 @@ message ImUserListRequest {
string Createtime = 9;
string Updatetime = 10;
int64 LoginStatus = 11;
string Platfrom = 12;
string Platform = 12;
string Edition = 13;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment