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
b93d01f6
Commit
b93d01f6
authored
Jan 07, 2021
by
shajiaiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
live api
parent
8ea05fb5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
61 additions
and
12 deletions
+61
-12
live_info.go
models/live_info.go
+12
-3
live.go
routers/api/app/live.go
+21
-3
router.go
routers/router.go
+2
-0
live_info.go
service/live_info_service/live_info.go
+26
-4
live_info.go
validate_service/live_info.go
+0
-2
No files found.
models/live_info.go
View file @
b93d01f6
...
...
@@ -13,7 +13,6 @@ type LiveInfo struct {
Cover
string
`json:"cover"`
CategoryId
uint8
`json:"category_id"`
Duration
uint32
`json:"duration"`
Attendance
uint32
`json:"attendance"`
Mode
uint8
`json:"mode"`
ApplyId
uint32
`json:"apply_id"`
ApplyName
string
`json:"apply_id"`
...
...
@@ -28,6 +27,17 @@ type LiveInfo struct {
Category
*
LiveCategory
`gorm:"foreignkey:CategoryId" json:"category"`
}
type
LiveInfoClientResp
struct
{
Id
int
`json:"id"`
Title
string
`json:"title"`
Cover
string
`json:"cover"`
Duration
uint32
`json:"duration"`
Status
uint8
`json:"status"`
LiveStatus
uint8
`json:"live_status"`
Sort
uint8
`json:"sort"`
Category
string
`json:"category"`
}
const
(
PROCESSING
=
0
//待审核
PEDDING_PAYMENT
=
1
//审核通过(待支付)
...
...
@@ -98,8 +108,7 @@ func AddLiveInfo(data map[string]interface{}) (error) {
Cover
:
data
[
"cover"
]
.
(
string
),
CategoryId
:
data
[
"category_id"
]
.
(
uint8
),
Duration
:
data
[
"duration"
]
.
(
uint32
),
Attendance
:
data
[
"attendance"
]
.
(
uint32
),
Mode
:
data
[
"mode"
]
.
(
uint8
),
Mode
:
1
,
ApplyId
:
data
[
"apply_id"
]
.
(
uint32
),
ApplyName
:
data
[
"apply_name"
]
.
(
string
),
PlatformId
:
data
[
"platform_id"
]
.
(
int64
),
...
...
routers/api/app/live.go
View file @
b93d01f6
...
...
@@ -31,8 +31,6 @@ func AddLive(c *gin.Context) {
Cover
:
info
.
Cover
,
CategoryId
:
info
.
CategoryId
,
Duration
:
info
.
Duration
,
Attendance
:
info
.
Attendance
,
Mode
:
info
.
Mode
,
ApplyId
:
info
.
ApplyId
,
ApplyName
:
info
.
ApplyName
,
PlatformId
:
info
.
PlatformId
,
...
...
@@ -72,7 +70,7 @@ func GetLiveInfos(c *gin.Context) {
return
}
info
,
err
:=
infoService
.
GetAll
()
info
,
err
:=
infoService
.
GetAll
ForClient
()
if
err
!=
nil
{
handler
.
SendResponse
(
c
,
errno
.
InternalServerError
,
nil
)
return
...
...
@@ -137,3 +135,23 @@ func ModifyTitle(c *gin.Context) {
handler
.
SendResponse
(
c
,
nil
,
nil
)
}
func
LiveStatus
(
c
*
gin
.
Context
)
{
}
func
GetLiveCharge
(
c
*
gin
.
Context
)
{
platform_id
,
_
:=
strconv
.
Atoi
(
c
.
Request
.
Header
.
Get
(
"FZM-PLATFORM-ID"
))
valid
:=
validation
.
Validation
{}
valid
.
Min
(
platform_id
,
1
,
"platform_id"
)
.
Message
(
"平台Id不能为空"
)
if
valid
.
HasErrors
()
{
handler
.
SendResponse
(
c
,
valid
.
Errors
[
0
],
nil
)
return
}
data
:=
make
(
map
[
string
]
interface
{})
data
[
"uint"
]
=
"BTY"
data
[
"uint_price"
]
=
1.1
handler
.
SendResponse
(
c
,
nil
,
data
)
}
routers/router.go
View file @
b93d01f6
...
...
@@ -41,6 +41,8 @@ func InitRouter() *gin.Engine {
client
.
GET
(
"/live"
,
app
.
GetLiveInfos
)
client
.
PUT
(
"/live-title"
,
app
.
ModifyTitle
)
client
.
GET
(
"/live-categories"
,
app
.
GetLiveCategories
)
client
.
GET
(
"/live-charge"
,
app
.
GetLiveCharge
)
client
.
PUT
(
"/live/status"
,
app
.
LiveStatus
)
api
:=
r
.
Group
(
"/api"
)
...
...
service/live_info_service/live_info.go
View file @
b93d01f6
...
...
@@ -11,7 +11,6 @@ type LiveInfo struct {
Cover
string
CategoryId
uint8
Duration
uint32
Attendance
uint32
Mode
uint8
ApplyId
uint32
ApplyName
string
...
...
@@ -46,6 +45,32 @@ func (l *LiveInfo) GetAll() ([]*models.LiveInfo, error) {
return
live
,
nil
}
func
(
l
*
LiveInfo
)
GetAllForClient
()
([]
*
models
.
LiveInfoClientResp
,
error
)
{
var
live
[]
*
models
.
LiveInfo
live
,
err
:=
models
.
GetLiveInfo
(
l
.
PageNum
,
l
.
PageSize
,
l
.
getMaps
())
if
err
!=
nil
{
return
nil
,
err
}
var
records
[]
*
models
.
LiveInfoClientResp
for
_
,
value
:=
range
live
{
record
:=
&
models
.
LiveInfoClientResp
{}
record
.
Id
=
value
.
ID
record
.
Title
=
value
.
Title
record
.
Cover
=
value
.
Cover
record
.
Status
=
value
.
Status
record
.
LiveStatus
=
value
.
LiveStatus
record
.
Sort
=
value
.
Sort
record
.
Duration
=
value
.
Duration
record
.
Category
=
value
.
Category
.
Name
records
=
append
(
records
,
record
)
}
return
records
,
nil
}
func
(
l
*
LiveInfo
)
Add
()
error
{
node
,
_
:=
snowflake
.
NewNode
(
0
)
id
:=
node
.
Generate
()
...
...
@@ -54,8 +79,6 @@ func (l *LiveInfo) Add() error {
"cover"
:
l
.
Cover
,
"category_id"
:
l
.
CategoryId
,
"duration"
:
l
.
Duration
,
"attendance"
:
l
.
Attendance
,
"mode"
:
l
.
Mode
,
"apply_id"
:
l
.
ApplyId
,
"apply_name"
:
l
.
ApplyName
,
"platform_id"
:
l
.
PlatformId
,
...
...
@@ -87,7 +110,6 @@ func (l *LiveInfo) Edit() error {
"cover"
:
l
.
Cover
,
"category_id"
:
l
.
CategoryId
,
"duration"
:
l
.
Duration
,
"attendance"
:
l
.
Attendance
,
"mode"
:
l
.
Mode
,
"apply_id"
:
l
.
ApplyId
,
"status"
:
l
.
Status
,
...
...
validate_service/live_info.go
View file @
b93d01f6
...
...
@@ -5,8 +5,6 @@ type LiveInfo struct {
Cover
string
`json:"cover" validate:"required"`
CategoryId
uint8
`json:"category_id" validate:"required"`
Duration
uint32
`json:"duration" validate:"required"`
Attendance
uint32
`json:"attendance" validate:"required"`
Mode
uint8
`json:"mode" validate:"required"`
ApplyId
uint32
`json:"apply_id" validate:"required"`
ApplyName
string
`json:"apply_name" validate:"required"`
PlatformId
int64
`json:"platform_id" validate:"required"`
...
...
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