From a519811d4cc978c5608f764e90f69b099ba4f2fe Mon Sep 17 00:00:00 2001 From: dinggang <2498628697@qq.com> Date: Wed, 27 Apr 2022 16:50:16 +0800 Subject: [PATCH] =?UTF-8?q?=E9=97=A8=E6=88=B7=E9=A6=96=E9=A1=B5=E5=8F=8A?= =?UTF-8?q?=E4=BA=8C=E7=BA=A7=E6=90=9C=E7=B4=A2=E9=A1=B5=E9=9D=A2=E6=8E=92?= =?UTF-8?q?=E5=BA=8F=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/resource/dao/ResourceDao.java | 12 +- .../modules/resource/dto/ResourceDTO.java | 4 + .../service/impl/ResourceServiceImpl.java | 62 +++---- .../resourceCar/dao/ResourceCarDao.java | 2 + .../dao/ResourceCollectionDao.java | 2 + .../resourceScore/dao/ResourceScoreDao.java | 4 + .../resources/mapper/resource/ResourceDao.xml | 173 +++++++++++++----- .../mapper/resourceCar/ResourceCarDao.xml | 11 ++ .../ResourceCollectionDao.xml | 11 ++ .../mapper/resourceScore/ResourceScoreDao.xml | 11 ++ 10 files changed, 211 insertions(+), 81 deletions(-) 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 d01db9c4..b5069726 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 @@ -20,9 +20,19 @@ public interface ResourceDao extends BaseDao { Integer deleteByIds(@Param("ids") List idList); - List selectWithAttrs(@Param("dto") ResourceDTO resourceDTO); + List selectWithAttrs(@Param("dto") ResourceDTO resourceDTO, + @Param("orderField") String orderField, + @Param("orderType") String orderType); List selectTypeCount(Long deptId); List selectMostPopular(Map selectMap); + + ResourceDTO selectDTOById(Long id); + + List selectDTOPage(@Param("dto")ResourceDTO resourceDTO, + @Param("pageNum") Integer pageNum, + @Param("pageSize") Integer pageSize, + @Param("orderField")String orderField, + @Param("orderType") String orderType); } \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/resource/dto/ResourceDTO.java b/renren-admin/src/main/java/io/renren/modules/resource/dto/ResourceDTO.java index fffc20de..e8125bac 100644 --- a/renren-admin/src/main/java/io/renren/modules/resource/dto/ResourceDTO.java +++ b/renren-admin/src/main/java/io/renren/modules/resource/dto/ResourceDTO.java @@ -77,10 +77,14 @@ public class ResourceDTO implements Serializable { private String deptName; @ApiModelProperty(value = "收藏标志") private String isCollect; + @ApiModelProperty(value = "收藏量") + private Integer collectCount; @ApiModelProperty(value = "评分") private Long score; @ApiModelProperty(value = "申请结果") private String applyState; + @ApiModelProperty(value = "申请量") + private String applyCount; @ApiModelProperty(value = "属性信息") 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 d01d52d9..86100493 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,6 +1,5 @@ package io.renren.modules.resource.service.impl; -import cn.hutool.core.util.ObjectUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; @@ -17,10 +16,11 @@ 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.resourceCar.dao.ResourceCarDao; +import io.renren.modules.resourceCollection.dao.ResourceCollectionDao; +import io.renren.modules.resourceScore.dao.ResourceScoreDao; import io.renren.modules.security.user.SecurityUser; import io.renren.modules.security.user.UserDetail; -import io.renren.modules.sys.dto.SysDeptDTO; -import io.renren.modules.sys.service.SysDeptService; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -41,10 +41,16 @@ import java.util.Map; public class ResourceServiceImpl extends CrudServiceImpl implements ResourceService { @Autowired - private SysDeptService sysDeptService; + private ResourceDao resourceDao; @Autowired - private ResourceDao resourceDao; + private ResourceScoreDao resourceScoreDao; + + @Autowired + private ResourceCollectionDao resourceCollectionDao; + + @Autowired + private ResourceCarDao resourceCarDao; @Autowired private AttrDao attrDao; @@ -91,7 +97,11 @@ public class ResourceServiceImpl extends CrudServiceImpl idList = jsonArray.toJavaList(Long.class); resourceDao.deleteByIds(idList); + //将所有能力相关表的删除标志都置为1 attrDao.delete4Resource(idList); + resourceCarDao.delete4Resource(idList); + resourceScoreDao.delete4Resource(idList); + resourceCollectionDao.delete4Resource(idList); } @Override @@ -112,16 +122,10 @@ public class ResourceServiceImpl extends CrudServiceImpl wrapper = new QueryWrapper<>(); - wrapper.eq("data_resource_id", resourceEntity.getId()) - .eq("del_flag", 0); + wrapper.eq("data_resource_id", id) + .eq("del_f lag", 0); List attrEntities = attrDao.selectList(wrapper); resourceDTO.setInfoList(attrEntities); return resourceDTO; @@ -134,32 +138,18 @@ public class ResourceServiceImpl extends CrudServiceImpl resultPage = new Page<>(pageNum, pageSize); if (resourceDTO.getInfoList().isEmpty()) { - Page page = new Page(pageNum, pageSize); - QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("del_flag", 0) - .like(StringUtils.isNotBlank(resourceDTO.getName()), "name", resourceDTO.getName()) - .eq(ObjectUtil.isNotNull(resourceDTO.getDistrictId()), "district_id", resourceDTO.getDistrictId()) - .eq(ObjectUtil.isNotNull(resourceDTO.getDeptId()), "dept_id", resourceDTO.getDeptId()) - .eq("type", resourceDTO.getType()) - .orderBy(true, orderASC, orderField); - Page entityPage = resourceDao.selectPage(page, queryWrapper); - ArrayList list = new ArrayList<>(); - entityPage.getRecords().forEach(item -> { - ResourceDTO dto = new ResourceDTO(); - BeanUtils.copyProperties(item, dto); - dto.setInfoList(this.selectAttrsByResourceId(dto.getId())); - list.add(dto); + List resourceDTOS = resourceDao.selectDTOPage(resourceDTO, (pageNum - 1)* pageSize, pageSize, orderField, orderType); + resourceDTOS.forEach(item -> { + item.setInfoList(this.selectAttrsByResourceId(item.getId())); }); - resultPage.setRecords(list); - resultPage.setTotal(page.getTotal()); - + resultPage.setRecords(resourceDTOS); + resultPage.setTotal(resourceDao.selectDTOPage(resourceDTO, 1, 100000, orderField, orderType).size()); } else { - List resourceDTOS = resourceDao.selectWithAttrs(resourceDTO); + List resourceDTOS = resourceDao.selectWithAttrs(resourceDTO , orderField, orderType); int j = Math.min(pageNum * pageSize, resourceDTOS.size()); if (resourceDTOS.isEmpty()) { resultPage.setRecords(null); diff --git a/renren-admin/src/main/java/io/renren/modules/resourceCar/dao/ResourceCarDao.java b/renren-admin/src/main/java/io/renren/modules/resourceCar/dao/ResourceCarDao.java index a9a8a997..5f28383d 100644 --- a/renren-admin/src/main/java/io/renren/modules/resourceCar/dao/ResourceCarDao.java +++ b/renren-admin/src/main/java/io/renren/modules/resourceCar/dao/ResourceCarDao.java @@ -23,4 +23,6 @@ public interface ResourceCarDao extends BaseDao { List selectPageWithResource(@Param("params") Map params, @Param("pageNum") Integer pageNum, @Param("pageSize") Integer pageSize); + + Integer delete4Resource(@Param("resourceIds") List idList); } \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/resourceCollection/dao/ResourceCollectionDao.java b/renren-admin/src/main/java/io/renren/modules/resourceCollection/dao/ResourceCollectionDao.java index bbbfc8dc..6f2136d0 100644 --- a/renren-admin/src/main/java/io/renren/modules/resourceCollection/dao/ResourceCollectionDao.java +++ b/renren-admin/src/main/java/io/renren/modules/resourceCollection/dao/ResourceCollectionDao.java @@ -23,4 +23,6 @@ public interface ResourceCollectionDao extends BaseDao List selectPageWithResource(@Param("params") Map params, @Param("pageNum") Integer pageNum, @Param("pageSize") Integer pageSize); + + Integer delete4Resource(@Param("resourceIds") List idList); } \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/resourceScore/dao/ResourceScoreDao.java b/renren-admin/src/main/java/io/renren/modules/resourceScore/dao/ResourceScoreDao.java index 55d7146f..f7b19dc6 100644 --- a/renren-admin/src/main/java/io/renren/modules/resourceScore/dao/ResourceScoreDao.java +++ b/renren-admin/src/main/java/io/renren/modules/resourceScore/dao/ResourceScoreDao.java @@ -5,6 +5,8 @@ import io.renren.modules.resourceScore.entity.ResourceScoreEntity; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; +import java.util.List; + /** * 能力评分表 * @@ -15,4 +17,6 @@ import org.apache.ibatis.annotations.Param; public interface ResourceScoreDao extends BaseDao { Integer deleteByIds(@Param("ids") Long[] ids); + + Integer delete4Resource(@Param("resourceIds") List idList); } \ No newline at end of file diff --git a/renren-admin/src/main/resources/mapper/resource/ResourceDao.xml b/renren-admin/src/main/resources/mapper/resource/ResourceDao.xml index 85ed452f..dfaa235b 100644 --- a/renren-admin/src/main/resources/mapper/resource/ResourceDao.xml +++ b/renren-admin/src/main/resources/mapper/resource/ResourceDao.xml @@ -60,9 +60,12 @@ - - + + + + + @@ -82,11 +85,11 @@ - update tb_data_resource - set del_flag = 1, - update_date = now() - where 1 = 1 - and id in + UPDATE tb_data_resource + SET del_flag = 1, + update_date = NOW() + WHERE 1 = 1 + AND id IN #{item} @@ -94,69 +97,86 @@ + + + + \ No newline at end of file diff --git a/renren-admin/src/main/resources/mapper/resourceCar/ResourceCarDao.xml b/renren-admin/src/main/resources/mapper/resourceCar/ResourceCarDao.xml index b434fa18..be86b2f9 100644 --- a/renren-admin/src/main/resources/mapper/resourceCar/ResourceCarDao.xml +++ b/renren-admin/src/main/resources/mapper/resourceCar/ResourceCarDao.xml @@ -30,6 +30,17 @@ + + update tb_resource_car + set del_flag = 1, + update_date = now() + where 1 = 1 + and resource_id in + + #{item} + + + select trc.* from tb_resource_collection trc diff --git a/renren-admin/src/main/resources/mapper/resourceScore/ResourceScoreDao.xml b/renren-admin/src/main/resources/mapper/resourceScore/ResourceScoreDao.xml index 99128adf..da55bd7c 100644 --- a/renren-admin/src/main/resources/mapper/resourceScore/ResourceScoreDao.xml +++ b/renren-admin/src/main/resources/mapper/resourceScore/ResourceScoreDao.xml @@ -32,4 +32,15 @@ + + update tb_resource_score + set del_flag = 1, + update_date = now() + where 1 = 1 + and resource_id in + + #{item} + + + \ No newline at end of file