|
@@ -4,16 +4,10 @@ import (
|
|
|
"github.com/gin-gonic/gin"
|
|
|
"hongze/hongze_yb/controller/response"
|
|
|
"hongze/hongze_yb/services/activity"
|
|
|
+ "hongze/hongze_yb/services/user"
|
|
|
"strconv"
|
|
|
)
|
|
|
|
|
|
-/**
|
|
|
- * @method GetPageList
|
|
|
- * @desc 获取活动分页列表
|
|
|
- * @param *gin.Context
|
|
|
- * @return json
|
|
|
- */
|
|
|
-
|
|
|
// GetPageList 活动列表
|
|
|
// @Tags 活动模块
|
|
|
// @Summary 活动列表
|
|
@@ -24,15 +18,17 @@ import (
|
|
|
// @Product json
|
|
|
// @Param activity_name query string false "活动名称"
|
|
|
// @Param activity_type_name query string false "活动类别"
|
|
|
-// @Param active_state query int false "活动状态"
|
|
|
+// @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.YbActivity
|
|
|
+// @Success 200 {object} []yb_activity.QueryActivity
|
|
|
// @Router /activity/getPageList [get]
|
|
|
func GetPageList(c *gin.Context) {
|
|
|
where := _handleListQuery(c)
|
|
|
page, limit := _handlePageParam(c)
|
|
|
- listData, err := activity.PageList(where, page, limit)
|
|
|
+ userInfo := user.GetUserInfoByStruct(c)
|
|
|
+ listData, err := activity.PageList(where, page, limit, userInfo)
|
|
|
if err != nil {
|
|
|
response.Fail("活动获取失败", c)
|
|
|
return
|
|
@@ -42,6 +38,7 @@ func GetPageList(c *gin.Context) {
|
|
|
|
|
|
func _handleListQuery(c *gin.Context) map[string]interface{} {
|
|
|
where := make(map[string]interface{})
|
|
|
+ where["is_delete ="] = 0
|
|
|
title := c.DefaultQuery("activity_name", "")
|
|
|
if title != "" {
|
|
|
where["activity_name like"] = "%" + c.Query("activity_name") + "%"
|
|
@@ -50,16 +47,76 @@ func _handleListQuery(c *gin.Context) map[string]interface{} {
|
|
|
if typeName != "" {
|
|
|
where["activity_type_name like"] = "%" + c.Query("activity_type_name") + "%"
|
|
|
}
|
|
|
- requestState := c.DefaultQuery("active_state", "0")
|
|
|
- if requestState != "" {
|
|
|
- state, _ := strconv.Atoi(requestState)
|
|
|
+ reqState := c.DefaultQuery("active_state", "0")
|
|
|
+ if reqState != "0" {
|
|
|
+ state, _ := strconv.Atoi(reqState)
|
|
|
where["active_state ="] = state
|
|
|
}
|
|
|
+ reqType := c.DefaultQuery("activity_type", "0")
|
|
|
+ if reqType != "0" {
|
|
|
+ activityType, _ := strconv.Atoi(reqType)
|
|
|
+ where["activity_type_id ="] = activityType
|
|
|
+ }
|
|
|
return where
|
|
|
}
|
|
|
|
|
|
-func _handlePageParam(c *gin.Context) (page int, limit int) {
|
|
|
+func _handlePageParam(c *gin.Context) (page, limit int) {
|
|
|
page, _ = strconv.Atoi(c.Query("page"))
|
|
|
limit, _ = strconv.Atoi(c.Query("limit"))
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+// 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 ""
|
|
|
+// @Router /activity/addRemind [post]
|
|
|
+func AddRemind(c *gin.Context) {
|
|
|
+ reqActivityId := c.DefaultPostForm("activity_id", "0")
|
|
|
+ if reqActivityId == "0" {
|
|
|
+ response.Fail("参数有误: activity_id", c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ activityId, _ := strconv.Atoi(reqActivityId)
|
|
|
+ userInfo := user.GetUserInfoByStruct(c)
|
|
|
+ _, err := activity.CreateRemind(activityId, userInfo)
|
|
|
+ if err != nil {
|
|
|
+ response.Fail("加入提醒失败", 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 ""
|
|
|
+// @Router /activity/registerActivity [post]
|
|
|
+func RegisterActivity(c *gin.Context) {
|
|
|
+ reqActivityId := c.DefaultPostForm("activity_id", "0")
|
|
|
+ if reqActivityId == "0" {
|
|
|
+ response.Fail("参数有误: activity_id", c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ activityId, _ := strconv.Atoi(reqActivityId)
|
|
|
+ userInfo := user.GetUserInfoByStruct(c)
|
|
|
+ _, err := activity.CreateRegister(activityId, userInfo)
|
|
|
+ if err != nil {
|
|
|
+ response.Fail("报名失败", c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ response.OkData("操作成功", "", c)
|
|
|
+}
|