|
@@ -3,7 +3,6 @@ package activity
|
|
import (
|
|
import (
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/gin-gonic/gin"
|
|
"hongze/hongze_yb/controller/response"
|
|
"hongze/hongze_yb/controller/response"
|
|
- activity2 "hongze/hongze_yb/models/request/activity"
|
|
|
|
"hongze/hongze_yb/services/activity"
|
|
"hongze/hongze_yb/services/activity"
|
|
"hongze/hongze_yb/services/user"
|
|
"hongze/hongze_yb/services/user"
|
|
"hongze/hongze_yb/utils"
|
|
"hongze/hongze_yb/utils"
|
|
@@ -58,7 +57,7 @@ func _handleListQuery(c *gin.Context) (string, []interface{}, string) {
|
|
weekStart := utils.GetNowWeekMonday()
|
|
weekStart := utils.GetNowWeekMonday()
|
|
weekEnd := utils.GetNowWeekLastDay()
|
|
weekEnd := utils.GetNowWeekLastDay()
|
|
// 比对本周开始时间和当前时间
|
|
// 比对本周开始时间和当前时间
|
|
- timeNow, _ := time.Parse("2006-01-02 15:04:05", nowTime)
|
|
|
|
|
|
+ timeNow, _ := time.ParseInLocation("2006-01-02 15:04:05", nowTime, time.Local)
|
|
queryStart := timeNow
|
|
queryStart := timeNow
|
|
if timeNow.Before(weekStart) {
|
|
if timeNow.Before(weekStart) {
|
|
queryStart = weekStart
|
|
queryStart = weekStart
|
|
@@ -91,144 +90,6 @@ func _handleListQuery(c *gin.Context) (string, []interface{}, string) {
|
|
return condition, pars, order
|
|
return condition, pars, order
|
|
}
|
|
}
|
|
|
|
|
|
-// AddRemind 添加提醒
|
|
|
|
-// @Tags 活动模块
|
|
|
|
-// @Summary 添加提醒
|
|
|
|
-// @Description 添加提醒
|
|
|
|
-// @Security ApiKeyAuth
|
|
|
|
-// @Param Authorization header string true "Bearer 31a165baebe6dec616b1f8f3207b4273"
|
|
|
|
-// @Accept json
|
|
|
|
-// @Product json
|
|
|
|
-// @Param activity_id query int true "活动ID"
|
|
|
|
-// @Success 200 {string} string "操作成功"
|
|
|
|
-// @failure 400 {string} string "操作失败"
|
|
|
|
-// @failure 4001 {object} activity.RemindCheckInfo "指定错误"
|
|
|
|
-// @Router /activity/addRemind [post]
|
|
|
|
-func AddRemind(c *gin.Context) {
|
|
|
|
- var req activity2.RemindReq
|
|
|
|
- if c.ShouldBind(&req) != nil {
|
|
|
|
- response.Fail("参数异常", c)
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
- userInfo := user.GetInfoByClaims(c)
|
|
|
|
- ok, permissionCheckInfo, err := activity.CheckActivityPermission(userInfo, req.ActivityID)
|
|
|
|
- if !ok {
|
|
|
|
- response.AuthError(permissionCheckInfo, "暂无权限", c)
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
- err, remindCheck := activity.CreateRemind(req.ActivityID, userInfo)
|
|
|
|
- if err != nil {
|
|
|
|
- if remindCheck.Specific == 1 {
|
|
|
|
- response.SpecificFail(remindCheck, remindCheck.Msg, c)
|
|
|
|
- } else {
|
|
|
|
- response.Fail(err.Error(), c)
|
|
|
|
- }
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
- response.OkData("操作成功", "", c)
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// CancelRemind 取消提醒
|
|
|
|
-// @Tags 活动模块
|
|
|
|
-// @Summary 取消提醒
|
|
|
|
-// @Description 取消提醒
|
|
|
|
-// @Security ApiKeyAuth
|
|
|
|
-// @Param Authorization header string true "Bearer 31a165baebe6dec616b1f8f3207b4273"
|
|
|
|
-// @Accept json
|
|
|
|
-// @Product json
|
|
|
|
-// @Param activity_id query int true "活动ID"
|
|
|
|
-// @Success 200 {string} string "操作成功"
|
|
|
|
-// @failure 400 {string} string "操作失败"
|
|
|
|
-// @Router /activity/cancelRemind [post]
|
|
|
|
-func CancelRemind(c *gin.Context) {
|
|
|
|
- var req activity2.RemindReq
|
|
|
|
- if c.ShouldBind(&req) != nil {
|
|
|
|
- response.Fail("参数异常", c)
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
- userInfo := user.GetInfoByClaims(c)
|
|
|
|
- ok, permissionCheckInfo, err := activity.CheckActivityPermission(userInfo, req.ActivityID)
|
|
|
|
- if !ok {
|
|
|
|
- response.AuthError(permissionCheckInfo, "暂无权限", c)
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
- err = activity.CancelRemind(req.ActivityID, userInfo)
|
|
|
|
- if err != nil {
|
|
|
|
- response.Fail(err.Error(), c)
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
- response.OkData("操作成功", "", c)
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// RegisterActivity 报名活动
|
|
|
|
-// @Tags 活动模块
|
|
|
|
-// @Summary 报名活动
|
|
|
|
-// @Description 报名活动
|
|
|
|
-// @Security ApiKeyAuth
|
|
|
|
-// @Param Authorization header string true "Bearer 31a165baebe6dec616b1f8f3207b4273"
|
|
|
|
-// @Accept json
|
|
|
|
-// @Product json
|
|
|
|
-// @Param activity_id query int true "活动ID"
|
|
|
|
-// @Success 200 {string} string "操作成功"
|
|
|
|
-// @failure 400 {string} string "操作失败"
|
|
|
|
-// @failure 4001 {object} activity.RegisterCheckInfo "指定错误"
|
|
|
|
-// @Router /activity/registerActivity [post]
|
|
|
|
-func RegisterActivity(c *gin.Context) {
|
|
|
|
- var req activity2.RegisterReq
|
|
|
|
- if c.ShouldBind(&req) != nil {
|
|
|
|
- response.Fail("参数异常", c)
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
- userInfo := user.GetInfoByClaims(c)
|
|
|
|
- ok, permissionCheckInfo, err := activity.CheckActivityPermission(userInfo, req.ActivityID)
|
|
|
|
- if !ok {
|
|
|
|
- response.AuthError(permissionCheckInfo, "暂无权限", c)
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
- err, registerCheck := activity.CreateRegister(req.ActivityID, userInfo)
|
|
|
|
- if err != nil {
|
|
|
|
- if registerCheck.Specific == 1 {
|
|
|
|
- response.SpecificFail(registerCheck, registerCheck.Msg, c)
|
|
|
|
- } else {
|
|
|
|
- response.Fail(err.Error(), c)
|
|
|
|
- }
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
- response.OkData("操作成功", "", c)
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// CancelRegister 取消报名
|
|
|
|
-// @Tags 活动模块
|
|
|
|
-// @Summary 取消报名
|
|
|
|
-// @Description 取消报名
|
|
|
|
-// @Security ApiKeyAuth
|
|
|
|
-// @Param Authorization header string true "Bearer 31a165baebe6dec616b1f8f3207b4273"
|
|
|
|
-// @Accept json
|
|
|
|
-// @Product json
|
|
|
|
-// @Param activity_id query int true "活动ID"
|
|
|
|
-// @Success 200 {string} string "操作成功"
|
|
|
|
-// @failure 400 {string} string "操作失败"
|
|
|
|
-// @Router /activity/cancelRegister [post]
|
|
|
|
-func CancelRegister(c *gin.Context) {
|
|
|
|
- var req activity2.RegisterReq
|
|
|
|
- if c.ShouldBind(&req) != nil {
|
|
|
|
- response.Fail("参数异常", c)
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
- userInfo := user.GetInfoByClaims(c)
|
|
|
|
- ok, permissionCheckInfo, err := activity.CheckActivityPermission(userInfo, req.ActivityID)
|
|
|
|
- if !ok {
|
|
|
|
- response.AuthError(permissionCheckInfo, "暂无权限", c)
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
- err = activity.CancelRegister(req.ActivityID, userInfo)
|
|
|
|
- if err != nil {
|
|
|
|
- response.Fail(err.Error(), c)
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
- response.OkData("操作成功", "", c)
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
// GetActivityDetail 获取活动详情
|
|
// GetActivityDetail 获取活动详情
|
|
// @Tags 活动模块
|
|
// @Tags 活动模块
|
|
// @Summary 获取活动详情
|
|
// @Summary 获取活动详情
|