互动
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.

49 lines
1.2 KiB

4 years ago
  1. package pc
  2. import (
  3. "hudongzhuanjia/controllers"
  4. "hudongzhuanjia/models"
  5. "hudongzhuanjia/utils/code"
  6. "hudongzhuanjia/utils/define"
  7. )
  8. type PadSignCtl struct {
  9. controllers.AuthorCtl
  10. }
  11. func (t *PadSignCtl) Setting() {
  12. activityId := t.MustGetInt("activity_id")
  13. // 平板签约信息
  14. padSigning := &models.PadSigning{}
  15. exist, err := padSigning.GetByActivityId(activityId)
  16. t.CheckErr(err)
  17. t.Assert(exist, code.MSG_PAD_SIGNING_NOT_EXIST, "平板签约信息异常")
  18. signers, err := models.ListPadSignerByActivityId(activityId)
  19. t.CheckErr(err)
  20. t.JSON(map[string]interface{}{
  21. "pad_signing": padSigning,
  22. "pad_signers": signers,
  23. })
  24. }
  25. func (t *PadSignCtl) Switch() {
  26. activityId := t.MustGetInt("activity_id")
  27. status := t.MustGet("status")
  28. if status != define.StatusOpen && status != define.StatusClose {
  29. t.DisplayByError("status值为开启或关闭", code.MSG_ERR_Param)
  30. return
  31. }
  32. padSigning := &models.PadSigning{}
  33. exist, err := padSigning.GetByActivityId(activityId)
  34. t.CheckErr(err)
  35. t.Assert(exist, code.MSG_PAD_SIGNING_NOT_EXIST, "平板签约信息异常")
  36. padSigning.PadSignStatus = status
  37. _, err = padSigning.Update(padSigning, padSigning.Id, "status")
  38. t.CheckErr(err)
  39. t.DisplayBySuccess("已" + status)
  40. }