我的评论(需求评论)
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.dto.TDemandCommentDTO;
|
||||||
import io.renren.modules.demandComment.excel.TDemandCommentExcel;
|
import io.renren.modules.demandComment.excel.TDemandCommentExcel;
|
||||||
import io.renren.modules.demandComment.service.TDemandCommentService;
|
import io.renren.modules.demandComment.service.TDemandCommentService;
|
||||||
|
import io.renren.modules.security.user.SecurityUser;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiImplicitParam;
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
import io.swagger.annotations.ApiImplicitParams;
|
import io.swagger.annotations.ApiImplicitParams;
|
||||||
|
@ -26,6 +27,7 @@ import springfox.documentation.annotations.ApiIgnore;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -55,16 +57,44 @@ public class TDemandCommentController {
|
||||||
// @RequiresPermissions("demandComment:tdemandcomment:page")
|
// @RequiresPermissions("demandComment:tdemandcomment:page")
|
||||||
public Result<PageData<TDemandCommentDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params) {
|
public Result<PageData<TDemandCommentDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params) {
|
||||||
PageData<TDemandCommentDTO> page = tDemandCommentService.page(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);
|
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}")
|
@GetMapping("/{id}")
|
||||||
@ApiOperation("信息")
|
@ApiOperation("信息")
|
||||||
// @RequiresPermissions("demandComment:tdemandcomment:info")
|
// @RequiresPermissions("demandComment:tdemandcomment:info")
|
||||||
public Result<TDemandCommentDTO> get(@PathVariable("id") Long id) {
|
public Result<TDemandCommentDTO> get(@PathVariable("id") Long id) {
|
||||||
TDemandCommentDTO data = tDemandCommentService.get(id);
|
TDemandCommentDTO data = tDemandCommentService.get(id);
|
||||||
|
|
||||||
|
data.setDemandDataDTO(tDemandDataService.get(data.getTargetId()));
|
||||||
|
|
||||||
return new Result<TDemandCommentDTO>().ok(data);
|
return new Result<TDemandCommentDTO>().ok(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package io.renren.modules.demandComment.dto;
|
package io.renren.modules.demandComment.dto;
|
||||||
|
|
||||||
|
import io.renren.modules.demanData.dto.TDemandDataDTO;
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
@ -8,11 +9,11 @@ import java.io.Serializable;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 需求评论
|
* 需求评论
|
||||||
*
|
*
|
||||||
* @author wangliwen wangliwen2@hisense.com
|
* @author wangliwen wangliwen2@hisense.com
|
||||||
* @since 1.0 2022-04-26
|
* @since 1.0 2022-04-26
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@ApiModel(value = "需求评论")
|
@ApiModel(value = "需求评论")
|
||||||
public class TDemandCommentDTO implements Serializable {
|
public class TDemandCommentDTO implements Serializable {
|
||||||
|
@ -42,4 +43,7 @@ public class TDemandCommentDTO implements Serializable {
|
||||||
@ApiModelProperty(value = "备用字段")
|
@ApiModelProperty(value = "备用字段")
|
||||||
private String note5;
|
private String note5;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "评论所属需求主题")
|
||||||
|
private TDemandDataDTO demandDataDTO;
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
package io.renren.modules.demandComment.service.impl;
|
package io.renren.modules.demandComment.service.impl;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
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.common.service.impl.CrudServiceImpl;
|
||||||
import io.renren.modules.demandComment.dao.TDemandCommentDao;
|
import io.renren.modules.demandComment.dao.TDemandCommentDao;
|
||||||
import io.renren.modules.demandComment.dto.TDemandCommentDTO;
|
import io.renren.modules.demandComment.dto.TDemandCommentDTO;
|
||||||
|
@ -22,9 +23,17 @@ public class TDemandCommentServiceImpl extends CrudServiceImpl<TDemandCommentDao
|
||||||
@Override
|
@Override
|
||||||
public QueryWrapper<TDemandCommentEntity> getWrapper(Map<String, Object> params) {
|
public QueryWrapper<TDemandCommentEntity> getWrapper(Map<String, Object> params) {
|
||||||
QueryWrapper<TDemandCommentEntity> wrapper = new QueryWrapper<>();
|
QueryWrapper<TDemandCommentEntity> wrapper = new QueryWrapper<>();
|
||||||
if (params.containsKey("targetId")) {
|
params.keySet().stream().filter(index -> null != params.get(index)).forEach(index -> {
|
||||||
wrapper.eq("target_id", params.get("targetId"));
|
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;
|
return wrapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue