Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
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) {
...
@@ -53,6 +53,8 @@ func (MySQLTitleQuery) Select(userID uint32) ([]schemas.TitleSchema, error) {
for
rows
.
Next
()
{
for
rows
.
Next
()
{
var
tmpTitle
schemas
.
TitleSchema
var
tmpTitle
schemas
.
TitleSchema
var
tmpUnlockScore
sql
.
NullInt32
var
tmpUnlockWin
sql
.
NullInt32
// Temporary subject
// Temporary subject
var
tmpSubjectID
sql
.
NullInt32
var
tmpSubjectID
sql
.
NullInt32
...
@@ -69,14 +71,26 @@ func (MySQLTitleQuery) Select(userID uint32) ([]schemas.TitleSchema, error) {
...
@@ -69,14 +71,26 @@ func (MySQLTitleQuery) Select(userID uint32) ([]schemas.TitleSchema, error) {
&
(
tmpSubjectShortForm
),
&
(
tmpSubjectShortForm
),
&
(
tmpSubjectDepartment
),
&
(
tmpSubjectDepartment
),
&
(
tmpSubjectDescription
),
&
(
tmpSubjectDescription
),
&
(
tmp
Title
.
UnlockScore
),
&
(
tmpUnlockScore
),
&
(
tmp
Title
.
UnlockWin
),
&
(
tmpUnlockWin
),
)
)
if
errFetch
!=
nil
{
if
errFetch
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"Cannot scan db values into titles list. "
+
errFetch
.
Error
())
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
{
if
tmpSubjectName
.
Valid
{
tmpTitle
.
Subject
=
&
schemas
.
Subject
{
tmpTitle
.
Subject
=
&
schemas
.
Subject
{
ID
:
uint32
(
tmpSubjectID
.
Int32
),
ID
:
uint32
(
tmpSubjectID
.
Int32
),
...
@@ -129,6 +143,9 @@ func (MySQLTitleQuery) SelectAll() ([]schemas.TitleSchema, error) {
...
@@ -129,6 +143,9 @@ func (MySQLTitleQuery) SelectAll() ([]schemas.TitleSchema, error) {
for
rows
.
Next
()
{
for
rows
.
Next
()
{
var
tmpTitle
schemas
.
TitleSchema
var
tmpTitle
schemas
.
TitleSchema
var
tmpUnlockScore
sql
.
NullInt32
var
tmpUnlockWin
sql
.
NullInt32
// Temporary subject
// Temporary subject
var
tmpSubjectID
sql
.
NullInt32
var
tmpSubjectID
sql
.
NullInt32
var
tmpSubjectName
sql
.
NullString
var
tmpSubjectName
sql
.
NullString
...
@@ -144,14 +161,26 @@ func (MySQLTitleQuery) SelectAll() ([]schemas.TitleSchema, error) {
...
@@ -144,14 +161,26 @@ func (MySQLTitleQuery) SelectAll() ([]schemas.TitleSchema, error) {
&
(
tmpSubjectShortForm
),
&
(
tmpSubjectShortForm
),
&
(
tmpSubjectDepartment
),
&
(
tmpSubjectDepartment
),
&
(
tmpSubjectDescription
),
&
(
tmpSubjectDescription
),
&
(
tmp
Title
.
UnlockScore
),
&
(
tmpUnlockScore
),
&
(
tmp
Title
.
UnlockWin
),
&
(
tmpUnlockWin
),
)
)
if
errFetch
!=
nil
{
if
errFetch
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"Cannot scan db values into titles list. "
+
errFetch
.
Error
())
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
{
if
tmpSubjectName
.
Valid
{
tmpTitle
.
Subject
=
&
schemas
.
Subject
{
tmpTitle
.
Subject
=
&
schemas
.
Subject
{
ID
:
uint32
(
tmpSubjectID
.
Int32
),
ID
:
uint32
(
tmpSubjectID
.
Int32
),
...
@@ -196,6 +225,9 @@ func (MySQLTitleQuery) SelectByID(titleID uint32) (*schemas.TitleSchema, error)
...
@@ -196,6 +225,9 @@ func (MySQLTitleQuery) SelectByID(titleID uint32) (*schemas.TitleSchema, error)
var
title
schemas
.
TitleSchema
var
title
schemas
.
TitleSchema
var
tmpUnlockScore
sql
.
NullInt32
var
tmpUnlockWin
sql
.
NullInt32
// Temporary subject
// Temporary subject
var
tmpSubjectID
sql
.
NullInt32
var
tmpSubjectID
sql
.
NullInt32
var
tmpSubjectName
sql
.
NullString
var
tmpSubjectName
sql
.
NullString
...
@@ -211,14 +243,26 @@ func (MySQLTitleQuery) SelectByID(titleID uint32) (*schemas.TitleSchema, error)
...
@@ -211,14 +243,26 @@ func (MySQLTitleQuery) SelectByID(titleID uint32) (*schemas.TitleSchema, error)
&
(
tmpSubjectShortForm
),
&
(
tmpSubjectShortForm
),
&
(
tmpSubjectDepartment
),
&
(
tmpSubjectDepartment
),
&
(
tmpSubjectDescription
),
&
(
tmpSubjectDescription
),
&
t
itle
.
UnlockScore
,
&
t
mp
UnlockScore
,
&
t
itle
.
UnlockWin
,
&
t
mp
UnlockWin
,
)
)
if
errScan
!=
nil
{
if
errScan
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"Could not get title form database. %s"
,
errScan
.
Error
())
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
{
if
tmpSubjectName
.
Valid
{
title
.
Subject
=
&
schemas
.
Subject
{
title
.
Subject
=
&
schemas
.
Subject
{
ID
:
uint32
(
tmpSubjectID
.
Int32
),
ID
:
uint32
(
tmpSubjectID
.
Int32
),
...
@@ -257,6 +301,7 @@ func (MySQLTitleQuery) SelectAndUpdateNew(userID uint32) ([]schemas.TitleSchema,
...
@@ -257,6 +301,7 @@ func (MySQLTitleQuery) SelectAndUpdateNew(userID uint32) ([]schemas.TitleSchema,
for
res
.
Next
()
{
for
res
.
Next
()
{
var
newTitle
=
schemas
.
TitleSchema
{}
var
newTitle
=
schemas
.
TitleSchema
{}
var
tmpUnlockScore
sql
.
NullInt32
var
tmpSubjectID
sql
.
NullInt32
var
tmpSubjectID
sql
.
NullInt32
var
tmpSubjectName
sql
.
NullString
var
tmpSubjectName
sql
.
NullString
var
tmpSubjectShortForm
sql
.
NullString
var
tmpSubjectShortForm
sql
.
NullString
...
@@ -270,12 +315,18 @@ func (MySQLTitleQuery) SelectAndUpdateNew(userID uint32) ([]schemas.TitleSchema,
...
@@ -270,12 +315,18 @@ func (MySQLTitleQuery) SelectAndUpdateNew(userID uint32) ([]schemas.TitleSchema,
&
(
tmpSubjectShortForm
),
&
(
tmpSubjectShortForm
),
&
(
tmpSubjectDepartment
),
&
(
tmpSubjectDepartment
),
&
(
tmpSubjectDescription
),
&
(
tmpSubjectDescription
),
&
newTitle
.
UnlockScore
)
&
tmp
UnlockScore
)
if
errScan
!=
nil
{
if
errScan
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"Could not scan new titles query result. %s"
,
errScan
.
Error
())
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
{
if
tmpSubjectID
.
Valid
{
// the title has a subject. subject is not null
// the title has a subject. subject is not null
var
subject
schemas
.
Subject
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