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

74 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
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. package client
  2. import (
  3. "fmt"
  4. "hudongzhuanjia/controllers"
  5. "hudongzhuanjia/models"
  6. "hudongzhuanjia/services/upper_wall"
  7. "hudongzhuanjia/utils/code"
  8. "time"
  9. )
  10. type UpperWallCtl struct {
  11. controllers.AuthorCtl
  12. }
  13. //发送上墙消息
  14. func (t *UpperWallCtl) Send() {
  15. uid := t.MustGetUID()
  16. activityId := t.MustGetInt64("activity_id")
  17. category := t.MustGetInt("category")
  18. content, _ := t.Get("content")
  19. img, _ := t.Get("img")
  20. //获取主活动信息
  21. activity := new(models.Activity)
  22. exist, err := models.Get(activity, activityId)
  23. t.CheckErr(err)
  24. t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在")
  25. t.CheckRunning(activity.Status)
  26. msgWall := new(models.MsgWallServer)
  27. exist, err = msgWall.GetByActivityId(activityId)
  28. t.CheckErr(err)
  29. if !exist || msgWall.UpWallStatus == "关闭" {
  30. t.ERROR("上墙活动尚未开启", code.MSG_ERR)
  31. }
  32. //获取用信息
  33. user := new(models.User)
  34. exist, err = models.Get(user, uid)
  35. t.CheckErr(err)
  36. t.Assert(exist, code.MSG_USER_NOT_EXIST, "用户不存在")
  37. uw := new(models.UpperWall)
  38. uw.RehearsalId = activity.RehearsalId
  39. uw.ActivityId = activityId
  40. uw.Category = fmt.Sprintf("%v", category)
  41. uw.UserId = user.Id
  42. uw.Content = content
  43. uw.Img = img
  44. uw.Status = 0
  45. uw.CreatedAt = time.Now()
  46. uw.UpdatedAt = time.Now()
  47. _, err = models.Add(uw)
  48. t.CheckErr(err)
  49. t.SUCCESS("成功")
  50. }
  51. func (t *UpperWallCtl) List() {
  52. activityId := t.MustGetInt64("activity_id")
  53. userId := t.MustGetUID()
  54. activity := new(models.Activity)
  55. exist, err := models.Get(activity, activityId)
  56. t.CheckErr(err)
  57. t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在")
  58. list, err := upper_wall.GetUpperWallResult(userId, activity.Id, activity.RehearsalId)
  59. t.CheckErr(err)
  60. t.JSON(map[string]interface{}{
  61. "list": list,
  62. "total": len(list),
  63. })
  64. }