Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
im-microservice
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Li Feifei
im-microservice
Commits
dbd843ee
Commit
dbd843ee
authored
Jul 08, 2020
by
Li Feifei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
go fmt project
parent
347fc415
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
21 additions
and
24 deletions
+21
-24
app_db.go
helper/app_db.go
+0
-1
helper.go
helper/helper.go
+0
-2
auth.go
middleware/auth.go
+1
-1
im_base.validator.pb.go
pb/im_base.validator.pb.go
+1
-1
im_chat_room.validator.pb.go
pb/im_chat_room.validator.pb.go
+1
-1
im_chat_room_user.validator.pb.go
pb/im_chat_room_user.validator.pb.go
+1
-1
im_friend_req.validator.pb.go
pb/im_friend_req.validator.pb.go
+1
-1
im_user.validator.pb.go
pb/im_user.validator.pb.go
+1
-1
im_user_relationship.validator.pb.go
pb/im_user_relationship.validator.pb.go
+1
-1
db.go
sevice/im_friend_request/db.go
+4
-4
main.go
sevice/im_friend_request/main.go
+5
-5
db.go
sevice/im_user_relationship/db.go
+2
-2
main.go
sevice/im_user_relationship/main.go
+3
-3
No files found.
helper/app_db.go
View file @
dbd843ee
...
@@ -19,7 +19,6 @@ func GetSecretByKey(key string) (error, string) {
...
@@ -19,7 +19,6 @@ func GetSecretByKey(key string) (error, string) {
return
nil
,
u_app
.
Secret
return
nil
,
u_app
.
Secret
}
}
func
AppIsExit
(
appid
int64
)
bool
{
func
AppIsExit
(
appid
int64
)
bool
{
return
db
.
MysqlClient
.
QueryTable
(
table_name
)
.
Filter
(
"id"
,
appid
)
.
Exist
()
return
db
.
MysqlClient
.
QueryTable
(
table_name
)
.
Filter
(
"id"
,
appid
)
.
Exist
()
}
}
helper/helper.go
View file @
dbd843ee
...
@@ -46,5 +46,3 @@ func Paginate(count, step, page int64) (int64, int64) {
...
@@ -46,5 +46,3 @@ func Paginate(count, step, page int64) (int64, int64) {
total
:=
int64
(
math
.
Ceil
(
float64
(
count
)
/
float64
(
step
)))
total
:=
int64
(
math
.
Ceil
(
float64
(
count
)
/
float64
(
step
)))
return
offset
,
total
return
offset
,
total
}
}
middleware/auth.go
View file @
dbd843ee
...
@@ -58,7 +58,7 @@ func Auth(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo,
...
@@ -58,7 +58,7 @@ func Auth(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo,
request_map
:=
make
(
map
[
string
]
string
)
request_map
:=
make
(
map
[
string
]
string
)
key_r
,
_
:=
regexp
.
Compile
(
`[^}|^Common:]\s?(.*?):"(.*?)"`
)
key_r
,
_
:=
regexp
.
Compile
(
`[^}|^Common:]\s?(.*?):"(.*?)"`
)
result
:=
key_r
.
FindAllStringSubmatch
(
fmt
.
Sprintf
(
"%v"
,
req
),
-
1
)
result
:=
key_r
.
FindAllStringSubmatch
(
fmt
.
Sprintf
(
"%v"
,
req
),
-
1
)
for
_
,
v
:=
range
result
{
for
_
,
v
:=
range
result
{
request_map
[
v
[
1
]]
=
v
[
2
]
request_map
[
v
[
1
]]
=
v
[
2
]
}
}
...
...
pb/im_base.validator.pb.go
View file @
dbd843ee
...
@@ -5,10 +5,10 @@ package pb
...
@@ -5,10 +5,10 @@ package pb
import
(
import
(
fmt
"fmt"
fmt
"fmt"
math
"math"
proto
"github.com/golang/protobuf/proto"
proto
"github.com/golang/protobuf/proto"
_
"github.com/mwitkow/go-proto-validators"
_
"github.com/mwitkow/go-proto-validators"
github_com_mwitkow_go_proto_validators
"github.com/mwitkow/go-proto-validators"
github_com_mwitkow_go_proto_validators
"github.com/mwitkow/go-proto-validators"
math
"math"
)
)
// Reference imports to suppress errors if they are not otherwise used.
// Reference imports to suppress errors if they are not otherwise used.
...
...
pb/im_chat_room.validator.pb.go
View file @
dbd843ee
...
@@ -5,10 +5,10 @@ package pb
...
@@ -5,10 +5,10 @@ package pb
import
(
import
(
fmt
"fmt"
fmt
"fmt"
math
"math"
proto
"github.com/golang/protobuf/proto"
proto
"github.com/golang/protobuf/proto"
_
"github.com/mwitkow/go-proto-validators"
_
"github.com/mwitkow/go-proto-validators"
github_com_mwitkow_go_proto_validators
"github.com/mwitkow/go-proto-validators"
github_com_mwitkow_go_proto_validators
"github.com/mwitkow/go-proto-validators"
math
"math"
)
)
// Reference imports to suppress errors if they are not otherwise used.
// Reference imports to suppress errors if they are not otherwise used.
...
...
pb/im_chat_room_user.validator.pb.go
View file @
dbd843ee
...
@@ -5,10 +5,10 @@ package pb
...
@@ -5,10 +5,10 @@ package pb
import
(
import
(
fmt
"fmt"
fmt
"fmt"
math
"math"
proto
"github.com/golang/protobuf/proto"
proto
"github.com/golang/protobuf/proto"
_
"github.com/mwitkow/go-proto-validators"
_
"github.com/mwitkow/go-proto-validators"
github_com_mwitkow_go_proto_validators
"github.com/mwitkow/go-proto-validators"
github_com_mwitkow_go_proto_validators
"github.com/mwitkow/go-proto-validators"
math
"math"
)
)
// Reference imports to suppress errors if they are not otherwise used.
// Reference imports to suppress errors if they are not otherwise used.
...
...
pb/im_friend_req.validator.pb.go
View file @
dbd843ee
...
@@ -5,10 +5,10 @@ package pb
...
@@ -5,10 +5,10 @@ package pb
import
(
import
(
fmt
"fmt"
fmt
"fmt"
math
"math"
proto
"github.com/golang/protobuf/proto"
proto
"github.com/golang/protobuf/proto"
_
"github.com/mwitkow/go-proto-validators"
_
"github.com/mwitkow/go-proto-validators"
github_com_mwitkow_go_proto_validators
"github.com/mwitkow/go-proto-validators"
github_com_mwitkow_go_proto_validators
"github.com/mwitkow/go-proto-validators"
math
"math"
)
)
// Reference imports to suppress errors if they are not otherwise used.
// Reference imports to suppress errors if they are not otherwise used.
...
...
pb/im_user.validator.pb.go
View file @
dbd843ee
...
@@ -5,10 +5,10 @@ package pb
...
@@ -5,10 +5,10 @@ package pb
import
(
import
(
fmt
"fmt"
fmt
"fmt"
math
"math"
proto
"github.com/golang/protobuf/proto"
proto
"github.com/golang/protobuf/proto"
_
"github.com/mwitkow/go-proto-validators"
_
"github.com/mwitkow/go-proto-validators"
github_com_mwitkow_go_proto_validators
"github.com/mwitkow/go-proto-validators"
github_com_mwitkow_go_proto_validators
"github.com/mwitkow/go-proto-validators"
math
"math"
)
)
// Reference imports to suppress errors if they are not otherwise used.
// Reference imports to suppress errors if they are not otherwise used.
...
...
pb/im_user_relationship.validator.pb.go
View file @
dbd843ee
...
@@ -5,10 +5,10 @@ package pb
...
@@ -5,10 +5,10 @@ package pb
import
(
import
(
fmt
"fmt"
fmt
"fmt"
math
"math"
proto
"github.com/golang/protobuf/proto"
proto
"github.com/golang/protobuf/proto"
_
"github.com/mwitkow/go-proto-validators"
_
"github.com/mwitkow/go-proto-validators"
github_com_mwitkow_go_proto_validators
"github.com/mwitkow/go-proto-validators"
github_com_mwitkow_go_proto_validators
"github.com/mwitkow/go-proto-validators"
math
"math"
)
)
// Reference imports to suppress errors if they are not otherwise used.
// Reference imports to suppress errors if they are not otherwise used.
...
...
sevice/im_friend_request/db.go
View file @
dbd843ee
...
@@ -15,15 +15,15 @@ var (
...
@@ -15,15 +15,15 @@ var (
field_status
=
"status"
field_status
=
"status"
field_key
=
"appkey"
field_key
=
"appkey"
field_updatetime
=
"updatetime"
field_updatetime
=
"updatetime"
)
)
const
(
const
(
field_status_wait
=
iota
field_status_wait
=
iota
field_status_agree
field_status_agree
field_status_refuse
field_status_refuse
)
)
func
All
(
accid
string
)
([]
db
.
ImFriendRequest
,
error
){
func
All
(
accid
string
)
([]
db
.
ImFriendRequest
,
error
)
{
var
list
[]
db
.
ImFriendRequest
var
list
[]
db
.
ImFriendRequest
_
,
err
:=
db
.
MysqlClient
.
QueryTable
(
table_name
)
.
Filter
(
field_accid
,
accid
)
.
_
,
err
:=
db
.
MysqlClient
.
QueryTable
(
table_name
)
.
Filter
(
field_accid
,
accid
)
.
Filter
(
field_status
,
field_status_wait
)
.
All
(
&
list
)
Filter
(
field_status
,
field_status_wait
)
.
All
(
&
list
)
...
@@ -35,7 +35,7 @@ func FindExits(accid, faccid, key string) bool {
...
@@ -35,7 +35,7 @@ func FindExits(accid, faccid, key string) bool {
Filter
(
field_accid
,
accid
)
.
Filter
(
field_accid
,
accid
)
.
Filter
(
field_faccid
,
faccid
)
.
Filter
(
field_faccid
,
faccid
)
.
Filter
(
field_key
,
key
)
.
Filter
(
field_key
,
key
)
.
Filter
(
field_status
,
field_status_wait
)
.
Exist
()
Filter
(
field_status
,
field_status_wait
)
.
Exist
()
}
}
func
AddRecord
(
in
*
pb
.
ImFriendAddReq
)
error
{
func
AddRecord
(
in
*
pb
.
ImFriendAddReq
)
error
{
...
...
sevice/im_friend_request/main.go
View file @
dbd843ee
...
@@ -15,14 +15,14 @@ type ImFriendService struct {
...
@@ -15,14 +15,14 @@ type ImFriendService struct {
pb
.
UnimplementedImFriendServiceServer
pb
.
UnimplementedImFriendServiceServer
}
}
func
(
fs
*
ImFriendService
)
All
(
ctx
context
.
Context
,
in
*
pb
.
ImFriendListReq
)
(
reply
*
pb
.
ImFriendListReply
,
err
error
)
{
func
(
fs
*
ImFriendService
)
All
(
ctx
context
.
Context
,
in
*
pb
.
ImFriendListReq
)
(
reply
*
pb
.
ImFriendListReply
,
err
error
)
{
// 请求超时
// 请求超时
if
ctx
.
Err
()
==
context
.
Canceled
{
if
ctx
.
Err
()
==
context
.
Canceled
{
err
=
status
.
New
(
codes
.
Canceled
,
"Client cancelled, abandoning."
)
.
Err
()
err
=
status
.
New
(
codes
.
Canceled
,
"Client cancelled, abandoning."
)
.
Err
()
return
return
}
}
// 添加用户是否存在
// 添加用户是否存在
if
_
,
err
=
im_user
.
GetImUserByAccid
(
in
.
Accid
);
err
!=
nil
{
if
_
,
err
=
im_user
.
GetImUserByAccid
(
in
.
Accid
);
err
!=
nil
{
err
=
status
.
Error
(
codes
.
NotFound
,
"用户不存在"
)
err
=
status
.
Error
(
codes
.
NotFound
,
"用户不存在"
)
return
return
}
}
...
@@ -44,14 +44,14 @@ func (fs *ImFriendService) All (ctx context.Context, in *pb.ImFriendListReq) (re
...
@@ -44,14 +44,14 @@ func (fs *ImFriendService) All (ctx context.Context, in *pb.ImFriendListReq) (re
return
return
}
}
func
(
fs
*
ImFriendService
)
Add
(
ctx
context
.
Context
,
in
*
pb
.
ImFriendAddReq
)
(
reply
*
pb
.
ImFriendEmptyReply
,
err
error
)
{
func
(
fs
*
ImFriendService
)
Add
(
ctx
context
.
Context
,
in
*
pb
.
ImFriendAddReq
)
(
reply
*
pb
.
ImFriendEmptyReply
,
err
error
)
{
// 请求超时
// 请求超时
if
ctx
.
Err
()
==
context
.
Canceled
{
if
ctx
.
Err
()
==
context
.
Canceled
{
err
=
status
.
New
(
codes
.
Canceled
,
"Client cancelled, abandoning."
)
.
Err
()
err
=
status
.
New
(
codes
.
Canceled
,
"Client cancelled, abandoning."
)
.
Err
()
return
return
}
}
// 添加用户是否存在
// 添加用户是否存在
if
_
,
err
=
im_user
.
GetImUserByAccid
(
in
.
Accid
);
err
!=
nil
{
if
_
,
err
=
im_user
.
GetImUserByAccid
(
in
.
Accid
);
err
!=
nil
{
err
=
status
.
Error
(
codes
.
NotFound
,
"用户不存在"
)
err
=
status
.
Error
(
codes
.
NotFound
,
"用户不存在"
)
return
return
}
}
...
@@ -66,7 +66,7 @@ func (fs *ImFriendService) Add (ctx context.Context,in *pb.ImFriendAddReq) (repl
...
@@ -66,7 +66,7 @@ func (fs *ImFriendService) Add (ctx context.Context,in *pb.ImFriendAddReq) (repl
return
return
}
}
//对方用户黑名单不能添加
//对方用户黑名单不能添加
if
ok
:=
im_user_relationship
.
IsBlack
(
in
.
Accid
,
in
.
Faccid
,
in
.
Common
.
Appkey
);
ok
{
if
ok
:=
im_user_relationship
.
IsBlack
(
in
.
Accid
,
in
.
Faccid
,
in
.
Common
.
Appkey
);
ok
{
err
=
status
.
Error
(
codes
.
AlreadyExists
,
"已经添加过该好友"
)
err
=
status
.
Error
(
codes
.
AlreadyExists
,
"已经添加过该好友"
)
return
return
}
}
...
...
sevice/im_user_relationship/db.go
View file @
dbd843ee
...
@@ -27,7 +27,7 @@ var (
...
@@ -27,7 +27,7 @@ var (
)
)
// 是否是好友
// 是否是好友
func
IsUserRelationship
(
accid
,
faccid
,
key
string
)
bool
{
func
IsUserRelationship
(
accid
,
faccid
,
key
string
)
bool
{
return
db
.
MysqlClient
.
QueryTable
(
db_tabel
)
.
Filter
(
db_field_accid
,
accid
)
.
return
db
.
MysqlClient
.
QueryTable
(
db_tabel
)
.
Filter
(
db_field_accid
,
accid
)
.
Filter
(
db_field_faccid
,
faccid
)
.
Filter
(
"appkey"
,
key
)
.
Exist
()
Filter
(
db_field_faccid
,
faccid
)
.
Filter
(
"appkey"
,
key
)
.
Exist
()
}
}
...
@@ -58,7 +58,7 @@ func AddUserRelationship(in *pb.UserRelationshipAddRequest) error {
...
@@ -58,7 +58,7 @@ func AddUserRelationship(in *pb.UserRelationshipAddRequest) error {
us
.
Appkey
=
in
.
Common
.
Appkey
us
.
Appkey
=
in
.
Common
.
Appkey
_
,
err
:=
db
.
MysqlClient
.
Insert
(
&
us
)
_
,
err
:=
db
.
MysqlClient
.
Insert
(
&
us
)
if
ok
:=
IsUserRelationship
(
in
.
Faccid
,
in
.
Accid
,
in
.
Common
.
Appkey
);
!
ok
{
if
ok
:=
IsUserRelationship
(
in
.
Faccid
,
in
.
Accid
,
in
.
Common
.
Appkey
);
!
ok
{
// 被添加者
// 被添加者
ts
.
Accid
=
in
.
Faccid
ts
.
Accid
=
in
.
Faccid
ts
.
Faccid
=
in
.
Accid
ts
.
Faccid
=
in
.
Accid
...
...
sevice/im_user_relationship/main.go
View file @
dbd843ee
...
@@ -7,9 +7,9 @@ import (
...
@@ -7,9 +7,9 @@ import (
"google.golang.org/grpc/codes"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"google.golang.org/grpc/status"
"im-microservice/sevice/im_user"
"im-microservice/helper"
"im-microservice/helper"
"im-microservice/pb"
"im-microservice/pb"
"im-microservice/sevice/im_user"
)
)
type
UserRelationshipService
struct
{
type
UserRelationshipService
struct
{
...
@@ -32,7 +32,7 @@ func (us *UserRelationshipService) Add(ctx context.Context,
...
@@ -32,7 +32,7 @@ func (us *UserRelationshipService) Add(ctx context.Context,
_
,
_
=
im_user
.
UpdateImUser
(
in
.
Accid
,
u_map
)
_
,
_
=
im_user
.
UpdateImUser
(
in
.
Accid
,
u_map
)
// 更改请求用户版本信息
// 更改请求用户版本信息
_
,
_
=
im_user
.
UpdateImUser
(
in
.
Faccid
,
u_map
)
_
,
_
=
im_user
.
UpdateImUser
(
in
.
Faccid
,
u_map
)
reply
=
&
pb
.
UserRelationshipAddReply
{}
reply
=
&
pb
.
UserRelationshipAddReply
{}
return
return
...
@@ -55,7 +55,7 @@ func (us *UserRelationshipService) Delete(ctx context.Context,
...
@@ -55,7 +55,7 @@ func (us *UserRelationshipService) Delete(ctx context.Context,
_
,
_
=
im_user
.
UpdateImUser
(
in
.
Accid
,
u_map
)
_
,
_
=
im_user
.
UpdateImUser
(
in
.
Accid
,
u_map
)
// 更改被添加用户版本信息
// 更改被添加用户版本信息
_
,
_
=
im_user
.
UpdateImUser
(
in
.
Faccid
,
u_map
)
_
,
_
=
im_user
.
UpdateImUser
(
in
.
Faccid
,
u_map
)
reply
=
&
pb
.
UserRelationshipAddReply
{}
reply
=
&
pb
.
UserRelationshipAddReply
{}
return
return
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment