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
494a2c82
Commit
494a2c82
authored
Oct 12, 2020
by
Julien Schröter
Committed by
Julien Schröter
Oct 13, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow title's unlock_score or unlock_win to be null
parent
31513bea
Pipeline
#2020
canceled with stages
in 1 minute and 52 seconds
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
58 additions
and
7 deletions
+58
-7
endpoint/title/query.go
endpoint/title/query.go
+58
-7
No files found.
endpoint/title/query.go
View file @
494a2c82
...
...
@@ -53,6 +53,8 @@ func (MySQLTitleQuery) Select(userID uint32) ([]schemas.TitleSchema, error) {
for
rows
.
Next
()
{
var
tmpTitle
schemas
.
TitleSchema
var
tmpUnlockScore
sql
.
NullInt32
var
tmpUnlockWin
sql
.
NullInt32
// Temporary subject
var
tmpSubjectID
sql
.
NullInt32
...
...
@@ -69,14 +71,26 @@ func (MySQLTitleQuery) Select(userID uint32) ([]schemas.TitleSchema, error) {
&
(
tmpSubjectShortForm
),
&
(
tmpSubjectDepartment
),
&
(
tmpSubjectDescription
),
&
(
tmp
Title
.
UnlockScore
),
&
(
tmp
Title
.
UnlockWin
),
&
(
tmpUnlockScore
),
&
(
tmpUnlockWin
),
)
if
errFetch
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"Cannot scan db values into titles list. "
+
errFetch
.
Error
())
}
if
tmpUnlockScore
.
Valid
{
tmpTitle
.
UnlockScore
=
tmpUnlockScore
.
Int32
}
else
{
tmpTitle
.
UnlockScore
=
-
1
}
if
tmpUnlockWin
.
Valid
{
tmpTitle
.
UnlockWin
=
tmpUnlockWin
.
Int32
}
else
{
tmpTitle
.
UnlockWin
=
-
1
}
if
tmpSubjectName
.
Valid
{
tmpTitle
.
Subject
=
&
schemas
.
Subject
{
ID
:
uint32
(
tmpSubjectID
.
Int32
),
...
...
@@ -129,6 +143,9 @@ func (MySQLTitleQuery) SelectAll() ([]schemas.TitleSchema, error) {
for
rows
.
Next
()
{
var
tmpTitle
schemas
.
TitleSchema
var
tmpUnlockScore
sql
.
NullInt32
var
tmpUnlockWin
sql
.
NullInt32
// Temporary subject
var
tmpSubjectID
sql
.
NullInt32
var
tmpSubjectName
sql
.
NullString
...
...
@@ -144,14 +161,26 @@ func (MySQLTitleQuery) SelectAll() ([]schemas.TitleSchema, error) {
&
(
tmpSubjectShortForm
),
&
(
tmpSubjectDepartment
),
&
(
tmpSubjectDescription
),
&
(
tmp
Title
.
UnlockScore
),
&
(
tmp
Title
.
UnlockWin
),
&
(
tmpUnlockScore
),
&
(
tmpUnlockWin
),
)
if
errFetch
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"Cannot scan db values into titles list. "
+
errFetch
.
Error
())
}
if
tmpUnlockScore
.
Valid
{
tmpTitle
.
UnlockScore
=
tmpUnlockScore
.
Int32
}
else
{
tmpTitle
.
UnlockScore
=
-
1
}
if
tmpUnlockWin
.
Valid
{
tmpTitle
.
UnlockWin
=
tmpUnlockWin
.
Int32
}
else
{
tmpTitle
.
UnlockWin
=
-
1
}
if
tmpSubjectName
.
Valid
{
tmpTitle
.
Subject
=
&
schemas
.
Subject
{
ID
:
uint32
(
tmpSubjectID
.
Int32
),
...
...
@@ -196,6 +225,9 @@ func (MySQLTitleQuery) SelectByID(titleID uint32) (*schemas.TitleSchema, error)
var
title
schemas
.
TitleSchema
var
tmpUnlockScore
sql
.
NullInt32
var
tmpUnlockWin
sql
.
NullInt32
// Temporary subject
var
tmpSubjectID
sql
.
NullInt32
var
tmpSubjectName
sql
.
NullString
...
...
@@ -211,14 +243,26 @@ func (MySQLTitleQuery) SelectByID(titleID uint32) (*schemas.TitleSchema, error)
&
(
tmpSubjectShortForm
),
&
(
tmpSubjectDepartment
),
&
(
tmpSubjectDescription
),
&
t
itle
.
UnlockScore
,
&
t
itle
.
UnlockWin
,
&
t
mp
UnlockScore
,
&
t
mp
UnlockWin
,
)
if
errScan
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"Could not get title form database. %s"
,
errScan
.
Error
())
}
if
tmpUnlockScore
.
Valid
{
title
.
UnlockScore
=
tmpUnlockScore
.
Int32
}
else
{
title
.
UnlockScore
=
-
1
}
if
tmpUnlockWin
.
Valid
{
title
.
UnlockWin
=
tmpUnlockWin
.
Int32
}
else
{
title
.
UnlockWin
=
-
1
}
if
tmpSubjectName
.
Valid
{
title
.
Subject
=
&
schemas
.
Subject
{
ID
:
uint32
(
tmpSubjectID
.
Int32
),
...
...
@@ -257,6 +301,7 @@ func (MySQLTitleQuery) SelectAndUpdateNew(userID uint32) ([]schemas.TitleSchema,
for
res
.
Next
()
{
var
newTitle
=
schemas
.
TitleSchema
{}
var
tmpUnlockScore
sql
.
NullInt32
var
tmpSubjectID
sql
.
NullInt32
var
tmpSubjectName
sql
.
NullString
var
tmpSubjectShortForm
sql
.
NullString
...
...
@@ -270,12 +315,18 @@ func (MySQLTitleQuery) SelectAndUpdateNew(userID uint32) ([]schemas.TitleSchema,
&
(
tmpSubjectShortForm
),
&
(
tmpSubjectDepartment
),
&
(
tmpSubjectDescription
),
&
newTitle
.
UnlockScore
)
&
tmp
UnlockScore
)
if
errScan
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"Could not scan new titles query result. %s"
,
errScan
.
Error
())
}
if
tmpUnlockScore
.
Valid
{
newTitle
.
UnlockScore
=
tmpUnlockScore
.
Int32
}
else
{
newTitle
.
UnlockScore
=
-
1
}
if
tmpSubjectID
.
Valid
{
// the title has a subject. subject is not null
var
subject
schemas
.
Subject
...
...
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