我的评论(需求评论)
This commit is contained in:
parent
efb58708e6
commit
01d4ff1157
|
@ -15,6 +15,7 @@ import io.renren.modules.demanData.service.TDemandDataService;
|
|||
import io.renren.modules.demandComment.dto.TDemandCommentDTO;
|
||||
import io.renren.modules.demandComment.excel.TDemandCommentExcel;
|
||||
import io.renren.modules.demandComment.service.TDemandCommentService;
|
||||
import io.renren.modules.security.user.SecurityUser;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
|
@ -26,6 +27,7 @@ import springfox.documentation.annotations.ApiIgnore;
|
|||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -55,16 +57,44 @@ public class TDemandCommentController {
|
|||
// @RequiresPermissions("demandComment:tdemandcomment:page")
|
||||
public Result<PageData<TDemandCommentDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params) {
|
||||
PageData<TDemandCommentDTO> page = tDemandCommentService.page(params);
|
||||
page.setList(page.getList().stream().map(index -> {
|
||||
index.setDemandDataDTO(tDemandDataService.get(index.getTargetId()));
|
||||
return index;
|
||||
}).collect(Collectors.toList()));
|
||||
|
||||
return new Result<PageData<TDemandCommentDTO>>().ok(page);
|
||||
}
|
||||
|
||||
@GetMapping("/myComment/page")
|
||||
@ApiOperation("我的评论分页")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", required = true, dataType = "int"),
|
||||
@ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query", required = true, dataType = "int"),
|
||||
@ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType = "String"),
|
||||
@ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType = "String"),
|
||||
@ApiImplicitParam(name = "targetId", value = "评论主题id", paramType = "query", dataType = "Long")
|
||||
})
|
||||
// @RequiresPermissions("demandComment:tdemandcomment:page")
|
||||
public Result<PageData<TDemandCommentDTO>> myCommentPage(@ApiIgnore @RequestParam Map<String, Object> params) {
|
||||
params.put("creator", SecurityUser.getUserId()); //
|
||||
PageData<TDemandCommentDTO> page = tDemandCommentService.page(params);
|
||||
page.setList(page.getList().stream().map(index -> {
|
||||
index.setDemandDataDTO(tDemandDataService.get(index.getTargetId()));
|
||||
return index;
|
||||
}).collect(Collectors.toList()));
|
||||
|
||||
return new Result<PageData<TDemandCommentDTO>>().ok(page);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/{id}")
|
||||
@ApiOperation("信息")
|
||||
// @RequiresPermissions("demandComment:tdemandcomment:info")
|
||||
public Result<TDemandCommentDTO> get(@PathVariable("id") Long id) {
|
||||
TDemandCommentDTO data = tDemandCommentService.get(id);
|
||||
|
||||
data.setDemandDataDTO(tDemandDataService.get(data.getTargetId()));
|
||||
|
||||
return new Result<TDemandCommentDTO>().ok(data);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package io.renren.modules.demandComment.dto;
|
||||
|
||||
import io.renren.modules.demanData.dto.TDemandDataDTO;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
@ -42,4 +43,7 @@ public class TDemandCommentDTO implements Serializable {
|
|||
@ApiModelProperty(value = "备用字段")
|
||||
private String note5;
|
||||
|
||||
@ApiModelProperty(value = "评论所属需求主题")
|
||||
private TDemandDataDTO demandDataDTO;
|
||||
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package io.renren.modules.demandComment.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import io.renren.common.service.impl.CrudServiceImpl;
|
||||
import io.renren.modules.demandComment.dao.TDemandCommentDao;
|
||||
import io.renren.modules.demandComment.dto.TDemandCommentDTO;
|
||||
|
@ -22,9 +23,17 @@ public class TDemandCommentServiceImpl extends CrudServiceImpl<TDemandCommentDao
|
|||
@Override
|
||||
public QueryWrapper<TDemandCommentEntity> getWrapper(Map<String, Object> params) {
|
||||
QueryWrapper<TDemandCommentEntity> wrapper = new QueryWrapper<>();
|
||||
if (params.containsKey("targetId")) {
|
||||
params.keySet().stream().filter(index -> null != params.get(index)).forEach(index -> {
|
||||
switch (index) {
|
||||
case "targetId":
|
||||
wrapper.eq("target_id", params.get("targetId"));
|
||||
break;
|
||||
case "creator":
|
||||
wrapper.eq(StringUtils.isNotBlank(params.get("creator").toString()), "creator", params.get("creator").toString());
|
||||
break;
|
||||
}
|
||||
});
|
||||
wrapper.groupBy("target_id");
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue