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

65 lines
1.8 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. package client
  2. import (
  3. "hudongzhuanjia/controllers"
  4. "hudongzhuanjia/models"
  5. "hudongzhuanjia/utils/code"
  6. "time"
  7. )
  8. type InvitationLetterCtl struct {
  9. controllers.AuthorCtl
  10. }
  11. func (t *InvitationLetterCtl) Invite() {
  12. uid := t.MustGetUID()
  13. activityId := t.MustGetInt64("activity_id")
  14. invitationId := t.MustGetInt64("invitation_id")
  15. answer := t.MustGet("answer")
  16. activity := new(models.Activity)
  17. exist, err := models.Get(activity, activityId)
  18. t.CheckErr(err)
  19. t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在")
  20. letter := new(models.InvitationLetter)
  21. exist, err = letter.GetByUserIdAndActivityId(uid, activityId, activity.RehearsalId)
  22. t.CheckErr(err)
  23. t.Assert(!exist, code.MSG_INVITE_LETTER_EXIST, "您已经接受过邀请")
  24. letter.UserId = uid
  25. letter.ActivityId = activityId
  26. letter.InvitationId = invitationId
  27. letter.RehearsalId = activity.RehearsalId
  28. letter.ExtraData = answer
  29. letter.IsDelete = false
  30. letter.CreatedAt = time.Now()
  31. letter.UpdatedAt = time.Now()
  32. _, err = models.Add(letter)
  33. t.CheckErr(err)
  34. t.SUCCESS("success")
  35. }
  36. func (t *InvitationLetterCtl) Setting() {
  37. activityId := t.MustGetInt64("activity_id")
  38. uid := t.MustGetUID()
  39. activity := new(models.Activity)
  40. exist, err := models.Get(activity, activityId)
  41. t.CheckErr(err)
  42. t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在")
  43. letter := new(models.InvitationLetter)
  44. exist, err = letter.GetByUserIdAndActivityId(uid, activityId, activity.RehearsalId)
  45. t.CheckErr(err)
  46. t.Assert(!exist, code.MSG_INVITE_LETTER_EXIST, "您已经接受过邀请")
  47. invitation := new(models.Invitation)
  48. exist, err = invitation.GetInvitationByActivityId(activityId)
  49. t.CheckErr(err)
  50. t.Assert(exist, code.MSG_INVITE_SETTING_NOT_EXIST, "邀请函设置不存在")
  51. t.JSON(map[string]interface{}{
  52. "setting": invitation,
  53. })
  54. }