123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- package activity
- import (
- "github.com/gin-gonic/gin"
- "hongze/hongze_yb/controller/response"
- "hongze/hongze_yb/services/activity"
- "hongze/hongze_yb/services/user"
- "strconv"
- )
- // GetPageList 活动列表
- // @Tags 活动模块
- // @Summary 活动列表
- // @Description 获取活动列表
- // @Security ApiKeyAuth
- // @Param Authorization header string true "Bearer 31a165baebe6dec616b1f8f3207b4273"
- // @Accept json
- // @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 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)
- page, limit := _handlePageParam(c)
- userInfo := user.GetUserInfoByStruct(c)
- listData, err := activity.PageList(where, page, limit, userInfo)
- if err != nil {
- response.Fail("活动获取失败", c)
- return
- }
- response.OkData("获取成功", listData, c)
- }
- 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") + "%"
- }
- typeName := c.DefaultQuery("activity_type_name", "")
- if typeName != "" {
- where["activity_type_name like"] = "%" + c.Query("activity_type_name") + "%"
- }
- 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, 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)
- }
|