上传文件新增容量字段。同步教材分页查询添加信息;
This commit is contained in:
parent
3d65a43faf
commit
4eefdb279d
|
@ -60,7 +60,7 @@ public class SysOssResourceController extends BaseController {
|
||||||
* 新增【请填写功能名称】
|
* 新增【请填写功能名称】
|
||||||
*/
|
*/
|
||||||
@SaCheckPermission("file:resource:add")
|
@SaCheckPermission("file:resource:add")
|
||||||
@Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
|
@Log(title = "【新增专题资源】", businessType = BusinessType.INSERT)
|
||||||
@RepeatSubmit()
|
@RepeatSubmit()
|
||||||
@PostMapping()
|
@PostMapping()
|
||||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody SysOssResourceBo bo) {
|
public R<Void> add(@Validated(AddGroup.class) @RequestBody SysOssResourceBo bo) {
|
||||||
|
@ -71,7 +71,7 @@ public class SysOssResourceController extends BaseController {
|
||||||
* 修改【请填写功能名称】
|
* 修改【请填写功能名称】
|
||||||
*/
|
*/
|
||||||
@SaCheckPermission("file:resource:edit")
|
@SaCheckPermission("file:resource:edit")
|
||||||
@Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
|
@Log(title = "【更新专题资源】", businessType = BusinessType.UPDATE)
|
||||||
@RepeatSubmit()
|
@RepeatSubmit()
|
||||||
@PutMapping()
|
@PutMapping()
|
||||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody SysOssResourceBo bo) {
|
public R<Void> edit(@Validated(EditGroup.class) @RequestBody SysOssResourceBo bo) {
|
||||||
|
@ -84,10 +84,21 @@ public class SysOssResourceController extends BaseController {
|
||||||
* @param ossIds 主键串
|
* @param ossIds 主键串
|
||||||
*/
|
*/
|
||||||
@SaCheckPermission("file:resource:remove")
|
@SaCheckPermission("file:resource:remove")
|
||||||
@Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
|
@Log(title = "【删除专题资源】", businessType = BusinessType.DELETE)
|
||||||
@DeleteMapping("/{ossIds}")
|
@DeleteMapping("/{ossIds}")
|
||||||
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||||
@PathVariable Long[] ossIds) {
|
@PathVariable Long[] ossIds) {
|
||||||
return toAjax(sysOssResourceService.deleteWithValidByIds(List.of(ossIds), true));
|
return toAjax(sysOssResourceService.deleteWithValidByIds(List.of(ossIds), true));
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* 审核
|
||||||
|
*
|
||||||
|
* @param bo 主键串
|
||||||
|
*/
|
||||||
|
@SaCheckPermission("file:textbook:review")
|
||||||
|
@Log(title = "【审核专题资源】", businessType = BusinessType.UPDATE)
|
||||||
|
@PutMapping("/review")
|
||||||
|
public R<Void> review(@RequestBody SysOssResourceBo bo) {
|
||||||
|
return toAjax(sysOssResourceService.reviewByBo(bo));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,7 +61,7 @@ public class SysOssTextbookController extends BaseController {
|
||||||
* 新增【请填写功能名称】
|
* 新增【请填写功能名称】
|
||||||
*/
|
*/
|
||||||
@SaCheckPermission("file:textbook:add")
|
@SaCheckPermission("file:textbook:add")
|
||||||
@Log(title = "【新增同步教材资源】", businessType = BusinessType.INSERT)
|
@Log(title = "【新增同步教材】", businessType = BusinessType.INSERT)
|
||||||
@RepeatSubmit()
|
@RepeatSubmit()
|
||||||
@PostMapping()
|
@PostMapping()
|
||||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody SysOssTextbookBo bo) {
|
public R<Void> add(@Validated(AddGroup.class) @RequestBody SysOssTextbookBo bo) {
|
||||||
|
@ -72,7 +72,7 @@ public class SysOssTextbookController extends BaseController {
|
||||||
* 修改【请填写功能名称】
|
* 修改【请填写功能名称】
|
||||||
*/
|
*/
|
||||||
@SaCheckPermission("file:textbook:edit")
|
@SaCheckPermission("file:textbook:edit")
|
||||||
@Log(title = "【更新同步教材资源】", businessType = BusinessType.UPDATE)
|
@Log(title = "【更新同步教材】", businessType = BusinessType.UPDATE)
|
||||||
@RepeatSubmit()
|
@RepeatSubmit()
|
||||||
@PutMapping()
|
@PutMapping()
|
||||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody SysOssTextbookBo bo) {
|
public R<Void> edit(@Validated(EditGroup.class) @RequestBody SysOssTextbookBo bo) {
|
||||||
|
@ -85,7 +85,7 @@ public class SysOssTextbookController extends BaseController {
|
||||||
* @param ossIds 主键串
|
* @param ossIds 主键串
|
||||||
*/
|
*/
|
||||||
@SaCheckPermission("file:textbook:remove")
|
@SaCheckPermission("file:textbook:remove")
|
||||||
@Log(title = "【删除同步教材资源】", businessType = BusinessType.DELETE)
|
@Log(title = "【删除同步教材】", businessType = BusinessType.DELETE)
|
||||||
@DeleteMapping("/{ossIds}")
|
@DeleteMapping("/{ossIds}")
|
||||||
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||||
@PathVariable Long[] ossIds) {
|
@PathVariable Long[] ossIds) {
|
||||||
|
@ -98,9 +98,34 @@ public class SysOssTextbookController extends BaseController {
|
||||||
* @param bo 主键串
|
* @param bo 主键串
|
||||||
*/
|
*/
|
||||||
@SaCheckPermission("file:textbook:review")
|
@SaCheckPermission("file:textbook:review")
|
||||||
@Log(title = "【审核同步教材资源】", businessType = BusinessType.UPDATE)
|
@Log(title = "【审核同步教材】", businessType = BusinessType.UPDATE)
|
||||||
@DeleteMapping("/review")
|
@PutMapping("/review")
|
||||||
public R<Void> review(@RequestBody SysOssTextbookBo bo) {
|
public R<Void> review(@RequestBody SysOssTextbookBo bo) {
|
||||||
return toAjax(sysOssTextbookService.reviewByBo(bo));
|
return toAjax(sysOssTextbookService.reviewByBo(bo));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 审核
|
||||||
|
*
|
||||||
|
* @param bo 主键串
|
||||||
|
*/
|
||||||
|
@SaCheckPermission("file:textbook:copy")
|
||||||
|
@Log(title = "【审核同步教材】", businessType = BusinessType.UPDATE)
|
||||||
|
@PutMapping("/copy")
|
||||||
|
public R<Void> copy(@RequestBody SysOssTextbookBo bo) {
|
||||||
|
return toAjax(sysOssTextbookService.copyByBo(bo));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 移动
|
||||||
|
*
|
||||||
|
* @param bo 主键串
|
||||||
|
*/
|
||||||
|
@SaCheckPermission("file:textbook:move")
|
||||||
|
@Log(title = "【移动同步教材】", businessType = BusinessType.UPDATE)
|
||||||
|
@PutMapping("/move")
|
||||||
|
public R<Void> move(@RequestBody SysOssTextbookBo bo) {
|
||||||
|
return toAjax(sysOssTextbookService.moveByBo(bo));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,11 @@ public class SysOss extends BaseEntity {
|
||||||
*/
|
*/
|
||||||
private String url;
|
private String url;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 容量
|
||||||
|
*/
|
||||||
|
private String volume;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 服务商
|
* 服务商
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -46,6 +46,11 @@ public class SysOssBo extends BaseEntity {
|
||||||
*/
|
*/
|
||||||
private String url;
|
private String url;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 容量
|
||||||
|
*/
|
||||||
|
private String volume;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 服务商
|
* 服务商
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -2,11 +2,13 @@ package org.dromara.system.domain.vo;
|
||||||
|
|
||||||
import io.github.linpeilie.annotations.AutoMapper;
|
import io.github.linpeilie.annotations.AutoMapper;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import org.dromara.common.translation.annotation.Translation;
|
||||||
|
import org.dromara.common.translation.constant.TransConstant;
|
||||||
import org.dromara.system.domain.SysOssTextbook;
|
import org.dromara.system.domain.SysOssTextbook;
|
||||||
|
|
||||||
import java.io.Serial;
|
import java.io.Serial;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -53,5 +55,20 @@ public class SysOssTextbookVo implements Serializable {
|
||||||
*/
|
*/
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件后缀名
|
||||||
|
*/
|
||||||
|
private String fileSuffix;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 容量
|
||||||
|
*/
|
||||||
|
private String volume;
|
||||||
|
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
@Translation(type = TransConstant.USER_ID_TO_NAME)
|
||||||
|
private Long createBy;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,6 +47,11 @@ public class SysOssVo implements Serializable {
|
||||||
*/
|
*/
|
||||||
private String url;
|
private String url;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 容量
|
||||||
|
*/
|
||||||
|
private String volume;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建时间
|
* 创建时间
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -66,4 +66,6 @@ public interface ISysOssResourceService {
|
||||||
* @return 是否删除成功
|
* @return 是否删除成功
|
||||||
*/
|
*/
|
||||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||||
|
|
||||||
|
Boolean reviewByBo(SysOssResourceBo bo);
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,4 +68,6 @@ public interface ISysOssTextbookService {
|
||||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||||
|
|
||||||
Boolean reviewByBo(SysOssTextbookBo bo);
|
Boolean reviewByBo(SysOssTextbookBo bo);
|
||||||
|
Boolean copyByBo(SysOssTextbookBo bo);
|
||||||
|
Boolean moveByBo(SysOssTextbookBo bo);
|
||||||
}
|
}
|
||||||
|
|
|
@ -155,4 +155,12 @@ public class SysOssResourceServiceImpl implements ISysOssResourceService {
|
||||||
}
|
}
|
||||||
return baseMapper.deleteBatchIds(ids) > 0;
|
return baseMapper.deleteBatchIds(ids) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean reviewByBo(SysOssResourceBo bo) {
|
||||||
|
SysOssResource date = new SysOssResource();
|
||||||
|
date.setId(bo.getId());
|
||||||
|
date.setStatus(bo.getStatus());
|
||||||
|
return baseMapper.updateById(date) > 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package org.dromara.system.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.convert.Convert;
|
import cn.hutool.core.convert.Convert;
|
||||||
|
import cn.hutool.core.io.unit.DataSizeUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
@ -187,6 +188,11 @@ public class SysOssServiceImpl implements ISysOssService, OssService {
|
||||||
@Override
|
@Override
|
||||||
public SysOssVo upload(MultipartFile file) {
|
public SysOssVo upload(MultipartFile file) {
|
||||||
String originalfileName = file.getOriginalFilename();
|
String originalfileName = file.getOriginalFilename();
|
||||||
|
long size = file.getSize();
|
||||||
|
if (size == 0) {
|
||||||
|
throw new ServiceException("上传的文件内容为空");
|
||||||
|
}
|
||||||
|
String format = DataSizeUtil.format(size);
|
||||||
String suffix = StringUtils.substring(originalfileName, originalfileName.lastIndexOf("."), originalfileName.length());
|
String suffix = StringUtils.substring(originalfileName, originalfileName.lastIndexOf("."), originalfileName.length());
|
||||||
OssClient storage = OssFactory.instance();
|
OssClient storage = OssFactory.instance();
|
||||||
UploadResult uploadResult;
|
UploadResult uploadResult;
|
||||||
|
@ -203,7 +209,7 @@ public class SysOssServiceImpl implements ISysOssService, OssService {
|
||||||
throw new ServiceException(e.getMessage());
|
throw new ServiceException(e.getMessage());
|
||||||
}
|
}
|
||||||
// 保存文件信息
|
// 保存文件信息
|
||||||
return buildResultEntity(originalfileName, md5, suffix, storage.getConfigKey(), uploadResult);
|
return buildResultEntity(originalfileName, md5, format, suffix, storage.getConfigKey(), uploadResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -215,6 +221,7 @@ public class SysOssServiceImpl implements ISysOssService, OssService {
|
||||||
@Override
|
@Override
|
||||||
public SysOssVo upload(File file) {
|
public SysOssVo upload(File file) {
|
||||||
String originalfileName = file.getName();
|
String originalfileName = file.getName();
|
||||||
|
String format = DataSizeUtil.format(file.length());
|
||||||
String suffix = StringUtils.substring(originalfileName, originalfileName.lastIndexOf("."), originalfileName.length());
|
String suffix = StringUtils.substring(originalfileName, originalfileName.lastIndexOf("."), originalfileName.length());
|
||||||
OssClient storage = OssFactory.instance();
|
OssClient storage = OssFactory.instance();
|
||||||
String md5;
|
String md5;
|
||||||
|
@ -230,17 +237,18 @@ public class SysOssServiceImpl implements ISysOssService, OssService {
|
||||||
}
|
}
|
||||||
UploadResult uploadResult = storage.uploadSuffix(file, suffix);
|
UploadResult uploadResult = storage.uploadSuffix(file, suffix);
|
||||||
// 保存文件信息
|
// 保存文件信息
|
||||||
return buildResultEntity(originalfileName, md5, suffix, storage.getConfigKey(), uploadResult);
|
return buildResultEntity(originalfileName, md5, format, suffix, storage.getConfigKey(), uploadResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private SysOssVo buildResultEntity(String originalfileName, String md5, String suffix, String configKey, UploadResult uploadResult) {
|
private SysOssVo buildResultEntity(String originalfileName, String md5, String format, String suffix, String configKey, UploadResult uploadResult) {
|
||||||
SysOss oss = new SysOss();
|
SysOss oss = new SysOss();
|
||||||
oss.setUrl(uploadResult.getUrl());
|
oss.setUrl(uploadResult.getUrl());
|
||||||
oss.setFileSuffix(suffix);
|
oss.setFileSuffix(suffix);
|
||||||
oss.setFileName(uploadResult.getFilename());
|
oss.setFileName(uploadResult.getFilename());
|
||||||
oss.setService(configKey);
|
oss.setService(configKey);
|
||||||
oss.setFileMd5(md5);
|
oss.setFileMd5(md5);
|
||||||
|
oss.setVolume(format);
|
||||||
baseMapper.insert(oss);
|
baseMapper.insert(oss);
|
||||||
SysOssVo sysOssVo = MapstructUtils.convert(oss, SysOssVo.class);
|
SysOssVo sysOssVo = MapstructUtils.convert(oss, SysOssVo.class);
|
||||||
sysOssVo.setOriginalName(originalfileName);
|
sysOssVo.setOriginalName(originalfileName);
|
||||||
|
@ -293,4 +301,5 @@ public class SysOssServiceImpl implements ISysOssService, OssService {
|
||||||
public SysOssVo getByMd5(String md5) {
|
public SysOssVo getByMd5(String md5) {
|
||||||
return baseMapper.selectVoOne(new LambdaQueryWrapper<SysOss>().eq(SysOss::getFileMd5, md5));
|
return baseMapper.selectVoOne(new LambdaQueryWrapper<SysOss>().eq(SysOss::getFileMd5, md5));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,7 +133,7 @@ public class SysOssTextbookServiceImpl implements ISysOssTextbookService {
|
||||||
private void validEntityBeforeSave(SysOssTextbook entity) {
|
private void validEntityBeforeSave(SysOssTextbook entity) {
|
||||||
SysOssVo ossVo = ossService.getById(entity.getOssId());
|
SysOssVo ossVo = ossService.getById(entity.getOssId());
|
||||||
if (ObjectUtil.isNull(ossVo)) {
|
if (ObjectUtil.isNull(ossVo)) {
|
||||||
throw new ServiceException("教材文件不存在");
|
throw new ServiceException("文件不存在");
|
||||||
}
|
}
|
||||||
SysCatalogTextbookVo ossTextbook = catalogService.selectCatalogById(entity.getCatalogId());
|
SysCatalogTextbookVo ossTextbook = catalogService.selectCatalogById(entity.getCatalogId());
|
||||||
if (ObjectUtil.isNull(ossTextbook)) {
|
if (ObjectUtil.isNull(ossTextbook)) {
|
||||||
|
@ -163,4 +163,32 @@ public class SysOssTextbookServiceImpl implements ISysOssTextbookService {
|
||||||
date.setStatus(bo.getStatus());
|
date.setStatus(bo.getStatus());
|
||||||
return baseMapper.updateById(date) > 0;
|
return baseMapper.updateById(date) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean copyByBo(SysOssTextbookBo bo) {
|
||||||
|
SysOssTextbook copy = processDate(bo);
|
||||||
|
validEntityBeforeSave(copy);
|
||||||
|
return baseMapper.insert(copy) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean moveByBo(SysOssTextbookBo bo) {
|
||||||
|
SysOssTextbook move = processDate(bo);
|
||||||
|
baseMapper.insert(move);
|
||||||
|
validEntityBeforeSave(move);
|
||||||
|
return baseMapper.deleteById(bo.getId()) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private SysOssTextbook processDate(SysOssTextbookBo bo) {
|
||||||
|
SysOssTextbook ossTextbook = baseMapper.selectById(bo.getId());
|
||||||
|
SysOssTextbook date = new SysOssTextbook();
|
||||||
|
date.setOssId(ossTextbook.getOssId());
|
||||||
|
String path = catalogService.selectCatalogNameById(bo.getCatalogId());
|
||||||
|
date.setCatalogId(bo.getCatalogId());
|
||||||
|
date.setFileName(ossTextbook.getFileName());
|
||||||
|
date.setFilePath(path);
|
||||||
|
date.setType(ossTextbook.getType());
|
||||||
|
date.setStatus(ossTextbook.getStatus());
|
||||||
|
return date;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,9 +5,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<mapper namespace="org.dromara.system.mapper.SysOssTextbookMapper">
|
<mapper namespace="org.dromara.system.mapper.SysOssTextbookMapper">
|
||||||
|
|
||||||
<select id="selectPageUserList" resultType="org.dromara.system.domain.vo.SysOssTextbookVo">
|
<select id="selectPageUserList" resultType="org.dromara.system.domain.vo.SysOssTextbookVo">
|
||||||
select *
|
select ot.*,o.file_suffix,o.volume
|
||||||
from sys_oss_textbook ot
|
from sys_oss_textbook ot
|
||||||
left join sys_catalog_textbook ct on ct.catalog_id = ot.catalog_id
|
left join sys_catalog_textbook ct on ct.catalog_id = ot.catalog_id
|
||||||
|
left join sys_oss o on o.oss_id = ot.oss_id
|
||||||
${ew.getCustomSqlSegment}
|
${ew.getCustomSqlSegment}
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
Loading…
Reference in New Issue