From b3e4b774470fe9419f44c01a6af40a2a2ef1f6b5 Mon Sep 17 00:00:00 2001 From: yitonglei Date: Tue, 19 Jul 2022 11:19:05 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E4=BF=AE=E6=94=B9=E4=B8=AA=E4=BA=BA?= =?UTF-8?q?=E4=B8=AD=E5=BF=83-=E6=88=91=E7=9A=84=E6=B5=8F=E8=A7=88?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ResourceBrowseController.java | 22 +++++++++++-- .../resourceBrowse/dao/ResourceBrowseDao.java | 4 +++ .../service/ResourceBrowseService.java | 6 ++++ .../impl/ResourceBrowseServiceImpl.java | 10 ++++++ .../resourceBrowse/ResourceBrowseDao.xml | 32 +++++++++++++++++++ 5 files changed, 71 insertions(+), 3 deletions(-) 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