Commit 3d62a020 authored by 刘基明's avatar 刘基明

接口调整

parent c4ed5301
......@@ -9,7 +9,7 @@ import java.time.LocalDateTime;
@Data
@ApiModel(value="TopicDTO对象", description="话题")
public class TopicDTO implements Serializable {
public class TopicDO implements Serializable {
private static final long serialVersionUID = 1L;
......
......@@ -2,8 +2,6 @@ package com.tanpu.community.api.beans.qo;
import io.swagger.annotations.ApiModelProperty;
import java.util.List;
public class TopicDetailQo {
@ApiModelProperty(value = "id")
......@@ -18,5 +16,4 @@ public class TopicDetailQo {
@ApiModelProperty(value = "讨论量")
private Integer disscussCount;
private List<ThemeQo> themes;
}
package com.tanpu.community.api.beans.req.theme;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class ThemeListByTopicReq {
@ApiModelProperty(value = "当前浏览的最后一个themeId")
private String lastId;
@ApiModelProperty(value = "页面大小")
private Integer PageSize;
@ApiModelProperty(value = "类型,1:最热 2:最新")
private Integer type;
@ApiModelProperty(value = "话题Id")
private String topicId;
}
......@@ -10,6 +10,8 @@ public class ThemeListReq {
private String lastId;
@ApiModelProperty(value = "页面大小")
private Integer PageSize;
@ApiModelProperty(value = "类型,1:推荐 2:关注")
private Integer type;
}
......@@ -2,7 +2,7 @@ package com.tanpu.community.controller;
import com.tanpu.common.api.CommonResp;
import com.tanpu.common.auth.UserHolder;
import com.tanpu.community.api.beans.TopicDTO;
import com.tanpu.community.api.beans.TopicDO;
import com.tanpu.community.api.beans.TopicDataAnalysDTO;
import com.tanpu.community.api.beans.req.topic.TopicConcealReq;
import com.tanpu.community.api.beans.req.topic.TopicModifyMountReq;
......@@ -17,7 +17,7 @@ import org.springframework.web.bind.annotation.*;
@RestController
@Slf4j
@RequestMapping(value = "/api/admin")
@RequestMapping(value = "/api/admin/topic")
public class AdminController {
......@@ -27,7 +27,7 @@ public class AdminController {
@Autowired
private UserHolder userHolder;
@GetMapping(value="/insertTopic")
@GetMapping(value="/add")
@ApiOperation("新增话题")
@ResponseBody
public CommonResp<Void> addTopic(@RequestParam String topicTitle){
......@@ -37,17 +37,17 @@ public class AdminController {
}
@ApiOperation("单个话题详细数据")
@PostMapping("/topic/detailData")
@PostMapping("/detailData")
@ResponseBody
public CommonResp<TopicDTO> selectOne(@RequestParam String topicId) throws MissingServletRequestParameterException {
public CommonResp<TopicDO> selectOne(@RequestParam String topicId) throws MissingServletRequestParameterException {
if (StringUtils.isEmpty(topicId)){
throw new MissingServletRequestParameterException("topicId","String");
}
TopicDTO topicDTO=topicManager.getDetail(topicId);
return CommonResp.success(topicDTO);
TopicDO topicDO =topicManager.getDetail(topicId);
return CommonResp.success(topicDO);
}
@PostMapping(value = "/topic/setTop")
@PostMapping(value = "/setTop")
@ApiOperation("顶置/取消顶置话题")
@ResponseBody
public CommonResp<Void> setTopTopic(@RequestBody TopicTopReq req) throws MissingServletRequestParameterException {
......@@ -55,7 +55,7 @@ public class AdminController {
return CommonResp.success();
}
@PostMapping(value = "/topic/setConceal")
@PostMapping(value = "/setConceal")
@ApiOperation("隐藏/显示话题")
@ResponseBody
public CommonResp<Void> setConceal(@RequestBody TopicConcealReq req) throws MissingServletRequestParameterException {
......@@ -63,7 +63,7 @@ public class AdminController {
return CommonResp.success();
}
@PostMapping(value = "/topic/modifyViewNum")
@PostMapping(value = "/modifyViewNum")
@ApiOperation("话题浏览数调整(后台管理)")
@ResponseBody
public CommonResp<Void> modifyViewNum(@RequestBody TopicModifyMountReq req) throws MissingServletRequestParameterException {
......@@ -71,7 +71,7 @@ public class AdminController {
return CommonResp.success();
}
@PostMapping(value = "/topic/dataAnalyse")
@PostMapping(value = "/dataAnalyse")
@ApiOperation("话题数据分析")
@ResponseBody
public CommonResp<TopicDataAnalysDTO> dataAnalyse(@RequestParam String topicId) throws MissingServletRequestParameterException {
......
......@@ -42,7 +42,7 @@ public class CommentController {
@ApiOperation("点赞评论")
@PostMapping(value = "/likeComment")
@ResponseBody
public CommonResp likeComment(@RequestParam String themeId){
public CommonResp<Void> likeComment(@RequestParam String commentId){
//todo
String userId = "liujm";
return CommonResp.success();
......@@ -51,7 +51,7 @@ public class CommentController {
@ApiOperation("举报评论")
@PostMapping(value = "/reportComment")
@ResponseBody
public CommonResp reportComment(@RequestParam String themeId){
public CommonResp<Void> reportComment(@RequestParam String commentId){
//todo
String userId = "liujm";
return CommonResp.success();
......
......@@ -6,6 +6,7 @@ import com.tanpu.community.api.beans.ForwardThemeReq;
import com.tanpu.community.api.beans.qo.MainTextQo;
import com.tanpu.community.api.beans.qo.ThemeQo;
import com.tanpu.community.api.beans.req.CreateThemeReq;
import com.tanpu.community.api.beans.req.theme.ThemeListByTopicReq;
import com.tanpu.community.api.beans.req.theme.ThemeListReq;
import com.tanpu.community.manager.ThemeManager;
import com.tanpu.community.service.FollowRelService;
......@@ -37,20 +38,28 @@ public class ThemeController {
return CommonResp.success();
}
@ApiOperation("圈子首页-推荐")
@GetMapping (value = "/recommendList")
@ApiOperation("圈子首页-推荐/关注")
@GetMapping(value = "/list")
@ResponseBody
public List<ThemeQo> selectHotList(ThemeListReq req) {
public List<ThemeQo> selectInterestList(@RequestBody ThemeListReq req) {
String userId = "liujm";
return themeManager.selectHotThemes(req,userId);
if (req.getType()==1){
return themeManager.selectHotThemes(req,userId);
}else {
return themeManager.selectInterestThemes(req,userId);
}
}
@ApiOperation("圈子首页-关注")
@GetMapping(value = "/followList")
@ApiOperation("话题详情页-最新/最热")
@GetMapping(value = "/listByTopic")
@ResponseBody
public List<ThemeQo> selectInterestList(ThemeListReq req) {
String userId = "liujm012";
return themeManager.selectInterestThemes(req,userId);
public CommonResp<List<ThemeQo>> getThemeMainText(@RequestBody ThemeListByTopicReq req) {
String userId = "liujm";
List<ThemeQo> result= themeManager.queryByTopic(req,userId);
return CommonResp.success(result);
}
......
......@@ -2,18 +2,16 @@ package com.tanpu.community.controller;
import com.tanpu.common.api.CommonResp;
import com.tanpu.common.auth.UserHolder;
import com.tanpu.community.api.beans.qo.ThemeQo;
import com.tanpu.community.api.beans.qo.TopicDetailQo;
import com.tanpu.community.api.beans.qo.TopicTitileQo;
import com.tanpu.community.api.beans.req.topic.TopicSearchReq;
import com.tanpu.community.api.beans.req.page.Page;
import com.tanpu.community.api.beans.req.topic.TopicSearchReq;
import com.tanpu.community.manager.TopicManager;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@Slf4j
@RequestMapping(value = "/api/topic")
......@@ -34,23 +32,15 @@ public class TopicController {
return CommonResp.success(allTopic);
}
@GetMapping(value = "/hotThemes")
@ApiOperation("话题详情页")
@GetMapping(value = "/detailPage")
@ApiOperation("话题详情页顶部")
@ResponseBody
public CommonResp<List<ThemeQo>> gethotThemes(@RequestParam String topicId){
public CommonResp<TopicDetailQo> gethotThemes(@RequestParam String topicId){
//todo
return CommonResp.success();
}
@GetMapping(value = "/latestThemes")
@ApiOperation("话题详情页")
@ResponseBody
public CommonResp<List<ThemeQo>> getlatestThemes(@RequestParam String topicId){
//todo
return CommonResp.success();
}
......
......@@ -7,6 +7,7 @@ import com.tanpu.community.api.beans.qo.AttachmentQo;
import com.tanpu.community.api.beans.qo.MainTextQo;
import com.tanpu.community.api.beans.qo.ThemeQo;
import com.tanpu.community.api.beans.req.CreateThemeReq;
import com.tanpu.community.api.beans.req.theme.ThemeListByTopicReq;
import com.tanpu.community.api.beans.req.theme.ThemeListReq;
import com.tanpu.community.api.enums.BlockTypeEnum;
import com.tanpu.community.api.enums.CollectionTypeEnum;
......@@ -322,4 +323,8 @@ public class ThemeManager {
return start.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
}
public List<ThemeQo> queryByTopic(ThemeListByTopicReq req, String userId) {
//TODO
return null;
}
}
package com.tanpu.community.manager;
import com.tanpu.common.exception.BizException;
import com.tanpu.community.api.beans.TopicDTO;
import com.tanpu.community.api.beans.TopicDO;
import com.tanpu.community.api.beans.TopicDataAnalysDTO;
import com.tanpu.community.api.beans.qo.TopicTitileQo;
import com.tanpu.community.api.beans.req.topic.TopicSearchReq;
......@@ -49,7 +49,7 @@ public class TopicManager {
}
//话题详情列表
public List<TopicDTO> getAllTopicDetail() {
public List<TopicDO> getAllTopicDetail() {
return ConvertUtil.topicEntitiesToDTOs(topicService.queryAll());
}
......@@ -93,16 +93,16 @@ public class TopicManager {
}
}
public TopicDTO getDetail(String topicId) {
public TopicDO getDetail(String topicId) {
TopicEntity topicEntity = topicService.queryById(topicId);
if (topicEntity == null) {
throw new BizException("找不到话题,id:" + topicId);
}
TopicDTO topicDTO = ConvertUtil.topicEntityToDTO(topicEntity);
topicDTO.setViewCount(redisService.getInteger(RedisKeyConstant.TOPIC_TOTAL_VIEW_COUNT_ + topicId));
topicDTO.setLikeCount(redisService.getInteger(RedisKeyConstant.TOPIC_LIKE_COUNT_ + topicId));
topicDTO.setUserCount(redisService.getInteger(RedisKeyConstant.TOPIC_USER_COUNT_ + topicId));
return topicDTO;
TopicDO topicDO = ConvertUtil.topicEntityToDTO(topicEntity);
topicDO.setViewCount(redisService.getInteger(RedisKeyConstant.TOPIC_TOTAL_VIEW_COUNT_ + topicId));
topicDO.setLikeCount(redisService.getInteger(RedisKeyConstant.TOPIC_LIKE_COUNT_ + topicId));
topicDO.setUserCount(redisService.getInteger(RedisKeyConstant.TOPIC_USER_COUNT_ + topicId));
return topicDO;
}
public void modifyViewCount(String topicId, Long modifyMount) {
......
package com.tanpu.community.util;
import com.tanpu.community.api.beans.qo.TopicTitileQo;
import com.tanpu.community.api.beans.TopicDTO;
import com.tanpu.community.api.beans.TopicDO;
import com.tanpu.community.api.beans.qo.CommentLv2Qo;
import com.tanpu.community.api.beans.qo.CommentQo;
import com.tanpu.community.api.beans.qo.FollowQo;
......@@ -41,10 +41,10 @@ public class ConvertUtil {
}
public static TopicDTO topicEntityToDTO(TopicEntity topicEntity) {
TopicDTO topicDTO = new TopicDTO();
BeanUtils.copyProperties(topicEntity, topicDTO);
return topicDTO;
public static TopicDO topicEntityToDTO(TopicEntity topicEntity) {
TopicDO topicDO = new TopicDO();
BeanUtils.copyProperties(topicEntity, topicDO);
return topicDO;
}
public static TopicTitileQo topicToBriefInfoDTO(TopicEntity topicEntity) {
......@@ -72,7 +72,7 @@ public class ConvertUtil {
return entities.stream().map(ConvertUtil::commentLv2Entity2Qo).collect(Collectors.toList());
}
public static List<TopicDTO> topicEntitiesToDTOs(List<TopicEntity> topicEntities) {
public static List<TopicDO> topicEntitiesToDTOs(List<TopicEntity> topicEntities) {
return topicEntities.stream().map(ConvertUtil::topicEntityToDTO).collect(Collectors.toList());
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment