You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.2 KiB
50 lines
1.2 KiB
package application
|
|
|
|
import (
|
|
"github.com/gin-gonic/gin"
|
|
"recook/internal/back"
|
|
"recook/internal/dbc"
|
|
"recook/internal/model/application"
|
|
"recook/tools"
|
|
)
|
|
|
|
type createParams struct {
|
|
BackgroundUrl string `json:"backgroundUrl" binding:"required"` //
|
|
GoodsID uint `json:"goodsId"validate:"numeric"`
|
|
GoodsName string `json:"goodsName"`
|
|
ActivityID uint `json:"activityId" validate:"numeric"`
|
|
ActivityName string `json:"activityName"`
|
|
ActivityOrGoods uint `json:"activityOrGoods" validate:"required"` // 传递 activity or goods 大小写随意
|
|
}
|
|
|
|
func CreateLaunchScreen(c *gin.Context) {
|
|
var p createParams
|
|
err := tools.Params(&p, c)
|
|
if err != nil {
|
|
back.Fail(c, err.Error())
|
|
return
|
|
}
|
|
|
|
s := application.LaunchScreen{
|
|
BackgroundUrl: p.BackgroundUrl,
|
|
GoodsID: p.GoodsID,
|
|
GoodsName: p.GoodsName,
|
|
IsActive: int8(p.ActivityOrGoods),
|
|
ActiveID: p.ActivityID,
|
|
ActiveName: p.ActivityName,
|
|
}
|
|
err = dbc.DB.Create(&s).Error
|
|
if err != nil {
|
|
back.Fail(c, err.Error())
|
|
return
|
|
}
|
|
|
|
back.Suc(c, "设置成功", &s)
|
|
}
|
|
|
|
func QueryCurrentLaunchScreen(c *gin.Context) {
|
|
s := &application.LaunchScreen{}
|
|
dbc.DB.Last(s)
|
|
back.Suc(c, "设置成功", s)
|
|
}
|