From 5f2bd3aeab15d3dd762668453ce4993944c9f52f Mon Sep 17 00:00:00 2001 From: dinggang <2498628697@qq.com> Date: Fri, 15 Apr 2022 11:49:50 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BC=96=E7=9B=AE=E7=AE=A1=E7=90=86=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=EF=BC=8C=E8=B5=84=E6=BA=90=E7=AE=A1=E7=90=86=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resource/controller/ResourceController.java | 12 +++++++----- .../renren/modules/resource/dao/ResourceDao.java | 3 +-- .../resource/service/ResourceService.java | 3 +-- .../service/impl/ResourceServiceImpl.java | 13 +++++++------ .../resources/mapper/resource/ResourceDao.xml | 16 +++++++--------- 5 files changed, 23 insertions(+), 24 deletions(-) diff --git a/renren-admin/src/main/java/io/renren/modules/resource/controller/ResourceController.java b/renren-admin/src/main/java/io/renren/modules/resource/controller/ResourceController.java index 805332aa..c6efe74a 100644 --- a/renren-admin/src/main/java/io/renren/modules/resource/controller/ResourceController.java +++ b/renren-admin/src/main/java/io/renren/modules/resource/controller/ResourceController.java @@ -8,7 +8,6 @@ import io.renren.common.utils.Result; import io.renren.common.validator.ValidatorUtils; import io.renren.common.validator.group.AddGroup; import io.renren.common.validator.group.DefaultGroup; -import io.renren.common.validator.group.UpdateGroup; import io.renren.modules.resource.dto.ResourceDTO; import io.renren.modules.resource.service.ResourceService; import io.swagger.annotations.Api; @@ -19,7 +18,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import springfox.documentation.annotations.ApiIgnore; -import java.util.List; import java.util.Map; /** @@ -58,10 +56,14 @@ public class ResourceController { @PostMapping("/pageWithAttrs") @ApiOperation("分页查询资源信息2") + //@ApiImplicitParams({ + // @ApiImplicitParam(name = "name", value = "资源名称", paramType = "query", dataType="String") , + // @ApiImplicitParam(name = "type", value = "资源类型", paramType = "query",required = true, dataType="String") , + // @ApiImplicitParam(name = "infoList", value = "类型", paramType = "query", dataType="List") + //}) //@RequiresPermissions("resource:resource:page") - public Result pageWithAttrs(@RequestBody ResourceDTO resourceDTO){ - - return new Result<>().ok(resourceService.pageWithAttrs(resourceDTO)); + public Result pageWithAttrs(@RequestBody JSONObject jsonObject){ + return new Result<>().ok(resourceService.pageWithAttrs(jsonObject)); } @GetMapping("/select/{id}") diff --git a/renren-admin/src/main/java/io/renren/modules/resource/dao/ResourceDao.java b/renren-admin/src/main/java/io/renren/modules/resource/dao/ResourceDao.java index 5c2bee64..e3b1ab2f 100644 --- a/renren-admin/src/main/java/io/renren/modules/resource/dao/ResourceDao.java +++ b/renren-admin/src/main/java/io/renren/modules/resource/dao/ResourceDao.java @@ -7,7 +7,6 @@ import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import java.util.List; -import java.util.Map; /** * 资源表 @@ -20,5 +19,5 @@ public interface ResourceDao extends BaseDao { Integer deleteByIds(@Param("ids") List idList); - List selectWithAttrs(ResourceDTO resourceDTO); + List selectWithAttrs(@Param("dto") ResourceDTO resourceDTO, @Param("pageNum") Integer pageNum, @Param("pageSize") Integer pageSize); } \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/resource/service/ResourceService.java b/renren-admin/src/main/java/io/renren/modules/resource/service/ResourceService.java index fe1f2691..163f1660 100644 --- a/renren-admin/src/main/java/io/renren/modules/resource/service/ResourceService.java +++ b/renren-admin/src/main/java/io/renren/modules/resource/service/ResourceService.java @@ -1,7 +1,6 @@ package io.renren.modules.resource.service; import com.alibaba.fastjson.JSONObject; -import io.renren.common.page.PageData; import io.renren.common.service.CrudService; import io.renren.modules.resource.dto.ResourceDTO; import io.renren.modules.resource.entity.AttrEntity; @@ -25,7 +24,7 @@ public interface ResourceService extends CrudService pageWithAttrs(ResourceDTO resourceDTO); + List pageWithAttrs(JSONObject jsonObject); List selectAttrsByResourceId(Long id); } \ No newline at end of file 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 41357bc5..6d2ab17b 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 @@ -1,26 +1,23 @@ package io.renren.modules.resource.service.impl; +import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.IdWorker; import io.renren.common.service.impl.CrudServiceImpl; -import io.renren.common.constant.Constant; import io.renren.modules.resource.dao.AttrDao; import io.renren.modules.resource.dao.ResourceDao; import io.renren.modules.resource.dto.ResourceDTO; import io.renren.modules.resource.entity.AttrEntity; import io.renren.modules.resource.entity.ResourceEntity; import io.renren.modules.resource.service.ResourceService; -import io.renren.modules.security.user.SecurityUser; -import org.apache.commons.lang3.StringUtils; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; import java.util.Map; @@ -106,8 +103,12 @@ public class ResourceServiceImpl extends CrudServiceImpl pageWithAttrs(ResourceDTO resourceDTO) { - return resourceDao.selectWithAttrs(resourceDTO); + public List pageWithAttrs(JSONObject jsonObject) { + ResourceDTO resourceDTO = JSON.toJavaObject(jsonObject, ResourceDTO.class); + + Integer pageNum = jsonObject.getInteger("pageNum"); + Integer pageSize = jsonObject.getInteger("pageSize"); + return resourceDao.selectWithAttrs(resourceDTO, (pageNum - 1) * pageSize, pageSize); } @Override diff --git a/renren-admin/src/main/resources/mapper/resource/ResourceDao.xml b/renren-admin/src/main/resources/mapper/resource/ResourceDao.xml index fd620f64..f0247431 100644 --- a/renren-admin/src/main/resources/mapper/resource/ResourceDao.xml +++ b/renren-admin/src/main/resources/mapper/resource/ResourceDao.xml @@ -85,12 +85,12 @@ tb_data_attr a WHERE 1 = 1 and r.id = a.data_resource_id - and r.type = #{type} + and r.type = #{dto.type} and r.del_flag = 0 - - and r.name like CONCAT('%',#{name},'%') + + and r.name like CONCAT('%',#{dto.name},'%') - + AND a.data_resource_id IN ( SELECT @@ -101,20 +101,18 @@ tb.data_resource_id FROM ( - + SELECT data_resource_id FROM tb_data_attr WHERE attr_type = #{item.attrType} AND attr_value = #{item.attrValue} and del_flag = 0 - ) tb GROUP BY tb.data_resource_id HAVING - COUNT( tb.data_resource_id ) = ${infoList.size} + COUNT( tb.data_resource_id ) = ${dto.infoList.size} ORDER BY tb.data_resource_id ASC - limit #{pageNum} , #{pageSize} - ) tmp) + ) tmp) limit ${pageNum}, ${pageSize}