Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Game Server Go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
11
Issues
11
List
Boards
Labels
Service Desk
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
External Wiki
External Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Akamu
Game Server Go
Commits
84df1f3a
Commit
84df1f3a
authored
Oct 13, 2020
by
Julien Schröter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow unlock_score=null and unlock_win=null outside of title repository
parent
47d7405f
Pipeline
#2040
passed with stage
in 11 minutes and 30 seconds
Changes
3
Pipelines
5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
106 additions
and
12 deletions
+106
-12
endpoint/duel/query.go
endpoint/duel/query.go
+4
-0
endpoint/friend/query.go
endpoint/friend/query.go
+51
-6
endpoint/user/query.go
endpoint/user/query.go
+51
-6
No files found.
endpoint/duel/query.go
View file @
84df1f3a
...
...
@@ -128,9 +128,13 @@ func (nT *nullableTitle) ToTitle(title *schemas.TitleSchema) bool {
}
if
nT
.
UnlockScore
.
Valid
{
title
.
UnlockScore
=
int32
(
nT
.
UnlockScore
.
Int64
)
}
else
{
title
.
UnlockScore
=
-
1
}
if
nT
.
UnlockWin
.
Valid
{
title
.
UnlockWin
=
int32
(
nT
.
UnlockWin
.
Int64
)
}
else
{
title
.
UnlockWin
=
-
1
}
return
nT
.
ID
.
Valid
&&
nT
.
Name
.
Valid
}
...
...
endpoint/friend/query.go
View file @
84df1f3a
...
...
@@ -66,6 +66,9 @@ func (MySQLFriendQuery) SelectByID(userID uint32) ([]schemas.InfoUserSchema, err
var
tmpSubjectDepartment
sql
.
NullString
var
tmpSubjectDescription
sql
.
NullString
var
tmpUnlockScore
sql
.
NullInt32
var
tmpUnlockWin
sql
.
NullInt32
if
errFetch
:=
rows
.
Scan
(
&
tmpFriend
.
ID
,
&
tmpFriend
.
Username
,
...
...
@@ -79,8 +82,8 @@ func (MySQLFriendQuery) SelectByID(userID uint32) ([]schemas.InfoUserSchema, err
&
(
tmpSubjectShortForm
),
&
(
tmpSubjectDepartment
),
&
(
tmpSubjectDescription
),
&
tmp
Friend
.
SelectedTitle
.
UnlockScore
,
&
tmp
Friend
.
SelectedTitle
.
UnlockWin
,
&
tmpUnlockScore
,
&
tmpUnlockWin
,
);
errFetch
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"Cannot scan db values into friends list. "
+
errFetch
.
Error
())
}
...
...
@@ -95,6 +98,18 @@ func (MySQLFriendQuery) SelectByID(userID uint32) ([]schemas.InfoUserSchema, err
}
}
if
tmpUnlockScore
.
Valid
{
tmpFriend
.
SelectedTitle
.
UnlockScore
=
tmpUnlockScore
.
Int32
}
else
{
tmpFriend
.
SelectedTitle
.
UnlockScore
=
-
1
}
if
tmpUnlockWin
.
Valid
{
tmpFriend
.
SelectedTitle
.
UnlockWin
=
tmpUnlockWin
.
Int32
}
else
{
tmpFriend
.
SelectedTitle
.
UnlockWin
=
-
1
}
friends
=
append
(
friends
,
tmpFriend
)
}
...
...
@@ -209,6 +224,9 @@ func (MySQLFriendQuery) Insert(userID, userIDToAdd uint32) ([]schemas.InfoUserSc
var
tmpSubjectDepartment
sql
.
NullString
var
tmpSubjectDescription
sql
.
NullString
var
tmpUnlockScore
sql
.
NullInt32
var
tmpUnlockWin
sql
.
NullInt32
if
errResult
:=
rows
.
Scan
(
&
tmpFriend
.
ID
,
&
tmpFriend
.
Username
,
...
...
@@ -222,8 +240,8 @@ func (MySQLFriendQuery) Insert(userID, userIDToAdd uint32) ([]schemas.InfoUserSc
&
(
tmpSubjectShortForm
),
&
(
tmpSubjectDepartment
),
&
(
tmpSubjectDescription
),
&
tmp
Friend
.
SelectedTitle
.
UnlockScore
,
&
tmp
Friend
.
SelectedTitle
.
UnlockWin
,
&
tmpUnlockScore
,
&
tmpUnlockWin
,
);
errResult
!=
nil
{
if
tmpSubjectName
.
Valid
{
tmpFriend
.
SelectedTitle
.
Subject
=
&
schemas
.
Subject
{
...
...
@@ -235,6 +253,18 @@ func (MySQLFriendQuery) Insert(userID, userIDToAdd uint32) ([]schemas.InfoUserSc
}
}
if
tmpUnlockScore
.
Valid
{
tmpFriend
.
SelectedTitle
.
UnlockScore
=
tmpUnlockScore
.
Int32
}
else
{
tmpFriend
.
SelectedTitle
.
UnlockScore
=
-
1
}
if
tmpUnlockWin
.
Valid
{
tmpFriend
.
SelectedTitle
.
UnlockWin
=
tmpUnlockWin
.
Int32
}
else
{
tmpFriend
.
SelectedTitle
.
UnlockWin
=
-
1
}
return
nil
,
fmt
.
Errorf
(
"failed to provide updated friends list."
+
errResult
.
Error
())
}
result
=
append
(
result
,
tmpFriend
)
...
...
@@ -309,6 +339,9 @@ func (MySQLFriendQuery) Delete(userID, userIDToRemove uint32) ([]schemas.InfoUse
var
tmpSubjectDepartment
sql
.
NullString
var
tmpSubjectDescription
sql
.
NullString
var
tmpUnlockScore
sql
.
NullInt32
var
tmpUnlockWin
sql
.
NullInt32
if
errResult
:=
rows
.
Scan
(
&
user
.
ID
,
&
user
.
Username
,
...
...
@@ -322,8 +355,8 @@ func (MySQLFriendQuery) Delete(userID, userIDToRemove uint32) ([]schemas.InfoUse
&
(
tmpSubjectShortForm
),
&
(
tmpSubjectDepartment
),
&
(
tmpSubjectDescription
),
&
user
.
SelectedTitle
.
UnlockScore
,
&
user
.
SelectedTitle
.
UnlockWin
,
&
tmp
UnlockScore
,
&
tmp
UnlockWin
,
);
errResult
!=
nil
{
if
tmpSubjectName
.
Valid
{
user
.
SelectedTitle
.
Subject
=
&
schemas
.
Subject
{
...
...
@@ -335,6 +368,18 @@ func (MySQLFriendQuery) Delete(userID, userIDToRemove uint32) ([]schemas.InfoUse
}
}
if
tmpUnlockScore
.
Valid
{
user
.
SelectedTitle
.
UnlockScore
=
tmpUnlockScore
.
Int32
}
else
{
user
.
SelectedTitle
.
UnlockScore
=
-
1
}
if
tmpUnlockWin
.
Valid
{
user
.
SelectedTitle
.
UnlockWin
=
tmpUnlockWin
.
Int32
}
else
{
user
.
SelectedTitle
.
UnlockWin
=
-
1
}
return
nil
,
fmt
.
Errorf
(
"failed to provide updated friends list."
+
errResult
.
Error
())
}
result
=
append
(
result
,
user
)
...
...
endpoint/user/query.go
View file @
84df1f3a
...
...
@@ -176,6 +176,9 @@ func (MySQLUserQuery) Select(id uint32) ([]schemas.FullUserSchema, error) {
var
tmpSubjectDepartment
sql
.
NullString
var
tmpSubjectDescription
sql
.
NullString
var
tmpUnlockScore
sql
.
NullInt32
var
tmpUnlockWin
sql
.
NullInt32
//make sql query and save response to the user pointer
err
=
stmt
.
QueryRow
(
id
)
.
Scan
(
&
users
[
0
]
.
ID
,
...
...
@@ -194,8 +197,8 @@ func (MySQLUserQuery) Select(id uint32) ([]schemas.FullUserSchema, error) {
&
(
tmpSubjectShortForm
),
&
(
tmpSubjectDepartment
),
&
(
tmpSubjectDescription
),
&
users
[
0
]
.
SelectedTitle
.
UnlockScore
,
&
users
[
0
]
.
SelectedTitle
.
UnlockWin
,
&
tmp
UnlockScore
,
&
tmp
UnlockWin
,
&
users
[
0
]
.
Verified
,
&
users
[
0
]
.
University
,
&
users
[
0
]
.
Level
)
...
...
@@ -217,6 +220,18 @@ func (MySQLUserQuery) Select(id uint32) ([]schemas.FullUserSchema, error) {
}
}
if
tmpUnlockScore
.
Valid
{
users
[
0
]
.
SelectedTitle
.
UnlockScore
=
tmpUnlockScore
.
Int32
}
else
{
users
[
0
]
.
SelectedTitle
.
UnlockScore
=
-
1
}
if
tmpUnlockWin
.
Valid
{
users
[
0
]
.
SelectedTitle
.
UnlockWin
=
tmpUnlockWin
.
Int32
}
else
{
users
[
0
]
.
SelectedTitle
.
UnlockWin
=
-
1
}
//return with no errors
return
users
,
nil
}
...
...
@@ -244,6 +259,9 @@ func (MySQLUserQuery) SelectByUsername(username string) ([]schemas.InfoUserSchem
var
tmpSubjectDepartment
sql
.
NullString
var
tmpSubjectDescription
sql
.
NullString
var
tmpUnlockScore
sql
.
NullInt32
var
tmpUnlockWin
sql
.
NullInt32
//make sql query and save response to the user pointer
err
=
stmt
.
QueryRow
(
username
)
.
Scan
(
&
user
[
0
]
.
ID
,
...
...
@@ -258,8 +276,8 @@ func (MySQLUserQuery) SelectByUsername(username string) ([]schemas.InfoUserSchem
&
(
tmpSubjectShortForm
),
&
(
tmpSubjectDepartment
),
&
(
tmpSubjectDescription
),
&
user
[
0
]
.
SelectedTitle
.
UnlockScore
,
&
user
[
0
]
.
SelectedTitle
.
UnlockWin
)
&
tmp
UnlockScore
,
&
tmp
UnlockWin
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -274,6 +292,18 @@ func (MySQLUserQuery) SelectByUsername(username string) ([]schemas.InfoUserSchem
}
}
if
tmpUnlockScore
.
Valid
{
user
[
0
]
.
SelectedTitle
.
UnlockScore
=
tmpUnlockScore
.
Int32
}
else
{
user
[
0
]
.
SelectedTitle
.
UnlockScore
=
-
1
}
if
tmpUnlockWin
.
Valid
{
user
[
0
]
.
SelectedTitle
.
UnlockWin
=
tmpUnlockWin
.
Int32
}
else
{
user
[
0
]
.
SelectedTitle
.
UnlockWin
=
-
1
}
//return with no errors
return
user
,
nil
}
...
...
@@ -463,6 +493,9 @@ func (MySQLUserQuery) SelectAll() ([]schemas.InfoUserSchema, error) {
var
tmpSubjectDepartment
sql
.
NullString
var
tmpSubjectDescription
sql
.
NullString
var
tmpUnlockScore
sql
.
NullInt32
var
tmpUnlockWin
sql
.
NullInt32
errScan
:=
rows
.
Scan
(
&
tmpUser
.
ID
,
&
tmpUser
.
Username
,
...
...
@@ -476,8 +509,8 @@ func (MySQLUserQuery) SelectAll() ([]schemas.InfoUserSchema, error) {
&
(
tmpSubjectShortForm
),
&
(
tmpSubjectDepartment
),
&
(
tmpSubjectDescription
),
&
tmpU
ser
.
SelectedTitle
.
U
nlockScore
,
&
tmpU
ser
.
SelectedTitle
.
U
nlockWin
,
&
tmpUnlockScore
,
&
tmpUnlockWin
,
)
if
errScan
!=
nil
{
...
...
@@ -494,6 +527,18 @@ func (MySQLUserQuery) SelectAll() ([]schemas.InfoUserSchema, error) {
}
}
if
tmpUnlockScore
.
Valid
{
tmpUser
.
SelectedTitle
.
UnlockScore
=
tmpUnlockScore
.
Int32
}
else
{
tmpUser
.
SelectedTitle
.
UnlockScore
=
-
1
}
if
tmpUnlockWin
.
Valid
{
tmpUser
.
SelectedTitle
.
UnlockWin
=
tmpUnlockWin
.
Int32
}
else
{
tmpUser
.
SelectedTitle
.
UnlockWin
=
-
1
}
users
=
append
(
users
,
tmpUser
)
}
...
...
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