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
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
30 additions
and
34 deletions
+30
-34
app_db.go
helper/app_db.go
+1
-3
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
+10
-10
main.go
sevice/im_friend_request/main.go
+6
-6
db.go
sevice/im_user_relationship/db.go
+3
-3
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) {
return
nil
,
u_app
.
Secret
}
func
AppIsExit
(
appid
int64
)
bool
{
return
db
.
MysqlClient
.
QueryTable
(
table_name
)
.
Filter
(
"id"
,
appid
)
.
Exist
()
}
\ No newline at end of file
}
helper/helper.go
View file @
dbd843ee
...
...
@@ -46,5 +46,3 @@ func Paginate(count, step, page int64) (int64, int64) {
total
:=
int64
(
math
.
Ceil
(
float64
(
count
)
/
float64
(
step
)))
return
offset
,
total
}
middleware/auth.go
View file @
dbd843ee
...
...
@@ -58,7 +58,7 @@ func Auth(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo,
request_map
:=
make
(
map
[
string
]
string
)
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
{
request_map
[
v
[
1
]]
=
v
[
2
]
}
...
...
pb/im_base.validator.pb.go
View file @
dbd843ee
...
...
@@ -5,10 +5,10 @@ package pb
import
(
fmt
"fmt"
math
"math"
proto
"github.com/golang/protobuf/proto"
_
"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.
...
...
pb/im_chat_room.validator.pb.go
View file @
dbd843ee
...
...
@@ -5,10 +5,10 @@ package pb
import
(
fmt
"fmt"
math
"math"
proto
"github.com/golang/protobuf/proto"
_
"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.
...
...
pb/im_chat_room_user.validator.pb.go
View file @
dbd843ee
...
...
@@ -5,10 +5,10 @@ package pb
import
(
fmt
"fmt"
math
"math"
proto
"github.com/golang/protobuf/proto"
_
"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.
...
...
pb/im_friend_req.validator.pb.go
View file @
dbd843ee
...
...
@@ -5,10 +5,10 @@ package pb
import
(
fmt
"fmt"
math
"math"
proto
"github.com/golang/protobuf/proto"
_
"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.
...
...
pb/im_user.validator.pb.go
View file @
dbd843ee
...
...
@@ -5,10 +5,10 @@ package pb
import
(
fmt
"fmt"
math
"math"
proto
"github.com/golang/protobuf/proto"
_
"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.
...
...
pb/im_user_relationship.validator.pb.go
View file @
dbd843ee
...
...
@@ -5,10 +5,10 @@ package pb
import
(
fmt
"fmt"
math
"math"
proto
"github.com/golang/protobuf/proto"
_
"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.
...
...
sevice/im_friend_request/db.go
View file @
dbd843ee
...
...
@@ -8,22 +8,22 @@ import (
)
var
(
table_name
=
"im_friend_request"
field_id
=
"id"
field_accid
=
"accid"
field_faccid
=
"faccid"
field_status
=
"status"
field_key
=
"appkey"
table_name
=
"im_friend_request"
field_id
=
"id"
field_accid
=
"accid"
field_faccid
=
"faccid"
field_status
=
"status"
field_key
=
"appkey"
field_updatetime
=
"updatetime"
)
const
(
const
(
field_status_wait
=
iota
field_status_agree
field_status_refuse
)
func
All
(
accid
string
)
([]
db
.
ImFriendRequest
,
error
){
func
All
(
accid
string
)
([]
db
.
ImFriendRequest
,
error
)
{
var
list
[]
db
.
ImFriendRequest
_
,
err
:=
db
.
MysqlClient
.
QueryTable
(
table_name
)
.
Filter
(
field_accid
,
accid
)
.
Filter
(
field_status
,
field_status_wait
)
.
All
(
&
list
)
...
...
@@ -35,7 +35,7 @@ func FindExits(accid, faccid, key string) bool {
Filter
(
field_accid
,
accid
)
.
Filter
(
field_faccid
,
faccid
)
.
Filter
(
field_key
,
key
)
.
Filter
(
field_status
,
field_status_wait
)
.
Exist
()
Filter
(
field_status
,
field_status_wait
)
.
Exist
()
}
func
AddRecord
(
in
*
pb
.
ImFriendAddReq
)
error
{
...
...
sevice/im_friend_request/main.go
View file @
dbd843ee
...
...
@@ -15,14 +15,14 @@ type ImFriendService struct {
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
{
err
=
status
.
New
(
codes
.
Canceled
,
"Client cancelled, abandoning."
)
.
Err
()
return
}
// 添加用户是否存在
if
_
,
err
=
im_user
.
GetImUserByAccid
(
in
.
Accid
);
err
!=
nil
{
if
_
,
err
=
im_user
.
GetImUserByAccid
(
in
.
Accid
);
err
!=
nil
{
err
=
status
.
Error
(
codes
.
NotFound
,
"用户不存在"
)
return
}
...
...
@@ -44,14 +44,14 @@ func (fs *ImFriendService) All (ctx context.Context, in *pb.ImFriendListReq) (re
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
{
err
=
status
.
New
(
codes
.
Canceled
,
"Client cancelled, abandoning."
)
.
Err
()
return
}
// 添加用户是否存在
if
_
,
err
=
im_user
.
GetImUserByAccid
(
in
.
Accid
);
err
!=
nil
{
if
_
,
err
=
im_user
.
GetImUserByAccid
(
in
.
Accid
);
err
!=
nil
{
err
=
status
.
Error
(
codes
.
NotFound
,
"用户不存在"
)
return
}
...
...
@@ -66,7 +66,7 @@ func (fs *ImFriendService) Add (ctx context.Context,in *pb.ImFriendAddReq) (repl
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
,
"已经添加过该好友"
)
return
}
...
...
@@ -88,7 +88,7 @@ func (fs *ImFriendService) Update(ctx context.Context, in *pb.ImFriendUpdateReq)
err
=
status
.
New
(
codes
.
Canceled
,
"Client cancelled, abandoning."
)
.
Err
()
return
}
if
err
=
Update
(
in
);
err
!=
nil
{
if
err
=
Update
(
in
);
err
!=
nil
{
err
=
status
.
Error
(
codes
.
Internal
,
err
.
Error
())
return
}
...
...
sevice/im_user_relationship/db.go
View file @
dbd843ee
...
...
@@ -22,12 +22,12 @@ var (
db_field_serverex
=
"serverex"
db_field_updatetime
=
"updatetime"
db_field_createtime
=
"createtime"
open
=
2
open
=
2
db_close
=
1
)
// 是否是好友
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
)
.
Filter
(
db_field_faccid
,
faccid
)
.
Filter
(
"appkey"
,
key
)
.
Exist
()
}
...
...
@@ -58,7 +58,7 @@ func AddUserRelationship(in *pb.UserRelationshipAddRequest) error {
us
.
Appkey
=
in
.
Common
.
Appkey
_
,
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
.
Faccid
=
in
.
Accid
...
...
sevice/im_user_relationship/main.go
View file @
dbd843ee
...
...
@@ -7,9 +7,9 @@ import (
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"im-microservice/sevice/im_user"
"im-microservice/helper"
"im-microservice/pb"
"im-microservice/sevice/im_user"
)
type
UserRelationshipService
struct
{
...
...
@@ -32,7 +32,7 @@ func (us *UserRelationshipService) Add(ctx context.Context,
_
,
_
=
im_user
.
UpdateImUser
(
in
.
Accid
,
u_map
)
// 更改请求用户版本信息
_
,
_
=
im_user
.
UpdateImUser
(
in
.
Faccid
,
u_map
)
_
,
_
=
im_user
.
UpdateImUser
(
in
.
Faccid
,
u_map
)
reply
=
&
pb
.
UserRelationshipAddReply
{}
return
...
...
@@ -55,7 +55,7 @@ func (us *UserRelationshipService) Delete(ctx context.Context,
_
,
_
=
im_user
.
UpdateImUser
(
in
.
Accid
,
u_map
)
// 更改被添加用户版本信息
_
,
_
=
im_user
.
UpdateImUser
(
in
.
Faccid
,
u_map
)
_
,
_
=
im_user
.
UpdateImUser
(
in
.
Faccid
,
u_map
)
reply
=
&
pb
.
UserRelationshipAddReply
{}
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