diff --git a/renren-admin/src/main/java/io/renren/modules/resource/service/impl/ResourceServiceImpl.java b/renren-admin/src/main/java/io/renren/modules/resource/service/impl/ResourceServiceImpl.java index cfb4fdda..7179ae30 100644 --- a/renren-admin/src/main/java/io/renren/modules/resource/service/impl/ResourceServiceImpl.java +++ b/renren-admin/src/main/java/io/renren/modules/resource/service/impl/ResourceServiceImpl.java @@ -248,14 +248,13 @@ public class ResourceServiceImpl extends CrudServiceImpl 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 resultPage = (Page)this.selectMostPopular(object); + if (!applyAreaList.isEmpty()) { ResourceDTO resourceDTO = new ResourceDTO(); ArrayList list = new ArrayList<>(); AttrEntity attrEntity = new AttrEntity(); @@ -268,7 +267,21 @@ public class ResourceServiceImpl extends CrudServiceImpl Page = (Page)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; } } diff --git a/renren-admin/src/main/java/io/renren/modules/workDynamics/controller/WorkDynamicsController.java b/renren-admin/src/main/java/io/renren/modules/workDynamics/controller/WorkDynamicsController.java index 21769e9a..2c1ccf84 100644 --- a/renren-admin/src/main/java/io/renren/modules/workDynamics/controller/WorkDynamicsController.java +++ b/renren-admin/src/main/java/io/renren/modules/workDynamics/controller/WorkDynamicsController.java @@ -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> page(@ApiIgnore @RequestParam Map params){ diff --git a/renren-admin/src/main/java/io/renren/modules/workDynamics/service/impl/WorkDynamicsServiceImpl.java b/renren-admin/src/main/java/io/renren/modules/workDynamics/service/impl/WorkDynamicsServiceImpl.java index d2830a6f..47337b82 100644 --- a/renren-admin/src/main/java/io/renren/modules/workDynamics/service/impl/WorkDynamicsServiceImpl.java +++ b/renren-admin/src/main/java/io/renren/modules/workDynamics/service/impl/WorkDynamicsServiceImpl.java @@ -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 getWrapper(Map params){ QueryWrapper 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; } diff --git a/renren-admin/src/main/resources/mapper/resource/ResourceDao.xml b/renren-admin/src/main/resources/mapper/resource/ResourceDao.xml index 9e81f55a..edf30e1d 100644 --- a/renren-admin/src/main/resources/mapper/resource/ResourceDao.xml +++ b/renren-admin/src/main/resources/mapper/resource/ResourceDao.xml @@ -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},'%') + + AND tdr.type LIKE CONCAT('%',#{dto.type},'%') + AND tdr.del_flag = 0 - AND tdr.name like CONCAT('%',#{dto.name},'%') + AND tdr.name LIKE CONCAT('%',#{dto.name},'%') AND tdr.district_id = #{dto.districtId} @@ -144,7 +146,7 @@ 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 ) tb GROUP BY tb.data_resource_id