|
@@ -18,19 +18,20 @@ import (
|
|
|
// @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 title 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.ActivityItem
|
|
|
+// @failure 400 {string} string "活动获取失败"
|
|
|
// @Router /activity/getPageList [get]
|
|
|
func GetPageList(c *gin.Context) {
|
|
|
- where, order := _handleListQuery(c)
|
|
|
- page, limit := _handlePageParam(c)
|
|
|
+ page, _ := strconv.Atoi(c.Query("page"))
|
|
|
+ limit, _ := strconv.Atoi(c.Query("limit"))
|
|
|
+ condition, pars, order := _handleListQuery(c)
|
|
|
userInfo := user.GetInfoByClaims(c)
|
|
|
- listData, err := activity.PageList(where, page, limit, order, userInfo)
|
|
|
+ listData, err := activity.PageList(condition, pars, page, limit, order, userInfo)
|
|
|
if err != nil {
|
|
|
response.Fail("活动获取失败", c)
|
|
|
return
|
|
@@ -38,16 +39,15 @@ func GetPageList(c *gin.Context) {
|
|
|
response.OkData("获取成功", listData, c)
|
|
|
}
|
|
|
|
|
|
-func _handleListQuery(c *gin.Context) (map[string]interface{}, string) {
|
|
|
- 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") + "%"
|
|
|
+func _handleListQuery(c *gin.Context) (string, []interface{}, string) {
|
|
|
+ condition := "is_delete = 0"
|
|
|
+ pars := make([]interface{}, 0)
|
|
|
+ // 活动类别/标题
|
|
|
+ reqTitle := c.DefaultQuery("title", "")
|
|
|
+ if reqTitle != "" {
|
|
|
+ condition += ` AND (activity_type_name LIKE ? OR activity_name LIKE ?)`
|
|
|
+ pars = append(pars, "%" + reqTitle + "%")
|
|
|
+ pars = append(pars, "%" + reqTitle + "%")
|
|
|
}
|
|
|
order := ""
|
|
|
reqState := c.DefaultQuery("active_state", "0")
|
|
@@ -65,28 +65,27 @@ func _handleListQuery(c *gin.Context) (map[string]interface{}, string) {
|
|
|
switch state {
|
|
|
case 1:
|
|
|
// 时间在本周内且未开始
|
|
|
- where["start_time >="] = queryStart
|
|
|
- where["end_time <"] = weekEnd
|
|
|
+ condition += ` AND start_time >= ?`
|
|
|
+ pars = append(pars, queryStart)
|
|
|
+ condition += ` AND end_time < ?`
|
|
|
+ pars = append(pars, weekEnd)
|
|
|
case 2:
|
|
|
- where["start_time <="] = nowTime
|
|
|
- where["end_time >"] = nowTime
|
|
|
+ condition += ` AND start_time <= ?`
|
|
|
+ pars = append(pars, nowTime)
|
|
|
+ condition += ` AND end_time > ?`
|
|
|
+ pars = append(pars, nowTime)
|
|
|
case 3:
|
|
|
- where["end_time <"] = nowTime
|
|
|
- order = "start_time desc"
|
|
|
+ condition += ` AND end_time < ?`
|
|
|
+ pars = append(pars, nowTime)
|
|
|
}
|
|
|
}
|
|
|
reqType := c.DefaultQuery("activity_type", "0")
|
|
|
if reqType != "0" {
|
|
|
activityType, _ := strconv.Atoi(reqType)
|
|
|
- where["activity_type_id ="] = activityType
|
|
|
+ condition += ` AND activity_type_id = ?`
|
|
|
+ pars = append(pars, activityType)
|
|
|
}
|
|
|
- return where, order
|
|
|
-}
|
|
|
-
|
|
|
-func _handlePageParam(c *gin.Context) (page, limit int) {
|
|
|
- page, _ = strconv.Atoi(c.Query("page"))
|
|
|
- limit, _ = strconv.Atoi(c.Query("limit"))
|
|
|
- return
|
|
|
+ return condition, pars, order
|
|
|
}
|
|
|
|
|
|
// AddRemind 添加提醒
|
|
@@ -98,7 +97,8 @@ func _handlePageParam(c *gin.Context) (page, limit int) {
|
|
|
// @Accept json
|
|
|
// @Product json
|
|
|
// @Param activity_id query int true "活动ID"
|
|
|
-// @Success 200 ""
|
|
|
+// @Success 200 {string} string "操作成功"
|
|
|
+// @failure 400 {string} string "操作失败"
|
|
|
// @Router /activity/addRemind [post]
|
|
|
func AddRemind(c *gin.Context) {
|
|
|
reqActivityId := c.DefaultPostForm("activity_id", "0")
|
|
@@ -108,7 +108,12 @@ func AddRemind(c *gin.Context) {
|
|
|
}
|
|
|
activityId, _ := strconv.Atoi(reqActivityId)
|
|
|
userInfo := user.GetInfoByClaims(c)
|
|
|
- err := activity.CreateRemind(activityId, userInfo)
|
|
|
+ ok, permissionCheckInfo, err := activity.CheckActivityPermission(userInfo, activityId)
|
|
|
+ if !ok {
|
|
|
+ response.AuthError(permissionCheckInfo, "暂无权限", c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ err = activity.CreateRemind(activityId, userInfo)
|
|
|
if err != nil {
|
|
|
response.Fail(err.Error(), c)
|
|
|
return
|
|
@@ -125,7 +130,8 @@ func AddRemind(c *gin.Context) {
|
|
|
// @Accept json
|
|
|
// @Product json
|
|
|
// @Param activity_id query int true "活动ID"
|
|
|
-// @Success 200 ""
|
|
|
+// @Success 200 {string} string "操作成功"
|
|
|
+// @failure 400 {string} string "操作失败"
|
|
|
// @Router /activity/cancelRemind [post]
|
|
|
func CancelRemind(c *gin.Context) {
|
|
|
reqActivityId := c.DefaultPostForm("activity_id", "0")
|
|
@@ -135,7 +141,12 @@ func CancelRemind(c *gin.Context) {
|
|
|
}
|
|
|
activityId, _ := strconv.Atoi(reqActivityId)
|
|
|
userInfo := user.GetInfoByClaims(c)
|
|
|
- err := activity.CancelRemind(activityId, userInfo)
|
|
|
+ ok, permissionCheckInfo, err := activity.CheckActivityPermission(userInfo, activityId)
|
|
|
+ if !ok {
|
|
|
+ response.AuthError(permissionCheckInfo, "暂无权限", c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ err = activity.CancelRemind(activityId, userInfo)
|
|
|
if err != nil {
|
|
|
response.Fail(err.Error(), c)
|
|
|
return
|
|
@@ -152,7 +163,8 @@ func CancelRemind(c *gin.Context) {
|
|
|
// @Accept json
|
|
|
// @Product json
|
|
|
// @Param activity_id query int true "活动ID"
|
|
|
-// @Success 200 ""
|
|
|
+// @Success 200 {string} string "操作成功"
|
|
|
+// @failure 400 {string} string "操作失败"
|
|
|
// @Router /activity/registerActivity [post]
|
|
|
func RegisterActivity(c *gin.Context) {
|
|
|
reqActivityId := c.DefaultPostForm("activity_id", "0")
|
|
@@ -162,7 +174,12 @@ func RegisterActivity(c *gin.Context) {
|
|
|
}
|
|
|
activityId, _ := strconv.Atoi(reqActivityId)
|
|
|
userInfo := user.GetInfoByClaims(c)
|
|
|
- err := activity.CreateRegister(activityId, userInfo)
|
|
|
+ ok, permissionCheckInfo, err := activity.CheckActivityPermission(userInfo, activityId)
|
|
|
+ if !ok {
|
|
|
+ response.AuthError(permissionCheckInfo, "暂无权限", c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ err = activity.CreateRegister(activityId, userInfo)
|
|
|
if err != nil {
|
|
|
response.Fail(err.Error(), c)
|
|
|
return
|
|
@@ -179,7 +196,8 @@ func RegisterActivity(c *gin.Context) {
|
|
|
// @Accept json
|
|
|
// @Product json
|
|
|
// @Param activity_id query int true "活动ID"
|
|
|
-// @Success 200 ""
|
|
|
+// @Success 200 {string} string "操作成功"
|
|
|
+// @failure 400 {string} string "操作失败"
|
|
|
// @Router /activity/cancelRegister [post]
|
|
|
func CancelRegister(c *gin.Context) {
|
|
|
reqActivityId := c.DefaultPostForm("activity_id", "0")
|
|
@@ -189,7 +207,12 @@ func CancelRegister(c *gin.Context) {
|
|
|
}
|
|
|
activityId, _ := strconv.Atoi(reqActivityId)
|
|
|
userInfo := user.GetInfoByClaims(c)
|
|
|
- err := activity.CancelRegister(activityId, userInfo)
|
|
|
+ ok, permissionCheckInfo, err := activity.CheckActivityPermission(userInfo, activityId)
|
|
|
+ if !ok {
|
|
|
+ response.AuthError(permissionCheckInfo, "暂无权限", c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ err = activity.CancelRegister(activityId, userInfo)
|
|
|
if err != nil {
|
|
|
response.Fail(err.Error(), c)
|
|
|
return
|
|
@@ -206,7 +229,8 @@ func CancelRegister(c *gin.Context) {
|
|
|
// @Accept json
|
|
|
// @Product json
|
|
|
// @Param activity_id query int true "活动ID"
|
|
|
-// @Success 200 ""
|
|
|
+// @Success 200 {object} yb_activity.ActivityDetail
|
|
|
+// @failure 400 {string} string "获取失败"
|
|
|
// @Router /activity/getActivityDetail [get]
|
|
|
func GetActivityDetail(c *gin.Context) {
|
|
|
reqActivityId := c.DefaultQuery("activity_id", "0")
|
|
@@ -216,6 +240,11 @@ func GetActivityDetail(c *gin.Context) {
|
|
|
}
|
|
|
activityId, _ := strconv.Atoi(reqActivityId)
|
|
|
userInfo := user.GetInfoByClaims(c)
|
|
|
+ ok, permissionCheckInfo, err := activity.CheckActivityPermission(userInfo, activityId)
|
|
|
+ if !ok {
|
|
|
+ response.AuthError(permissionCheckInfo, "暂无权限", c)
|
|
|
+ return
|
|
|
+ }
|
|
|
data, err := activity.GetActivityDetail(activityId, int(userInfo.UserID))
|
|
|
if err != nil {
|
|
|
response.Fail("未找到记录", c)
|
|
@@ -233,7 +262,8 @@ func GetActivityDetail(c *gin.Context) {
|
|
|
// @Accept json
|
|
|
// @Product json
|
|
|
// @Param activity_id query int true "活动ID"
|
|
|
-// @Success 200 ""
|
|
|
+// @Success 200 {object} []yb_activity_voice.YbActivityVoice
|
|
|
+// @failure 400 {string} string "获取失败"
|
|
|
// @Router /activity/getActivityVoices [get]
|
|
|
func GetActivityVoices(c *gin.Context) {
|
|
|
reqActivityId := c.DefaultQuery("activity_id", "0")
|