|
@@ -5,7 +5,9 @@ import (
|
|
|
"hongze/hongze_yb/controller/response"
|
|
|
"hongze/hongze_yb/services/activity"
|
|
|
"hongze/hongze_yb/services/user"
|
|
|
+ "hongze/hongze_yb/utils"
|
|
|
"strconv"
|
|
|
+ "time"
|
|
|
)
|
|
|
|
|
|
// GetPageList 活动列表
|
|
@@ -18,17 +20,17 @@ import (
|
|
|
// @Product json
|
|
|
// @Param activity_name query string false "活动名称"
|
|
|
// @Param activity_type_name query string false "活动类别"
|
|
|
-// @Param active_state query int false "活动状态 1-未开始 2-进行中 3-已结束"
|
|
|
+// @Param active_state query int false "活动状态 1-本周预告 2-进行中 3-已结束"
|
|
|
// @Param activity_type query int false "活动类型 1-线上会议 3-线下沙龙"
|
|
|
// @Param page query int false "当前页码"
|
|
|
// @Param limit query int false "每页数量"
|
|
|
// @Success 200 {object} []yb_activity.QueryActivity
|
|
|
// @Router /activity/getPageList [get]
|
|
|
func GetPageList(c *gin.Context) {
|
|
|
- where := _handleListQuery(c)
|
|
|
+ where, order := _handleListQuery(c)
|
|
|
page, limit := _handlePageParam(c)
|
|
|
userInfo := user.GetUserInfoByStruct(c)
|
|
|
- listData, err := activity.PageList(where, page, limit, userInfo)
|
|
|
+ listData, err := activity.PageList(where, page, limit, order, userInfo)
|
|
|
if err != nil {
|
|
|
response.Fail("活动获取失败", c)
|
|
|
return
|
|
@@ -36,7 +38,7 @@ func GetPageList(c *gin.Context) {
|
|
|
response.OkData("获取成功", listData, c)
|
|
|
}
|
|
|
|
|
|
-func _handleListQuery(c *gin.Context) map[string]interface{} {
|
|
|
+func _handleListQuery(c *gin.Context) (map[string]interface{}, string) {
|
|
|
where := make(map[string]interface{})
|
|
|
where["is_delete ="] = 0
|
|
|
title := c.DefaultQuery("activity_name", "")
|
|
@@ -47,17 +49,38 @@ func _handleListQuery(c *gin.Context) map[string]interface{} {
|
|
|
if typeName != "" {
|
|
|
where["activity_type_name like"] = "%" + c.Query("activity_type_name") + "%"
|
|
|
}
|
|
|
+ order := ""
|
|
|
reqState := c.DefaultQuery("active_state", "0")
|
|
|
if reqState != "0" {
|
|
|
state, _ := strconv.Atoi(reqState)
|
|
|
- where["active_state ="] = state
|
|
|
+ nowTime := time.Now().Format("2006-01-02 15:04:05")
|
|
|
+ weekStart := utils.GetNowWeekMonday()
|
|
|
+ weekEnd := utils.GetNowWeekLastDay()
|
|
|
+ // 比对本周开始时间和当前时间
|
|
|
+ timeNow, _ := time.Parse("2006-01-02 15:04:05", nowTime)
|
|
|
+ queryStart := timeNow
|
|
|
+ if timeNow.Before(weekStart) {
|
|
|
+ queryStart = weekStart
|
|
|
+ }
|
|
|
+ switch state {
|
|
|
+ case 1:
|
|
|
+ // 时间在本周内且未开始
|
|
|
+ where["start_time >="] = queryStart
|
|
|
+ where["end_time <"] = weekEnd
|
|
|
+ case 2:
|
|
|
+ where["start_time <="] = nowTime
|
|
|
+ where["end_time >"] = nowTime
|
|
|
+ case 3:
|
|
|
+ where["end_time <"] = nowTime
|
|
|
+ order = "start_time desc"
|
|
|
+ }
|
|
|
}
|
|
|
reqType := c.DefaultQuery("activity_type", "0")
|
|
|
if reqType != "0" {
|
|
|
activityType, _ := strconv.Atoi(reqType)
|
|
|
where["activity_type_id ="] = activityType
|
|
|
}
|
|
|
- return where
|
|
|
+ return where, order
|
|
|
}
|
|
|
|
|
|
func _handlePageParam(c *gin.Context) (page, limit int) {
|
|
@@ -77,22 +100,48 @@ func _handlePageParam(c *gin.Context) (page, limit int) {
|
|
|
// @Param activity_id query int true "活动ID"
|
|
|
// @Success 200 ""
|
|
|
// @Router /activity/addRemind [post]
|
|
|
-func AddRemind(c *gin.Context) {
|
|
|
+func AddRemind(c *gin.Context) {
|
|
|
reqActivityId := c.DefaultPostForm("activity_id", "0")
|
|
|
if reqActivityId == "0" {
|
|
|
- response.Fail("参数有误: activity_id", c)
|
|
|
+ response.Fail("参数异常", c)
|
|
|
return
|
|
|
}
|
|
|
activityId, _ := strconv.Atoi(reqActivityId)
|
|
|
userInfo := user.GetUserInfoByStruct(c)
|
|
|
- _, err := activity.CreateRemind(activityId, userInfo)
|
|
|
+ err := activity.CreateRemind(activityId, userInfo)
|
|
|
if err != nil {
|
|
|
- response.Fail("加入提醒失败", c)
|
|
|
+ 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 ""
|
|
|
+// @Router /activity/cancelRemind [post]
|
|
|
+func CancelRemind(c *gin.Context) {
|
|
|
+ reqActivityId := c.DefaultPostForm("activity_id", "0")
|
|
|
+ if reqActivityId == "0" {
|
|
|
+ response.Fail("参数异常", c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ activityId, _ := strconv.Atoi(reqActivityId)
|
|
|
+ userInfo := user.GetUserInfoByStruct(c)
|
|
|
+ err := activity.CancelRemind(activityId, userInfo)
|
|
|
+ if err != nil {
|
|
|
+ response.Fail(err.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ response.OkData("操作成功", "", c)
|
|
|
+}
|
|
|
|
|
|
// RegisterActivity 报名活动
|
|
|
// @Tags 活动模块
|
|
@@ -108,15 +157,82 @@ func AddRemind(c *gin.Context) {
|
|
|
func RegisterActivity(c *gin.Context) {
|
|
|
reqActivityId := c.DefaultPostForm("activity_id", "0")
|
|
|
if reqActivityId == "0" {
|
|
|
- response.Fail("参数有误: activity_id", c)
|
|
|
+ response.Fail("参数异常", c)
|
|
|
return
|
|
|
}
|
|
|
activityId, _ := strconv.Atoi(reqActivityId)
|
|
|
userInfo := user.GetUserInfoByStruct(c)
|
|
|
- _, err := activity.CreateRegister(activityId, userInfo)
|
|
|
+ err := activity.CreateRegister(activityId, userInfo)
|
|
|
if err != nil {
|
|
|
- response.Fail("报名失败", c)
|
|
|
+ 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 ""
|
|
|
+// @Router /activity/cancelRegister [post]
|
|
|
+func CancelRegister(c *gin.Context) {
|
|
|
+ reqActivityId := c.DefaultPostForm("activity_id", "0")
|
|
|
+ if reqActivityId == "0" {
|
|
|
+ response.Fail("参数异常", c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ activityId, _ := strconv.Atoi(reqActivityId)
|
|
|
+ userInfo := user.GetUserInfoByStruct(c)
|
|
|
+ err := activity.CancelRegister(activityId, userInfo)
|
|
|
+ if err != nil {
|
|
|
+ response.Fail(err.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ response.OkData("操作成功", "", c)
|
|
|
+}
|
|
|
+
|
|
|
+// GetActivityDetail 获取活动详情
|
|
|
+// @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 ""
|
|
|
+// @Router /activity/getActivityDetail [get]
|
|
|
+func GetActivityDetail(c *gin.Context) {
|
|
|
+ reqActivityId := c.DefaultQuery("activity_id", "0")
|
|
|
+ if reqActivityId == "0" {
|
|
|
+ response.Fail("参数异常", c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ response.OkData("获取成功", "", c)
|
|
|
+}
|
|
|
+
|
|
|
+// GetActivityVoices 获取活动录音
|
|
|
+// @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 ""
|
|
|
+// @Router /activity/getActivityVoices [get]
|
|
|
+func GetActivityVoices(c *gin.Context) {
|
|
|
+ reqActivityId := c.DefaultQuery("activity_id", "0")
|
|
|
+ if reqActivityId == "0" {
|
|
|
+ response.Fail("参数异常", c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ response.OkData("获取成功", "", c)
|
|
|
}
|