feat: ①up,tencent,minio,qiniu,ali,sftp添加convertEntityToBOList ②注册注销bean(init,shutdown) ③controller层部分返回未修改->Result.ok
This commit is contained in:
@@ -4,12 +4,15 @@ import cn.hutool.extra.spring.SpringUtil;
|
|||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import com.schisandra.oss.application.convert.SchisandraOssAliDTOConverter;
|
import com.schisandra.oss.application.convert.SchisandraOssAliDTOConverter;
|
||||||
|
import com.schisandra.oss.application.convert.SchisandraOssMinioDTOConverter;
|
||||||
import com.schisandra.oss.application.dto.SchisandraOssAliDTO;
|
import com.schisandra.oss.application.dto.SchisandraOssAliDTO;
|
||||||
|
import com.schisandra.oss.application.oss.constant.OssConstant;
|
||||||
import com.schisandra.oss.application.oss.core.ali.AliOssClient;
|
import com.schisandra.oss.application.oss.core.ali.AliOssClient;
|
||||||
import com.schisandra.oss.application.oss.core.ali.AliOssConfiguration;
|
import com.schisandra.oss.application.oss.core.ali.AliOssConfiguration;
|
||||||
import com.schisandra.oss.application.oss.model.OssInfo;
|
import com.schisandra.oss.application.oss.model.OssInfo;
|
||||||
import com.schisandra.oss.common.entity.Result;
|
import com.schisandra.oss.common.entity.Result;
|
||||||
import com.schisandra.oss.domain.bo.SchisandraOssAliBO;
|
import com.schisandra.oss.domain.bo.SchisandraOssAliBO;
|
||||||
|
import com.schisandra.oss.domain.bo.SchisandraOssMinioBO;
|
||||||
import com.schisandra.oss.domain.redis.RedisUtil;
|
import com.schisandra.oss.domain.redis.RedisUtil;
|
||||||
import com.schisandra.oss.domain.service.SchisandraOssAliDomainService;
|
import com.schisandra.oss.domain.service.SchisandraOssAliDomainService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@@ -53,27 +56,51 @@ public class SchisandraOssAliController {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@GetMapping("returnAll")
|
@GetMapping("returnAll")
|
||||||
public List<SchisandraOssAliDTO> returnAll() {
|
public Result returnAll() {
|
||||||
return aliOssConfiguration.selectAll();
|
List<SchisandraOssAliBO> list = schisandraOssAliDomainService.selectAll();
|
||||||
|
if(list.isEmpty()){
|
||||||
|
return Result.fail();
|
||||||
|
}
|
||||||
|
return Result.ok(SchisandraOssAliDTOConverter.INSTANCE.convertBOToDTOList(list));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("init")
|
@GetMapping("init")
|
||||||
public void init(@RequestParam String userId) {
|
public Result init(@RequestParam String userId,@RequestParam String Id) {
|
||||||
if (log.isInfoEnabled()) {
|
if (log.isInfoEnabled()) {
|
||||||
log.info("SchisandraOssAliController.init.userId:{}", userId);
|
log.info("SchisandraOssAliController.init.userId:{}", userId);
|
||||||
}
|
}
|
||||||
Preconditions.checkNotNull(userId, "用户id不能为空!");
|
Preconditions.checkNotNull(userId, "用户id不能为空!");
|
||||||
try {
|
SchisandraOssAliBO bo = new SchisandraOssAliBO();
|
||||||
aliOssConfiguration.aliOssClient(userId);
|
bo.setId(Long.valueOf(Id));
|
||||||
log.info("用户: " + userId + "-> ali oss 初始化完成!");
|
bo.setUserId(Long.valueOf(OssConstant.OssType.ALI+ userId));
|
||||||
} catch (Exception e) {
|
bo.setStatus(String.valueOf(true));
|
||||||
log.error("用户: " + userId + "-> ali oss 初始化失败!", e.getMessage(), e);
|
if(schisandraOssAliDomainService.update(bo)){
|
||||||
|
return aliOssConfiguration.aliOssClient(userId);
|
||||||
|
}else{
|
||||||
|
return Result.fail("初始化失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("shutdown")
|
||||||
|
public Result shutdownAli(@RequestParam String userId,@RequestParam String Id){
|
||||||
|
if (log.isInfoEnabled()) {
|
||||||
|
log.info("SchisandraOssAliController.shutdown.userId:{}", JSON.toJSONString(userId));
|
||||||
|
}
|
||||||
|
SchisandraOssAliBO bo = new SchisandraOssAliBO();
|
||||||
|
bo.setId(Long.valueOf(Id));
|
||||||
|
bo.setUserId(Long.valueOf(OssConstant.OssType.ALI + userId));
|
||||||
|
bo.setStatus(String.valueOf(false));
|
||||||
|
if(schisandraOssAliDomainService.update(bo)){
|
||||||
|
SpringUtil.unregisterBean(OssConstant.OssType.ALI+ userId);
|
||||||
|
return Result.ok("关闭成功");
|
||||||
|
}else{
|
||||||
|
return Result.fail("关闭失败");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增
|
* 新增阿里配置表
|
||||||
*/
|
*/
|
||||||
@RequestMapping("add")
|
@RequestMapping("add")
|
||||||
public Result<Boolean> add(@RequestBody SchisandraOssAliDTO schisandraOssAliDTO) {
|
public Result<Boolean> add(@RequestBody SchisandraOssAliDTO schisandraOssAliDTO) {
|
||||||
@@ -118,7 +145,6 @@ public class SchisandraOssAliController {
|
|||||||
*/
|
*/
|
||||||
@RequestMapping("delete")
|
@RequestMapping("delete")
|
||||||
public Result<Boolean> delete(@RequestBody SchisandraOssAliDTO schisandraOssAliDTO) {
|
public Result<Boolean> delete(@RequestBody SchisandraOssAliDTO schisandraOssAliDTO) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (log.isInfoEnabled()) {
|
if (log.isInfoEnabled()) {
|
||||||
log.info("SchisandraOssAliController.delete.dto:{}", JSON.toJSONString(schisandraOssAliDTO));
|
log.info("SchisandraOssAliController.delete.dto:{}", JSON.toJSONString(schisandraOssAliDTO));
|
||||||
@@ -130,7 +156,6 @@ public class SchisandraOssAliController {
|
|||||||
log.error("SchisandraOssAliController.delete.error:{}", e.getMessage(), e);
|
log.error("SchisandraOssAliController.delete.error:{}", e.getMessage(), e);
|
||||||
return Result.fail("删除信息失败");
|
return Result.fail("删除信息失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -142,11 +167,16 @@ public class SchisandraOssAliController {
|
|||||||
@GetMapping("listDir")
|
@GetMapping("listDir")
|
||||||
public Result<String> listAliDir(@RequestParam String userId, @RequestParam String bucket, @RequestParam String prefix) throws Exception {
|
public Result<String> listAliDir(@RequestParam String userId, @RequestParam String bucket, @RequestParam String prefix) throws Exception {
|
||||||
Preconditions.checkNotNull(userId, "不能为空");
|
Preconditions.checkNotNull(userId, "不能为空");
|
||||||
AliOssClient bean = SpringUtil.getBean(userId);
|
AliOssClient bean = SpringUtil.getBean(OssConstant.OssType.ALI+ userId);
|
||||||
bean.getAliOssConfig().setBucketName(bucket);
|
bean.getAliOssConfig().setBucketName(bucket);
|
||||||
if (prefix == null)
|
if (prefix == null)
|
||||||
prefix = "";
|
prefix = "";
|
||||||
return Result.ok(bean.listAliInfo(bucket, prefix));
|
if(bean.listAliInfo(bucket, prefix) != null){
|
||||||
|
return Result.ok(bean.listAliInfo(bucket, prefix));
|
||||||
|
}else{
|
||||||
|
return Result.fail("获取文件目录信息失败");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -158,8 +188,13 @@ public class SchisandraOssAliController {
|
|||||||
@PostMapping("seleteBucket")
|
@PostMapping("seleteBucket")
|
||||||
public Result<String> seleteBucket(@RequestParam String userId) {
|
public Result<String> seleteBucket(@RequestParam String userId) {
|
||||||
Preconditions.checkNotNull(userId, "不能为空");
|
Preconditions.checkNotNull(userId, "不能为空");
|
||||||
AliOssClient bean = SpringUtil.getBean(userId);
|
AliOssClient bean = SpringUtil.getBean(OssConstant.OssType.ALI+ userId);
|
||||||
return Result.ok(bean.selectAllBucket());
|
if(bean.selectAllBucket() != null){
|
||||||
|
return Result.ok(bean.selectAllBucket());
|
||||||
|
}else{
|
||||||
|
return Result.fail("查询失败");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -173,9 +208,13 @@ public class SchisandraOssAliController {
|
|||||||
public Result<String> createBucket(@RequestParam String userId, @RequestParam String bucket) {
|
public Result<String> createBucket(@RequestParam String userId, @RequestParam String bucket) {
|
||||||
Preconditions.checkNotNull(userId, "不能为空");
|
Preconditions.checkNotNull(userId, "不能为空");
|
||||||
Preconditions.checkNotNull(bucket, "不能为空");
|
Preconditions.checkNotNull(bucket, "不能为空");
|
||||||
AliOssClient bean = SpringUtil.getBean(userId);
|
AliOssClient bean = SpringUtil.getBean(OssConstant.OssType.ALI+ userId);
|
||||||
bean.getAliOssConfig().setBucketName(bucket);
|
bean.getAliOssConfig().setBucketName(bucket);
|
||||||
return Result.ok(bean.createBucket(bucket));
|
if(bean.createBucket(bucket).equals(bucket)){
|
||||||
|
return Result.ok(bean.createBucket(bucket));
|
||||||
|
}else{
|
||||||
|
return Result.fail("创建失败");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -189,9 +228,13 @@ public class SchisandraOssAliController {
|
|||||||
public Result<String> deleteBucket(@RequestParam String userId, @RequestParam String bucket) {
|
public Result<String> deleteBucket(@RequestParam String userId, @RequestParam String bucket) {
|
||||||
Preconditions.checkNotNull(userId, "不能为空");
|
Preconditions.checkNotNull(userId, "不能为空");
|
||||||
Preconditions.checkNotNull(bucket, "不能为空");
|
Preconditions.checkNotNull(bucket, "不能为空");
|
||||||
AliOssClient bean = SpringUtil.getBean(userId);
|
AliOssClient bean = SpringUtil.getBean(OssConstant.OssType.ALI + userId);
|
||||||
bean.getAliOssConfig().setBucketName(bucket);
|
bean.getAliOssConfig().setBucketName(bucket);
|
||||||
return Result.ok(bean.deleteBucket(bucket));
|
if(bean.deleteBucket(bucket).equals("yes")){
|
||||||
|
return Result.ok(bean.deleteBucket(bucket));
|
||||||
|
}else{
|
||||||
|
return Result.fail("删除失败,或许桶已经不存在");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -221,30 +264,37 @@ public class SchisandraOssAliController {
|
|||||||
}
|
}
|
||||||
// 获取文件输入流
|
// 获取文件输入流
|
||||||
InputStream is = file.getInputStream();
|
InputStream is = file.getInputStream();
|
||||||
AliOssClient bean = SpringUtil.getBean(userId);
|
AliOssClient bean = SpringUtil.getBean(OssConstant.OssType.ALI + userId);
|
||||||
bean.getAliOssConfig().setBucketName(bucket);
|
bean.getAliOssConfig().setBucketName(bucket);
|
||||||
return Result.ok(bean.upLoad(is, fileName, true));
|
if(bean.upLoad(is, fileName, true) != null){
|
||||||
|
return Result.ok(bean.upLoad(is, fileName, true));
|
||||||
|
}else{
|
||||||
|
return Result.fail();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description: 下载文件
|
* @description: 下载文件
|
||||||
* @param: [schisandraOssMinioDTO]
|
* @param: [schisandraOssAliDTO]
|
||||||
* @return: voiD
|
* @return: voiD
|
||||||
* @date: 2024/6/26 13:56
|
* @date: 2024/6/26 13:56
|
||||||
*/
|
*/
|
||||||
@GetMapping("downloadFile")
|
@GetMapping("downloadFile")
|
||||||
public void getAliFile(@RequestParam String bucket, @RequestParam String userId, @RequestParam String filePath, HttpServletResponse response) throws Exception {
|
public Result getAliFile(@RequestParam String bucket, @RequestParam String userId, @RequestParam String filePath, HttpServletResponse response) throws Exception {
|
||||||
Preconditions.checkNotNull(bucket, "不能为空");
|
Preconditions.checkNotNull(bucket, "不能为空");
|
||||||
Preconditions.checkNotNull(userId, "不能为空");
|
Preconditions.checkNotNull(userId, "不能为空");
|
||||||
Preconditions.checkNotNull(filePath, "不能为空");
|
Preconditions.checkNotNull(filePath, "不能为空");
|
||||||
AliOssClient bean = SpringUtil.getBean(userId);
|
AliOssClient bean = SpringUtil.getBean(OssConstant.OssType.ALI + userId);
|
||||||
bean.getAliOssConfig().setBucketName(bucket);
|
bean.getAliOssConfig().setBucketName(bucket);
|
||||||
ServletOutputStream output = response.getOutputStream();
|
ServletOutputStream output = response.getOutputStream();
|
||||||
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(filePath.substring(filePath.lastIndexOf("/") + 1), "UTF-8"));
|
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(filePath.substring(filePath.lastIndexOf("/") + 1), "UTF-8"));
|
||||||
response.setContentType("application/octet-stream");
|
response.setContentType("application/octet-stream");
|
||||||
response.setCharacterEncoding("UTF-8");
|
response.setCharacterEncoding("UTF-8");
|
||||||
bean.downLoad(output, filePath);
|
bean.downLoad(output, filePath);
|
||||||
|
return Result.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -254,11 +304,11 @@ public class SchisandraOssAliController {
|
|||||||
* @date: 2024/6/26 14:34
|
* @date: 2024/6/26 14:34
|
||||||
*/
|
*/
|
||||||
@PostMapping("deleteFile")
|
@PostMapping("deleteFile")
|
||||||
public Result deleteAliFile(@RequestParam String bucket, @RequestParam String userId, @RequestParam String filePath) {
|
public Result<String> deleteAliFile(@RequestParam String bucket, @RequestParam String userId, @RequestParam String filePath) {
|
||||||
Preconditions.checkNotNull(bucket, "不能为空");
|
Preconditions.checkNotNull(bucket, "不能为空");
|
||||||
Preconditions.checkNotNull(userId, "不能为空");
|
Preconditions.checkNotNull(userId, "不能为空");
|
||||||
Preconditions.checkNotNull(filePath, "不能为空");
|
Preconditions.checkNotNull(filePath, "不能为空");
|
||||||
AliOssClient bean = SpringUtil.getBean(userId);
|
AliOssClient bean = SpringUtil.getBean(OssConstant.OssType.ALI + userId);
|
||||||
bean.getAliOssConfig().setBucketName(bucket);
|
bean.getAliOssConfig().setBucketName(bucket);
|
||||||
bean.delete(filePath);
|
bean.delete(filePath);
|
||||||
return Result.ok();
|
return Result.ok();
|
||||||
@@ -278,7 +328,7 @@ public class SchisandraOssAliController {
|
|||||||
Preconditions.checkNotNull(bucket, "不能为空");
|
Preconditions.checkNotNull(bucket, "不能为空");
|
||||||
Preconditions.checkNotNull(oldFileName, "不能为空");
|
Preconditions.checkNotNull(oldFileName, "不能为空");
|
||||||
Preconditions.checkNotNull(newFileName, "不能为空");
|
Preconditions.checkNotNull(newFileName, "不能为空");
|
||||||
AliOssClient bean = SpringUtil.getBean(userId);
|
AliOssClient bean = SpringUtil.getBean(OssConstant.OssType.ALI + userId);
|
||||||
bean.getAliOssConfig().setBucketName(bucket);
|
bean.getAliOssConfig().setBucketName(bucket);
|
||||||
try {
|
try {
|
||||||
bean.rename(oldFileName, newFileName);
|
bean.rename(oldFileName, newFileName);
|
||||||
|
@@ -3,13 +3,18 @@ package com.schisandra.oss.application.controller;
|
|||||||
import cn.hutool.core.util.ZipUtil;
|
import cn.hutool.core.util.ZipUtil;
|
||||||
import cn.hutool.extra.spring.SpringUtil;
|
import cn.hutool.extra.spring.SpringUtil;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.aliyun.oss.internal.OSSConstants;
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import com.schisandra.oss.application.convert.SchisandraOssMinioDTOConverter;
|
import com.schisandra.oss.application.convert.SchisandraOssMinioDTOConverter;
|
||||||
|
import com.schisandra.oss.application.convert.SchisandraOssQiniuDTOConverter;
|
||||||
import com.schisandra.oss.application.dto.SchisandraOssMinioDTO;
|
import com.schisandra.oss.application.dto.SchisandraOssMinioDTO;
|
||||||
|
import com.schisandra.oss.application.oss.constant.OssConstant;
|
||||||
import com.schisandra.oss.application.oss.core.minio.MinioOssClient;
|
import com.schisandra.oss.application.oss.core.minio.MinioOssClient;
|
||||||
import com.schisandra.oss.application.oss.core.minio.MinioOssConfiguration;
|
import com.schisandra.oss.application.oss.core.minio.MinioOssConfiguration;
|
||||||
import com.schisandra.oss.common.entity.Result;
|
import com.schisandra.oss.common.entity.Result;
|
||||||
|
import com.schisandra.oss.domain.bo.SchisandraOssAliBO;
|
||||||
import com.schisandra.oss.domain.bo.SchisandraOssMinioBO;
|
import com.schisandra.oss.domain.bo.SchisandraOssMinioBO;
|
||||||
|
import com.schisandra.oss.domain.bo.SchisandraOssQiniuBO;
|
||||||
import com.schisandra.oss.domain.redis.RedisUtil;
|
import com.schisandra.oss.domain.redis.RedisUtil;
|
||||||
import com.schisandra.oss.domain.service.SchisandraOssMinioDomainService;
|
import com.schisandra.oss.domain.service.SchisandraOssMinioDomainService;
|
||||||
import io.minio.errors.*;
|
import io.minio.errors.*;
|
||||||
@@ -58,8 +63,12 @@ public class SchisandraOssMinioController {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@GetMapping("returnAll")
|
@GetMapping("returnAll")
|
||||||
public List<SchisandraOssMinioDTO> returnAll() {
|
public Result returnAll() {
|
||||||
return minioOssConfiguration.selectAll();
|
List<SchisandraOssMinioBO> list = schisandraOssMinioDomainService.selectAll();
|
||||||
|
if(list.isEmpty()){
|
||||||
|
return Result.fail();
|
||||||
|
}
|
||||||
|
return Result.ok(SchisandraOssMinioDTOConverter.INSTANCE.convertBOToDTOList(list));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -71,17 +80,36 @@ public class SchisandraOssMinioController {
|
|||||||
* @date: 2024/5/15 13:34
|
* @date: 2024/5/15 13:34
|
||||||
*/
|
*/
|
||||||
@PostMapping("init")
|
@PostMapping("init")
|
||||||
public void initMinio(@RequestParam String userId) {
|
public Result initMinio(@RequestParam String userId,@RequestParam String Id) {
|
||||||
if (log.isInfoEnabled()) {
|
if (log.isInfoEnabled()) {
|
||||||
log.info("SchisandraOssMinioController.init.userId:{}", userId);
|
log.info("SchisandraOssMinioController.init.userId:{}", userId);
|
||||||
}
|
}
|
||||||
Preconditions.checkNotNull(userId, "用户id不能为空!");
|
Preconditions.checkNotNull(userId, "用户id不能为空!");
|
||||||
|
SchisandraOssMinioBO bo = new SchisandraOssMinioBO();
|
||||||
|
bo.setId(Long.valueOf(Id));
|
||||||
|
bo.setUserId(Long.valueOf(OssConstant.OssType.MINIO + userId));
|
||||||
|
bo.setStatus(String.valueOf(true));
|
||||||
|
if(schisandraOssMinioDomainService.update(bo)){
|
||||||
|
return minioOssConfiguration.minioOssClient(userId);
|
||||||
|
}else{
|
||||||
|
return Result.fail("初始化失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Result result = minioOssConfiguration.minioOssClient(userId);
|
@PostMapping("shutdown")
|
||||||
if (result.getSuccess()) {
|
public Result shutdownMinio(@RequestParam String userId,@RequestParam String Id){
|
||||||
log.info("用户: {}-> minio 初始化完成!", userId);
|
if (log.isInfoEnabled()) {
|
||||||
} else {
|
log.info("SchisandraOssMinioController.shutdown.userId:{}", JSON.toJSONString(userId));
|
||||||
log.error("用户: {}-> minio 初始化完成!", userId);
|
}
|
||||||
|
SchisandraOssMinioBO bo = new SchisandraOssMinioBO();
|
||||||
|
bo.setId(Long.valueOf(Id));
|
||||||
|
bo.setUserId(Long.valueOf(OssConstant.OssType.MINIO + userId));
|
||||||
|
bo.setStatus(String.valueOf(false));
|
||||||
|
if(schisandraOssMinioDomainService.update(bo)){
|
||||||
|
SpringUtil.unregisterBean(OssConstant.OssType.MINIO + userId);
|
||||||
|
return Result.ok("关闭成功");
|
||||||
|
}else{
|
||||||
|
return Result.fail("关闭失败");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,10 +120,10 @@ public class SchisandraOssMinioController {
|
|||||||
* @author zlg
|
* @author zlg
|
||||||
* @date: 2024/6/26 13:55
|
* @date: 2024/6/26 13:55
|
||||||
*/
|
*/
|
||||||
@GetMapping("listMinioDir")
|
@GetMapping("listDir")
|
||||||
public Result<String> listMinioInfo(@RequestParam String userId, @RequestParam String dirName, @RequestParam String bucket) throws Exception {
|
public Result<String> listMinioInfo(@RequestParam String userId, @RequestParam String dirName, @RequestParam String bucket) throws Exception {
|
||||||
Preconditions.checkNotNull(userId, "不能为空");
|
Preconditions.checkNotNull(userId, "不能为空");
|
||||||
MinioOssClient bean = SpringUtil.getBean(userId);
|
MinioOssClient bean = SpringUtil.getBean(OssConstant.OssType.MINIO + userId);
|
||||||
bean.getMinioOssConfig().setBucketName(bucket);
|
bean.getMinioOssConfig().setBucketName(bucket);
|
||||||
return Result.ok(bean.listDir(bucket, dirName));
|
return Result.ok(bean.listDir(bucket, dirName));
|
||||||
}
|
}
|
||||||
@@ -107,12 +135,12 @@ public class SchisandraOssMinioController {
|
|||||||
* @author zlg
|
* @author zlg
|
||||||
* @date: 2024/6/26 13:56
|
* @date: 2024/6/26 13:56
|
||||||
*/
|
*/
|
||||||
@GetMapping("downloadMinioFile")
|
@GetMapping("downloadFile")
|
||||||
public void getMinioFile(@RequestParam String bucket, @RequestParam String userId, @RequestParam List<String> listObjectsArgs, HttpServletResponse response) throws Exception {
|
public void getMinioFile(@RequestParam String bucket, @RequestParam String userId, @RequestParam List<String> listObjectsArgs, HttpServletResponse response) throws Exception {
|
||||||
Preconditions.checkNotNull(bucket, "不能为空");
|
Preconditions.checkNotNull(bucket, "不能为空");
|
||||||
Preconditions.checkNotNull(userId, "不能为空");
|
Preconditions.checkNotNull(userId, "不能为空");
|
||||||
Preconditions.checkNotNull(listObjectsArgs, "不能为空");
|
Preconditions.checkNotNull(listObjectsArgs, "不能为空");
|
||||||
MinioOssClient bean = SpringUtil.getBean(userId);
|
MinioOssClient bean = SpringUtil.getBean(OssConstant.OssType.MINIO + userId);
|
||||||
bean.getMinioOssConfig().setBucketName(bucket);
|
bean.getMinioOssConfig().setBucketName(bucket);
|
||||||
HashMap<String, InputStream> list = bean.getTargetDir(listObjectsArgs);
|
HashMap<String, InputStream> list = bean.getTargetDir(listObjectsArgs);
|
||||||
ServletOutputStream output = response.getOutputStream();
|
ServletOutputStream output = response.getOutputStream();
|
||||||
@@ -133,12 +161,12 @@ public class SchisandraOssMinioController {
|
|||||||
* @author zlg
|
* @author zlg
|
||||||
* @date: 2024/6/26 14:34
|
* @date: 2024/6/26 14:34
|
||||||
*/
|
*/
|
||||||
@PostMapping("deleteMinioFile")
|
@PostMapping("deleteFile")
|
||||||
public Result deleteMinioFile(@RequestParam String bucket, @RequestParam String userId, @RequestParam String filePath) {
|
public Result deleteMinioFile(@RequestParam String bucket, @RequestParam String userId, @RequestParam String filePath) {
|
||||||
Preconditions.checkNotNull(bucket, "不能为空");
|
Preconditions.checkNotNull(bucket, "不能为空");
|
||||||
Preconditions.checkNotNull(userId, "不能为空");
|
Preconditions.checkNotNull(userId, "不能为空");
|
||||||
Preconditions.checkNotNull(filePath, "不能为空");
|
Preconditions.checkNotNull(filePath, "不能为空");
|
||||||
MinioOssClient bean = SpringUtil.getBean(userId);
|
MinioOssClient bean = SpringUtil.getBean(OssConstant.OssType.MINIO + userId);
|
||||||
bean.getMinioOssConfig().setBucketName(bucket);
|
bean.getMinioOssConfig().setBucketName(bucket);
|
||||||
bean.delete(filePath);
|
bean.delete(filePath);
|
||||||
return Result.ok();
|
return Result.ok();
|
||||||
@@ -151,7 +179,7 @@ public class SchisandraOssMinioController {
|
|||||||
* @author zlg
|
* @author zlg
|
||||||
* @date: 2024/6/26 14:34
|
* @date: 2024/6/26 14:34
|
||||||
*/
|
*/
|
||||||
@PostMapping("uploadMinioFile")
|
@PostMapping("uploadFile")
|
||||||
public Result<Object> uploadMinioFile(@RequestParam String userId, @RequestParam MultipartFile file, @RequestParam String fileName, @RequestParam String bucket) throws IOException {
|
public Result<Object> uploadMinioFile(@RequestParam String userId, @RequestParam MultipartFile file, @RequestParam String fileName, @RequestParam String bucket) throws IOException {
|
||||||
Preconditions.checkNotNull(userId, "不能为空");
|
Preconditions.checkNotNull(userId, "不能为空");
|
||||||
Preconditions.checkNotNull(fileName, "不能为空");
|
Preconditions.checkNotNull(fileName, "不能为空");
|
||||||
@@ -171,7 +199,7 @@ public class SchisandraOssMinioController {
|
|||||||
|
|
||||||
// 获取文件输入流
|
// 获取文件输入流
|
||||||
InputStream is = file.getInputStream();
|
InputStream is = file.getInputStream();
|
||||||
MinioOssClient bean = SpringUtil.getBean(userId);
|
MinioOssClient bean = SpringUtil.getBean(OssConstant.OssType.MINIO + userId);
|
||||||
bean.getMinioOssConfig().setBucketName(bucket);
|
bean.getMinioOssConfig().setBucketName(bucket);
|
||||||
return Result.ok(bean.upLoad(is, fileName, true));
|
return Result.ok(bean.upLoad(is, fileName, true));
|
||||||
|
|
||||||
@@ -185,14 +213,14 @@ public class SchisandraOssMinioController {
|
|||||||
* @author zlg
|
* @author zlg
|
||||||
* @date: 2024/6/27 9:41
|
* @date: 2024/6/27 9:41
|
||||||
*/
|
*/
|
||||||
@PostMapping("renameMinioFile")
|
@PostMapping("renameFile")
|
||||||
public Result renameMinioFile(@RequestParam String userId, @RequestParam String bucket, @RequestParam String oldFileName, @RequestParam String newFileName) throws IOException {
|
public Result renameMinioFile(@RequestParam String userId, @RequestParam String bucket, @RequestParam String oldFileName, @RequestParam String newFileName) throws IOException {
|
||||||
|
|
||||||
Preconditions.checkNotNull(userId, "不能为空");
|
Preconditions.checkNotNull(userId, "不能为空");
|
||||||
Preconditions.checkNotNull(bucket, "不能为空");
|
Preconditions.checkNotNull(bucket, "不能为空");
|
||||||
Preconditions.checkNotNull(oldFileName, "不能为空");
|
Preconditions.checkNotNull(oldFileName, "不能为空");
|
||||||
Preconditions.checkNotNull(newFileName, "不能为空");
|
Preconditions.checkNotNull(newFileName, "不能为空");
|
||||||
MinioOssClient bean = SpringUtil.getBean(userId);
|
MinioOssClient bean = SpringUtil.getBean(OssConstant.OssType.MINIO + userId);
|
||||||
bean.getMinioOssConfig().setBucketName(bucket);
|
bean.getMinioOssConfig().setBucketName(bucket);
|
||||||
try {
|
try {
|
||||||
bean.rename(oldFileName, newFileName);
|
bean.rename(oldFileName, newFileName);
|
||||||
@@ -209,14 +237,14 @@ public class SchisandraOssMinioController {
|
|||||||
* @author zlg
|
* @author zlg
|
||||||
* @date: 2024/6/27 9:52
|
* @date: 2024/6/27 9:52
|
||||||
*/
|
*/
|
||||||
@PostMapping("copyMinioFile")
|
@PostMapping("copyFile")
|
||||||
public Result copyMinioFile(@RequestParam String userId, @RequestParam String bucket, @RequestParam String oldFilePath, @RequestParam String newFilePath) throws IOException {
|
public Result copyMinioFile(@RequestParam String userId, @RequestParam String bucket, @RequestParam String oldFilePath, @RequestParam String newFilePath) throws IOException {
|
||||||
|
|
||||||
Preconditions.checkNotNull(userId, "不能为空");
|
Preconditions.checkNotNull(userId, "不能为空");
|
||||||
Preconditions.checkNotNull(bucket, "不能为空");
|
Preconditions.checkNotNull(bucket, "不能为空");
|
||||||
Preconditions.checkNotNull(oldFilePath, "不能为空");
|
Preconditions.checkNotNull(oldFilePath, "不能为空");
|
||||||
Preconditions.checkNotNull(newFilePath, "不能为空");
|
Preconditions.checkNotNull(newFilePath, "不能为空");
|
||||||
MinioOssClient bean = SpringUtil.getBean(userId);
|
MinioOssClient bean = SpringUtil.getBean(OssConstant.OssType.MINIO + userId);
|
||||||
bean.getMinioOssConfig().setBucketName(bucket);
|
bean.getMinioOssConfig().setBucketName(bucket);
|
||||||
try {
|
try {
|
||||||
bean.copy(oldFilePath, newFilePath);
|
bean.copy(oldFilePath, newFilePath);
|
||||||
@@ -233,12 +261,12 @@ public class SchisandraOssMinioController {
|
|||||||
* @author zlg
|
* @author zlg
|
||||||
* @date: 2024/6/27 10:14
|
* @date: 2024/6/27 10:14
|
||||||
*/
|
*/
|
||||||
@PostMapping("previewMinioFile")
|
@PostMapping("previewFile")
|
||||||
public Result<String> previewMinioFile(@RequestParam String userId, @RequestParam String bucket, @RequestParam String filePath) throws IOException {
|
public Result<String> previewMinioFile(@RequestParam String userId, @RequestParam String bucket, @RequestParam String filePath) throws IOException {
|
||||||
Preconditions.checkNotNull(userId, "不能为空");
|
Preconditions.checkNotNull(userId, "不能为空");
|
||||||
Preconditions.checkNotNull(bucket, "不能为空");
|
Preconditions.checkNotNull(bucket, "不能为空");
|
||||||
Preconditions.checkNotNull(filePath, "不能为空");
|
Preconditions.checkNotNull(filePath, "不能为空");
|
||||||
MinioOssClient bean = SpringUtil.getBean(userId);
|
MinioOssClient bean = SpringUtil.getBean(OssConstant.OssType.MINIO + userId);
|
||||||
bean.getMinioOssConfig().setBucketName(bucket);
|
bean.getMinioOssConfig().setBucketName(bucket);
|
||||||
try {
|
try {
|
||||||
return Result.ok(bean.getMinioPreviewUrl(filePath));
|
return Result.ok(bean.getMinioPreviewUrl(filePath));
|
||||||
@@ -255,12 +283,12 @@ public class SchisandraOssMinioController {
|
|||||||
* @author zlg
|
* @author zlg
|
||||||
* @date: 2024/6/27 10:17
|
* @date: 2024/6/27 10:17
|
||||||
*/
|
*/
|
||||||
@PostMapping("shareMinioFile")
|
@PostMapping("shareFile")
|
||||||
public Result<String> shareMinioFile(@RequestParam String userId, @RequestParam String bucket, @RequestParam String filePath, @RequestParam int time) throws IOException {
|
public Result<String> shareMinioFile(@RequestParam String userId, @RequestParam String bucket, @RequestParam String filePath, @RequestParam int time) throws IOException {
|
||||||
Preconditions.checkNotNull(userId, "不能为空");
|
Preconditions.checkNotNull(userId, "不能为空");
|
||||||
Preconditions.checkNotNull(bucket, "不能为空");
|
Preconditions.checkNotNull(bucket, "不能为空");
|
||||||
Preconditions.checkNotNull(filePath, "不能为空");
|
Preconditions.checkNotNull(filePath, "不能为空");
|
||||||
MinioOssClient bean = SpringUtil.getBean(userId);
|
MinioOssClient bean = SpringUtil.getBean(OssConstant.OssType.MINIO + userId);
|
||||||
bean.getMinioOssConfig().setBucketName(bucket);
|
bean.getMinioOssConfig().setBucketName(bucket);
|
||||||
try {
|
try {
|
||||||
return Result.ok(bean.shareMinioFile(filePath, time));
|
return Result.ok(bean.shareMinioFile(filePath, time));
|
||||||
@@ -279,7 +307,7 @@ public class SchisandraOssMinioController {
|
|||||||
@PostMapping("seleteBucket")
|
@PostMapping("seleteBucket")
|
||||||
public Result<String> seleteBucket(@RequestParam String userId) throws ServerException, InsufficientDataException, ErrorResponseException, IOException, NoSuchAlgorithmException, InvalidKeyException, InvalidResponseException, XmlParserException, InternalException {
|
public Result<String> seleteBucket(@RequestParam String userId) throws ServerException, InsufficientDataException, ErrorResponseException, IOException, NoSuchAlgorithmException, InvalidKeyException, InvalidResponseException, XmlParserException, InternalException {
|
||||||
Preconditions.checkNotNull(userId, "不能为空");
|
Preconditions.checkNotNull(userId, "不能为空");
|
||||||
MinioOssClient bean = SpringUtil.getBean(userId);
|
MinioOssClient bean = SpringUtil.getBean(OssConstant.OssType.MINIO + userId);
|
||||||
return Result.ok(bean.selectAllBucket());
|
return Result.ok(bean.selectAllBucket());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -294,7 +322,7 @@ public class SchisandraOssMinioController {
|
|||||||
public Result<String> createBucket(@RequestParam String userId, @RequestParam String bucket) {
|
public Result<String> createBucket(@RequestParam String userId, @RequestParam String bucket) {
|
||||||
Preconditions.checkNotNull(userId, "不能为空");
|
Preconditions.checkNotNull(userId, "不能为空");
|
||||||
Preconditions.checkNotNull(bucket, "不能为空");
|
Preconditions.checkNotNull(bucket, "不能为空");
|
||||||
MinioOssClient bean = SpringUtil.getBean(userId);
|
MinioOssClient bean = SpringUtil.getBean(OssConstant.OssType.MINIO + userId);
|
||||||
bean.getMinioOssConfig().setBucketName(bucket);
|
bean.getMinioOssConfig().setBucketName(bucket);
|
||||||
return Result.ok(bean.createBucket(bucket));
|
return Result.ok(bean.createBucket(bucket));
|
||||||
}
|
}
|
||||||
@@ -310,7 +338,7 @@ public class SchisandraOssMinioController {
|
|||||||
public Result<String> deleteBucket(@RequestParam String userId, @RequestParam String bucket) {
|
public Result<String> deleteBucket(@RequestParam String userId, @RequestParam String bucket) {
|
||||||
Preconditions.checkNotNull(userId, "不能为空");
|
Preconditions.checkNotNull(userId, "不能为空");
|
||||||
Preconditions.checkNotNull(bucket, "不能为空");
|
Preconditions.checkNotNull(bucket, "不能为空");
|
||||||
MinioOssClient bean = SpringUtil.getBean(userId);
|
MinioOssClient bean = SpringUtil.getBean(OssConstant.OssType.MINIO + userId);
|
||||||
bean.getMinioOssConfig().setBucketName(bucket);
|
bean.getMinioOssConfig().setBucketName(bucket);
|
||||||
return Result.ok(bean.deleteBucket(bucket));
|
return Result.ok(bean.deleteBucket(bucket));
|
||||||
}
|
}
|
||||||
@@ -384,7 +412,7 @@ public class SchisandraOssMinioController {
|
|||||||
|
|
||||||
@PostMapping("getBaseInfo")
|
@PostMapping("getBaseInfo")
|
||||||
public Result getBaseInfo(@RequestParam String fileName, @RequestParam String userId) {
|
public Result getBaseInfo(@RequestParam String fileName, @RequestParam String userId) {
|
||||||
MinioOssClient bean = SpringUtil.getBean(userId);
|
MinioOssClient bean = SpringUtil.getBean(OssConstant.OssType.MINIO + userId);
|
||||||
if (bean == null) {
|
if (bean == null) {
|
||||||
log.error("容器获取失败!");
|
log.error("容器获取失败!");
|
||||||
return null;
|
return null;
|
||||||
|
@@ -4,14 +4,20 @@ import cn.hutool.extra.spring.SpringUtil;
|
|||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import com.schisandra.oss.application.convert.SchisandraOssQiniuDTOConverter;
|
import com.schisandra.oss.application.convert.SchisandraOssQiniuDTOConverter;
|
||||||
|
import com.schisandra.oss.application.convert.SchisandraOssSftpDTOConverter;
|
||||||
import com.schisandra.oss.application.dto.SchisandraOssQiniuDTO;
|
import com.schisandra.oss.application.dto.SchisandraOssQiniuDTO;
|
||||||
|
import com.schisandra.oss.application.oss.constant.OssConstant;
|
||||||
import com.schisandra.oss.application.oss.core.qiniu.QiNiuOssClient;
|
import com.schisandra.oss.application.oss.core.qiniu.QiNiuOssClient;
|
||||||
import com.schisandra.oss.application.oss.core.qiniu.QiNiuOssConfiguration;
|
import com.schisandra.oss.application.oss.core.qiniu.QiNiuOssConfiguration;
|
||||||
|
import com.schisandra.oss.application.oss.exception.OssException;
|
||||||
import com.schisandra.oss.application.oss.model.OssInfo;
|
import com.schisandra.oss.application.oss.model.OssInfo;
|
||||||
import com.schisandra.oss.common.entity.Result;
|
import com.schisandra.oss.common.entity.Result;
|
||||||
|
import com.schisandra.oss.domain.bo.SchisandraOssMinioBO;
|
||||||
import com.schisandra.oss.domain.bo.SchisandraOssQiniuBO;
|
import com.schisandra.oss.domain.bo.SchisandraOssQiniuBO;
|
||||||
|
import com.schisandra.oss.domain.bo.SchisandraOssSftpBO;
|
||||||
import com.schisandra.oss.domain.redis.RedisUtil;
|
import com.schisandra.oss.domain.redis.RedisUtil;
|
||||||
import com.schisandra.oss.domain.service.SchisandraOssQiniuDomainService;
|
import com.schisandra.oss.domain.service.SchisandraOssQiniuDomainService;
|
||||||
|
import lombok.SneakyThrows;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
@@ -52,8 +58,12 @@ public class SchisandraOssQiniuController {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@GetMapping("returnAll")
|
@GetMapping("returnAll")
|
||||||
public List<SchisandraOssQiniuDTO> returnAll() {
|
public Result returnAll() {
|
||||||
return qiNiuOssConfiguration.selectAll();
|
List<SchisandraOssQiniuBO> list = schisandraOssQiniuDomainService.selectAll();
|
||||||
|
if(list.isEmpty()){
|
||||||
|
return Result.fail();
|
||||||
|
}
|
||||||
|
return Result.ok(SchisandraOssQiniuDTOConverter.INSTANCE.convertBOToDTOList(list));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -65,9 +75,14 @@ public class SchisandraOssQiniuController {
|
|||||||
@GetMapping("listDir")
|
@GetMapping("listDir")
|
||||||
public Result<String> listQiniuInfo(@RequestParam String userId, @RequestParam String prefix, @RequestParam String bucket) throws Exception {
|
public Result<String> listQiniuInfo(@RequestParam String userId, @RequestParam String prefix, @RequestParam String bucket) throws Exception {
|
||||||
Preconditions.checkNotNull(userId, "不能为空");
|
Preconditions.checkNotNull(userId, "不能为空");
|
||||||
QiNiuOssClient bean = SpringUtil.getBean(userId);
|
QiNiuOssClient bean = SpringUtil.getBean(OssConstant.OssType.QINIU+ userId);
|
||||||
bean.getQiNiuOssConfig().setBucketName(bucket);
|
bean.getQiNiuOssConfig().setBucketName(bucket);
|
||||||
return Result.ok(bean.listfile(bucket, prefix));
|
if(bean.listfile(bucket, prefix).isEmpty()){
|
||||||
|
return Result.fail();
|
||||||
|
}else{
|
||||||
|
return Result.ok(bean.listfile(bucket, prefix));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -83,7 +98,7 @@ public class SchisandraOssQiniuController {
|
|||||||
Preconditions.checkNotNull(bucket, "不能为空");
|
Preconditions.checkNotNull(bucket, "不能为空");
|
||||||
Preconditions.checkNotNull(oldFileName, "不能为空");
|
Preconditions.checkNotNull(oldFileName, "不能为空");
|
||||||
Preconditions.checkNotNull(newFileName, "不能为空");
|
Preconditions.checkNotNull(newFileName, "不能为空");
|
||||||
QiNiuOssClient bean = SpringUtil.getBean(userId);
|
QiNiuOssClient bean = SpringUtil.getBean(OssConstant.OssType.QINIU+ userId);
|
||||||
bean.getQiNiuOssConfig().setBucketName(bucket);
|
bean.getQiNiuOssConfig().setBucketName(bucket);
|
||||||
try {
|
try {
|
||||||
bean.rename(oldFileName, newFileName);
|
bean.rename(oldFileName, newFileName);
|
||||||
@@ -107,7 +122,7 @@ public class SchisandraOssQiniuController {
|
|||||||
Preconditions.checkNotNull(bucket, "不能为空");
|
Preconditions.checkNotNull(bucket, "不能为空");
|
||||||
Preconditions.checkNotNull(oldFilePath, "不能为空");
|
Preconditions.checkNotNull(oldFilePath, "不能为空");
|
||||||
Preconditions.checkNotNull(newFilePath, "不能为空");
|
Preconditions.checkNotNull(newFilePath, "不能为空");
|
||||||
QiNiuOssClient bean = SpringUtil.getBean(userId);
|
QiNiuOssClient bean = SpringUtil.getBean(OssConstant.OssType.QINIU+ userId);
|
||||||
bean.getQiNiuOssConfig().setBucketName(bucket);
|
bean.getQiNiuOssConfig().setBucketName(bucket);
|
||||||
try {
|
try {
|
||||||
bean.copy(oldFilePath, newFilePath);
|
bean.copy(oldFilePath, newFilePath);
|
||||||
@@ -127,7 +142,7 @@ public class SchisandraOssQiniuController {
|
|||||||
*/
|
*/
|
||||||
@GetMapping("downloadFile")
|
@GetMapping("downloadFile")
|
||||||
public void download_open(@RequestParam String userId, @RequestParam String endpoint, @RequestParam String filename, HttpServletResponse response) throws IOException {
|
public void download_open(@RequestParam String userId, @RequestParam String endpoint, @RequestParam String filename, HttpServletResponse response) throws IOException {
|
||||||
QiNiuOssClient bean = SpringUtil.getBean(userId);
|
QiNiuOssClient bean = SpringUtil.getBean(OssConstant.OssType.QINIU+ userId);
|
||||||
bean.getQiNiuOssConfig().setEndpoint(endpoint);
|
bean.getQiNiuOssConfig().setEndpoint(endpoint);
|
||||||
ServletOutputStream output = response.getOutputStream();
|
ServletOutputStream output = response.getOutputStream();
|
||||||
|
|
||||||
@@ -150,10 +165,14 @@ public class SchisandraOssQiniuController {
|
|||||||
Preconditions.checkNotNull(bucket, "不能为空");
|
Preconditions.checkNotNull(bucket, "不能为空");
|
||||||
Preconditions.checkNotNull(userId, "不能为空");
|
Preconditions.checkNotNull(userId, "不能为空");
|
||||||
Preconditions.checkNotNull(filePath, "不能为空");
|
Preconditions.checkNotNull(filePath, "不能为空");
|
||||||
QiNiuOssClient bean = SpringUtil.getBean(userId);
|
QiNiuOssClient bean = SpringUtil.getBean(OssConstant.OssType.QINIU+ userId);
|
||||||
bean.getQiNiuOssConfig().setBucketName(bucket);
|
bean.getQiNiuOssConfig().setBucketName(bucket);
|
||||||
bean.delete(filePath);
|
try{
|
||||||
return Result.ok();
|
bean.delete(filePath);
|
||||||
|
return Result.ok();
|
||||||
|
}catch(OssException e){
|
||||||
|
return Result.fail();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -184,9 +203,12 @@ public class SchisandraOssQiniuController {
|
|||||||
|
|
||||||
// 获取文件输入流
|
// 获取文件输入流
|
||||||
InputStream is = file.getInputStream();
|
InputStream is = file.getInputStream();
|
||||||
QiNiuOssClient bean = SpringUtil.getBean(userId);
|
QiNiuOssClient bean = SpringUtil.getBean(OssConstant.OssType.QINIU+ userId);
|
||||||
bean.getQiNiuOssConfig().setBucketName(bucket);
|
bean.getQiNiuOssConfig().setBucketName(bucket);
|
||||||
return Result.ok(bean.upLoad(is, fileName, true));
|
if(bean.upLoad(is, fileName, true) != null){
|
||||||
|
return Result.ok(bean.upLoad(is, fileName, true));
|
||||||
|
}
|
||||||
|
return Result.fail();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -196,11 +218,16 @@ public class SchisandraOssQiniuController {
|
|||||||
* @return: com.schisandra.oss.common.entity.Result<java.lang.String>
|
* @return: com.schisandra.oss.common.entity.Result<java.lang.String>
|
||||||
* @date: 2024/7/8 17:37
|
* @date: 2024/7/8 17:37
|
||||||
*/
|
*/
|
||||||
@GetMapping("seleteBucket")
|
@SneakyThrows
|
||||||
public Result<String> seleteBucket(@RequestParam String userId) {
|
@PostMapping("seleteBucket")
|
||||||
|
public Result seleteBucket(@RequestParam String userId) {
|
||||||
Preconditions.checkNotNull(userId, "不能为空");
|
Preconditions.checkNotNull(userId, "不能为空");
|
||||||
QiNiuOssClient bean = SpringUtil.getBean(userId);
|
QiNiuOssClient bean = SpringUtil.getBean(OssConstant.OssType.QINIU+ userId);
|
||||||
return Result.ok(bean.selectAllBucket());
|
if(bean.selectAllBucket().isEmpty()){
|
||||||
|
return Result.fail();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return Result.ok(bean.selectAllBucket());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -210,12 +237,16 @@ public class SchisandraOssQiniuController {
|
|||||||
* @date: 2024/7/8 17:38
|
* @date: 2024/7/8 17:38
|
||||||
*/
|
*/
|
||||||
@PostMapping("deleteBucket")
|
@PostMapping("deleteBucket")
|
||||||
public Result<String> deleteBucket(@RequestParam String userId, @RequestParam String bucket) {
|
public Result deleteBucket(@RequestParam String userId, @RequestParam String bucket) {
|
||||||
Preconditions.checkNotNull(userId, "不能为空");
|
Preconditions.checkNotNull(userId, "不能为空");
|
||||||
Preconditions.checkNotNull(bucket, "不能为空");
|
Preconditions.checkNotNull(bucket, "不能为空");
|
||||||
QiNiuOssClient bean = SpringUtil.getBean(userId);
|
QiNiuOssClient bean = SpringUtil.getBean(OssConstant.OssType.QINIU+ userId);
|
||||||
bean.getQiNiuOssConfig().setBucketName(bucket);
|
bean.getQiNiuOssConfig().setBucketName(bucket);
|
||||||
return Result.ok(bean.deleteBucket(bucket));
|
if(bean.deleteBucket(bucket) == 1){
|
||||||
|
return Result.ok();
|
||||||
|
}else
|
||||||
|
return Result.fail("删除桶失败");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -225,18 +256,21 @@ public class SchisandraOssQiniuController {
|
|||||||
* @param bucket
|
* @param bucket
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@SneakyThrows
|
||||||
@PostMapping("createBucket")
|
@PostMapping("createBucket")
|
||||||
public Result<String> createBucket(@RequestParam String userId, @RequestParam String bucket, @RequestParam String region) {
|
public Result<String> createBucket(@RequestParam String userId, @RequestParam String bucket, @RequestParam String region) {
|
||||||
Preconditions.checkNotNull(userId, "不能为空");
|
Preconditions.checkNotNull(userId, "不能为空");
|
||||||
Preconditions.checkNotNull(bucket, "不能为空");
|
Preconditions.checkNotNull(bucket, "不能为空");
|
||||||
QiNiuOssClient bean = SpringUtil.getBean(userId);
|
QiNiuOssClient bean = SpringUtil.getBean(OssConstant.OssType.QINIU+ userId);
|
||||||
bean.getQiNiuOssConfig().setBucketName(bucket);
|
bean.getQiNiuOssConfig().setBucketName(bucket);
|
||||||
bean.getQiNiuOssConfig().setRegion(region);
|
bean.getQiNiuOssConfig().setRegion(region);
|
||||||
try {
|
if(bean.createBucket(bucket, region) == 1){
|
||||||
return Result.ok(bean.createBucket(bucket, region));
|
return Result.ok(bean.createBucket(bucket, region));
|
||||||
} catch (IOException e) {
|
}else
|
||||||
throw new RuntimeException(e);
|
return Result.fail("创建桶失败");
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -246,17 +280,36 @@ public class SchisandraOssQiniuController {
|
|||||||
* @date: 2024/7/8 13:34
|
* @date: 2024/7/8 13:34
|
||||||
*/
|
*/
|
||||||
@PostMapping("init")
|
@PostMapping("init")
|
||||||
public void initQiniu(@RequestParam String userId) {
|
public Result initQiniu(@RequestParam String userId,@RequestParam String Id) {
|
||||||
if (log.isInfoEnabled()) {
|
if (log.isInfoEnabled()) {
|
||||||
log.info("SchisandraOssQiniuController.init.userId:{}", userId);
|
log.info("SchisandraOssQiniuController.init.userId:{}", userId);
|
||||||
}
|
}
|
||||||
Preconditions.checkNotNull(userId, "用户id不能为空!");
|
Preconditions.checkNotNull(userId, "用户id不能为空!");
|
||||||
|
SchisandraOssQiniuBO bo = new SchisandraOssQiniuBO();
|
||||||
|
bo.setId(Long.valueOf(Id));
|
||||||
|
bo.setUserId(Long.valueOf(OssConstant.OssType.QINIU+ userId));
|
||||||
|
bo.setStatus(String.valueOf(true));
|
||||||
|
if(schisandraOssQiniuDomainService.update(bo)){
|
||||||
|
return qiNiuOssConfiguration.qiNiuOssClient(userId);
|
||||||
|
}else{
|
||||||
|
return Result.fail("初始化失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Result result = qiNiuOssConfiguration.qiNiuOssClient(userId);
|
@PostMapping("shutdown")
|
||||||
if (result != null) {
|
public Result shutdownQiniu(@RequestParam String userId,@RequestParam String Id){
|
||||||
log.info("用户: {}-> qiniu 初始化完成!", userId);
|
if (log.isInfoEnabled()) {
|
||||||
} else {
|
log.info("SchisandraOssQiniuController.shutdown.userId:{}", JSON.toJSONString(userId));
|
||||||
log.error("用户: {}-> qiniu 初始化失败!", userId);
|
}
|
||||||
|
SchisandraOssQiniuBO bo = new SchisandraOssQiniuBO();
|
||||||
|
bo.setId(Long.valueOf(Id));
|
||||||
|
bo.setUserId(Long.valueOf(OssConstant.OssType.QINIU + userId));
|
||||||
|
bo.setStatus(String.valueOf(false));
|
||||||
|
if(schisandraOssQiniuDomainService.update(bo)){
|
||||||
|
SpringUtil.unregisterBean(OssConstant.OssType.QINIU + userId);
|
||||||
|
return Result.ok("关闭成功");
|
||||||
|
}else{
|
||||||
|
return Result.fail("关闭失败");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -271,37 +324,6 @@ public class SchisandraOssQiniuController {
|
|||||||
if (log.isInfoEnabled()) {
|
if (log.isInfoEnabled()) {
|
||||||
log.info("SchisandraOssQiniuController.add.dto:{}", JSON.toJSONString(schisandraOssQiniuDTO));
|
log.info("SchisandraOssQiniuController.add.dto:{}", JSON.toJSONString(schisandraOssQiniuDTO));
|
||||||
}
|
}
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getId(), "不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getUserId(), "不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getBasePath(), "不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getAccessKey(), "不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getSecretKey(), "不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getBucketName(), "不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getRegion(), "使用的Region不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getUseHttpsDomains(), "空间相关上传管理操作是否使用 https , 默认 是不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getAccUpHostFirst(), "空间相关上传管理操作是否使用代理加速上传,默认 是不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getUseDefaultUpHostIfNone(), "使用 AutoRegion 时,如果从区域信息得到上传 host 失败,使用默认的上传域名上传,默认 是upload.qiniup.com,uploadz1.qiniup.com,upload-z2.qiniup.com,upload-na0.qiniup.com,upload-as0.qiniup.com不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getPutThreshold(), "如果文件大小大于此值则使用断点上传, 否则使用Form上传不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getConnectTimeout(), "连接超时时间 单位秒(默认10s)不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getWriteTimeout(), "写超时时间 单位秒(默认 0 , 不超时)不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getReadTimeout(), "回复超时时间 单位秒(默认30s)不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getDispatcherMaxRequests(), "底层HTTP库所有的并发执行的请求数量不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getDispatcherMaxRequestsPerHost(), "底层HTTP库对每个独立的Host进行并发请求的数量不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getConnectionPoolMaxIdleCount(), "底层HTTP库中复用连接对象的最大空闲数量不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getConnectionPoolMaxIdleMinutes(), "底层HTTP库中复用连接对象的回收周期(单位分钟)不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getRetryMax(), "上传失败重试次数不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getPartSize(), "分片大小,默认5MB不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getTaskNum(), "并发线程数,默认等于CPU的核数不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getStatus(), "状态不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getOpenAdvancedSetup(), "是否开启高级设置不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getCreatedBy(), "创建人不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getCreatedTime(), "创建时间不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getUpdateTime(), "更新时间不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getUpdateBy(), "更新人不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getIsDeleted(), "是否删除 0 未删除 1已删除不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getExtraJson(), "额外字段不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getCreateBucket(), "当桶不存在,是否创建不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getCheckBucket(), "启动检测桶,是否存在不能为空");
|
|
||||||
SchisandraOssQiniuBO SchisandraOssQiniuBO = SchisandraOssQiniuDTOConverter.INSTANCE.convertDTOToBO(schisandraOssQiniuDTO);
|
SchisandraOssQiniuBO SchisandraOssQiniuBO = SchisandraOssQiniuDTOConverter.INSTANCE.convertDTOToBO(schisandraOssQiniuDTO);
|
||||||
return Result.ok(schisandraOssQiniuDomainService.add(SchisandraOssQiniuBO));
|
return Result.ok(schisandraOssQiniuDomainService.add(SchisandraOssQiniuBO));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -321,37 +343,7 @@ public class SchisandraOssQiniuController {
|
|||||||
if (log.isInfoEnabled()) {
|
if (log.isInfoEnabled()) {
|
||||||
log.info("SchisandraOssQiniuController.update.dto:{}", JSON.toJSONString(schisandraOssQiniuDTO));
|
log.info("SchisandraOssQiniuController.update.dto:{}", JSON.toJSONString(schisandraOssQiniuDTO));
|
||||||
}
|
}
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getId(), "不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getUserId(), "不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getBasePath(), "不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getAccessKey(), "不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getSecretKey(), "不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getBucketName(), "不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getRegion(), "使用的Region不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getUseHttpsDomains(), "空间相关上传管理操作是否使用 https , 默认 是不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getAccUpHostFirst(), "空间相关上传管理操作是否使用代理加速上传,默认 是不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getUseDefaultUpHostIfNone(), "使用 AutoRegion 时,如果从区域信息得到上传 host 失败,使用默认的上传域名上传,默认 是upload.qiniup.com,uploadz1.qiniup.com,upload-z2.qiniup.com,upload-na0.qiniup.com,upload-as0.qiniup.com不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getPutThreshold(), "如果文件大小大于此值则使用断点上传, 否则使用Form上传不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getConnectTimeout(), "连接超时时间 单位秒(默认10s)不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getWriteTimeout(), "写超时时间 单位秒(默认 0 , 不超时)不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getReadTimeout(), "回复超时时间 单位秒(默认30s)不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getDispatcherMaxRequests(), "底层HTTP库所有的并发执行的请求数量不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getDispatcherMaxRequestsPerHost(), "底层HTTP库对每个独立的Host进行并发请求的数量不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getConnectionPoolMaxIdleCount(), "底层HTTP库中复用连接对象的最大空闲数量不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getConnectionPoolMaxIdleMinutes(), "底层HTTP库中复用连接对象的回收周期(单位分钟)不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getRetryMax(), "上传失败重试次数不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getPartSize(), "分片大小,默认5MB不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getTaskNum(), "并发线程数,默认等于CPU的核数不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getStatus(), "状态不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getOpenAdvancedSetup(), "是否开启高级设置不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getCreatedBy(), "创建人不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getCreatedTime(), "创建时间不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getUpdateTime(), "更新时间不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getUpdateBy(), "更新人不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getIsDeleted(), "是否删除 0 未删除 1已删除不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getExtraJson(), "额外字段不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getCreateBucket(), "当桶不存在,是否创建不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getCheckBucket(), "启动检测桶,是否存在不能为空");
|
|
||||||
SchisandraOssQiniuBO schisandraOssQiniuBO = SchisandraOssQiniuDTOConverter.INSTANCE.convertDTOToBO(schisandraOssQiniuDTO);
|
SchisandraOssQiniuBO schisandraOssQiniuBO = SchisandraOssQiniuDTOConverter.INSTANCE.convertDTOToBO(schisandraOssQiniuDTO);
|
||||||
return Result.ok(schisandraOssQiniuDomainService.update(schisandraOssQiniuBO));
|
return Result.ok(schisandraOssQiniuDomainService.update(schisandraOssQiniuBO));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -371,37 +363,6 @@ public class SchisandraOssQiniuController {
|
|||||||
if (log.isInfoEnabled()) {
|
if (log.isInfoEnabled()) {
|
||||||
log.info("SchisandraOssQiniuController.delete.dto:{}", JSON.toJSONString(schisandraOssQiniuDTO));
|
log.info("SchisandraOssQiniuController.delete.dto:{}", JSON.toJSONString(schisandraOssQiniuDTO));
|
||||||
}
|
}
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getId(), "不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getUserId(), "不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getBasePath(), "不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getAccessKey(), "不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getSecretKey(), "不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getBucketName(), "不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getRegion(), "使用的Region不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getUseHttpsDomains(), "空间相关上传管理操作是否使用 https , 默认 是不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getAccUpHostFirst(), "空间相关上传管理操作是否使用代理加速上传,默认 是不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getUseDefaultUpHostIfNone(), "使用 AutoRegion 时,如果从区域信息得到上传 host 失败,使用默认的上传域名上传,默认 是upload.qiniup.com,uploadz1.qiniup.com,upload-z2.qiniup.com,upload-na0.qiniup.com,upload-as0.qiniup.com不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getPutThreshold(), "如果文件大小大于此值则使用断点上传, 否则使用Form上传不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getConnectTimeout(), "连接超时时间 单位秒(默认10s)不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getWriteTimeout(), "写超时时间 单位秒(默认 0 , 不超时)不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getReadTimeout(), "回复超时时间 单位秒(默认30s)不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getDispatcherMaxRequests(), "底层HTTP库所有的并发执行的请求数量不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getDispatcherMaxRequestsPerHost(), "底层HTTP库对每个独立的Host进行并发请求的数量不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getConnectionPoolMaxIdleCount(), "底层HTTP库中复用连接对象的最大空闲数量不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getConnectionPoolMaxIdleMinutes(), "底层HTTP库中复用连接对象的回收周期(单位分钟)不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getRetryMax(), "上传失败重试次数不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getPartSize(), "分片大小,默认5MB不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getTaskNum(), "并发线程数,默认等于CPU的核数不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getStatus(), "状态不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getOpenAdvancedSetup(), "是否开启高级设置不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getCreatedBy(), "创建人不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getCreatedTime(), "创建时间不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getUpdateTime(), "更新时间不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getUpdateBy(), "更新人不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getIsDeleted(), "是否删除 0 未删除 1已删除不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getExtraJson(), "额外字段不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getCreateBucket(), "当桶不存在,是否创建不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssQiniuDTO.getCheckBucket(), "启动检测桶,是否存在不能为空");
|
|
||||||
SchisandraOssQiniuBO schisandraOssQiniuBO = SchisandraOssQiniuDTOConverter.INSTANCE.convertDTOToBO(schisandraOssQiniuDTO);
|
SchisandraOssQiniuBO schisandraOssQiniuBO = SchisandraOssQiniuDTOConverter.INSTANCE.convertDTOToBO(schisandraOssQiniuDTO);
|
||||||
return Result.ok(schisandraOssQiniuDomainService.delete(schisandraOssQiniuBO));
|
return Result.ok(schisandraOssQiniuDomainService.delete(schisandraOssQiniuBO));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@@ -3,14 +3,19 @@ package com.schisandra.oss.application.controller;
|
|||||||
import cn.hutool.extra.spring.SpringUtil;
|
import cn.hutool.extra.spring.SpringUtil;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
|
import com.schisandra.oss.application.convert.SchisandraOssQiniuDTOConverter;
|
||||||
import com.schisandra.oss.application.convert.SchisandraOssSftpDTOConverter;
|
import com.schisandra.oss.application.convert.SchisandraOssSftpDTOConverter;
|
||||||
|
import com.schisandra.oss.application.convert.SchisandraOssTencentDTOConverter;
|
||||||
import com.schisandra.oss.application.dto.SchisandraOssSftpDTO;
|
import com.schisandra.oss.application.dto.SchisandraOssSftpDTO;
|
||||||
|
import com.schisandra.oss.application.oss.constant.OssConstant;
|
||||||
import com.schisandra.oss.application.oss.core.qiniu.QiNiuOssClient;
|
import com.schisandra.oss.application.oss.core.qiniu.QiNiuOssClient;
|
||||||
import com.schisandra.oss.application.oss.core.sftp.SftpOssClient;
|
import com.schisandra.oss.application.oss.core.sftp.SftpOssClient;
|
||||||
import com.schisandra.oss.application.oss.core.sftp.SftpOssConfiguration;
|
import com.schisandra.oss.application.oss.core.sftp.SftpOssConfiguration;
|
||||||
import com.schisandra.oss.application.oss.model.OssInfo;
|
import com.schisandra.oss.application.oss.model.OssInfo;
|
||||||
import com.schisandra.oss.common.entity.Result;
|
import com.schisandra.oss.common.entity.Result;
|
||||||
|
import com.schisandra.oss.domain.bo.SchisandraOssAliBO;
|
||||||
import com.schisandra.oss.domain.bo.SchisandraOssSftpBO;
|
import com.schisandra.oss.domain.bo.SchisandraOssSftpBO;
|
||||||
|
import com.schisandra.oss.domain.bo.SchisandraOssTencentBO;
|
||||||
import com.schisandra.oss.domain.redis.RedisUtil;
|
import com.schisandra.oss.domain.redis.RedisUtil;
|
||||||
import com.schisandra.oss.domain.service.SchisandraOssSftpDomainService;
|
import com.schisandra.oss.domain.service.SchisandraOssSftpDomainService;
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
@@ -55,8 +60,12 @@ public class SchisandraOssSftpController {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@GetMapping("returnAll")
|
@GetMapping("returnAll")
|
||||||
public List<SchisandraOssSftpDTO> returnAll() {
|
public Result returnAll() {
|
||||||
return sftpOssConfiguration.selectAll();
|
List<SchisandraOssSftpBO> list = schisandraOssSftpDomainService.selectAll();
|
||||||
|
if(list.isEmpty()){
|
||||||
|
return Result.fail();
|
||||||
|
}
|
||||||
|
return Result.ok(SchisandraOssSftpDTOConverter.INSTANCE.convertBOToDTOList(list));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -71,7 +80,7 @@ public class SchisandraOssSftpController {
|
|||||||
Preconditions.checkNotNull(userId, "不能为空");
|
Preconditions.checkNotNull(userId, "不能为空");
|
||||||
Preconditions.checkNotNull(oldFilePath, "不能为空");
|
Preconditions.checkNotNull(oldFilePath, "不能为空");
|
||||||
Preconditions.checkNotNull(newFilePath, "不能为空");
|
Preconditions.checkNotNull(newFilePath, "不能为空");
|
||||||
QiNiuOssClient bean = SpringUtil.getBean(userId);
|
QiNiuOssClient bean = SpringUtil.getBean(OssConstant.OssType.SFTP + userId);
|
||||||
try {
|
try {
|
||||||
bean.copy(oldFilePath, newFilePath);
|
bean.copy(oldFilePath, newFilePath);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -89,7 +98,7 @@ public class SchisandraOssSftpController {
|
|||||||
Preconditions.checkNotNull(userId, "不能为空");
|
Preconditions.checkNotNull(userId, "不能为空");
|
||||||
Preconditions.checkNotNull(oldFileName, "不能为空");
|
Preconditions.checkNotNull(oldFileName, "不能为空");
|
||||||
Preconditions.checkNotNull(newFileName, "不能为空");
|
Preconditions.checkNotNull(newFileName, "不能为空");
|
||||||
SftpOssClient bean = SpringUtil.getBean(userId);
|
SftpOssClient bean = SpringUtil.getBean(OssConstant.OssType.SFTP + userId);
|
||||||
try {
|
try {
|
||||||
bean.rename(oldFileName, newFileName);
|
bean.rename(oldFileName, newFileName);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -107,7 +116,7 @@ public class SchisandraOssSftpController {
|
|||||||
@GetMapping("listDir")
|
@GetMapping("listDir")
|
||||||
public Result<String> listSftpInfo(@RequestParam String userId, @RequestParam String prefix) throws Exception {
|
public Result<String> listSftpInfo(@RequestParam String userId, @RequestParam String prefix) throws Exception {
|
||||||
Preconditions.checkNotNull(userId, "不能为空");
|
Preconditions.checkNotNull(userId, "不能为空");
|
||||||
SftpOssClient bean = SpringUtil.getBean(userId);
|
SftpOssClient bean = SpringUtil.getBean(OssConstant.OssType.SFTP + userId);
|
||||||
return Result.ok(bean.listfile(prefix));
|
return Result.ok(bean.listfile(prefix));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,7 +126,7 @@ public class SchisandraOssSftpController {
|
|||||||
*/
|
*/
|
||||||
@PostMapping("deleteFile")
|
@PostMapping("deleteFile")
|
||||||
public Result deleteSftpFile(@RequestParam String userId, @RequestParam String fileName) {
|
public Result deleteSftpFile(@RequestParam String userId, @RequestParam String fileName) {
|
||||||
SftpOssClient bean = SpringUtil.getBean(userId);
|
SftpOssClient bean = SpringUtil.getBean(OssConstant.OssType.SFTP + userId);
|
||||||
bean.delete(fileName);
|
bean.delete(fileName);
|
||||||
return Result.ok();
|
return Result.ok();
|
||||||
}
|
}
|
||||||
@@ -129,7 +138,7 @@ public class SchisandraOssSftpController {
|
|||||||
|
|
||||||
@GetMapping("downloadFile")
|
@GetMapping("downloadFile")
|
||||||
public void downloadSftpFile(@RequestParam String userId, @RequestParam String filename, HttpServletResponse response) throws IOException {
|
public void downloadSftpFile(@RequestParam String userId, @RequestParam String filename, HttpServletResponse response) throws IOException {
|
||||||
SftpOssClient bean = SpringUtil.getBean(userId);
|
SftpOssClient bean = SpringUtil.getBean(OssConstant.OssType.SFTP + userId);
|
||||||
ServletOutputStream output = response.getOutputStream();
|
ServletOutputStream output = response.getOutputStream();
|
||||||
|
|
||||||
|
|
||||||
@@ -164,7 +173,7 @@ public class SchisandraOssSftpController {
|
|||||||
|
|
||||||
// 获取文件输入流
|
// 获取文件输入流
|
||||||
InputStream is = file.getInputStream();
|
InputStream is = file.getInputStream();
|
||||||
SftpOssClient bean = SpringUtil.getBean(userId);
|
SftpOssClient bean = SpringUtil.getBean(OssConstant.OssType.SFTP + userId);
|
||||||
|
|
||||||
return Result.ok(bean.upLoad(is, fileName, true));
|
return Result.ok(bean.upLoad(is, fileName, true));
|
||||||
}
|
}
|
||||||
@@ -177,17 +186,36 @@ public class SchisandraOssSftpController {
|
|||||||
* @date: 2024/7/12 13:34
|
* @date: 2024/7/12 13:34
|
||||||
*/
|
*/
|
||||||
@PostMapping("init")
|
@PostMapping("init")
|
||||||
public void initSftp(@RequestParam String userId) {
|
public Result initSftp(@RequestParam String userId,@RequestParam String Id) {
|
||||||
if (log.isInfoEnabled()) {
|
if (log.isInfoEnabled()) {
|
||||||
log.info("SchisandraOssSftpController.init.userId:{}", userId);
|
log.info("SchisandraOssSftpController.init.userId:{}", userId);
|
||||||
}
|
}
|
||||||
Preconditions.checkNotNull(userId, "用户id不能为空!");
|
Preconditions.checkNotNull(userId, "用户id不能为空!");
|
||||||
|
SchisandraOssSftpBO bo = new SchisandraOssSftpBO();
|
||||||
|
bo.setId(Long.valueOf(Id));
|
||||||
|
bo.setUserId(Long.valueOf(OssConstant.OssType.SFTP+ userId));
|
||||||
|
bo.setStatus(String.valueOf(true));
|
||||||
|
if(schisandraOssSftpDomainService.update(bo)){
|
||||||
|
return sftpOssConfiguration.sftpOssClient(userId);
|
||||||
|
}else{
|
||||||
|
return Result.fail("初始化失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Result result = sftpOssConfiguration.sftpOssClient(userId);
|
@PostMapping("shutdown")
|
||||||
if (result != null) {
|
public Result shutdownSftp(@RequestParam String userId,@RequestParam String Id){
|
||||||
log.info("用户: {}-> sftp 初始化完成!", userId);
|
if (log.isInfoEnabled()) {
|
||||||
} else {
|
log.info("SchisandraOssSftpController.shutdown.userId:{}", JSON.toJSONString(userId));
|
||||||
log.error("用户: {}-> sftp 初始化失败!", userId);
|
}
|
||||||
|
SchisandraOssSftpBO bo = new SchisandraOssSftpBO();
|
||||||
|
bo.setId(Long.valueOf(Id));
|
||||||
|
bo.setUserId(Long.valueOf(OssConstant.OssType.SFTP + userId));
|
||||||
|
bo.setStatus(String.valueOf(false));
|
||||||
|
if(schisandraOssSftpDomainService.update(bo)){
|
||||||
|
SpringUtil.unregisterBean(OssConstant.OssType.SFTP+ userId);
|
||||||
|
return Result.ok("关闭成功");
|
||||||
|
}else{
|
||||||
|
return Result.fail("关闭失败");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -202,28 +230,6 @@ public class SchisandraOssSftpController {
|
|||||||
if (log.isInfoEnabled()) {
|
if (log.isInfoEnabled()) {
|
||||||
log.info("SchisandraOssSftpController.add.dto:{}", JSON.toJSONString(schisandraOssSftpDTO));
|
log.info("SchisandraOssSftpController.add.dto:{}", JSON.toJSONString(schisandraOssSftpDTO));
|
||||||
}
|
}
|
||||||
Preconditions.checkNotNull(schisandraOssSftpDTO.getId(), "不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssSftpDTO.getUserId(), "不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssSftpDTO.getHost(), "主机不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssSftpDTO.getPort(), "端口不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssSftpDTO.getBasePath(), "不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssSftpDTO.getUser(), "不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssSftpDTO.getPassword(), "不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssSftpDTO.getCharset(), "编码不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssSftpDTO.getConnectionTimeout(), "连接超时时长,单位毫秒不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssSftpDTO.getSoTimeout(), "Socket连接超时时长,单位毫秒不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssSftpDTO.getServerLanguageCode(), "设置服务器语言不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssSftpDTO.getSystemKey(), "设置服务器系统关键词不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssSftpDTO.getPartSize(), "分片大小,默认5MB不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssSftpDTO.getTaskNum(), "并发线程数,默认等于CPU的核数不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssSftpDTO.getStatus(), "状态不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssSftpDTO.getOpenAdvancedSetup(), "是否开启高级设置不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssSftpDTO.getCreatedBy(), "创建人不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssSftpDTO.getCreatedTime(), "创建时间不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssSftpDTO.getUpdateTime(), "更新时间不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssSftpDTO.getUpdateBy(), "更新人不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssSftpDTO.getIsDeleted(), "是否删除 0 未删除 1已删除不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssSftpDTO.getExtraJson(), "额外字段不能为空");
|
|
||||||
SchisandraOssSftpBO SchisandraOssSftpBO = SchisandraOssSftpDTOConverter.INSTANCE.convertDTOToBO(schisandraOssSftpDTO);
|
SchisandraOssSftpBO SchisandraOssSftpBO = SchisandraOssSftpDTOConverter.INSTANCE.convertDTOToBO(schisandraOssSftpDTO);
|
||||||
return Result.ok(schisandraOssSftpDomainService.add(SchisandraOssSftpBO));
|
return Result.ok(schisandraOssSftpDomainService.add(SchisandraOssSftpBO));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@@ -8,14 +8,18 @@ import com.qcloud.cos.model.CopyResult;
|
|||||||
import com.qcloud.cos.model.DeleteObjectsRequest;
|
import com.qcloud.cos.model.DeleteObjectsRequest;
|
||||||
import com.qcloud.cos.model.DeleteObjectsResult;
|
import com.qcloud.cos.model.DeleteObjectsResult;
|
||||||
import com.schisandra.oss.application.convert.SchisandraOssTencentDTOConverter;
|
import com.schisandra.oss.application.convert.SchisandraOssTencentDTOConverter;
|
||||||
|
import com.schisandra.oss.application.convert.SchisandraOssUpDTOConverter;
|
||||||
import com.schisandra.oss.application.dto.SchisandraOssTencentDTO;
|
import com.schisandra.oss.application.dto.SchisandraOssTencentDTO;
|
||||||
|
|
||||||
import com.schisandra.oss.application.dto.SchisandraOssUpDTO;
|
import com.schisandra.oss.application.dto.SchisandraOssUpDTO;
|
||||||
|
import com.schisandra.oss.application.oss.constant.OssConstant;
|
||||||
import com.schisandra.oss.application.oss.core.minio.MinioOssClient;
|
import com.schisandra.oss.application.oss.core.minio.MinioOssClient;
|
||||||
import com.schisandra.oss.application.oss.core.tencent.TencentOssClient;
|
import com.schisandra.oss.application.oss.core.tencent.TencentOssClient;
|
||||||
import com.schisandra.oss.application.oss.core.tencent.TencentOssConfiguration;
|
import com.schisandra.oss.application.oss.core.tencent.TencentOssConfiguration;
|
||||||
import com.schisandra.oss.common.entity.Result;
|
import com.schisandra.oss.common.entity.Result;
|
||||||
|
import com.schisandra.oss.domain.bo.SchisandraOssAliBO;
|
||||||
import com.schisandra.oss.domain.bo.SchisandraOssTencentBO;
|
import com.schisandra.oss.domain.bo.SchisandraOssTencentBO;
|
||||||
|
import com.schisandra.oss.domain.bo.SchisandraOssUpBO;
|
||||||
import com.schisandra.oss.domain.redis.RedisUtil;
|
import com.schisandra.oss.domain.redis.RedisUtil;
|
||||||
import com.schisandra.oss.domain.service.SchisandraOssTencentDomainService;
|
import com.schisandra.oss.domain.service.SchisandraOssTencentDomainService;
|
||||||
import io.minio.errors.*;
|
import io.minio.errors.*;
|
||||||
@@ -56,28 +60,49 @@ public class SchisandraOssTencentController {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@GetMapping("returnAll")
|
@GetMapping("returnAll")
|
||||||
public List<SchisandraOssTencentDTO> returnAll() {
|
public Result returnAll() {
|
||||||
return tencentOssConfiguration.selectAll();
|
List<SchisandraOssTencentBO> list = schisandraOssTencentDomainService.selectAll();
|
||||||
|
if(list.isEmpty()){
|
||||||
|
return Result.fail();
|
||||||
|
}
|
||||||
|
return Result.ok(SchisandraOssTencentDTOConverter.INSTANCE.convertBOToDTOList(list));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@PostMapping("init")
|
@PostMapping("init")
|
||||||
public void initTencent(@RequestParam String userId) throws ServerException, InsufficientDataException, ErrorResponseException, IOException, NoSuchAlgorithmException, InvalidKeyException, InvalidResponseException, XmlParserException, InternalException {
|
public Result initTencent(@RequestParam String userId,@RequestParam String Id){
|
||||||
|
|
||||||
|
|
||||||
if (log.isInfoEnabled()) {
|
if (log.isInfoEnabled()) {
|
||||||
log.info("SchisandraOssTencentController.init.userId:{}", userId);
|
log.info("SchisandraOssTencentController.init.userId:{}", userId);
|
||||||
}
|
}
|
||||||
Preconditions.checkNotNull(userId, "用户id不能为空!");
|
Preconditions.checkNotNull(userId, "用户id不能为空!");
|
||||||
|
SchisandraOssTencentBO bo = new SchisandraOssTencentBO();
|
||||||
Result result = tencentOssConfiguration.tencentOssClient(userId);
|
bo.setId(Long.valueOf(Id));
|
||||||
if (result.getSuccess()) {
|
bo.setUserId(Long.valueOf(OssConstant.OssType.TENCENT+ userId));
|
||||||
log.info("用户: {}-> TencentOSS 初始化完成!", userId);
|
bo.setStatus(String.valueOf(true));
|
||||||
} else {
|
if(schisandraOssTencentDomainService.update(bo)){
|
||||||
log.error("用户: {}-> TencentOSS 初始化完成!", userId);
|
return tencentOssConfiguration.tencentOssClient(userId);
|
||||||
|
}else{
|
||||||
|
return Result.fail("初始化失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("shutdown")
|
||||||
|
public Result shutdownTencent(@RequestParam String userId,@RequestParam String Id){
|
||||||
|
if (log.isInfoEnabled()) {
|
||||||
|
log.info("SchisandraOssTencentController.shutdown.userId:{}", JSON.toJSONString(userId));
|
||||||
|
}
|
||||||
|
SchisandraOssTencentBO bo = new SchisandraOssTencentBO();
|
||||||
|
bo.setId(Long.valueOf(Id));
|
||||||
|
bo.setUserId(Long.valueOf(OssConstant.OssType.TENCENT + userId));
|
||||||
|
bo.setStatus(String.valueOf(false));
|
||||||
|
if(schisandraOssTencentDomainService.update(bo)){
|
||||||
|
SpringUtil.unregisterBean(OssConstant.OssType.TENCENT+ userId);
|
||||||
|
return Result.ok("关闭成功");
|
||||||
|
}else{
|
||||||
|
return Result.fail("关闭失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description: 查询所有存储桶
|
* @description: 查询所有存储桶
|
||||||
* @param: [userId]
|
* @param: [userId]
|
||||||
@@ -88,7 +113,7 @@ public class SchisandraOssTencentController {
|
|||||||
@PostMapping("seleteBucket")
|
@PostMapping("seleteBucket")
|
||||||
public Result<String> seleteBucket(@RequestParam String userId) throws ServerException, InsufficientDataException, ErrorResponseException, IOException, NoSuchAlgorithmException, InvalidKeyException, InvalidResponseException, XmlParserException, InternalException {
|
public Result<String> seleteBucket(@RequestParam String userId) throws ServerException, InsufficientDataException, ErrorResponseException, IOException, NoSuchAlgorithmException, InvalidKeyException, InvalidResponseException, XmlParserException, InternalException {
|
||||||
Preconditions.checkNotNull(userId, "不能为空");
|
Preconditions.checkNotNull(userId, "不能为空");
|
||||||
TencentOssClient bean = SpringUtil.getBean(userId);
|
TencentOssClient bean = SpringUtil.getBean(OssConstant.OssType.TENCENT+ userId);
|
||||||
return Result.ok(bean.selectAllBucket());
|
return Result.ok(bean.selectAllBucket());
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@@ -98,11 +123,11 @@ public class SchisandraOssTencentController {
|
|||||||
* @author zlg
|
* @author zlg
|
||||||
* @date: 2024/6/29 13:28
|
* @date: 2024/6/29 13:28
|
||||||
*/
|
*/
|
||||||
@GetMapping("listTencentDir")
|
@GetMapping("listDir")
|
||||||
public Result<String> listMinioInfo(@RequestParam String userId, @RequestParam String dirName,@RequestParam String bucket) throws Exception {
|
public Result<String> listTencentInfo(@RequestParam String userId, @RequestParam String dirName,@RequestParam String bucket) throws Exception {
|
||||||
Preconditions.checkNotNull(bucket, "不能为空");
|
Preconditions.checkNotNull(bucket, "不能为空");
|
||||||
Preconditions.checkNotNull(userId, "不能为空");
|
Preconditions.checkNotNull(userId, "不能为空");
|
||||||
TencentOssClient bean = SpringUtil.getBean(userId);
|
TencentOssClient bean = SpringUtil.getBean(OssConstant.OssType.TENCENT+ userId);
|
||||||
bean.getTencentOssConfig().setBucketName(bucket);
|
bean.getTencentOssConfig().setBucketName(bucket);
|
||||||
return Result.ok(bean.listTargetDir(bucket, dirName));
|
return Result.ok(bean.listTargetDir(bucket, dirName));
|
||||||
}
|
}
|
||||||
@@ -117,7 +142,7 @@ public class SchisandraOssTencentController {
|
|||||||
public Result<String> createBucket(@RequestParam String userId, @RequestParam String bucket,@RequestParam String appId) {
|
public Result<String> createBucket(@RequestParam String userId, @RequestParam String bucket,@RequestParam String appId) {
|
||||||
Preconditions.checkNotNull(userId, "不能为空");
|
Preconditions.checkNotNull(userId, "不能为空");
|
||||||
Preconditions.checkNotNull(bucket, "不能为空");
|
Preconditions.checkNotNull(bucket, "不能为空");
|
||||||
TencentOssClient bean = SpringUtil.getBean(userId);
|
TencentOssClient bean = SpringUtil.getBean(OssConstant.OssType.TENCENT+ userId);
|
||||||
// bean.getTencentOssConfig().setBucketName(bucket);
|
// bean.getTencentOssConfig().setBucketName(bucket);
|
||||||
return Result.ok(bean.createBuctet(bucket,appId));
|
return Result.ok(bean.createBuctet(bucket,appId));
|
||||||
}
|
}
|
||||||
@@ -132,7 +157,7 @@ public class SchisandraOssTencentController {
|
|||||||
public Result<String> deleteBucket(@RequestParam String userId, @RequestParam String bucket,@RequestParam String appId) {
|
public Result<String> deleteBucket(@RequestParam String userId, @RequestParam String bucket,@RequestParam String appId) {
|
||||||
Preconditions.checkNotNull(userId, "不能为空");
|
Preconditions.checkNotNull(userId, "不能为空");
|
||||||
Preconditions.checkNotNull(bucket, "不能为空");
|
Preconditions.checkNotNull(bucket, "不能为空");
|
||||||
TencentOssClient bean = SpringUtil.getBean(userId);
|
TencentOssClient bean = SpringUtil.getBean(OssConstant.OssType.TENCENT+ userId);
|
||||||
// bean.getTencentOssConfig().setBucketName(bucket);
|
// bean.getTencentOssConfig().setBucketName(bucket);
|
||||||
if (bean.deleteBucket(bucket,appId)){
|
if (bean.deleteBucket(bucket,appId)){
|
||||||
return Result.ok();
|
return Result.ok();
|
||||||
@@ -147,11 +172,11 @@ public class SchisandraOssTencentController {
|
|||||||
* @author zlg
|
* @author zlg
|
||||||
* @date: 2024/6/29 13:27
|
* @date: 2024/6/29 13:27
|
||||||
*/
|
*/
|
||||||
@GetMapping("shareTencentUrl")
|
@GetMapping("shareUrl")
|
||||||
public Result<String> shareTencentUrl(@RequestParam String userId, @RequestParam String bucket,@RequestParam String target) {
|
public Result<String> shareTencentUrl(@RequestParam String userId, @RequestParam String bucket,@RequestParam String target) {
|
||||||
Preconditions.checkNotNull(userId, "不能为空");
|
Preconditions.checkNotNull(userId, "不能为空");
|
||||||
Preconditions.checkNotNull(bucket, "不能为空");
|
Preconditions.checkNotNull(bucket, "不能为空");
|
||||||
TencentOssClient bean = SpringUtil.getBean(userId);
|
TencentOssClient bean = SpringUtil.getBean(OssConstant.OssType.TENCENT+ userId);
|
||||||
return Result.ok(bean.shareTencentObject(bucket,target));
|
return Result.ok(bean.shareTencentObject(bucket,target));
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@@ -168,7 +193,7 @@ public class SchisandraOssTencentController {
|
|||||||
if (!target.isEmpty()){
|
if (!target.isEmpty()){
|
||||||
target=target+"/"+file.getOriginalFilename();
|
target=target+"/"+file.getOriginalFilename();
|
||||||
}
|
}
|
||||||
TencentOssClient bean = SpringUtil.getBean(userId);
|
TencentOssClient bean = SpringUtil.getBean(OssConstant.OssType.TENCENT+ userId);
|
||||||
InputStream is = file.getInputStream();
|
InputStream is = file.getInputStream();
|
||||||
bean.getTencentOssConfig().setBucketName(bucket);
|
bean.getTencentOssConfig().setBucketName(bucket);
|
||||||
//设置热力图
|
//设置热力图
|
||||||
@@ -192,11 +217,11 @@ public class SchisandraOssTencentController {
|
|||||||
* @author zlg
|
* @author zlg
|
||||||
* @date: 2024/7/1 16:02
|
* @date: 2024/7/1 16:02
|
||||||
*/
|
*/
|
||||||
@GetMapping("downloadTencent")
|
@GetMapping("downloadFile")
|
||||||
public Result<String> downloadTencent(@RequestParam String userId, @RequestParam String bucket, @RequestParam String target) {
|
public Result<String> downloadTencent(@RequestParam String userId, @RequestParam String bucket, @RequestParam String target) {
|
||||||
Preconditions.checkNotNull(userId, "不能为空");
|
Preconditions.checkNotNull(userId, "不能为空");
|
||||||
Preconditions.checkNotNull(bucket, "不能为空");
|
Preconditions.checkNotNull(bucket, "不能为空");
|
||||||
TencentOssClient bean = SpringUtil.getBean(userId);
|
TencentOssClient bean = SpringUtil.getBean(OssConstant.OssType.TENCENT+ userId);
|
||||||
return Result.ok(bean.downloadTencent(bucket,target));
|
return Result.ok(bean.downloadTencent(bucket,target));
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@@ -206,10 +231,10 @@ public class SchisandraOssTencentController {
|
|||||||
* @author zlg
|
* @author zlg
|
||||||
* @date: 2024/7/1 16:02
|
* @date: 2024/7/1 16:02
|
||||||
*/
|
*/
|
||||||
@PostMapping("moveTencent")
|
@PostMapping("moveFile")
|
||||||
public Result<String> moveTencent(@RequestParam String userId, @RequestParam String sourceBucket, @RequestParam String targetBucket, @RequestParam String targetName,@RequestParam String SourceName) throws IOException {
|
public Result<String> moveTencent(@RequestParam String userId, @RequestParam String sourceBucket, @RequestParam String targetBucket, @RequestParam String targetName,@RequestParam String SourceName) throws IOException {
|
||||||
Preconditions.checkNotNull(userId, "不能为空");
|
Preconditions.checkNotNull(userId, "不能为空");
|
||||||
TencentOssClient bean = SpringUtil.getBean(userId);
|
TencentOssClient bean = SpringUtil.getBean(OssConstant.OssType.TENCENT+ userId);
|
||||||
CopyResult copyResult = bean.moveTencent(SourceName, targetName, sourceBucket, targetBucket);
|
CopyResult copyResult = bean.moveTencent(SourceName, targetName, sourceBucket, targetBucket);
|
||||||
if (copyResult==null){
|
if (copyResult==null){
|
||||||
return Result.fail();
|
return Result.fail();
|
||||||
@@ -223,10 +248,10 @@ public class SchisandraOssTencentController {
|
|||||||
* @author zlg
|
* @author zlg
|
||||||
* @date: 2024/7/1 16:02
|
* @date: 2024/7/1 16:02
|
||||||
*/
|
*/
|
||||||
@PostMapping("copyTencent")
|
@PostMapping("copyFile")
|
||||||
public Result<String> copyTencent(@RequestParam String userId, @RequestParam String sourceBucket, @RequestParam String targetBucket, @RequestParam String targetName,@RequestParam String SourceName) throws IOException {
|
public Result<String> copyTencent(@RequestParam String userId, @RequestParam String sourceBucket, @RequestParam String targetBucket, @RequestParam String targetName,@RequestParam String SourceName) throws IOException {
|
||||||
Preconditions.checkNotNull(userId, "不能为空");
|
Preconditions.checkNotNull(userId, "不能为空");
|
||||||
TencentOssClient bean = SpringUtil.getBean(userId);
|
TencentOssClient bean = SpringUtil.getBean(OssConstant.OssType.TENCENT+ userId);
|
||||||
CopyResult copyResult = bean.copyTencent(SourceName,targetName , sourceBucket, targetBucket);
|
CopyResult copyResult = bean.copyTencent(SourceName,targetName , sourceBucket, targetBucket);
|
||||||
if (copyResult==null){
|
if (copyResult==null){
|
||||||
return Result.fail();
|
return Result.fail();
|
||||||
@@ -240,10 +265,10 @@ public class SchisandraOssTencentController {
|
|||||||
* @author zlg
|
* @author zlg
|
||||||
* @date: 2024/7/1 16:02
|
* @date: 2024/7/1 16:02
|
||||||
*/
|
*/
|
||||||
@PostMapping("deleteTencent")
|
@PostMapping("deleteFile")
|
||||||
public Result<String> deleteTencent(@RequestParam String userId, @RequestParam String bucketName, @RequestParam List<DeleteObjectsRequest.KeyVersion> target) throws IOException {
|
public Result<String> deleteTencent(@RequestParam String userId, @RequestParam String bucketName, @RequestParam List<DeleteObjectsRequest.KeyVersion> target) throws IOException {
|
||||||
Preconditions.checkNotNull(userId, "不能为空");
|
Preconditions.checkNotNull(userId, "不能为空");
|
||||||
TencentOssClient bean = SpringUtil.getBean(userId);
|
TencentOssClient bean = SpringUtil.getBean(OssConstant.OssType.TENCENT+ userId);
|
||||||
DeleteObjectsResult deleteResult = bean.deleteTencent(bucketName, target);
|
DeleteObjectsResult deleteResult = bean.deleteTencent(bucketName, target);
|
||||||
if (deleteResult==null){
|
if (deleteResult==null){
|
||||||
return Result.fail();
|
return Result.fail();
|
||||||
@@ -265,42 +290,6 @@ public class SchisandraOssTencentController {
|
|||||||
if (log.isInfoEnabled()) {
|
if (log.isInfoEnabled()) {
|
||||||
log.info("SchisandraOssTencentController.add.dto:{}", JSON.toJSONString(schisandraOssTencentDTO));
|
log.info("SchisandraOssTencentController.add.dto:{}", JSON.toJSONString(schisandraOssTencentDTO));
|
||||||
}
|
}
|
||||||
Preconditions.checkNotNull(schisandraOssTencentDTO.getId(), "不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssTencentDTO.getUserId(), "不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssTencentDTO.getBasePath(), "不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssTencentDTO.getBucketName(), "不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssTencentDTO.getSecretId(), "不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssTencentDTO.getSecretKey(), "不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssTencentDTO.getRegion(), "地域不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssTencentDTO.getHttpProtocol(), "连接OSS所采用的协议(HTTP或HTTPS),默认为HTTPS。不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssTencentDTO.getEndPointSuffix(), "域名后缀不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssTencentDTO.getHttpProxyIp(), "http proxy代理,如果使用http proxy代理,需要设置IP与端口不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssTencentDTO.getHttpProxyPort(), "代理服务器端口不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssTencentDTO.getProxyUserName(), "代理服务器验证的用户名。不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssTencentDTO.getProxyPassword(), "代理服务器验证的密码。不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssTencentDTO.getUseBasicAuth(), "是否使用基本身份验证不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssTencentDTO.getSignExpired(), "多次签名的过期时间,单位秒不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssTencentDTO.getConnectionRequestTimeout(), "获取连接的超时时间, 单位ms不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssTencentDTO.getConnectionTimeout(), "默认连接超时, 单位ms不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssTencentDTO.getSocketTimeout(), "SOCKET读取超时时间, 单位ms不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssTencentDTO.getMaxConnectionsCount(), "最大HTTP连接数不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssTencentDTO.getIdleConnectionAlive(), "空闲连接存活时间不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssTencentDTO.getUserAgent(), "user_agent标识不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssTencentDTO.getReadLimit(), "读取限制不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssTencentDTO.getCiSpecialRequest(), "数据万象特殊请求配置不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssTencentDTO.getMaxErrorRetry(), "请求失败后最大的重试次数。默认3次。不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssTencentDTO.getExtraJson(), "额外json不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssTencentDTO.getStatus(), "状态不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssTencentDTO.getCreatedBy(), "创建人不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssTencentDTO.getCreatedTime(), "创建时间不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssTencentDTO.getUpdateTime(), "更新时间不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssTencentDTO.getUpdateBy(), "更新人不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssTencentDTO.getIsDeleted(), "是否删除 0 未删除 1已删除不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssTencentDTO.getOpenAdvancedSetup(), "是否开启高级设置不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssTencentDTO.getCreateBucket(), "当桶不存在,是否创建不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssTencentDTO.getCheckBucket(), "启动检测桶,是否存在不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssTencentDTO.getPartSize(), "分片大小,默认5MB不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssTencentDTO.getTaskNum(), "并发线程数,默认等于CPU的核数不能为空");
|
|
||||||
SchisandraOssTencentBO SchisandraOssTencentBO = SchisandraOssTencentDTOConverter.INSTANCE.convertDTOToBO(schisandraOssTencentDTO);
|
SchisandraOssTencentBO SchisandraOssTencentBO = SchisandraOssTencentDTOConverter.INSTANCE.convertDTOToBO(schisandraOssTencentDTO);
|
||||||
return Result.ok(schisandraOssTencentDomainService.add(SchisandraOssTencentBO));
|
return Result.ok(schisandraOssTencentDomainService.add(SchisandraOssTencentBO));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -320,42 +309,6 @@ public class SchisandraOssTencentController {
|
|||||||
if (log.isInfoEnabled()) {
|
if (log.isInfoEnabled()) {
|
||||||
log.info("SchisandraOssTencentController.update.dto:{}", JSON.toJSONString(schisandraOssTencentDTO));
|
log.info("SchisandraOssTencentController.update.dto:{}", JSON.toJSONString(schisandraOssTencentDTO));
|
||||||
}
|
}
|
||||||
Preconditions.checkNotNull(schisandraOssTencentDTO.getId(), "不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssTencentDTO.getUserId(), "不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssTencentDTO.getBasePath(), "不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssTencentDTO.getBucketName(), "不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssTencentDTO.getSecretId(), "不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssTencentDTO.getSecretKey(), "不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssTencentDTO.getRegion(), "地域不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssTencentDTO.getHttpProtocol(), "连接OSS所采用的协议(HTTP或HTTPS),默认为HTTPS。不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssTencentDTO.getEndPointSuffix(), "域名后缀不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssTencentDTO.getHttpProxyIp(), "http proxy代理,如果使用http proxy代理,需要设置IP与端口不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssTencentDTO.getHttpProxyPort(), "代理服务器端口不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssTencentDTO.getProxyUserName(), "代理服务器验证的用户名。不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssTencentDTO.getProxyPassword(), "代理服务器验证的密码。不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssTencentDTO.getUseBasicAuth(), "是否使用基本身份验证不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssTencentDTO.getSignExpired(), "多次签名的过期时间,单位秒不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssTencentDTO.getConnectionRequestTimeout(), "获取连接的超时时间, 单位ms不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssTencentDTO.getConnectionTimeout(), "默认连接超时, 单位ms不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssTencentDTO.getSocketTimeout(), "SOCKET读取超时时间, 单位ms不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssTencentDTO.getMaxConnectionsCount(), "最大HTTP连接数不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssTencentDTO.getIdleConnectionAlive(), "空闲连接存活时间不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssTencentDTO.getUserAgent(), "user_agent标识不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssTencentDTO.getReadLimit(), "读取限制不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssTencentDTO.getCiSpecialRequest(), "数据万象特殊请求配置不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssTencentDTO.getMaxErrorRetry(), "请求失败后最大的重试次数。默认3次。不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssTencentDTO.getExtraJson(), "额外json不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssTencentDTO.getStatus(), "状态不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssTencentDTO.getCreatedBy(), "创建人不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssTencentDTO.getCreatedTime(), "创建时间不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssTencentDTO.getUpdateTime(), "更新时间不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssTencentDTO.getUpdateBy(), "更新人不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssTencentDTO.getIsDeleted(), "是否删除 0 未删除 1已删除不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssTencentDTO.getOpenAdvancedSetup(), "是否开启高级设置不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssTencentDTO.getCreateBucket(), "当桶不存在,是否创建不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssTencentDTO.getCheckBucket(), "启动检测桶,是否存在不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssTencentDTO.getPartSize(), "分片大小,默认5MB不能为空");
|
|
||||||
Preconditions.checkNotNull(schisandraOssTencentDTO.getTaskNum(), "并发线程数,默认等于CPU的核数不能为空");
|
|
||||||
SchisandraOssTencentBO schisandraOssTencentBO = SchisandraOssTencentDTOConverter.INSTANCE.convertDTOToBO(schisandraOssTencentDTO);
|
SchisandraOssTencentBO schisandraOssTencentBO = SchisandraOssTencentDTOConverter.INSTANCE.convertDTOToBO(schisandraOssTencentDTO);
|
||||||
return Result.ok(schisandraOssTencentDomainService.update(schisandraOssTencentBO));
|
return Result.ok(schisandraOssTencentDomainService.update(schisandraOssTencentBO));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@@ -5,10 +5,12 @@ import com.alibaba.fastjson.JSON;
|
|||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import com.schisandra.oss.application.convert.SchisandraOssUpDTOConverter;
|
import com.schisandra.oss.application.convert.SchisandraOssUpDTOConverter;
|
||||||
import com.schisandra.oss.application.dto.SchisandraOssUpDTO;
|
import com.schisandra.oss.application.dto.SchisandraOssUpDTO;
|
||||||
|
import com.schisandra.oss.application.oss.constant.OssConstant;
|
||||||
import com.schisandra.oss.application.oss.core.up.UpOssClient;
|
import com.schisandra.oss.application.oss.core.up.UpOssClient;
|
||||||
import com.schisandra.oss.application.oss.core.up.UpOssConfiguration;
|
import com.schisandra.oss.application.oss.core.up.UpOssConfiguration;
|
||||||
import com.schisandra.oss.application.oss.model.OssInfo;
|
import com.schisandra.oss.application.oss.model.OssInfo;
|
||||||
import com.schisandra.oss.common.entity.Result;
|
import com.schisandra.oss.common.entity.Result;
|
||||||
|
import com.schisandra.oss.domain.bo.SchisandraOssAliBO;
|
||||||
import com.schisandra.oss.domain.bo.SchisandraOssUpBO;
|
import com.schisandra.oss.domain.bo.SchisandraOssUpBO;
|
||||||
import com.schisandra.oss.domain.service.SchisandraOssUpDomainService;
|
import com.schisandra.oss.domain.service.SchisandraOssUpDomainService;
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
@@ -44,8 +46,12 @@ public class SchisandraOssUpController {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@GetMapping("returnAll")
|
@GetMapping("returnAll")
|
||||||
public List<SchisandraOssUpDTO> returnAll() {
|
public Result returnAll() {
|
||||||
return upOssConfiguration.selectAll();
|
List<SchisandraOssUpBO> list = schisandraOssUpDomainService.selectAll();
|
||||||
|
if(list.isEmpty()){
|
||||||
|
return Result.fail();
|
||||||
|
}
|
||||||
|
return Result.ok(SchisandraOssUpDTOConverter.INSTANCE.convertBOToDTOList(list));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -56,14 +62,37 @@ public class SchisandraOssUpController {
|
|||||||
* @date: 2024/6/28 上午11:36
|
* @date: 2024/6/28 上午11:36
|
||||||
*/
|
*/
|
||||||
@PostMapping("init")
|
@PostMapping("init")
|
||||||
public void init(@RequestParam("userId") String userId) {
|
public Result init(@RequestParam String userId,@RequestParam String Id) {
|
||||||
try {
|
if (log.isInfoEnabled()) {
|
||||||
upOssConfiguration.upOssClient(userId);
|
log.info("SchisandraOssUpController.init.userId:{}", userId);
|
||||||
log.info("用户:{} 又拍云oss初始化成功", userId);
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("用户:{} 又拍云oss初始化失败", userId);
|
|
||||||
}
|
}
|
||||||
|
Preconditions.checkNotNull(userId, "用户id不能为空!");
|
||||||
|
SchisandraOssUpBO bo = new SchisandraOssUpBO();
|
||||||
|
bo.setId(Long.valueOf(Id));
|
||||||
|
bo.setUserId(Long.valueOf(OssConstant.OssType.UP+ userId));
|
||||||
|
bo.setStatus(String.valueOf(true));
|
||||||
|
if(schisandraOssUpDomainService.update(bo)){
|
||||||
|
return upOssConfiguration.upOssClient(userId);
|
||||||
|
}else{
|
||||||
|
return Result.fail("初始化失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("shutdown")
|
||||||
|
public Result shutdownUp(@RequestParam String userId,@RequestParam String Id){
|
||||||
|
if (log.isInfoEnabled()) {
|
||||||
|
log.info("SchisandraOssUpController.shutdown.userId:{}", JSON.toJSONString(userId));
|
||||||
|
}
|
||||||
|
SchisandraOssUpBO bo = new SchisandraOssUpBO();
|
||||||
|
bo.setId(Long.valueOf(Id));
|
||||||
|
bo.setUserId(Long.valueOf(OssConstant.OssType.UP + userId));
|
||||||
|
bo.setStatus(String.valueOf(false));
|
||||||
|
if(schisandraOssUpDomainService.update(bo)){
|
||||||
|
SpringUtil.unregisterBean(OssConstant.OssType.UP+ userId);
|
||||||
|
return Result.ok("关闭成功");
|
||||||
|
}else{
|
||||||
|
return Result.fail("关闭失败");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -75,7 +104,7 @@ public class SchisandraOssUpController {
|
|||||||
*/
|
*/
|
||||||
@PostMapping("getInfo")
|
@PostMapping("getInfo")
|
||||||
public Result getInfo(@RequestParam("userId") String userId, @RequestParam("fileName") String fileName) {
|
public Result getInfo(@RequestParam("userId") String userId, @RequestParam("fileName") String fileName) {
|
||||||
UpOssClient bean = SpringUtil.getBean(userId);
|
UpOssClient bean = SpringUtil.getBean(OssConstant.OssType.UP+ userId);
|
||||||
OssInfo info = bean.getInfo(fileName);
|
OssInfo info = bean.getInfo(fileName);
|
||||||
return Result.ok(info);
|
return Result.ok(info);
|
||||||
}
|
}
|
||||||
@@ -88,9 +117,9 @@ public class SchisandraOssUpController {
|
|||||||
* @date: 2024/6/28 下午3:00
|
* @date: 2024/6/28 下午3:00
|
||||||
*/
|
*/
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
@PostMapping("upload")
|
@PostMapping("uploadFile")
|
||||||
public Result upload(@RequestParam("userId") String userId, @RequestParam("file") MultipartFile file, @RequestParam("isOverride") Boolean isOverride) {
|
public Result upload(@RequestParam("userId") String userId, @RequestParam("file") MultipartFile file, @RequestParam("isOverride") Boolean isOverride) {
|
||||||
UpOssClient bean = SpringUtil.getBean(userId);
|
UpOssClient bean = SpringUtil.getBean(OssConstant.OssType.UP+ userId);
|
||||||
String originalFileName = file.getOriginalFilename();
|
String originalFileName = file.getOriginalFilename();
|
||||||
InputStream is = file.getInputStream();
|
InputStream is = file.getInputStream();
|
||||||
OssInfo ossInfo = bean.upLoad(is, originalFileName, isOverride);
|
OssInfo ossInfo = bean.upLoad(is, originalFileName, isOverride);
|
||||||
@@ -106,7 +135,7 @@ public class SchisandraOssUpController {
|
|||||||
*/
|
*/
|
||||||
@PostMapping("deleteFile")
|
@PostMapping("deleteFile")
|
||||||
public Result deleteFile(@RequestParam("userId") String userId, @RequestParam("fileName") String fileName) {
|
public Result deleteFile(@RequestParam("userId") String userId, @RequestParam("fileName") String fileName) {
|
||||||
UpOssClient bean = SpringUtil.getBean(userId);
|
UpOssClient bean = SpringUtil.getBean(OssConstant.OssType.UP+ userId);
|
||||||
bean.delete(fileName);
|
bean.delete(fileName);
|
||||||
return Result.ok();
|
return Result.ok();
|
||||||
}
|
}
|
||||||
@@ -121,7 +150,7 @@ public class SchisandraOssUpController {
|
|||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
@GetMapping("download")
|
@GetMapping("download")
|
||||||
public Result download(@RequestParam("userId") String userId, @RequestParam("fileName") String fileName, HttpServletResponse response) {
|
public Result download(@RequestParam("userId") String userId, @RequestParam("fileName") String fileName, HttpServletResponse response) {
|
||||||
UpOssClient bean = SpringUtil.getBean(userId);
|
UpOssClient bean = SpringUtil.getBean(OssConstant.OssType.UP+ userId);
|
||||||
ServletOutputStream output = response.getOutputStream();
|
ServletOutputStream output = response.getOutputStream();
|
||||||
response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
|
response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
|
||||||
response.setContentType("application/octet-stream");
|
response.setContentType("application/octet-stream");
|
||||||
|
@@ -32,6 +32,8 @@ public class SchisandraUserOssController {
|
|||||||
private final String USER_OSS_PREFIX = "oss:user:heat";
|
private final String USER_OSS_PREFIX = "oss:user:heat";
|
||||||
@Resource
|
@Resource
|
||||||
RedisUtil redisUtil;
|
RedisUtil redisUtil;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增用户对象存储映射表
|
* 新增用户对象存储映射表
|
||||||
*/
|
*/
|
||||||
@@ -151,6 +153,4 @@ public class SchisandraUserOssController {
|
|||||||
String key = redisUtil.buildKey(USER_OSS_PREFIX+":"+userId);
|
String key = redisUtil.buildKey(USER_OSS_PREFIX+":"+userId);
|
||||||
return Result.ok(redisUtil.getDataFromDirectory(key));
|
return Result.ok(redisUtil.getDataFromDirectory(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -2,10 +2,14 @@ package com.schisandra.oss.application.convert;
|
|||||||
|
|
||||||
|
|
||||||
import com.schisandra.oss.application.dto.SchisandraOssAliDTO;
|
import com.schisandra.oss.application.dto.SchisandraOssAliDTO;
|
||||||
|
import com.schisandra.oss.application.dto.SchisandraUserOssDTO;
|
||||||
import com.schisandra.oss.domain.bo.SchisandraOssAliBO;
|
import com.schisandra.oss.domain.bo.SchisandraOssAliBO;
|
||||||
|
import com.schisandra.oss.domain.bo.SchisandraUserOssBO;
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.factory.Mappers;
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* dto转换器
|
* dto转换器
|
||||||
*
|
*
|
||||||
@@ -19,5 +23,5 @@ public interface SchisandraOssAliDTOConverter {
|
|||||||
|
|
||||||
SchisandraOssAliBO convertDTOToBO(SchisandraOssAliDTO schisandraOssAliDTO);
|
SchisandraOssAliBO convertDTOToBO(SchisandraOssAliDTO schisandraOssAliDTO);
|
||||||
SchisandraOssAliDTO convertBOToDTO(SchisandraOssAliBO schisandraOssAli);
|
SchisandraOssAliDTO convertBOToDTO(SchisandraOssAliBO schisandraOssAli);
|
||||||
|
List<SchisandraOssAliDTO> convertBOToDTOList(List<SchisandraOssAliBO> schisandraAliBOList);
|
||||||
}
|
}
|
||||||
|
@@ -1,10 +1,14 @@
|
|||||||
package com.schisandra.oss.application.convert;
|
package com.schisandra.oss.application.convert;
|
||||||
|
|
||||||
|
import com.schisandra.oss.application.dto.SchisandraOssMinioDTO;
|
||||||
import com.schisandra.oss.application.dto.SchisandraOssQiniuDTO;
|
import com.schisandra.oss.application.dto.SchisandraOssQiniuDTO;
|
||||||
|
import com.schisandra.oss.domain.bo.SchisandraOssMinioBO;
|
||||||
import com.schisandra.oss.domain.bo.SchisandraOssQiniuBO;
|
import com.schisandra.oss.domain.bo.SchisandraOssQiniuBO;
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.factory.Mappers;
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 七牛云对象存储配置表 dto转换器
|
* 七牛云对象存储配置表 dto转换器
|
||||||
*
|
*
|
||||||
@@ -19,4 +23,5 @@ public interface SchisandraOssQiniuDTOConverter {
|
|||||||
SchisandraOssQiniuBO convertDTOToBO(SchisandraOssQiniuDTO schisandraOssQiniuDTO);
|
SchisandraOssQiniuBO convertDTOToBO(SchisandraOssQiniuDTO schisandraOssQiniuDTO);
|
||||||
SchisandraOssQiniuDTO convertBOToDTO(SchisandraOssQiniuBO schisandraOssQiniuBO);
|
SchisandraOssQiniuDTO convertBOToDTO(SchisandraOssQiniuBO schisandraOssQiniuBO);
|
||||||
|
|
||||||
|
List<SchisandraOssQiniuDTO> convertBOToDTOList(List<SchisandraOssQiniuBO> SchisandraOssQiniuBOList);
|
||||||
}
|
}
|
||||||
|
@@ -1,10 +1,14 @@
|
|||||||
package com.schisandra.oss.application.convert;
|
package com.schisandra.oss.application.convert;
|
||||||
|
|
||||||
|
import com.schisandra.oss.application.dto.SchisandraOssQiniuDTO;
|
||||||
import com.schisandra.oss.application.dto.SchisandraOssSftpDTO;
|
import com.schisandra.oss.application.dto.SchisandraOssSftpDTO;
|
||||||
|
import com.schisandra.oss.domain.bo.SchisandraOssQiniuBO;
|
||||||
import com.schisandra.oss.domain.bo.SchisandraOssSftpBO;
|
import com.schisandra.oss.domain.bo.SchisandraOssSftpBO;
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.factory.Mappers;
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sftp存储配置表 dto转换器
|
* sftp存储配置表 dto转换器
|
||||||
*
|
*
|
||||||
@@ -19,4 +23,5 @@ public interface SchisandraOssSftpDTOConverter {
|
|||||||
SchisandraOssSftpBO convertDTOToBO(SchisandraOssSftpDTO schisandraOssSftpDTO);
|
SchisandraOssSftpBO convertDTOToBO(SchisandraOssSftpDTO schisandraOssSftpDTO);
|
||||||
SchisandraOssSftpDTO convertBOToDTO(SchisandraOssSftpBO schisandraOssSftpBO);
|
SchisandraOssSftpDTO convertBOToDTO(SchisandraOssSftpBO schisandraOssSftpBO);
|
||||||
|
|
||||||
|
List<SchisandraOssSftpDTO> convertBOToDTOList(List<SchisandraOssSftpBO> SchisandraOssSftpBOList);
|
||||||
}
|
}
|
||||||
|
@@ -1,10 +1,14 @@
|
|||||||
package com.schisandra.oss.application.convert;
|
package com.schisandra.oss.application.convert;
|
||||||
|
|
||||||
|
import com.schisandra.oss.application.dto.SchisandraOssSftpDTO;
|
||||||
import com.schisandra.oss.application.dto.SchisandraOssTencentDTO;
|
import com.schisandra.oss.application.dto.SchisandraOssTencentDTO;
|
||||||
|
import com.schisandra.oss.domain.bo.SchisandraOssSftpBO;
|
||||||
import com.schisandra.oss.domain.bo.SchisandraOssTencentBO;
|
import com.schisandra.oss.domain.bo.SchisandraOssTencentBO;
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.factory.Mappers;
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 腾讯云对象存储配置表 dto转换器
|
* 腾讯云对象存储配置表 dto转换器
|
||||||
*
|
*
|
||||||
@@ -20,4 +24,5 @@ public interface SchisandraOssTencentDTOConverter {
|
|||||||
|
|
||||||
SchisandraOssTencentDTO convertBOToDTO(SchisandraOssTencentBO schisandraOssTencentBO);
|
SchisandraOssTencentDTO convertBOToDTO(SchisandraOssTencentBO schisandraOssTencentBO);
|
||||||
|
|
||||||
|
List<SchisandraOssTencentDTO> convertBOToDTOList(List<SchisandraOssTencentBO> SchisandraOssTencentBOList);
|
||||||
}
|
}
|
||||||
|
@@ -1,10 +1,14 @@
|
|||||||
package com.schisandra.oss.application.convert;
|
package com.schisandra.oss.application.convert;
|
||||||
|
|
||||||
|
import com.schisandra.oss.application.dto.SchisandraOssTencentDTO;
|
||||||
import com.schisandra.oss.application.dto.SchisandraOssUpDTO;
|
import com.schisandra.oss.application.dto.SchisandraOssUpDTO;
|
||||||
|
import com.schisandra.oss.domain.bo.SchisandraOssTencentBO;
|
||||||
import com.schisandra.oss.domain.bo.SchisandraOssUpBO;
|
import com.schisandra.oss.domain.bo.SchisandraOssUpBO;
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.factory.Mappers;
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 又拍云对象存储配置表 dto转换器
|
* 又拍云对象存储配置表 dto转换器
|
||||||
*
|
*
|
||||||
@@ -19,4 +23,5 @@ public interface SchisandraOssUpDTOConverter {
|
|||||||
SchisandraOssUpBO convertDTOToBO(SchisandraOssUpDTO schisandraOssUpDTO);
|
SchisandraOssUpBO convertDTOToBO(SchisandraOssUpDTO schisandraOssUpDTO);
|
||||||
SchisandraOssUpDTO convertBOToDTO(SchisandraOssUpBO schisandraOssUpBO);
|
SchisandraOssUpDTO convertBOToDTO(SchisandraOssUpBO schisandraOssUpBO);
|
||||||
|
|
||||||
|
List<SchisandraOssUpDTO> convertBOToDTOList(List<SchisandraOssUpBO> SchisandraOssUpBOList);
|
||||||
}
|
}
|
||||||
|
@@ -6,6 +6,7 @@ import cn.hutool.core.date.DateUtil;
|
|||||||
import cn.hutool.core.io.IoUtil;
|
import cn.hutool.core.io.IoUtil;
|
||||||
import cn.hutool.core.io.file.FileNameUtil;
|
import cn.hutool.core.io.file.FileNameUtil;
|
||||||
import cn.hutool.core.io.unit.DataSizeUtil;
|
import cn.hutool.core.io.unit.DataSizeUtil;
|
||||||
|
import cn.hutool.core.lang.hash.Hash;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.ReflectUtil;
|
import cn.hutool.core.util.ReflectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
@@ -13,6 +14,8 @@ import com.aliyun.oss.OSS;
|
|||||||
import com.aliyun.oss.common.utils.HttpHeaders;
|
import com.aliyun.oss.common.utils.HttpHeaders;
|
||||||
import com.aliyun.oss.model.*;
|
import com.aliyun.oss.model.*;
|
||||||
|
|
||||||
|
import com.qiniu.storage.BucketManager;
|
||||||
|
import com.qiniu.storage.model.FileInfo;
|
||||||
import com.schisandra.oss.application.oss.constant.OssConstant;
|
import com.schisandra.oss.application.oss.constant.OssConstant;
|
||||||
import com.schisandra.oss.application.oss.core.StandardOssClient;
|
import com.schisandra.oss.application.oss.core.StandardOssClient;
|
||||||
import com.schisandra.oss.application.oss.core.ali.model.AliOssConfig;
|
import com.schisandra.oss.application.oss.core.ali.model.AliOssConfig;
|
||||||
@@ -54,11 +57,21 @@ public class AliOssClient implements StandardOssClient {
|
|||||||
private OSS oss;
|
private OSS oss;
|
||||||
private AliOssConfig aliOssConfig;
|
private AliOssConfig aliOssConfig;
|
||||||
|
|
||||||
public List<String> selectAllBucket() {
|
public String getAliBucketSize(String bucket) {
|
||||||
|
ObjectListing objectListing = oss.listObjects(bucket, "");
|
||||||
|
long x = 0L;
|
||||||
|
List<OSSObjectSummary> sums = objectListing.getObjectSummaries();
|
||||||
|
for(OSSObjectSummary objectSummary : sums){
|
||||||
|
x+=objectSummary.getSize();
|
||||||
|
}
|
||||||
|
return DataSizeUtil.format(x);
|
||||||
|
}
|
||||||
|
|
||||||
|
public HashMap<String,String> selectAllBucket() {
|
||||||
List<Bucket> buckets = oss.listBuckets();
|
List<Bucket> buckets = oss.listBuckets();
|
||||||
List<String> names = new ArrayList<>();
|
HashMap<String,String> names = new HashMap<>();
|
||||||
buckets.forEach(bucket -> {
|
buckets.forEach(bucket -> {
|
||||||
names.add(bucket.getName());
|
names.put(bucket.getName(),getAliBucketSize(bucket.getName()));
|
||||||
});
|
});
|
||||||
return names;
|
return names;
|
||||||
}
|
}
|
||||||
|
@@ -7,9 +7,11 @@ import com.aliyun.oss.OSSClientBuilder;
|
|||||||
import com.aliyun.oss.common.comm.Protocol;
|
import com.aliyun.oss.common.comm.Protocol;
|
||||||
import com.schisandra.oss.application.convert.SchisandraOssAliDTOConverter;
|
import com.schisandra.oss.application.convert.SchisandraOssAliDTOConverter;
|
||||||
import com.schisandra.oss.application.dto.SchisandraOssAliDTO;
|
import com.schisandra.oss.application.dto.SchisandraOssAliDTO;
|
||||||
|
import com.schisandra.oss.application.oss.constant.OssConstant;
|
||||||
import com.schisandra.oss.application.oss.core.StandardOssClient;
|
import com.schisandra.oss.application.oss.core.StandardOssClient;
|
||||||
import com.schisandra.oss.application.oss.core.ali.model.AliOssClientConfig;
|
import com.schisandra.oss.application.oss.core.ali.model.AliOssClientConfig;
|
||||||
import com.schisandra.oss.application.oss.core.ali.model.AliOssConfig;
|
import com.schisandra.oss.application.oss.core.ali.model.AliOssConfig;
|
||||||
|
import com.schisandra.oss.common.entity.Result;
|
||||||
import com.schisandra.oss.domain.bo.SchisandraOssAliBO;
|
import com.schisandra.oss.domain.bo.SchisandraOssAliBO;
|
||||||
import com.schisandra.oss.domain.service.SchisandraOssAliDomainService;
|
import com.schisandra.oss.domain.service.SchisandraOssAliDomainService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@@ -31,19 +33,10 @@ import java.util.concurrent.CompletableFuture;
|
|||||||
public class AliOssConfiguration {
|
public class AliOssConfiguration {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
SchisandraOssAliDomainService schisandraOssAliDomainService;
|
private SchisandraOssAliDomainService schisandraOssAliDomainService;
|
||||||
|
|
||||||
public List<SchisandraOssAliDTO> selectAll(){
|
|
||||||
List<SchisandraOssAliBO> schisandraOssAliBO_list = schisandraOssAliDomainService.selectAll();
|
|
||||||
List<SchisandraOssAliDTO> schisandraOssAliDTO_list = new ArrayList<>();
|
|
||||||
for (SchisandraOssAliBO schisandraOssAliBO : schisandraOssAliBO_list ){
|
|
||||||
SchisandraOssAliDTO schisandraOssAliDTO = SchisandraOssAliDTOConverter.INSTANCE.convertBOToDTO(schisandraOssAliBO);
|
|
||||||
schisandraOssAliDTO_list.add(schisandraOssAliDTO);
|
|
||||||
}
|
|
||||||
return schisandraOssAliDTO_list;
|
|
||||||
}
|
|
||||||
|
|
||||||
public StandardOssClient aliOssClient(String userId) {
|
public Result aliOssClient(String userId) {
|
||||||
CompletableFuture<SchisandraOssAliDTO> futurePrice = CompletableFuture.supplyAsync(() -> {
|
CompletableFuture<SchisandraOssAliDTO> futurePrice = CompletableFuture.supplyAsync(() -> {
|
||||||
SchisandraOssAliBO schisandraOssAliBO = schisandraOssAliDomainService.getAliOssConfig(Long.valueOf(userId));
|
SchisandraOssAliBO schisandraOssAliBO = schisandraOssAliDomainService.getAliOssConfig(Long.valueOf(userId));
|
||||||
SchisandraOssAliDTO schisandraOssAliDTO = SchisandraOssAliDTOConverter.INSTANCE.convertBOToDTO(schisandraOssAliBO);
|
SchisandraOssAliDTO schisandraOssAliDTO = SchisandraOssAliDTOConverter.INSTANCE.convertBOToDTO(schisandraOssAliBO);
|
||||||
@@ -52,16 +45,20 @@ public class AliOssConfiguration {
|
|||||||
SchisandraOssAliDTO ali = futurePrice.join();
|
SchisandraOssAliDTO ali = futurePrice.join();
|
||||||
if (ObjectUtil.isEmpty(ali)) {
|
if (ObjectUtil.isEmpty(ali)) {
|
||||||
log.error("ali oss配置信息获取失败");
|
log.error("ali oss配置信息获取失败");
|
||||||
return null;
|
return Result.fail();
|
||||||
}
|
}
|
||||||
AliOssConfig aliOssConfig = new AliOssConfig();
|
AliOssConfig aliOssConfig = new AliOssConfig();
|
||||||
aliOssConfig.setEndpoint(ali.getEndpoint());
|
aliOssConfig.setEndpoint(ali.getEndpoint());
|
||||||
aliOssConfig.setAccessKeyId(ali.getAccessKeyId());
|
aliOssConfig.setAccessKeyId(ali.getAccessKeyId());
|
||||||
aliOssConfig.setAccessKeySecret(ali.getAccessKeySecret());
|
aliOssConfig.setAccessKeySecret(ali.getAccessKeySecret());
|
||||||
aliOssConfig.setBasePath(ali.getBasePath());
|
aliOssConfig.setBasePath(ali.getBasePath());
|
||||||
|
try{
|
||||||
SpringUtil.registerBean(userId, aliOssClient(aliOssConfig));
|
SpringUtil.registerBean(OssConstant.OssType.ALI+ userId, aliOssClient(aliOssConfig));
|
||||||
return aliOssClient(aliOssConfig);
|
return Result.ok();
|
||||||
|
}catch(Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
return Result.fail();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public AliOssClient aliOssClient(AliOssConfig aliOssConfig) {
|
public AliOssClient aliOssClient(AliOssConfig aliOssConfig) {
|
||||||
|
@@ -6,7 +6,9 @@ import com.schisandra.oss.application.convert.SchisandraOssAliDTOConverter;
|
|||||||
import com.schisandra.oss.application.convert.SchisandraOssMinioDTOConverter;
|
import com.schisandra.oss.application.convert.SchisandraOssMinioDTOConverter;
|
||||||
import com.schisandra.oss.application.dto.SchisandraOssAliDTO;
|
import com.schisandra.oss.application.dto.SchisandraOssAliDTO;
|
||||||
import com.schisandra.oss.application.dto.SchisandraOssMinioDTO;
|
import com.schisandra.oss.application.dto.SchisandraOssMinioDTO;
|
||||||
|
import com.schisandra.oss.application.oss.constant.OssConstant;
|
||||||
import com.schisandra.oss.application.oss.core.StandardOssClient;
|
import com.schisandra.oss.application.oss.core.StandardOssClient;
|
||||||
|
import com.schisandra.oss.application.oss.core.ali.model.AliOssConfig;
|
||||||
import com.schisandra.oss.application.oss.core.minio.model.MinioOssClientConfig;
|
import com.schisandra.oss.application.oss.core.minio.model.MinioOssClientConfig;
|
||||||
import com.schisandra.oss.application.oss.core.minio.model.MinioOssConfig;
|
import com.schisandra.oss.application.oss.core.minio.model.MinioOssConfig;
|
||||||
import com.schisandra.oss.common.entity.Result;
|
import com.schisandra.oss.common.entity.Result;
|
||||||
@@ -39,43 +41,28 @@ public class MinioOssConfiguration {
|
|||||||
@Resource
|
@Resource
|
||||||
private SchisandraOssMinioDomainService schisandraOssMinioDomainService;
|
private SchisandraOssMinioDomainService schisandraOssMinioDomainService;
|
||||||
|
|
||||||
public List<SchisandraOssMinioDTO> selectAll(){
|
|
||||||
List<SchisandraOssMinioBO> schisandraOssMinioBO_list = schisandraOssMinioDomainService.selectAll();
|
|
||||||
List<SchisandraOssMinioDTO> schisandraOssAliDTO_list = new ArrayList<>();
|
|
||||||
for (SchisandraOssMinioBO schisandraOssMinioBO : schisandraOssMinioBO_list ){
|
|
||||||
SchisandraOssMinioDTO schisandraOssMinioDTO = SchisandraOssMinioDTOConverter.INSTANCE.convertBOToDTO(schisandraOssMinioBO);
|
|
||||||
schisandraOssAliDTO_list.add(schisandraOssMinioDTO);
|
|
||||||
}
|
|
||||||
return schisandraOssAliDTO_list;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Result minioOssClient(String userId) {
|
public Result minioOssClient(String userId) {
|
||||||
try {
|
CompletableFuture<SchisandraOssMinioDTO> futurePrice = CompletableFuture.supplyAsync(() -> {
|
||||||
SchisandraOssMinioDTO minio = minioOssConfiguration.getSchisandraOssMinioDTO(userId);
|
SchisandraOssMinioBO schisandraOssMinioBO = schisandraOssMinioDomainService.getMinioConfig(Long.valueOf(userId));
|
||||||
if (minio == null) return null;
|
SchisandraOssMinioDTO schisandraOssMinioDTO = SchisandraOssMinioDTOConverter.INSTANCE.convertBOToDTO(schisandraOssMinioBO);
|
||||||
MinioOssConfig minioOssConfig = new MinioOssConfig();
|
return schisandraOssMinioDTO;
|
||||||
minioOssConfig.setBasePath(minio.getBasePath());
|
});
|
||||||
minioOssConfig.setBucketName(minio.getBucketName());
|
SchisandraOssMinioDTO minio = futurePrice.join();
|
||||||
minioOssConfig.setAccessKey(minio.getAccessKey());
|
if (ObjectUtil.isEmpty(minio)) {
|
||||||
minioOssConfig.setSecretKey(minio.getSecretKey());
|
log.error("minio oss配置信息获取失败");
|
||||||
minioOssConfig.setEndpoint(minio.getEndpoint());
|
return Result.fail();
|
||||||
minioOssConfig.init();
|
}
|
||||||
if (Boolean.parseBoolean(minio.getOpenAdvancedSetup())) {
|
MinioOssConfig minioOssConfig = new MinioOssConfig();
|
||||||
MinioOssClientConfig minioOssClientConfig = new MinioOssClientConfig();
|
minioOssConfig.setEndpoint(minio.getEndpoint());
|
||||||
minioOssClientConfig.setWriteTimeout(minio.getWriteTimeout());
|
minioOssConfig.setAccessKey(minio.getAccessKey());
|
||||||
minioOssClientConfig.setConnectTimeout(minio.getConnectTimeout());
|
minioOssConfig.setSecretKey(minio.getSecretKey());
|
||||||
minioOssClientConfig.setReadTimeout(minio.getReadTimeout());
|
minioOssConfig.setBasePath(minio.getBasePath());
|
||||||
minioOssClientConfig.setFollowSslRedirects(Boolean.parseBoolean(minio.getFollowSslRedirects()));
|
try{
|
||||||
minioOssClientConfig.setRetryOnConnectionFailure(Boolean.parseBoolean(minio.getRetryOnConnectionFailure()));
|
SpringUtil.registerBean(OssConstant.OssType.MINIO+ userId, minioOssClient(minioOssConfig));
|
||||||
minioOssClientConfig.setPingInterval(minio.getPingInterval());
|
|
||||||
minioOssClientConfig.setFollowRedirects(Boolean.parseBoolean(minio.getFollowRedirects()));
|
|
||||||
minioOssClientConfig.setCallTimeout(minio.getCallTimeout());
|
|
||||||
minioOssConfig.setClientConfig(minioOssClientConfig);
|
|
||||||
}
|
|
||||||
SpringUtil.registerBean(userId, minioOssClient(minioOssConfig));
|
|
||||||
return Result.ok();
|
return Result.ok();
|
||||||
} catch (Exception e) {
|
}catch(Exception e){
|
||||||
log.error("MinioOssConfiguration.minioOssClient:{}", e.getMessage(), e);
|
e.printStackTrace();
|
||||||
return Result.fail();
|
return Result.fail();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -27,6 +27,9 @@ import com.schisandra.oss.application.oss.model.OssInfo;
|
|||||||
import com.schisandra.oss.application.oss.model.download.DownloadCheckPoint;
|
import com.schisandra.oss.application.oss.model.download.DownloadCheckPoint;
|
||||||
import com.schisandra.oss.application.oss.model.download.DownloadObjectStat;
|
import com.schisandra.oss.application.oss.model.download.DownloadObjectStat;
|
||||||
import com.schisandra.oss.application.oss.utils.OssPathUtil;
|
import com.schisandra.oss.application.oss.utils.OssPathUtil;
|
||||||
|
import io.minio.ListObjectsArgs;
|
||||||
|
import io.minio.Result;
|
||||||
|
import io.minio.messages.Item;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
@@ -66,15 +69,18 @@ public class QiNiuOssClient implements StandardOssClient {
|
|||||||
private QiNiuOssConfig qiNiuOssConfig;
|
private QiNiuOssConfig qiNiuOssConfig;
|
||||||
private Configuration configuration;
|
private Configuration configuration;
|
||||||
|
|
||||||
/*
|
|
||||||
* 将时间转换为时间戳
|
public String getQiniuBucketSize(String bucket) {
|
||||||
*/
|
String delimiter = "";
|
||||||
@SneakyThrows
|
Long x = 0L;
|
||||||
public static long dateToStamp(String s) {
|
BucketManager.FileListIterator fileListIterator = bucketManager.createFileListIterator(bucket, "", 1000, delimiter);
|
||||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
while (fileListIterator.hasNext()) {
|
||||||
Date date = simpleDateFormat.parse(s);
|
FileInfo[] items = fileListIterator.next();
|
||||||
long ts = date.getTime();
|
for (FileInfo item : items) {
|
||||||
return ts;
|
x += item.fsize;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return DataSizeUtil.format(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -86,7 +92,6 @@ public class QiNiuOssClient implements StandardOssClient {
|
|||||||
public List<OssInfo> listfile(String bucket, String prefix) {
|
public List<OssInfo> listfile(String bucket, String prefix) {
|
||||||
String delimiter = "";
|
String delimiter = "";
|
||||||
|
|
||||||
|
|
||||||
BucketManager.FileListIterator fileListIterator = bucketManager.createFileListIterator(bucket, prefix, 1000, delimiter);
|
BucketManager.FileListIterator fileListIterator = bucketManager.createFileListIterator(bucket, prefix, 1000, delimiter);
|
||||||
List<OssInfo> infos = new ArrayList<>();
|
List<OssInfo> infos = new ArrayList<>();
|
||||||
while (fileListIterator.hasNext()){
|
while (fileListIterator.hasNext()){
|
||||||
@@ -143,11 +148,13 @@ public class QiNiuOssClient implements StandardOssClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SneakyThrows
|
public HashMap<String, String> selectAllBucket() throws IOException{
|
||||||
public String[] selectAllBucket() {
|
String[] list = bucketManager.buckets();
|
||||||
String[] buckets = bucketManager.buckets();
|
HashMap<String, String> names = new HashMap<>();
|
||||||
|
for(int i=0;i<list.length;i++){
|
||||||
return buckets;
|
names.put(list[i],getQiniuBucketSize(list[i]));
|
||||||
|
}
|
||||||
|
return names;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -176,7 +183,6 @@ public class QiNiuOssClient implements StandardOssClient {
|
|||||||
System.out.println(re.code());
|
System.out.println(re.code());
|
||||||
System.out.println(re.toString());
|
System.out.println(re.toString());
|
||||||
return re.code();
|
return re.code();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -7,15 +7,20 @@ import com.qiniu.storage.BucketManager;
|
|||||||
import com.qiniu.storage.Configuration;
|
import com.qiniu.storage.Configuration;
|
||||||
import com.qiniu.storage.UploadManager;
|
import com.qiniu.storage.UploadManager;
|
||||||
import com.qiniu.util.Auth;
|
import com.qiniu.util.Auth;
|
||||||
|
import com.schisandra.oss.application.convert.SchisandraOssAliDTOConverter;
|
||||||
import com.schisandra.oss.application.convert.SchisandraOssQiniuDTOConverter;
|
import com.schisandra.oss.application.convert.SchisandraOssQiniuDTOConverter;
|
||||||
import com.schisandra.oss.application.convert.SchisandraOssUpDTOConverter;
|
import com.schisandra.oss.application.convert.SchisandraOssUpDTOConverter;
|
||||||
|
import com.schisandra.oss.application.dto.SchisandraOssAliDTO;
|
||||||
import com.schisandra.oss.application.dto.SchisandraOssQiniuDTO;
|
import com.schisandra.oss.application.dto.SchisandraOssQiniuDTO;
|
||||||
import com.schisandra.oss.application.dto.SchisandraOssUpDTO;
|
import com.schisandra.oss.application.dto.SchisandraOssUpDTO;
|
||||||
|
import com.schisandra.oss.application.oss.constant.OssConstant;
|
||||||
import com.schisandra.oss.application.oss.core.StandardOssClient;
|
import com.schisandra.oss.application.oss.core.StandardOssClient;
|
||||||
|
import com.schisandra.oss.application.oss.core.ali.model.AliOssConfig;
|
||||||
import com.schisandra.oss.application.oss.core.qiniu.model.QiNiuOssClientConfig;
|
import com.schisandra.oss.application.oss.core.qiniu.model.QiNiuOssClientConfig;
|
||||||
import com.schisandra.oss.application.oss.core.qiniu.model.QiNiuOssConfig;
|
import com.schisandra.oss.application.oss.core.qiniu.model.QiNiuOssConfig;
|
||||||
import com.schisandra.oss.application.oss.model.SliceConfig;
|
import com.schisandra.oss.application.oss.model.SliceConfig;
|
||||||
import com.schisandra.oss.common.entity.Result;
|
import com.schisandra.oss.common.entity.Result;
|
||||||
|
import com.schisandra.oss.domain.bo.SchisandraOssAliBO;
|
||||||
import com.schisandra.oss.domain.bo.SchisandraOssQiniuBO;
|
import com.schisandra.oss.domain.bo.SchisandraOssQiniuBO;
|
||||||
import com.schisandra.oss.domain.bo.SchisandraOssUpBO;
|
import com.schisandra.oss.domain.bo.SchisandraOssUpBO;
|
||||||
import com.schisandra.oss.domain.service.SchisandraOssQiniuDomainService;
|
import com.schisandra.oss.domain.service.SchisandraOssQiniuDomainService;
|
||||||
@@ -45,16 +50,6 @@ public class QiNiuOssConfiguration {
|
|||||||
@Resource
|
@Resource
|
||||||
private SchisandraOssQiniuDomainService schisandraOssQiniuDomainService;
|
private SchisandraOssQiniuDomainService schisandraOssQiniuDomainService;
|
||||||
|
|
||||||
public List<SchisandraOssQiniuDTO> selectAll(){
|
|
||||||
List<SchisandraOssQiniuBO> schisandraOssQiniuBO_list = schisandraOssQiniuDomainService.selectAll();
|
|
||||||
List<SchisandraOssQiniuDTO> schisandraOssQiniuDTO_list = new ArrayList<>();
|
|
||||||
for (SchisandraOssQiniuBO schisandraOssQiniuBO : schisandraOssQiniuBO_list ){
|
|
||||||
SchisandraOssQiniuDTO schisandraOssQiniuDTO = SchisandraOssQiniuDTOConverter.INSTANCE.convertBOToDTO(schisandraOssQiniuBO);
|
|
||||||
schisandraOssQiniuDTO_list.add(schisandraOssQiniuDTO);
|
|
||||||
}
|
|
||||||
return schisandraOssQiniuDTO_list;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public SchisandraOssQiniuDTO getSchisandraOssQiNDTO(String userId) {
|
public SchisandraOssQiniuDTO getSchisandraOssQiNDTO(String userId) {
|
||||||
CompletableFuture<SchisandraOssQiniuDTO> futurePrice = CompletableFuture.supplyAsync(() -> {
|
CompletableFuture<SchisandraOssQiniuDTO> futurePrice = CompletableFuture.supplyAsync(() -> {
|
||||||
@@ -71,22 +66,28 @@ public class QiNiuOssConfiguration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Result qiNiuOssClient(String userId) {
|
public Result qiNiuOssClient(String userId) {
|
||||||
try {
|
CompletableFuture<SchisandraOssQiniuDTO> futurePrice = CompletableFuture.supplyAsync(() -> {
|
||||||
SchisandraOssQiniuDTO qiniu = qiniuOssConfiguration.getSchisandraOssQiNDTO(userId);
|
SchisandraOssQiniuBO schisandraOssQiniuBO = schisandraOssQiniuDomainService.getQiniuOssConfig(userId);
|
||||||
if (qiniu == null) return null;
|
SchisandraOssQiniuDTO schisandraOssQiniuDTO = SchisandraOssQiniuDTOConverter.INSTANCE.convertBOToDTO(schisandraOssQiniuBO);
|
||||||
QiNiuOssConfig qiniuOssConfig = new QiNiuOssConfig();
|
return schisandraOssQiniuDTO;
|
||||||
qiniuOssConfig.setBasePath(qiniu.getBasePath());
|
});
|
||||||
qiniuOssConfig.setBucketName(qiniu.getBucketName());
|
SchisandraOssQiniuDTO qiniu = futurePrice.join();
|
||||||
qiniuOssConfig.setAccessKey(qiniu.getAccessKey());
|
if (ObjectUtil.isEmpty(qiniu)) {
|
||||||
qiniuOssConfig.setSecretKey(qiniu.getSecretKey());
|
log.error("qiniu oss配置信息获取失败");
|
||||||
qiniuOssConfig.setRegion(qiniu.getRegion());
|
return Result.fail();
|
||||||
qiniuOssConfig.setEndpoint(qiniu.getEndpoint());
|
}
|
||||||
qiniuOssConfig.init();
|
QiNiuOssConfig qiniuOssConfig = new QiNiuOssConfig();
|
||||||
|
qiniuOssConfig.setBasePath(qiniu.getBasePath());
|
||||||
SpringUtil.registerBean(userId, qiNiuOssClient(qiniuOssConfig));
|
qiniuOssConfig.setBucketName(qiniu.getBucketName());
|
||||||
|
qiniuOssConfig.setAccessKey(qiniu.getAccessKey());
|
||||||
|
qiniuOssConfig.setSecretKey(qiniu.getSecretKey());
|
||||||
|
qiniuOssConfig.setRegion(qiniu.getRegion());
|
||||||
|
qiniuOssConfig.setEndpoint(qiniu.getEndpoint());
|
||||||
|
try{
|
||||||
|
SpringUtil.registerBean(OssConstant.OssType.QINIU+ userId, qiNiuOssClient(qiniuOssConfig));
|
||||||
return Result.ok();
|
return Result.ok();
|
||||||
} catch (Exception e) {
|
}catch(Exception e){
|
||||||
log.error("QiniuOssConfiguration.qiniuOssClient:{}", e.getMessage(), e);
|
e.printStackTrace();
|
||||||
return Result.fail();
|
return Result.fail();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -2,13 +2,18 @@ package com.schisandra.oss.application.oss.core.sftp;
|
|||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.extra.spring.SpringUtil;
|
import cn.hutool.extra.spring.SpringUtil;
|
||||||
import cn.hutool.extra.ssh.Sftp;
|
import cn.hutool.extra.ssh.Sftp;
|
||||||
|
import com.schisandra.oss.application.convert.SchisandraOssAliDTOConverter;
|
||||||
import com.schisandra.oss.application.convert.SchisandraOssSftpDTOConverter;
|
import com.schisandra.oss.application.convert.SchisandraOssSftpDTOConverter;
|
||||||
import com.schisandra.oss.application.convert.SchisandraOssUpDTOConverter;
|
import com.schisandra.oss.application.convert.SchisandraOssUpDTOConverter;
|
||||||
|
import com.schisandra.oss.application.dto.SchisandraOssAliDTO;
|
||||||
import com.schisandra.oss.application.dto.SchisandraOssSftpDTO;
|
import com.schisandra.oss.application.dto.SchisandraOssSftpDTO;
|
||||||
import com.schisandra.oss.application.dto.SchisandraOssUpDTO;
|
import com.schisandra.oss.application.dto.SchisandraOssUpDTO;
|
||||||
|
import com.schisandra.oss.application.oss.constant.OssConstant;
|
||||||
import com.schisandra.oss.application.oss.core.StandardOssClient;
|
import com.schisandra.oss.application.oss.core.StandardOssClient;
|
||||||
|
import com.schisandra.oss.application.oss.core.ali.model.AliOssConfig;
|
||||||
import com.schisandra.oss.application.oss.core.sftp.model.SftpOssConfig;
|
import com.schisandra.oss.application.oss.core.sftp.model.SftpOssConfig;
|
||||||
import com.schisandra.oss.common.entity.Result;
|
import com.schisandra.oss.common.entity.Result;
|
||||||
|
import com.schisandra.oss.domain.bo.SchisandraOssAliBO;
|
||||||
import com.schisandra.oss.domain.bo.SchisandraOssSftpBO;
|
import com.schisandra.oss.domain.bo.SchisandraOssSftpBO;
|
||||||
import com.schisandra.oss.domain.bo.SchisandraOssUpBO;
|
import com.schisandra.oss.domain.bo.SchisandraOssUpBO;
|
||||||
import com.schisandra.oss.domain.service.SchisandraOssSftpDomainService;
|
import com.schisandra.oss.domain.service.SchisandraOssSftpDomainService;
|
||||||
@@ -33,16 +38,6 @@ public class SftpOssConfiguration {
|
|||||||
|
|
||||||
public static final String DEFAULT_BEAN_NAME = "sftpOssClient";
|
public static final String DEFAULT_BEAN_NAME = "sftpOssClient";
|
||||||
|
|
||||||
public List<SchisandraOssSftpDTO> selectAll(){
|
|
||||||
List<SchisandraOssSftpBO> schisandraOssSftpBO_list = schisandraOssSftpDomainService.selectAll();
|
|
||||||
List<SchisandraOssSftpDTO> schisandraOssSdtpDTO_list = new ArrayList<>();
|
|
||||||
for (SchisandraOssSftpBO shisandraOssSftpBO : schisandraOssSftpBO_list ){
|
|
||||||
SchisandraOssSftpDTO schisandraOssSftpDTO = SchisandraOssSftpDTOConverter.INSTANCE.convertBOToDTO(shisandraOssSftpBO);
|
|
||||||
schisandraOssSdtpDTO_list.add(schisandraOssSftpDTO);
|
|
||||||
}
|
|
||||||
return schisandraOssSdtpDTO_list;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SchisandraOssSftpDTO getSchisandraOssSftpDTO(String userId) {
|
public SchisandraOssSftpDTO getSchisandraOssSftpDTO(String userId) {
|
||||||
CompletableFuture<SchisandraOssSftpDTO> futurePrice = CompletableFuture.supplyAsync(() -> {
|
CompletableFuture<SchisandraOssSftpDTO> futurePrice = CompletableFuture.supplyAsync(() -> {
|
||||||
SchisandraOssSftpBO sftpBO = schisandraOssSftpDomainService.getSftpOssConfig(userId);
|
SchisandraOssSftpBO sftpBO = schisandraOssSftpDomainService.getSftpOssConfig(userId);
|
||||||
@@ -59,21 +54,27 @@ public class SftpOssConfiguration {
|
|||||||
|
|
||||||
|
|
||||||
public Result sftpOssClient(String userId) {
|
public Result sftpOssClient(String userId) {
|
||||||
try {
|
CompletableFuture<SchisandraOssSftpDTO> futurePrice = CompletableFuture.supplyAsync(() -> {
|
||||||
SchisandraOssSftpDTO sftp = sftpOssConfiguration.getSchisandraOssSftpDTO(userId);
|
SchisandraOssSftpBO schisandraOssSftpBO = schisandraOssSftpDomainService.getSftpOssConfig(userId);
|
||||||
if (sftp == null) return null;
|
SchisandraOssSftpDTO schisandraOssSftpDTO = SchisandraOssSftpDTOConverter.INSTANCE.convertBOToDTO(schisandraOssSftpBO);
|
||||||
SftpOssConfig sftpOssConfig = new SftpOssConfig();
|
return schisandraOssSftpDTO;
|
||||||
sftpOssConfig.setBasePath(sftp.getBasePath());
|
});
|
||||||
sftpOssConfig.setHost(sftp.getHost());
|
SchisandraOssSftpDTO sftp = futurePrice.join();
|
||||||
sftpOssConfig.setPort(sftp.getPort());
|
if (ObjectUtil.isEmpty(sftp)) {
|
||||||
sftpOssConfig.setPassword(sftp.getPassword());
|
log.error("sftp oss配置信息获取失败");
|
||||||
sftpOssConfig.setCharset(sftp.getCharset());
|
return Result.fail();
|
||||||
sftpOssConfig.init();
|
}
|
||||||
|
SftpOssConfig sftpOssConfig = new SftpOssConfig();
|
||||||
SpringUtil.registerBean(userId, sftpOssClient(sftpOssConfig));
|
sftpOssConfig.setBasePath(sftp.getBasePath());
|
||||||
|
sftpOssConfig.setHost(sftp.getHost());
|
||||||
|
sftpOssConfig.setPort(sftp.getPort());
|
||||||
|
sftpOssConfig.setPassword(sftp.getPassword());
|
||||||
|
sftpOssConfig.setCharset(sftp.getCharset());
|
||||||
|
try{
|
||||||
|
SpringUtil.registerBean(OssConstant.OssType.SFTP+ userId, sftpOssClient(sftpOssConfig));
|
||||||
return Result.ok();
|
return Result.ok();
|
||||||
} catch (Exception e) {
|
}catch(Exception e){
|
||||||
log.error("SftpOssConfiguration.qiniuOssClient:{}", e.getMessage(), e);
|
e.printStackTrace();
|
||||||
return Result.fail();
|
return Result.fail();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -10,14 +10,19 @@ import com.qcloud.cos.auth.BasicCOSCredentials;
|
|||||||
import com.qcloud.cos.auth.COSCredentials;
|
import com.qcloud.cos.auth.COSCredentials;
|
||||||
import com.qcloud.cos.http.HttpProtocol;
|
import com.qcloud.cos.http.HttpProtocol;
|
||||||
import com.qcloud.cos.region.Region;
|
import com.qcloud.cos.region.Region;
|
||||||
|
import com.schisandra.oss.application.convert.SchisandraOssAliDTOConverter;
|
||||||
import com.schisandra.oss.application.convert.SchisandraOssTencentDTOConverter;
|
import com.schisandra.oss.application.convert.SchisandraOssTencentDTOConverter;
|
||||||
import com.schisandra.oss.application.convert.SchisandraOssUpDTOConverter;
|
import com.schisandra.oss.application.convert.SchisandraOssUpDTOConverter;
|
||||||
|
import com.schisandra.oss.application.dto.SchisandraOssAliDTO;
|
||||||
import com.schisandra.oss.application.dto.SchisandraOssTencentDTO;
|
import com.schisandra.oss.application.dto.SchisandraOssTencentDTO;
|
||||||
import com.schisandra.oss.application.dto.SchisandraOssUpDTO;
|
import com.schisandra.oss.application.dto.SchisandraOssUpDTO;
|
||||||
|
import com.schisandra.oss.application.oss.constant.OssConstant;
|
||||||
import com.schisandra.oss.application.oss.core.StandardOssClient;
|
import com.schisandra.oss.application.oss.core.StandardOssClient;
|
||||||
|
import com.schisandra.oss.application.oss.core.ali.model.AliOssConfig;
|
||||||
import com.schisandra.oss.application.oss.core.tencent.model.TencentOssClientConfig;
|
import com.schisandra.oss.application.oss.core.tencent.model.TencentOssClientConfig;
|
||||||
import com.schisandra.oss.application.oss.core.tencent.model.TencentOssConfig;
|
import com.schisandra.oss.application.oss.core.tencent.model.TencentOssConfig;
|
||||||
import com.schisandra.oss.common.entity.Result;
|
import com.schisandra.oss.common.entity.Result;
|
||||||
|
import com.schisandra.oss.domain.bo.SchisandraOssAliBO;
|
||||||
import com.schisandra.oss.domain.bo.SchisandraOssTencentBO;
|
import com.schisandra.oss.domain.bo.SchisandraOssTencentBO;
|
||||||
import com.schisandra.oss.domain.bo.SchisandraOssUpBO;
|
import com.schisandra.oss.domain.bo.SchisandraOssUpBO;
|
||||||
import com.schisandra.oss.domain.service.SchisandraOssTencentDomainService;
|
import com.schisandra.oss.domain.service.SchisandraOssTencentDomainService;
|
||||||
@@ -29,6 +34,7 @@ import javax.annotation.Resource;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
import static com.tencentcloudapi.common.profile.Region.Chengdu;
|
import static com.tencentcloudapi.common.profile.Region.Chengdu;
|
||||||
|
|
||||||
@@ -46,47 +52,33 @@ public class TencentOssConfiguration {
|
|||||||
@Resource
|
@Resource
|
||||||
private SchisandraOssTencentDomainService schisandraOssTencentDomainService;
|
private SchisandraOssTencentDomainService schisandraOssTencentDomainService;
|
||||||
|
|
||||||
public List<SchisandraOssTencentDTO> selectAll(){
|
|
||||||
List<SchisandraOssTencentBO> schisandraOssTencentBO_list = schisandraOssTencentDomainService.selectAll();
|
|
||||||
List<SchisandraOssTencentDTO> schisandraOssTencentDTO_list = new ArrayList<>();
|
|
||||||
for (SchisandraOssTencentBO schisandraOssTencentBO : schisandraOssTencentBO_list ){
|
|
||||||
SchisandraOssTencentDTO schisandraOssTencentDTO = SchisandraOssTencentDTOConverter.INSTANCE.convertBOToDTO(schisandraOssTencentBO);
|
|
||||||
schisandraOssTencentDTO_list.add(schisandraOssTencentDTO);
|
|
||||||
}
|
|
||||||
return schisandraOssTencentDTO_list;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Result tencentOssClient(String userId) {
|
public Result tencentOssClient(String userId) {
|
||||||
SchisandraOssTencentBO schisandraOssTencentBO = schisandraOssTencentDomainService.getTencentOssConfig(userId);
|
CompletableFuture<SchisandraOssTencentDTO> futurePrice = CompletableFuture.supplyAsync(() -> {
|
||||||
SchisandraOssTencentDTO schisandraOssTencentDTO = SchisandraOssTencentDTOConverter.INSTANCE.convertBOToDTO(schisandraOssTencentBO);
|
SchisandraOssTencentBO schisandraOssTencentBO = schisandraOssTencentDomainService.getTencentOssConfig(userId);
|
||||||
if (ObjectUtil.isEmpty(schisandraOssTencentDTO)) {
|
SchisandraOssTencentDTO schisandraOssTencentDTO = SchisandraOssTencentDTOConverter.INSTANCE.convertBOToDTO(schisandraOssTencentBO);
|
||||||
log.error("Tencent oss配置信息获取失败");
|
return schisandraOssTencentDTO;
|
||||||
return null;
|
});
|
||||||
|
SchisandraOssTencentDTO tencent = futurePrice.join();
|
||||||
|
if (ObjectUtil.isEmpty(tencent)) {
|
||||||
|
log.error("tencent oss配置信息获取失败");
|
||||||
|
return Result.fail();
|
||||||
}
|
}
|
||||||
String secretId = schisandraOssTencentDTO.getSecretId();
|
|
||||||
String secretKey = schisandraOssTencentDTO.getSecretKey();
|
|
||||||
TencentOssConfig tencentOssConfig = new TencentOssConfig();
|
TencentOssConfig tencentOssConfig = new TencentOssConfig();
|
||||||
tencentOssConfig.setSecretId(secretId);
|
tencentOssConfig.setSecretId(tencent.getSecretId());
|
||||||
tencentOssConfig.setSecretKey(secretKey);
|
tencentOssConfig.setSecretKey(tencent.getSecretKey());
|
||||||
|
|
||||||
|
|
||||||
// COSCredentials cred = new BasicCOSCredentials(secretId, secretKey);
|
|
||||||
// Region region = new Region();
|
|
||||||
//高级设置
|
|
||||||
TencentOssClientConfig tencentOssClientConfig = new TencentOssClientConfig();
|
TencentOssClientConfig tencentOssClientConfig = new TencentOssClientConfig();
|
||||||
tencentOssClientConfig.setRegion("ap-chengdu");
|
tencentOssClientConfig.setRegion("ap-chengdu");
|
||||||
// COSClient cosClient = new COSClient(cred, clientConfig.toClientConfig());
|
|
||||||
tencentOssConfig.setClientConfig(tencentOssClientConfig);
|
tencentOssConfig.setClientConfig(tencentOssClientConfig);
|
||||||
//
|
try{
|
||||||
|
SpringUtil.registerBean(OssConstant.OssType.TENCENT+ userId, tencentOssClient(tencentOssConfig));
|
||||||
try {
|
|
||||||
SpringUtil.registerBean(userId, tencentOssClient(tencentOssConfig));
|
|
||||||
return Result.ok();
|
return Result.ok();
|
||||||
} catch (Exception e) {
|
}catch(Exception e){
|
||||||
log.error("TencentOssConfiguration.tencentOssClient:{}", e.getMessage(), e);
|
e.printStackTrace();
|
||||||
return Result.fail();
|
return Result.fail();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private StandardOssClient tencentOssClient(TencentOssConfig tencentOssConfig) {
|
private StandardOssClient tencentOssClient(TencentOssConfig tencentOssConfig) {
|
||||||
TencentOssClientConfig clientConfig = Optional.ofNullable(tencentOssConfig.getClientConfig()).orElse(new TencentOssClientConfig());
|
TencentOssClientConfig clientConfig = Optional.ofNullable(tencentOssConfig.getClientConfig()).orElse(new TencentOssClientConfig());
|
||||||
COSCredentials cosCredentials = cosCredentials(tencentOssConfig);
|
COSCredentials cosCredentials = cosCredentials(tencentOssConfig);
|
||||||
|
@@ -11,9 +11,11 @@ import com.schisandra.oss.application.dto.SchisandraOssUcloudDTO;
|
|||||||
import com.schisandra.oss.application.dto.SchisandraOssUpDTO;
|
import com.schisandra.oss.application.dto.SchisandraOssUpDTO;
|
||||||
import com.schisandra.oss.application.oss.constant.OssConstant;
|
import com.schisandra.oss.application.oss.constant.OssConstant;
|
||||||
import com.schisandra.oss.application.oss.core.StandardOssClient;
|
import com.schisandra.oss.application.oss.core.StandardOssClient;
|
||||||
|
import com.schisandra.oss.application.oss.core.ali.model.AliOssConfig;
|
||||||
import com.schisandra.oss.application.oss.core.up.model.UpOssClientConfig;
|
import com.schisandra.oss.application.oss.core.up.model.UpOssClientConfig;
|
||||||
import com.schisandra.oss.application.oss.core.up.model.UpOssConfig;
|
import com.schisandra.oss.application.oss.core.up.model.UpOssConfig;
|
||||||
import com.schisandra.oss.application.oss.model.SliceConfig;
|
import com.schisandra.oss.application.oss.model.SliceConfig;
|
||||||
|
import com.schisandra.oss.common.entity.Result;
|
||||||
import com.schisandra.oss.domain.bo.SchisandraOssAliBO;
|
import com.schisandra.oss.domain.bo.SchisandraOssAliBO;
|
||||||
import com.schisandra.oss.domain.bo.SchisandraOssUcloudBO;
|
import com.schisandra.oss.domain.bo.SchisandraOssUcloudBO;
|
||||||
import com.schisandra.oss.domain.bo.SchisandraOssUpBO;
|
import com.schisandra.oss.domain.bo.SchisandraOssUpBO;
|
||||||
@@ -36,6 +38,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description:
|
* @description:
|
||||||
@@ -53,38 +56,31 @@ public class UpOssConfiguration {
|
|||||||
@Resource
|
@Resource
|
||||||
private SchisandraOssUpDomainService schisandraOssUpDomainService;
|
private SchisandraOssUpDomainService schisandraOssUpDomainService;
|
||||||
|
|
||||||
public List<SchisandraOssUpDTO> selectAll(){
|
|
||||||
List<SchisandraOssUpBO> schisandraOssUpBO_list = schisandraOssUpDomainService.selectAll();
|
|
||||||
List<SchisandraOssUpDTO> schisandraOssUpDTO_list = new ArrayList<>();
|
public Result upOssClient(String userId) {
|
||||||
for (SchisandraOssUpBO schisandraOssUpBO : schisandraOssUpBO_list ){
|
CompletableFuture<SchisandraOssUpDTO> futurePrice = CompletableFuture.supplyAsync(() -> {
|
||||||
|
SchisandraOssUpBO schisandraOssUpBO = schisandraOssUpDomainService.getUpOssConfig(userId);
|
||||||
SchisandraOssUpDTO schisandraOssUpDTO = SchisandraOssUpDTOConverter.INSTANCE.convertBOToDTO(schisandraOssUpBO);
|
SchisandraOssUpDTO schisandraOssUpDTO = SchisandraOssUpDTOConverter.INSTANCE.convertBOToDTO(schisandraOssUpBO);
|
||||||
schisandraOssUpDTO_list.add(schisandraOssUpDTO);
|
return schisandraOssUpDTO;
|
||||||
|
});
|
||||||
|
SchisandraOssUpDTO up = futurePrice.join();
|
||||||
|
if (ObjectUtil.isEmpty(up)) {
|
||||||
|
log.error("up oss配置信息获取失败");
|
||||||
|
return Result.fail();
|
||||||
}
|
}
|
||||||
return schisandraOssUpDTO_list;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public StandardOssClient upOssClient(String userId) {
|
|
||||||
SchisandraOssUpBO schisandraOssUpBO = schisandraOssUpDomainService.getUpOssConfig(userId);
|
|
||||||
SchisandraOssUpDTO schisandraOssUpDTO = SchisandraOssUpDTOConverter.INSTANCE.convertBOToDTO(schisandraOssUpBO);
|
|
||||||
log.info("Up oss配置信息获取成功:{}", schisandraOssUpDTO);
|
|
||||||
if (ObjectUtil.isEmpty(schisandraOssUpDTO)) {
|
|
||||||
log.error("Up oss配置信息获取失败");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
String userName = schisandraOssUpDTO.getUserName();
|
|
||||||
String password = schisandraOssUpDTO.getPassword();
|
|
||||||
String bucketName = schisandraOssUpDTO.getBucketName();
|
|
||||||
String basePath = schisandraOssUpDTO.getBasePath();
|
|
||||||
UpOssConfig upOssConfig = new UpOssConfig();
|
UpOssConfig upOssConfig = new UpOssConfig();
|
||||||
upOssConfig.setUserName(userName);
|
upOssConfig.setUserName(up.getUserName());
|
||||||
upOssConfig.setPassword(password);
|
upOssConfig.setPassword(up.getPassword());
|
||||||
upOssConfig.setBucketName(bucketName);
|
upOssConfig.setBucketName(up.getBucketName());
|
||||||
upOssConfig.setBasePath(basePath);
|
upOssConfig.setBasePath(up.getBasePath());
|
||||||
SpringUtil.registerBean(userId, upOssClient(upOssConfig));
|
try{
|
||||||
return upOssClient(upOssConfig);
|
SpringUtil.registerBean(OssConstant.OssType.UP+ userId, upOssClient(upOssConfig));
|
||||||
|
return Result.ok();
|
||||||
|
}catch(Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
return Result.fail();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private UpOssClient upOssClient(UpOssConfig upOssConfig) {
|
private UpOssClient upOssClient(UpOssConfig upOssConfig) {
|
||||||
|
@@ -0,0 +1,56 @@
|
|||||||
|
package com.schisandra.oss.common.enums;
|
||||||
|
|
||||||
|
public enum OssName {
|
||||||
|
/**
|
||||||
|
* 阿里oss
|
||||||
|
*/
|
||||||
|
ALI("阿里云OSS"),
|
||||||
|
/**
|
||||||
|
* Minio oss
|
||||||
|
*/
|
||||||
|
MINIO("MinIO"),
|
||||||
|
/**
|
||||||
|
* 又拍OSS
|
||||||
|
*/
|
||||||
|
UP("又拍云USS"),
|
||||||
|
/**
|
||||||
|
* SFTP
|
||||||
|
*/
|
||||||
|
SFTP("sftp"),
|
||||||
|
/**
|
||||||
|
* 腾讯OSS
|
||||||
|
*/
|
||||||
|
TENCENT("腾讯云COS"),
|
||||||
|
/**
|
||||||
|
* 百度OSS
|
||||||
|
*/
|
||||||
|
BAIDU("百度云BOS"),
|
||||||
|
/**
|
||||||
|
* 华为OSS
|
||||||
|
*/
|
||||||
|
HUAWEI("华为云OBS"),
|
||||||
|
/**
|
||||||
|
* 网易 OSS
|
||||||
|
*/
|
||||||
|
WANGYI("网易云NOS"),
|
||||||
|
/**
|
||||||
|
* 七牛 oss
|
||||||
|
*/
|
||||||
|
QINIU("七牛云Kodo");
|
||||||
|
|
||||||
|
|
||||||
|
public String type;
|
||||||
|
|
||||||
|
|
||||||
|
OssName(String type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
public static OssType getByType(String type) {
|
||||||
|
for (OssType resultKeyEnum : OssType.values()) {
|
||||||
|
if (resultKeyEnum.type.equals(type)) {
|
||||||
|
return resultKeyEnum;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,56 @@
|
|||||||
|
package com.schisandra.oss.common.enums;
|
||||||
|
|
||||||
|
public enum OssType {
|
||||||
|
/**
|
||||||
|
* 阿里oss
|
||||||
|
*/
|
||||||
|
ALI("ali"),
|
||||||
|
/**
|
||||||
|
* Minio oss
|
||||||
|
*/
|
||||||
|
MINIO("minio"),
|
||||||
|
/**
|
||||||
|
* 又拍OSS
|
||||||
|
*/
|
||||||
|
UP("up"),
|
||||||
|
/**
|
||||||
|
* SFTP
|
||||||
|
*/
|
||||||
|
SFTP("sftp"),
|
||||||
|
/**
|
||||||
|
* 腾讯OSS
|
||||||
|
*/
|
||||||
|
TENCENT("tencent"),
|
||||||
|
/**
|
||||||
|
* 百度OSS
|
||||||
|
*/
|
||||||
|
BAIDU("baidu"),
|
||||||
|
/**
|
||||||
|
* 华为OSS
|
||||||
|
*/
|
||||||
|
HUAWEI("huawei"),
|
||||||
|
/**
|
||||||
|
* 网易 OSS
|
||||||
|
*/
|
||||||
|
WANGYI("wangyi"),
|
||||||
|
/**
|
||||||
|
* 七牛 oss
|
||||||
|
*/
|
||||||
|
QINIU("qiniu");
|
||||||
|
|
||||||
|
|
||||||
|
public String type;
|
||||||
|
|
||||||
|
|
||||||
|
OssType(String type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
public static OssType getByType(String type) {
|
||||||
|
for (OssType resultKeyEnum : OssType.values()) {
|
||||||
|
if (resultKeyEnum.type.equals(type)) {
|
||||||
|
return resultKeyEnum;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
@@ -6,6 +6,8 @@ package com.schisandra.oss.domain.convert;
|
|||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.factory.Mappers;
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* bo转换器
|
* bo转换器
|
||||||
*
|
*
|
||||||
@@ -20,4 +22,5 @@ public interface SchisandraOssAliBOConverter {
|
|||||||
SchisandraOssAli convertBOToEntity(SchisandraOssAliBO schisandraOssAliBO);
|
SchisandraOssAli convertBOToEntity(SchisandraOssAliBO schisandraOssAliBO);
|
||||||
SchisandraOssAliBO convertEntityToBO(SchisandraOssAli schisandraOssAli);
|
SchisandraOssAliBO convertEntityToBO(SchisandraOssAli schisandraOssAli);
|
||||||
|
|
||||||
|
List<SchisandraOssAliBO> convertEntityToBOList(List<SchisandraOssAli> list);
|
||||||
}
|
}
|
||||||
|
@@ -5,6 +5,8 @@ import com.schisandra.oss.infra.basic.entity.SchisandraOssQiniu;
|
|||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.factory.Mappers;
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 七牛云对象存储配置表 bo转换器
|
* 七牛云对象存储配置表 bo转换器
|
||||||
*
|
*
|
||||||
@@ -18,5 +20,5 @@ public interface SchisandraOssQiniuBOConverter {
|
|||||||
|
|
||||||
SchisandraOssQiniu convertBOToEntity(SchisandraOssQiniuBO schisandraOssQiniuBO);
|
SchisandraOssQiniu convertBOToEntity(SchisandraOssQiniuBO schisandraOssQiniuBO);
|
||||||
SchisandraOssQiniuBO convertEntityToBO(SchisandraOssQiniu schisandraOssQiniu);
|
SchisandraOssQiniuBO convertEntityToBO(SchisandraOssQiniu schisandraOssQiniu);
|
||||||
|
List<SchisandraOssQiniuBO > convertEntityToBOList(List<SchisandraOssQiniu> schisandraOssQiniu);
|
||||||
}
|
}
|
||||||
|
@@ -5,6 +5,8 @@ import com.schisandra.oss.infra.basic.entity.SchisandraOssSftp;
|
|||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.factory.Mappers;
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sftp存储配置表 bo转换器
|
* sftp存储配置表 bo转换器
|
||||||
*
|
*
|
||||||
@@ -18,5 +20,5 @@ public interface SchisandraOssSftpBOConverter {
|
|||||||
|
|
||||||
SchisandraOssSftp convertBOToEntity(SchisandraOssSftpBO schisandraOssSftpBO);
|
SchisandraOssSftp convertBOToEntity(SchisandraOssSftpBO schisandraOssSftpBO);
|
||||||
SchisandraOssSftpBO convertEntityToBO(SchisandraOssSftp schisandraOssSftp);
|
SchisandraOssSftpBO convertEntityToBO(SchisandraOssSftp schisandraOssSftp);
|
||||||
|
List<SchisandraOssSftpBO> convertEntityToBOList(List<SchisandraOssSftp> schisandraOssSftp);
|
||||||
}
|
}
|
||||||
|
@@ -5,6 +5,8 @@ import com.schisandra.oss.infra.basic.entity.SchisandraOssTencent;
|
|||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.factory.Mappers;
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 腾讯云对象存储配置表 bo转换器
|
* 腾讯云对象存储配置表 bo转换器
|
||||||
*
|
*
|
||||||
@@ -19,5 +21,5 @@ public interface SchisandraOssTencentBOConverter {
|
|||||||
SchisandraOssTencent convertBOToEntity(SchisandraOssTencentBO schisandraOssTencentBO);
|
SchisandraOssTencent convertBOToEntity(SchisandraOssTencentBO schisandraOssTencentBO);
|
||||||
|
|
||||||
SchisandraOssTencentBO convertEntityToBO(SchisandraOssTencent schisandraOssTencent);
|
SchisandraOssTencentBO convertEntityToBO(SchisandraOssTencent schisandraOssTencent);
|
||||||
|
List<SchisandraOssTencentBO> convertEntityToBOList(List<SchisandraOssTencent> schisandraOssTencent);
|
||||||
}
|
}
|
||||||
|
@@ -5,6 +5,8 @@ import com.schisandra.oss.infra.basic.entity.SchisandraOssUp;
|
|||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.factory.Mappers;
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 又拍云对象存储配置表 bo转换器
|
* 又拍云对象存储配置表 bo转换器
|
||||||
*
|
*
|
||||||
@@ -18,5 +20,5 @@ public interface SchisandraOssUpBOConverter {
|
|||||||
|
|
||||||
SchisandraOssUp convertBOToEntity(SchisandraOssUpBO schisandraOssUpBO);
|
SchisandraOssUp convertBOToEntity(SchisandraOssUpBO schisandraOssUpBO);
|
||||||
SchisandraOssUpBO convertEntityToBO(SchisandraOssUp schisandraOssUp);
|
SchisandraOssUpBO convertEntityToBO(SchisandraOssUp schisandraOssUp);
|
||||||
|
List<SchisandraOssUpBO> convertEntityToBOList(List<SchisandraOssUp> schisandraOssUp);
|
||||||
}
|
}
|
||||||
|
@@ -2,6 +2,7 @@ package com.schisandra.oss.domain.service;
|
|||||||
|
|
||||||
import com.schisandra.oss.domain.bo.SchisandraOssAliBO;
|
import com.schisandra.oss.domain.bo.SchisandraOssAliBO;
|
||||||
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
@@ -28,4 +28,6 @@ public interface SchisandraUserOssDomainService {
|
|||||||
Boolean delete(SchisandraUserOssBO schisandraUserOssBO);
|
Boolean delete(SchisandraUserOssBO schisandraUserOssBO);
|
||||||
|
|
||||||
List<SchisandraUserOssBO> queryOSSByUserId(Long userId);
|
List<SchisandraUserOssBO> queryOSSByUserId(Long userId);
|
||||||
|
|
||||||
|
SchisandraUserOssBO queryOSSByTypeAndUserId(Long userId,String type);
|
||||||
}
|
}
|
||||||
|
@@ -2,16 +2,23 @@ package com.schisandra.oss.domain.service.impl;
|
|||||||
|
|
||||||
|
|
||||||
import com.schisandra.oss.common.enums.IsDeletedFlagEnum;
|
import com.schisandra.oss.common.enums.IsDeletedFlagEnum;
|
||||||
|
import com.schisandra.oss.common.enums.OssName;
|
||||||
|
import com.schisandra.oss.common.enums.OssType;
|
||||||
import com.schisandra.oss.domain.bo.SchisandraOssAliBO;
|
import com.schisandra.oss.domain.bo.SchisandraOssAliBO;
|
||||||
|
import com.schisandra.oss.domain.bo.SchisandraUserOssBO;
|
||||||
import com.schisandra.oss.domain.convert.SchisandraOssAliBOConverter;
|
import com.schisandra.oss.domain.convert.SchisandraOssAliBOConverter;
|
||||||
|
import com.schisandra.oss.domain.convert.SchisandraUserOssBOConverter;
|
||||||
import com.schisandra.oss.domain.service.SchisandraOssAliDomainService;
|
import com.schisandra.oss.domain.service.SchisandraOssAliDomainService;
|
||||||
import com.schisandra.oss.infra.basic.entity.SchisandraOssAli;
|
import com.schisandra.oss.infra.basic.entity.SchisandraOssAli;
|
||||||
|
import com.schisandra.oss.infra.basic.entity.SchisandraUserOss;
|
||||||
import com.schisandra.oss.infra.basic.service.SchisandraOssAliService;
|
import com.schisandra.oss.infra.basic.service.SchisandraOssAliService;
|
||||||
|
import com.schisandra.oss.infra.basic.service.SchisandraUserOssService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -26,9 +33,25 @@ public class SchisandraOssAliDomainServiceImpl implements SchisandraOssAliDomain
|
|||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private SchisandraOssAliService schisandraOssAliService;
|
private SchisandraOssAliService schisandraOssAliService;
|
||||||
|
@Resource
|
||||||
|
private SchisandraUserOssService schisandraUserOssService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean add(SchisandraOssAliBO schisandraOssAliBO) {
|
public Boolean add(SchisandraOssAliBO schisandraOssAliBO) {
|
||||||
|
SchisandraUserOss userOss = schisandraUserOssService.queryOSSByTypeAndUserId(schisandraOssAliBO.getUserId(), String.valueOf(OssType.ALI));
|
||||||
|
if(userOss == null){
|
||||||
|
SchisandraUserOss schisandraUserOss = new SchisandraUserOss();
|
||||||
|
schisandraUserOss.setUserId(schisandraOssAliBO.getUserId());
|
||||||
|
schisandraUserOss.setIsDeleted(0);
|
||||||
|
schisandraUserOss.setCreatedTime(new Date());
|
||||||
|
schisandraUserOss.setOssType(String.valueOf(OssType.ALI));
|
||||||
|
schisandraUserOss.setConfigcount(1);
|
||||||
|
schisandraUserOss.setName(String.valueOf(OssName.ALI));
|
||||||
|
schisandraUserOssService.insert(schisandraUserOss);
|
||||||
|
}else{
|
||||||
|
userOss.setConfigcount(userOss.getConfigcount()+1);
|
||||||
|
schisandraUserOssService.update(userOss);
|
||||||
|
}
|
||||||
SchisandraOssAli schisandraOssAli = SchisandraOssAliBOConverter.INSTANCE.convertBOToEntity(schisandraOssAliBO);
|
SchisandraOssAli schisandraOssAli = SchisandraOssAliBOConverter.INSTANCE.convertBOToEntity(schisandraOssAliBO);
|
||||||
schisandraOssAli.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());
|
schisandraOssAli.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());
|
||||||
return schisandraOssAliService.insert(schisandraOssAli) > 0;
|
return schisandraOssAliService.insert(schisandraOssAli) > 0;
|
||||||
@@ -59,12 +82,6 @@ public class SchisandraOssAliDomainServiceImpl implements SchisandraOssAliDomain
|
|||||||
@Override
|
@Override
|
||||||
public List<SchisandraOssAliBO> selectAll() {
|
public List<SchisandraOssAliBO> selectAll() {
|
||||||
List<SchisandraOssAli> list = schisandraOssAliService.selectAll();
|
List<SchisandraOssAli> list = schisandraOssAliService.selectAll();
|
||||||
List<SchisandraOssAliBO> schisandraOssAliBO_list = new ArrayList<>();
|
return SchisandraOssAliBOConverter.INSTANCE.convertEntityToBOList(list);
|
||||||
for (SchisandraOssAli schisandraOssAli : list) {
|
|
||||||
SchisandraOssAliBO schisandraOssAliBO = SchisandraOssAliBOConverter.INSTANCE.convertEntityToBO(schisandraOssAli);
|
|
||||||
schisandraOssAliBO_list.add(schisandraOssAliBO);
|
|
||||||
}
|
|
||||||
return schisandraOssAliBO_list;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -2,6 +2,8 @@ package com.schisandra.oss.domain.service.impl;
|
|||||||
|
|
||||||
|
|
||||||
import com.schisandra.oss.common.enums.IsDeletedFlagEnum;
|
import com.schisandra.oss.common.enums.IsDeletedFlagEnum;
|
||||||
|
import com.schisandra.oss.common.enums.OssName;
|
||||||
|
import com.schisandra.oss.common.enums.OssType;
|
||||||
import com.schisandra.oss.domain.bo.SchisandraOssAliBO;
|
import com.schisandra.oss.domain.bo.SchisandraOssAliBO;
|
||||||
import com.schisandra.oss.domain.bo.SchisandraOssMinioBO;
|
import com.schisandra.oss.domain.bo.SchisandraOssMinioBO;
|
||||||
import com.schisandra.oss.domain.convert.SchisandraOssAliBOConverter;
|
import com.schisandra.oss.domain.convert.SchisandraOssAliBOConverter;
|
||||||
@@ -9,12 +11,15 @@ import com.schisandra.oss.domain.convert.SchisandraOssMinioBOConverter;
|
|||||||
import com.schisandra.oss.domain.service.SchisandraOssMinioDomainService;
|
import com.schisandra.oss.domain.service.SchisandraOssMinioDomainService;
|
||||||
import com.schisandra.oss.infra.basic.entity.SchisandraOssAli;
|
import com.schisandra.oss.infra.basic.entity.SchisandraOssAli;
|
||||||
import com.schisandra.oss.infra.basic.entity.SchisandraOssMinio;
|
import com.schisandra.oss.infra.basic.entity.SchisandraOssMinio;
|
||||||
|
import com.schisandra.oss.infra.basic.entity.SchisandraUserOss;
|
||||||
import com.schisandra.oss.infra.basic.service.SchisandraOssMinioService;
|
import com.schisandra.oss.infra.basic.service.SchisandraOssMinioService;
|
||||||
|
import com.schisandra.oss.infra.basic.service.SchisandraUserOssService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -29,9 +34,25 @@ public class SchisandraOssMinioDomainServiceImpl implements SchisandraOssMinioDo
|
|||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private SchisandraOssMinioService schisandraOssMinioService;
|
private SchisandraOssMinioService schisandraOssMinioService;
|
||||||
|
@Resource
|
||||||
|
private SchisandraUserOssService schisandraUserOssService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean add(SchisandraOssMinioBO schisandraOssMinioBO) {
|
public Boolean add(SchisandraOssMinioBO schisandraOssMinioBO) {
|
||||||
|
SchisandraUserOss userOss = schisandraUserOssService.queryOSSByTypeAndUserId(schisandraOssMinioBO.getUserId(),String.valueOf(OssType.MINIO));
|
||||||
|
if(userOss == null){
|
||||||
|
SchisandraUserOss schisandraUserOss = new SchisandraUserOss();
|
||||||
|
schisandraUserOss.setUserId(schisandraOssMinioBO.getUserId());
|
||||||
|
schisandraUserOss.setIsDeleted(0);
|
||||||
|
schisandraUserOss.setCreatedTime(new Date());
|
||||||
|
schisandraUserOss.setOssType(String.valueOf(OssType.MINIO));
|
||||||
|
schisandraUserOss.setName(String.valueOf(OssName.MINIO));
|
||||||
|
schisandraUserOss.setConfigcount(1);
|
||||||
|
schisandraUserOssService.insert(schisandraUserOss);
|
||||||
|
}else{
|
||||||
|
userOss.setConfigcount(userOss.getConfigcount()+1);
|
||||||
|
schisandraUserOssService.update(userOss);
|
||||||
|
}
|
||||||
SchisandraOssMinio schisandraOssMinio = SchisandraOssMinioBOConverter.INSTANCE.convertBOToEntity(schisandraOssMinioBO);
|
SchisandraOssMinio schisandraOssMinio = SchisandraOssMinioBOConverter.INSTANCE.convertBOToEntity(schisandraOssMinioBO);
|
||||||
schisandraOssMinio.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());
|
schisandraOssMinio.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());
|
||||||
return schisandraOssMinioService.insert(schisandraOssMinio) > 0;
|
return schisandraOssMinioService.insert(schisandraOssMinio) > 0;
|
||||||
@@ -68,12 +89,7 @@ public class SchisandraOssMinioDomainServiceImpl implements SchisandraOssMinioDo
|
|||||||
@Override
|
@Override
|
||||||
public List<SchisandraOssMinioBO> selectAll(){
|
public List<SchisandraOssMinioBO> selectAll(){
|
||||||
List<SchisandraOssMinio> list = schisandraOssMinioService.selectAll();
|
List<SchisandraOssMinio> list = schisandraOssMinioService.selectAll();
|
||||||
List<SchisandraOssMinioBO> schisandraOssMinioBO_list = new ArrayList<>();
|
return SchisandraOssMinioBOConverter.INSTANCE.convertEntityToBOList(list);
|
||||||
for (SchisandraOssMinio schisandraOssMinio : list) {
|
|
||||||
SchisandraOssMinioBO schisandraOssMinioBO = SchisandraOssMinioBOConverter.INSTANCE.convertEntityToBO(schisandraOssMinio);
|
|
||||||
schisandraOssMinioBO_list.add(schisandraOssMinioBO);
|
|
||||||
}
|
|
||||||
return schisandraOssMinioBO_list;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,8 @@
|
|||||||
package com.schisandra.oss.domain.service.impl;
|
package com.schisandra.oss.domain.service.impl;
|
||||||
|
|
||||||
import com.schisandra.oss.common.enums.IsDeletedFlagEnum;
|
import com.schisandra.oss.common.enums.IsDeletedFlagEnum;
|
||||||
|
import com.schisandra.oss.common.enums.OssName;
|
||||||
|
import com.schisandra.oss.common.enums.OssType;
|
||||||
import com.schisandra.oss.domain.bo.SchisandraOssJdBO;
|
import com.schisandra.oss.domain.bo.SchisandraOssJdBO;
|
||||||
import com.schisandra.oss.domain.bo.SchisandraOssUpBO;
|
import com.schisandra.oss.domain.bo.SchisandraOssUpBO;
|
||||||
import com.schisandra.oss.domain.convert.SchisandraOssJdBOConverter;
|
import com.schisandra.oss.domain.convert.SchisandraOssJdBOConverter;
|
||||||
@@ -11,12 +13,15 @@ import com.schisandra.oss.domain.service.SchisandraOssQiniuDomainService;
|
|||||||
import com.schisandra.oss.infra.basic.entity.SchisandraOssJd;
|
import com.schisandra.oss.infra.basic.entity.SchisandraOssJd;
|
||||||
import com.schisandra.oss.infra.basic.entity.SchisandraOssQiniu;
|
import com.schisandra.oss.infra.basic.entity.SchisandraOssQiniu;
|
||||||
import com.schisandra.oss.infra.basic.entity.SchisandraOssUp;
|
import com.schisandra.oss.infra.basic.entity.SchisandraOssUp;
|
||||||
|
import com.schisandra.oss.infra.basic.entity.SchisandraUserOss;
|
||||||
import com.schisandra.oss.infra.basic.service.SchisandraOssQiniuService;
|
import com.schisandra.oss.infra.basic.service.SchisandraOssQiniuService;
|
||||||
|
import com.schisandra.oss.infra.basic.service.SchisandraUserOssService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -31,9 +36,26 @@ public class SchisandraOssQiniuDomainServiceImpl implements SchisandraOssQiniuDo
|
|||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private SchisandraOssQiniuService schisandraOssQiniuService;
|
private SchisandraOssQiniuService schisandraOssQiniuService;
|
||||||
|
@Resource
|
||||||
|
private SchisandraUserOssService schisandraUserOssService;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean add(SchisandraOssQiniuBO schisandraOssQiniuBO) {
|
public Boolean add(SchisandraOssQiniuBO schisandraOssQiniuBO) {
|
||||||
|
SchisandraUserOss userOss = schisandraUserOssService.queryOSSByTypeAndUserId(schisandraOssQiniuBO.getUserId(), String.valueOf(OssType.QINIU));
|
||||||
|
if(userOss == null){
|
||||||
|
SchisandraUserOss schisandraUserOss = new SchisandraUserOss();
|
||||||
|
schisandraUserOss.setUserId(schisandraOssQiniuBO.getUserId());
|
||||||
|
schisandraUserOss.setIsDeleted(0);
|
||||||
|
schisandraUserOss.setCreatedTime(new Date());
|
||||||
|
schisandraUserOss.setOssType(String.valueOf(OssType.QINIU));
|
||||||
|
schisandraUserOss.setName(String.valueOf(OssName.QINIU));
|
||||||
|
schisandraUserOss.setConfigcount(1);
|
||||||
|
schisandraUserOssService.insert(schisandraUserOss);
|
||||||
|
}else{
|
||||||
|
userOss.setConfigcount(userOss.getConfigcount()+1);
|
||||||
|
schisandraUserOssService.update(userOss);
|
||||||
|
}
|
||||||
SchisandraOssQiniu schisandraOssQiniu = SchisandraOssQiniuBOConverter.INSTANCE.convertBOToEntity(schisandraOssQiniuBO);
|
SchisandraOssQiniu schisandraOssQiniu = SchisandraOssQiniuBOConverter.INSTANCE.convertBOToEntity(schisandraOssQiniuBO);
|
||||||
schisandraOssQiniu.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());
|
schisandraOssQiniu.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());
|
||||||
return schisandraOssQiniuService.insert(schisandraOssQiniu) > 0;
|
return schisandraOssQiniuService.insert(schisandraOssQiniu) > 0;
|
||||||
@@ -63,11 +85,6 @@ public class SchisandraOssQiniuDomainServiceImpl implements SchisandraOssQiniuDo
|
|||||||
@Override
|
@Override
|
||||||
public List<SchisandraOssQiniuBO> selectAll(){
|
public List<SchisandraOssQiniuBO> selectAll(){
|
||||||
List<SchisandraOssQiniu> list = schisandraOssQiniuService.selectAll();
|
List<SchisandraOssQiniu> list = schisandraOssQiniuService.selectAll();
|
||||||
List<SchisandraOssQiniuBO> SchisandraOssQiniuBO_list = new ArrayList<>();
|
return SchisandraOssQiniuBOConverter.INSTANCE.convertEntityToBOList(list);
|
||||||
for (SchisandraOssQiniu schisandraOssQiniu : list) {
|
|
||||||
SchisandraOssQiniuBO schisandraOssQiniuBO = SchisandraOssQiniuBOConverter.INSTANCE.convertEntityToBO(schisandraOssQiniu);
|
|
||||||
SchisandraOssQiniuBO_list.add(schisandraOssQiniuBO);
|
|
||||||
}
|
|
||||||
return SchisandraOssQiniuBO_list;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,8 @@
|
|||||||
package com.schisandra.oss.domain.service.impl;
|
package com.schisandra.oss.domain.service.impl;
|
||||||
|
|
||||||
import com.schisandra.oss.common.enums.IsDeletedFlagEnum;
|
import com.schisandra.oss.common.enums.IsDeletedFlagEnum;
|
||||||
|
import com.schisandra.oss.common.enums.OssName;
|
||||||
|
import com.schisandra.oss.common.enums.OssType;
|
||||||
import com.schisandra.oss.domain.bo.SchisandraOssFtpBO;
|
import com.schisandra.oss.domain.bo.SchisandraOssFtpBO;
|
||||||
import com.schisandra.oss.domain.bo.SchisandraOssUpBO;
|
import com.schisandra.oss.domain.bo.SchisandraOssUpBO;
|
||||||
import com.schisandra.oss.domain.convert.SchisandraOssFtpBOConverter;
|
import com.schisandra.oss.domain.convert.SchisandraOssFtpBOConverter;
|
||||||
@@ -11,12 +13,15 @@ import com.schisandra.oss.domain.service.SchisandraOssSftpDomainService;
|
|||||||
import com.schisandra.oss.infra.basic.entity.SchisandraOssFtp;
|
import com.schisandra.oss.infra.basic.entity.SchisandraOssFtp;
|
||||||
import com.schisandra.oss.infra.basic.entity.SchisandraOssSftp;
|
import com.schisandra.oss.infra.basic.entity.SchisandraOssSftp;
|
||||||
import com.schisandra.oss.infra.basic.entity.SchisandraOssUp;
|
import com.schisandra.oss.infra.basic.entity.SchisandraOssUp;
|
||||||
|
import com.schisandra.oss.infra.basic.entity.SchisandraUserOss;
|
||||||
import com.schisandra.oss.infra.basic.service.SchisandraOssSftpService;
|
import com.schisandra.oss.infra.basic.service.SchisandraOssSftpService;
|
||||||
|
import com.schisandra.oss.infra.basic.service.SchisandraUserOssService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -31,9 +36,24 @@ public class SchisandraOssSftpDomainServiceImpl implements SchisandraOssSftpDoma
|
|||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private SchisandraOssSftpService schisandraOssSftpService;
|
private SchisandraOssSftpService schisandraOssSftpService;
|
||||||
|
@Resource
|
||||||
|
private SchisandraUserOssService schisandraUserOssService;
|
||||||
@Override
|
@Override
|
||||||
public Boolean add(SchisandraOssSftpBO schisandraOssSftpBO) {
|
public Boolean add(SchisandraOssSftpBO schisandraOssSftpBO) {
|
||||||
|
SchisandraUserOss userOss = schisandraUserOssService.queryOSSByTypeAndUserId(schisandraOssSftpBO.getUserId(), String.valueOf(OssType.SFTP));
|
||||||
|
if(userOss == null){
|
||||||
|
SchisandraUserOss schisandraUserOss = new SchisandraUserOss();
|
||||||
|
schisandraUserOss.setUserId(schisandraOssSftpBO.getUserId());
|
||||||
|
schisandraUserOss.setIsDeleted(0);
|
||||||
|
schisandraUserOss.setCreatedTime(new Date());
|
||||||
|
schisandraUserOss.setOssType(String.valueOf(OssType.SFTP));
|
||||||
|
schisandraUserOss.setName(String.valueOf(OssName.SFTP));
|
||||||
|
schisandraUserOss.setConfigcount(1);
|
||||||
|
schisandraUserOssService.insert(schisandraUserOss);
|
||||||
|
}else{
|
||||||
|
userOss.setConfigcount(userOss.getConfigcount()+1);
|
||||||
|
schisandraUserOssService.update(userOss);
|
||||||
|
}
|
||||||
SchisandraOssSftp schisandraOssSftp = SchisandraOssSftpBOConverter.INSTANCE.convertBOToEntity(schisandraOssSftpBO);
|
SchisandraOssSftp schisandraOssSftp = SchisandraOssSftpBOConverter.INSTANCE.convertBOToEntity(schisandraOssSftpBO);
|
||||||
schisandraOssSftp.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());
|
schisandraOssSftp.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());
|
||||||
return schisandraOssSftpService.insert(schisandraOssSftp) > 0;
|
return schisandraOssSftpService.insert(schisandraOssSftp) > 0;
|
||||||
@@ -63,11 +83,6 @@ public class SchisandraOssSftpDomainServiceImpl implements SchisandraOssSftpDoma
|
|||||||
@Override
|
@Override
|
||||||
public List<SchisandraOssSftpBO> selectAll(){
|
public List<SchisandraOssSftpBO> selectAll(){
|
||||||
List<SchisandraOssSftp> list = schisandraOssSftpService.selectAll();
|
List<SchisandraOssSftp> list = schisandraOssSftpService.selectAll();
|
||||||
List<SchisandraOssSftpBO> SchisandraOssSftpBO_list = new ArrayList<>();
|
return SchisandraOssSftpBOConverter.INSTANCE.convertEntityToBOList(list);
|
||||||
for (SchisandraOssSftp schisandraOssSftp : list) {
|
|
||||||
SchisandraOssSftpBO schisandraOssSftpBO = SchisandraOssSftpBOConverter.INSTANCE.convertEntityToBO(schisandraOssSftp);
|
|
||||||
SchisandraOssSftpBO_list.add(schisandraOssSftpBO);
|
|
||||||
}
|
|
||||||
return SchisandraOssSftpBO_list;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,8 @@
|
|||||||
package com.schisandra.oss.domain.service.impl;
|
package com.schisandra.oss.domain.service.impl;
|
||||||
|
|
||||||
import com.schisandra.oss.common.enums.IsDeletedFlagEnum;
|
import com.schisandra.oss.common.enums.IsDeletedFlagEnum;
|
||||||
|
import com.schisandra.oss.common.enums.OssName;
|
||||||
|
import com.schisandra.oss.common.enums.OssType;
|
||||||
import com.schisandra.oss.domain.bo.SchisandraOssQiniuBO;
|
import com.schisandra.oss.domain.bo.SchisandraOssQiniuBO;
|
||||||
import com.schisandra.oss.domain.bo.SchisandraOssUpBO;
|
import com.schisandra.oss.domain.bo.SchisandraOssUpBO;
|
||||||
import com.schisandra.oss.domain.convert.SchisandraOssQiniuBOConverter;
|
import com.schisandra.oss.domain.convert.SchisandraOssQiniuBOConverter;
|
||||||
@@ -11,12 +13,15 @@ import com.schisandra.oss.domain.service.SchisandraOssTencentDomainService;
|
|||||||
import com.schisandra.oss.infra.basic.entity.SchisandraOssQiniu;
|
import com.schisandra.oss.infra.basic.entity.SchisandraOssQiniu;
|
||||||
import com.schisandra.oss.infra.basic.entity.SchisandraOssTencent;
|
import com.schisandra.oss.infra.basic.entity.SchisandraOssTencent;
|
||||||
import com.schisandra.oss.infra.basic.entity.SchisandraOssUp;
|
import com.schisandra.oss.infra.basic.entity.SchisandraOssUp;
|
||||||
|
import com.schisandra.oss.infra.basic.entity.SchisandraUserOss;
|
||||||
import com.schisandra.oss.infra.basic.service.SchisandraOssTencentService;
|
import com.schisandra.oss.infra.basic.service.SchisandraOssTencentService;
|
||||||
|
import com.schisandra.oss.infra.basic.service.SchisandraUserOssService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -31,9 +36,25 @@ public class SchisandraOssTencentDomainServiceImpl implements SchisandraOssTence
|
|||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private SchisandraOssTencentService schisandraOssTencentService;
|
private SchisandraOssTencentService schisandraOssTencentService;
|
||||||
|
@Resource
|
||||||
|
private SchisandraUserOssService schisandraUserOssService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean add(SchisandraOssTencentBO schisandraOssTencentBO) {
|
public Boolean add(SchisandraOssTencentBO schisandraOssTencentBO) {
|
||||||
|
SchisandraUserOss userOss = schisandraUserOssService.queryOSSByTypeAndUserId(schisandraOssTencentBO.getUserId(),String.valueOf(OssType.TENCENT));
|
||||||
|
if(userOss == null){
|
||||||
|
SchisandraUserOss schisandraUserOss = new SchisandraUserOss();
|
||||||
|
schisandraUserOss.setUserId(schisandraOssTencentBO.getUserId());
|
||||||
|
schisandraUserOss.setIsDeleted(0);
|
||||||
|
schisandraUserOss.setCreatedTime(new Date());
|
||||||
|
schisandraUserOss.setOssType(String.valueOf(OssType.TENCENT));
|
||||||
|
schisandraUserOss.setConfigcount(1);
|
||||||
|
schisandraUserOss.setName(String.valueOf(OssName.TENCENT));
|
||||||
|
schisandraUserOssService.insert(schisandraUserOss);
|
||||||
|
}else{
|
||||||
|
userOss.setConfigcount(userOss.getConfigcount()+1);
|
||||||
|
schisandraUserOssService.update(userOss);
|
||||||
|
}
|
||||||
SchisandraOssTencent schisandraOssTencent = SchisandraOssTencentBOConverter.INSTANCE.convertBOToEntity(schisandraOssTencentBO);
|
SchisandraOssTencent schisandraOssTencent = SchisandraOssTencentBOConverter.INSTANCE.convertBOToEntity(schisandraOssTencentBO);
|
||||||
schisandraOssTencent.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());
|
schisandraOssTencent.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());
|
||||||
return schisandraOssTencentService.insert(schisandraOssTencent) > 0;
|
return schisandraOssTencentService.insert(schisandraOssTencent) > 0;
|
||||||
@@ -63,11 +84,6 @@ public class SchisandraOssTencentDomainServiceImpl implements SchisandraOssTence
|
|||||||
@Override
|
@Override
|
||||||
public List<SchisandraOssTencentBO> selectAll(){
|
public List<SchisandraOssTencentBO> selectAll(){
|
||||||
List<SchisandraOssTencent> list = schisandraOssTencentService.selectAll();
|
List<SchisandraOssTencent> list = schisandraOssTencentService.selectAll();
|
||||||
List<SchisandraOssTencentBO> SchisandraOssTencentBO_list = new ArrayList<>();
|
return SchisandraOssTencentBOConverter.INSTANCE.convertEntityToBOList(list);
|
||||||
for (SchisandraOssTencent schisandraOssTencent : list) {
|
|
||||||
SchisandraOssTencentBO schisandraOssUpBO = SchisandraOssTencentBOConverter.INSTANCE.convertEntityToBO(schisandraOssTencent);
|
|
||||||
SchisandraOssTencentBO_list.add(schisandraOssUpBO);
|
|
||||||
}
|
|
||||||
return SchisandraOssTencentBO_list;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -8,12 +8,15 @@ import com.schisandra.oss.domain.bo.SchisandraOssUpBO;
|
|||||||
import com.schisandra.oss.domain.service.SchisandraOssUpDomainService;
|
import com.schisandra.oss.domain.service.SchisandraOssUpDomainService;
|
||||||
import com.schisandra.oss.infra.basic.entity.SchisandraOssMinio;
|
import com.schisandra.oss.infra.basic.entity.SchisandraOssMinio;
|
||||||
import com.schisandra.oss.infra.basic.entity.SchisandraOssUp;
|
import com.schisandra.oss.infra.basic.entity.SchisandraOssUp;
|
||||||
|
import com.schisandra.oss.infra.basic.entity.SchisandraUserOss;
|
||||||
import com.schisandra.oss.infra.basic.service.SchisandraOssUpService;
|
import com.schisandra.oss.infra.basic.service.SchisandraOssUpService;
|
||||||
|
import com.schisandra.oss.infra.basic.service.SchisandraUserOssService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -28,9 +31,24 @@ public class SchisandraOssUpDomainServiceImpl implements SchisandraOssUpDomainSe
|
|||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private SchisandraOssUpService schisandraOssUpService;
|
private SchisandraOssUpService schisandraOssUpService;
|
||||||
|
@Resource
|
||||||
|
private SchisandraUserOssService schisandraUserOssService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean add(SchisandraOssUpBO schisandraOssUpBO) {
|
public Boolean add(SchisandraOssUpBO schisandraOssUpBO) {
|
||||||
|
SchisandraUserOss schisandraUserOss = schisandraUserOssService.queryOSSByTypeAndUserId(schisandraOssUpBO.getUserId(),"up");
|
||||||
|
if(schisandraUserOss == null){
|
||||||
|
SchisandraUserOss x = new SchisandraUserOss();
|
||||||
|
x.setUserId(schisandraOssUpBO.getUserId());
|
||||||
|
x.setIsDeleted(0);
|
||||||
|
x.setCreatedTime(new Date());
|
||||||
|
x.setOssType("up");
|
||||||
|
x.setConfigcount(1);
|
||||||
|
schisandraUserOssService.insert(x);
|
||||||
|
}else{
|
||||||
|
schisandraUserOss.setConfigcount(schisandraUserOss.getConfigcount()+1);
|
||||||
|
schisandraUserOssService.update(schisandraUserOss);
|
||||||
|
}
|
||||||
SchisandraOssUp schisandraOssUp = SchisandraOssUpBOConverter.INSTANCE.convertBOToEntity(schisandraOssUpBO);
|
SchisandraOssUp schisandraOssUp = SchisandraOssUpBOConverter.INSTANCE.convertBOToEntity(schisandraOssUpBO);
|
||||||
schisandraOssUp.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());
|
schisandraOssUp.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());
|
||||||
return schisandraOssUpService.insert(schisandraOssUp) > 0;
|
return schisandraOssUpService.insert(schisandraOssUp) > 0;
|
||||||
@@ -59,12 +77,7 @@ public class SchisandraOssUpDomainServiceImpl implements SchisandraOssUpDomainSe
|
|||||||
@Override
|
@Override
|
||||||
public List<SchisandraOssUpBO> selectAll(){
|
public List<SchisandraOssUpBO> selectAll(){
|
||||||
List<SchisandraOssUp> list = schisandraOssUpService.selectAll();
|
List<SchisandraOssUp> list = schisandraOssUpService.selectAll();
|
||||||
List<SchisandraOssUpBO> SchisandraOssUpBO_list = new ArrayList<>();
|
return SchisandraOssUpBOConverter.INSTANCE.convertEntityToBOList(list);
|
||||||
for (SchisandraOssUp schisandraOssUp : list) {
|
|
||||||
SchisandraOssUpBO schisandraOssUpBO = SchisandraOssUpBOConverter.INSTANCE.convertEntityToBO(schisandraOssUp);
|
|
||||||
SchisandraOssUpBO_list.add(schisandraOssUpBO);
|
|
||||||
}
|
|
||||||
return SchisandraOssUpBO_list;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -54,4 +54,11 @@ public class SchisandraUserOssDomainServiceImpl implements SchisandraUserOssDoma
|
|||||||
return SchisandraUserOssBOList;
|
return SchisandraUserOssBOList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SchisandraUserOssBO queryOSSByTypeAndUserId(Long userId,String type ) {
|
||||||
|
SchisandraUserOssBO schisandraUserOssBO = SchisandraUserOssBOConverter
|
||||||
|
.INSTANCE.convertEntityToBO(schisandraUserOssService.queryOSSByTypeAndUserId(userId, type));
|
||||||
|
return schisandraUserOssBO;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -49,6 +49,9 @@ public class SchisandraUserOss implements Serializable {
|
|||||||
@Column("name")
|
@Column("name")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
@Column("config_count")
|
||||||
|
private Integer configcount;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@@ -3,6 +3,7 @@ package com.schisandra.oss.infra.basic.service;
|
|||||||
import com.schisandra.oss.infra.basic.entity.SchisandraUserOss;
|
import com.schisandra.oss.infra.basic.entity.SchisandraUserOss;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户对象存储映射表 表服务接口
|
* 用户对象存储映射表 表服务接口
|
||||||
@@ -46,5 +47,5 @@ public interface SchisandraUserOssService {
|
|||||||
|
|
||||||
List<SchisandraUserOss> queryOSSByUserId(Long userId);
|
List<SchisandraUserOss> queryOSSByUserId(Long userId);
|
||||||
|
|
||||||
|
SchisandraUserOss queryOSSByTypeAndUserId(Long userId,String Type);
|
||||||
}
|
}
|
||||||
|
@@ -71,5 +71,8 @@ public class SchisandraUserOssServiceImpl implements SchisandraUserOssService {
|
|||||||
return this.schisandraUserOssDao.selectListByCondition(SchisandraUserOssTableDef.SCHISANDRA_USER_OSS.USER_ID.eq(userId));
|
return this.schisandraUserOssDao.selectListByCondition(SchisandraUserOssTableDef.SCHISANDRA_USER_OSS.USER_ID.eq(userId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SchisandraUserOss queryOSSByTypeAndUserId(Long userId,String type) {
|
||||||
|
return this.schisandraUserOssDao.selectOneByCondition(SchisandraUserOssTableDef.SCHISANDRA_USER_OSS.USER_ID.eq(userId).and(SchisandraUserOssTableDef.SCHISANDRA_USER_OSS.OSS_TYPE.eq(type)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user