From c3737733f73100fd6afbe0eb5ccfa49a8e2e9c0d Mon Sep 17 00:00:00 2001 From: lizhicheng Date: Mon, 11 Jul 2022 09:17:28 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=AE=8C=E6=88=90=E8=9E=8D=E5=90=88?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E5=8A=9F=E8=83=BD=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fuse/controller/FuseController.java | 47 ++++++----- .../io/renren/modules/fuse/dao/TbFuseDao.java | 8 ++ .../io/renren/modules/fuse/dto/TbFuseDTO.java | 4 + .../modules/fuse/dto/TbFuseResourceDTO.java | 3 + .../modules/fuse/entity/TbFuseEntity.java | 1 + .../fuse/entity/TbFuseResourceEntity.java | 1 - .../modules/fuse/service/TbFuseService.java | 2 + .../fuse/service/impl/TbFuseServiceImpl.java | 78 +++++++++++++----- .../controller/ResourceController.java | 15 ++-- .../modules/resource/dao/ResourceDao.java | 2 + .../service/impl/ResourceServiceImpl.java | 31 ++------ .../dao/ResourceCollectionDao.java | 6 +- .../dto/ResourceCollectionDTO.java | 3 + .../impl/ResourceCollectionServiceImpl.java | 28 ++++++- .../main/resources/mapper/fuse/TbFuseDao.xml | 79 +++++++++++++++++++ .../resources/mapper/resource/ResourceDao.xml | 22 +++++- .../ResourceCollectionDao.xml | 20 +++-- 17 files changed, 263 insertions(+), 87 deletions(-) diff --git a/renren-admin/src/main/java/io/renren/modules/fuse/controller/FuseController.java b/renren-admin/src/main/java/io/renren/modules/fuse/controller/FuseController.java index 3262ae29..ec9ce0bb 100644 --- a/renren-admin/src/main/java/io/renren/modules/fuse/controller/FuseController.java +++ b/renren-admin/src/main/java/io/renren/modules/fuse/controller/FuseController.java @@ -1,5 +1,7 @@ package io.renren.modules.fuse.controller; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; import io.renren.common.annotation.LogOperation; import io.renren.common.constant.Constant; import io.renren.common.page.PageData; @@ -18,6 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import springfox.documentation.annotations.ApiIgnore; +import java.util.Arrays; import java.util.Map; /** @@ -29,7 +32,7 @@ import java.util.Map; */ @RestController @RequestMapping("fuse") -@Api(tags="融合服务") +@Api(tags = "融合服务") public class FuseController { @Autowired @@ -38,35 +41,36 @@ public class FuseController { @GetMapping("page") @ApiOperation("分页") @ApiImplicitParams({ - @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 = "name", value = "融合服务名称", paramType = "query", dataType="String"), - @ApiImplicitParam(name = "description", value = "融合服务描述", paramType = "query", dataType="String"), - @ApiImplicitParam(name = "applicationArea", value = "应用领域", paramType = "query", dataType="String"), - @ApiImplicitParam(name = "deptId", value = "所属部门", paramType = "query", dataType="int"), - @ApiImplicitParam(name = "deptUser", value = "部门联系人", paramType = "query", dataType="String"), - @ApiImplicitParam(name = "mobile", value = "部门联系人电话", paramType = "query", dataType="String"), - @ApiImplicitParam(name = "provider", value = "服务商", paramType = "query", dataType="String"), - @ApiImplicitParam(name = "providerUser", value = "服务商联系人", paramType = "query", dataType="String"), - @ApiImplicitParam(name = "providerMobile", value = "服务商联系人电话", paramType = "query", dataType="String") + @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 = "排序字段,可选值(create_date、update_date、collectCount)", required = true, paramType = "query", dataType = "String"), + @ApiImplicitParam(name = Constant.ORDER, required = true, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType = "String"), + @ApiImplicitParam(name = "name", value = "融合服务名称", paramType = "query", dataType = "String"), + @ApiImplicitParam(name = "description", value = "融合服务描述", paramType = "query", dataType = "String"), + @ApiImplicitParam(name = "applicationArea", value = "应用领域", paramType = "query", dataType = "String"), + @ApiImplicitParam(name = "deptId", value = "所属部门", paramType = "query", dataType = "int"), + @ApiImplicitParam(name = "deptUser", value = "部门联系人", paramType = "query", dataType = "String"), + @ApiImplicitParam(name = "mobile", value = "部门联系人电话", paramType = "query", dataType = "String"), + @ApiImplicitParam(name = "provider", value = "服务商", paramType = "query", dataType = "String"), + @ApiImplicitParam(name = "providerUser", value = "服务商联系人", paramType = "query", dataType = "String"), + @ApiImplicitParam(name = "providerMobile", value = "服务商联系人电话", paramType = "query", dataType = "String") }) - public Result> page(@ApiIgnore @RequestParam Map params){ + public Result> page(@ApiIgnore @RequestParam Map params) { PageData page = tbFuseService.page(params); return new Result>().ok(page); } @GetMapping("{id}") @ApiOperation("信息") - public Result get(@PathVariable("id") Long id){ + @LogOperation("信息") + public Result get(@PathVariable("id") Long id) { return new Result().ok(tbFuseService.getFuseById(id)); } @PostMapping @ApiOperation("保存") @LogOperation("保存") - public Result save(@RequestBody TbFuseDTO dto){ + public Result save(@RequestBody TbFuseDTO dto) { //效验数据 ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); return new Result().ok(tbFuseService.addFuse(dto)); @@ -75,16 +79,17 @@ public class FuseController { @PutMapping @ApiOperation("修改") @LogOperation("修改") - public Result update(@RequestBody TbFuseDTO dto){ + public Result update(@RequestBody TbFuseDTO dto) { //效验数据 ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); return new Result().ok(tbFuseService.updateFuse(dto)); } - @DeleteMapping + @DeleteMapping("/delete") @ApiOperation("删除") @LogOperation("删除") - public Result delete(@RequestBody Long id){ - return new Result().ok(tbFuseService.deleteFuse(id)); + public Result delete(@RequestBody Long[] fuseIds) { + Arrays.stream(fuseIds).forEach(id->tbFuseService.deleteFuse(id)); + return new Result(); } } diff --git a/renren-admin/src/main/java/io/renren/modules/fuse/dao/TbFuseDao.java b/renren-admin/src/main/java/io/renren/modules/fuse/dao/TbFuseDao.java index 4c594e4f..6a3aa6f8 100644 --- a/renren-admin/src/main/java/io/renren/modules/fuse/dao/TbFuseDao.java +++ b/renren-admin/src/main/java/io/renren/modules/fuse/dao/TbFuseDao.java @@ -1,9 +1,13 @@ package io.renren.modules.fuse.dao; import io.renren.common.dao.BaseDao; +import io.renren.modules.fuse.dto.TbFuseDTO; import io.renren.modules.fuse.entity.TbFuseEntity; import org.apache.ibatis.annotations.Mapper; +import java.util.List; +import java.util.Map; + /** * @Auther:lizhicheng2@hisense.com * @date:2022/6/30 @@ -12,4 +16,8 @@ import org.apache.ibatis.annotations.Mapper; @Mapper public interface TbFuseDao extends BaseDao { + List getFuseDTOList(Map params); + + List> selectGroupByDeptId(); + } diff --git a/renren-admin/src/main/java/io/renren/modules/fuse/dto/TbFuseDTO.java b/renren-admin/src/main/java/io/renren/modules/fuse/dto/TbFuseDTO.java index b9b5352f..c4957117 100644 --- a/renren-admin/src/main/java/io/renren/modules/fuse/dto/TbFuseDTO.java +++ b/renren-admin/src/main/java/io/renren/modules/fuse/dto/TbFuseDTO.java @@ -45,6 +45,10 @@ public class TbFuseDTO { private Long updater; @ApiModelProperty(value = "更新时间") private Date updateDate; + @ApiModelProperty(value = "收藏标志") + private String isCollect; + @ApiModelProperty(value = "收藏量") + private Integer collectCount; @ApiModelProperty(value = "资源融合关系") private List fuseResourceList; @ApiModelProperty(value = "融合资源属性") diff --git a/renren-admin/src/main/java/io/renren/modules/fuse/dto/TbFuseResourceDTO.java b/renren-admin/src/main/java/io/renren/modules/fuse/dto/TbFuseResourceDTO.java index fc3b986b..44f2e440 100644 --- a/renren-admin/src/main/java/io/renren/modules/fuse/dto/TbFuseResourceDTO.java +++ b/renren-admin/src/main/java/io/renren/modules/fuse/dto/TbFuseResourceDTO.java @@ -1,5 +1,6 @@ package io.renren.modules.fuse.dto; +import io.renren.modules.resource.dto.ResourceDTO; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -22,5 +23,7 @@ public class TbFuseResourceDTO { private Long resourceId; @ApiModelProperty(value = "资源挂载顺序") private String sequence; + @ApiModelProperty(value = "资源") + private ResourceDTO resource; } diff --git a/renren-admin/src/main/java/io/renren/modules/fuse/entity/TbFuseEntity.java b/renren-admin/src/main/java/io/renren/modules/fuse/entity/TbFuseEntity.java index 5948af97..8a077ecb 100644 --- a/renren-admin/src/main/java/io/renren/modules/fuse/entity/TbFuseEntity.java +++ b/renren-admin/src/main/java/io/renren/modules/fuse/entity/TbFuseEntity.java @@ -37,6 +37,7 @@ public class TbFuseEntity extends BaseEntity { /** * 所属部门 */ + @TableField(fill = FieldFill.INSERT) private Long deptId; /** * 部门联系人 diff --git a/renren-admin/src/main/java/io/renren/modules/fuse/entity/TbFuseResourceEntity.java b/renren-admin/src/main/java/io/renren/modules/fuse/entity/TbFuseResourceEntity.java index f1b1a932..d32186d8 100644 --- a/renren-admin/src/main/java/io/renren/modules/fuse/entity/TbFuseResourceEntity.java +++ b/renren-admin/src/main/java/io/renren/modules/fuse/entity/TbFuseResourceEntity.java @@ -2,7 +2,6 @@ package io.renren.modules.fuse.entity; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; -import io.renren.common.entity.BaseEntity; import lombok.Data; import lombok.EqualsAndHashCode; diff --git a/renren-admin/src/main/java/io/renren/modules/fuse/service/TbFuseService.java b/renren-admin/src/main/java/io/renren/modules/fuse/service/TbFuseService.java index d731cc86..bc872ee0 100644 --- a/renren-admin/src/main/java/io/renren/modules/fuse/service/TbFuseService.java +++ b/renren-admin/src/main/java/io/renren/modules/fuse/service/TbFuseService.java @@ -21,4 +21,6 @@ public interface TbFuseService extends CrudService { Integer deleteFuse(Long id); + Integer count(Map params); + } diff --git a/renren-admin/src/main/java/io/renren/modules/fuse/service/impl/TbFuseServiceImpl.java b/renren-admin/src/main/java/io/renren/modules/fuse/service/impl/TbFuseServiceImpl.java index 848d2165..6b895db0 100644 --- a/renren-admin/src/main/java/io/renren/modules/fuse/service/impl/TbFuseServiceImpl.java +++ b/renren-admin/src/main/java/io/renren/modules/fuse/service/impl/TbFuseServiceImpl.java @@ -1,9 +1,9 @@ package io.renren.modules.fuse.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.baomidou.mybatisplus.core.toolkit.StringUtils; +import io.renren.common.constant.Constant; import io.renren.common.page.PageData; import io.renren.common.service.impl.CrudServiceImpl; import io.renren.modules.fuse.dao.TbFuseAttrDao; @@ -16,7 +16,10 @@ import io.renren.modules.fuse.entity.TbFuseAttrEntity; import io.renren.modules.fuse.entity.TbFuseEntity; import io.renren.modules.fuse.entity.TbFuseResourceEntity; import io.renren.modules.fuse.service.TbFuseService; +import io.renren.modules.resource.service.ResourceService; import io.renren.modules.resource.service.impl.ResourceServiceImpl; +import io.renren.modules.resourceCollection.dao.ResourceCollectionDao; +import io.renren.modules.security.user.SecurityUser; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; @@ -24,8 +27,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.stream.Collectors; /** @@ -44,6 +46,10 @@ public class TbFuseServiceImpl extends CrudServiceImpl getWrapper(Map params) { @@ -95,31 +101,57 @@ public class TbFuseServiceImpl extends CrudServiceImpl page(Map params){ - IPage page = baseDao.selectPage( - getPage(params, null, false), - getWrapper(params) - ); - List result=page.getRecords().stream().map(entity->{ - TbFuseDTO dto=new TbFuseDTO(); - BeanUtils.copyProperties(entity, dto); + public PageData page(Map params) { + long curPage = 1; + long limit = 10; + if (params.get(Constant.PAGE) != null) { + curPage = Long.parseLong((String) params.get(Constant.PAGE)); + } + if (params.get(Constant.LIMIT) != null) { + limit = Long.parseLong((String) params.get(Constant.LIMIT)); + } + params.put("userId", SecurityUser.getUserId()); + List dtoList = baseDao.getFuseDTOList(params); + dtoList.forEach(dto -> { dto.setFuseResourceList(getFuseResourceByFuseId(dto.getId())); dto.setFuseAttrList(getAttrByFuseId(dto.getId())); - return dto; - }).collect(Collectors.toList()); - return new PageData(result, page.getTotal()); + }); + List result = dtoList.stream().skip((curPage - 1) * limit).limit(limit).collect(Collectors.toList()); + return new PageData(result, dtoList.size()); + } + + @Override + public Integer count(Map params) { + if (params != null) { + return baseDao.selectCount(getWrapper(params)); + } else { + return baseDao.selectCount(null); + } } @Override public TbFuseDTO getFuseById(Long id) { TbFuseEntity fuseEntity = fuseDao.selectById(id); + if(fuseEntity==null){ + return null; + } TbFuseDTO fuseDTO = new TbFuseDTO(); BeanUtils.copyProperties(fuseEntity, fuseDTO); fuseDTO.setFuseAttrList(getAttrByFuseId(id)); fuseDTO.setFuseResourceList(getFuseResourceByFuseId(id)); + setCollection(fuseDTO); return fuseDTO; } + private void setCollection(TbFuseDTO dto) { + QueryWrapper wrapper = new QueryWrapper(); + wrapper.eq("del_flag", "0"); + wrapper.eq("resource_id", dto.getId()); + dto.setCollectCount(resourceCollectionDao.selectCount(wrapper)); + wrapper.eq("user_id", SecurityUser.getUserId()); + dto.setIsCollect(resourceCollectionDao.selectCount(wrapper) > 0 ? "true" : "false"); + } + private List getAttrByFuseId(Long fuseId) { QueryWrapper wrapper = new QueryWrapper(); wrapper.eq("fuse_id", fuseId); @@ -138,6 +170,7 @@ public class TbFuseServiceImpl extends CrudServiceImpl { TbFuseResourceDTO dto = new TbFuseResourceDTO(); BeanUtils.copyProperties(attr, dto); + dto.setResource(resourceService.get(dto.getResourceId())); return dto; }).collect(Collectors.toList()); } @@ -147,18 +180,18 @@ public class TbFuseServiceImpl extends CrudServiceImpl{ + int result = fuseDao.insert(fuseEntity); + dto.getFuseResourceList().forEach(fuseResourceDTO -> { fuseResourceDTO.setId(IdWorker.getId(fuseResourceDTO)); fuseResourceDTO.setFuseId(fuseEntity.getId()); - TbFuseResourceEntity entity=new TbFuseResourceEntity(); + TbFuseResourceEntity entity = new TbFuseResourceEntity(); BeanUtils.copyProperties(fuseResourceDTO, entity); fuseResourceDao.insert(entity); }); dto.getFuseAttrList().forEach(fuseAttrDTO -> { fuseAttrDTO.setId(IdWorker.getId(fuseAttrDTO)); fuseAttrDTO.setFuseId(fuseEntity.getId()); - TbFuseAttrEntity entity=new TbFuseAttrEntity(); + TbFuseAttrEntity entity = new TbFuseAttrEntity(); BeanUtils.copyProperties(fuseAttrDTO, entity); fuseAttrDao.insert(entity); }); @@ -171,10 +204,10 @@ public class TbFuseServiceImpl extends CrudServiceImpl{ + dto.getFuseResourceList().forEach(fuseResourceDTO -> { fuseResourceDTO.setId(IdWorker.getId(fuseResourceDTO)); fuseResourceDTO.setFuseId(fuseEntity.getId()); - TbFuseResourceEntity entity=new TbFuseResourceEntity(); + TbFuseResourceEntity entity = new TbFuseResourceEntity(); BeanUtils.copyProperties(fuseResourceDTO, entity); fuseResourceDao.insert(entity); }); @@ -182,7 +215,7 @@ public class TbFuseServiceImpl extends CrudServiceImpl { fuseAttrDTO.setId(IdWorker.getId(fuseAttrDTO)); fuseAttrDTO.setFuseId(fuseEntity.getId()); - TbFuseAttrEntity entity=new TbFuseAttrEntity(); + TbFuseAttrEntity entity = new TbFuseAttrEntity(); BeanUtils.copyProperties(fuseAttrDTO, entity); fuseAttrDao.insert(entity); }); @@ -194,6 +227,9 @@ public class TbFuseServiceImpl extends CrudServiceImpl() {{ + this.add(id); + }}); return fuseDao.deleteById(id); } 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 f6f151bb..7e8311ad 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 @@ -518,13 +518,11 @@ public class ResourceController { } @GetMapping("/getApplyByDept") - @ApiOperation("获取当前登录用户所在部门申请的资源") - @LogOperation("获取当前登录用户所在部门申请的资源") + @ApiOperation("获取当前登录用户所在部门申请的资源-按照申请次数排名") + @LogOperation("获取当前登录用户所在部门申请的资源-按照申请次数排名") @ApiImplicitParams({ @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.LIMIT, value = "每页显示记录数", paramType = "query", required = true, dataType = "int") }) public Result getApplyByDept(@ApiIgnore @RequestParam Map params) { return new Result().ok(resourceService.getApplyByDept(params)); @@ -554,4 +552,11 @@ public class ResourceController { public Result selectInfrastructureList() { return new Result().ok(resourceService.selectInfrastructureList()); } + + @GetMapping("/list") + @ApiOperation("能力查询") + @LogOperation("能力查询") + public Result list(@ApiIgnore @RequestParam Map params){ + return new Result<>().ok(resourceService.list(params)); + } } \ No newline at end of file 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 c3362a12..73242c7a 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 @@ -164,4 +164,6 @@ public interface ResourceDao extends BaseDao { Long selectDayAvg(@Param("days") Long days); Integer selectDayMax(); + + List selectUsersApplyAndCount(@Param("userIds") List userIds); } \ 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 171560f0..73150fed 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 @@ -1617,32 +1617,13 @@ public class ResourceServiceImpl extends CrudServiceImpl sysUserList = sysUserService.list(new HashMap()); - List list = new ArrayList<>(); - HistoricProcessInstanceQuery query = historyService.createHistoricProcessInstanceQuery(); - query.orderByProcessInstanceStartTime().desc(); - for (SysUserDTO user : sysUserList) { - query.startedBy(user.getId().toString()); - list.addAll(query.list()); + List result=resourceDao.selectUsersApplyAndCount(sysUserList.stream().map(dto->dto.getId()).collect(Collectors.toList())); + int j = Math.min(curPage * limit, result.size()); + ArrayList recordLists = new ArrayList<>(); + for (int i = (curPage - 1) * limit; i < j; i++) { + recordLists.add(result.get(i)); } - boolean isAsc = false; - if (params.get(Constant.ORDER) != null && "asc".equals(params.get(Constant.ORDER))) { - isAsc = true; - } - String orderColumn = params.get(Constant.ORDER_FIELD) == null ? "create_date" : (String) params.get(Constant.ORDER_FIELD); - List resourceIds = getSourceIdsByProcess(list); - IPage page = new Page<>(curPage, limit); - QueryWrapper queryWrapper = new QueryWrapper<>(); - if (!resourceIds.isEmpty()) { - queryWrapper.in("id", resourceIds); - } - queryWrapper.eq("del_flag", ResourceEntityDelFlag.NORMAL.getFlag()).orderBy(true, isAsc, orderColumn); - List dtoList = ConvertUtils.sourceToTarget(Optional.ofNullable(resourceDao.selectPage(page, queryWrapper).getRecords()).orElse(new ArrayList<>()), ResourceDTO.class); - dtoList.forEach(temp -> { - Map p = new HashMap(); - p.put("resource_id", temp.getId()); - temp.setApplyCount(String.valueOf(tAbilityApplicationService.list(p).size())); - }); - return new PageData<>(dtoList, dtoList.size()); + return new PageData<>(recordLists, result.size()); } @Override 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 2fb9b622..b1b2f1fa 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 @@ -20,9 +20,9 @@ public interface ResourceCollectionDao extends BaseDao Integer deleteByIds(@Param("ids") Long[] ids); - List selectPageWithResource(@Param("params") Map params, - @Param("pageNum") Integer pageNum, - @Param("pageSize") Integer pageSize); + List selectWithResource(@Param("params") Map params); + + List selectWithFuse(@Param("params") Map params); Integer delete4Resource(@Param("resourceIds") List idList); diff --git a/renren-admin/src/main/java/io/renren/modules/resourceCollection/dto/ResourceCollectionDTO.java b/renren-admin/src/main/java/io/renren/modules/resourceCollection/dto/ResourceCollectionDTO.java index 3ab844d1..38a25edf 100644 --- a/renren-admin/src/main/java/io/renren/modules/resourceCollection/dto/ResourceCollectionDTO.java +++ b/renren-admin/src/main/java/io/renren/modules/resourceCollection/dto/ResourceCollectionDTO.java @@ -1,5 +1,6 @@ package io.renren.modules.resourceCollection.dto; +import io.renren.modules.fuse.dto.TbFuseDTO; import io.renren.modules.resource.dto.ResourceDTO; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -47,4 +48,6 @@ public class ResourceCollectionDTO implements Serializable { @ApiModelProperty(value = "资源信息") private ResourceDTO resourceDTO; + @ApiModelProperty(value = "融合服务信息") + private TbFuseDTO fuseDTO; } \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/resourceCollection/service/impl/ResourceCollectionServiceImpl.java b/renren-admin/src/main/java/io/renren/modules/resourceCollection/service/impl/ResourceCollectionServiceImpl.java index 5e52a12f..ee7e27b2 100644 --- a/renren-admin/src/main/java/io/renren/modules/resourceCollection/service/impl/ResourceCollectionServiceImpl.java +++ b/renren-admin/src/main/java/io/renren/modules/resourceCollection/service/impl/ResourceCollectionServiceImpl.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import io.renren.common.service.impl.CrudServiceImpl; +import io.renren.modules.fuse.service.TbFuseService; import io.renren.modules.resource.service.ResourceService; import io.renren.modules.resourceCollection.dao.ResourceCollectionDao; import io.renren.modules.resourceCollection.dto.ResourceCollectionDTO; @@ -16,6 +17,7 @@ import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.util.ArrayList; import java.util.Date; import java.util.HashMap; import java.util.List; @@ -37,6 +39,8 @@ public class ResourceCollectionServiceImpl extends CrudServiceImpl getWrapper(Map params) { @@ -51,11 +55,27 @@ public class ResourceCollectionServiceImpl extends CrudServiceImpl page = new Page(pageNum, pageSize); params.put("userId", user.getId()); - List resourceCollectionDTOS = resourceCollectionDao.selectPageWithResource(params, (pageNum - 1) * pageSize, pageSize); + List result=new ArrayList<>(); + List resourceCollectionDTOS = resourceCollectionDao.selectWithResource(params); resourceCollectionDTOS.forEach(item -> item.setResourceDTO(resourceService.selectWithAttrs(item.getResourceId()))); - List resourceCollectionDTOSs = resourceCollectionDao.selectPageWithResource(params, 0, 100000); - page.setRecords(resourceCollectionDTOS); - page.setTotal(resourceCollectionDTOSs.size()); + result.addAll(resourceCollectionDTOS); + if(params.get("type") == null || "".equals(params.get("type"))){ + List fuseCollectionDTOS = resourceCollectionDao.selectWithFuse(params); + fuseCollectionDTOS.forEach(item -> item.setFuseDTO(fuseService.getFuseById(item.getResourceId()))); + result.addAll(fuseCollectionDTOS); + } + int j = Math.min(pageNum * pageSize, result.size()); + if (result.isEmpty()) { + page.setRecords(null); + page.setTotal(0); + } else { + ArrayList recordLists = new ArrayList<>(); + for (int i = (pageNum - 1) * pageSize; i < j; i++) { + recordLists.add(result.get(i)); + } + page.setRecords(recordLists); + page.setTotal(result.size()); + } return page; } diff --git a/renren-admin/src/main/resources/mapper/fuse/TbFuseDao.xml b/renren-admin/src/main/resources/mapper/fuse/TbFuseDao.xml index f776af9a..aa4328e1 100644 --- a/renren-admin/src/main/resources/mapper/fuse/TbFuseDao.xml +++ b/renren-admin/src/main/resources/mapper/fuse/TbFuseDao.xml @@ -2,5 +2,84 @@ + + + + + + + + + + + + + + + + + + + + + + + \ 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 9ee51b7d..c95a38a1 100644 --- a/renren-admin/src/main/resources/mapper/resource/ResourceDao.xml +++ b/renren-admin/src/main/resources/mapper/resource/ResourceDao.xml @@ -1336,10 +1336,13 @@ + + + + + \ No newline at end of file From 1b46f676f2a36dfcdc8f53347a801f94ee079669 Mon Sep 17 00:00:00 2001 From: wangliwen Date: Mon, 11 Jul 2022 11:02:39 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E9=83=A8=E9=97=A8?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=20by=20name?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sys/controller/SysDeptController.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/renren-admin/src/main/java/io/renren/modules/sys/controller/SysDeptController.java b/renren-admin/src/main/java/io/renren/modules/sys/controller/SysDeptController.java index 2748b040..90101897 100644 --- a/renren-admin/src/main/java/io/renren/modules/sys/controller/SysDeptController.java +++ b/renren-admin/src/main/java/io/renren/modules/sys/controller/SysDeptController.java @@ -11,15 +11,13 @@ import io.renren.modules.sys.dto.SysDeptDTO; import io.renren.modules.sys.service.SysDeptService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.util.CollectionUtils; import org.springframework.web.bind.annotation.*; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; +import java.util.*; /** * 部门管理 @@ -47,9 +45,13 @@ public class SysDeptController { @ApiOperation("查询所有部门列表") @LogOperation("查询所有部门列表") // @RequiresPermissions("sys:dept:list") - public Result>> all() { - List> list = jdbcTemplate.queryForList("SELECT id,`name` FROM sys_dept;"); - + public Result>> all(String name) { + List> list = new ArrayList<>(); + if (StringUtils.isNotEmpty(name)) { + list = jdbcTemplate.queryForList(String.format("SELECT id,`name` FROM sys_dept WHERE `name` LIKE '%s';", name)); + } else { + list = jdbcTemplate.queryForList("SELECT id,`name` FROM sys_dept;"); + } return new Result>>().ok(list); }