调整
This commit is contained in:
parent
02833fc89c
commit
ba6decbbd8
@ -51,7 +51,10 @@ func (gs *GameSwitchApi) Init() {
|
|||||||
func (this *GameSwitchApi) List(c *gin.Context) {
|
func (this *GameSwitchApi) List(c *gin.Context) {
|
||||||
pagesize := c.DefaultQuery("pagesize", "10")
|
pagesize := c.DefaultQuery("pagesize", "10")
|
||||||
page := c.DefaultQuery("page", "")
|
page := c.DefaultQuery("page", "")
|
||||||
result := []*system.GameSwitch{}
|
result := []struct {
|
||||||
|
system.GameSwitch
|
||||||
|
Remark string `json:"remark"`
|
||||||
|
}{}
|
||||||
f5.GetGoStyleDb().PageQuery(
|
f5.GetGoStyleDb().PageQuery(
|
||||||
constant.CONF_DB,
|
constant.CONF_DB,
|
||||||
q5.ToInt32(pagesize),
|
q5.ToInt32(pagesize),
|
||||||
@ -70,7 +73,7 @@ func (this *GameSwitchApi) List(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for pg.Rows.Next() {
|
for pg.Rows.Next() {
|
||||||
p := new(system.GameSwitch)
|
p := q5.NewSliceElement(&result)
|
||||||
p.Idx = q5.SafeToInt64(pg.Rows.GetByName("idx"))
|
p.Idx = q5.SafeToInt64(pg.Rows.GetByName("idx"))
|
||||||
p.Name = pg.Rows.GetByName("switch_name")
|
p.Name = pg.Rows.GetByName("switch_name")
|
||||||
p.Opened = q5.SafeToInt32(pg.Rows.GetByName("is_open"))
|
p.Opened = q5.SafeToInt32(pg.Rows.GetByName("is_open"))
|
||||||
@ -80,7 +83,6 @@ func (this *GameSwitchApi) List(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
p.CreateTime = q5.SafeToInt32(pg.Rows.GetByName("createtime"))
|
p.CreateTime = q5.SafeToInt32(pg.Rows.GetByName("createtime"))
|
||||||
p.ModifyTime = q5.SafeToInt32(pg.Rows.GetByName("modifytime"))
|
p.ModifyTime = q5.SafeToInt32(pg.Rows.GetByName("modifytime"))
|
||||||
q5.AppendSlice(&result, p)
|
|
||||||
}
|
}
|
||||||
c.JSON(http.StatusOK, gin.H{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
"code": 0,
|
"code": 0,
|
||||||
@ -97,7 +99,6 @@ func (this *GameSwitchApi) Add(c *gin.Context) {
|
|||||||
req := struct {
|
req := struct {
|
||||||
Name string `binding:"required" json:"switch_name"`
|
Name string `binding:"required" json:"switch_name"`
|
||||||
Open *int32 `binding:"required" json:"is_open"`
|
Open *int32 `binding:"required" json:"is_open"`
|
||||||
Remark string `binding:"required" json:"remark"`
|
|
||||||
}{}
|
}{}
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := c.ShouldBindJSON(&req); err != nil {
|
||||||
c.JSON(http.StatusOK, gin.H{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
@ -118,7 +119,6 @@ func (this *GameSwitchApi) Add(c *gin.Context) {
|
|||||||
gswitch := new(system.GameSwitch)
|
gswitch := new(system.GameSwitch)
|
||||||
gswitch.Name = req.Name
|
gswitch.Name = req.Name
|
||||||
gswitch.Opened = *req.Open
|
gswitch.Opened = *req.Open
|
||||||
gswitch.Remark = req.Remark
|
|
||||||
gswitch.CreateTime = nowDaySeconds
|
gswitch.CreateTime = nowDaySeconds
|
||||||
gswitch.ModifyTime = nowDaySeconds
|
gswitch.ModifyTime = nowDaySeconds
|
||||||
if err := f5.GetApp().GetOrmDb(constant.CONF_DB).Create(gswitch).Error; err != nil {
|
if err := f5.GetApp().GetOrmDb(constant.CONF_DB).Create(gswitch).Error; err != nil {
|
||||||
@ -168,9 +168,6 @@ func (this *GameSwitchApi) Edit(c *gin.Context) {
|
|||||||
|
|
||||||
nowDaySeconds := int32(f5.GetApp().GetRealSeconds())
|
nowDaySeconds := int32(f5.GetApp().GetRealSeconds())
|
||||||
gswitch.Opened = *req.Open
|
gswitch.Opened = *req.Open
|
||||||
if req.Remark != "" {
|
|
||||||
gswitch.Remark = req.Remark
|
|
||||||
}
|
|
||||||
gswitch.ModifyTime = nowDaySeconds
|
gswitch.ModifyTime = nowDaySeconds
|
||||||
if err := db.Where("switch_name = ?", req.Name).Save(gswitch).Error; err != nil {
|
if err := db.Where("switch_name = ?", req.Name).Save(gswitch).Error; err != nil {
|
||||||
c.JSON(http.StatusOK, gin.H{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
|
@ -4,7 +4,6 @@ type GameSwitch struct {
|
|||||||
Idx int64 `gorm:"uniqueIndex;comment:idx" json:"idx"`
|
Idx int64 `gorm:"uniqueIndex;comment:idx" json:"idx"`
|
||||||
Name string `gorm:"column:switch_name" json:"switch_name"`
|
Name string `gorm:"column:switch_name" json:"switch_name"`
|
||||||
Opened int32 `gorm:"column:is_open" json:"is_open"`
|
Opened int32 `gorm:"column:is_open" json:"is_open"`
|
||||||
Remark string `gorm:"column:remark" json:"remark"`
|
|
||||||
CreateTime int32 `gorm:"column:createtime" json:"createtime"`
|
CreateTime int32 `gorm:"column:createtime" json:"createtime"`
|
||||||
ModifyTime int32 `gorm:"column:modifytime" json:"modifytime"`
|
ModifyTime int32 `gorm:"column:modifytime" json:"modifytime"`
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user