Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
xuzhenhao
/
rlw-dev
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 705d75d7
authored
Dec 25, 2017
by
xuzhenhao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复了好友系统拒绝好友之后再添加会提示已经成为好友的问题
1 parent
da4cfdbc
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
3 deletions
friendSystem/models/friend.go
friendSystem/models/friend.go
View file @
705d75d
...
...
@@ -60,13 +60,38 @@ func (f *FriendRelationship) AddFriend(addType string) (result interface{}, err
}
friendrelationship
:=
make
([]
FriendRelationship
,
0
)
sql
:=
` select relationship_value from ice_friend_relationship where (friend_relationship_a_id=? and friend_relationship_b_id=?) or (friend_relationship_b_id=? and friend_relationship_a_id =?) `
err
=
db
.
Engine
.
Sql
(
sql
,
f
.
FriendRelationshipAId
,
f
.
FriendRelationshipBId
,
f
.
FriendRelationshipAId
,
f
.
FriendRelationshipBId
)
.
Find
(
&
friendrelationship
)
if
err
=
db
.
Engine
.
Sql
(
sql
,
f
.
FriendRelationshipAId
,
f
.
FriendRelationshipBId
,
f
.
FriendRelationshipAId
,
f
.
FriendRelationshipBId
)
.
Find
(
&
friendrelationship
);
err
!=
nil
{
return
nil
,
err
}
if
len
(
friendrelationship
)
!=
0
{
if
friendrelationship
[
0
]
.
RelationshipValue
==
0
{
// if friendrelationship[0].RelationshipValue == 0 {
// err = errors.New("已向该玩家发送请求")
// } else if friendrelationship[0].RelationshipValue == 1 {
// err = errors.New("该玩家已经是你的好友")
// } else {
// }
// return nil, err
switch
friendrelationship
[
0
]
.
RelationshipValue
{
case
0
:
err
=
errors
.
New
(
"已向该玩家发送请求"
)
}
else
{
break
case
1
:
err
=
errors
.
New
(
"该玩家已经是你的好友"
)
break
case
2
:
log
.
Println
(
"该玩家已经拒绝过你的请求"
)
break
case
3
:
err
=
errors
.
New
(
"该玩家已经拒绝过你的请求"
)
break
default
:
err
=
errors
.
New
(
"未知的好友关系类型"
)
break
}
}
if
err
!=
nil
{
return
nil
,
err
}
var
res
string
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment