feat: 获取分享列表接口
This commit is contained in:
@@ -66,7 +66,7 @@ public class SchisandraOssMinioController {
|
||||
@GetMapping("returnAll")
|
||||
public Result returnAll() {
|
||||
List<SchisandraOssMinioBO> list = schisandraOssMinioDomainService.selectAll();
|
||||
if(list.isEmpty()){
|
||||
if (list.isEmpty()) {
|
||||
return Result.fail();
|
||||
}
|
||||
return Result.ok(SchisandraOssMinioDTOConverter.INSTANCE.convertBOToDTOList(list));
|
||||
@@ -86,7 +86,7 @@ public class SchisandraOssMinioController {
|
||||
log.info("SchisandraOssMinioController.init.userId:{}", userId);
|
||||
}
|
||||
Preconditions.checkNotNull(userId, "用户id不能为空!");
|
||||
List<SchisandraOssMinioBO> list= schisandraOssMinioDomainService.getAllMinioInfoByUserId(Long.valueOf(userId));
|
||||
List<SchisandraOssMinioBO> list = schisandraOssMinioDomainService.getAllMinioInfoByUserId(Long.valueOf(userId));
|
||||
if (list.size() != 0) {
|
||||
return Result.fail(list);
|
||||
}
|
||||
@@ -112,7 +112,7 @@ public class SchisandraOssMinioController {
|
||||
bo.setUserId(Long.valueOf(userId));
|
||||
bo.setStatus(String.valueOf(false));
|
||||
if (schisandraOssMinioDomainService.update(bo)) {
|
||||
SpringUtil.unregisterBean(OssConstant.OssType.MINIO+userId);
|
||||
SpringUtil.unregisterBean(OssConstant.OssType.MINIO + userId);
|
||||
return Result.ok();
|
||||
} else {
|
||||
return Result.fail();
|
||||
@@ -132,7 +132,7 @@ public class SchisandraOssMinioController {
|
||||
@GetMapping("listDir")
|
||||
public Result<String> listMinioInfo(@RequestParam String userId, @RequestParam String dirName, @RequestParam String bucket) throws Exception {
|
||||
Preconditions.checkNotNull(userId, "不能为空");
|
||||
MinioOssClient bean = SpringUtil.getBean(OssConstant.OssType.MINIO+userId);
|
||||
MinioOssClient bean = SpringUtil.getBean(OssConstant.OssType.MINIO + userId);
|
||||
bean.getMinioOssConfig().setBucketName(bucket);
|
||||
return Result.ok(bean.listDir(bucket, dirName));
|
||||
}
|
||||
@@ -149,7 +149,7 @@ public class SchisandraOssMinioController {
|
||||
Preconditions.checkNotNull(bucket, "不能为空");
|
||||
Preconditions.checkNotNull(userId, "不能为空");
|
||||
Preconditions.checkNotNull(listObjectsArgs, "不能为空");
|
||||
MinioOssClient bean = SpringUtil.getBean(OssConstant.OssType.MINIO+userId);
|
||||
MinioOssClient bean = SpringUtil.getBean(OssConstant.OssType.MINIO + userId);
|
||||
bean.getMinioOssConfig().setBucketName(bucket);
|
||||
HashMap<String, InputStream> list = bean.getTargetDir(listObjectsArgs);
|
||||
|
||||
@@ -166,13 +166,13 @@ public class SchisandraOssMinioController {
|
||||
Date date = new Date();
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
String formattedDate = dateFormat.format(date);
|
||||
list.keySet().forEach( name -> {
|
||||
list.keySet().forEach(name -> {
|
||||
try {
|
||||
byte[] bytes = StreamUtils.copyToByteArray(list.get(name));
|
||||
String key = redisUtil.buildKey(USER_OSS_PREFIX, "download", formattedDate, userId, name);
|
||||
HashMap<Object, Object> map = new HashMap<>();
|
||||
map.put("size", bytes.length);
|
||||
map.put("time",formattedDate);
|
||||
map.put("time", formattedDate);
|
||||
redisUtil.setNx(key, map, 30L, TimeUnit.DAYS);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
@@ -195,7 +195,7 @@ public class SchisandraOssMinioController {
|
||||
Preconditions.checkNotNull(bucket, "不能为空");
|
||||
Preconditions.checkNotNull(userId, "不能为空");
|
||||
Preconditions.checkNotNull(filePath, "不能为空");
|
||||
MinioOssClient bean = SpringUtil.getBean(OssConstant.OssType.MINIO+userId);
|
||||
MinioOssClient bean = SpringUtil.getBean(OssConstant.OssType.MINIO + userId);
|
||||
bean.getMinioOssConfig().setBucketName(bucket);
|
||||
bean.delete(filePath);
|
||||
return Result.ok();
|
||||
@@ -216,7 +216,7 @@ public class SchisandraOssMinioController {
|
||||
Preconditions.checkNotNull(bucket, "不能为空");
|
||||
// 获取文件输入流
|
||||
InputStream is = file.getInputStream();
|
||||
MinioOssClient bean = SpringUtil.getBean(OssConstant.OssType.MINIO+userId);
|
||||
MinioOssClient bean = SpringUtil.getBean(OssConstant.OssType.MINIO + userId);
|
||||
bean.getMinioOssConfig().setBucketName(bucket);
|
||||
//设置热力图
|
||||
Date date = new Date();
|
||||
@@ -226,7 +226,7 @@ public class SchisandraOssMinioController {
|
||||
HashMap<Object, Object> map = new HashMap<>();
|
||||
map.put("descreption", "这是一个文件");
|
||||
map.put("size", String.valueOf(file.getSize()));
|
||||
map.put("time",formattedDate);
|
||||
map.put("time", formattedDate);
|
||||
if (bean.upLoad(is, fileName, true) != null) {
|
||||
redisUtil.setNx(key, map, 30L, TimeUnit.DAYS);
|
||||
return Result.ok();
|
||||
@@ -251,7 +251,7 @@ public class SchisandraOssMinioController {
|
||||
Preconditions.checkNotNull(bucket, "不能为空");
|
||||
Preconditions.checkNotNull(oldFileName, "不能为空");
|
||||
Preconditions.checkNotNull(newFileName, "不能为空");
|
||||
MinioOssClient bean = SpringUtil.getBean(OssConstant.OssType.MINIO+userId);
|
||||
MinioOssClient bean = SpringUtil.getBean(OssConstant.OssType.MINIO + userId);
|
||||
bean.getMinioOssConfig().setBucketName(bucket);
|
||||
try {
|
||||
bean.rename(oldFileName, newFileName);
|
||||
@@ -276,7 +276,7 @@ public class SchisandraOssMinioController {
|
||||
Preconditions.checkNotNull(bucket, "不能为空");
|
||||
Preconditions.checkNotNull(oldFilePath, "不能为空");
|
||||
Preconditions.checkNotNull(newFilePath, "不能为空");
|
||||
MinioOssClient bean = SpringUtil.getBean(OssConstant.OssType.MINIO+userId);
|
||||
MinioOssClient bean = SpringUtil.getBean(OssConstant.OssType.MINIO + userId);
|
||||
bean.getMinioOssConfig().setBucketName(bucket);
|
||||
try {
|
||||
bean.copy(oldFilePath, newFilePath);
|
||||
@@ -298,7 +298,7 @@ public class SchisandraOssMinioController {
|
||||
Preconditions.checkNotNull(userId, "不能为空");
|
||||
Preconditions.checkNotNull(bucket, "不能为空");
|
||||
Preconditions.checkNotNull(filePath, "不能为空");
|
||||
MinioOssClient bean = SpringUtil.getBean(OssConstant.OssType.MINIO+userId);
|
||||
MinioOssClient bean = SpringUtil.getBean(OssConstant.OssType.MINIO + userId);
|
||||
bean.getMinioOssConfig().setBucketName(bucket);
|
||||
try {
|
||||
Date date = new Date();
|
||||
@@ -306,7 +306,7 @@ public class SchisandraOssMinioController {
|
||||
String formattedDate = dateFormat.format(date);
|
||||
String key = redisUtil.buildKey(USER_OSS_PREFIX, "previewFile", formattedDate, userId, filePath);
|
||||
HashMap<Object, Object> map = new HashMap<>();
|
||||
String url=bean.getMinioPreviewUrl(filePath);
|
||||
String url = bean.getMinioPreviewUrl(filePath);
|
||||
map.put("url", url);
|
||||
map.put("time", formattedDate);
|
||||
redisUtil.setNx(key, map, 30L, TimeUnit.DAYS);
|
||||
@@ -329,7 +329,7 @@ public class SchisandraOssMinioController {
|
||||
Preconditions.checkNotNull(userId, "不能为空");
|
||||
Preconditions.checkNotNull(bucket, "不能为空");
|
||||
Preconditions.checkNotNull(filePath, "不能为空");
|
||||
MinioOssClient bean = SpringUtil.getBean(OssConstant.OssType.MINIO+userId);
|
||||
MinioOssClient bean = SpringUtil.getBean(OssConstant.OssType.MINIO + userId);
|
||||
bean.getMinioOssConfig().setBucketName(bucket);
|
||||
try {
|
||||
return Result.ok(bean.shareMinioFile(filePath, time));
|
||||
@@ -348,7 +348,7 @@ public class SchisandraOssMinioController {
|
||||
@PostMapping("seleteBucket")
|
||||
public Result<String> seleteBucket(@RequestParam String userId) throws ServerException, InsufficientDataException, ErrorResponseException, IOException, NoSuchAlgorithmException, InvalidKeyException, InvalidResponseException, XmlParserException, InternalException {
|
||||
Preconditions.checkNotNull(userId, "不能为空");
|
||||
MinioOssClient bean = SpringUtil.getBean(OssConstant.OssType.MINIO+userId);
|
||||
MinioOssClient bean = SpringUtil.getBean(OssConstant.OssType.MINIO + userId);
|
||||
return Result.ok(bean.selectAllBucket());
|
||||
}
|
||||
|
||||
@@ -363,7 +363,7 @@ public class SchisandraOssMinioController {
|
||||
public Result<String> createBucket(@RequestParam String userId, @RequestParam String bucket) {
|
||||
Preconditions.checkNotNull(userId, "不能为空");
|
||||
Preconditions.checkNotNull(bucket, "不能为空");
|
||||
MinioOssClient bean = SpringUtil.getBean(OssConstant.OssType.MINIO+userId);
|
||||
MinioOssClient bean = SpringUtil.getBean(OssConstant.OssType.MINIO + userId);
|
||||
bean.getMinioOssConfig().setBucketName(bucket);
|
||||
return Result.ok(bean.createBucket(bucket));
|
||||
}
|
||||
@@ -379,7 +379,7 @@ public class SchisandraOssMinioController {
|
||||
public Result<String> deleteBucket(@RequestParam String userId, @RequestParam String bucket) {
|
||||
Preconditions.checkNotNull(userId, "不能为空");
|
||||
Preconditions.checkNotNull(bucket, "不能为空");
|
||||
MinioOssClient bean = SpringUtil.getBean(OssConstant.OssType.MINIO+userId);
|
||||
MinioOssClient bean = SpringUtil.getBean(OssConstant.OssType.MINIO + userId);
|
||||
bean.getMinioOssConfig().setBucketName(bucket);
|
||||
return Result.ok(bean.deleteBucket(bucket));
|
||||
}
|
||||
@@ -453,7 +453,7 @@ public class SchisandraOssMinioController {
|
||||
|
||||
@PostMapping("getBaseInfo")
|
||||
public Result getBaseInfo(@RequestParam String fileName, @RequestParam String userId) {
|
||||
MinioOssClient bean = SpringUtil.getBean(OssConstant.OssType.MINIO+userId);
|
||||
MinioOssClient bean = SpringUtil.getBean(OssConstant.OssType.MINIO + userId);
|
||||
if (bean == null) {
|
||||
log.error("容器获取失败!");
|
||||
return null;
|
||||
|
@@ -1,38 +1,40 @@
|
||||
package com.schisandra.oss.application.oss.model;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author landaiqing
|
||||
* @version Info.java, v 1.1 2021/11/15 10:16 chenmin Exp $
|
||||
* Created on 2021/11/15
|
||||
*/
|
||||
@Data
|
||||
public class OssInfo {
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 是否是文件夹
|
||||
*/
|
||||
private Boolean isDir;
|
||||
/**
|
||||
* 存储路径
|
||||
*/
|
||||
private String path;
|
||||
/**
|
||||
* 对象大小
|
||||
*/
|
||||
private String length;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private String createTime;
|
||||
/**
|
||||
* 最新修改时间
|
||||
*/
|
||||
private String lastUpdateTime;
|
||||
|
||||
}
|
||||
package com.schisandra.oss.application.oss.model;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author landaiqing
|
||||
* @version Info.java, v 1.1 2021/11/15 10:16 chenmin Exp $
|
||||
* Created on 2021/11/15
|
||||
*/
|
||||
@Data
|
||||
public class OssInfo implements Serializable {
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 是否是文件夹
|
||||
*/
|
||||
private Boolean isDir;
|
||||
/**
|
||||
* 存储路径
|
||||
*/
|
||||
private String path;
|
||||
/**
|
||||
* 对象大小
|
||||
*/
|
||||
private String length;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private String createTime;
|
||||
/**
|
||||
* 最新修改时间
|
||||
*/
|
||||
private String lastUpdateTime;
|
||||
|
||||
}
|
||||
|
@@ -1,6 +1,5 @@
|
||||
package com.schisandra.oss.job.job;
|
||||
|
||||
import com.schisandra.oss.domain.bo.SchisandraFileHeatmapBO;
|
||||
import com.schisandra.oss.domain.service.SchisandraFileHeatmapDomainService;
|
||||
import com.xxl.job.core.context.XxlJobHelper;
|
||||
import com.xxl.job.core.handler.annotation.XxlJob;
|
||||
@@ -8,7 +7,6 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
@@ -19,17 +17,17 @@ public class OssHeatMapRedisToMysqlHandler {
|
||||
@XxlJob("ossHeatMapRedisToMysqlHandler")
|
||||
public void ossHeatMapRedisToMysqlHandler() throws Exception {
|
||||
XxlJobHelper.log("ossHeatMapRedisToMysqlHandler.starter");
|
||||
if (schisandraFileHeatmapDomainService.uploadHeatMapRedisToMysql()==1 ){
|
||||
XxlJobHelper.log("ossHeatMapRedisToMysqlHandler.upload.success");
|
||||
log.info("1");
|
||||
}else {
|
||||
XxlJobHelper.log("ossHeatMapRedisToMysqlHandler.fail");
|
||||
}
|
||||
if (schisandraFileHeatmapDomainService.downloadHeatMapRedisToMysql()==1){
|
||||
XxlJobHelper.log("ossHeatMapRedisToMysqlHandler.success");
|
||||
}else {
|
||||
XxlJobHelper.log("ossHeatMapRedisToMysqlHandler.download.fail");
|
||||
}
|
||||
if (schisandraFileHeatmapDomainService.uploadHeatMapRedisToMysql() == 1) {
|
||||
XxlJobHelper.log("ossHeatMapRedisToMysqlHandler.upload.success");
|
||||
log.info("1");
|
||||
} else {
|
||||
XxlJobHelper.log("ossHeatMapRedisToMysqlHandler.fail");
|
||||
}
|
||||
if (schisandraFileHeatmapDomainService.downloadHeatMapRedisToMysql() == 1) {
|
||||
XxlJobHelper.log("ossHeatMapRedisToMysqlHandler.success");
|
||||
} else {
|
||||
XxlJobHelper.log("ossHeatMapRedisToMysqlHandler.download.fail");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -1,56 +1,58 @@
|
||||
package com.schisandra.oss.common.entity;
|
||||
|
||||
import com.schisandra.oss.common.enums.ResultCodeEnum;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @description: 返回结果泛型类
|
||||
* @author: schisandra
|
||||
* @date: 2024/3/22 13:09
|
||||
*/
|
||||
@Data
|
||||
public class Result<T> {
|
||||
|
||||
private Boolean success;
|
||||
|
||||
private Integer code;
|
||||
|
||||
private String message;
|
||||
|
||||
private T data;
|
||||
|
||||
public static Result ok() {
|
||||
Result result = new Result();
|
||||
result.setSuccess(true);
|
||||
result.setCode(ResultCodeEnum.SUCCESS.getCode());
|
||||
result.setMessage(ResultCodeEnum.SUCCESS.getDesc());
|
||||
return result;
|
||||
}
|
||||
|
||||
public static <T> Result ok(T data) {
|
||||
Result result = new Result();
|
||||
result.setSuccess(true);
|
||||
result.setCode(ResultCodeEnum.SUCCESS.getCode());
|
||||
result.setMessage(ResultCodeEnum.SUCCESS.getDesc());
|
||||
result.setData(data);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Result fail() {
|
||||
Result result = new Result();
|
||||
result.setSuccess(false);
|
||||
result.setCode(ResultCodeEnum.FAIL.getCode());
|
||||
result.setMessage(ResultCodeEnum.FAIL.getDesc());
|
||||
return result;
|
||||
}
|
||||
|
||||
public static <T> Result fail(T data) {
|
||||
Result result = new Result();
|
||||
result.setSuccess(false);
|
||||
result.setCode(ResultCodeEnum.FAIL.getCode());
|
||||
result.setMessage(ResultCodeEnum.FAIL.getDesc());
|
||||
result.setData(data);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
package com.schisandra.oss.common.entity;
|
||||
|
||||
import com.schisandra.oss.common.enums.ResultCodeEnum;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @description: 返回结果泛型类
|
||||
* @author: schisandra
|
||||
* @date: 2024/3/22 13:09
|
||||
*/
|
||||
@Data
|
||||
public class Result<T> implements Serializable {
|
||||
|
||||
private Boolean success;
|
||||
|
||||
private Integer code;
|
||||
|
||||
private String message;
|
||||
|
||||
private T data;
|
||||
|
||||
public static Result ok() {
|
||||
Result result = new Result();
|
||||
result.setSuccess(true);
|
||||
result.setCode(ResultCodeEnum.SUCCESS.getCode());
|
||||
result.setMessage(ResultCodeEnum.SUCCESS.getDesc());
|
||||
return result;
|
||||
}
|
||||
|
||||
public static <T> Result ok(T data) {
|
||||
Result result = new Result();
|
||||
result.setSuccess(true);
|
||||
result.setCode(ResultCodeEnum.SUCCESS.getCode());
|
||||
result.setMessage(ResultCodeEnum.SUCCESS.getDesc());
|
||||
result.setData(data);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Result fail() {
|
||||
Result result = new Result();
|
||||
result.setSuccess(false);
|
||||
result.setCode(ResultCodeEnum.FAIL.getCode());
|
||||
result.setMessage(ResultCodeEnum.FAIL.getDesc());
|
||||
return result;
|
||||
}
|
||||
|
||||
public static <T> Result fail(T data) {
|
||||
Result result = new Result();
|
||||
result.setSuccess(false);
|
||||
result.setCode(ResultCodeEnum.FAIL.getCode());
|
||||
result.setMessage(ResultCodeEnum.FAIL.getDesc());
|
||||
result.setData(data);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -67,12 +67,12 @@ mybatis-flex:
|
||||
xxl:
|
||||
job:
|
||||
admin:
|
||||
addresses: http://127.0.0.1:8080/xxl-job-admin
|
||||
addresses: http://1.95.0.111:8088/xxl-job-admin
|
||||
accessToken: default_token
|
||||
executor:
|
||||
appname: schisandra-cloud-storage-oss
|
||||
address:
|
||||
ip: 127.0.0.1
|
||||
port: 9999
|
||||
ip: 1.95.0.111
|
||||
port: 9998
|
||||
logpath: /data/applogs/xxl-job/jobhandler
|
||||
logretentiondays: 30
|
Reference in New Issue
Block a user