Browse Source

fix:bug

dev
Tooooommy 4 years ago
parent
commit
5bfede1b51
  1. 49
      controllers/pc/pad_sign.go
  2. 24
      models/pad_signer.go
  3. 23
      models/pad_signing.go
  4. 1
      utils/code/code.go

49
controllers/pc/pad_sign.go

@ -0,0 +1,49 @@
package pc
import (
"hudongzhuanjia/controllers"
"hudongzhuanjia/models"
"hudongzhuanjia/utils/code"
"hudongzhuanjia/utils/define"
)
type PadSignCtl struct {
controllers.AuthorCtl
}
func (t *PadSignCtl) Setting() {
activityId := t.MustGetInt("activity_id")
// 平板签约信息
padSigning := &models.PadSigning{}
exist, err := padSigning.GetByActivityId(activityId)
t.CheckErr(err)
t.Assert(exist, code.MSG_PAD_SIGNING_NOT_EXIST, "平板签约信息异常")
signers, err := models.ListPadSignerByActivityId(activityId)
t.CheckErr(err)
t.JSON(map[string]interface{}{
"pad_signing": padSigning,
"pad_signers": signers,
})
}
func (t *PadSignCtl) Switch() {
activityId := t.MustGetInt("activity_id")
status := t.MustGet("status")
if status != define.StatusOpen && status != define.StatusClose {
t.DisplayByError("status值为开启或关闭", code.MSG_ERR_Param)
return
}
padSigning := &models.PadSigning{}
exist, err := padSigning.GetByActivityId(activityId)
t.CheckErr(err)
t.Assert(exist, code.MSG_PAD_SIGNING_NOT_EXIST, "平板签约信息异常")
padSigning.PadSignStatus = status
_, err = padSigning.Update(padSigning, padSigning.Id, "status")
t.CheckErr(err)
t.DisplayBySuccess("已" + status)
}

24
models/pad_signer.go

@ -0,0 +1,24 @@
package models
import "github.com/ouxuanserver/osmanthuswine/src/core"
const PadSignerTN = TableNamePrefix + "pad_signer"
type PadSigner struct {
Model `xorm:"extends"`
ActivityId int `json:"activity_id" xorm:"not null default 0 comment('互动id') INT(11)"`
PadSignerName string `json:"pad_signer_name" xorm:"not null default '' comment('签约方名称')"`
PadBgUrl string `json:"pad_bg_url" xorm:"not null default '' comment('平板背景链接') VARCHAR(255)"`
Sid int `json:"sid" xorm:"not null default 0 comment('排序') INT(11)"`
WsId int `json:"ws_id" xorm:"not null default '' comment('websocket连接标识id') VARCHAR(255)"`
}
func (t *PadSigner) TableName() string {
return PadSigningTN
}
func ListPadSignerByActivityId(activityId int) (signers []*PadSigner, err error) {
err = core.GetXormAuto().Where("activity_id=? and is_delete=0", activityId).Find(&signers)
return
}

23
models/pad_signing.go

@ -0,0 +1,23 @@
package models
import "github.com/ouxuanserver/osmanthuswine/src/core"
const PadSigningTN = TableNamePrefix + "pad_signing"
type PadSigning struct {
Model `xorm:"extends"`
ActivityId int `json:"activity_id" xorm:"not null default 0 comment('互动id') INT(11)"`
CustomerId int `json:"customer_id" xorm:"not null default 0 comment('客户id') INT(11)"`
SignTheme string `json:"sign_theme" xorm:"not null default '' comment('签约主题') VARCHAR(255)"`
MaxBgUrl string `json:"max_bg_url" xorm:"not null default '' comment('大屏幕链接') VARCHAR(255)"`
PadSignStatus string `json:"pad_sign_status" xorm:"not null default '关闭' comment('平板签约状态开启或关闭') VARCHAR(128)" `
}
func (t *PadSigning) TableName() string {
return PadSigningTN
}
func (t *PadSigning) GetByActivityId(activityId int) (bool, error) {
return core.GetXormAuto().Where("activity_id=? and is_delete=0", activityId).Get(t)
}

1
utils/code/code.go

@ -21,6 +21,7 @@ const (
MSG_MODULE_STATUS_END = 1002 // 该模块活动已结束
MSG_MODULE_STATUS_NOT_RUNNING = 1003 // 该模块活动不在进行中
MSG_MODULE_STATUS_ERROR = 1005 // 状态出差
MSG_PAD_SIGNING_NOT_EXIST = 1006 // 平板签约不存在
MSG_TUGWAR_NOT_EXIST = 2000 // 拔河不存在
MSG_TUGWAR_TEAM_OVER_LIMIT = 2001 // 拔河队伍满人
MSG_TUGWAR_MEMBER_NOT_EXIST = 2002 // 拔河队伍不存在人员

Loading…
Cancel
Save