需求接口出评论数目
This commit is contained in:
parent
59d13aadc8
commit
cea2901afa
|
@ -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<PageData<TDemandDataDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params) {
|
||||
PageData<TDemandDataDTO> 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<PageData<TDemandDataDTO>>().ok(page);
|
||||
}
|
||||
|
||||
|
@ -63,7 +70,7 @@ public class TDemandDataController {
|
|||
// @RequiresPermissions("demanData:tdemanddata:info")
|
||||
public Result<TDemandDataDTO> get(@PathVariable("id") Long id) {
|
||||
TDemandDataDTO data = tDemandDataService.get(id);
|
||||
|
||||
data.setCommentCount(tDemandCommentService.commentCount(id));
|
||||
return new Result<TDemandDataDTO>().ok(data);
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -12,5 +12,7 @@ import org.apache.ibatis.annotations.Mapper;
|
|||
*/
|
||||
@Mapper
|
||||
public interface TDemandCommentDao extends BaseDao<TDemandCommentEntity> {
|
||||
|
||||
Long commentCount(Long dataId);
|
||||
|
||||
}
|
|
@ -11,5 +11,6 @@ import io.renren.modules.demandComment.entity.TDemandCommentEntity;
|
|||
* @since 1.0 2022-04-26
|
||||
*/
|
||||
public interface TDemandCommentService extends CrudService<TDemandCommentEntity, TDemandCommentDTO> {
|
||||
Long commentCount(Long dataId);
|
||||
|
||||
}
|
|
@ -55,4 +55,8 @@ public class TDemandCommentServiceImpl extends CrudServiceImpl<TDemandCommentDao
|
|||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Long commentCount(Long dataId) {
|
||||
return baseDao.commentCount(dataId);
|
||||
}
|
||||
}
|
|
@ -17,5 +17,13 @@
|
|||
<result property="note4" column="note4"/>
|
||||
<result property="note5" column="note5"/>
|
||||
</resultMap>
|
||||
<select id="commentCount" resultType="java.lang.Long">
|
||||
SELECT
|
||||
COUNT( id )
|
||||
FROM
|
||||
t_demand_comment
|
||||
WHERE
|
||||
target_id = #{dataId};
|
||||
</select>
|
||||
|
||||
</mapper>
|
Loading…
Reference in New Issue