门户资源分页查询优化;资源容量优化
This commit is contained in:
parent
a786d1b81a
commit
c72b8f2aba
|
@ -43,4 +43,6 @@ public class SysOssVolumeVo implements Serializable {
|
|||
*/
|
||||
private Long useVolume;
|
||||
private String useVolumename;
|
||||
|
||||
private String volumePercent;
|
||||
}
|
||||
|
|
|
@ -17,5 +17,8 @@ import org.dromara.system.domain.vo.SysCatalogResourceVo;
|
|||
@Mapper
|
||||
public interface SysCatalogResourceMapper extends BaseMapperPlus<SysCatalogResource, SysCatalogResourceVo> {
|
||||
Page<SysCatalogResourceVo> selectPageList(@Param("page") Page<SysCatalogResource> page, @Param("catalogId") Long catalogId);
|
||||
Page<SysCatalogResourceVo> selectProtalPageList(@Param("page") Page<SysCatalogResource> page,@Param("tenantId") String tenantId);
|
||||
|
||||
Page<SysCatalogResourceVo> selectProtalPageList(@Param("page") Page<SysCatalogResource> page, @Param("tenantId") String tenantId);
|
||||
|
||||
long selectChildFileNumById(@Param("tenantId") String tenantId, @Param("catalogId") Long catalogId);
|
||||
}
|
||||
|
|
|
@ -98,6 +98,10 @@ public class SysCatalogResourceServiceImpl implements ISysCatalogResourceService
|
|||
//临时存放
|
||||
String tenantId = bo.getAncestors();
|
||||
IPage<SysCatalogResourceVo> result = baseMapper.selectProtalPageList(pageQuery.build(), tenantId);
|
||||
for (SysCatalogResourceVo record : result.getRecords()) {
|
||||
long count = baseMapper.selectChildFileNumById(tenantId, record.getCatalogId());
|
||||
record.setResourceNum(record.getResourceNum() + count);
|
||||
}
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
|
|
|
@ -43,6 +43,8 @@ import org.springframework.stereotype.Service;
|
|||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.*;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
@ -377,10 +379,16 @@ public class SysOssServiceImpl implements ISysOssService, OssService {
|
|||
@Override
|
||||
public SysOssVolumeVo getVolumeVoByType(Integer type) {
|
||||
SysOssVolumeVo ossVolumeVo = volumeMapper.selectVoOne(new LambdaQueryWrapper<SysOssVolume>().eq(SysOssVolume::getType, type));
|
||||
String totalName = DataSizeUtil.format(ossVolumeVo.getTotalVolume());
|
||||
String useName = DataSizeUtil.format(ossVolumeVo.getUseVolume());
|
||||
Long totalVolume = ossVolumeVo.getTotalVolume();
|
||||
Long useVolume = ossVolumeVo.getUseVolume();
|
||||
String totalName = DataSizeUtil.format(totalVolume);
|
||||
String useName = DataSizeUtil.format(useVolume);
|
||||
ossVolumeVo.setTotalVolumeName(totalName);
|
||||
ossVolumeVo.setUseVolumename(useName);
|
||||
int i = BigDecimal.valueOf(useVolume)
|
||||
.divide(BigDecimal.valueOf(totalVolume), 2, RoundingMode.HALF_UP)
|
||||
.multiply(BigDecimal.valueOf(100)).intValue();
|
||||
ossVolumeVo.setVolumePercent(i + "%");
|
||||
return ossVolumeVo;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,24 +15,25 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</select>
|
||||
|
||||
<select id="selectProtalPageList" resultType="org.dromara.system.domain.vo.SysCatalogResourceVo">
|
||||
with recursive cte as (select *
|
||||
from sys_catalog_resource
|
||||
where type = 2
|
||||
and del_flag = 0
|
||||
and tenant_id = #{tenantId}
|
||||
union all
|
||||
select d.*
|
||||
from sys_catalog_resource d
|
||||
inner join cte on d.parent_id = cte.catalog_id
|
||||
where d.del_flag = 0
|
||||
and d.tenant_id = #{tenantId})
|
||||
select t.catalog_id as catalogId,
|
||||
any_value(t.catalog_name) as catalogName,
|
||||
any_value(t.create_time) as createTime,
|
||||
any_value(t.cover) as coverUrl,
|
||||
count(r.id) as resourceNum
|
||||
from cte t
|
||||
left join sys_oss_resource r on r.catalog_id = t.catalog_id and r.status = 1
|
||||
group by t.catalog_id
|
||||
select cr.catalog_id as catalogId,
|
||||
cr.catalog_name as catalogName,
|
||||
cr.create_time as createTime,
|
||||
cr.cover as coverUrl,
|
||||
count(r.id) as resourceNum
|
||||
from sys_catalog_resource cr
|
||||
left join sys_oss_resource r on r.catalog_id = cr.catalog_id and r.status = 1
|
||||
where cr.type = 2
|
||||
and cr.del_flag = 0
|
||||
and cr.tenant_id = #{tenantId}
|
||||
group by cr.catalog_id
|
||||
</select>
|
||||
|
||||
<select id="selectChildFileNumById" resultType="long">
|
||||
select count(*)
|
||||
from sys_catalog_resource cr
|
||||
left join sys_oss_resource r on r.catalog_id = cr.catalog_id
|
||||
where cr.tenant_id = #{tenantId}
|
||||
and r.status = 1
|
||||
and FIND_IN_SET(#{catalogId}, cr.ancestors)
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
Loading…
Reference in New Issue