diff --git a/renren-admin/src/main/java/io/renren/modules/resourceBrowse/controller/ResourceBrowseController.java b/renren-admin/src/main/java/io/renren/modules/resourceBrowse/controller/ResourceBrowseController.java index 2e39d367..9b27a040 100644 --- a/renren-admin/src/main/java/io/renren/modules/resourceBrowse/controller/ResourceBrowseController.java +++ b/renren-admin/src/main/java/io/renren/modules/resourceBrowse/controller/ResourceBrowseController.java @@ -14,6 +14,7 @@ import io.renren.modules.resourceBrowse.dto.ResourceBrowseDTO; import io.renren.modules.resourceBrowse.excel.ResourceBrowseExcel; import io.renren.modules.resourceBrowse.service.ResourceBrowseService; import io.renren.modules.security.user.SecurityUser; +import io.renren.modules.security.user.UserDetail; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; @@ -57,12 +58,27 @@ public class ResourceBrowseController { @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 = "name", value = "关键字", paramType = "query", dataType = "String"), + @ApiImplicitParam(name = "type",value = "查询类型(组件服务 应用资源 知识库)", paramType = "query", dataType = "String"), }) //@RequiresPermissions("resourceBrowse:resourcebrowse:page") public Result> page(@ApiIgnore @RequestParam Map params) { - PageData page = resourceBrowseService.page(params); - page.getList().forEach(item -> item.setResourceDTO(resourceService.get(item.getResourceId()))); - return new Result>().ok(page); + UserDetail user = SecurityUser.getUser(); + if(user == null){ + return new Result<>(); + }else{ + Long id = user.getId(); + params.put("userId",id); + } + Integer page = Integer.parseInt(params.get("page").toString()) - 1; + Integer pageSize = Integer.parseInt(params.get("limit").toString()); + params.put("pageNum",page); + params.put("pageSize",pageSize); + + //PageData page = resourceBrowseService.page(params); + PageData pageData = resourceBrowseService.selectResourceBrowseByTypeAndUser(params); + pageData.getList().forEach(item -> item.setResourceDTO(resourceService.get(item.getResourceId()))); + return new Result>().ok(pageData); } @GetMapping("/select/{id}") diff --git a/renren-admin/src/main/java/io/renren/modules/resourceBrowse/dao/ResourceBrowseDao.java b/renren-admin/src/main/java/io/renren/modules/resourceBrowse/dao/ResourceBrowseDao.java index ef37bb7f..d63ee619 100644 --- a/renren-admin/src/main/java/io/renren/modules/resourceBrowse/dao/ResourceBrowseDao.java +++ b/renren-admin/src/main/java/io/renren/modules/resourceBrowse/dao/ResourceBrowseDao.java @@ -1,6 +1,7 @@ package io.renren.modules.resourceBrowse.dao; import io.renren.common.dao.BaseDao; +import io.renren.modules.resourceBrowse.dto.ResourceBrowseDTO; import io.renren.modules.resourceBrowse.entity.ResourceBrowseEntity; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -22,4 +23,7 @@ public interface ResourceBrowseDao extends BaseDao { Integer selectDayMax(); List selectDayList(@Param("startDate") String startDate,@Param("endDate") String endDate); + + List selectResourceBrowseByTypeAndUser(@Param("params") Map params); + Integer resourceBrowseDTOCount(@Param("params") Map params); } \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/resourceBrowse/service/ResourceBrowseService.java b/renren-admin/src/main/java/io/renren/modules/resourceBrowse/service/ResourceBrowseService.java index 76ac4a33..2ac2043c 100644 --- a/renren-admin/src/main/java/io/renren/modules/resourceBrowse/service/ResourceBrowseService.java +++ b/renren-admin/src/main/java/io/renren/modules/resourceBrowse/service/ResourceBrowseService.java @@ -1,9 +1,13 @@ package io.renren.modules.resourceBrowse.service; +import io.renren.common.page.PageData; import io.renren.common.service.CrudService; import io.renren.modules.resourceBrowse.dto.ResourceBrowseDTO; import io.renren.modules.resourceBrowse.entity.ResourceBrowseEntity; +import java.util.List; +import java.util.Map; + /** * 浏览记录 * @@ -17,4 +21,6 @@ public interface ResourceBrowseService extends CrudService selectResourceBrowseByTypeAndUser(Map map); } \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/resourceBrowse/service/impl/ResourceBrowseServiceImpl.java b/renren-admin/src/main/java/io/renren/modules/resourceBrowse/service/impl/ResourceBrowseServiceImpl.java index 8c67dab8..f72e538f 100644 --- a/renren-admin/src/main/java/io/renren/modules/resourceBrowse/service/impl/ResourceBrowseServiceImpl.java +++ b/renren-admin/src/main/java/io/renren/modules/resourceBrowse/service/impl/ResourceBrowseServiceImpl.java @@ -1,6 +1,7 @@ package io.renren.modules.resourceBrowse.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import io.renren.common.page.PageData; import io.renren.common.service.impl.CrudServiceImpl; import io.renren.common.utils.DateUtils; import io.renren.modules.resourceBrowse.dao.ResourceBrowseDao; @@ -10,6 +11,7 @@ import io.renren.modules.resourceBrowse.service.ResourceBrowseService; import io.renren.modules.security.user.SecurityUser; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; +import org.springframework.security.core.parameters.P; import org.springframework.stereotype.Service; import java.util.*; @@ -75,4 +77,12 @@ public class ResourceBrowseServiceImpl extends CrudServiceImpl selectResourceBrowseByTypeAndUser(Map map) { + Integer total = resourceBrowseDao.resourceBrowseDTOCount(map); + List list = resourceBrowseDao.selectResourceBrowseByTypeAndUser(map); + PageData pageData = new PageData(list,total); + return pageData; + } } \ No newline at end of file diff --git a/renren-admin/src/main/resources/mapper/resourceBrowse/ResourceBrowseDao.xml b/renren-admin/src/main/resources/mapper/resourceBrowse/ResourceBrowseDao.xml index 508b30c8..fdea7f44 100644 --- a/renren-admin/src/main/resources/mapper/resourceBrowse/ResourceBrowseDao.xml +++ b/renren-admin/src/main/resources/mapper/resourceBrowse/ResourceBrowseDao.xml @@ -52,4 +52,36 @@ SUBSTR(create_date, 1, 10) + + + \ No newline at end of file