置顶、回复备注、文章删除的时候评论展示
This commit is contained in:
parent
baeeb84cee
commit
341c082d8d
|
|
@ -58,6 +58,13 @@ public class PublicDetailCommentAppController {
|
|||
return Result.success(detailCommentAppService.query(detailComment, pageNum, pageSize));
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@PostMapping("/getTopComment")
|
||||
@ApiOperation(value = "获取置顶评论")
|
||||
public Result<PublicDetailComment> getTopComment(@RequestBody PublicDetailComment detailComment) {
|
||||
return Result.success(detailCommentAppService.getTopComment(detailComment));
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@PostMapping("/start")
|
||||
@ApiOperation(value = "点赞用户评论")
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import java.util.Date;
|
|||
import java.util.List;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.playlet.common.utils.StringUtils;
|
||||
import com.playlet.system.domain.PublicDetailComment;
|
||||
import com.playlet.system.service.IPublicDetailCommentService;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
|
|
@ -97,6 +98,10 @@ public class PublicCommentResponseController extends BaseController
|
|||
.eq(PublicCommentResponse::getCommentId, publicCommentResponse.getCommentId())
|
||||
.one();
|
||||
if(model != null){
|
||||
// 置空默认为删除
|
||||
if(StringUtils.isEmpty(publicCommentResponse.getResponseContent())){
|
||||
publicCommentResponseService.removeById(model.getId());
|
||||
}
|
||||
model.setResponseContent(publicCommentResponse.getResponseContent());
|
||||
model.setCreateTime(new Date());
|
||||
publicCommentResponseService.updateById(model);
|
||||
|
|
@ -107,6 +112,9 @@ public class PublicCommentResponseController extends BaseController
|
|||
PublicDetailComment comment = publicDetailCommentService.getById(publicCommentResponse.getCommentId());
|
||||
if(comment != null){
|
||||
comment.setRemark(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
|
||||
if(StringUtils.isEmpty(publicCommentResponse.getResponseContent())){
|
||||
comment.setRemark("");
|
||||
}
|
||||
publicDetailCommentService.updateById(comment);
|
||||
}
|
||||
return AjaxResult.success();
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.playlet.web.controller.system;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import com.playlet.common.core.domain.entity.SysUser;
|
||||
import com.playlet.system.domain.PlayletPublicDetail;
|
||||
import com.playlet.system.domain.PublicCommentResponse;
|
||||
import com.playlet.system.service.IPlayletPublicDetailService;
|
||||
|
|
@ -66,6 +67,8 @@ public class PublicDetailCommentController extends BaseController
|
|||
if(playletPublicDetail != null){
|
||||
model.setDetailName(playletPublicDetail.getTitle());
|
||||
model.setAuthorAlias(playletPublicDetail.getAuthorAlias());
|
||||
}else {
|
||||
model.setDetailName("已删除文章");
|
||||
}
|
||||
PublicCommentResponse publicCommentResponse = publicCommentResponseService.lambdaQuery()
|
||||
.eq(PublicCommentResponse::getCommentId, model.getId()).one();
|
||||
|
|
@ -144,6 +147,26 @@ public class PublicDetailCommentController extends BaseController
|
|||
return toAjax(publicDetailCommentService.updatePublicDetailComment(publicDetailComment));
|
||||
}
|
||||
|
||||
@PostMapping("/changeStatus")
|
||||
@ResponseBody
|
||||
public AjaxResult changeStatus(PublicDetailComment publicDetailComment)
|
||||
{
|
||||
// 查询评论
|
||||
PublicDetailComment model = publicDetailCommentService.getById(publicDetailComment.getId());
|
||||
// 查询是否已经有置顶的评论
|
||||
PublicDetailComment topModel = publicDetailCommentService.lambdaQuery()
|
||||
.eq(PublicDetailComment::getDetailId, model.getDetailId())
|
||||
.eq(PublicDetailComment::getTopStatus, "02")
|
||||
.one();
|
||||
if(topModel != null){
|
||||
topModel.setTopStatus("01");
|
||||
publicDetailCommentService.updateById(topModel);
|
||||
}
|
||||
model.setTopStatus("02");
|
||||
publicDetailCommentService.updateById(model);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除文章评论
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -19,4 +19,7 @@ public interface PublicDetailCommentAppService {
|
|||
|
||||
void delete(PublicDetailComment detailComment);
|
||||
|
||||
PublicDetailComment getTopComment(PublicDetailComment detailComment);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,9 +5,12 @@ import com.playlet.system.service.IPlayletPublicUserService;
|
|||
import com.playlet.web.service.app.PlayletPublicUserAppService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||
|
|
@ -23,10 +26,14 @@ public class PlayletPublicUserAppServiceImpl implements PlayletPublicUserAppServ
|
|||
|
||||
@Override
|
||||
public PlayletPublicUser findByUnionIdAndPublicId(PlayletPublicUser publicUser) {
|
||||
return iPlayletPublicUserService.lambdaQuery()
|
||||
List<PlayletPublicUser> list =iPlayletPublicUserService.lambdaQuery()
|
||||
.eq(PlayletPublicUser::getPublicId, publicUser.getPublicId())
|
||||
.eq(PlayletPublicUser::getUnionId, publicUser.getUnionId())
|
||||
.one();
|
||||
.list();
|
||||
if(CollectionUtils.isNotEmpty(list)){
|
||||
return list.get(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -91,4 +91,12 @@ public class PublicDetailCommentAppServiceImpl implements PublicDetailCommentApp
|
|||
iPublicDetailCommentService.removeById(detailComment.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public PublicDetailComment getTopComment(PublicDetailComment detailComment) {
|
||||
// 查询是否已经有置顶的评论
|
||||
return iPublicDetailCommentService.lambdaQuery()
|
||||
.eq(PublicDetailComment::getDetailId, detailComment.getDetailId())
|
||||
.eq(PublicDetailComment::getTopStatus, "02")
|
||||
.one();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -124,6 +124,7 @@
|
|||
formatter: function(value, row, index) {
|
||||
var actions = [];
|
||||
// actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
|
||||
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="topComment(\'' + row.id + '\')"><i class="fa fa-edit"></i>置顶评论</a> ');
|
||||
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="responseComment(\'' + row.id + '\')"><i class="fa fa-edit"></i>回复评论</a> ');
|
||||
actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
|
||||
return actions.join('');
|
||||
|
|
@ -139,6 +140,12 @@
|
|||
$.modal.open("回复评论", url, '770', '380');
|
||||
}
|
||||
|
||||
function topComment(id) {
|
||||
$.modal.confirm("确认要置顶评论吗?", function() {
|
||||
$.operate.post(prefix + "/changeStatus", { "id": id, "topStatus": "02" });
|
||||
})
|
||||
}
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -78,4 +78,7 @@ public class PublicDetailComment extends BaseEntity
|
|||
@ApiModelProperty(value = "是否点赞 01.未点赞 02.已点赞")
|
||||
private String isStar;
|
||||
|
||||
@ApiModelProperty(value = "置顶状态 01.普通 02.置顶")
|
||||
private String topStatus;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,10 +17,11 @@
|
|||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="remark" column="remark" />
|
||||
<result property="topStatus" column="top_status" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectPublicDetailCommentVo">
|
||||
select id, detail_id, user_id, user_name, img_url, content, star_count, create_by, create_time, update_by, update_time, remark from public_detail_comment
|
||||
select id, detail_id, user_id, user_name, top_status, img_url, content, star_count, create_by, create_time, update_by, update_time, remark from public_detail_comment
|
||||
</sql>
|
||||
|
||||
<select id="selectPublicDetailCommentList" parameterType="PublicDetailComment" resultMap="PublicDetailCommentResult">
|
||||
|
|
|
|||
Loading…
Reference in New Issue