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
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
35 deletions
+36
-35
live_title_record.go
models/live_title_record.go
+14
-26
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,40 +2,28 @@ package models
import
(
"bwallet/pkg/setting"
"fmt"
"github.com/jinzhu/gorm"
)
type
LiveTitleRecord
struct
{
Model
LiveId
int
`json:"live_id"`
CurrentTitle
string
`json:"current_title"`
NewTitle
string
`json:"new_title"`
Status
uint8
`json:"status"`
PlatformId
int64
`gorm:"not null;default:0" json:"platform_id"`
LiveInfo
*
LiveInfo
`gorm:"foreignkey:LiveId" json:"live"`
LiveId
int
`json:"live_id"`
CurrentTitle
string
`json:"current_title"`
NewTitle
string
`json:"new_title"`
Status
uint8
`json:"status"`
PlatformId
int64
`json:"platform_id,omitempty"`
CreateTime
int64
`json:"create_time,omitempty"`
CreatedTime
string
`json:"created_time,omitempty"`
ApplyId
uint32
`json:"apply_id"`
LiveInfo
*
LiveInfo
`gorm:"foreignkey:LiveId" json:"live,omitempty"`
}
func
(
w
LiveTitleRecord
)
TableName
()
string
{
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
)
{
var
live
LiveTitleRecord
err
:=
db
.
Select
(
"id"
)
.
Where
(
"id = ?"
,
id
)
.
First
(
&
live
)
.
Error
...
...
@@ -62,8 +50,8 @@ func GetLiveTitleRecordTotal(maps interface{}) (int, error) {
func
GetLiveTitleRecord
(
pageNum
,
pageSize
int
,
maps
interface
{})
([]
*
LiveTitleRecord
,
error
)
{
var
live
[]
*
LiveTitleRecord
err
:=
db
.
Where
(
maps
)
.
Preload
(
"LiveInfo"
)
.
Order
(
"create_time desc"
)
.
Offset
(
pageNum
)
.
Limit
(
pageSize
)
.
Find
(
&
live
)
.
Error
fmt
.
Println
(
maps
)
err
:=
db
.
Debug
()
.
Where
(
maps
)
.
Preload
(
"LiveInfo"
)
.
Order
(
"create_time desc"
)
.
Offset
(
pageNum
)
.
Limit
(
pageSize
)
.
Find
(
&
live
)
.
Error
if
err
!=
nil
&&
err
!=
gorm
.
ErrRecordNotFound
{
return
nil
,
err
}
...
...
@@ -78,6 +66,7 @@ func AddLiveTitleRecord(data map[string]interface{}) (error) {
NewTitle
:
data
[
"new_title"
]
.
(
string
),
Status
:
data
[
"sort"
]
.
(
uint8
),
PlatformId
:
data
[
"platform_id"
]
.
(
int64
),
CreateTime
:
data
[
"create_time"
]
.
(
int64
),
}
if
err
:=
db
.
Create
(
&
live
)
.
Error
;
err
!=
nil
{
...
...
@@ -93,4 +82,4 @@ func EditLiveTitleRecord(id int, data interface{}) error {
}
return
nil
}
\ No newline at end of file
}
service/live_info_service/live_info.go
View file @
0ea19b5c
...
...
@@ -115,13 +115,12 @@ func (l *LiveInfo) getMaps() (map[string]interface{}) {
maps
[
"category_id"
]
=
l
.
CategoryId
}
if
l
.
Status
!=
0
{
maps
[
"status"
]
=
l
.
Status
}
if
l
.
PlatformId
!=
0
{
maps
[
"platform_id"
]
=
l
.
PlatformId
}
maps
[
"status"
]
=
l
.
Status
return
maps
}
service/live_title_record_service/live_title_record.go
View file @
0ea19b5c
...
...
@@ -2,6 +2,8 @@ package live_title_record_service
import
(
"bwallet/models"
"fmt"
"time"
)
type
LiveTitleRecord
struct
{
...
...
@@ -18,13 +20,27 @@ type LiveTitleRecord struct {
func
(
l
*
LiveTitleRecord
)
GetAll
()
([]
*
models
.
LiveTitleRecord
,
error
)
{
var
live
[]
*
models
.
LiveTitleRecord
fmt
.
Println
(
l
.
getMaps
())
live
,
err
:=
models
.
GetLiveTitleRecord
(
l
.
PageNum
,
l
.
PageSize
,
l
.
getMaps
())
if
err
!=
nil
{
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
{
...
...
@@ -69,14 +85,12 @@ func (l *LiveTitleRecord) getMaps() (map[string]interface{}) {
maps
[
"id"
]
=
l
.
Id
}
if
l
.
Status
!=
0
{
maps
[
"status"
]
=
l
.
Status
}
if
l
.
PlatformId
!=
0
{
maps
[
"platform_id"
]
=
l
.
PlatformId
}
maps
[
"status"
]
=
l
.
Status
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