diff --git a/renren-admin/src/main/java/io/renren/modules/demanData/controller/TDemandDataController.java b/renren-admin/src/main/java/io/renren/modules/demanData/controller/TDemandDataController.java index 3b07af35..f4b29055 100644 --- a/renren-admin/src/main/java/io/renren/modules/demanData/controller/TDemandDataController.java +++ b/renren-admin/src/main/java/io/renren/modules/demanData/controller/TDemandDataController.java @@ -13,6 +13,7 @@ import io.renren.common.validator.group.UpdateGroup; import io.renren.modules.demanData.dto.TDemandDataDTO; import io.renren.modules.demanData.excel.TDemandDataExcel; import io.renren.modules.demanData.service.TDemandDataService; +import io.renren.modules.demandComment.service.TDemandCommentService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; @@ -24,6 +25,7 @@ import springfox.documentation.annotations.ApiIgnore; import javax.servlet.http.HttpServletResponse; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; /** @@ -38,6 +40,8 @@ import java.util.Map; public class TDemandDataController { @Autowired private TDemandDataService tDemandDataService; + @Autowired + private TDemandCommentService tDemandCommentService; @GetMapping("/page") @ApiOperation("分页") @@ -54,7 +58,10 @@ public class TDemandDataController { // @RequiresPermissions("demanData:tdemanddata:page") public Result> page(@ApiIgnore @RequestParam Map params) { PageData page = tDemandDataService.page(params); - + page.setList(page.getList().stream().map(index -> { + index.setCommentCount(tDemandCommentService.commentCount(index.getId())); + return index; + }).collect(Collectors.toList())); return new Result>().ok(page); } @@ -63,7 +70,7 @@ public class TDemandDataController { // @RequiresPermissions("demanData:tdemanddata:info") public Result get(@PathVariable("id") Long id) { TDemandDataDTO data = tDemandDataService.get(id); - + data.setCommentCount(tDemandCommentService.commentCount(id)); return new Result().ok(data); } diff --git a/renren-admin/src/main/java/io/renren/modules/demanData/dto/TDemandDataDTO.java b/renren-admin/src/main/java/io/renren/modules/demanData/dto/TDemandDataDTO.java index 59b67084..d47e0732 100644 --- a/renren-admin/src/main/java/io/renren/modules/demanData/dto/TDemandDataDTO.java +++ b/renren-admin/src/main/java/io/renren/modules/demanData/dto/TDemandDataDTO.java @@ -61,6 +61,9 @@ public class TDemandDataDTO extends AuditingBaseDTO implements Serializable { @ApiModelProperty(value = "实例ID") private String instanceId; + @ApiModelProperty(value = "评论数目") + private Long commentCount = 0l; + public TDemandDataDTO() { this.flag = TDemandDataEntityFlag.INIT.getFlag(); this.visits = 0l; diff --git a/renren-admin/src/main/java/io/renren/modules/demandComment/dao/TDemandCommentDao.java b/renren-admin/src/main/java/io/renren/modules/demandComment/dao/TDemandCommentDao.java index 74a87dc5..d3145515 100644 --- a/renren-admin/src/main/java/io/renren/modules/demandComment/dao/TDemandCommentDao.java +++ b/renren-admin/src/main/java/io/renren/modules/demandComment/dao/TDemandCommentDao.java @@ -12,5 +12,7 @@ import org.apache.ibatis.annotations.Mapper; */ @Mapper public interface TDemandCommentDao extends BaseDao { + + Long commentCount(Long dataId); } \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/demandComment/service/TDemandCommentService.java b/renren-admin/src/main/java/io/renren/modules/demandComment/service/TDemandCommentService.java index 55a6a6eb..ff47a785 100644 --- a/renren-admin/src/main/java/io/renren/modules/demandComment/service/TDemandCommentService.java +++ b/renren-admin/src/main/java/io/renren/modules/demandComment/service/TDemandCommentService.java @@ -11,5 +11,6 @@ import io.renren.modules.demandComment.entity.TDemandCommentEntity; * @since 1.0 2022-04-26 */ public interface TDemandCommentService extends CrudService { + Long commentCount(Long dataId); } \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/demandComment/service/impl/TDemandCommentServiceImpl.java b/renren-admin/src/main/java/io/renren/modules/demandComment/service/impl/TDemandCommentServiceImpl.java index 17deab03..79947dfd 100644 --- a/renren-admin/src/main/java/io/renren/modules/demandComment/service/impl/TDemandCommentServiceImpl.java +++ b/renren-admin/src/main/java/io/renren/modules/demandComment/service/impl/TDemandCommentServiceImpl.java @@ -55,4 +55,8 @@ public class TDemandCommentServiceImpl extends CrudServiceImpl + \ No newline at end of file