需求主题模糊查询与需求评论模糊查询

This commit is contained in:
wangliwen 2022-05-06 10:59:27 +08:00
parent 4566c0303b
commit ac5aecf518
4 changed files with 28 additions and 4 deletions

View File

@ -1,6 +1,7 @@
package io.renren.modules.demanData.service.impl; package io.renren.modules.demanData.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.renren.common.constant.Constant;
import io.renren.common.service.impl.CrudServiceImpl; import io.renren.common.service.impl.CrudServiceImpl;
import io.renren.modules.demanData.dao.TDemandDataDao; import io.renren.modules.demanData.dao.TDemandDataDao;
import io.renren.modules.demanData.dto.TDemandDataDTO; import io.renren.modules.demanData.dto.TDemandDataDTO;
@ -34,6 +35,9 @@ public class TDemandDataServiceImpl extends CrudServiceImpl<TDemandDataDao, TDem
case "detailsType": case "detailsType":
wrapper.eq("details_type", params.get("detailsType").toString()); wrapper.eq("details_type", params.get("detailsType").toString());
break; break;
case Constant.SEARCHKEY:
wrapper.like("demand_subject", params.get(Constant.SEARCHKEY));
break;
} }
}); });
if (!params.containsKey("creator")) { if (!params.containsKey("creator")) {

View File

@ -52,7 +52,8 @@ public class TDemandCommentController {
@ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", 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_FIELD, value = "排序字段", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType = "String"), @ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "targetId", value = "评论主题id", paramType = "query", dataType = "Long") @ApiImplicitParam(name = "targetId", value = "评论主题id", paramType = "query", dataType = "Long"),
@ApiImplicitParam(name = "searchKey", value = "模糊查询关键字", paramType = "query", dataType = "String")
}) })
// @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) {

View File

@ -2,14 +2,19 @@ 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 com.baomidou.mybatisplus.core.toolkit.StringUtils;
import io.renren.common.constant.Constant;
import io.renren.common.service.impl.CrudServiceImpl; import io.renren.common.service.impl.CrudServiceImpl;
import io.renren.modules.demanData.service.TDemandDataService;
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;
import io.renren.modules.demandComment.entity.TDemandCommentEntity; import io.renren.modules.demandComment.entity.TDemandCommentEntity;
import io.renren.modules.demandComment.service.TDemandCommentService; import io.renren.modules.demandComment.service.TDemandCommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors;
/** /**
* 需求评论 * 需求评论
@ -19,6 +24,8 @@ import java.util.Map;
*/ */
@Service @Service
public class TDemandCommentServiceImpl extends CrudServiceImpl<TDemandCommentDao, TDemandCommentEntity, TDemandCommentDTO> implements TDemandCommentService { public class TDemandCommentServiceImpl extends CrudServiceImpl<TDemandCommentDao, TDemandCommentEntity, TDemandCommentDTO> implements TDemandCommentService {
@Autowired
private TDemandDataService tDemandDataService;
@Override @Override
public QueryWrapper<TDemandCommentEntity> getWrapper(Map<String, Object> params) { public QueryWrapper<TDemandCommentEntity> getWrapper(Map<String, Object> params) {
@ -31,9 +38,18 @@ public class TDemandCommentServiceImpl extends CrudServiceImpl<TDemandCommentDao
case "creator": case "creator":
wrapper.eq(StringUtils.isNotBlank(params.get("creator").toString()), "creator", params.get("creator").toString()); wrapper.eq(StringUtils.isNotBlank(params.get("creator").toString()), "creator", params.get("creator").toString());
break; break;
case Constant.SEARCHKEY: {
wrapper
.in(StringUtils.isNotBlank(params.get("searchKey").toString()), "", tDemandDataService.list(new HashMap<String, Object>() {
{
put(Constant.SEARCHKEY, params.get(Constant.SEARCHKEY).toString());
}
}).stream().map(index_ -> index_.getId()).collect(Collectors.toList()).toArray());
}
break;
} }
}); });
// wrapper.groupBy("target_id"); wrapper.orderByDesc("create_date");
return wrapper; return wrapper;
} }

View File

@ -2,9 +2,12 @@ package io.renren.common.constant;
/** /**
* 常量 * 常量
*
*/ */
public interface Constant { public interface Constant {
/**
* 模糊查询时key
*/
String SEARCHKEY = "searchKey";
/** /**
* 成功 * 成功
*/ */
@ -34,7 +37,7 @@ public interface Constant {
*/ */
Long DICT_ROOT = 0L; Long DICT_ROOT = 0L;
/** /**
* 升序 * 升序
*/ */
String ASC = "asc"; String ASC = "asc";
/** /**