diff --git a/community-api/src/main/java/com/tanpu/community/api/beans/qo/MainTextQo.java b/community-api/src/main/java/com/tanpu/community/api/beans/qo/MainTextQo.java index 4e69eb16429cee518857d762bb0a5caea04e2b37..3309ff65201f01a5df5f2a6676712be94bceb1b7 100644 --- a/community-api/src/main/java/com/tanpu/community/api/beans/qo/MainTextQo.java +++ b/community-api/src/main/java/com/tanpu/community/api/beans/qo/MainTextQo.java @@ -5,7 +5,7 @@ import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; -import java.util.List; +import java.time.LocalDateTime; /** * æ£æ–‡ @@ -60,8 +60,11 @@ public class MainTextQo { @ApiModelProperty(value = "点赞é‡") private Integer likeCount; - @ApiModelProperty("附件,") - private List<AttachmentQo> attachment; + + + private LocalDateTime createTime; + + private LocalDateTime updateTime; } diff --git a/community-api/src/main/java/com/tanpu/community/api/beans/qo/ThemeQo.java b/community-api/src/main/java/com/tanpu/community/api/beans/qo/ThemeQo.java index 69d1952c512773a0485f1825c6715dd6b8236c52..c7017bc77720e053c29952e3c7bab7ded8ced832 100644 --- a/community-api/src/main/java/com/tanpu/community/api/beans/qo/ThemeQo.java +++ b/community-api/src/main/java/com/tanpu/community/api/beans/qo/ThemeQo.java @@ -64,4 +64,9 @@ public class ThemeQo { @ApiModelProperty(value = "转å‘的主题") private ThemeFormerQo formerTheme; + + private LocalDateTime createTime; + + private LocalDateTime updateTime; + } diff --git a/community-api/src/main/java/com/tanpu/community/api/beans/qo/TopicDetailQo.java b/community-api/src/main/java/com/tanpu/community/api/beans/qo/TopicDetailQo.java index 54f4715e260affb13cc77d28741a8e59b7542c77..be2e5643fedc60ba3397de47b76edd8416b860cd 100644 --- a/community-api/src/main/java/com/tanpu/community/api/beans/qo/TopicDetailQo.java +++ b/community-api/src/main/java/com/tanpu/community/api/beans/qo/TopicDetailQo.java @@ -2,9 +2,15 @@ package com.tanpu.community.api.beans.qo; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Data; +import lombok.NoArgsConstructor; @Data +@Builder +@AllArgsConstructor +@NoArgsConstructor @ApiModel("è¯é¢˜è¯¦æƒ…对象") public class TopicDetailQo { @@ -20,6 +26,4 @@ public class TopicDetailQo { @ApiModelProperty(value = "讨论é‡") private Integer disscussCount; - @ApiModelProperty(value = "类型 1ï¼šçƒ 2:新") - private Integer type; } diff --git a/community-api/src/main/java/com/tanpu/community/api/beans/qo/TopicTitileQo.java b/community-api/src/main/java/com/tanpu/community/api/beans/qo/TopicTitileQo.java index ffd97837945dc0364b95f3fff23f31d28cd22277..03ecf01ce5ab41a1ec0a68e849e1b7bf12582ac6 100644 --- a/community-api/src/main/java/com/tanpu/community/api/beans/qo/TopicTitileQo.java +++ b/community-api/src/main/java/com/tanpu/community/api/beans/qo/TopicTitileQo.java @@ -15,7 +15,7 @@ public class TopicTitileQo { private String topicId; @ApiModelProperty("è¯é¢˜åç§°") - private String title; + private String topicTitle; @ApiModelProperty("讨论数") private Integer discussionCount; diff --git a/community-api/src/main/java/com/tanpu/community/api/beans/req/theme/ThemeListReq.java b/community-api/src/main/java/com/tanpu/community/api/beans/req/theme/ThemeListReq.java index da45e744559096c3ae7110fd57b57bbe140b0620..44ab09153c02775839d7e02d2c2463bb8b0601f0 100644 --- a/community-api/src/main/java/com/tanpu/community/api/beans/req/theme/ThemeListReq.java +++ b/community-api/src/main/java/com/tanpu/community/api/beans/req/theme/ThemeListReq.java @@ -4,18 +4,18 @@ package com.tanpu.community.api.beans.req.theme; import io.swagger.annotations.ApiModelProperty; import lombok.Data; -import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; @Data public class ThemeListReq { @ApiModelProperty(value = "当剿µè§ˆçš„æœ€åŽä¸€ä¸ªthemeId,å¯ä»¥ä¸ºç©º") private String lastId; - @NotEmpty(message = "PageSizeä¸èƒ½ä¸ºç©º") + @NotNull(message = "PageSizeä¸èƒ½ä¸ºç©º") @ApiModelProperty(value = "页é¢å¤§å°") - private Integer PageSize; + private Integer pageSize; - @NotEmpty(message = "主题类型ä¸èƒ½ä¸ºç©º") + @NotNull(message = "主题类型ä¸èƒ½ä¸ºç©º") @ApiModelProperty(value = "类型,1:推è 2:关注") private Integer type; diff --git a/community-api/src/main/java/com/tanpu/community/api/enums/ThemeListTypeEnum.java b/community-api/src/main/java/com/tanpu/community/api/enums/ThemeListTypeEnum.java new file mode 100644 index 0000000000000000000000000000000000000000..080b22b410a4ca140ee0a90c44e4e814262c4bd4 --- /dev/null +++ b/community-api/src/main/java/com/tanpu/community/api/enums/ThemeListTypeEnum.java @@ -0,0 +1,32 @@ +package com.tanpu.community.api.enums; + +public enum ThemeListTypeEnum { + + + RECOMMEND(1,"推è列表"), + FOLLOW(2,"关注列表"); + + private Integer code; + private String type; + + ThemeListTypeEnum(Integer code, String type) { + this.code = code; + this.type = type; + } + + public Integer getCode() { + return code; + } + + public void setCode(Integer code) { + this.code = code; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } +} diff --git a/community-service/src/main/java/com/tanpu/community/controller/AdminController.java b/community-service/src/main/java/com/tanpu/community/controller/AdminController.java index abf7eebd9c6c1b99a0e1e0cfbc86edf3bde9cd69..77c7a9564fa0a5436e1f5ae32ac7674864dd2fcf 100644 --- a/community-service/src/main/java/com/tanpu/community/controller/AdminController.java +++ b/community-service/src/main/java/com/tanpu/community/controller/AdminController.java @@ -2,15 +2,11 @@ package com.tanpu.community.controller; import com.tanpu.common.api.CommonResp; import com.tanpu.common.auth.UserHolder; -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; import com.tanpu.community.api.beans.req.topic.TopicTopReq; import com.tanpu.community.manager.TopicManager; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.MissingServletRequestParameterException; import org.springframework.web.bind.annotation.*; @@ -35,17 +31,17 @@ public class AdminController { topicManager.insertTopic(topicTitle,userId); return CommonResp.success(); } - - @ApiOperation("å•个è¯é¢˜è¯¦ç»†æ•°æ®") - @GetMapping("/detailData") - @ResponseBody - public CommonResp<TopicDO> selectOne(@RequestParam String topicId) throws MissingServletRequestParameterException { - if (StringUtils.isEmpty(topicId)){ - throw new MissingServletRequestParameterException("topicId","String"); - } - TopicDO topicDO =topicManager.getDetail(topicId); - return CommonResp.success(topicDO); - } +// +// @ApiOperation("å•个è¯é¢˜è¯¦ç»†æ•°æ®") +// @GetMapping("/detailData") +// @ResponseBody +// public CommonResp<TopicDO> selectOne(@RequestParam String topicId) throws MissingServletRequestParameterException { +// if (StringUtils.isEmpty(topicId)){ +// throw new MissingServletRequestParameterException("topicId","String"); +// } +// TopicDO topicDO =topicManager.getDetail(topicId); +// return CommonResp.success(topicDO); +// } @PostMapping(value = "/setTop") @ApiOperation("é¡¶ç½®/å–æ¶ˆé¡¶ç½®è¯é¢˜") @@ -62,20 +58,20 @@ public class AdminController { topicManager.setTopicConceal(req.getTopicId(),req.isConceal()); return CommonResp.success(); } - - @PostMapping(value = "/modifyViewNum") - @ApiOperation("è¯é¢˜æµè§ˆæ•°è°ƒæ•´ï¼ˆåŽå°ç®¡ç†ï¼‰") - @ResponseBody - public CommonResp<Void> modifyViewNum(@RequestBody TopicModifyMountReq req) throws MissingServletRequestParameterException { - topicManager.modifyViewCount(req.getTopicId(),req.getModifyMount()); - return CommonResp.success(); - } - - @GetMapping(value = "/dataAnalyse") - @ApiOperation("è¯é¢˜æ•°æ®åˆ†æž") - @ResponseBody - public CommonResp<TopicDataAnalysDTO> dataAnalyse(@RequestParam String topicId) throws MissingServletRequestParameterException { - TopicDataAnalysDTO result =topicManager.queryDataAnalysis(topicId); - return CommonResp.success(result); - } +// +// @PostMapping(value = "/modifyViewNum") +// @ApiOperation("è¯é¢˜æµè§ˆæ•°è°ƒæ•´ï¼ˆåŽå°ç®¡ç†ï¼‰") +// @ResponseBody +// public CommonResp<Void> modifyViewNum(@RequestBody TopicModifyMountReq req) throws MissingServletRequestParameterException { +// topicManager.modifyViewCount(req.getTopicId(),req.getModifyMount()); +// return CommonResp.success(); +// } +// +// @GetMapping(value = "/dataAnalyse") +// @ApiOperation("è¯é¢˜æ•°æ®åˆ†æž") +// @ResponseBody +// public CommonResp<TopicDataAnalysDTO> dataAnalyse(@RequestParam String topicId) throws MissingServletRequestParameterException { +// TopicDataAnalysDTO result =topicManager.queryDataAnalysis(topicId); +// return CommonResp.success(result); +// } } diff --git a/community-service/src/main/java/com/tanpu/community/controller/ThemeController.java b/community-service/src/main/java/com/tanpu/community/controller/ThemeController.java index 1a5d8da655a4ff283c92f6029f71e1a15b26392f..92527a84d77f6cb1bab9489c92b781376e29a72b 100644 --- a/community-service/src/main/java/com/tanpu/community/controller/ThemeController.java +++ b/community-service/src/main/java/com/tanpu/community/controller/ThemeController.java @@ -40,10 +40,9 @@ public class ThemeController { @ApiOperation("圈å首页-推è/关注") @PostMapping(value = "/list") @ResponseBody - public CommonResp<List<ThemeQo>> selectInterestList(@RequestBody ThemeListReq req) { + public CommonResp<List<ThemeQo>> selectInterestList(@Validated @RequestBody ThemeListReq req) { String userId = "liujm"; - List<ThemeQo> result= req.getType()==1?themeManager.selectHotThemes(req,userId) - :themeManager.selectInterestThemes(req,userId); + List<ThemeQo> result= themeManager.queryThemeList(req,userId); return CommonResp.success(result); } diff --git a/community-service/src/main/java/com/tanpu/community/controller/TopicController.java b/community-service/src/main/java/com/tanpu/community/controller/TopicController.java index df7f3a288faddd77f0c83b78b6e6dcbeecae25d3..d5d979f082049b647ef320c6172ced03b3282c49 100644 --- a/community-service/src/main/java/com/tanpu/community/controller/TopicController.java +++ b/community-service/src/main/java/com/tanpu/community/controller/TopicController.java @@ -30,7 +30,7 @@ public class TopicController { @PostMapping(value = "/list") @ApiOperation("APP全部è¯é¢˜é¡µé¢ï¼Œå¯æœç´¢") @ResponseBody - public CommonResp<Page<TopicTitileQo>> getTopicBriefInfoList(TopicSearchReq req){ + public CommonResp<Page<TopicTitileQo>> getTopicBriefInfoList(@RequestBody TopicSearchReq req){ Page<TopicTitileQo> allTopic = topicManager.getAllTopicBriefInfo(req); return CommonResp.success(allTopic); } @@ -40,8 +40,8 @@ public class TopicController { @ResponseBody public CommonResp<TopicDetailQo> gethotThemes(@RequestParam String topicId){ //todo - return CommonResp.success(); - + TopicDetailQo detail = topicManager.getDetail(topicId); + return CommonResp.success(detail); } @@ -49,8 +49,7 @@ public class TopicController { @ApiOperation("首页顶部è¯é¢˜æ ‡é¢˜åˆ—") @ResponseBody public CommonResp<List<TopicHotQo>> getTitleList(){ - //todo - return CommonResp.success(); + return CommonResp.success(topicManager.getHotTopicTitles()); } diff --git a/community-service/src/main/java/com/tanpu/community/manager/ThemeManager.java b/community-service/src/main/java/com/tanpu/community/manager/ThemeManager.java index a49ac9761f9c0aced4ba5617e4713cf7d5dbedd4..62d45089a58eb98572e4388208afffd63f0e3b76 100644 --- a/community-service/src/main/java/com/tanpu/community/manager/ThemeManager.java +++ b/community-service/src/main/java/com/tanpu/community/manager/ThemeManager.java @@ -11,6 +11,7 @@ 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; +import com.tanpu.community.api.enums.ThemeListTypeEnum; import com.tanpu.community.api.enums.ThemeTypeEnum; import com.tanpu.community.dao.entity.community.BlackListEntity; import com.tanpu.community.dao.entity.community.HomePageEntity; @@ -89,7 +90,6 @@ public class ThemeManager { private FeignClientForCourse feignClientForCourse; - public void publishTheme(CreateThemeReq req, String userId) { ThemeEntity themeEntity = new ThemeEntity(); BeanUtils.copyProperties(req, themeEntity); @@ -103,25 +103,22 @@ public class ThemeManager { } // 返回推èä¸»é¢˜æ–‡ç« - public List<ThemeQo> selectHotThemes(ThemeListReq req, String userId) { - // TODO:推è - List<ThemeEntity> themeEntities = themeService.selectAll(req.getLastId(),req.getPageSize()); + public List<ThemeQo> queryThemeList(ThemeListReq req, String userId) { + List<ThemeEntity> themeEntities; + if (ThemeListTypeEnum.RECOMMEND.getCode().equals(req.getType())) { + // TODO:推è + themeEntities = themeService.selectAll(req.getLastId(), req.getPageSize()); + } else { + List<String> fansList = followRelService.queryFansByFollowerId(userId); + themeEntities = themeService.queryByFans(fansList, req.getLastId(), req.getPageSize()); + } List<ThemeQo> themeQos = convertEntityToQo(themeEntities, userId); return themeQos; } - // 返回关注主题 - public List<ThemeQo> selectInterestThemes(ThemeListReq req,String userId) { - List<String> fansList = followRelService.queryFansByFollowerId(userId); - List<ThemeEntity> themeEntities = themeService.queryByFans(fansList,req.getLastId(),req.getPageSize()); - List<ThemeQo> themeQos = convertEntityToQo(themeEntities, userId); - return themeQos; - } - public List<ThemeQo> queryByTopic(ThemeListByTopicReq req, String userId) { - //TODO - List<ThemeEntity> themeEntities = themeService.queryByTopic(req.getTopicId(),req.getLastId(),req.getPageSize()); + List<ThemeEntity> themeEntities = themeService.queryByTopic(req.getTopicId(), req.getLastId(), req.getPageSize()); List<ThemeQo> themeQos = convertEntityToQo(themeEntities, userId); return themeQos; } @@ -129,13 +126,13 @@ public class ThemeManager { //è¿”å›žæ£æ–‡ public MainTextQo getMainText(String themeId, String userId) { - ThemeEntity themeEntity = themeService.queryById(themeId); + ThemeEntity themeEntity = themeService.queryByThemeId(themeId); if (themeEntity == null) { throw new BizException("找ä¸åˆ°å¸–åid:" + themeId); } MainTextQo mainTextQo = new MainTextQo(); BeanUtils.copyProperties(themeEntity, mainTextQo); - buildMainTestExtraInfo(mainTextQo, userId); + buildMainTestExtraInfo(mainTextQo, userId); return mainTextQo; } @@ -148,10 +145,9 @@ public class ThemeManager { } - //è½¬å‘ public void forward(ForwardThemeReq req, String userId) { - ThemeEntity targetTheme = themeService.queryById(req.getFormerThemeId()); + ThemeEntity targetTheme = themeService.queryByThemeId(req.getFormerThemeId()); ThemeEntity newTheme = ThemeEntity.builder() .content(req.getContent()) .topicId(req.getTopicId()) @@ -194,9 +190,9 @@ public class ThemeManager { // å±è”½(主题) public void blockTheme(String themeId, String userId) { blackListService.addBlock(themeId, userId, BlockTypeEnum.THEME); - BlackListEntity selectOne = blackListService.selectOne(themeService.queryById(themeId).getAuthorId(), userId, BlockTypeEnum.USER.getCode()); + BlackListEntity selectOne = blackListService.selectOne(themeService.queryByThemeId(themeId).getAuthorId(), userId, BlockTypeEnum.USER.getCode()); if (selectOne == null) { - blackListService.addBlock(themeService.queryById(themeId).getAuthorId(), userId, BlockTypeEnum.USER); + blackListService.addBlock(themeService.queryByThemeId(themeId).getAuthorId(), userId, BlockTypeEnum.USER); } } @@ -253,9 +249,8 @@ public class ThemeManager { List<AttachmentQo> attachmentQos = new ArrayList<>(); attachments.forEach(o -> attachmentQos.add(AttachmentQo.builder() .type(o.getAttachType()) - .attachment(transferAttachment(o,userId)) + .attachment(transferAttachment(o, userId)) .build())); - maintTextQo.setAttachment(attachmentQos); } //迄今时间 maintTextQo.setUpToNowTime(calUpToNowTime(maintTextQo.getCreateTime())); diff --git a/community-service/src/main/java/com/tanpu/community/manager/TopicManager.java b/community-service/src/main/java/com/tanpu/community/manager/TopicManager.java index ba7e29a18716dcd98806aff1cbecd80f0c39fb1d..3552b5e8c094a2b815647309a1f521d5833b0745 100644 --- a/community-service/src/main/java/com/tanpu/community/manager/TopicManager.java +++ b/community-service/src/main/java/com/tanpu/community/manager/TopicManager.java @@ -3,23 +3,24 @@ package com.tanpu.community.manager; import com.tanpu.common.exception.BizException; import com.tanpu.community.api.beans.TopicDO; import com.tanpu.community.api.beans.TopicDataAnalysDTO; +import com.tanpu.community.api.beans.qo.TopicDetailQo; +import com.tanpu.community.api.beans.qo.TopicHotQo; 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.api.constants.RedisKeyConstant; import com.tanpu.community.api.enums.CollectionTypeEnum; -import com.tanpu.community.dao.entity.community.ThemeEntity; import com.tanpu.community.dao.entity.community.TopicEntity; import com.tanpu.community.service.*; import com.tanpu.community.util.ConvertUtil; import com.tanpu.community.util.PageUtils; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.HashSet; import java.util.List; import java.util.Set; -import java.util.stream.Collectors; @Service public class TopicManager { @@ -58,16 +59,43 @@ public class TopicManager { public Page<TopicTitileQo> getAllTopicBriefInfo(TopicSearchReq req) { List<TopicEntity> allTopic = topicService.queryByKeyword(req.getSearchKeyword()); List<TopicTitileQo> topicTitileQos = ConvertUtil.topicEntitiesToBriefDTOs(allTopic); - //讨论数=å‘布主题贴数+å›žå¤æ€»æ•° + for (TopicTitileQo topicQo : topicTitileQos) { + //TODO 讨论数=å‘布主题贴数+å›žå¤æ€»æ•° // Integer commentCountByThemeIds = commentService.getCommentCountByThemeIds(themeIds); - topicQo.setDiscussionCount(0); } - + //TODO 判æ–é¡¶ç½® return PageUtils.page(req.getPage(),topicTitileQos); } + public TopicDetailQo getDetail(String topicId) { + TopicEntity topicEntity = topicService.queryById(topicId); + if (topicEntity == null) { + throw new BizException("找ä¸åˆ°è¯é¢˜ï¼Œid:" + topicId); + } + TopicDetailQo topicDetailQo = new TopicDetailQo(); + BeanUtils.copyProperties(topicEntity,topicDetailQo); + List<String> themeIds = themeService.queryThemeIdsByTopic(topicId); + Integer likeCountByThemeIds = collectionService.getCountByTypeAndIds(themeIds, CollectionTypeEnum.LIKE_THEME); + Integer bookCountByThemeIds = collectionService.getCountByTypeAndIds(themeIds, CollectionTypeEnum.BOOK_THEME); + + //TODO æµè§ˆé‡ + topicDetailQo.setViewCount(0); + //讨论数=å‘布主题贴数+å›žå¤æ€»æ•° + Integer commentCount = commentService.getCommentCountByThemeIds(themeIds); + topicDetailQo.setDisscussCount(themeIds.size()+commentCount); + return topicDetailQo; + } + + + public List<TopicHotQo> getHotTopicTitles(){ + List<TopicEntity> topicEntities = topicService.queryAll(); + List<TopicHotQo> topicHotQos = ConvertUtil.topicEntityToHotQos(topicEntities); + //TODO æ·»åŠ ç±»åž‹:çƒ æ–° é¡¶ + return topicHotQos; + + } public void setTopTopic(String topicId, boolean setTop) { TopicEntity topicEntity = topicService.queryById(topicId); @@ -93,17 +121,7 @@ public class TopicManager { } } - public TopicDO getDetail(String topicId) { - TopicEntity topicEntity = topicService.queryById(topicId); - if (topicEntity == null) { - throw new BizException("找ä¸åˆ°è¯é¢˜ï¼Œid:" + topicId); - } - 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) { TopicEntity topicEntity = topicService.queryById(topicId); @@ -125,8 +143,7 @@ public class TopicManager { for (TopicEntity topic : topicEntities) { String topicId = topic.getTopicId(); Long viewCountModify = topic.getviewCntAdjust(); - List<ThemeEntity> themeEntities = themeService.queryByTopic(topicId,null,null); - List<String> themeIds = themeEntities.stream().map(ThemeEntity::getThemeId).collect(Collectors.toList()); + List<String> themeIds = themeService.queryThemeIdsByTopic(topicId); Integer likeCountByThemeIds = collectionService.getCountByTypeAndIds(themeIds, CollectionTypeEnum.LIKE_THEME); Integer bookCountByThemeIds = collectionService.getCountByTypeAndIds(themeIds, CollectionTypeEnum.BOOK_THEME); Long commentCountByThemeIds = (long)commentService.getCommentCountByThemeIds(themeIds); diff --git a/community-service/src/main/java/com/tanpu/community/service/CollectionService.java b/community-service/src/main/java/com/tanpu/community/service/CollectionService.java index c8a556ca61ff7f30433572e3d5a519da45135157..3c7f451dbd9db1078f93b255be0739a189bb67be 100644 --- a/community-service/src/main/java/com/tanpu/community/service/CollectionService.java +++ b/community-service/src/main/java/com/tanpu/community/service/CollectionService.java @@ -68,8 +68,7 @@ public class CollectionService { } - - // 统计å•ä¸ªä¸»é¢˜çš„æ•°é‡ + // 统计å•个对象(主题ã€è¯„论)的数é‡ï¼ˆç‚¹èµžã€æ”¶è—) public Integer getCountByTypeAndId(String targetId, CollectionTypeEnum type) { return collectionMapper.selectCount((new LambdaQueryWrapper<CollectionEntity>() .eq(CollectionEntity::getTargetId, targetId) @@ -77,10 +76,10 @@ public class CollectionService { .eq(CollectionEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED.getCode()))); } - // ç»Ÿè®¡å¤šä¸ªä¸»é¢˜çš„ç‚¹èµžé‡ - public Integer getCountByTypeAndIds(List<String> themeIds, CollectionTypeEnum type) { + // 统计多个对象(主题ã€è¯„论)的数é‡ï¼ˆç‚¹èµžã€æ”¶è—) + public Integer getCountByTypeAndIds(List<String> targetIds, CollectionTypeEnum type) { return collectionMapper.selectCount((new LambdaQueryWrapper<CollectionEntity>() - .in(CollectionEntity::getTargetId, themeIds) + .in(CollectionEntity::getTargetId, targetIds) .eq(CollectionEntity::getCollectionType, type.getCode())) .eq(CollectionEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED.getCode())); } diff --git a/community-service/src/main/java/com/tanpu/community/service/ThemeService.java b/community-service/src/main/java/com/tanpu/community/service/ThemeService.java index 5e1da0877060337d813f3e8e222785551e84f234..da497b5640ae90efba214c793300e6a671c7c682 100644 --- a/community-service/src/main/java/com/tanpu/community/service/ThemeService.java +++ b/community-service/src/main/java/com/tanpu/community/service/ThemeService.java @@ -30,27 +30,40 @@ public class ThemeService { } //æ ¹æ®id返回主题详情 - public ThemeEntity queryById(String themeId) { - return themeMapper.selectById(themeId); + public ThemeEntity queryByThemeId(String themeId) { + return themeMapper.selectOne(new LambdaQueryWrapper<ThemeEntity>().eq(ThemeEntity::getThemeId,themeId)); } - //æ ¹æ®è¯é¢˜æŸ¥è¯¢ä¸»é¢˜ + /** + * æ ¹æ®æ¡ä»¶æŸ¥è¯¢ä¸»é¢˜ + * @param topidId è¯é¢˜Id + * @param lastId 查询æ¤ä¸»é¢˜Id之å‰çš„主题 + * @param pageSize æŸ¥è¯¢æ•°é‡ + * @return + */ public List<ThemeEntity> queryByTopic(String topidId, String lastId,Integer pageSize) { LambdaQueryWrapper<ThemeEntity> queryWrapper = new LambdaQueryWrapper<ThemeEntity>() .eq(ThemeEntity::getTopicId, topidId); if (StringUtils.isNotEmpty(lastId)) { - ThemeEntity lastEntity = queryById(lastId); + ThemeEntity lastEntity = queryByThemeId(lastId); if (lastEntity==null) throw new BizException("主题未找到,id:"+lastId); queryWrapper.lt(ThemeEntity::getUpdateTime, lastEntity.getUpdateTime()); } if (pageSize!=null){ queryWrapper.last("limit "+pageSize); - } return themeMapper.selectList(queryWrapper); } + //æ ¹æ®è¯é¢˜æŸ¥è¯¢æ‰€æœ‰çš„主题Id + public List<String> queryThemeIdsByTopic(String topidId) { + LambdaQueryWrapper<ThemeEntity> queryWrapper = new LambdaQueryWrapper<ThemeEntity>() + .eq(ThemeEntity::getTopicId, topidId); + queryWrapper.select(ThemeEntity::getThemeId); + return themeMapper.selectList(queryWrapper).stream().map(ThemeEntity::getThemeId).collect(Collectors.toList()); + } + //关注的主题列表 public List<ThemeEntity> queryByFans(List<String> fansList, String lastId,Integer pageSize) { @@ -58,7 +71,7 @@ public class ThemeService { .in(ThemeEntity::getAuthorId, fansList) .orderByDesc(ThemeEntity::getUpdateTime); if (StringUtils.isNotEmpty(lastId)) { - ThemeEntity lastEntity = queryById(lastId); + ThemeEntity lastEntity = queryByThemeId(lastId); if (lastEntity==null) throw new BizException("主题未找到,id:"+lastId); queryWrapper.lt(ThemeEntity::getUpdateTime, lastEntity.getUpdateTime()); } @@ -73,7 +86,7 @@ public class ThemeService { LambdaQueryWrapper<ThemeEntity> queryWrapper = new LambdaQueryWrapper<ThemeEntity>() .orderByDesc(ThemeEntity::getUpdateTime); if (StringUtils.isNotEmpty(lastId)) { - ThemeEntity lastEntity = queryById(lastId); + ThemeEntity lastEntity = queryByThemeId(lastId); if (lastEntity==null) throw new BizException("主题未找到,id:"+lastId); queryWrapper.lt(ThemeEntity::getUpdateTime, lastEntity.getUpdateTime()); } diff --git a/community-service/src/main/java/com/tanpu/community/service/TopicService.java b/community-service/src/main/java/com/tanpu/community/service/TopicService.java index 859a04e92eebc683efb211d7f291603a067de819..784f9a6d823ba5c0b331b9c2350e15b97dbc7750 100644 --- a/community-service/src/main/java/com/tanpu/community/service/TopicService.java +++ b/community-service/src/main/java/com/tanpu/community/service/TopicService.java @@ -78,7 +78,7 @@ public class TopicService { } public TopicEntity queryById(String topicId) { - return topicMapper.selectById(topicId); + return topicMapper.selectOne(new LambdaQueryWrapper<TopicEntity>().eq(TopicEntity::getTopicId,topicId)); } public void modifyViewCount(String topicId, long Count) { diff --git a/community-service/src/main/java/com/tanpu/community/util/ConvertUtil.java b/community-service/src/main/java/com/tanpu/community/util/ConvertUtil.java index 285ca2c110eb66a15fa339c2f8814b4f24851944..1cf3e7868ff0a9020afeb04bfaecf29f7f1c9b24 100644 --- a/community-service/src/main/java/com/tanpu/community/util/ConvertUtil.java +++ b/community-service/src/main/java/com/tanpu/community/util/ConvertUtil.java @@ -33,17 +33,22 @@ public class ConvertUtil { } - public static List<ThemeEntity> themeDTOSToEntitys(List<ThemeQo> themeQos) { - return themeQos.stream().map(ConvertUtil::themeDTOToEntity).collect(Collectors.toList()); - } - - public static TopicDO topicEntityToDTO(TopicEntity topicEntity) { TopicDO topicDO = new TopicDO(); BeanUtils.copyProperties(topicEntity, topicDO); return topicDO; } + public static TopicHotQo topicEntityToHotQo(TopicEntity topicEntity) { + TopicHotQo topicHotQo = new TopicHotQo(); + BeanUtils.copyProperties(topicEntity, topicHotQo); + return topicHotQo; + } + + public static List<TopicHotQo> topicEntityToHotQos(List<TopicEntity> topicEntities){ + return topicEntities.stream().map(ConvertUtil::topicEntityToHotQo).collect(Collectors.toList()); + } + public static TopicTitileQo topicToBriefInfoDTO(TopicEntity topicEntity) { TopicTitileQo topicTitileQo = new TopicTitileQo(); BeanUtils.copyProperties(topicEntity, topicTitileQo); diff --git a/community-service/src/main/java/com/tanpu/community/util/PageUtils.java b/community-service/src/main/java/com/tanpu/community/util/PageUtils.java index a234f410418d7a68e9a26bc7f37043fb4960e7f5..78e84469fa1a292c68f7201e21aba17b59f49345 100644 --- a/community-service/src/main/java/com/tanpu/community/util/PageUtils.java +++ b/community-service/src/main/java/com/tanpu/community/util/PageUtils.java @@ -32,7 +32,7 @@ public class PageUtils { int toIndex; // 防æ¢ç´¢å¼•越界 - if (Integer.getInteger("0").equals(pageable.getPageNumber())) { + if (Integer.valueOf(0).equals(pageable.getPageNumber())) { pageable.setPageNumber(1); } diff --git a/community-service/src/main/resources/application-dev.yml b/community-service/src/main/resources/application-dev.yml index 7925c9bd137c0706daccf1123ddd3bdd10bb42f5..1d1f343cb3dba843161c0fcac3756a21bc057612 100644 --- a/community-service/src/main/resources/application-dev.yml +++ b/community-service/src/main/resources/application-dev.yml @@ -1,5 +1,5 @@ -apollo.bootstrap.enabled: true +apollo.bootstrap.enabled: false #app.id: tanpu-community #apollo: