Commit 189f8881 authored by shajiaiming's avatar shajiaiming

直播接口

parent 723471ca
package models
import (
"bwallet/pkg/setting"
"github.com/jinzhu/gorm"
)
type LiveCharge struct {
Model
Unit string `json:"title"`
PlatformId int64 `json:"platform_id"`
UnitPrice float64 `json:"unit_price"`
}
func (w LiveCharge) TableName() string {
return setting.DatabaseSetting.Name_Sources + ".wallet_live_charge"
}
func GetOneLiveCharge(id int) (*LiveCharge, error) {
var charge LiveCharge
err := db.Where("id = ?", id).First(&charge).Error
if err != nil && err != gorm.ErrRecordNotFound {
return nil, err
}
err = db.Model(&charge).Error
if err != nil && err != gorm.ErrRecordNotFound {
return nil, err
}
return &charge, nil
}
func ExistLiveChargeById(id int) (bool, error) {
var charge LiveCharge
err := db.Select("id").Where("id = ?", id).First(&charge).Error
if err != nil && err != gorm.ErrRecordNotFound {
return false, err
}
if charge.ID > 0 {
return true, nil
}
return false, nil
}
func GetLiveChargeTotal(maps interface{}) (int, error) {
var count int
if err := db.Model(&LiveCharge{}).Where(maps).Count(&count).Error; err != nil {
return 0, err
}
return count, nil
}
func GetLiveCharge(pageNum, pageSize int, maps interface{}) ([]*LiveCharge, error) {
var charge []*LiveCharge
err := db.Where(maps).Order("id desc").Offset(pageNum).Limit(pageSize).Find(&charge).Error
if err != nil && err != gorm.ErrRecordNotFound {
return nil, err
}
return charge, nil
}
func AddLiveCharge(data map[string]interface{}) (error) {
charge := LiveCharge{
Unit: data["unit"].(string),
PlatformId: data["platform_id"].(int64),
UnitPrice: data["unit_price"].(float64),
}
if err := db.Create(&charge).Error; err != nil {
return err
}
return nil
}
func EditLiveCharge(id int, data interface{}) error {
if err := db.Model(&LiveCharge{}).Where("id = ?", id).Updates(data).Error; err != nil {
return err
}
return nil
}
...@@ -15,12 +15,12 @@ type LiveInfo struct { ...@@ -15,12 +15,12 @@ type LiveInfo struct {
Duration uint32 `json:"duration"` Duration uint32 `json:"duration"`
Mode uint8 `json:"mode"` Mode uint8 `json:"mode"`
ApplyId uint32 `json:"apply_id"` ApplyId uint32 `json:"apply_id"`
ApplyName string `json:"apply_id"` ApplyName string `json:"apply_name"`
Status uint8 `json:"status"` Status uint8 `json:"status"`
LiveStatus uint8 `json:"live_status"` LiveStatus uint8 `json:"live_status"`
Sort uint8 `json:"sort"`
PlatformId int64 `json:"platform_id"` PlatformId int64 `json:"platform_id"`
OrderSn int64 `json:"order_sn"` OrderSn int64 `json:"order_sn"`
Unit string `json:"unit"`
Price float64 `json:"price"` Price float64 `json:"price"`
CreateTime int64 `json:"create_time,omitempty"` CreateTime int64 `json:"create_time,omitempty"`
...@@ -28,14 +28,30 @@ type LiveInfo struct { ...@@ -28,14 +28,30 @@ type LiveInfo struct {
} }
type LiveInfoClientResp struct { type LiveInfoClientResp struct {
Id int `json:"id"` Id int `json:"id"`
Title string `json:"title"` Title string `json:"title"`
Cover string `json:"cover"` Cover string `json:"cover"`
Duration uint32 `json:"duration"` Duration uint32 `json:"duration"`
Status uint8 `json:"status"` Status uint8 `json:"status"`
LiveStatus uint8 `json:"live_status"` LiveStatus uint8 `json:"live_status"`
Sort uint8 `json:"sort"` Unit string `json:"unit"`
Category string `json:"category"` Price float64 `json:"price"`
Category string `json:"category"`
}
type LiveInfoBackendResp struct {
Id int `json:"id"`
Title string `json:"title"`
Cover string `json:"cover"`
Duration uint32 `json:"duration"`
ApplyName string `json:"apply_name"`
Status uint8 `json:"status"`
LiveStatus uint8 `json:"live_status"`
OrderSn int64 `json:"order_sn"`
Unit string `json:"unit"`
Price float64 `json:"price"`
Category string `json:"category"`
CreateTime string `json:"create_time"`
} }
const ( const (
...@@ -94,7 +110,7 @@ func GetLiveInfoTotal(maps interface{}) (int, error) { ...@@ -94,7 +110,7 @@ func GetLiveInfoTotal(maps interface{}) (int, error) {
func GetLiveInfo(pageNum, pageSize int, maps interface{}) ([]*LiveInfo, error) { func GetLiveInfo(pageNum, pageSize int, maps interface{}) ([]*LiveInfo, error) {
var live []*LiveInfo var live []*LiveInfo
err := db.Where(maps).Preload("Category").Order("sort desc").Order("create_time desc").Offset(pageNum).Limit(pageSize).Find(&live).Error err := db.Where(maps).Preload("Category").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
} }
...@@ -113,6 +129,7 @@ func AddLiveInfo(data map[string]interface{}) (error) { ...@@ -113,6 +129,7 @@ func AddLiveInfo(data map[string]interface{}) (error) {
ApplyName: data["apply_name"].(string), ApplyName: data["apply_name"].(string),
PlatformId: data["platform_id"].(int64), PlatformId: data["platform_id"].(int64),
OrderSn: data["order_sn"].(int64), OrderSn: data["order_sn"].(int64),
Unit: data["unit"].(string),
Price: data["price"].(float64), Price: data["price"].(float64),
Status: PROCESSING, Status: PROCESSING,
LiveStatus: PROCESSING, LiveStatus: PROCESSING,
......
...@@ -15,20 +15,17 @@ type LiveTitleRecord struct { ...@@ -15,20 +15,17 @@ type LiveTitleRecord struct {
Status uint8 `json:"status"` Status uint8 `json:"status"`
PlatformId int64 `json:"platform_id,omitempty"` PlatformId int64 `json:"platform_id,omitempty"`
CreateTime int64 `json:"create_time,omitempty"` CreateTime int64 `json:"create_time,omitempty"`
ApplyName string `json:"apply_name"`
LiveInfo *LiveInfo `gorm:"foreignkey:LiveId" json:"live,omitempty"` LiveInfo *LiveInfo `gorm:"foreignkey:LiveId" json:"live,omitempty"`
} }
type LiveTitleRecordResp struct { type LiveTitleRecordResp struct {
Id int `json:"id"` Id int `json:"id"`
LiveId int `json:"live_id"` LiveId int `json:"live_id"`
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 `json:"platform_id,omitempty"` CreateTime string `json:"create_time"`
CreatedTime string `json:"create_time,omitempty"` ApplyName string `json:"apply_name"`
ApplyName string `json:"apply_name"`
LiveInfo *LiveInfo `gorm:"foreignkey:LiveId" json:"live,omitempty"`
} }
type LiveTitleRecordTemp struct { type LiveTitleRecordTemp struct {
...@@ -96,7 +93,6 @@ func AddLiveTitleRecord(data map[string]interface{}) (error) { ...@@ -96,7 +93,6 @@ func AddLiveTitleRecord(data map[string]interface{}) (error) {
NewTitle: data["new_title"].(string), NewTitle: data["new_title"].(string),
Status: data["status"].(uint8), Status: data["status"].(uint8),
PlatformId: data["platform_id"].(int64), PlatformId: data["platform_id"].(int64),
ApplyName: data["apply_name"].(string),
CreateTime: time.Now().UTC().Unix(), CreateTime: time.Now().UTC().Unix(),
} }
......
...@@ -174,6 +174,14 @@ var ( ...@@ -174,6 +174,14 @@ var (
ErrDeleteLiveInfo = &Errno{Code: 20105, Message: "The live info delete error."} ErrDeleteLiveInfo = &Errno{Code: 20105, Message: "The live info delete error."}
ErrExistLiveInfo = &Errno{Code: 20106, Message: "The live info already exists."} ErrExistLiveInfo = &Errno{Code: 20106, Message: "The live info already exists."}
// live charge errors
ErrLiveChargeNotFound = &Errno{Code: 20101, Message: "The live charge was not found."}
ErrCountLiveCharge = &Errno{Code: 20102, Message: "The live charge statistic error."}
ErrAddLiveCharge = &Errno{Code: 20103, Message: "The live charge add error."}
ErrUpdateLiveCharge = &Errno{Code: 20104, Message: "The live charge update error."}
ErrDeleteLiveCharge = &Errno{Code: 20105, Message: "The live charge delete error."}
ErrExistLiveCharge = &Errno{Code: 20106, Message: "The live charge already exists."}
// live title record errors // live title record errors
ErrLiveTitleRecordNotFound = &Errno{Code: 20101, Message: "The live title record was not found."} ErrLiveTitleRecordNotFound = &Errno{Code: 20101, Message: "The live title record was not found."}
ErrCountLiveTitleRecord = &Errno{Code: 20102, Message: "The live title record statistic error."} ErrCountLiveTitleRecord = &Errno{Code: 20102, Message: "The live title record statistic error."}
......
...@@ -4,8 +4,9 @@ import ( ...@@ -4,8 +4,9 @@ import (
"bwallet/pkg/errno" "bwallet/pkg/errno"
"bwallet/pkg/handler" "bwallet/pkg/handler"
"bwallet/pkg/util" "bwallet/pkg/util"
"bwallet/service/live_charge_service"
"bwallet/service/live_info_service" "bwallet/service/live_info_service"
live_title_record_service2 "bwallet/service/live_title_record_service" "bwallet/service/live_title_record_service"
"bwallet/validate_service" "bwallet/validate_service"
"github.com/Unknwon/com" "github.com/Unknwon/com"
"github.com/astaxie/beego/validation" "github.com/astaxie/beego/validation"
...@@ -26,6 +27,17 @@ func AddLive(c *gin.Context) { ...@@ -26,6 +27,17 @@ func AddLive(c *gin.Context) {
} }
} }
chargeService := live_charge_service.LiveCharge{
PlatformId: info.PlatformId,
PageNum: util.GetPage(c),
PageSize: util.GetLimit(c),
}
charge, err := chargeService.GetAll()
if err != nil || len(charge) == 0 {
handler.SendResponse(c, errno.ErrAddLiveInfo, nil)
return
}
infoService := live_info_service.LiveInfo{ infoService := live_info_service.LiveInfo{
Title: info.Title, Title: info.Title,
Cover: info.Cover, Cover: info.Cover,
...@@ -34,6 +46,7 @@ func AddLive(c *gin.Context) { ...@@ -34,6 +46,7 @@ func AddLive(c *gin.Context) {
ApplyId: info.ApplyId, ApplyId: info.ApplyId,
ApplyName: info.ApplyName, ApplyName: info.ApplyName,
PlatformId: info.PlatformId, PlatformId: info.PlatformId,
Unit: charge[0].Unit,
Price: info.Price, Price: info.Price,
} }
...@@ -119,16 +132,15 @@ func ModifyTitle(c *gin.Context) { ...@@ -119,16 +132,15 @@ func ModifyTitle(c *gin.Context) {
return return
} }
live_title_record_service := live_title_record_service2.LiveTitleRecord{ recordService := live_title_record_service.LiveTitleRecord{
LiveId: info.Id, LiveId: info.Id,
CurrentTitle: model.Title, CurrentTitle: model.Title,
Status: 0, Status: 0,
NewTitle: info.Title, NewTitle: info.Title,
PlatformId: int64(platform_id), PlatformId: int64(platform_id),
ApplyName: model.ApplyName,
} }
if err := live_title_record_service.Add(); err != nil { if err := recordService.Add(); err != nil {
handler.SendResponse(c, errno.ErrUpdateLiveInfo, nil) handler.SendResponse(c, errno.ErrUpdateLiveInfo, nil)
return return
} }
......
package backend
import (
"bwallet/pkg/errno"
"bwallet/pkg/handler"
"bwallet/pkg/util"
"bwallet/service/live_charge_service"
"bwallet/validate_service"
"github.com/Unknwon/com"
"github.com/gin-gonic/gin"
"strings"
)
func GetLiveCharge(c *gin.Context) {
token := c.Request.Header.Get("Token")
user, _ := util.ParseToken(token)
group := user.UserInfo.Group
var platform_id int64
platform_id = int64(user.UserInfo.PlatformId)
if ("administrator" == group) {
if arg := c.Query("platform_id"); arg != "" {
platform_id = com.StrTo(c.Query("platform_id")).MustInt64()
}
}
chargeService := live_charge_service.LiveCharge{
PlatformId: platform_id,
PageNum: util.GetPage(c),
PageSize: util.GetLimit(c),
}
total, err := chargeService.Count()
if err != nil {
handler.SendResponse(c, errno.ErrCountCoin, nil)
return
}
records, err := chargeService.GetAll()
if err != nil {
handler.SendResponse(c, errno.InternalServerError, nil)
return
}
data := make(map[string]interface{})
data["items"] = records
data["total"] = total
handler.SendResponse(c, nil, data)
}
func AddLiveCharge(c *gin.Context) {
charge := validate_service.LiveCharge{}
c.ShouldBindJSON(&charge)
//方法一
if ok, errors := validate_service.ValidateInputs(charge); !ok {
for _, err := range errors {
handler.SendResponse(c, errno.ErrBind, strings.Join(err, " "))
return
}
}
token := c.Request.Header.Get("Token")
user, _ := util.ParseToken(token)
group := user.UserInfo.Group
var platform_id int64
platform_id = int64(user.UserInfo.PlatformId)
if ("administrator" != group && charge.PlatformId != platform_id) {
handler.SendResponse(c, errno.ErrUserAuthIncorrect, nil)
return
}
if ("administrator" == group) {
if charge.PlatformId != 0 {
platform_id = charge.PlatformId
}
}
chargeService := live_charge_service.LiveCharge{
Unit: charge.Unit,
UnitPrice: charge.UnitPrice,
PlatformId: platform_id,
}
if err := chargeService.Add(); err != nil {
handler.SendResponse(c, errno.ErrAddLiveCharge, nil)
return
}
handler.SendResponse(c, nil, nil)
}
func EditLiveCharge(c *gin.Context) {
charge := validate_service.EditLiveCharge{}
c.ShouldBindJSON(&charge)
//方法一
if ok, errors := validate_service.ValidateInputs(charge); !ok {
for _, err := range errors {
handler.SendResponse(c, errno.ErrBind, strings.Join(err, " "))
return
}
}
chargeService := live_charge_service.LiveCharge{
Id: charge.Id,
}
exists, err := chargeService.ExistById()
if err != nil || !exists {
handler.SendResponse(c, errno.ErrLiveChargeNotFound, nil)
return
}
temp, err := chargeService.GetOneLiveInfo()
if err != nil {
handler.SendResponse(c, errno.ErrLiveChargeNotFound, nil)
return
}
token := c.Request.Header.Get("Token")
user, _ := util.ParseToken(token)
group := user.UserInfo.Group
var platform_id int64
platform_id = int64(user.UserInfo.PlatformId)
if ("administrator" != group) {
if platform_id != temp.PlatformId {
handler.SendResponse(c, errno.ErrUserAuthIncorrect, nil)
return
}
}
chargeService.UnitPrice = charge.UnitPrice
chargeService.Unit = charge.Unit
if err := chargeService.Edit(); err != nil {
handler.SendResponse(c, errno.ErrUpdateCoin, nil)
return
}
handler.SendResponse(c, nil, nil)
}
...@@ -39,7 +39,7 @@ func GetLiveInfo(c *gin.Context) { ...@@ -39,7 +39,7 @@ func GetLiveInfo(c *gin.Context) {
return return
} }
info, err := infoService.GetAll() info, err := infoService.GetAllForBackend()
if err != nil { if err != nil {
handler.SendResponse(c, errno.InternalServerError, nil) handler.SendResponse(c, errno.InternalServerError, nil)
return return
...@@ -52,8 +52,6 @@ func GetLiveInfo(c *gin.Context) { ...@@ -52,8 +52,6 @@ func GetLiveInfo(c *gin.Context) {
handler.SendResponse(c, nil, data) handler.SendResponse(c, nil, data)
} }
func VerifyLiveInfo(c *gin.Context) { func VerifyLiveInfo(c *gin.Context) {
info := validate_service.VerifyLiveInfo{} info := validate_service.VerifyLiveInfo{}
c.ShouldBindJSON(&info) c.ShouldBindJSON(&info)
......
...@@ -42,8 +42,7 @@ func InitRouter() *gin.Engine { ...@@ -42,8 +42,7 @@ func InitRouter() *gin.Engine {
client.PUT("/live-title", app.ModifyTitle) client.PUT("/live-title", app.ModifyTitle)
client.GET("/live-categories", app.GetLiveCategories) client.GET("/live-categories", app.GetLiveCategories)
client.GET("/live-charge", app.GetLiveCharge) client.GET("/live-charge", app.GetLiveCharge)
client.PUT("/live/status",app.LiveStatus) client.PUT("/live/status", app.LiveStatus)
api := r.Group("/api") api := r.Group("/api")
...@@ -137,6 +136,10 @@ func InitRouter() *gin.Engine { ...@@ -137,6 +136,10 @@ func InitRouter() *gin.Engine {
api.PUT("/live-banner", backend.EditLiveBanner) api.PUT("/live-banner", backend.EditLiveBanner)
api.DELETE("/live-banner", backend.DeleteLiveBanner) api.DELETE("/live-banner", backend.DeleteLiveBanner)
api.GET("/live-charge", backend.GetLiveCharge)
api.POST("/live-charge", backend.AddLiveCharge)
api.PUT("/live-charge", backend.EditLiveCharge)
api.GET("/managers", backend.GetManagers) api.GET("/managers", backend.GetManagers)
//api.GET("/user", backend.GetUser) //api.GET("/user", backend.GetUser)
api.POST("/manager", backend.AddManager) api.POST("/manager", backend.AddManager)
......
package live_charge_service
import (
"bwallet/models"
)
type LiveCharge struct {
Id int
Unit string
UnitPrice float64
PlatformId int64
PageNum int
PageSize int
}
func (l *LiveCharge) GetAll() ([]*models.LiveCharge, error) {
var charge []*models.LiveCharge
charge, err := models.GetLiveCharge(l.PageNum, l.PageSize, l.getMaps())
if err != nil {
return nil, err
}
return charge, nil
}
func (l *LiveCharge) Add() error {
charge := map[string]interface{}{
"unit": l.Unit,
"unit_price": l.UnitPrice,
"platform_id": l.PlatformId,
}
if err := models.AddLiveCharge(charge); err != nil {
return err
}
return nil
}
func (l *LiveCharge) Edit() error {
return models.EditLiveCharge(l.Id, map[string]interface{}{
"unit": l.Unit,
"unit_price": l.UnitPrice,
})
}
func (l *LiveCharge) ExistById() (bool, error) {
return models.ExistLiveChargeById(l.Id)
}
func (l *LiveCharge) GetOneLiveInfo() (*models.LiveCharge, error) {
charge, err := models.GetOneLiveCharge(l.Id)
if err != nil {
return nil, err
}
return charge, nil
}
func (l *LiveCharge) Count() (int, error) {
return models.GetLiveChargeTotal(l.getMaps())
}
func (l *LiveCharge) getMaps() (map[string]interface{}) {
maps := make(map[string]interface{})
if l.Id != 0 {
maps["id"] = l.Id
}
if l.PlatformId != 0 {
maps["platform_id"] = l.PlatformId
}
return maps
}
...@@ -3,6 +3,7 @@ package live_info_service ...@@ -3,6 +3,7 @@ package live_info_service
import ( import (
"bwallet/models" "bwallet/models"
"bwallet/pkg/snowflake" "bwallet/pkg/snowflake"
"bwallet/pkg/util"
) )
type LiveInfo struct { type LiveInfo struct {
...@@ -16,9 +17,9 @@ type LiveInfo struct { ...@@ -16,9 +17,9 @@ type LiveInfo struct {
ApplyName string ApplyName string
Status uint8 Status uint8
LiveStatus uint8 LiveStatus uint8
Sort uint8
PlatformId int64 PlatformId int64
OrderSn int64 OrderSn int64
Unit string
Price float64 Price float64
PageNum int PageNum int
...@@ -34,7 +35,7 @@ func (l *LiveInfo) GetOneLiveInfo() (*models.LiveInfo, error) { ...@@ -34,7 +35,7 @@ func (l *LiveInfo) GetOneLiveInfo() (*models.LiveInfo, error) {
return live, nil return live, nil
} }
func (l *LiveInfo) GetAll() ([]*models.LiveInfo, error) { func (l *LiveInfo) GetAllForBackend() ([]*models.LiveInfoBackendResp, error) {
var live []*models.LiveInfo var live []*models.LiveInfo
live, err := models.GetLiveInfo(l.PageNum, l.PageSize, l.getMaps()) live, err := models.GetLiveInfo(l.PageNum, l.PageSize, l.getMaps())
...@@ -42,7 +43,26 @@ func (l *LiveInfo) GetAll() ([]*models.LiveInfo, error) { ...@@ -42,7 +43,26 @@ func (l *LiveInfo) GetAll() ([]*models.LiveInfo, error) {
return nil, err return nil, err
} }
return live, nil var records = []*models.LiveInfoBackendResp{}
for _, value := range live {
record := &models.LiveInfoBackendResp{}
record.Id = value.ID
record.Title = value.Title
record.Cover = value.Cover
record.Status = value.Status
record.LiveStatus = value.LiveStatus
record.Duration = value.Duration
record.ApplyName = value.ApplyName
record.Unit = value.Unit
record.Price = value.Price
record.OrderSn = value.OrderSn
record.Category = value.Category.Name
record.CreateTime = util.FormatUnix(value.CreateTime)
records = append(records, record)
}
return records, nil
} }
func (l *LiveInfo) GetAllForClient() ([]*models.LiveInfoClientResp, error) { func (l *LiveInfo) GetAllForClient() ([]*models.LiveInfoClientResp, error) {
...@@ -61,8 +81,9 @@ func (l *LiveInfo) GetAllForClient() ([]*models.LiveInfoClientResp, error) { ...@@ -61,8 +81,9 @@ func (l *LiveInfo) GetAllForClient() ([]*models.LiveInfoClientResp, error) {
record.Cover = value.Cover record.Cover = value.Cover
record.Status = value.Status record.Status = value.Status
record.LiveStatus = value.LiveStatus record.LiveStatus = value.LiveStatus
record.Sort = value.Sort
record.Duration = value.Duration record.Duration = value.Duration
record.Unit = value.Unit
record.Price = value.Price
record.Category = value.Category.Name record.Category = value.Category.Name
records = append(records, record) records = append(records, record)
...@@ -83,6 +104,7 @@ func (l *LiveInfo) Add() error { ...@@ -83,6 +104,7 @@ func (l *LiveInfo) Add() error {
"apply_name": l.ApplyName, "apply_name": l.ApplyName,
"platform_id": l.PlatformId, "platform_id": l.PlatformId,
"order_sn": id.Int64(), "order_sn": id.Int64(),
"unit": l.Unit,
"price": l.Price, "price": l.Price,
} }
if err := models.AddLiveInfo(live); err != nil { if err := models.AddLiveInfo(live); err != nil {
...@@ -113,7 +135,6 @@ func (l *LiveInfo) Edit() error { ...@@ -113,7 +135,6 @@ func (l *LiveInfo) Edit() error {
"mode": l.Mode, "mode": l.Mode,
"apply_id": l.ApplyId, "apply_id": l.ApplyId,
"status": l.Status, "status": l.Status,
"sort": l.Sort,
"platform_id": l.PlatformId, "platform_id": l.PlatformId,
}) })
} }
......
...@@ -2,7 +2,7 @@ package live_title_record_service ...@@ -2,7 +2,7 @@ package live_title_record_service
import ( import (
"bwallet/models" "bwallet/models"
"time" "bwallet/pkg/util"
) )
type LiveTitleRecord struct { type LiveTitleRecord struct {
...@@ -11,7 +11,6 @@ type LiveTitleRecord struct { ...@@ -11,7 +11,6 @@ type LiveTitleRecord struct {
CurrentTitle string CurrentTitle string
NewTitle string NewTitle string
Status uint8 Status uint8
ApplyName string
PlatformId int64 PlatformId int64
PageNum int PageNum int
...@@ -42,8 +41,8 @@ func (l *LiveTitleRecord) GetAll() ([]*models.LiveTitleRecordResp, error) { ...@@ -42,8 +41,8 @@ func (l *LiveTitleRecord) GetAll() ([]*models.LiveTitleRecordResp, error) {
record.NewTitle = value.NewTitle record.NewTitle = value.NewTitle
record.Status = value.Status record.Status = value.Status
record.LiveId = value.LiveId record.LiveId = value.LiveId
record.CreatedTime = time.Unix(value.CreateTime, 0).Format("2006-01-02 15:04:05") record.CreateTime = util.FormatUnix(value.CreateTime)
record.ApplyName = value.ApplyName record.ApplyName = value.LiveInfo.ApplyName
records = append(records, record) records = append(records, record)
} }
...@@ -58,7 +57,6 @@ func (l *LiveTitleRecord) Add() error { ...@@ -58,7 +57,6 @@ func (l *LiveTitleRecord) Add() error {
"status": l.Status, "status": l.Status,
"new_title": l.NewTitle, "new_title": l.NewTitle,
"platform_id": l.PlatformId, "platform_id": l.PlatformId,
"apply_name": l.ApplyName,
} }
if err := models.AddLiveTitleRecord(live); err != nil { if err := models.AddLiveTitleRecord(live); err != nil {
......
package validate_service
type LiveCharge struct {
Unit string `json:"unit" validate:"required"`
UnitPrice float64 `json:"unit_price" validate:"required"`
PlatformId int64 `json:"platform_id" validate:"required"`
}
type EditLiveCharge struct {
Id int `json:"id" validate:"required"`
Unit string `json:"unit" validate:"required"`
UnitPrice float64 `json:"unit_price" 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