门户搜索修改

This commit is contained in:
dinggang 2022-05-12 13:48:47 +08:00
parent a73228e07e
commit 1abc8a883e
4 changed files with 34 additions and 14 deletions

View File

@ -248,14 +248,13 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
//根据用户收藏和申请数据查出应用领域排名在根据应用领域查询热门能力推荐给用户
List<Map> applyAreaList = resourceDao.selectApplyArea(userId);
//没有收藏和申请过按最热能力选取,否则根据应用领域最多类型推荐
if (applyAreaList.isEmpty()) {
JSONObject object = new JSONObject();
object.put("pageNum", 0);
object.put("pageSize", 9);
object.put("orderFiled", "total");
object.put("orderType", "DESC");
return this.selectMostPopular(object);
} else {
JSONObject object = new JSONObject();
object.put("pageNum", 0);
object.put("pageSize", 9);
object.put("orderFiled", "total");
object.put("orderType", "DESC");
Page<ResourceDTO> resultPage = (Page<ResourceDTO>)this.selectMostPopular(object);
if (!applyAreaList.isEmpty()) {
ResourceDTO resourceDTO = new ResourceDTO();
ArrayList<AttrEntity> list = new ArrayList<>();
AttrEntity attrEntity = new AttrEntity();
@ -268,7 +267,21 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
jsonObject.put("pageSize", 9);
jsonObject.put("orderField", "total");
jsonObject.put("orderType", "DESC");
return this.pageWithAttrs(jsonObject);
Page<ResourceDTO> Page = (Page<ResourceDTO>)this.pageWithAttrs(jsonObject);
//若查出数据不足9条则在热门能力补充缺少的数量
if (Page.getRecords().size() < 9) {
for (int i = 0; Page.getRecords().size() < 9; i++) {
for (int j = 0; j < Page.getRecords().size(); j++) {
if (!Page.getRecords().get(j).getId().equals(resultPage.getRecords().get(i).getId())) {
Page.getRecords().add(resultPage.getRecords().get(i));
break;
}
}
}
}
return Page;
} else {
return resultPage;
}
}

View File

@ -44,7 +44,8 @@ public class WorkDynamicsController {
@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 = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType="String"),
@ApiImplicitParam(name = "name", value = "工作动态标题", paramType = "query", dataType="String")
})
//@RequiresPermissions("workDynamics:workdynamics:page")
public Result<PageData<WorkDynamicsDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params){

View File

@ -1,5 +1,6 @@
package io.renren.modules.workDynamics.service.impl;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.renren.common.service.impl.CrudServiceImpl;
import io.renren.common.constant.Constant;
@ -8,6 +9,7 @@ import io.renren.modules.workDynamics.dto.WorkDynamicsDTO;
import io.renren.modules.workDynamics.entity.WorkDynamicsEntity;
import io.renren.modules.workDynamics.service.WorkDynamicsService;
import io.renren.modules.security.user.SecurityUser;
import org.apache.commons.lang.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -29,9 +31,11 @@ public class WorkDynamicsServiceImpl extends CrudServiceImpl<WorkDynamicsDao, Wo
@Override
public QueryWrapper<WorkDynamicsEntity> getWrapper(Map<String, Object> params){
QueryWrapper<WorkDynamicsEntity> wrapper = new QueryWrapper<>();
if (ObjectUtil.isNotNull(params.get("name"))) {
wrapper.like("title", params.get("name").toString());
}
wrapper.eq("del_flag", 0)
.orderByDesc("create_date");
return wrapper;
}

View File

@ -123,10 +123,12 @@
GROUP BY id) taa2 ON tdr.id = taa2.resource_id
LEFT JOIN sys_dept sd ON tdr.dept_id = sd.id
WHERE 1 = 1
AND tdr.type LIKE CONCAT('%',#{dto.type},'%')
<if test="dto.type != null and dto.type != ''">
AND tdr.type LIKE CONCAT('%',#{dto.type},'%')
</if>
AND tdr.del_flag = 0
<if test="dto.name != null and dto.name != ''">
AND tdr.name like CONCAT('%',#{dto.name},'%')
AND tdr.name LIKE CONCAT('%',#{dto.name},'%')
</if>
<if test="dto.districtId != null and dto.districtId != ''">
AND tdr.district_id = #{dto.districtId}
@ -144,7 +146,7 @@
<foreach collection="dto.infoList" item="item" separator="union all">
SELECT data_resource_id FROM tb_data_attr
WHERE attr_type = #{item.attrType}
AND attr_value = #{item.attrValue}
AND attr_value LIKE CONCAT('%', #{item.attrValue}, '%')
AND del_flag = 0
</foreach>) tb
GROUP BY tb.data_resource_id