Merge branch 'main' into jingquan
This commit is contained in:
@ -6,6 +6,7 @@ import com.fuyuanshen.app.domain.vo.AppFileVo;
|
||||
import com.fuyuanshen.app.service.AppFileService;
|
||||
import com.fuyuanshen.common.core.domain.R;
|
||||
import com.fuyuanshen.common.web.core.BaseController;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@ -44,8 +45,8 @@ public class AppFileController extends BaseController {
|
||||
/**
|
||||
* 文件删除
|
||||
*/
|
||||
@DeleteMapping("/delete")
|
||||
public R<Void> delete(Long[] ids) {
|
||||
@DeleteMapping("/delete/{ids}")
|
||||
public R<Void> delete(@NotEmpty(message = "主键不能为空") @PathVariable Long[] ids) {
|
||||
if(ids == null || ids.length == 0){
|
||||
return R.fail("请选择要删除的文件");
|
||||
}
|
||||
|
@ -16,6 +16,6 @@ public class AppFileDto {
|
||||
/**
|
||||
* 文件
|
||||
*/
|
||||
private MultipartFile file;
|
||||
private MultipartFile[] files;
|
||||
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import com.fuyuanshen.app.domain.bo.AppBusinessFileBo;
|
||||
import com.fuyuanshen.app.domain.dto.AppFileDto;
|
||||
import com.fuyuanshen.app.domain.vo.AppBusinessFileVo;
|
||||
import com.fuyuanshen.app.domain.vo.AppFileVo;
|
||||
import com.fuyuanshen.common.core.exception.ServiceException;
|
||||
import com.fuyuanshen.common.oss.core.OssClient;
|
||||
import com.fuyuanshen.common.oss.factory.OssFactory;
|
||||
import com.fuyuanshen.common.satoken.utils.AppLoginHelper;
|
||||
@ -12,6 +13,7 @@ import com.fuyuanshen.system.service.ISysOssService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -36,20 +38,32 @@ public class AppFileService {
|
||||
|
||||
public Boolean add(AppFileDto bo) {
|
||||
|
||||
// 上传文件
|
||||
SysOssVo upload = sysOssService.upload(bo.getFile());
|
||||
MultipartFile[] files = bo.getFiles();
|
||||
if(files == null || files.length == 0){
|
||||
throw new ServiceException("请选择要上传的文件");
|
||||
}
|
||||
if(files.length > 5){
|
||||
throw new ServiceException("最多只能上传5个文件");
|
||||
}
|
||||
for (int i = 0; i < files.length; i++) {
|
||||
MultipartFile file = files[i];
|
||||
// 上传文件
|
||||
SysOssVo upload = sysOssService.upload(file);
|
||||
|
||||
if (upload == null) {
|
||||
return false;
|
||||
if (upload == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
AppBusinessFileBo appBusinessFileBo = new AppBusinessFileBo();
|
||||
appBusinessFileBo.setFileId(upload.getOssId());
|
||||
appBusinessFileBo.setBusinessId(bo.getDeviceId());
|
||||
appBusinessFileBo.setFileType(bo.getFileType());
|
||||
appBusinessFileBo.setCreateBy(AppLoginHelper.getUserId());
|
||||
appBusinessFileService.insertByBo(appBusinessFileBo);
|
||||
}
|
||||
|
||||
AppBusinessFileBo appBusinessFileBo = new AppBusinessFileBo();
|
||||
appBusinessFileBo.setFileId(upload.getOssId());
|
||||
appBusinessFileBo.setBusinessId(bo.getDeviceId());
|
||||
appBusinessFileBo.setFileType(bo.getFileType());
|
||||
appBusinessFileBo.setCreateBy(AppLoginHelper.getUserId());
|
||||
|
||||
return appBusinessFileService.insertByBo(appBusinessFileBo);
|
||||
return true;
|
||||
}
|
||||
|
||||
public Boolean delete(Long[] ids) {
|
||||
|
@ -6,6 +6,11 @@ import lombok.Data;
|
||||
public class AppFileVo {
|
||||
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 业务id
|
||||
*/
|
||||
private String businessId;
|
||||
/**
|
||||
* 文件id
|
||||
*/
|
||||
|
@ -5,7 +5,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<mapper namespace="com.fuyuanshen.app.mapper.AppBusinessFileMapper">
|
||||
|
||||
<select id="queryAppFileList" resultType="com.fuyuanshen.app.domain.vo.AppFileVo">
|
||||
select a.business_id id,a.file_id,b.file_name,b.url fileUrl from app_business_file a left join sys_oss b on a.file_id = b.oss_id
|
||||
select a.id,a.business_id,a.file_id,b.file_name,b.url fileUrl from app_business_file a left join sys_oss b on a.file_id = b.oss_id
|
||||
where
|
||||
<if test="businessId != null">
|
||||
and a.business_id = #{businessId}
|
||||
|
@ -97,6 +97,9 @@ public class Device extends TenantEntity {
|
||||
@Schema(name = "设备状态")
|
||||
private Integer deviceStatus;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 绑定状态
|
||||
* 0 未绑定
|
||||
|
Reference in New Issue
Block a user