Compare commits
3 Commits
d57d17dc50
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| b33ee00dbd | |||
| c8f9cc4f31 | |||
| 26d2f05c4e |
@ -11,6 +11,7 @@ import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -39,7 +40,7 @@ public class AppFileController extends BaseController {
|
||||
* 上传文件
|
||||
*/
|
||||
@PostMapping("/upload")
|
||||
public R<Void> upload(@Validated @ModelAttribute AppFileDto bo) {
|
||||
public R<Void> upload(@Validated @ModelAttribute AppFileDto bo) throws IOException {
|
||||
return toAjax(appFileService.add(bo));
|
||||
}
|
||||
|
||||
|
||||
@ -8,6 +8,7 @@ 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;
|
||||
import com.fuyuanshen.equipment.utils.FileHashUtil;
|
||||
import com.fuyuanshen.system.domain.vo.SysOssVo;
|
||||
import com.fuyuanshen.system.service.ISysOssService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@ -15,6 +16,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -31,24 +33,38 @@ public class AppFileService {
|
||||
|
||||
private final IAppBusinessFileService appBusinessFileService;
|
||||
|
||||
private final FileHashUtil fileHashUtil;
|
||||
private final ISysOssService ossService;
|
||||
|
||||
|
||||
public List<AppFileVo> list(AppBusinessFileBo bo) {
|
||||
// bo.setCreateBy(AppLoginHelper.getUserId());
|
||||
return appBusinessFileService.queryAppFileList(bo);
|
||||
}
|
||||
|
||||
public Boolean add(AppFileDto bo) {
|
||||
|
||||
/**
|
||||
* APP文件上传
|
||||
*/
|
||||
public Boolean add(AppFileDto bo) throws IOException {
|
||||
|
||||
MultipartFile[] files = bo.getFiles();
|
||||
if(files == null || files.length == 0){
|
||||
if (files == null || files.length == 0) {
|
||||
throw new ServiceException("请选择要上传的文件");
|
||||
}
|
||||
if(files.length > 5){
|
||||
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);
|
||||
// SysOssVo upload = sysOssService.upload(file);
|
||||
String fileHash = fileHashUtil.hash(file);
|
||||
SysOssVo upload = ossService.updateHash(file, fileHash);
|
||||
// 强制将HTTP替换为HTTPS
|
||||
if (upload.getUrl() != null && upload.getUrl().startsWith("http://")) {
|
||||
upload.setUrl(upload.getUrl().replaceFirst("^http://", "https://"));
|
||||
}
|
||||
|
||||
if (upload == null) {
|
||||
return false;
|
||||
@ -66,6 +82,7 @@ public class AppFileService {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public Boolean delete(Long[] ids) {
|
||||
AppBusinessFileBo bo = new AppBusinessFileBo();
|
||||
// bo.setCreateBy(AppLoginHelper.getUserId());
|
||||
@ -79,4 +96,5 @@ public class AppFileService {
|
||||
}
|
||||
return appBusinessFileService.deleteWithValidByIds(List.of(ids), true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -123,4 +123,12 @@ public class DeviceQueryCriteria extends BaseEntity {
|
||||
*/
|
||||
private Integer onlineStatus;
|
||||
|
||||
/**
|
||||
* 绑定状态
|
||||
* 0 未绑定
|
||||
* 1 已绑定
|
||||
*/
|
||||
@Schema(title = "绑定状态")
|
||||
private Integer bindingStatus;
|
||||
|
||||
}
|
||||
|
||||
@ -1,13 +1,10 @@
|
||||
package com.fuyuanshen.equipment.service;
|
||||
|
||||
import cn.hutool.core.lang.Dict;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.fuyuanshen.common.core.domain.PageResult;
|
||||
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
|
||||
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
||||
import com.fuyuanshen.equipment.domain.Device;
|
||||
import com.fuyuanshen.equipment.domain.DeviceType;
|
||||
import com.fuyuanshen.equipment.domain.dto.AppDeviceBo;
|
||||
import com.fuyuanshen.equipment.domain.form.DeviceForm;
|
||||
import com.fuyuanshen.equipment.domain.query.DeviceQueryCriteria;
|
||||
@ -146,7 +143,7 @@ public interface DeviceService extends IService<Device> {
|
||||
* @return
|
||||
*/
|
||||
List<Map<String, Object>> getEquipmentUsageData(Long deviceTypeId, Integer range);
|
||||
|
||||
|
||||
/**
|
||||
* 根据设备IMEI查询设备
|
||||
*
|
||||
@ -191,7 +188,7 @@ public interface DeviceService extends IService<Device> {
|
||||
/**
|
||||
* 根据条件查询设备位置信息
|
||||
*
|
||||
* @param groupId 设备分组ID
|
||||
* @param groupId 设备分组ID
|
||||
* @param deviceType 设备类型
|
||||
* @param deviceImei 设备IMEI
|
||||
* @return 设备位置信息列表
|
||||
|
||||
@ -74,6 +74,9 @@
|
||||
<if test="criteria.onlineStatus != null">
|
||||
and d.online_status = #{criteria.onlineStatus}
|
||||
</if>
|
||||
<if test="criteria.bindingStatus != null">
|
||||
and d.binding_status = #{criteria.bindingStatus}
|
||||
</if>
|
||||
<if test="criteria.groupId != null">
|
||||
and d.group_id = #{criteria.groupId}
|
||||
</if>
|
||||
|
||||
@ -72,10 +72,10 @@ public class SysOssVo implements Serializable {
|
||||
* 服务商
|
||||
*/
|
||||
private String service;
|
||||
|
||||
/**
|
||||
* 内容哈希
|
||||
*/
|
||||
private String fileHash;
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user