Commit b93d01f6 authored by shajiaiming's avatar shajiaiming

live api

parent 8ea05fb5
......@@ -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),
......
......@@ -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.GetAllForClient()
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)
}
......@@ -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")
......
......@@ -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,
......
......@@ -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"`
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment