|
@@ -1,20 +1,28 @@
|
|
package yb
|
|
package yb
|
|
|
|
|
|
import (
|
|
import (
|
|
|
|
+ "encoding/json"
|
|
"github.com/rdlucklib/rdluck_tools/paging"
|
|
"github.com/rdlucklib/rdluck_tools/paging"
|
|
|
|
+ "hongze/hongze_mobile_admin/controllers"
|
|
|
|
+ ybRequest "hongze/hongze_mobile_admin/models/request/yb"
|
|
ybResponse "hongze/hongze_mobile_admin/models/response/yb"
|
|
ybResponse "hongze/hongze_mobile_admin/models/response/yb"
|
|
"hongze/hongze_mobile_admin/services/yb"
|
|
"hongze/hongze_mobile_admin/services/yb"
|
|
"hongze/hongze_mobile_admin/utils"
|
|
"hongze/hongze_mobile_admin/utils"
|
|
)
|
|
)
|
|
|
|
|
|
-// QuestionCommentList
|
|
|
|
|
|
+type CommunityQuestionCommentController struct {
|
|
|
|
+ controllers.BaseAuth
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// List
|
|
// @Title 获取问答评论列表
|
|
// @Title 获取问答评论列表
|
|
// @Description 获取问答评论列表
|
|
// @Description 获取问答评论列表
|
|
-// @Param TopStatus query int false "提问状态 -1:全部 0-未精选,1-已精选"
|
|
|
|
|
|
+// @Param CommunityQuestionCommentId query int false "评论id"
|
|
|
|
+// @Param HotStatus query int false "精选状态 -1:全部 0-未精选,1-已精选"
|
|
// @Param Keyword query string false "关键字搜索"
|
|
// @Param Keyword query string false "关键字搜索"
|
|
// @Success 200 {object} yb.CommunityQuestionCommentListResp
|
|
// @Success 200 {object} yb.CommunityQuestionCommentListResp
|
|
// @router /community/question/comment/list [get]
|
|
// @router /community/question/comment/list [get]
|
|
-func (c *CommunityQuestionController) QuestionCommentList() {
|
|
|
|
|
|
+func (c *CommunityQuestionCommentController) List() {
|
|
sysUser := c.AdminWx
|
|
sysUser := c.AdminWx
|
|
|
|
|
|
// 权限校验
|
|
// 权限校验
|
|
@@ -27,16 +35,23 @@ func (c *CommunityQuestionController) QuestionCommentList() {
|
|
condition := ""
|
|
condition := ""
|
|
pars := make([]interface{}, 0)
|
|
pars := make([]interface{}, 0)
|
|
|
|
|
|
- //精选状态状态
|
|
|
|
- topStatus, _ := c.GetInt("TopStatus", 0)
|
|
|
|
- if topStatus >= 0 {
|
|
|
|
- condition += ` AND a.is_hot = ? `
|
|
|
|
- pars = append(pars, topStatus)
|
|
|
|
- }
|
|
|
|
- //关键字
|
|
|
|
- keyword := c.GetString("Keyword", "")
|
|
|
|
- if keyword != "" {
|
|
|
|
- condition += ` AND a.content like "%` + keyword + `%"`
|
|
|
|
|
|
+ //问答id
|
|
|
|
+ communityQuestionCommentId, _ := c.GetInt("CommunityQuestionCommentId", 0)
|
|
|
|
+ if communityQuestionCommentId > 0 {
|
|
|
|
+ condition += ` AND a.community_question_comment_id = ? `
|
|
|
|
+ pars = append(pars, communityQuestionCommentId)
|
|
|
|
+ } else {
|
|
|
|
+ //精选状态状态
|
|
|
|
+ hotStatus, _ := c.GetInt("HotStatus", 0)
|
|
|
|
+ if hotStatus >= 0 {
|
|
|
|
+ condition += ` AND a.is_hot = ? `
|
|
|
|
+ pars = append(pars, hotStatus)
|
|
|
|
+ }
|
|
|
|
+ //关键字
|
|
|
|
+ keyword := c.GetString("Keyword", "")
|
|
|
|
+ if keyword != "" {
|
|
|
|
+ condition += ` AND a.content like "%` + keyword + `%"`
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
var startSize int
|
|
var startSize int
|
|
@@ -62,3 +77,56 @@ func (c *CommunityQuestionController) QuestionCommentList() {
|
|
List: list,
|
|
List: list,
|
|
}, "获取成功")
|
|
}, "获取成功")
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+// Delete
|
|
|
|
+// @Title 删除评论
|
|
|
|
+// @Description 删除评论
|
|
|
|
+// @Param QuestionId query int false "问题ID"
|
|
|
|
+// @Success 200 string "操作成功"
|
|
|
|
+// @router /community/question/comment/delete [post]
|
|
|
|
+func (c *CommunityQuestionCommentController) Delete() {
|
|
|
|
+ sysUser := c.AdminWx
|
|
|
|
+ // 权限校验
|
|
|
|
+ msg, err := yb.CheckCommunityQuestionPermission(sysUser.AdminId)
|
|
|
|
+ if err != nil {
|
|
|
|
+ c.FailWithMessage(msg, err.Error())
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ var req ybRequest.QuestionCommentDeleteReq
|
|
|
|
+ if err := json.Unmarshal(c.Ctx.Input.RequestBody, &req); err != nil {
|
|
|
|
+ c.FailWithMessage("参数解析异常!", "参数解析失败,Err:"+err.Error())
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ if err, errMsg := yb.SoftDeleteQuestionComment(req.CommunityQuestionCommentId); err != nil {
|
|
|
|
+ c.FailWithMessage(errMsg, "DeleteQuestion,Err:"+err.Error())
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ c.OkWithMessage("删除成功")
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// Hot
|
|
|
|
+// @Title 设置/取消 问题评论精选
|
|
|
|
+// @Description 设置/取消 问题评论精选
|
|
|
|
+// @Success 200 string "操作成功"
|
|
|
|
+// @router /community/question/comment/hot [post]
|
|
|
|
+func (c *CommunityQuestionCommentController) Hot() {
|
|
|
|
+ sysUser := c.AdminWx
|
|
|
|
+ // 权限校验
|
|
|
|
+ msg, err := yb.CheckCommunityQuestionPermission(sysUser.AdminId)
|
|
|
|
+ if err != nil {
|
|
|
|
+ c.FailWithMessage(msg, err.Error())
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ var req ybRequest.QuestionCommentHotReq
|
|
|
|
+ if err := json.Unmarshal(c.Ctx.Input.RequestBody, &req); err != nil {
|
|
|
|
+ c.FailWithMessage("参数解析异常!", "参数解析失败,Err:"+err.Error())
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ if err, errMsg := yb.SetHotQuestionComment(req.CommunityQuestionCommentId); err != nil {
|
|
|
|
+ c.FailWithMessage(errMsg, "DeleteQuestion,Err:"+err.Error())
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ c.OkWithMessage("操作成功")
|
|
|
|
+}
|