forked from Gitlink/microservices
feat(文章评论功能开发): 文章评论获取调整为公开接口允许所有人访问,不进行可否删除权限判断
This commit is contained in:
parent
f982494346
commit
475e097a4f
|
|
@ -6,7 +6,9 @@ import com.ruoyi.cms.doc.domain.CmsDocCommentUpdateDto;
|
||||||
import com.ruoyi.cms.doc.service.ICmsDocCommentService;
|
import com.ruoyi.cms.doc.service.ICmsDocCommentService;
|
||||||
import com.ruoyi.common.core.web.controller.BaseController;
|
import com.ruoyi.common.core.web.controller.BaseController;
|
||||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||||
import io.swagger.annotations.*;
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import io.swagger.annotations.ApiParam;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
|
@ -63,19 +65,4 @@ public class CmsDocCommentController extends BaseController {
|
||||||
return success(result);
|
return success(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取文章下评论列表
|
|
||||||
*/
|
|
||||||
@GetMapping("/{docId}/list")
|
|
||||||
@ApiOperation(value = "获取文章下评论列表")
|
|
||||||
@ApiImplicitParams({
|
|
||||||
@ApiImplicitParam(name = "page", value = "页码", paramType = "query", dataType = "Integer"),
|
|
||||||
@ApiImplicitParam(name = "limit", value = "分页数", paramType = "query", dataType = "Integer"),
|
|
||||||
})
|
|
||||||
public AjaxResult getCommentList(
|
|
||||||
@ApiParam("文章Id") @PathVariable Long docId, Integer page, Integer limit) {
|
|
||||||
JSONObject result = cmsDocCommentService.getCommentList(docId, page, limit);
|
|
||||||
return success(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
package com.ruoyi.cms.doc.controller;
|
package com.ruoyi.cms.doc.controller;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.ruoyi.cms.doc.domain.*;
|
import com.ruoyi.cms.doc.domain.*;
|
||||||
|
import com.ruoyi.cms.doc.service.ICmsDocCommentService;
|
||||||
import com.ruoyi.cms.doc.service.ICmsDocService;
|
import com.ruoyi.cms.doc.service.ICmsDocService;
|
||||||
import com.ruoyi.common.core.web.controller.BaseController;
|
import com.ruoyi.common.core.web.controller.BaseController;
|
||||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||||
|
|
@ -26,6 +28,8 @@ import java.util.List;
|
||||||
public class OpenController extends BaseController {
|
public class OpenController extends BaseController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private ICmsDocService cmsDocService;
|
private ICmsDocService cmsDocService;
|
||||||
|
@Autowired
|
||||||
|
private ICmsDocCommentService cmsDocCommentService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询栏目列表
|
* 查询栏目列表
|
||||||
|
|
@ -163,5 +167,21 @@ public class OpenController extends BaseController {
|
||||||
cmsDocService.syncDocData(deptId,bodyStr);
|
cmsDocService.syncDocData(deptId,bodyStr);
|
||||||
return AjaxResult.success("同步消息发送成功");
|
return AjaxResult.success("同步消息发送成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 公开获取文章下评论列表
|
||||||
|
*/
|
||||||
|
@GetMapping("/{docId}/journalList")
|
||||||
|
@ApiOperation(value = "公开获取文章下评论列表")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "page", value = "页码", paramType = "query", dataType = "Integer"),
|
||||||
|
@ApiImplicitParam(name = "limit", value = "分页数", paramType = "query", dataType = "Integer"),
|
||||||
|
})
|
||||||
|
public AjaxResult getCommentList(
|
||||||
|
@ApiParam("文章Id") @PathVariable Long docId, Integer page, Integer limit) {
|
||||||
|
JSONObject result = cmsDocCommentService.getCommentList(docId, page, limit);
|
||||||
|
return success(result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -82,24 +82,24 @@ public class CmsDocCommentServiceImpl implements ICmsDocCommentService {
|
||||||
page, limit
|
page, limit
|
||||||
));
|
));
|
||||||
JSONArray journals = journalDataJson.getJSONArray("journals");
|
JSONArray journals = journalDataJson.getJSONArray("journals");
|
||||||
if (journals != null) {
|
// if (journals != null) {
|
||||||
// 设置评论可删除权限
|
// // 设置评论可删除权限
|
||||||
for (int i = 0; i < journals.size(); i++) {
|
// for (int i = 0; i < journals.size(); i++) {
|
||||||
JSONObject journal = journals.getJSONObject(i);
|
// JSONObject journal = journals.getJSONObject(i);
|
||||||
setJournalCanDelete(cmsDoc, journal);
|
// setJournalCanDelete(cmsDoc, journal);
|
||||||
journals.set(i, journal);
|
// journals.set(i, journal);
|
||||||
// 检查评论是否存在回复
|
// // 检查评论是否存在回复
|
||||||
JSONArray childrenJournals = journal.getJSONArray("children_journals");
|
// JSONArray childrenJournals = journal.getJSONArray("children_journals");
|
||||||
if (childrenJournals != null) {
|
// if (childrenJournals != null) {
|
||||||
for (int j = 0; j < childrenJournals.size(); j++) {
|
// for (int j = 0; j < childrenJournals.size(); j++) {
|
||||||
JSONObject childrenJournal = childrenJournals.getJSONObject(j);
|
// JSONObject childrenJournal = childrenJournals.getJSONObject(j);
|
||||||
setJournalCanDelete(cmsDoc, childrenJournal);
|
// setJournalCanDelete(cmsDoc, childrenJournal);
|
||||||
childrenJournals.set(j, childrenJournal);
|
// childrenJournals.set(j, childrenJournal);
|
||||||
}
|
// }
|
||||||
journal.put("children_journals", childrenJournals);
|
// journal.put("children_journals", childrenJournals);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
journalDataJson.put("journals", journals);
|
journalDataJson.put("journals", journals);
|
||||||
return journalDataJson;
|
return journalDataJson;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -177,11 +177,11 @@ public class CmsGitLinkRequestUrl extends GitLinkRequestUrl {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GitLinkRequestUrl GET_ISSUE(String username, String identifier, Long issueId) {
|
public static GitLinkRequestUrl GET_ISSUE(String username, String identifier, Long issueId) {
|
||||||
return getGitLinkRequestUrl(String.format("/api/v1/%s/%s/issues/%d", username, identifier, issueId));
|
return getOpenGitLinkRequestUrl(String.format("/api/v1/%s/%s/issues/%d", username, identifier, issueId));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GitLinkRequestUrl GET_JOURNALS(String username, String identifier, Long issueId, Integer page, Integer limit) {
|
public static GitLinkRequestUrl GET_JOURNALS(String username, String identifier, Long issueId, Integer page, Integer limit) {
|
||||||
return getGitLinkRequestUrl(String.format("/api/v1/%s/%s/issues/%d/journals?category=comment&page=%d&limit=%d", username, identifier, issueId, page, limit));
|
return getOpenGitLinkRequestUrl(String.format("/api/v1/%s/%s/issues/%d/journals?category=comment&page=%d&limit=%d", username, identifier, issueId, page, limit));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GitLinkRequestUrl DELETE_AND_UPDATE_JOURNAL(String username, String identifier, Long issueId, Long journalId) {
|
public static GitLinkRequestUrl DELETE_AND_UPDATE_JOURNAL(String username, String identifier, Long issueId, Long journalId) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue