Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
bwallet
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Go
bwallet
Commits
0ea19b5c
Commit
0ea19b5c
authored
Nov 30, 2020
by
shajiaiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化
parent
57dfa249
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
29 deletions
+31
-29
live_title_record.go
models/live_title_record.go
+9
-20
live_info.go
service/live_info_service/live_info.go
+2
-3
live_title_record.go
service/live_title_record_service/live_title_record.go
+20
-6
No files found.
models/live_title_record.go
View file @
0ea19b5c
...
@@ -2,6 +2,7 @@ package models
...
@@ -2,6 +2,7 @@ package models
import
(
import
(
"bwallet/pkg/setting"
"bwallet/pkg/setting"
"fmt"
"github.com/jinzhu/gorm"
"github.com/jinzhu/gorm"
)
)
...
@@ -12,30 +13,17 @@ type LiveTitleRecord struct {
...
@@ -12,30 +13,17 @@ type LiveTitleRecord struct {
CurrentTitle
string
`json:"current_title"`
CurrentTitle
string
`json:"current_title"`
NewTitle
string
`json:"new_title"`
NewTitle
string
`json:"new_title"`
Status
uint8
`json:"status"`
Status
uint8
`json:"status"`
PlatformId
int64
`gorm:"not null;default:0" json:"platform_id"`
PlatformId
int64
`json:"platform_id,omitempty"`
CreateTime
int64
`json:"create_time,omitempty"`
LiveInfo
*
LiveInfo
`gorm:"foreignkey:LiveId" json:"live"`
CreatedTime
string
`json:"created_time,omitempty"`
ApplyId
uint32
`json:"apply_id"`
LiveInfo
*
LiveInfo
`gorm:"foreignkey:LiveId" json:"live,omitempty"`
}
}
func
(
w
LiveTitleRecord
)
TableName
()
string
{
func
(
w
LiveTitleRecord
)
TableName
()
string
{
return
setting
.
DatabaseSetting
.
Name_Sources
+
".wallet_live_title_record"
return
setting
.
DatabaseSetting
.
Name_Sources
+
".wallet_live_title_record"
}
}
func
GetOneLiveTitleRecord
(
id
int
)
(
*
LiveTitleRecord
,
error
)
{
var
live
LiveTitleRecord
err
:=
db
.
Where
(
"id = ?"
,
id
)
.
First
(
&
live
)
.
Error
if
err
!=
nil
&&
err
!=
gorm
.
ErrRecordNotFound
{
return
nil
,
err
}
err
=
db
.
Model
(
&
live
)
.
Error
if
err
!=
nil
&&
err
!=
gorm
.
ErrRecordNotFound
{
return
nil
,
err
}
return
&
live
,
nil
}
func
ExistLiveTitleRecordById
(
id
int
)
(
bool
,
error
)
{
func
ExistLiveTitleRecordById
(
id
int
)
(
bool
,
error
)
{
var
live
LiveTitleRecord
var
live
LiveTitleRecord
err
:=
db
.
Select
(
"id"
)
.
Where
(
"id = ?"
,
id
)
.
First
(
&
live
)
.
Error
err
:=
db
.
Select
(
"id"
)
.
Where
(
"id = ?"
,
id
)
.
First
(
&
live
)
.
Error
...
@@ -62,8 +50,8 @@ func GetLiveTitleRecordTotal(maps interface{}) (int, error) {
...
@@ -62,8 +50,8 @@ func GetLiveTitleRecordTotal(maps interface{}) (int, error) {
func
GetLiveTitleRecord
(
pageNum
,
pageSize
int
,
maps
interface
{})
([]
*
LiveTitleRecord
,
error
)
{
func
GetLiveTitleRecord
(
pageNum
,
pageSize
int
,
maps
interface
{})
([]
*
LiveTitleRecord
,
error
)
{
var
live
[]
*
LiveTitleRecord
var
live
[]
*
LiveTitleRecord
fmt
.
Println
(
maps
)
err
:=
db
.
Where
(
maps
)
.
Preload
(
"LiveInfo"
)
.
Order
(
"create_time desc"
)
.
Offset
(
pageNum
)
.
Limit
(
pageSize
)
.
Find
(
&
live
)
.
Error
err
:=
db
.
Debug
()
.
Where
(
maps
)
.
Preload
(
"LiveInfo"
)
.
Order
(
"create_time desc"
)
.
Offset
(
pageNum
)
.
Limit
(
pageSize
)
.
Find
(
&
live
)
.
Error
if
err
!=
nil
&&
err
!=
gorm
.
ErrRecordNotFound
{
if
err
!=
nil
&&
err
!=
gorm
.
ErrRecordNotFound
{
return
nil
,
err
return
nil
,
err
}
}
...
@@ -78,6 +66,7 @@ func AddLiveTitleRecord(data map[string]interface{}) (error) {
...
@@ -78,6 +66,7 @@ func AddLiveTitleRecord(data map[string]interface{}) (error) {
NewTitle
:
data
[
"new_title"
]
.
(
string
),
NewTitle
:
data
[
"new_title"
]
.
(
string
),
Status
:
data
[
"sort"
]
.
(
uint8
),
Status
:
data
[
"sort"
]
.
(
uint8
),
PlatformId
:
data
[
"platform_id"
]
.
(
int64
),
PlatformId
:
data
[
"platform_id"
]
.
(
int64
),
CreateTime
:
data
[
"create_time"
]
.
(
int64
),
}
}
if
err
:=
db
.
Create
(
&
live
)
.
Error
;
err
!=
nil
{
if
err
:=
db
.
Create
(
&
live
)
.
Error
;
err
!=
nil
{
...
...
service/live_info_service/live_info.go
View file @
0ea19b5c
...
@@ -115,13 +115,12 @@ func (l *LiveInfo) getMaps() (map[string]interface{}) {
...
@@ -115,13 +115,12 @@ func (l *LiveInfo) getMaps() (map[string]interface{}) {
maps
[
"category_id"
]
=
l
.
CategoryId
maps
[
"category_id"
]
=
l
.
CategoryId
}
}
if
l
.
Status
!=
0
{
maps
[
"status"
]
=
l
.
Status
}
if
l
.
PlatformId
!=
0
{
if
l
.
PlatformId
!=
0
{
maps
[
"platform_id"
]
=
l
.
PlatformId
maps
[
"platform_id"
]
=
l
.
PlatformId
}
}
maps
[
"status"
]
=
l
.
Status
return
maps
return
maps
}
}
service/live_title_record_service/live_title_record.go
View file @
0ea19b5c
...
@@ -2,6 +2,8 @@ package live_title_record_service
...
@@ -2,6 +2,8 @@ package live_title_record_service
import
(
import
(
"bwallet/models"
"bwallet/models"
"fmt"
"time"
)
)
type
LiveTitleRecord
struct
{
type
LiveTitleRecord
struct
{
...
@@ -18,13 +20,27 @@ type LiveTitleRecord struct {
...
@@ -18,13 +20,27 @@ type LiveTitleRecord struct {
func
(
l
*
LiveTitleRecord
)
GetAll
()
([]
*
models
.
LiveTitleRecord
,
error
)
{
func
(
l
*
LiveTitleRecord
)
GetAll
()
([]
*
models
.
LiveTitleRecord
,
error
)
{
var
live
[]
*
models
.
LiveTitleRecord
var
live
[]
*
models
.
LiveTitleRecord
fmt
.
Println
(
l
.
getMaps
())
live
,
err
:=
models
.
GetLiveTitleRecord
(
l
.
PageNum
,
l
.
PageSize
,
l
.
getMaps
())
live
,
err
:=
models
.
GetLiveTitleRecord
(
l
.
PageNum
,
l
.
PageSize
,
l
.
getMaps
())
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
return
live
,
nil
var
records
[]
*
models
.
LiveTitleRecord
for
_
,
value
:=
range
live
{
record
:=
&
models
.
LiveTitleRecord
{}
record
.
ID
=
value
.
ID
record
.
CurrentTitle
=
value
.
CurrentTitle
record
.
NewTitle
=
value
.
NewTitle
record
.
Status
=
value
.
Status
record
.
LiveId
=
value
.
LiveId
record
.
CreatedTime
=
time
.
Unix
(
value
.
CreateTime
,
0
)
.
Format
(
"2006-01-02 15:04:05"
)
record
.
ApplyId
=
value
.
LiveInfo
.
ApplyId
records
=
append
(
records
,
record
)
}
return
records
,
nil
}
}
func
(
l
*
LiveTitleRecord
)
Add
()
error
{
func
(
l
*
LiveTitleRecord
)
Add
()
error
{
...
@@ -69,14 +85,12 @@ func (l *LiveTitleRecord) getMaps() (map[string]interface{}) {
...
@@ -69,14 +85,12 @@ func (l *LiveTitleRecord) getMaps() (map[string]interface{}) {
maps
[
"id"
]
=
l
.
Id
maps
[
"id"
]
=
l
.
Id
}
}
if
l
.
Status
!=
0
{
maps
[
"status"
]
=
l
.
Status
}
if
l
.
PlatformId
!=
0
{
if
l
.
PlatformId
!=
0
{
maps
[
"platform_id"
]
=
l
.
PlatformId
maps
[
"platform_id"
]
=
l
.
PlatformId
}
}
maps
[
"status"
]
=
l
.
Status
return
maps
return
maps
}
}
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