activity_remind.go 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. package activity
  2. import (
  3. "github.com/gin-gonic/gin"
  4. "hongze/hongze_yb/controller/response"
  5. activity2 "hongze/hongze_yb/models/request/activity"
  6. "hongze/hongze_yb/services/activity"
  7. "hongze/hongze_yb/services/user"
  8. )
  9. // AddRemind 添加提醒
  10. // @Tags 活动模块
  11. // @Summary 添加提醒
  12. // @Description 添加提醒
  13. // @Security ApiKeyAuth
  14. // @Param Authorization header string true "Bearer 31a165baebe6dec616b1f8f3207b4273"
  15. // @Accept json
  16. // @Product json
  17. // @Param activity_id query int true "活动ID"
  18. // @Success 200 {string} string "操作成功"
  19. // @failure 400 {string} string "操作失败"
  20. // @failure 4001 {object} activity.RemindCheckInfo "指定错误"
  21. // @Router /activity/addRemind [post]
  22. func AddRemind(c *gin.Context) {
  23. var req activity2.RemindReq
  24. if c.ShouldBind(&req) != nil {
  25. response.Fail("参数异常", c)
  26. return
  27. }
  28. userInfo := user.GetInfoByClaims(c)
  29. ok, permissionCheckInfo, err := activity.CheckActivityPermission(userInfo, req.ActivityID)
  30. if !ok {
  31. response.AuthError(permissionCheckInfo, "暂无权限", c)
  32. return
  33. }
  34. err, remindCheck := activity.CreateRemind(req.ActivityID, userInfo)
  35. if err != nil {
  36. if remindCheck.Specific == 1 {
  37. response.SpecificFail(remindCheck, remindCheck.Msg, c)
  38. } else {
  39. response.Fail(err.Error(), c)
  40. }
  41. return
  42. }
  43. response.OkData("操作成功", "", c)
  44. }
  45. // CancelRemind 取消提醒
  46. // @Tags 活动模块
  47. // @Summary 取消提醒
  48. // @Description 取消提醒
  49. // @Security ApiKeyAuth
  50. // @Param Authorization header string true "Bearer 31a165baebe6dec616b1f8f3207b4273"
  51. // @Accept json
  52. // @Product json
  53. // @Param activity_id query int true "活动ID"
  54. // @Success 200 {string} string "操作成功"
  55. // @failure 400 {string} string "操作失败"
  56. // @Router /activity/cancelRemind [post]
  57. func CancelRemind(c *gin.Context) {
  58. var req activity2.RemindReq
  59. if c.ShouldBind(&req) != nil {
  60. response.Fail("参数异常", c)
  61. return
  62. }
  63. userInfo := user.GetInfoByClaims(c)
  64. ok, permissionCheckInfo, err := activity.CheckActivityPermission(userInfo, req.ActivityID)
  65. if !ok {
  66. response.AuthError(permissionCheckInfo, "暂无权限", c)
  67. return
  68. }
  69. err = activity.CancelRemind(req.ActivityID, userInfo)
  70. if err != nil {
  71. response.Fail(err.Error(), c)
  72. return
  73. }
  74. response.OkData("操作成功", "", c)
  75. }