为资源上传相关添加逻辑删除字段;统计取消自选租户id;新增门户统计

This commit is contained in:
cjw 2024-07-15 13:55:37 +08:00
parent 6cfb02aafb
commit 74df0be997
25 changed files with 281 additions and 110 deletions

View File

@ -0,0 +1,18 @@
package org.dromara.system.constant;
import java.util.List;
public interface FileTypeConstants {
List<String> PPT_TYPE = List.of(".ppt", ".pptx");
List<String> WORD_TYPE = List.of(".doc", ".docx");
List<String> EXCEL_TYPE = List.of(".xls", ".xlsx");
List<String> PDF_TYPE = List.of(".pdf");
List<String> TXT_TYPE = List.of(".txt");
List<String> IMAGE_TYPE = List.of(".jpg",".png",".jpeg",".gif",".bmp");
List<String> AUDIO_TYPE = List.of(".mp3",".wma");
List<String> VIDEO_TYPE = List.of(".mp4",".mov",".wmv",".flv",".avi",".mkv");
List<String> ZIP_TYPE = List.of(".rar",".zip");
}

View File

@ -41,6 +41,7 @@ public class StatisticController extends BaseController {
public R<Integer> getClassNum() {
return R.ok(statisticService.getCalssNum());
}
/**
* 获取总班级数
*/
@ -66,10 +67,20 @@ public class StatisticController extends BaseController {
}
/**
* 资源使用排行榜
* 资源类型统计-课件作业等
*/
@GetMapping("/oss/type")
public R<List<StatisticNumVo>> getOssType() {
return R.ok(statisticService.getOssType());
}
/**
* 资源使用排行榜
*/
@GetMapping("/upload/num")
public R<List<StatisticNumVo>> getUploadNum() {
return R.ok(statisticService.getUploadNum());
}
}

View File

@ -105,6 +105,18 @@ public class SysOssPersonController extends BaseController {
return toAjax(sysOssPersonService.moveByBo(bo));
}
/**
* 分享
*
* @param bo 主键串
*/
@SaCheckPermission("file:person:share")
@Log(title = "【分享我的空间】", businessType = BusinessType.UPDATE)
@PutMapping("/share")
public R<Void> share(@RequestBody SysOssPersonBo bo) {
return toAjax(sysOssPersonService.share(bo));
}
/**
* 下载
*

View File

@ -2,6 +2,7 @@ package org.dromara.system.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
@ -49,5 +50,11 @@ public class SysCatalogPerson extends TenantEntity {
*/
private Long orderNum;
/**
* 删除标志0代表存在 2代表删除
*/
@TableLogic
private String delFlag;
}

View File

@ -57,5 +57,12 @@ public class SysCatalogResource extends TenantEntity {
*/
private Long cover;
/**
* 删除标志0代表存在 2代表删除
*/
@TableLogic
private String delFlag;
}

View File

@ -2,6 +2,7 @@ package org.dromara.system.domain;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
@ -59,6 +60,12 @@ public class SysOssPerson extends TenantEntity {
*/
private String fileSuffix;
/**
* 删除标志0代表存在 2代表删除
*/
@TableLogic
private String delFlag;
@TableField(exist = false)
private Long use;
}

View File

@ -2,6 +2,7 @@ package org.dromara.system.domain;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
@ -55,6 +56,12 @@ public class SysOssResource extends TenantEntity {
private Long previewNum;
/**
* 删除标志0代表存在 2代表删除
*/
@TableLogic
private String delFlag;
@TableField(exist = false)
private Long use;

View File

@ -2,6 +2,7 @@ package org.dromara.system.domain;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
@ -59,6 +60,12 @@ public class SysOssTextbook extends TenantEntity {
private Long previewNum;
/**
* 删除标志0代表存在 2代表删除
*/
@TableLogic
private String delFlag;
@TableField(exist = false)
private Long use;
}

View File

@ -8,18 +8,21 @@ import java.util.List;
@Mapper
public interface StatisticMapper {
int selectGradeNum(@Param("tenantId") String tenantId);
int selectGradeNum();
int selectCalssNum(@Param("tenantId") String tenantId);
int selectCalssNum();
int selectTeacherNum(@Param("tenantId") String tenantId);
int selectTeacherNum();
int selectTextbookNum(@Param("tenantId") String tenantId);
int selectTextbookNum();
int selectResourceNum(@Param("tenantId") String tenantId);
int selectResourceNum();
List<StatisticNumVo> selectOssUse(@Param("tenantId") String tenantId);
List<StatisticNumVo> selectOssUse();
List<StatisticNumVo> selectOssType4Textbook();
int selectUploadNum(@Param("list") List<String> list, @Param("time") String time);
List<StatisticNumVo> selectOssType4Textbook(@Param("tenantId") String tenantId);
}

View File

@ -17,4 +17,6 @@ public interface SysCatalogPersonMapper extends BaseMapperPlus<SysCatalogPerson,
int addOrderNum(@Param("mix") Long mix, @Param("max") Long max);
int subOrderNum(@Param("mix") Long mix, @Param("max") Long max);
int selectMaxOrderNumByParentId(Long parentId);
}

View File

@ -25,4 +25,6 @@ public interface SysCatalogResourceMapper extends BaseMapperPlus<SysCatalogResou
int addOrderNum(@Param("mix") Long mix, @Param("max") Long max);
int subOrderNum(@Param("mix") Long mix, @Param("max") Long max);
int selectMaxOrderNumByParentId(Long parentId);
}

View File

@ -16,4 +16,5 @@ public interface IStatisticService {
List<StatisticNumVo> getOssUseRank();
List<StatisticNumVo> getOssType();
List<StatisticNumVo> getUploadNum();
}

View File

@ -74,4 +74,6 @@ public interface ISysOssPersonService {
void download(Long id, HttpServletResponse response) throws Exception;
String preview(Long id);
boolean share(SysOssPersonBo bo);
}

View File

@ -1,12 +1,14 @@
package org.dromara.system.service.impl;
import lombok.RequiredArgsConstructor;
import org.dromara.common.tenant.helper.TenantHelper;
import org.dromara.common.core.utils.DateUtils;
import org.dromara.system.constant.FileTypeConstants;
import org.dromara.system.domain.vo.StatisticNumVo;
import org.dromara.system.mapper.StatisticMapper;
import org.dromara.system.service.IStatisticService;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
@ -23,41 +25,35 @@ public class StatisticServiceImpl implements IStatisticService {
@Override
public int getGradeNum() {
String tenantId = getTenantId();
return statisticMapper.selectGradeNum(tenantId);
return statisticMapper.selectGradeNum();
}
@Override
public int getCalssNum() {
String tenantId = getTenantId();
return statisticMapper.selectCalssNum(tenantId);
return statisticMapper.selectCalssNum();
}
@Override
public int getTeacherNum() {
String tenantId = getTenantId();
return statisticMapper.selectTeacherNum(tenantId);
return statisticMapper.selectTeacherNum();
}
@Override
public int getOssNum() {
String tenantId = getTenantId();
int textbookNum = statisticMapper.selectTextbookNum(tenantId);
int resourceNum = statisticMapper.selectResourceNum(tenantId);
int textbookNum = statisticMapper.selectTextbookNum();
int resourceNum = statisticMapper.selectResourceNum();
return textbookNum + resourceNum;
}
@Override
public List<StatisticNumVo> getOssUseRank() {
String tenantId = getTenantId();
return statisticMapper.selectOssUse(tenantId);
return statisticMapper.selectOssUse();
}
@Override
public List<StatisticNumVo> getOssType() {
String tenantId = getTenantId();
List<StatisticNumVo> statisticNumVos = statisticMapper.selectOssType4Textbook(tenantId);
int resourceNum = statisticMapper.selectResourceNum(tenantId);
List<StatisticNumVo> statisticNumVos = statisticMapper.selectOssType4Textbook();
int resourceNum = statisticMapper.selectResourceNum();
StatisticNumVo resource = new StatisticNumVo();
resource.setName("专题资源");
resource.setValue(resourceNum);
@ -65,11 +61,55 @@ public class StatisticServiceImpl implements IStatisticService {
return statisticNumVos;
}
private String getTenantId() {
String tenantId = TenantHelper.getTenantId();
if ("000000".equals(tenantId)) {
tenantId = null;
}
return tenantId;
@Override
public List<StatisticNumVo> getUploadNum() {
String today = DateUtils.getDate() + " 00:00:00";
List<StatisticNumVo> list = new ArrayList<>(4);
//图片
int imageNum = statisticMapper.selectUploadNum(FileTypeConstants.IMAGE_TYPE, null);
int imageTodayNum = statisticMapper.selectUploadNum(FileTypeConstants.IMAGE_TYPE, today);
StatisticNumVo image = new StatisticNumVo();
image.setValue(imageNum);
image.setSpareValue(imageTodayNum);
image.setName("image");
list.add(image);
//文档
List<String> documentTypes = new ArrayList<>();
documentTypes.addAll(FileTypeConstants.PPT_TYPE);
documentTypes.addAll(FileTypeConstants.WORD_TYPE);
documentTypes.addAll(FileTypeConstants.EXCEL_TYPE);
documentTypes.addAll(FileTypeConstants.PDF_TYPE);
documentTypes.addAll(FileTypeConstants.TXT_TYPE);
int documentNum = statisticMapper.selectUploadNum(documentTypes, null);
int documentTodayNum = statisticMapper.selectUploadNum(documentTypes, today);
StatisticNumVo document = new StatisticNumVo();
document.setValue(documentNum);
document.setSpareValue(documentTodayNum);
document.setName("document");
list.add(document);
//视频
int videoNum = statisticMapper.selectUploadNum(FileTypeConstants.VIDEO_TYPE, null);
int videoTodayNum = statisticMapper.selectUploadNum(FileTypeConstants.VIDEO_TYPE, today);
StatisticNumVo video = new StatisticNumVo();
video.setValue(videoNum);
video.setSpareValue(videoTodayNum);
video.setName("video");
list.add(video);
//其他
List<String> otherTypes = new ArrayList<>();
otherTypes.addAll(FileTypeConstants.AUDIO_TYPE);
otherTypes.addAll(FileTypeConstants.ZIP_TYPE);
int otherNum = statisticMapper.selectUploadNum(otherTypes, null);
int otherTodayNum = statisticMapper.selectUploadNum(otherTypes, today);
StatisticNumVo other = new StatisticNumVo();
other.setValue(otherNum);
other.setSpareValue(otherTodayNum);
other.setName("other");
list.add(other);
return list;
}
}

View File

@ -77,6 +77,7 @@ public class SysCatalogPersonServiceImpl implements ISysCatalogPersonService {
lqw.like(StringUtils.isNotBlank(bo.getCatalogName()), SysCatalogPerson::getCatalogName, bo.getCatalogName());
lqw.eq(bo.getOrderNum() != null, SysCatalogPerson::getOrderNum, bo.getOrderNum());
lqw.eq(SysCatalogPerson::getCreateBy, bo.getCreateBy());
lqw.eq(SysCatalogPerson::getDelFlag, 0);
return lqw;
}
@ -88,9 +89,12 @@ public class SysCatalogPersonServiceImpl implements ISysCatalogPersonService {
*/
@Override
public Boolean insertByBo(SysCatalogPersonBo bo) {
SysCatalogPerson info = baseMapper.selectById(bo.getParentId());
Long parentId = bo.getParentId();
SysCatalogPerson info = baseMapper.selectById(parentId);
int orderNum = baseMapper.selectMaxOrderNumByParentId(parentId) + 1;
SysCatalogPerson add = MapstructUtils.convert(bo, SysCatalogPerson.class);
add.setAncestors(info.getAncestors() + StringUtils.SEPARATOR + add.getParentId());
add.setOrderNum((long) orderNum);
return baseMapper.insert(add) > 0;
}
@ -131,6 +135,8 @@ public class SysCatalogPersonServiceImpl implements ISysCatalogPersonService {
*/
@Override
public int deleteById(Long catalogId) {
SysCatalogPerson sysCatalogPerson = baseMapper.selectById(catalogId);
baseMapper.subOrderNum(sysCatalogPerson.getOrderNum(), null);
return baseMapper.deleteById(catalogId);
}
@ -139,6 +145,7 @@ public class SysCatalogPersonServiceImpl implements ISysCatalogPersonService {
boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysCatalogPerson>()
.eq(SysCatalogPerson::getCatalogName, resource.getCatalogName())
.eq(SysCatalogPerson::getParentId, resource.getParentId())
.eq(SysCatalogPerson::getDelFlag, 0)
.ne(ObjectUtil.isNotNull(resource.getCatalogId()), SysCatalogPerson::getCatalogId, resource.getCatalogId()));
return !exist;
}
@ -146,12 +153,14 @@ public class SysCatalogPersonServiceImpl implements ISysCatalogPersonService {
@Override
public boolean hasChildByCatalogId(Long catalogId) {
return baseMapper.exists(new LambdaQueryWrapper<SysCatalogPerson>()
.eq(SysCatalogPerson::getDelFlag, 0)
.eq(SysCatalogPerson::getParentId, catalogId));
}
@Override
public boolean checkCatalogExistFile(Long catalogId) {
return ossPersonMapper.exists(new LambdaQueryWrapper<SysOssPerson>()
.eq(SysOssPerson::getDelFlag, 0)
.eq(SysOssPerson::getCatalogId, catalogId));
}
@ -231,7 +240,8 @@ public class SysCatalogPersonServiceImpl implements ISysCatalogPersonService {
*/
private void updateDeptChildren(Long catalogId, String newAncestors, String oldAncestors) {
List<SysCatalogPerson> children = baseMapper.selectList(new LambdaQueryWrapper<SysCatalogPerson>()
.apply(DataBaseHelper.findInSet(catalogId, "ancestors")));
.apply(DataBaseHelper.findInSet(catalogId, "ancestors"))
.eq(SysCatalogPerson::getDelFlag, 0));
List<SysCatalogPerson> list = new ArrayList<>();
for (SysCatalogPerson child : children) {
SysCatalogPerson resource = new SysCatalogPerson();

View File

@ -82,6 +82,7 @@ public class SysCatalogResourceServiceImpl implements ISysCatalogResourceService
*/
@Override
public TableDataInfo<SysCatalogResourceVo> queryPageList(SysCatalogResourceBo bo, PageQuery pageQuery) {
//todo
Page<SysCatalogResourceVo> result = baseMapper.selectPageList(pageQuery.build(), bo.getCatalogId());
return TableDataInfo.build(result);
}
@ -112,6 +113,7 @@ public class SysCatalogResourceServiceImpl implements ISysCatalogResourceService
LambdaQueryWrapper<SysCatalogResource> lqw = Wrappers.lambdaQuery();
lqw.like(bo.getParentId() != null, SysCatalogResource::getAncestors, bo.getParentId());
lqw.eq(bo.getType() != null, SysCatalogResource::getType, bo.getType());
lqw.eq(SysCatalogResource::getDelFlag, 0);
return lqw;
}
@ -123,9 +125,12 @@ public class SysCatalogResourceServiceImpl implements ISysCatalogResourceService
*/
@Override
public Boolean insertByBo(SysCatalogResourceBo bo) {
SysCatalogResource info = baseMapper.selectById(bo.getParentId());
Long parentId = bo.getParentId();
SysCatalogResource info = baseMapper.selectById(parentId);
int orderNum = baseMapper.selectMaxOrderNumByParentId(parentId) + 1;
SysCatalogResource add = MapstructUtils.convert(bo, SysCatalogResource.class);
add.setAncestors(info.getAncestors() + StringUtils.SEPARATOR + add.getParentId());
add.setOrderNum((long) orderNum);
String[] split = StringUtils.split(add.getAncestors(), StringUtils.SEPARATOR);
if (split.length < 3) {
add.setType(split.length);
@ -172,6 +177,8 @@ public class SysCatalogResourceServiceImpl implements ISysCatalogResourceService
*/
@Override
public int deleteById(Long catalogId) {
SysCatalogResource sysCatalogResource = baseMapper.selectById(catalogId);
baseMapper.subOrderNum(sysCatalogResource.getOrderNum(), null);
return baseMapper.deleteById(catalogId);
}
@ -180,6 +187,7 @@ public class SysCatalogResourceServiceImpl implements ISysCatalogResourceService
boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysCatalogResource>()
.eq(SysCatalogResource::getCatalogName, resource.getCatalogName())
.eq(SysCatalogResource::getParentId, resource.getParentId())
.eq(SysCatalogResource::getDelFlag, 0)
.ne(ObjectUtil.isNotNull(resource.getCatalogId()), SysCatalogResource::getCatalogId, resource.getCatalogId()));
return !exist;
}
@ -187,12 +195,14 @@ public class SysCatalogResourceServiceImpl implements ISysCatalogResourceService
@Override
public boolean hasChildByCatalogId(Long catalogId) {
return baseMapper.exists(new LambdaQueryWrapper<SysCatalogResource>()
.eq(SysCatalogResource::getDelFlag, 0)
.eq(SysCatalogResource::getParentId, catalogId));
}
@Override
public boolean checkCatalogExistFile(Long catalogId) {
return ossResourceMapper.exists(new LambdaQueryWrapper<SysOssResource>()
.eq(SysOssResource::getDelFlag, 0)
.eq(SysOssResource::getCatalogId, catalogId));
}
@ -294,6 +304,7 @@ public class SysCatalogResourceServiceImpl implements ISysCatalogResourceService
*/
private void updateDeptChildren(Long catalogId, String newAncestors, String oldAncestors) {
List<SysCatalogResource> children = baseMapper.selectList(new LambdaQueryWrapper<SysCatalogResource>()
.eq(SysCatalogResource::getDelFlag, 0)
.apply(DataBaseHelper.findInSet(catalogId, "ancestors")));
List<SysCatalogResource> list = new ArrayList<>();
for (SysCatalogResource child : children) {

View File

@ -75,6 +75,7 @@ public class SysCatalogTextbookServiceImpl implements ISysCatalogTextbookService
@Override
public TableDataInfo<SysCatalogTextbookVo> queryPageList(SysCatalogTextbookBo bo, PageQuery pageQuery) {
//todo
Page<SysCatalogTextbookVo> result = baseMapper.selectPageUserList(pageQuery.build(), bo.getCatalogId());
return TableDataInfo.build(result);
}
@ -85,6 +86,7 @@ public class SysCatalogTextbookServiceImpl implements ISysCatalogTextbookService
//lqw.eq(bo.getParentId() != null, SysCatalogTextbook::getParentId, bo.getParentId());
lqw.like(bo.getParentId() != null, SysCatalogTextbook::getAncestors, bo.getParentId());
lqw.le(bo.getType() != null, SysCatalogTextbook::getType, bo.getType());
lqw.eq(SysCatalogTextbook::getDelFlag, 0);
return lqw;
}
@ -149,6 +151,8 @@ public class SysCatalogTextbookServiceImpl implements ISysCatalogTextbookService
*/
@Override
public int deleteById(Long catalogId) {
SysCatalogTextbook sysCatalogTextbook = baseMapper.selectById(catalogId);
baseMapper.subOrderNum(sysCatalogTextbook.getOrderNum(), null);
return baseMapper.deleteById(catalogId);
}
@ -157,6 +161,7 @@ public class SysCatalogTextbookServiceImpl implements ISysCatalogTextbookService
boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysCatalogTextbook>()
.eq(SysCatalogTextbook::getCatalogName, textbook.getCatalogName())
.eq(SysCatalogTextbook::getParentId, textbook.getParentId())
.eq(SysCatalogTextbook::getDelFlag, 0)
.ne(ObjectUtil.isNotNull(textbook.getCatalogId()), SysCatalogTextbook::getCatalogId, textbook.getCatalogId()));
return !exist;
}
@ -164,12 +169,14 @@ public class SysCatalogTextbookServiceImpl implements ISysCatalogTextbookService
@Override
public boolean hasChildByCatalogId(Long catalogId) {
return baseMapper.exists(new LambdaQueryWrapper<SysCatalogTextbook>()
.eq(SysCatalogTextbook::getDelFlag, 0)
.eq(SysCatalogTextbook::getParentId, catalogId));
}
@Override
public boolean checkCatalogExistFile(Long catalogId) {
return ossTextbookMapper.exists(new LambdaQueryWrapper<SysOssTextbook>()
.eq(SysOssTextbook::getDelFlag, 0)
.eq(SysOssTextbook::getCatalogId, catalogId));
}
@ -277,6 +284,7 @@ public class SysCatalogTextbookServiceImpl implements ISysCatalogTextbookService
*/
private void updateCatalogChildren(Long catalogId, String newAncestors, String oldAncestors) {
List<SysCatalogTextbook> children = baseMapper.selectList(new LambdaQueryWrapper<SysCatalogTextbook>()
.eq(SysCatalogTextbook::getDelFlag, 0)
.apply(DataBaseHelper.findInSet(catalogId, "ancestors")));
List<SysCatalogTextbook> list = new ArrayList<>();
for (SysCatalogTextbook child : children) {

View File

@ -18,12 +18,15 @@ import org.dromara.common.mybatis.helper.DataBaseHelper;
import org.dromara.common.satoken.utils.LoginHelper;
import org.dromara.system.domain.SysCatalogPerson;
import org.dromara.system.domain.SysOssPerson;
import org.dromara.system.domain.SysOssTextbook;
import org.dromara.system.domain.bo.SysOssPersonBo;
import org.dromara.system.domain.vo.SysCatalogPersonVo;
import org.dromara.system.domain.vo.SysOssPersonVo;
import org.dromara.system.domain.vo.SysOssVo;
import org.dromara.system.mapper.SysOssPersonMapper;
import org.dromara.system.mapper.SysOssTextbookMapper;
import org.dromara.system.service.ISysCatalogPersonService;
import org.dromara.system.service.ISysCatalogTextbookService;
import org.dromara.system.service.ISysOssPersonService;
import org.dromara.system.service.ISysOssService;
import org.springframework.stereotype.Service;
@ -47,6 +50,10 @@ public class SysOssPersonServiceImpl implements ISysOssPersonService {
private final ISysOssService ossService;
private final SysOssTextbookMapper textbookMapper;
private final ISysCatalogTextbookService catalogTextbookService;
/**
* 查询资源-我的空间
*
@ -85,7 +92,8 @@ public class SysOssPersonServiceImpl implements ISysOssPersonService {
private Wrapper<SysOssPerson> buildQueryWrapper(SysOssPersonBo bo) {
QueryWrapper<SysOssPerson> wrapper = Wrappers.query();
wrapper.eq(ObjectUtil.isNotNull(bo.getCreateBy()), "op.create_by", bo.getCreateBy())
wrapper.eq("op.del_flag", 0)
.eq(ObjectUtil.isNotNull(bo.getCreateBy()), "op.create_by", bo.getCreateBy())
.eq(ObjectUtil.isNotNull(bo.getType()), "op.type", bo.getType())
.eq(StringUtils.isNotEmpty(bo.getFileSuffix()), "op.file_suffix", bo.getFileSuffix())
.like(StringUtils.isNotEmpty(bo.getFileName()), "op.file_name", bo.getFileName())
@ -217,4 +225,17 @@ public class SysOssPersonServiceImpl implements ISysOssPersonService {
SysOssPerson ossPerson = baseMapper.selectById(id);
return ossService.getUrlById(ossPerson.getOssId());
}
@Override
public boolean share(SysOssPersonBo bo) {
SysOssPerson ossPerson = baseMapper.selectById(bo.getId());
SysOssTextbook date = new SysOssTextbook();
String path = catalogTextbookService.selectCatalogNameById(bo.getCatalogId());
date.setCatalogId(bo.getCatalogId());
date.setFileName(ossPerson.getFileName());
date.setFileSuffix(ossPerson.getFileSuffix());
date.setFilePath(path);
date.setType(ossPerson.getType());
return textbookMapper.insert(date) > 0;
}
}

View File

@ -75,6 +75,7 @@ public class SysOssResourceServiceImpl implements ISysOssResourceService {
public TableDataInfo<SysOssResourceVo> queryAwaitPageList(SysOssResourceBo bo, PageQuery pageQuery) {
QueryWrapper<SysOssResource> wrapper = Wrappers.query();
wrapper.le("r.status", 0)
.eq("r.del_flag", 0)
.eq(StringUtils.isNotEmpty(bo.getFileSuffix()), "r.file_suffix", bo.getFileSuffix())
.like(StringUtils.isNotEmpty(bo.getFileName()), "r.file_name", bo.getFileName())
.orderByDesc("r.create_time");
@ -104,7 +105,8 @@ public class SysOssResourceServiceImpl implements ISysOssResourceService {
private Wrapper<SysOssResource> buildQueryWrapper(SysOssResourceBo bo) {
QueryWrapper<SysOssResource> wrapper = Wrappers.query();
wrapper.eq(ObjectUtil.isNotNull(bo.getStatus()), "r.status", bo.getStatus())
wrapper.eq("r.del_flag", 0)
.eq(ObjectUtil.isNotNull(bo.getStatus()), "r.status", bo.getStatus())
.eq(StringUtils.isNotEmpty(bo.getFileSuffix()), "r.file_suffix", bo.getFileSuffix())
.like(StringUtils.isNotEmpty(bo.getFileName()), "r.file_name", bo.getFileName())
.and(ObjectUtil.isNotNull(bo.getCatalogId()), w -> {

View File

@ -1,5 +1,6 @@
package org.dromara.system.service.impl;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@ -15,6 +16,7 @@ import org.dromara.common.core.utils.StringUtils;
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.constant.FileTypeConstants;
import org.dromara.system.domain.SysCatalogTextbook;
import org.dromara.system.domain.SysOssTextbook;
import org.dromara.system.domain.bo.SysOssTextbookBo;
@ -77,6 +79,7 @@ public class SysOssTextbookServiceImpl implements ISysOssTextbookService {
QueryWrapper<SysOssTextbook> wrapper = Wrappers.query();
wrapper.le("ot.status", 0)
.eq("ot.del_flag", 0)
.eq(StringUtils.isNotEmpty(bo.getFileSuffix()), "ot.file_suffix", bo.getFileSuffix())
.like(StringUtils.isNotEmpty(bo.getFileName()), "ot.file_name", bo.getFileName())
// .and(ObjectUtil.isNotNull(bo.getCatalogId()), w -> {
@ -96,6 +99,7 @@ public class SysOssTextbookServiceImpl implements ISysOssTextbookService {
public Long countAwaitList(SysOssTextbookBo bo) {
LambdaQueryWrapper<SysOssTextbook> wrapper = Wrappers.lambdaQuery();
wrapper.eq(SysOssTextbook::getStatus, -1)
.eq(SysOssTextbook::getDelFlag, 0)
.eq(StringUtils.isNotEmpty(bo.getFileSuffix()), SysOssTextbook::getFileSuffix, bo.getFileSuffix())
.like(StringUtils.isNotEmpty(bo.getFileName()), SysOssTextbook::getFileName, bo.getFileName());
return baseMapper.selectCount(wrapper);
@ -114,7 +118,8 @@ public class SysOssTextbookServiceImpl implements ISysOssTextbookService {
private Wrapper<SysOssTextbook> buildQueryWrapper(SysOssTextbookBo bo) {
QueryWrapper<SysOssTextbook> wrapper = Wrappers.query();
wrapper.eq(ObjectUtil.isNotNull(bo.getType()), "ot.type", bo.getType())
wrapper.eq("ot.del_flag", 0)
.eq(ObjectUtil.isNotNull(bo.getType()), "ot.type", bo.getType())
.eq(ObjectUtil.isNotNull(bo.getStatus()), "ot.status", bo.getStatus())
.eq(StringUtils.isNotEmpty(bo.getFileSuffix()), "ot.file_suffix", bo.getFileSuffix())
.like(StringUtils.isNotEmpty(bo.getFileName()), "ot.file_name", bo.getFileName())
@ -129,11 +134,7 @@ public class SysOssTextbookServiceImpl implements ISysOssTextbookService {
.and(ObjectUtil.isNotNull(bo.getFormatSuffix()), w -> {
Integer format = bo.getFormatSuffix();
List<String> list = processFormatSuffixQuery(format);
if (7 == format) {
w.notIn("ot.file_suffix", list);
} else {
w.in("ot.file_suffix", list);
}
w.in(ArrayUtil.isEmpty(list), "ot.file_suffix", list);
});
String orderByColumn = bo.getOrderByColumn();
if (StringUtils.isNotEmpty(orderByColumn)) {
@ -295,60 +296,36 @@ public class SysOssTextbookServiceImpl implements ISysOssTextbookService {
}
private List<String> processFormatSuffixQuery(int format) {
List<String> list = new ArrayList<>(18);
switch (format) {
case 1 -> {
list.add(".ppt");
list.add(".pptx");
return FileTypeConstants.PPT_TYPE;
}
case 2 -> {
list.add(".doc");
list.add(".docx");
return FileTypeConstants.WORD_TYPE;
}
case 3 -> {
return FileTypeConstants.PDF_TYPE;
}
case 3 -> list.add(".pdf");
case 4 -> {
list.add(".jpg");
list.add(".png");
list.add(".jpeg");
list.add(".gif");
list.add(".bmp");
return FileTypeConstants.IMAGE_TYPE;
}
case 5 -> {
list.add(".mp3");
list.add(".wma");
return FileTypeConstants.AUDIO_TYPE;
}
case 6 -> {
list.add(".mp4");
list.add(".mov");
list.add(".wmv");
list.add(".flv");
list.add(".avi");
list.add(".mkv");
return FileTypeConstants.VIDEO_TYPE;
}
case 7 -> {
list.add(".ppt");
list.add(".pptx");
list.add(".doc");
list.add(".docx");
list.add(".pdf");
list.add(".jpg");
list.add(".png");
list.add(".jpeg");
list.add(".gif");
list.add(".bmp");
list.add(".mp3");
list.add(".wma");
list.add(".mp4");
list.add(".mov");
list.add(".wmv");
list.add(".flv");
list.add(".avi");
list.add(".mkv");
List<String> list = new ArrayList<>();
list.addAll(FileTypeConstants.ZIP_TYPE);
list.addAll(FileTypeConstants.EXCEL_TYPE);
list.addAll(FileTypeConstants.TXT_TYPE);
return list;
}
default -> {
return null;
}
}
return list;
}
}

View File

@ -5,50 +5,38 @@
<mapper namespace="org.dromara.system.mapper.StatisticMapper">
<select id="selectGradeNum" resultType="int">
select count(d.dept_id)
from sys_dept d left join sys_dept p on p.dept_id = d.parent_id
where p.parent_id = 0
<if test="tenantId != null and tenantId != ''">
and d.tenant_id = #{tenantId}
</if>
from sys_dept d
left join sys_dept p on p.dept_id = d.parent_id
where p.parent_id = 0
and d.del_flag = 0
</select>
<select id="selectCalssNum" resultType="int">
select count(d.dept_id)
from sys_dept d
left join sys_dept p on d.parent_id = p.dept_id
left join sys_dept pp on pp.dept_id = p.parent_id
left join sys_dept pp on pp.dept_id = p.parent_id
where pp.parent_id = 0
<if test="tenantId != null and tenantId != ''">
and d.tenant_id = #{tenantId}
</if>
and d.del_flag = 0
</select>
<select id="selectTeacherNum" resultType="int">
select count(*)
from sys_teacher
<where>
<if test="tenantId != null and tenantId != ''">
and tenant_id = #{tenantId}
</if>
</where>
</select>
<select id="selectTextbookNum" resultType="int">
select count(*)
from sys_oss_textbook
where status = 1
<if test="tenantId != null and tenantId != ''">
and tenant_id = #{tenantId}
</if>
and del_flag = 0
</select>
<select id="selectResourceNum" resultType="int">
select count(*) as rNum
from sys_oss_resource
where status = 1
<if test="tenantId != null and tenantId != ''">
and tenant_id = #{tenantId}
</if>
and del_flag = 0
</select>
<select id="selectOssUse" resultType="org.dromara.system.domain.vo.StatisticNumVo">
@ -57,17 +45,13 @@
CONCAT(file_path, '/', file_name) as name
from sys_oss_resource
where status = 1
<if test="tenantId != null and tenantId != ''">
and tenant_id = #{tenantId}
</if>
and del_flag = 0
union all
select download_num as value,
CONCAT(file_path, '/', file_name) as name
from sys_oss_textbook
where status = 1
<if test="tenantId != null and tenantId != ''">
and tenant_id = #{tenantId}
</if>
and del_flag = 0
) t
order by t.value desc
limit 10
@ -83,9 +67,24 @@
end as `name`
from sys_oss_textbook
where status = 1
<if test="tenantId != null and tenantId != ''">
and tenant_id = #{tenantId}
</if>
and del_flag = 0
group by type
</select>
<select id="selectUploadNum" resultType="int">
select count(*)
from sys_oss_textbook
where status = 1
and del_flag = 0
<if test="list != null and list.size() != 0">
and file_suffix in
<foreach collection="list" close=")" open="(" separator="," item="fileSuffix">
#{fileSuffix}
</foreach>
</if>
<if test="time != null and time != ''">
and create_time &gt;= #{time}
</if>
</select>
</mapper>

View File

@ -30,4 +30,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</where>
</update>
<select id="selectMaxOrderNumByParentId" resultType="int">
select IFNULL(Max(order_num), 0)
from sys_catalog_person
where parent_id = #{parentId}
and del_flag = 0
</select>
</mapper>

View File

@ -21,8 +21,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
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
left join sys_oss_resource r on r.catalog_id = cr.catalog_id and r.status = 1 and r.del_flag = 0
where cr.type = 2
and cr.del_flag = 0
and cr.tenant_id = #{tenantId}
group by cr.catalog_id
</select>
@ -33,6 +34,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
left join sys_oss_resource r on r.catalog_id = cr.catalog_id
where cr.tenant_id = #{tenantId}
and r.status = 1
and cr.del_flag = 0
and r.del_flag = 0
and FIND_IN_SET(#{catalogId}, cr.ancestors)
</select>
@ -61,4 +64,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if>
</where>
</update>
<select id="selectMaxOrderNumByParentId" resultType="int">
select IFNULL(Max(order_num), 0)
from sys_catalog_resource
where parent_id = #{parentId}
and del_flag = 0
</select>
</mapper>

View File

@ -14,9 +14,10 @@
</select>
<select id="selectMaxOrderNumByParentId" resultType="int">
select IFNULL(Max(order_num),0)
select IFNULL(Max(order_num), 0)
from sys_catalog_textbook
where parent_id = #{parentId}
and del_flag = 0
</select>
<update id="addOrderNum">

View File

@ -2,6 +2,6 @@
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.dromara.system.mapper.SysLogininforMapper">
<mapper namespace="org.dromara.system.mapper.SysLoginincatalog:person:Mapper">
</mapper>