diff --git a/src/main/java/com/cm/news/controller/app/apis/newscomment/NewsCommentAppController.java b/src/main/java/com/cm/news/controller/app/apis/newscomment/NewsCommentAppController.java index ce054ad..224641a 100644 --- a/src/main/java/com/cm/news/controller/app/apis/newscomment/NewsCommentAppController.java +++ b/src/main/java/com/cm/news/controller/app/apis/newscomment/NewsCommentAppController.java @@ -16,12 +16,14 @@ import com.cm.common.token.app.AppTokenManager; import com.cm.common.token.app.entity.AppToken; import com.cm.common.utils.UUIDUtil; import com.cm.common.utils.WStringUtil; +import com.cm.news.pojo.dtos.newscomment.NewsCommentCountDTO; import com.cm.news.pojo.dtos.newscomment.NewsCommentDTO; import com.cm.news.pojo.util.AntistopUtil; import com.cm.news.pojo.vos.newscomment.NewsCommentVO; import com.cm.news.service.newscomment.INewsCommentService; import com.github.pagehelper.util.StringUtil; import io.swagger.annotations.*; +import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -29,6 +31,7 @@ import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; import javax.servlet.http.HttpServletRequest; +import java.util.Arrays; import java.util.List; import java.util.Map; @@ -47,6 +50,18 @@ public class NewsCommentAppController extends AbstractController { @Autowired private INewsCommentService newsCommentService; + @ApiOperation(value = "新闻的评论数", notes = "新闻的评论数接口") + @ApiImplicitParams({ + @ApiImplicitParam(name = "newsContentIds", value = "新闻ID集,多个用_隔开", paramType = "query") + }) + @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) + @GetMapping("getcountbynewscontentids" + ISystemConstant.APP_RELEASE_SUFFIX + "/{newsContentIds}") + public List getCountbyNewsContentIds(@PathVariable("newsContentIds") String newsContentIds) throws SearchException { + String[] newsContentIdArr = newsContentIds.split("_"); + List newsContentIdList = Arrays.asList(newsContentIdArr); + return newsCommentService.countCountByNewsContentIds(newsContentIdList); + } + private String getRemortIP() throws Exception { HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); String ip = ""; diff --git a/src/main/java/com/cm/news/controller/app/apis/newscontentcollect/NewsContentCollectAppController.java b/src/main/java/com/cm/news/controller/app/apis/newscontentcollect/NewsContentCollectAppController.java index 0afba76..85e413e 100644 --- a/src/main/java/com/cm/news/controller/app/apis/newscontentcollect/NewsContentCollectAppController.java +++ b/src/main/java/com/cm/news/controller/app/apis/newscontentcollect/NewsContentCollectAppController.java @@ -13,7 +13,9 @@ import com.cm.common.result.SuccessResultData; import com.cm.common.result.SuccessResultList; import com.cm.common.token.app.AppTokenManager; import com.cm.news.pojo.dtos.newscontent.NewsContentAppDTO; +import com.cm.news.pojo.dtos.newscontentcollect.NewsContentCollectCountDTO; import com.cm.news.pojo.dtos.newscontentcollect.NewsContentCollectDTO; +import com.cm.news.pojo.dtos.newscontentcollect.NewsContentCollectionCountDTO; import com.cm.news.pojo.vos.newscontentcollect.NewsContentCollectVO; import com.cm.news.service.newscontent.INewsContentService; import com.cm.news.service.newscontentcollect.INewsContentCollectService; @@ -44,6 +46,18 @@ public class NewsContentCollectAppController extends AbstractController { @Autowired protected SecurityComponent securityComponent; + @ApiOperation(value = "新闻的收藏数", notes = "新闻的收藏数接口") + @ApiImplicitParams({ + @ApiImplicitParam(name = "newsContentIds", value = "新闻ID集,多个用_隔开", paramType = "query") + }) + @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) + @GetMapping("getcountbynewscontentids" + ISystemConstant.APP_RELEASE_SUFFIX + "/{newsContentIds}") + public List getCountbyNewsContentIds(@PathVariable("newsContentIds") String newsContentIds) throws SearchException { + String[] newsContentIdArr = newsContentIds.split("_"); + List newsContentIdList = Arrays.asList(newsContentIdArr); + return newsContentCollectService.countCountByNewsContentIds(newsContentIdList); + } + @ApiOperation(value = "新增新闻收藏表", notes = "新增新闻收藏表接口") @ApiImplicitParams({ @ApiImplicitParam(name = "token", value = "token", paramType = "header") diff --git a/src/main/java/com/cm/news/controller/app/apis/newscontentlike/NewsContentLikeAppController.java b/src/main/java/com/cm/news/controller/app/apis/newscontentlike/NewsContentLikeAppController.java index 81e9a4b..e8cd8c0 100644 --- a/src/main/java/com/cm/news/controller/app/apis/newscontentlike/NewsContentLikeAppController.java +++ b/src/main/java/com/cm/news/controller/app/apis/newscontentlike/NewsContentLikeAppController.java @@ -10,6 +10,8 @@ import com.cm.common.result.ErrorResult; import com.cm.common.result.SuccessResult; import com.cm.common.result.SuccessResultData; import com.cm.common.result.SuccessResultList; +import com.cm.news.pojo.dtos.newscomment.NewsCommentCountDTO; +import com.cm.news.pojo.dtos.newscontentlike.NewsContentLikeCountDTO; import com.cm.news.pojo.dtos.newscontentlike.NewsContentLikeDTO; import com.cm.news.pojo.vos.newscontentlike.NewsContentLikeVO; import com.cm.news.service.newscontentlike.INewsContentLikeService; @@ -36,6 +38,18 @@ public class NewsContentLikeAppController extends AbstractController { @Autowired private INewsContentLikeService newsContentLikeService; + @ApiOperation(value = "新闻的点赞数", notes = "新闻的点赞数接口") + @ApiImplicitParams({ + @ApiImplicitParam(name = "newsContentIds", value = "新闻ID集,多个用_隔开", paramType = "query") + }) + @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) + @GetMapping("getcountbynewscontentids" + ISystemConstant.APP_RELEASE_SUFFIX + "/{newsContentIds}") + public List getCountbyNewsContentIds(@PathVariable("newsContentIds") String newsContentIds) throws SearchException { + String[] newsContentIdArr = newsContentIds.split("_"); + List newsContentIdList = Arrays.asList(newsContentIdArr); + return newsContentLikeService.countCountByNewsContentIds(newsContentIdList); + } + @ApiOperation(value = "新增新闻点赞", notes = "新增新闻点赞接口") @ApiImplicitParams({ @ApiImplicitParam(name = "token", value = "token", paramType = "header") diff --git a/src/main/java/com/cm/news/dao/newscomment/INewsCommentDao.java b/src/main/java/com/cm/news/dao/newscomment/INewsCommentDao.java index faa3d85..6246944 100644 --- a/src/main/java/com/cm/news/dao/newscomment/INewsCommentDao.java +++ b/src/main/java/com/cm/news/dao/newscomment/INewsCommentDao.java @@ -84,4 +84,4 @@ public interface INewsCommentDao { * @throws SearchException */ List listCountByNewsContentIds(Map params) throws SearchException; -} +} \ No newline at end of file diff --git a/src/main/java/com/cm/news/dao/newscontentcollect/INewsContentCollectDao.java b/src/main/java/com/cm/news/dao/newscontentcollect/INewsContentCollectDao.java index dc4c67c..5897928 100644 --- a/src/main/java/com/cm/news/dao/newscontentcollect/INewsContentCollectDao.java +++ b/src/main/java/com/cm/news/dao/newscontentcollect/INewsContentCollectDao.java @@ -5,6 +5,7 @@ import com.cm.common.exception.SaveException; import com.cm.common.exception.SearchException; import com.cm.common.exception.UpdateException; import com.cm.common.result.SuccessResultList; +import com.cm.news.pojo.dtos.newscontentcollect.NewsContentCollectCountDTO; import com.cm.news.pojo.dtos.newscontentcollect.NewsContentCollectDTO; import com.cm.news.pojo.dtos.newscontentcollect.NewsContentCollectionCountDTO; import org.springframework.stereotype.Repository; @@ -102,4 +103,6 @@ public interface INewsContentCollectDao { * @throws SearchException */ List listNewsContentCollectByNewsContentIdsAndUserId(Map map) throws SearchException; + + List getCountbyNewsContentIds(Map params) throws SearchException; } \ No newline at end of file diff --git a/src/main/java/com/cm/news/dao/newscontentlike/INewsContentLikeDao.java b/src/main/java/com/cm/news/dao/newscontentlike/INewsContentLikeDao.java index 22d525b..1ece11e 100644 --- a/src/main/java/com/cm/news/dao/newscontentlike/INewsContentLikeDao.java +++ b/src/main/java/com/cm/news/dao/newscontentlike/INewsContentLikeDao.java @@ -6,6 +6,7 @@ import com.cm.common.exception.SearchException; import com.cm.common.exception.UpdateException; import com.cm.common.result.SuccessResultList; import com.cm.news.pojo.dtos.newscommentlike.NewsCommentLikeCountDTO; +import com.cm.news.pojo.dtos.newscontentlike.NewsContentLikeCountDTO; import com.cm.news.pojo.dtos.newscontentlike.NewsContentLikeDTO; import org.springframework.stereotype.Repository; @@ -92,5 +93,5 @@ public interface INewsContentLikeDao { * @return * @throws SearchException */ - List listCountByNewsContentIds(Map params) throws SearchException; + List listCountByNewsContentIds(Map params) throws SearchException; } \ No newline at end of file diff --git a/src/main/java/com/cm/news/pojo/dtos/newscomment/NewsCommentCountDTO.java b/src/main/java/com/cm/news/pojo/dtos/newscomment/NewsCommentCountDTO.java index 8814e36..463dfd7 100644 --- a/src/main/java/com/cm/news/pojo/dtos/newscomment/NewsCommentCountDTO.java +++ b/src/main/java/com/cm/news/pojo/dtos/newscomment/NewsCommentCountDTO.java @@ -6,8 +6,9 @@ import io.swagger.annotations.ApiModelProperty; import java.io.Serializable; /** + * * @ClassName: NewsCommentDTO - * @Description: 新闻评论记录表 + * @Description: 新闻评论数 * @Author: WenG * @Date: 2020-05-07 14:01 * @Version: 1.0 @@ -15,14 +16,13 @@ import java.io.Serializable; @ApiModel public class NewsCommentCountDTO implements Serializable { - private static final long serialVersionUID = -4018217677091807455L; - @ApiModelProperty(name = "newsContentId", value = "新闻ID") + @ApiModelProperty(name = "newsContentId", value = "新闻内容ID") private String newsContentId; - @ApiModelProperty(name = "count", value = "总数") + @ApiModelProperty(name = "count", value = "评论数量") private Integer count; public String getNewsContentId() { - return newsContentId == null ? "" : newsContentId.trim(); + return newsContentId == null ? "" : newsContentId; } public void setNewsContentId(String newsContentId) { diff --git a/src/main/java/com/cm/news/pojo/dtos/newscontentcollect/NewsContentCollectCountDTO.java b/src/main/java/com/cm/news/pojo/dtos/newscontentcollect/NewsContentCollectCountDTO.java new file mode 100644 index 0000000..8a937ef --- /dev/null +++ b/src/main/java/com/cm/news/pojo/dtos/newscontentcollect/NewsContentCollectCountDTO.java @@ -0,0 +1,37 @@ +package com.cm.news.pojo.dtos.newscontentcollect; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +/** + * + * @ClassName: NewsContentCollectDTO + * @Description: 新闻收藏数 + * @Author: WenG + * @Date: 2020-05-12 10:35 + * @Version: 1.0 + **/ +@ApiModel +public class NewsContentCollectCountDTO { + + @ApiModelProperty(name = "newsContentId", value = "新闻ID") + private String newsContentId; + @ApiModelProperty(name = "collectCount", value = "收藏数") + private Integer collectCount; + + public String getNewsContentId() { + return newsContentId == null ? "" : newsContentId; + } + + public void setNewsContentId(String newsContentId) { + this.newsContentId = newsContentId; + } + + public Integer getCollectCount() { + return collectCount; + } + + public void setCollectCount(Integer collectCount) { + this.collectCount = collectCount; + } +} diff --git a/src/main/java/com/cm/news/pojo/dtos/newscontentcollect/NewsContentCollectDTO.java b/src/main/java/com/cm/news/pojo/dtos/newscontentcollect/NewsContentCollectDTO.java index 653dd83..50bf4fd 100644 --- a/src/main/java/com/cm/news/pojo/dtos/newscontentcollect/NewsContentCollectDTO.java +++ b/src/main/java/com/cm/news/pojo/dtos/newscontentcollect/NewsContentCollectDTO.java @@ -3,8 +3,6 @@ package com.cm.news.pojo.dtos.newscontentcollect; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import java.io.Serializable; - /** * * @ClassName: NewsContentCollectDTO @@ -14,9 +12,8 @@ import java.io.Serializable; * @Version: 1.0 **/ @ApiModel -public class NewsContentCollectDTO implements Serializable { +public class NewsContentCollectDTO { - private static final long serialVersionUID = 3774070218632818773L; @ApiModelProperty(name = "newsContentCollectId", value = "主键") private String newsContentCollectId; @ApiModelProperty(name = "newsContentId", value = "新闻") diff --git a/src/main/java/com/cm/news/pojo/dtos/newscontentcollect/NewsContentCollectionCountDTO.java b/src/main/java/com/cm/news/pojo/dtos/newscontentcollect/NewsContentCollectionCountDTO.java index 71864a1..c8cb0b8 100644 --- a/src/main/java/com/cm/news/pojo/dtos/newscontentcollect/NewsContentCollectionCountDTO.java +++ b/src/main/java/com/cm/news/pojo/dtos/newscontentcollect/NewsContentCollectionCountDTO.java @@ -1,28 +1,18 @@ package com.cm.news.pojo.dtos.newscontentcollect; -import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import java.io.Serializable; -/** - * @ClassName: NewsCommentLikeCountDTO - * @Description: 新闻收藏统计 - * @Author: WenG - * @Date: 2020-05-07 14:01 - * @Version: 1.0 - **/ -@ApiModel public class NewsContentCollectionCountDTO implements Serializable { - private static final long serialVersionUID = 4024432852658941620L; @ApiModelProperty(name = "newsContentId", value = "新闻ID") private String newsContentId; - @ApiModelProperty(name = "count", value = "总数") + @ApiModelProperty(name = "count", value = "收藏数") private Integer count; public String getNewsContentId() { - return newsContentId == null ? "" : newsContentId.trim(); + return newsContentId == null ? "" : newsContentId; } public void setNewsContentId(String newsContentId) { @@ -30,7 +20,7 @@ public class NewsContentCollectionCountDTO implements Serializable { } public Integer getCount() { - return count == null ? 0 : count; + return count; } public void setCount(Integer count) { diff --git a/src/main/java/com/cm/news/pojo/dtos/newscontentlike/NewsContentLikeCountDTO.java b/src/main/java/com/cm/news/pojo/dtos/newscontentlike/NewsContentLikeCountDTO.java new file mode 100644 index 0000000..a9fb06f --- /dev/null +++ b/src/main/java/com/cm/news/pojo/dtos/newscontentlike/NewsContentLikeCountDTO.java @@ -0,0 +1,40 @@ +package com.cm.news.pojo.dtos.newscontentlike; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.io.Serializable; + +/** + * + * @ClassName: NewsContentLikeDTO + * @Description: 新闻点赞数 + * @Author: WenG + * @Date: 2020-05-12 10:33 + * @Version: 1.0 + **/ +@ApiModel +public class NewsContentLikeCountDTO implements Serializable { + + @ApiModelProperty(name = "newsContentId", value = "新闻ID") + private String newsContentId; + @ApiModelProperty(name = "count", value = "点赞数量") + private Integer count; + + public String getNewsContentId() { + return newsContentId == null ? "" : newsContentId; + } + + public void setNewsContentId(String newsContentId) { + this.newsContentId = newsContentId; + } + + public Integer getCount() { + return count == null ? 0 : count; + } + + public void setCount(Integer count) { + this.count = count; + } + +} diff --git a/src/main/java/com/cm/news/service/newscomment/INewsCommentService.java b/src/main/java/com/cm/news/service/newscomment/INewsCommentService.java index e996aa4..2a8a2d5 100644 --- a/src/main/java/com/cm/news/service/newscomment/INewsCommentService.java +++ b/src/main/java/com/cm/news/service/newscomment/INewsCommentService.java @@ -9,7 +9,6 @@ import com.cm.news.pojo.dtos.newscomment.NewsCommentCountDTO; import com.cm.news.pojo.dtos.newscomment.NewsCommentDTO; import com.cm.news.pojo.vos.newscomment.NewsCommentVO; import com.cm.news.pojo.vos.newscomment.NewsCommentViolationVO; -import com.cm.news.pojo.vos.newscommentlike.NewsCommentLikeVO; import java.util.List; import java.util.Map; @@ -104,7 +103,7 @@ public interface INewsCommentService { * 新闻评论记录表分页列表 * * @param page - * @return + * @returncountCountByNewsContentIds * @throws SearchException */ SuccessResultList> listPageNewsComment(ListPage page) throws SearchException; @@ -117,8 +116,6 @@ public interface INewsCommentService { Integer getCountByNewsContentId(String newsContentId) throws SearchException; - Integer getCountByNewsContentIds(List newsContentIds) throws SearchException; - /** * 统计评论总数列表 * diff --git a/src/main/java/com/cm/news/service/newscomment/impl/NewsCommentServiceImpl.java b/src/main/java/com/cm/news/service/newscomment/impl/NewsCommentServiceImpl.java index 57695d8..410727a 100644 --- a/src/main/java/com/cm/news/service/newscomment/impl/NewsCommentServiceImpl.java +++ b/src/main/java/com/cm/news/service/newscomment/impl/NewsCommentServiceImpl.java @@ -256,17 +256,11 @@ public class NewsCommentServiceImpl extends BaseService implements INewsCommentS return newsCommentDao.getCountByNewsContentId(params); } - @Override - public Integer getCountByNewsContentIds(List newsContentIds) throws SearchException { - Map params = new HashMap(); - params.put("newsContentIds", newsContentIds); - return newsCommentDao.getCountByNewsContentId(params); - } - @Override public List countCountByNewsContentIds(List newsContentIds) throws SearchException { Map params = getHashMap(2); params.put("newsContentIds", newsContentIds); return newsCommentDao.listCountByNewsContentIds(params); } + } diff --git a/src/main/java/com/cm/news/service/newscontent/impl/NewsContentServiceImpl.java b/src/main/java/com/cm/news/service/newscontent/impl/NewsContentServiceImpl.java index 147ba4c..1751a4f 100644 --- a/src/main/java/com/cm/news/service/newscontent/impl/NewsContentServiceImpl.java +++ b/src/main/java/com/cm/news/service/newscontent/impl/NewsContentServiceImpl.java @@ -380,14 +380,31 @@ public class NewsContentServiceImpl extends BaseService implements INewsContentS @Override public SuccessResultList> listPageNewsContentToApp(ListPage page) throws SearchException { - List userIds = iUserService.listUserIdAllByAreaId(page.getParams()); - page.getParams().put("createUserIdList", userIds); + Map param = page.getParams(); + // 1. 是否查询区域新闻 + // 1. Start + boolean queryArea = false; + for(int i = 1 ; i <= 5 ; i++) { + if( param.get("area" + i) != null) { + queryArea = true; + break; + } + } + if(queryArea) { + List userIds = iUserService.listUserIdAllByAreaId(param); + // 防止区域没有配置人的时候 , 不按区域userId查询 , 查出全部 + if (userIds.size() < 1) { + userIds.add("-1"); + } + page.getParams().put("createUserIdList", userIds ); + } + page.getParams().put("queryArea", queryArea); + // 1. End PageHelper.startPage(page.getPage(), page.getRows()); List newsContentDTOs = newsContentDao.listNewsContentToApp(page.getParams()); if (newsContentDTOs.isEmpty()) { return new SuccessResultList<>(new ArrayList<>(), 1, 0L); } - Map map = new HashMap(); String userId = ""; if (page.getParams().get("token") != null) { userId = AppTokenManager.getInstance().getToken(page.getParams().get("token").toString()).getAppTokenUser().getId(); @@ -399,14 +416,14 @@ public class NewsContentServiceImpl extends BaseService implements INewsContentS } // 第一步 查找封面图片 List converList = iNewsContentCoverService.listNewsContentCoverByNewsContentIds(newsContentIds); - // 第二步 查找配置的标签项 - List configList = iNewsLabelConfigService.listNewsLabelConfigByNewsContentIds(newsContentIds); - // 第三步 查找评论数 - List newsCommentCountList = iNewsCommentService.countCountByNewsContentIds(newsContentIds); - // 第四步 查找点赞数 - List newsCommentLikeCountList = iNewsContentLikeService.countCountByNewsContentIds(newsContentIds); - // 第五步 查找收藏数 - List newsContentCollectionCountList = iNewsContentCollectService.countCountByNewsContentIds(newsContentIds); +// // 第二步 查找配置的标签项 || 2021年1月5日11:04:42 目前没有启用标签功能, 所以无需查询 +// List configList = iNewsLabelConfigService.listNewsLabelConfigByNewsContentIds(newsContentIds); +// // 第三步 查找评论数 || 2021年1月5日11:05:09 通过单独的app接口提供 +// List newsCommentCountList = iNewsCommentService.countCountByNewsContentIds(newsContentIds); +// // 第四步 查找点赞数 || 2021年1月5日11:05:09 通过单独的app接口提供 +// List newsCommentLikeCountList = iNewsContentLikeService.countCountByNewsContentIds(newsContentIds); +// // 第五步 查找收藏数 || 2021年1月5日11:05:09 通过单独的app接口提供 +// List newsContentCollectionCountList = iNewsContentCollectService.countCountByNewsContentIds(newsContentIds); // 第六步 是否收藏 List likeDTOs = new ArrayList<>(); if (!StringUtil.isEmpty(userId)) { @@ -421,32 +438,32 @@ public class NewsContentServiceImpl extends BaseService implements INewsContentS newsContentCoverDTOs.add(newsContentCoverDTO); } } - // 第二步 查找配置的标签项 - List newsLabelConfigDTOs = new ArrayList<>(); - appDTO.setNewsContentLabelList(newsLabelConfigDTOs); - for (NewsLabelConfigDTO newsLabelConfigDTO : configList) { - if (StringUtils.equals(appDTO.getNewsContentId(), newsLabelConfigDTO.getNewsContentId())) { - newsLabelConfigDTOs.add(newsLabelConfigDTO); - } - } - // 第三步 查找评论数 - for (NewsCommentCountDTO newsCommentCountDTO : newsCommentCountList) { - if (StringUtils.equals(appDTO.getNewsContentId(), newsCommentCountDTO.getNewsContentId())) { - appDTO.setNewsContentCommentNumber(newsCommentCountDTO.getCount()); - } - } - // 第四步 查找点赞数 - for (NewsCommentLikeCountDTO newsCommentLikeCountDTO : newsCommentLikeCountList) { - if (StringUtils.equals(appDTO.getNewsContentId(), newsCommentLikeCountDTO.getNewsContentId())) { - appDTO.setNewsContentCollectionNumber(newsCommentLikeCountDTO.getCount()); - } - } - // 第五步 查找收藏数 - for (NewsContentCollectionCountDTO newsContentCollectionDTO : newsContentCollectionCountList) { - if (StringUtils.equals(appDTO.getNewsContentId(), newsContentCollectionDTO.getNewsContentId())) { - appDTO.setNewsContentLikeNumber(newsContentCollectionDTO.getCount()); - } - } +// // 第二步 查找配置的标签项 +// List newsLabelConfigDTOs = new ArrayList<>(); +// appDTO.setNewsContentLabelList(newsLabelConfigDTOs); +// for (NewsLabelConfigDTO newsLabelConfigDTO : configList) { +// if (StringUtils.equals(appDTO.getNewsContentId(), newsLabelConfigDTO.getNewsContentId())) { +// newsLabelConfigDTOs.add(newsLabelConfigDTO); +// } +// } +// // 第三步 查找评论数 +// for (NewsCommentCountDTO newsCommentCountDTO : newsCommentCountList) { +// if (StringUtils.equals(appDTO.getNewsContentId(), newsCommentCountDTO.getNewsContentId())) { +// appDTO.setNewsContentCommentNumber(newsCommentCountDTO.getCount()); +// } +// } +// // 第四步 查找点赞数 +// for (NewsCommentLikeCountDTO newsCommentLikeCountDTO : newsCommentLikeCountList) { +// if (StringUtils.equals(appDTO.getNewsContentId(), newsCommentLikeCountDTO.getNewsContentId())) { +// appDTO.setNewsContentCollectionNumber(newsCommentLikeCountDTO.getCount()); +// } +// } +// // 第五步 查找收藏数 +// for (NewsContentCollectionCountDTO newsContentCollectionDTO : newsContentCollectionCountList) { +// if (StringUtils.equals(appDTO.getNewsContentId(), newsContentCollectionDTO.getNewsContentId())) { +// appDTO.setNewsContentLikeNumber(newsContentCollectionDTO.getCount()); +// } +// } // 第六步 是否收藏 if (!StringUtil.isEmpty(userId)) { for (NewsContentCollectDTO likeDTO : likeDTOs) { diff --git a/src/main/java/com/cm/news/service/newscontentcollect/INewsContentCollectService.java b/src/main/java/com/cm/news/service/newscontentcollect/INewsContentCollectService.java index 6e93899..d2fab71 100644 --- a/src/main/java/com/cm/news/service/newscontentcollect/INewsContentCollectService.java +++ b/src/main/java/com/cm/news/service/newscontentcollect/INewsContentCollectService.java @@ -6,10 +6,10 @@ import com.cm.common.pojo.ListPage; import com.cm.common.result.SuccessResult; import com.cm.common.result.SuccessResultData; import com.cm.common.result.SuccessResultList; +import com.cm.news.pojo.dtos.newscontentcollect.NewsContentCollectCountDTO; import com.cm.news.pojo.dtos.newscontentcollect.NewsContentCollectDTO; import com.cm.news.pojo.dtos.newscontentcollect.NewsContentCollectionCountDTO; import com.cm.news.pojo.vos.newscontentcollect.NewsContentCollectVO; - import java.util.List; import java.util.Map; @@ -175,4 +175,5 @@ public interface INewsContentCollectService { * @throws SearchException */ List listNewsContentCollectByNewsContentIdsAndUserId(String userId, List newsContentIds) throws SearchException; + } \ No newline at end of file diff --git a/src/main/java/com/cm/news/service/newscontentcollect/impl/NewsContentCollectServiceImpl.java b/src/main/java/com/cm/news/service/newscontentcollect/impl/NewsContentCollectServiceImpl.java index b30ff74..123327c 100644 --- a/src/main/java/com/cm/news/service/newscontentcollect/impl/NewsContentCollectServiceImpl.java +++ b/src/main/java/com/cm/news/service/newscontentcollect/impl/NewsContentCollectServiceImpl.java @@ -11,6 +11,7 @@ import com.cm.common.token.app.AppTokenManager; import com.cm.common.utils.HashMapUtil; import com.cm.common.utils.UUIDUtil; import com.cm.news.dao.newscontentcollect.INewsContentCollectDao; +import com.cm.news.pojo.dtos.newscontentcollect.NewsContentCollectCountDTO; import com.cm.news.pojo.dtos.newscontentcollect.NewsContentCollectDTO; import com.cm.news.pojo.dtos.newscontentcollect.NewsContentCollectionCountDTO; import com.cm.news.pojo.vos.newscontentcollect.NewsContentCollectVO; @@ -223,4 +224,5 @@ public class NewsContentCollectServiceImpl extends BaseService implements INewsC map.put("newsContentIds", newsContentIds); return newsContentCollectDao.listNewsContentCollectByNewsContentIdsAndUserId(map); } + } \ No newline at end of file diff --git a/src/main/java/com/cm/news/service/newscontentlike/INewsContentLikeService.java b/src/main/java/com/cm/news/service/newscontentlike/INewsContentLikeService.java index 90dc238..7c7370a 100644 --- a/src/main/java/com/cm/news/service/newscontentlike/INewsContentLikeService.java +++ b/src/main/java/com/cm/news/service/newscontentlike/INewsContentLikeService.java @@ -8,6 +8,7 @@ import com.cm.common.result.SuccessResult; import com.cm.common.result.SuccessResultData; import com.cm.common.result.SuccessResultList; import com.cm.news.pojo.dtos.newscommentlike.NewsCommentLikeCountDTO; +import com.cm.news.pojo.dtos.newscontentlike.NewsContentLikeCountDTO; import com.cm.news.pojo.dtos.newscontentlike.NewsContentLikeDTO; import com.cm.news.pojo.vos.newscontentlike.NewsContentLikeVO; @@ -165,5 +166,5 @@ public interface INewsContentLikeService { * @return * @throws SearchException */ - List countCountByNewsContentIds(List newsContentIds) throws SearchException; + List countCountByNewsContentIds(List newsContentIds) throws SearchException; } \ No newline at end of file diff --git a/src/main/java/com/cm/news/service/newscontentlike/impl/NewsContentLikeServiceImpl.java b/src/main/java/com/cm/news/service/newscontentlike/impl/NewsContentLikeServiceImpl.java index 9f8bfd5..ba46750 100644 --- a/src/main/java/com/cm/news/service/newscontentlike/impl/NewsContentLikeServiceImpl.java +++ b/src/main/java/com/cm/news/service/newscontentlike/impl/NewsContentLikeServiceImpl.java @@ -12,6 +12,7 @@ import com.cm.common.utils.UUIDUtil; import com.cm.news.dao.newscontentlike.INewsContentLikeDao; import com.cm.news.pojo.dtos.newscommentlike.NewsCommentLikeCountDTO; import com.cm.news.pojo.dtos.newscontentcollect.NewsContentCollectDTO; +import com.cm.news.pojo.dtos.newscontentlike.NewsContentLikeCountDTO; import com.cm.news.pojo.dtos.newscontentlike.NewsContentLikeDTO; import com.cm.news.pojo.vos.newscontentlike.NewsContentLikeVO; import com.cm.news.service.BaseService; @@ -210,7 +211,7 @@ public class NewsContentLikeServiceImpl extends BaseService implements INewsCont } @Override - public List countCountByNewsContentIds(List newsContentIds) throws SearchException { + public List countCountByNewsContentIds(List newsContentIds) throws SearchException { Map params = new HashMap(); params.put("newsContentIds", newsContentIds); return newsContentLikeDao.listCountByNewsContentIds(params); diff --git a/src/main/resources/mybatis/mapper/newscomment/newscomment-mapper.xml b/src/main/resources/mybatis/mapper/newscomment/newscomment-mapper.xml index 401b8b4..8bddabd 100644 --- a/src/main/resources/mybatis/mapper/newscomment/newscomment-mapper.xml +++ b/src/main/resources/mybatis/mapper/newscomment/newscomment-mapper.xml @@ -32,7 +32,7 @@ SELECT - news_content_id, - COUNT(*) count + news_content_id, + COUNT(1) count FROM - gen_news_content_collect + gen_news_content_collect WHERE - is_delete = 0 + is_delete = 0 AND - news_content_id IN + news_content_id IN #{newsContentIds[${index}]} GROUP BY - news_content_id + news_content_id SELECT - news_content_collect_id, - news_content_id + news_content_collect_id, + news_content_id FROM - gen_news_content_collect + gen_news_content_collect WHERE - is_delete = 0 AND creator = #{creator} + is_delete = 0 AND creator = #{creator} AND - news_content_id IN + news_content_id IN #{newsContentIds[${index}]} @@ -90,13 +90,13 @@ UPDATE - gen_news_content_collect + gen_news_content_collect SET - is_delete = 1, - modifier = #{modifier}, - gmt_modified = #{gmtModified} + is_delete = 1, + modifier = #{modifier}, + gmt_modified = #{gmtModified} WHERE - news_content_collect_id IN + news_content_collect_id IN #{newsContentCollectIds[${index}]} @@ -105,9 +105,9 @@ DELETE FROM - gen_news_content_collect + gen_news_content_collect WHERE - news_content_collect_id IN + news_content_collect_id IN #{newsContentCollectIds[${index}]} @@ -116,28 +116,28 @@ UPDATE - gen_news_content_collect + gen_news_content_collect SET news_content_id = #{newsContentId}, - modifier = #{modifier}, - gmt_modified = #{gmtModified} + modifier = #{modifier}, + gmt_modified = #{gmtModified} WHERE - news_content_collect_id = #{newsContentCollectId} + news_content_collect_id = #{newsContentCollectId} @@ -145,36 +145,36 @@ diff --git a/src/main/resources/mybatis/mapper/newscontentlike/newscontentlike-mapper.xml b/src/main/resources/mybatis/mapper/newscontentlike/newscontentlike-mapper.xml index aec2316..87ac35d 100644 --- a/src/main/resources/mybatis/mapper/newscontentlike/newscontentlike-mapper.xml +++ b/src/main/resources/mybatis/mapper/newscontentlike/newscontentlike-mapper.xml @@ -9,16 +9,16 @@ - + - SELECT news_content_id, - COUNT(*) count + COUNT(1) count FROM gen_news_content_like WHERE