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
347fc415
Commit
347fc415
authored
Jul 08, 2020
by
Li Feifei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add appkey field
parent
6a8be980
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
18 additions
and
11 deletions
+18
-11
db_struct.go
db/db_struct.go
+2
-0
db.go
sevice/im_friend_request/db.go
+4
-1
main.go
sevice/im_friend_request/main.go
+3
-3
db.go
sevice/im_user_relationship/db.go
+8
-6
main.go
sevice/im_user_relationship/main.go
+1
-1
No files found.
db/db_struct.go
View file @
347fc415
...
...
@@ -40,6 +40,7 @@ type ImChatRoomUser struct {
type
ImUserRelationship
struct
{
Id
int
Accid
string
Appkey
string
Faccid
string
Type
int
Msg
string
...
...
@@ -67,6 +68,7 @@ type ImUser struct {
type
ImFriendRequest
struct
{
Id
int
Accid
string
Appkey
string
Faccid
string
Status
int64
Createtime
string
...
...
sevice/im_friend_request/db.go
View file @
347fc415
...
...
@@ -13,6 +13,7 @@ var (
field_accid
=
"accid"
field_faccid
=
"faccid"
field_status
=
"status"
field_key
=
"appkey"
field_updatetime
=
"updatetime"
)
...
...
@@ -29,10 +30,11 @@ func All(accid string) ([]db.ImFriendRequest, error){
return
list
,
err
}
func
FindExits
(
accid
,
faccid
string
)
bool
{
func
FindExits
(
accid
,
faccid
,
key
string
)
bool
{
return
db
.
MysqlClient
.
QueryTable
(
table_name
)
.
Filter
(
field_accid
,
accid
)
.
Filter
(
field_faccid
,
faccid
)
.
Filter
(
field_key
,
key
)
.
Filter
(
field_status
,
field_status_wait
)
.
Exist
()
}
...
...
@@ -46,6 +48,7 @@ func AddRecord(in *pb.ImFriendAddReq) error {
db_friend
.
Status
=
field_status_wait
db_friend
.
Createtime
=
now
db_friend
.
Updatetime
=
now
db_friend
.
Appkey
=
in
.
Common
.
Appkey
_
,
err
:=
db
.
MysqlClient
.
Insert
(
&
db_friend
)
return
err
}
...
...
sevice/im_friend_request/main.go
View file @
347fc415
...
...
@@ -61,17 +61,17 @@ func (fs *ImFriendService) Add (ctx context.Context,in *pb.ImFriendAddReq) (repl
return
}
//是否已经添加过好友
if
ok
:=
im_user_relationship
.
IsUserRelationship
(
in
.
Accid
,
in
.
Faccid
);
ok
{
if
ok
:=
im_user_relationship
.
IsUserRelationship
(
in
.
Accid
,
in
.
Faccid
,
in
.
Common
.
Appkey
);
ok
{
err
=
status
.
Error
(
codes
.
AlreadyExists
,
"已经添加过该好友"
)
return
}
//对方用户黑名单不能添加
if
ok
:=
im_user_relationship
.
IsBlack
(
in
.
Accid
,
in
.
Faccid
);
ok
{
if
ok
:=
im_user_relationship
.
IsBlack
(
in
.
Accid
,
in
.
Faccid
,
in
.
Common
.
Appkey
);
ok
{
err
=
status
.
Error
(
codes
.
AlreadyExists
,
"已经添加过该好友"
)
return
}
// 已经提过添加好友申请
if
ok
:=
FindExits
(
in
.
Accid
,
in
.
Faccid
);
ok
{
if
ok
:=
FindExits
(
in
.
Accid
,
in
.
Faccid
,
in
.
Common
.
Appkey
);
ok
{
err
=
status
.
Error
(
codes
.
AlreadyExists
,
"已经提交过申请"
)
return
}
...
...
sevice/im_user_relationship/db.go
View file @
347fc415
...
...
@@ -27,15 +27,15 @@ var (
)
// 是否是好友
func
IsUserRelationship
(
accid
,
faccid
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
)
.
Exist
()
Filter
(
db_field_faccid
,
faccid
)
.
Filter
(
"appkey"
,
key
)
.
Exist
()
}
//是否是对方黑名单
func
IsBlack
(
accid
,
faccid
string
)
bool
{
func
IsBlack
(
accid
,
faccid
,
key
string
)
bool
{
return
db
.
MysqlClient
.
QueryTable
(
db_tabel
)
.
Filter
(
db_field_accid
,
faccid
)
.
Filter
(
db_field_faccid
,
accid
)
.
Filter
(
db_field_blacklist
,
db_close
)
.
Exist
()
Filter
(
db_field_faccid
,
accid
)
.
Filter
(
db_field_blacklist
,
db_close
)
.
Filter
(
"appkey"
,
key
)
.
Exist
()
}
...
...
@@ -55,9 +55,10 @@ func AddUserRelationship(in *pb.UserRelationshipAddRequest) error {
us
.
Blacklist
=
open
us
.
Mute
=
open
us
.
Createtime
=
now
us
.
Appkey
=
in
.
Common
.
Appkey
_
,
err
:=
db
.
MysqlClient
.
Insert
(
&
us
)
if
ok
:=
IsUserRelationship
(
in
.
Faccid
,
in
.
Accid
);
!
ok
{
if
ok
:=
IsUserRelationship
(
in
.
Faccid
,
in
.
Accid
,
in
.
Common
.
Appkey
);
!
ok
{
// 被添加者
ts
.
Accid
=
in
.
Faccid
ts
.
Faccid
=
in
.
Accid
...
...
@@ -67,6 +68,7 @@ func AddUserRelationship(in *pb.UserRelationshipAddRequest) error {
ts
.
Blacklist
=
open
ts
.
Mute
=
open
ts
.
Createtime
=
now
ts
.
Appkey
=
in
.
Common
.
Appkey
_
,
err1
:=
db
.
MysqlClient
.
Insert
(
&
ts
)
if
err1
!=
nil
{
return
status
.
Error
(
codes
.
Internal
,
err
.
Error
())
...
...
@@ -106,7 +108,7 @@ func DBAll(in *pb.UserRelationshipListRequest) ([]db.ImUserRelationship, error)
func
SetSpecialRelationDb
(
in
*
pb
.
SetSpecialRelationReq
)
error
{
if
ok
:=
IsUserRelationship
(
in
.
Accid
,
in
.
TargetAcc
);
!
ok
{
if
ok
:=
IsUserRelationship
(
in
.
Accid
,
in
.
TargetAcc
,
in
.
Common
.
Appkey
);
!
ok
{
return
errors
.
New
(
"被操作用户不是该用户好友"
)
}
orm_params
:=
make
(
orm
.
Params
)
...
...
sevice/im_user_relationship/main.go
View file @
347fc415
...
...
@@ -3,7 +3,7 @@ package im_user_relationship
import
(
"context"
"fmt"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
...
...
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