专题资源树形结构

This commit is contained in:
cjw 2024-06-21 10:29:32 +08:00
parent c4a4fadfb4
commit 7c9343d6a6
10 changed files with 69 additions and 7 deletions

View File

@ -104,6 +104,16 @@ public class PortalController extends BaseController {
return resourceService.queryProtalPageList(bo, pageQuery);
}
/**
* 查询目录-专题资源
*/
@SaIgnore
@GetMapping("/resource/catalog/tree")
public R<List<Tree<Long>>> treeList(SysCatalogResourceBo bo) {
List<Tree<Long>> trees = resourceService.buildTreeSelect(bo);
return R.ok(trees);
}
/**
* 查询目录-专题资源

View File

@ -31,4 +31,5 @@ public interface SysOssResourceMapper extends BaseMapperPlus<SysOssResource, Sys
@Param(Constants.WRAPPER) Wrapper<SysOssTextbook> queryWrapper);
int addDownloadNum(Long id);
int addPreviewNum(Long id);
}

View File

@ -29,4 +29,5 @@ public interface SysOssTextbookMapper extends BaseMapperPlus<SysOssTextbook, Sys
@Param(Constants.WRAPPER) Wrapper<SysOssTextbook> queryWrapper);
int addDownloadNum(Long id);
int addPreviewNum(Long id);
}

View File

@ -1,6 +1,7 @@
package org.dromara.system.service;
import cn.hutool.core.lang.tree.Tree;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.mybatis.core.page.TableDataInfo;
@ -118,4 +119,12 @@ public interface ISysCatalogResourceService {
String selectCatalogNameById(Long catalogId);
List<SysCatalogResource> selectList(Wrapper<SysCatalogResource> queryWrapper);
/**
* 构建前端所需要下拉树结构
*
* @param bo 目录列表
* @return 下拉树结构列表
*/
List<Tree<Long>> buildTreeSelect(SysCatalogResourceBo bo);
}

View File

@ -114,10 +114,8 @@ public interface ISysCatalogTextbookService {
/**
* 构建前端所需要下拉树结构
*
* @param catalogs 目录列表
* @param bo 目录列表
* @return 下拉树结构列表
*/
//List<Tree<Long>> buildCatalogTreeSelect(List<SysCatalogTextbookVo> catalogs);
List<Tree<Long>> buildTreeSelect(SysCatalogTextbookBo bo);
}

View File

@ -1,6 +1,7 @@
package org.dromara.system.service;
import cn.hutool.core.lang.tree.Tree;
import jakarta.servlet.http.HttpServletResponse;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.mybatis.core.page.TableDataInfo;

View File

@ -2,6 +2,7 @@ package org.dromara.system.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.lang.tree.Tree;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@ -13,6 +14,7 @@ import org.dromara.common.core.constant.CacheNames;
import org.dromara.common.core.utils.MapstructUtils;
import org.dromara.common.core.utils.SpringUtils;
import org.dromara.common.core.utils.StringUtils;
import org.dromara.common.core.utils.TreeBuildUtils;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.common.mybatis.helper.DataBaseHelper;
@ -70,7 +72,7 @@ public class SysCatalogResourceServiceImpl implements ISysCatalogResourceService
}
/**
* 管理使用
* 管理使用,页面
*
* @param bo 查询条件
* @param pageQuery 分页参数
@ -210,6 +212,28 @@ public class SysCatalogResourceServiceImpl implements ISysCatalogResourceService
return baseMapper.selectList(queryWrapper);
}
@Override
public List<Tree<Long>> buildTreeSelect(SysCatalogResourceBo bo) {
LambdaQueryWrapper<SysCatalogResource> lqw = buildQueryWrapper(bo);
List<SysCatalogResourceVo> voList = baseMapper.selectVoList(lqw);
return buildCatalogTreeSelect(voList);
}
//@Override
private List<Tree<Long>> buildCatalogTreeSelect(List<SysCatalogResourceVo> catalogs) {
if (CollUtil.isEmpty(catalogs)) {
return CollUtil.newArrayList();
}
return TreeBuildUtils.build(catalogs, (catalog, tree) ->
tree.setId(catalog.getCatalogId())
.setParentId(catalog.getParentId())
.setName(catalog.getCatalogName())
.setWeight(catalog.getOrderNum())
.putExtra("type", catalog.getType())
);
}
/**
* 修改子元素关系
*

View File

@ -1,5 +1,7 @@
package org.dromara.system.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.lang.tree.Tree;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@ -12,14 +14,18 @@ import org.dromara.common.core.exception.ServiceException;
import org.dromara.common.core.utils.MapstructUtils;
import org.dromara.common.core.utils.StreamUtils;
import org.dromara.common.core.utils.StringUtils;
import org.dromara.common.core.utils.TreeBuildUtils;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.common.mybatis.helper.DataBaseHelper;
import org.dromara.system.domain.SysCatalogResource;
import org.dromara.system.domain.SysCatalogTextbook;
import org.dromara.system.domain.SysOssResource;
import org.dromara.system.domain.SysOssTextbook;
import org.dromara.system.domain.bo.SysCatalogTextbookBo;
import org.dromara.system.domain.bo.SysOssResourceBo;
import org.dromara.system.domain.vo.SysCatalogResourceVo;
import org.dromara.system.domain.vo.SysCatalogTextbookVo;
import org.dromara.system.domain.vo.SysOssResourceVo;
import org.dromara.system.domain.vo.SysOssVo;
import org.dromara.system.mapper.SysOssResourceMapper;
@ -223,4 +229,5 @@ public class SysOssResourceServiceImpl implements ISysOssResourceService {
ossService.download(ossResource.getOssId(), fileName, response);
baseMapper.addDownloadNum(id);
}
}

View File

@ -22,4 +22,10 @@
set download_num = download_num + 1
where id = #{id}
</update>
<update id="addPreviewNum">
update sys_oss_resource
set preview_num = preview_num + 1
where id = #{id}
</update>
</mapper>

View File

@ -1,9 +1,8 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.dromara.system.mapper.SysOssTextbookMapper">
<select id="selectPageList" resultType="org.dromara.system.domain.vo.SysOssTextbookVo">
select ot.*, o.volume
from sys_oss_textbook ot
@ -24,4 +23,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
set download_num = download_num + 1
where id = #{id}
</update>
<update id="addPreviewNum">
update sys_oss_textbook
set preview_num = preview_num + 1
where id = #{id}
</update>
</mapper>