|
|
|
@ -37,12 +37,12 @@ func NewSheetHandler(
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (j *SheetHandler) ListTopComment(ctx *gin.Context) (interface{}, error) {
|
|
|
|
|
func (s *SheetHandler) ListTopComment(ctx *gin.Context) (interface{}, error) {
|
|
|
|
|
sheetID, err := util.ParamInt32(ctx, "sheetID")
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
pageSize := j.OptionService.GetOrByDefault(ctx, property.CommentPageSize).(int)
|
|
|
|
|
pageSize := s.OptionService.GetOrByDefault(ctx, property.CommentPageSize).(int)
|
|
|
|
|
|
|
|
|
|
commentQuery := param.CommentQuery{}
|
|
|
|
|
err = ctx.ShouldBindWith(&commentQuery, binding.CustomFormBinding)
|
|
|
|
@ -60,19 +60,19 @@ func (j *SheetHandler) ListTopComment(ctx *gin.Context) (interface{}, error) {
|
|
|
|
|
commentQuery.PageSize = pageSize
|
|
|
|
|
commentQuery.ParentID = util.Int32Ptr(0)
|
|
|
|
|
|
|
|
|
|
comments, totalCount, err := j.SheetCommentService.Page(ctx, commentQuery, consts.CommentTypeSheet)
|
|
|
|
|
comments, totalCount, err := s.SheetCommentService.Page(ctx, commentQuery, consts.CommentTypeSheet)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
_ = j.SheetCommentAssembler.ClearSensitiveField(ctx, comments)
|
|
|
|
|
commenVOs, err := j.SheetCommentAssembler.ConvertToWithHasChildren(ctx, comments)
|
|
|
|
|
_ = s.SheetCommentAssembler.ClearSensitiveField(ctx, comments)
|
|
|
|
|
commenVOs, err := s.SheetCommentAssembler.ConvertToWithHasChildren(ctx, comments)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
return dto.NewPage(commenVOs, totalCount, commentQuery.Page), nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (j *SheetHandler) ListChildren(ctx *gin.Context) (interface{}, error) {
|
|
|
|
|
func (s *SheetHandler) ListChildren(ctx *gin.Context) (interface{}, error) {
|
|
|
|
|
sheetID, err := util.ParamInt32(ctx, "sheetID")
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
@ -81,20 +81,20 @@ func (j *SheetHandler) ListChildren(ctx *gin.Context) (interface{}, error) {
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
children, err := j.SheetCommentService.GetChildren(ctx, parentID, sheetID, consts.CommentTypeSheet)
|
|
|
|
|
children, err := s.SheetCommentService.GetChildren(ctx, parentID, sheetID, consts.CommentTypeSheet)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
_ = j.SheetCommentAssembler.ClearSensitiveField(ctx, children)
|
|
|
|
|
return j.SheetCommentAssembler.ConvertToDTOList(ctx, children)
|
|
|
|
|
_ = s.SheetCommentAssembler.ClearSensitiveField(ctx, children)
|
|
|
|
|
return s.SheetCommentAssembler.ConvertToDTOList(ctx, children)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p *SheetHandler) ListCommentTree(ctx *gin.Context) (interface{}, error) {
|
|
|
|
|
func (s *SheetHandler) ListCommentTree(ctx *gin.Context) (interface{}, error) {
|
|
|
|
|
sheetID, err := util.ParamInt32(ctx, "sheetID")
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
pageSize := p.OptionService.GetOrByDefault(ctx, property.CommentPageSize).(int)
|
|
|
|
|
pageSize := s.OptionService.GetOrByDefault(ctx, property.CommentPageSize).(int)
|
|
|
|
|
|
|
|
|
|
commentQuery := param.CommentQuery{}
|
|
|
|
|
err = ctx.ShouldBindWith(&commentQuery, binding.CustomFormBinding)
|
|
|
|
@ -112,24 +112,24 @@ func (p *SheetHandler) ListCommentTree(ctx *gin.Context) (interface{}, error) {
|
|
|
|
|
commentQuery.PageSize = pageSize
|
|
|
|
|
commentQuery.ParentID = util.Int32Ptr(0)
|
|
|
|
|
|
|
|
|
|
allComments, err := p.SheetCommentService.GetByContentID(ctx, sheetID, consts.CommentTypeSheet, commentQuery.Sort)
|
|
|
|
|
allComments, err := s.SheetCommentService.GetByContentID(ctx, sheetID, consts.CommentTypeSheet, commentQuery.Sort)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
_ = p.SheetCommentAssembler.ClearSensitiveField(ctx, allComments)
|
|
|
|
|
commentVOs, total, err := p.SheetCommentAssembler.PageConvertToVOs(ctx, allComments, commentQuery.Page)
|
|
|
|
|
_ = s.SheetCommentAssembler.ClearSensitiveField(ctx, allComments)
|
|
|
|
|
commentVOs, total, err := s.SheetCommentAssembler.PageConvertToVOs(ctx, allComments, commentQuery.Page)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
return dto.NewPage(commentVOs, total, commentQuery.Page), nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p *SheetHandler) ListComment(ctx *gin.Context) (interface{}, error) {
|
|
|
|
|
func (s *SheetHandler) ListComment(ctx *gin.Context) (interface{}, error) {
|
|
|
|
|
sheetID, err := util.ParamInt32(ctx, "sheetID")
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
pageSize := p.OptionService.GetOrByDefault(ctx, property.CommentPageSize).(int)
|
|
|
|
|
pageSize := s.OptionService.GetOrByDefault(ctx, property.CommentPageSize).(int)
|
|
|
|
|
|
|
|
|
|
commentQuery := param.CommentQuery{}
|
|
|
|
|
err = ctx.ShouldBindWith(&commentQuery, binding.CustomFormBinding)
|
|
|
|
@ -147,21 +147,21 @@ func (p *SheetHandler) ListComment(ctx *gin.Context) (interface{}, error) {
|
|
|
|
|
commentQuery.PageSize = pageSize
|
|
|
|
|
commentQuery.ParentID = util.Int32Ptr(0)
|
|
|
|
|
|
|
|
|
|
comments, total, err := p.SheetCommentService.Page(ctx, commentQuery, consts.CommentTypeSheet)
|
|
|
|
|
comments, total, err := s.SheetCommentService.Page(ctx, commentQuery, consts.CommentTypeSheet)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
_ = p.SheetCommentAssembler.ClearSensitiveField(ctx, comments)
|
|
|
|
|
result, err := p.SheetCommentAssembler.ConvertToWithParentVO(ctx, comments)
|
|
|
|
|
_ = s.SheetCommentAssembler.ClearSensitiveField(ctx, comments)
|
|
|
|
|
result, err := s.SheetCommentAssembler.ConvertToWithParentVO(ctx, comments)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
return dto.NewPage(result, total, commentQuery.Page), nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p *SheetHandler) CreateComment(ctx *gin.Context) (interface{}, error) {
|
|
|
|
|
func (s *SheetHandler) CreateComment(ctx *gin.Context) (interface{}, error) {
|
|
|
|
|
comment := param.Comment{}
|
|
|
|
|
err := ctx.ShouldBindJSON(&p)
|
|
|
|
|
err := ctx.ShouldBindJSON(&comment)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
@ -170,9 +170,9 @@ func (p *SheetHandler) CreateComment(ctx *gin.Context) (interface{}, error) {
|
|
|
|
|
comment.Content = template.HTMLEscapeString(comment.Content)
|
|
|
|
|
comment.Email = template.HTMLEscapeString(comment.Email)
|
|
|
|
|
comment.CommentType = consts.CommentTypeSheet
|
|
|
|
|
result, err := p.SheetCommentService.CreateBy(ctx, &comment)
|
|
|
|
|
result, err := s.SheetCommentService.CreateBy(ctx, &comment)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
return p.SheetCommentAssembler.ConvertToDTO(ctx, result)
|
|
|
|
|
return s.SheetCommentAssembler.ConvertToDTO(ctx, result)
|
|
|
|
|
}
|
|
|
|
|