feat: 近期文件模块设计
This commit is contained in:
@@ -167,7 +167,7 @@ public class SchisandraAuthUserDomainServiceImpl implements SchisandraAuthUserDo
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Long
|
* @param
|
||||||
* @return
|
* @return
|
||||||
* @description 查询用户信息
|
* @description 查询用户信息
|
||||||
* @author msz
|
* @author msz
|
||||||
|
@@ -3,22 +3,22 @@ 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.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.*;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.cache.annotation.CacheEvict;
|
||||||
|
import org.springframework.cache.annotation.Cacheable;
|
||||||
|
import org.springframework.cache.annotation.Caching;
|
||||||
|
import org.springframework.util.StreamUtils;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
@@ -34,6 +34,7 @@ import java.text.SimpleDateFormat;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* controller
|
* controller
|
||||||
@@ -80,39 +81,46 @@ public class SchisandraOssMinioController {
|
|||||||
* @date: 2024/5/15 13:34
|
* @date: 2024/5/15 13:34
|
||||||
*/
|
*/
|
||||||
@PostMapping("init")
|
@PostMapping("init")
|
||||||
public Result initMinio(@RequestParam String userId,@RequestParam String Id) {
|
public Result<Object> 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不能为空!");
|
||||||
|
List<SchisandraOssMinioBO> list= schisandraOssMinioDomainService.getAllMinioInfoByUserId(Long.valueOf(userId));
|
||||||
|
if (list.size() != 0) {
|
||||||
|
return Result.fail(list);
|
||||||
|
}
|
||||||
|
|
||||||
SchisandraOssMinioBO bo = new SchisandraOssMinioBO();
|
SchisandraOssMinioBO bo = new SchisandraOssMinioBO();
|
||||||
bo.setId(Long.valueOf(Id));
|
bo.setId(Long.valueOf(Id));
|
||||||
bo.setUserId(Long.valueOf(userId));
|
bo.setUserId(Long.valueOf(userId));
|
||||||
bo.setStatus(String.valueOf(true));
|
bo.setStatus(String.valueOf(true));
|
||||||
if(schisandraOssMinioDomainService.update(bo)){
|
if (schisandraOssMinioDomainService.update(bo)) {
|
||||||
return minioOssConfiguration.minioOssClient(userId);
|
return minioOssConfiguration.minioOssClient(userId);
|
||||||
}else{
|
} else {
|
||||||
return Result.fail("初始化失败");
|
return Result.fail();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("shutdown")
|
@PostMapping("shutdown")
|
||||||
public Result shutdownMinio(@RequestParam String userId,@RequestParam String Id){
|
public Result<Object> shutdownMinio(@RequestParam String userId, @RequestParam String Id) {
|
||||||
if (log.isInfoEnabled()) {
|
if (log.isInfoEnabled()) {
|
||||||
log.info("SchisandraOssMinioController.shutdown.userId:{}", JSON.toJSONString(userId));
|
log.info("SchisandraOssMinioController.shutdown.userId:{}", userId);
|
||||||
}
|
}
|
||||||
SchisandraOssMinioBO bo = new SchisandraOssMinioBO();
|
SchisandraOssMinioBO bo = new SchisandraOssMinioBO();
|
||||||
bo.setId(Long.valueOf(Id));
|
bo.setId(Long.valueOf(Id));
|
||||||
bo.setUserId(Long.valueOf(userId));
|
bo.setUserId(Long.valueOf(userId));
|
||||||
bo.setStatus(String.valueOf(false));
|
bo.setStatus(String.valueOf(false));
|
||||||
if(schisandraOssMinioDomainService.update(bo)){
|
if (schisandraOssMinioDomainService.update(bo)) {
|
||||||
SpringUtil.unregisterBean(OssConstant.OssType.MINIO + userId);
|
SpringUtil.unregisterBean(OssConstant.OssType.MINIO+userId);
|
||||||
return Result.ok("关闭成功");
|
return Result.ok();
|
||||||
}else{
|
} else {
|
||||||
return Result.fail("关闭失败");
|
return Result.fail();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description: 获取文件目录信息
|
* @description: 获取文件目录信息
|
||||||
* @param: [target, userId, dirName]
|
* @param: [target, userId, dirName]
|
||||||
@@ -120,10 +128,11 @@ public class SchisandraOssMinioController {
|
|||||||
* @author zlg
|
* @author zlg
|
||||||
* @date: 2024/6/26 13:55
|
* @date: 2024/6/26 13:55
|
||||||
*/
|
*/
|
||||||
|
@Cacheable(value = "MinioListDir", key = "#userId+#bucket+#dirName")
|
||||||
@GetMapping("listDir")
|
@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(OssConstant.OssType.MINIO + 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));
|
||||||
}
|
}
|
||||||
@@ -140,9 +149,10 @@ public class SchisandraOssMinioController {
|
|||||||
Preconditions.checkNotNull(bucket, "不能为空");
|
Preconditions.checkNotNull(bucket, "不能为空");
|
||||||
Preconditions.checkNotNull(userId, "不能为空");
|
Preconditions.checkNotNull(userId, "不能为空");
|
||||||
Preconditions.checkNotNull(listObjectsArgs, "不能为空");
|
Preconditions.checkNotNull(listObjectsArgs, "不能为空");
|
||||||
MinioOssClient bean = SpringUtil.getBean(OssConstant.OssType.MINIO + 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();
|
||||||
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("下载.zip", "UTF-8"));
|
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("下载.zip", "UTF-8"));
|
||||||
response.setContentType("application/octet-stream");
|
response.setContentType("application/octet-stream");
|
||||||
@@ -151,6 +161,24 @@ public class SchisandraOssMinioController {
|
|||||||
InputStream[] inputStreams = new InputStream[list.size()];
|
InputStream[] inputStreams = new InputStream[list.size()];
|
||||||
path = list.keySet().toArray(path);
|
path = list.keySet().toArray(path);
|
||||||
inputStreams = list.values().toArray(inputStreams);
|
inputStreams = list.values().toArray(inputStreams);
|
||||||
|
|
||||||
|
//记录用户下载
|
||||||
|
Date date = new Date();
|
||||||
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
String formattedDate = dateFormat.format(date);
|
||||||
|
list.keySet().forEach( name -> {
|
||||||
|
try {
|
||||||
|
byte[] bytes = StreamUtils.copyToByteArray(list.get(name));
|
||||||
|
String key = redisUtil.buildKey(USER_OSS_PREFIX, "download", formattedDate, userId, name);
|
||||||
|
HashMap<Object, Object> map = new HashMap<>();
|
||||||
|
map.put("size", bytes.length);
|
||||||
|
map.put("time",formattedDate);
|
||||||
|
redisUtil.setNx(key, map, 30L, TimeUnit.DAYS);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
ZipUtil.zip(output, path, inputStreams);
|
ZipUtil.zip(output, path, inputStreams);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -161,12 +189,13 @@ public class SchisandraOssMinioController {
|
|||||||
* @author zlg
|
* @author zlg
|
||||||
* @date: 2024/6/26 14:34
|
* @date: 2024/6/26 14:34
|
||||||
*/
|
*/
|
||||||
|
@CacheEvict(value = "MinioListDir", key = "#userId+#bucket+#dirName")
|
||||||
@PostMapping("deleteFile")
|
@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(OssConstant.OssType.MINIO + 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();
|
||||||
@@ -179,30 +208,31 @@ public class SchisandraOssMinioController {
|
|||||||
* @author zlg
|
* @author zlg
|
||||||
* @date: 2024/6/26 14:34
|
* @date: 2024/6/26 14:34
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@PostMapping("uploadFile")
|
@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, "不能为空");
|
||||||
Preconditions.checkNotNull(bucket, "不能为空");
|
Preconditions.checkNotNull(bucket, "不能为空");
|
||||||
|
// 获取文件输入流
|
||||||
|
InputStream is = file.getInputStream();
|
||||||
|
MinioOssClient bean = SpringUtil.getBean(OssConstant.OssType.MINIO+userId);
|
||||||
|
bean.getMinioOssConfig().setBucketName(bucket);
|
||||||
//设置热力图
|
//设置热力图
|
||||||
Date date = new Date();
|
Date date = new Date();
|
||||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
String formattedDate = dateFormat.format(date);
|
String formattedDate = dateFormat.format(date);
|
||||||
String key = redisUtil.buildKey(USER_OSS_PREFIX + ":" + userId, formattedDate);
|
String key = redisUtil.buildKey(USER_OSS_PREFIX, "upload", formattedDate, userId, fileName);
|
||||||
int count = 1;
|
HashMap<Object, Object> map = new HashMap<>();
|
||||||
if (redisUtil.exist(key)) {
|
map.put("descreption", "这是一个文件");
|
||||||
count = Integer.parseInt(redisUtil.get(key));
|
map.put("size", String.valueOf(file.getSize()));
|
||||||
redisUtil.set(key, String.valueOf(count + 1));
|
map.put("time",formattedDate);
|
||||||
|
if (bean.upLoad(is, fileName, true) != null) {
|
||||||
|
redisUtil.setNx(key, map, 30L, TimeUnit.DAYS);
|
||||||
|
return Result.ok();
|
||||||
} else {
|
} else {
|
||||||
redisUtil.set(key, String.valueOf(1));
|
return Result.fail();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取文件输入流
|
|
||||||
InputStream is = file.getInputStream();
|
|
||||||
MinioOssClient bean = SpringUtil.getBean(OssConstant.OssType.MINIO + userId);
|
|
||||||
bean.getMinioOssConfig().setBucketName(bucket);
|
|
||||||
return Result.ok(bean.upLoad(is, fileName, true));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -213,6 +243,7 @@ public class SchisandraOssMinioController {
|
|||||||
* @author zlg
|
* @author zlg
|
||||||
* @date: 2024/6/27 9:41
|
* @date: 2024/6/27 9:41
|
||||||
*/
|
*/
|
||||||
|
@Caching(cacheable = @Cacheable(value = "MinioListDir", key = "#userId+#bucket+#newFileName"), evict = @CacheEvict(value = "MinioListDir", key = "#userId+#bucket+#oldFileName"))
|
||||||
@PostMapping("renameFile")
|
@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 {
|
||||||
|
|
||||||
@@ -220,7 +251,7 @@ public class SchisandraOssMinioController {
|
|||||||
Preconditions.checkNotNull(bucket, "不能为空");
|
Preconditions.checkNotNull(bucket, "不能为空");
|
||||||
Preconditions.checkNotNull(oldFileName, "不能为空");
|
Preconditions.checkNotNull(oldFileName, "不能为空");
|
||||||
Preconditions.checkNotNull(newFileName, "不能为空");
|
Preconditions.checkNotNull(newFileName, "不能为空");
|
||||||
MinioOssClient bean = SpringUtil.getBean(OssConstant.OssType.MINIO + 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);
|
||||||
@@ -237,6 +268,7 @@ public class SchisandraOssMinioController {
|
|||||||
* @author zlg
|
* @author zlg
|
||||||
* @date: 2024/6/27 9:52
|
* @date: 2024/6/27 9:52
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@PostMapping("copyFile")
|
@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 {
|
||||||
|
|
||||||
@@ -244,7 +276,7 @@ public class SchisandraOssMinioController {
|
|||||||
Preconditions.checkNotNull(bucket, "不能为空");
|
Preconditions.checkNotNull(bucket, "不能为空");
|
||||||
Preconditions.checkNotNull(oldFilePath, "不能为空");
|
Preconditions.checkNotNull(oldFilePath, "不能为空");
|
||||||
Preconditions.checkNotNull(newFilePath, "不能为空");
|
Preconditions.checkNotNull(newFilePath, "不能为空");
|
||||||
MinioOssClient bean = SpringUtil.getBean(OssConstant.OssType.MINIO + 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);
|
||||||
@@ -266,10 +298,19 @@ public class SchisandraOssMinioController {
|
|||||||
Preconditions.checkNotNull(userId, "不能为空");
|
Preconditions.checkNotNull(userId, "不能为空");
|
||||||
Preconditions.checkNotNull(bucket, "不能为空");
|
Preconditions.checkNotNull(bucket, "不能为空");
|
||||||
Preconditions.checkNotNull(filePath, "不能为空");
|
Preconditions.checkNotNull(filePath, "不能为空");
|
||||||
MinioOssClient bean = SpringUtil.getBean(OssConstant.OssType.MINIO + 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));
|
Date date = new Date();
|
||||||
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
String formattedDate = dateFormat.format(date);
|
||||||
|
String key = redisUtil.buildKey(USER_OSS_PREFIX, "previewFile", formattedDate, userId, filePath);
|
||||||
|
HashMap<Object, Object> map = new HashMap<>();
|
||||||
|
String url=bean.getMinioPreviewUrl(filePath);
|
||||||
|
map.put("url", url);
|
||||||
|
map.put("time", formattedDate);
|
||||||
|
redisUtil.setNx(key, map, 30L, TimeUnit.DAYS);
|
||||||
|
return Result.ok(url);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return Result.fail(e.getMessage());
|
return Result.fail(e.getMessage());
|
||||||
}
|
}
|
||||||
@@ -288,7 +329,7 @@ public class SchisandraOssMinioController {
|
|||||||
Preconditions.checkNotNull(userId, "不能为空");
|
Preconditions.checkNotNull(userId, "不能为空");
|
||||||
Preconditions.checkNotNull(bucket, "不能为空");
|
Preconditions.checkNotNull(bucket, "不能为空");
|
||||||
Preconditions.checkNotNull(filePath, "不能为空");
|
Preconditions.checkNotNull(filePath, "不能为空");
|
||||||
MinioOssClient bean = SpringUtil.getBean(OssConstant.OssType.MINIO + 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));
|
||||||
@@ -307,7 +348,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(OssConstant.OssType.MINIO + userId);
|
MinioOssClient bean = SpringUtil.getBean(OssConstant.OssType.MINIO+userId);
|
||||||
return Result.ok(bean.selectAllBucket());
|
return Result.ok(bean.selectAllBucket());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -322,7 +363,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(OssConstant.OssType.MINIO + 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));
|
||||||
}
|
}
|
||||||
@@ -338,7 +379,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(OssConstant.OssType.MINIO + 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));
|
||||||
}
|
}
|
||||||
@@ -412,7 +453,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(OssConstant.OssType.MINIO + userId);
|
MinioOssClient bean = SpringUtil.getBean(OssConstant.OssType.MINIO+userId);
|
||||||
if (bean == null) {
|
if (bean == null) {
|
||||||
log.error("容器获取失败!");
|
log.error("容器获取失败!");
|
||||||
return null;
|
return null;
|
||||||
|
@@ -7,13 +7,13 @@ import com.schisandra.oss.application.dto.SchisandraUserOssDTO;
|
|||||||
import com.schisandra.oss.common.entity.Result;
|
import com.schisandra.oss.common.entity.Result;
|
||||||
import com.schisandra.oss.domain.bo.SchisandraUserOssBO;
|
import com.schisandra.oss.domain.bo.SchisandraUserOssBO;
|
||||||
import com.schisandra.oss.domain.redis.RedisUtil;
|
import com.schisandra.oss.domain.redis.RedisUtil;
|
||||||
|
import com.schisandra.oss.domain.service.SchisandraFileHeatmapDomainService;
|
||||||
import com.schisandra.oss.domain.service.SchisandraUserOssDomainService;
|
import com.schisandra.oss.domain.service.SchisandraUserOssDomainService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.text.SimpleDateFormat;
|
import java.util.HashMap;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -27,12 +27,20 @@ import java.util.List;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
public class SchisandraUserOssController {
|
public class SchisandraUserOssController {
|
||||||
|
|
||||||
@Resource
|
|
||||||
private SchisandraUserOssDomainService schisandraUserOssDomainService;
|
|
||||||
private final String USER_OSS_PREFIX = "oss:user:heat";
|
private final String USER_OSS_PREFIX = "oss:user:heat";
|
||||||
@Resource
|
@Resource
|
||||||
RedisUtil redisUtil;
|
RedisUtil redisUtil;
|
||||||
|
@Resource
|
||||||
|
private SchisandraUserOssDomainService schisandraUserOssDomainService;
|
||||||
|
/**
|
||||||
|
* @description: 查询用户文件热度
|
||||||
|
* @param: [userId]
|
||||||
|
* @return: com.schisandra.oss.common.entity.Result<java.lang.Object>
|
||||||
|
* @author zlg
|
||||||
|
* @date: 2024/7/11 14:41
|
||||||
|
*/
|
||||||
|
@Resource
|
||||||
|
private SchisandraFileHeatmapDomainService schisandraFileHeatmapDomainService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增用户对象存储映射表
|
* 新增用户对象存储映射表
|
||||||
@@ -123,6 +131,7 @@ public class SchisandraUserOssController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description: 查询用户对象存储映射表
|
* @description: 查询用户对象存储映射表
|
||||||
* @param: [userId]
|
* @param: [userId]
|
||||||
@@ -131,26 +140,125 @@ public class SchisandraUserOssController {
|
|||||||
* @date: 2024/7/11 14:41
|
* @date: 2024/7/11 14:41
|
||||||
*/
|
*/
|
||||||
@GetMapping("selectUserOSSType")
|
@GetMapping("selectUserOSSType")
|
||||||
public Result<Object> selectUserOSSType(Long userId){
|
public Result<Object> selectUserOSSType(Long userId) {
|
||||||
Preconditions.checkNotNull(userId, "不能为空");
|
Preconditions.checkNotNull(userId, "不能为空");
|
||||||
List<SchisandraUserOssDTO> SchisandraUserOssDTOList=SchisandraUserOssDTOConverter.INSTANCE.convertBOListToDTOList(schisandraUserOssDomainService.queryOSSByUserId(userId));
|
List<SchisandraUserOssDTO> SchisandraUserOssDTOList = SchisandraUserOssDTOConverter.INSTANCE.convertBOListToDTOList(schisandraUserOssDomainService.queryOSSByUserId(userId));
|
||||||
if (SchisandraUserOssDTOList.isEmpty()) {
|
if (SchisandraUserOssDTOList.isEmpty()) {
|
||||||
return Result.fail("没有查询到用户对象存储映射表信息");
|
return Result.fail("没有查询到用户对象存储映射表信息");
|
||||||
}else {
|
} else {
|
||||||
return Result.ok(SchisandraUserOssDTOList);
|
return Result.ok(SchisandraUserOssDTOList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description: 查询用户文件热度
|
* @description: 查询用户文件热度
|
||||||
* @param: [userId]
|
* @param: [userId]
|
||||||
* @return: com.schisandra.oss.common.entity.Result<java.lang.Object>
|
* @return: com.schisandra.oss.common.entity.Result<java.lang.Object>
|
||||||
* @author zlg
|
* @author zlg
|
||||||
* @date: 2024/7/11 14:41
|
* @date: 2024/7/13 11:09
|
||||||
*/
|
*/
|
||||||
@GetMapping("selectUserFileHeat")
|
@GetMapping("selectUserFileHeat")
|
||||||
public Result<Object> selectUserFileHeat(@RequestParam Long userId){
|
public Result<Object> selectUserFileHeat(@RequestParam Long userId) {
|
||||||
Preconditions.checkNotNull(userId, "不能为空");
|
Preconditions.checkNotNull(userId, "userId不能为空");
|
||||||
String key = redisUtil.buildKey(USER_OSS_PREFIX+":"+userId);
|
HashMap<Object, Object> map = new HashMap<>();
|
||||||
return Result.ok(redisUtil.getDataFromDirectory(key));
|
map.put("download", schisandraFileHeatmapDomainService.selectUserDownloadFileHeatMap(String.valueOf(userId)));
|
||||||
|
map.put("upload", schisandraFileHeatmapDomainService.selectUserUploadFileHeatMap(String.valueOf(userId)));
|
||||||
|
return Result.ok(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description: 查询用户上传和下载流量
|
||||||
|
* @param: [userId]
|
||||||
|
* @return: com.schisandra.oss.common.entity.Result<java.lang.Object>
|
||||||
|
* @author zlg
|
||||||
|
* @date: 2024/7/13 11:09
|
||||||
|
*/
|
||||||
|
@GetMapping("selectFileFlow")
|
||||||
|
public Result<Object> selectFileFlow(@RequestParam Long userId) {
|
||||||
|
Preconditions.checkNotNull(userId, "userId不能为空");
|
||||||
|
return Result.ok(schisandraFileHeatmapDomainService.selectUserUploadAndDownloadflow(String.valueOf(userId)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description: 查询用户上传和下载次数
|
||||||
|
* @param: [userId]
|
||||||
|
* @return: com.schisandra.oss.common.entity.Result<java.lang.Object>
|
||||||
|
* @author zlg
|
||||||
|
* @date: 2024/7/13 11:09
|
||||||
|
*/
|
||||||
|
@GetMapping("selectFileCount")
|
||||||
|
public Result<Object> selectFileCount(@RequestParam Long userId) {
|
||||||
|
Preconditions.checkNotNull(userId, "userId不能为空");
|
||||||
|
return Result.ok(schisandraFileHeatmapDomainService.selectUserUploadAndDownloadCount(String.valueOf(userId)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description: 查询用户最近上传文件
|
||||||
|
* @param: [userId]
|
||||||
|
* @return: com.schisandra.oss.common.entity.Result<java.lang.Object>
|
||||||
|
* @author zlg
|
||||||
|
* @date: 2024/7/13 11:10
|
||||||
|
*/
|
||||||
|
@GetMapping("selectRecentUploadFile")
|
||||||
|
public Result<Object> selectRecentUploadFile(@RequestParam Long userId) {
|
||||||
|
Preconditions.checkNotNull(userId, "userId不能为空");
|
||||||
|
return Result.ok(schisandraFileHeatmapDomainService.selectRecentUploadFile(String.valueOf(userId)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description: 查询用户最近下载文件
|
||||||
|
* @param: [userId]
|
||||||
|
* @return: com.schisandra.oss.common.entity.Result<java.lang.Object>
|
||||||
|
* @author zlg
|
||||||
|
* @date: 2024/7/13 11:10
|
||||||
|
*/
|
||||||
|
@GetMapping("selectRecentDownloadFile")
|
||||||
|
public Result<Object> selectRecentDownloadFile(@RequestParam Long userId) {
|
||||||
|
Preconditions.checkNotNull(userId, "userId不能为空");
|
||||||
|
return Result.ok(schisandraFileHeatmapDomainService.selectRecentDownloadFile(String.valueOf(userId)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description: 查询用户上传文件每月
|
||||||
|
* @param: [userId]
|
||||||
|
* @return: com.schisandra.oss.common.entity.Result<java.lang.Object>
|
||||||
|
* @author zlg
|
||||||
|
* @date: 2024/7/15 11:05
|
||||||
|
*/
|
||||||
|
@GetMapping("selectUploadFileDiagramPerMonth")
|
||||||
|
public Result<Object> selectFileDiagramPerMonth(@RequestParam Long userId) {
|
||||||
|
Preconditions.checkNotNull(userId, "userId不能为空");
|
||||||
|
return Result.ok(schisandraFileHeatmapDomainService.selectFileDiagramPerMonth(String.valueOf(userId),0)
|
||||||
|
.get("month"));
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @description: 查询用户下载文件每月
|
||||||
|
* @param: [userId]
|
||||||
|
* @return: com.schisandra.oss.common.entity.Result<java.lang.Object>
|
||||||
|
* @author zlg
|
||||||
|
* @date: 2024/7/15 11:26
|
||||||
|
*/
|
||||||
|
@GetMapping("selectDownloadFileDiagramPerMonth")
|
||||||
|
public Result<Object> selectDownloadFileDiagramPerMonth(@RequestParam Long userId) {
|
||||||
|
Preconditions.checkNotNull(userId, "userId不能为空");
|
||||||
|
return Result.ok(schisandraFileHeatmapDomainService.selectFileDiagramPerMonth(String.valueOf(userId),1)
|
||||||
|
.get("month"));
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @description: 查询用户最近预览文件
|
||||||
|
* @param: [userId]
|
||||||
|
* @return: com.schisandra.oss.common.entity.Result<java.lang.Object>
|
||||||
|
* @author zlg
|
||||||
|
* @date: 2024/7/15 11:19
|
||||||
|
*/
|
||||||
|
@GetMapping("selectPreviewFile")
|
||||||
|
public Result<Object> selectShareFileDiagramPerMonth(@RequestParam Long userId) {
|
||||||
|
Preconditions.checkNotNull(userId, "userId不能为空");
|
||||||
|
return Result.ok(schisandraFileHeatmapDomainService.selectRecentPreviewFile(String.valueOf(userId)));
|
||||||
|
}
|
||||||
|
@GetMapping("TEST")
|
||||||
|
public Result<Object> TEST() {
|
||||||
|
return Result.ok(schisandraFileHeatmapDomainService.downloadHeatMapRedisToMysql());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -27,7 +27,7 @@ public class SchisandraFileHeatmapDTO implements Serializable {
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private Date date;
|
private String date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@@ -70,6 +70,7 @@ public class MinioOssClient implements StandardOssClient {
|
|||||||
private MinioOssConfig minioOssConfig;
|
private MinioOssConfig minioOssConfig;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public MinioOssConfig getMinioOssConfig() {
|
public MinioOssConfig getMinioOssConfig() {
|
||||||
return minioOssConfig;
|
return minioOssConfig;
|
||||||
}
|
}
|
||||||
@@ -150,16 +151,20 @@ public class MinioOssClient implements StandardOssClient {
|
|||||||
return "success";
|
return "success";
|
||||||
}
|
}
|
||||||
|
|
||||||
public HashMap<String, String> selectAllBucket() throws ServerException, InsufficientDataException, ErrorResponseException, IOException, NoSuchAlgorithmException, InvalidKeyException, InvalidResponseException, XmlParserException, InternalException {
|
public List<HashMap<String,String>> selectAllBucket() throws ServerException, InsufficientDataException, ErrorResponseException, IOException, NoSuchAlgorithmException, InvalidKeyException, InvalidResponseException, XmlParserException, InternalException {
|
||||||
List<Bucket> list = minioClient.listBuckets();
|
List<Bucket> list = minioClient.listBuckets();
|
||||||
HashMap<String, String> names = new HashMap<>();
|
List<HashMap<String,String>> list1=new ArrayList<>();
|
||||||
list.forEach(bucket -> {
|
list.forEach(bucket -> {
|
||||||
names.put(bucket.name(), getMinioBucketSize(bucket.name()));
|
HashMap<String, String> names = new HashMap<>();
|
||||||
|
names.put("name", bucket.name());
|
||||||
|
names.put("size",getMinioBucketSize(bucket.name()));
|
||||||
|
list1.add(names);
|
||||||
});
|
});
|
||||||
return names;
|
return list1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HashMap<String,InputStream> getTargetDir(List<String> listObjectsArgs) throws Exception {
|
public HashMap<String,InputStream> getTargetDir(List<String> listObjectsArgs) throws Exception {
|
||||||
|
|
||||||
HashMap<String,InputStream> list = new HashMap<>();
|
HashMap<String,InputStream> list = new HashMap<>();
|
||||||
List<WorkerWrapper> wrappers=new ArrayList<>();
|
List<WorkerWrapper> wrappers=new ArrayList<>();
|
||||||
listObjectsArgs.forEach(args -> {
|
listObjectsArgs.forEach(args -> {
|
||||||
@@ -175,7 +180,6 @@ public class MinioOssClient implements StandardOssClient {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}).param(r.get().objectName()).id(r.get().versionId()).callback((boolean success, String param,WorkResult<InputStream> re)->{
|
}).param(r.get().objectName()).id(r.get().versionId()).callback((boolean success, String param,WorkResult<InputStream> re)->{
|
||||||
System.out.println("success:"+success+" param:");
|
|
||||||
}).build();
|
}).build();
|
||||||
wrappers.add(wrapper1);
|
wrappers.add(wrapper1);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@@ -2,12 +2,16 @@ package com.schisandra.oss.application.oss.core.minio;
|
|||||||
|
|
||||||
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 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.SchisandraOssMinioDTO;
|
import com.schisandra.oss.application.dto.SchisandraOssMinioDTO;
|
||||||
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.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;
|
||||||
|
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.service.SchisandraOssMinioDomainService;
|
import com.schisandra.oss.domain.service.SchisandraOssMinioDomainService;
|
||||||
import io.minio.MinioClient;
|
import io.minio.MinioClient;
|
||||||
@@ -16,6 +20,8 @@ import okhttp3.OkHttpClient;
|
|||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@@ -28,33 +34,67 @@ import java.util.concurrent.TimeUnit;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
public class MinioOssConfiguration {
|
public class MinioOssConfiguration {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
MinioOssConfiguration 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 {
|
||||||
|
SchisandraOssMinioDTO minio = minioOssConfiguration.getSchisandraOssMinioDTO(userId);
|
||||||
|
if (minio == null) return null;
|
||||||
|
MinioOssConfig minioOssConfig = new MinioOssConfig();
|
||||||
|
minioOssConfig.setBasePath(minio.getBasePath());
|
||||||
|
minioOssConfig.setBucketName(minio.getBucketName());
|
||||||
|
minioOssConfig.setAccessKey(minio.getAccessKey());
|
||||||
|
minioOssConfig.setSecretKey(minio.getSecretKey());
|
||||||
|
minioOssConfig.setEndpoint(minio.getEndpoint());
|
||||||
|
minioOssConfig.init();
|
||||||
|
if (Boolean.parseBoolean(minio.getOpenAdvancedSetup())) {
|
||||||
|
MinioOssClientConfig minioOssClientConfig = new MinioOssClientConfig();
|
||||||
|
minioOssClientConfig.setWriteTimeout(minio.getWriteTimeout());
|
||||||
|
minioOssClientConfig.setConnectTimeout(minio.getConnectTimeout());
|
||||||
|
minioOssClientConfig.setReadTimeout(minio.getReadTimeout());
|
||||||
|
minioOssClientConfig.setFollowSslRedirects(Boolean.parseBoolean(minio.getFollowSslRedirects()));
|
||||||
|
minioOssClientConfig.setRetryOnConnectionFailure(Boolean.parseBoolean(minio.getRetryOnConnectionFailure()));
|
||||||
|
minioOssClientConfig.setPingInterval(minio.getPingInterval());
|
||||||
|
minioOssClientConfig.setFollowRedirects(Boolean.parseBoolean(minio.getFollowRedirects()));
|
||||||
|
minioOssClientConfig.setCallTimeout(minio.getCallTimeout());
|
||||||
|
minioOssConfig.setClientConfig(minioOssClientConfig);
|
||||||
|
}
|
||||||
|
SpringUtil.registerBean(OssConstant.OssType.MINIO+userId,minioOssClient(minioOssConfig));
|
||||||
|
// this.minioOssClient1= minioOssClient(minioOssConfig);
|
||||||
|
return Result.ok();
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("MinioOssConfiguration.minioOssClient:{}", e.getMessage(), e);
|
||||||
|
return Result.fail();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public SchisandraOssMinioDTO getSchisandraOssMinioDTO(String userId) {
|
||||||
CompletableFuture<SchisandraOssMinioDTO> futurePrice = CompletableFuture.supplyAsync(() -> {
|
CompletableFuture<SchisandraOssMinioDTO> futurePrice = CompletableFuture.supplyAsync(() -> {
|
||||||
SchisandraOssMinioBO schisandraOssMinioBO = schisandraOssMinioDomainService.getMinioConfig(Long.valueOf(userId));
|
SchisandraOssMinioBO minioBO = schisandraOssMinioDomainService.getMinioConfig(Long.valueOf(userId));
|
||||||
SchisandraOssMinioDTO schisandraOssMinioDTO = SchisandraOssMinioDTOConverter.INSTANCE.convertBOToDTO(schisandraOssMinioBO);
|
SchisandraOssMinioDTO minioDTO = SchisandraOssMinioDTOConverter.INSTANCE.convertBOToDTO(minioBO);
|
||||||
return schisandraOssMinioDTO;
|
return minioDTO;
|
||||||
});
|
});
|
||||||
SchisandraOssMinioDTO minio = futurePrice.join();
|
SchisandraOssMinioDTO minio = futurePrice.join();
|
||||||
if (ObjectUtil.isEmpty(minio)) {
|
if (ObjectUtil.isEmpty(minio)) {
|
||||||
log.error("minio oss配置信息获取失败");
|
log.error("minio配置信息获取失败");
|
||||||
return Result.fail();
|
return null;
|
||||||
}
|
|
||||||
MinioOssConfig minioOssConfig = new MinioOssConfig();
|
|
||||||
minioOssConfig.setEndpoint(minio.getEndpoint());
|
|
||||||
minioOssConfig.setAccessKey(minio.getAccessKey());
|
|
||||||
minioOssConfig.setSecretKey(minio.getSecretKey());
|
|
||||||
minioOssConfig.setBasePath(minio.getBasePath());
|
|
||||||
try {
|
|
||||||
SpringUtil.registerBean(OssConstant.OssType.MINIO + userId, minioOssClient(minioOssConfig));
|
|
||||||
return Result.ok();
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
return Result.fail();
|
|
||||||
}
|
}
|
||||||
|
return minio;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MinioOssClient minioOssClient(MinioOssConfig minioOssConfig) {
|
public MinioOssClient minioOssClient(MinioOssConfig minioOssConfig) {
|
||||||
|
@@ -20,6 +20,15 @@
|
|||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.xuxueli</groupId>
|
||||||
|
<artifactId>xxl-job-core</artifactId>
|
||||||
|
<version>2.4.0</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.schisandra</groupId>
|
||||||
|
<artifactId>schisandra-cloud-storage-oss-domain</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
@@ -0,0 +1,78 @@
|
|||||||
|
package com.schisandra.oss.job.config;
|
||||||
|
|
||||||
|
import com.xxl.job.core.executor.impl.XxlJobSpringExecutor;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xxl-job config
|
||||||
|
*
|
||||||
|
* @author xuxueli 2017-04-28
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
public class XxlJobConfig {
|
||||||
|
private Logger logger = LoggerFactory.getLogger(XxlJobConfig.class);
|
||||||
|
|
||||||
|
@Value("${xxl.job.admin.addresses}")
|
||||||
|
private String adminAddresses;
|
||||||
|
|
||||||
|
@Value("${xxl.job.accessToken}")
|
||||||
|
private String accessToken;
|
||||||
|
|
||||||
|
@Value("${xxl.job.executor.appname}")
|
||||||
|
private String appname;
|
||||||
|
|
||||||
|
@Value("${xxl.job.executor.address}")
|
||||||
|
private String address;
|
||||||
|
|
||||||
|
@Value("${xxl.job.executor.ip}")
|
||||||
|
private String ip;
|
||||||
|
|
||||||
|
@Value("${xxl.job.executor.port}")
|
||||||
|
private int port;
|
||||||
|
|
||||||
|
@Value("${xxl.job.executor.logpath}")
|
||||||
|
private String logPath;
|
||||||
|
|
||||||
|
@Value("${xxl.job.executor.logretentiondays}")
|
||||||
|
private int logRetentionDays;
|
||||||
|
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public XxlJobSpringExecutor xxlJobExecutor() {
|
||||||
|
logger.info(">>>>>>>>>>> xxl-job config init.");
|
||||||
|
XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
|
||||||
|
xxlJobSpringExecutor.setAdminAddresses(adminAddresses);
|
||||||
|
xxlJobSpringExecutor.setAppname(appname);
|
||||||
|
xxlJobSpringExecutor.setAddress(address);
|
||||||
|
xxlJobSpringExecutor.setIp(ip);
|
||||||
|
xxlJobSpringExecutor.setPort(port);
|
||||||
|
xxlJobSpringExecutor.setAccessToken(accessToken);
|
||||||
|
xxlJobSpringExecutor.setLogPath(logPath);
|
||||||
|
xxlJobSpringExecutor.setLogRetentionDays(logRetentionDays);
|
||||||
|
|
||||||
|
return xxlJobSpringExecutor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 针对多网卡、容器内部署等情况,可借助 "spring-cloud-commons" 提供的 "InetUtils" 组件灵活定制注册IP;
|
||||||
|
*
|
||||||
|
* 1、引入依赖:
|
||||||
|
* <dependency>
|
||||||
|
* <groupId>org.springframework.cloud</groupId>
|
||||||
|
* <artifactId>spring-cloud-commons</artifactId>
|
||||||
|
* <version>${version}</version>
|
||||||
|
* </dependency>
|
||||||
|
*
|
||||||
|
* 2、配置文件,或者容器启动变量
|
||||||
|
* spring.cloud.inetutils.preferred-networks: 'xxx.xxx.xxx.'
|
||||||
|
*
|
||||||
|
* 3、获取IP
|
||||||
|
* String ip_ = inetUtils.findFirstNonLoopbackHostInfo().getIpAddress();
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,35 @@
|
|||||||
|
package com.schisandra.oss.job.job;
|
||||||
|
|
||||||
|
import com.schisandra.oss.domain.bo.SchisandraFileHeatmapBO;
|
||||||
|
import com.schisandra.oss.domain.service.SchisandraFileHeatmapDomainService;
|
||||||
|
import com.xxl.job.core.context.XxlJobHelper;
|
||||||
|
import com.xxl.job.core.handler.annotation.XxlJob;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Slf4j
|
||||||
|
public class OssHeatMapRedisToMysqlHandler {
|
||||||
|
@Resource
|
||||||
|
SchisandraFileHeatmapDomainService schisandraFileHeatmapDomainService;
|
||||||
|
|
||||||
|
@XxlJob("ossHeatMapRedisToMysqlHandler")
|
||||||
|
public void ossHeatMapRedisToMysqlHandler() throws Exception {
|
||||||
|
XxlJobHelper.log("ossHeatMapRedisToMysqlHandler.starter");
|
||||||
|
if (schisandraFileHeatmapDomainService.uploadHeatMapRedisToMysql()==1 ){
|
||||||
|
XxlJobHelper.log("ossHeatMapRedisToMysqlHandler.upload.success");
|
||||||
|
log.info("1");
|
||||||
|
}else {
|
||||||
|
XxlJobHelper.log("ossHeatMapRedisToMysqlHandler.fail");
|
||||||
|
}
|
||||||
|
if (schisandraFileHeatmapDomainService.downloadHeatMapRedisToMysql()==1){
|
||||||
|
XxlJobHelper.log("ossHeatMapRedisToMysqlHandler.success");
|
||||||
|
}else {
|
||||||
|
XxlJobHelper.log("ossHeatMapRedisToMysqlHandler.download.fail");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@@ -23,15 +23,15 @@ public class SchisandraFileHeatmapBO implements Serializable {
|
|||||||
*/
|
*/
|
||||||
private Long userId;
|
private Long userId;
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private Date date;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private Long count;
|
private Long count;
|
||||||
|
|
||||||
|
private Long size;
|
||||||
|
private Date updateTime;
|
||||||
|
private Integer type;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -5,6 +5,8 @@ import com.schisandra.oss.infra.basic.entity.SchisandraFileHeatmap;
|
|||||||
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,4 +21,6 @@ public interface SchisandraFileHeatmapBOConverter {
|
|||||||
SchisandraFileHeatmap convertBOToEntity(SchisandraFileHeatmapBO schisandraFileHeatmapBO);
|
SchisandraFileHeatmap convertBOToEntity(SchisandraFileHeatmapBO schisandraFileHeatmapBO);
|
||||||
SchisandraFileHeatmapBO convertEntityToBO(SchisandraFileHeatmap schisandraFileHeatmap);
|
SchisandraFileHeatmapBO convertEntityToBO(SchisandraFileHeatmap schisandraFileHeatmap);
|
||||||
|
|
||||||
|
List<SchisandraFileHeatmap> convertBOListToEntityList(List<SchisandraFileHeatmapBO> schisandraFileHeatmapBOList);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -1,15 +1,12 @@
|
|||||||
package com.schisandra.oss.domain.redis;
|
package com.schisandra.oss.domain.redis;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.data.redis.core.RedisTemplate;
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.ArrayList;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.HashMap;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
@@ -42,6 +39,18 @@ public class RedisUtil {
|
|||||||
});
|
});
|
||||||
return keysList;
|
return keysList;
|
||||||
}
|
}
|
||||||
|
public List<HashMap<Object,Object>> getDataFromDir(String directory) {
|
||||||
|
|
||||||
|
Set<String>keys=redisTemplate.keys(directory);
|
||||||
|
List<HashMap<Object,Object>> keysList=new ArrayList<>();
|
||||||
|
keys.forEach(key->{
|
||||||
|
HashMap<Object,Object> map=new HashMap<>();
|
||||||
|
HashMap<Object,Object> value= (HashMap<Object, Object>) redisTemplate.opsForValue().get(key);
|
||||||
|
map.put(key,value);
|
||||||
|
keysList.add(map);
|
||||||
|
});
|
||||||
|
return keysList;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -133,4 +142,7 @@ public class RedisUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void setNx(String key, HashMap<Object, Object> map, Long time, TimeUnit timeUnit) {
|
||||||
|
redisTemplate.opsForValue().set(key, map, time, timeUnit);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -2,6 +2,9 @@ package com.schisandra.oss.domain.service;
|
|||||||
|
|
||||||
import com.schisandra.oss.domain.bo.SchisandraFileHeatmapBO;
|
import com.schisandra.oss.domain.bo.SchisandraFileHeatmapBO;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文件上传热力图表 领域service
|
* 文件上传热力图表 领域service
|
||||||
*
|
*
|
||||||
@@ -25,4 +28,86 @@ public interface SchisandraFileHeatmapDomainService {
|
|||||||
*/
|
*/
|
||||||
Boolean delete(SchisandraFileHeatmapBO schisandraFileHeatmapBO);
|
Boolean delete(SchisandraFileHeatmapBO schisandraFileHeatmapBO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description: 查询用户上传文件热力图
|
||||||
|
* @param: [userId]
|
||||||
|
* @return: java.util.List<java.util.HashMap < java.lang.Object, java.lang.Object>>
|
||||||
|
* @author zlg
|
||||||
|
* @date: 2024/7/13 10:31
|
||||||
|
*/
|
||||||
|
List<HashMap<Object, Object>> selectUserUploadFileHeatMap(String userId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description: 查询用户下载文件热力图
|
||||||
|
* @param: [userId]
|
||||||
|
* @return: java.util.List<java.util.HashMap < java.lang.Object, java.lang.Object>>
|
||||||
|
* @author zlg
|
||||||
|
* @date: 2024/7/13 10:32
|
||||||
|
*/
|
||||||
|
List<HashMap<Object, Object>> selectUserDownloadFileHeatMap(String userId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description: 查询用户上传和下载流量
|
||||||
|
* @param: [userId]
|
||||||
|
* @return: java.util.HashMap<java.lang.Object, java.lang.Object>
|
||||||
|
* @author zlg
|
||||||
|
* @date: 2024/7/13 10:32
|
||||||
|
*/
|
||||||
|
HashMap<Object, Object> selectUserUploadAndDownloadflow(String userId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description: 将redis中的文件上传热力图数据同步到mysql中
|
||||||
|
* @param: []
|
||||||
|
* @return: int
|
||||||
|
* @author zlg
|
||||||
|
* @date: 2024/7/13 10:32
|
||||||
|
*/
|
||||||
|
int uploadHeatMapRedisToMysql();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description: 将redis中的文件下载热力图数据同步到mysql中
|
||||||
|
* @param: []
|
||||||
|
* @return: int
|
||||||
|
* @author zlg
|
||||||
|
* @date: 2024/7/13 10:32
|
||||||
|
*/
|
||||||
|
int downloadHeatMapRedisToMysql();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description: 查询用户最近上传的文件
|
||||||
|
* @param: [userId]
|
||||||
|
* @return: java.util.List<java.util.HashMap < java.lang.Object, java.lang.Object>>
|
||||||
|
* @author zlg
|
||||||
|
* @date: 2024/7/13 10:32
|
||||||
|
*/
|
||||||
|
List<HashMap<Object, Object>> selectRecentUploadFile(String userId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description: 查询用户最近下载的文件
|
||||||
|
* @param: [userId]
|
||||||
|
* @return: java.util.List<java.util.HashMap < java.lang.Object, java.lang.Object>>
|
||||||
|
* @author zlg
|
||||||
|
* @date: 2024/7/13 10:32
|
||||||
|
*/
|
||||||
|
List<HashMap<Object, Object>> selectRecentDownloadFile(String userId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description: 查询用户上传和下载次数
|
||||||
|
* @param: [userId]
|
||||||
|
* @return: java.util.HashMap<java.lang.Object, java.lang.Object>
|
||||||
|
* @author zlg
|
||||||
|
* @date: 2024/7/13 10:33
|
||||||
|
*/
|
||||||
|
HashMap<Object, Object> selectUserUploadAndDownloadCount(String userId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description: 插入文件上传热力图数据
|
||||||
|
* @param: [schisandraFileHeatmapBOList]
|
||||||
|
* @return: int
|
||||||
|
* @author zlg
|
||||||
|
* @date: 2024/7/13 10:33
|
||||||
|
*/
|
||||||
|
int insertFileHeatmapBatch(List<SchisandraFileHeatmapBO> schisandraFileHeatmapBOList);
|
||||||
|
HashMap<Object,Object> selectFileDiagramPerMonth(String userId,int type);
|
||||||
|
List<HashMap<Object,Object>> selectRecentPreviewFile(String userId);
|
||||||
}
|
}
|
||||||
|
@@ -31,6 +31,7 @@ public interface SchisandraOssMinioDomainService {
|
|||||||
|
|
||||||
SchisandraOssMinioBO getMinioConfig(Long userId);
|
SchisandraOssMinioBO getMinioConfig(Long userId);
|
||||||
|
|
||||||
|
List<SchisandraOssMinioBO> getAllMinioInfoByUserId(Long userId);
|
||||||
List<SchisandraOssMinioBO> getAllMinioInfo();
|
List<SchisandraOssMinioBO> getAllMinioInfo();
|
||||||
|
|
||||||
List<SchisandraOssMinioBO> selectAll();
|
List<SchisandraOssMinioBO> selectAll();
|
||||||
|
@@ -1,6 +1,9 @@
|
|||||||
package com.schisandra.oss.domain.service.impl;
|
package com.schisandra.oss.domain.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.io.unit.DataSizeUtil;
|
||||||
|
import com.schisandra.oss.domain.convert.SchisandraFileHeatmapBOConverter;
|
||||||
import com.schisandra.oss.domain.bo.SchisandraFileHeatmapBO;
|
import com.schisandra.oss.domain.bo.SchisandraFileHeatmapBO;
|
||||||
|
import com.schisandra.oss.domain.redis.RedisUtil;
|
||||||
import com.schisandra.oss.domain.convert.SchisandraFileHeatmapBOConverter;
|
import com.schisandra.oss.domain.convert.SchisandraFileHeatmapBOConverter;
|
||||||
import com.schisandra.oss.domain.service.SchisandraFileHeatmapDomainService;
|
import com.schisandra.oss.domain.service.SchisandraFileHeatmapDomainService;
|
||||||
import com.schisandra.oss.infra.basic.entity.SchisandraFileHeatmap;
|
import com.schisandra.oss.infra.basic.entity.SchisandraFileHeatmap;
|
||||||
@@ -9,6 +12,12 @@ 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.text.SimpleDateFormat;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import static jdk.nashorn.internal.runtime.GlobalFunctions.encodeURIComponent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文件上传热力图表 领域service实现了
|
* 文件上传热力图表 领域service实现了
|
||||||
@@ -22,6 +31,9 @@ public class SchisandraFileHeatmapDomainServiceImpl implements SchisandraFileHea
|
|||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private SchisandraFileHeatmapService schisandraFileHeatmapService;
|
private SchisandraFileHeatmapService schisandraFileHeatmapService;
|
||||||
|
@Resource
|
||||||
|
RedisUtil redisUtil;
|
||||||
|
private final String USER_OSS_PREFIX = "oss:user:heat";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean add(SchisandraFileHeatmapBO schisandraFileHeatmapBO) {
|
public Boolean add(SchisandraFileHeatmapBO schisandraFileHeatmapBO) {
|
||||||
@@ -42,4 +54,175 @@ public class SchisandraFileHeatmapDomainServiceImpl implements SchisandraFileHea
|
|||||||
return schisandraFileHeatmapService.update(schisandraFileHeatmap) > 0;
|
return schisandraFileHeatmapService.update(schisandraFileHeatmap) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<HashMap<Object, Object>> selectUserUploadFileHeatMap(String userId) {
|
||||||
|
String dire=redisUtil.buildKey(USER_OSS_PREFIX,"upload","*",userId,"*");
|
||||||
|
List<HashMap<Object,Object>> list=redisUtil.getDataFromDir(dire);
|
||||||
|
Map<Object, List<HashMap<Object, Object>>> list1=list.stream().collect(Collectors
|
||||||
|
.groupingBy(obj->String.valueOf(obj.keySet().toArray()[0]).split(":")[4]));
|
||||||
|
List<HashMap<Object,Object>> mapList =new ArrayList<>();
|
||||||
|
list1.keySet().forEach(obj->{
|
||||||
|
HashMap<Object,Object> map=new HashMap<>();
|
||||||
|
map.put(obj,Long.valueOf(list1.get(obj).size()));
|
||||||
|
mapList.add(map);
|
||||||
|
});
|
||||||
|
return mapList;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<HashMap<Object, Object>> selectUserDownloadFileHeatMap(String userId) {
|
||||||
|
String dire=redisUtil.buildKey(USER_OSS_PREFIX,"download","*",userId,"*");
|
||||||
|
List<HashMap<Object,Object>> list=redisUtil.getDataFromDir(dire);
|
||||||
|
Map<Object, List<HashMap<Object, Object>>> list1=list.stream().collect(Collectors
|
||||||
|
.groupingBy(obj->String.valueOf(obj.keySet().toArray()[0]).split(":")[4]));
|
||||||
|
List<HashMap<Object,Object>> mapList =new ArrayList<>();
|
||||||
|
list1.keySet().forEach(obj->{
|
||||||
|
HashMap<Object,Object> map=new HashMap<>();
|
||||||
|
map.put(obj,Long.valueOf(list1.get(obj).size()));
|
||||||
|
mapList.add(map);
|
||||||
|
});
|
||||||
|
return mapList;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HashMap<Object, Object> selectUserUploadAndDownloadflow(String userId) {
|
||||||
|
Long uploadflow=schisandraFileHeatmapService.selectUserUploadAndDownloadflow(userId,0);
|
||||||
|
Long downloadflow=schisandraFileHeatmapService.selectUserUploadAndDownloadflow(userId,1);
|
||||||
|
HashMap<Object,Object> map=new HashMap<>();
|
||||||
|
map.put("uploadflow", DataSizeUtil.format(uploadflow));
|
||||||
|
map.put("downloadflow",DataSizeUtil.format(downloadflow));
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int uploadHeatMapRedisToMysql() {
|
||||||
|
Date date =new Date();
|
||||||
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
String formattedDate = dateFormat.format(date);
|
||||||
|
String dire=redisUtil.buildKey(USER_OSS_PREFIX,"upload",formattedDate,"*");
|
||||||
|
List<HashMap<Object,Object>> list=redisUtil.getDataFromDir(dire);
|
||||||
|
if (list.isEmpty()){
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
Map<Object, List<HashMap<Object, Object>>> list1=list.stream().collect(Collectors
|
||||||
|
.groupingBy(obj->String.valueOf(obj.keySet().toArray()[0]).split(":")[5]));
|
||||||
|
List<SchisandraFileHeatmapBO> schisandraFileHeatmapBOList = new ArrayList<>();
|
||||||
|
list1.keySet().forEach(obj->{
|
||||||
|
SchisandraFileHeatmapBO schisandraFileHeatmapBO1 = new SchisandraFileHeatmapBO();
|
||||||
|
schisandraFileHeatmapBO1.setUserId(Long.valueOf(String.valueOf(obj)));
|
||||||
|
schisandraFileHeatmapBO1.setCount(Long.valueOf(list1.get(obj).size()));
|
||||||
|
schisandraFileHeatmapBO1.setType(0);
|
||||||
|
schisandraFileHeatmapBO1.setSize(0L);
|
||||||
|
list1.get(obj).forEach(obj1->{
|
||||||
|
String key= String.valueOf(obj1.keySet().toArray()[0]);
|
||||||
|
HashMap<Object,Object>temp= (HashMap<Object, Object>) obj1.get(key);
|
||||||
|
schisandraFileHeatmapBO1.setSize(Long.valueOf(temp.get("size").toString())
|
||||||
|
+ schisandraFileHeatmapBO1.getSize());
|
||||||
|
});
|
||||||
|
schisandraFileHeatmapBOList.add(schisandraFileHeatmapBO1);
|
||||||
|
});
|
||||||
|
return insertFileHeatmapBatch(schisandraFileHeatmapBOList);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int downloadHeatMapRedisToMysql() {
|
||||||
|
Date date =new Date();
|
||||||
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
String formattedDate = dateFormat.format(date);
|
||||||
|
String dire=redisUtil.buildKey(USER_OSS_PREFIX,"download",formattedDate,"*");
|
||||||
|
List<HashMap<Object,Object>> list=redisUtil.getDataFromDir(dire);
|
||||||
|
if (list.isEmpty()){
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
Map<Object, List<HashMap<Object, Object>>> list1=list.stream().collect(Collectors
|
||||||
|
.groupingBy(obj->String.valueOf(obj.keySet().toArray()[0]).split(":")[5]));
|
||||||
|
List<SchisandraFileHeatmapBO> schisandraFileHeatmapBOList = new ArrayList<>();
|
||||||
|
list1.keySet().forEach(obj->{
|
||||||
|
SchisandraFileHeatmapBO schisandraFileHeatmapBO1 = new SchisandraFileHeatmapBO();
|
||||||
|
schisandraFileHeatmapBO1.setUserId(Long.valueOf(String.valueOf(obj)));
|
||||||
|
schisandraFileHeatmapBO1.setCount(Long.valueOf(list1.get(obj).size()));
|
||||||
|
schisandraFileHeatmapBO1.setType(1);
|
||||||
|
schisandraFileHeatmapBO1.setSize(0L);
|
||||||
|
list1.get(obj).forEach(obj1->{
|
||||||
|
String key= String.valueOf(obj1.keySet().toArray()[0]);
|
||||||
|
HashMap<Object,Object>temp= (HashMap<Object, Object>) obj1.get(key);
|
||||||
|
schisandraFileHeatmapBO1.setSize(Long.valueOf(temp.get("size").toString())
|
||||||
|
+ schisandraFileHeatmapBO1.getSize());
|
||||||
|
});
|
||||||
|
schisandraFileHeatmapBOList.add(schisandraFileHeatmapBO1);
|
||||||
|
});
|
||||||
|
return insertFileHeatmapBatch(schisandraFileHeatmapBOList);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<HashMap<Object, Object>> selectRecentUploadFile(String userId) {
|
||||||
|
String recent=redisUtil.buildKey(USER_OSS_PREFIX,"upload","*",userId,"*");
|
||||||
|
List<HashMap<Object,Object>> list=redisUtil.getDataFromDir(recent);
|
||||||
|
List<HashMap<Object, Object>> list1 = new ArrayList<>();
|
||||||
|
list.forEach(obj->{
|
||||||
|
HashMap<Object,Object> recentFile = new HashMap<>();
|
||||||
|
String key= String.valueOf(obj.keySet().toArray()[0]);
|
||||||
|
String fileName=key.split(":")[6];
|
||||||
|
HashMap<Object,Object>temp= (HashMap<Object, Object>) obj.get(key);
|
||||||
|
recentFile.put(fileName,temp);
|
||||||
|
list1.add(recentFile);
|
||||||
|
});
|
||||||
|
return list1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<HashMap<Object, Object>> selectRecentDownloadFile(String userId) {
|
||||||
|
String recent=redisUtil.buildKey(USER_OSS_PREFIX,"download","*",userId,"*");
|
||||||
|
List<HashMap<Object,Object>> list=redisUtil.getDataFromDir(recent);
|
||||||
|
List<HashMap<Object, Object>> list1 = new ArrayList<>();
|
||||||
|
list.forEach(obj->{
|
||||||
|
HashMap<Object,Object> recentFile = new HashMap<>();
|
||||||
|
String key= String.valueOf(obj.keySet().toArray()[0]);
|
||||||
|
String fileName=key.split(":")[6];
|
||||||
|
HashMap<Object,Object>temp= (HashMap<Object, Object>) obj.get(key);
|
||||||
|
recentFile.put(fileName,temp);
|
||||||
|
list1.add(recentFile);
|
||||||
|
});
|
||||||
|
return list1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HashMap<Object, Object> selectUserUploadAndDownloadCount(String userId) {
|
||||||
|
HashMap<Object, Object> map = new HashMap<>();
|
||||||
|
map.put("upload", schisandraFileHeatmapService.selectUserUploadAndDownloadCount(userId,0));
|
||||||
|
map.put("download", schisandraFileHeatmapService.selectUserUploadAndDownloadCount(userId,1));
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int insertFileHeatmapBatch(List<SchisandraFileHeatmapBO> schisandraFileHeatmapBOList) {
|
||||||
|
List<SchisandraFileHeatmap> schisandraFileHeatmapList=SchisandraFileHeatmapBOConverter
|
||||||
|
.INSTANCE.convertBOListToEntityList(schisandraFileHeatmapBOList);
|
||||||
|
return schisandraFileHeatmapService.insertFileHeatmapBatch(schisandraFileHeatmapList);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HashMap<Object, Object> selectFileDiagramPerMonth(String userId,int type) {
|
||||||
|
return schisandraFileHeatmapService.selectFileDiagramPerMonth(userId, type);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public List<HashMap<Object, Object>> selectRecentPreviewFile(String userId) {
|
||||||
|
String recent=redisUtil.buildKey(USER_OSS_PREFIX,"previewFile","*",userId,"*");
|
||||||
|
List<HashMap<Object,Object>> list=redisUtil.getDataFromDir(recent);
|
||||||
|
List<HashMap<Object, Object>> list1 = new ArrayList<>();
|
||||||
|
list.forEach(obj->{
|
||||||
|
HashMap<Object,Object> recentFile = new HashMap<>();
|
||||||
|
String key= String.valueOf(obj.keySet().toArray()[0]);
|
||||||
|
String fileName=key.split(":")[6];
|
||||||
|
HashMap<Object,Object>temp= (HashMap<Object, Object>) obj.get(key);
|
||||||
|
recentFile.put(fileName,temp);
|
||||||
|
list1.add(recentFile);
|
||||||
|
});
|
||||||
|
return list1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -79,6 +79,13 @@ public class SchisandraOssMinioDomainServiceImpl implements SchisandraOssMinioDo
|
|||||||
return schisandraOssMinioBO;
|
return schisandraOssMinioBO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<SchisandraOssMinioBO> getAllMinioInfoByUserId(Long userId) {
|
||||||
|
List<SchisandraOssMinio> schisandraOssMinios = schisandraOssMinioService.getAllMinioInfoByUserId(userId);
|
||||||
|
List<SchisandraOssMinioBO> schisandraOssMinioBO = SchisandraOssMinioBOConverter.INSTANCE.convertEntityToBOList(schisandraOssMinios);
|
||||||
|
return schisandraOssMinioBO;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SchisandraOssMinioBO> getAllMinioInfo() {
|
public List<SchisandraOssMinioBO> getAllMinioInfo() {
|
||||||
List<SchisandraOssMinio> allMinioInfo = schisandraOssMinioService.getAllMinioInfo();
|
List<SchisandraOssMinio> allMinioInfo = schisandraOssMinioService.getAllMinioInfo();
|
||||||
|
@@ -31,11 +31,6 @@ public class SchisandraFileHeatmap implements Serializable {
|
|||||||
@Column("user_id")
|
@Column("user_id")
|
||||||
private Long userId;
|
private Long userId;
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Column("date")
|
|
||||||
private Date date;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -43,5 +38,13 @@ public class SchisandraFileHeatmap implements Serializable {
|
|||||||
@Column("count")
|
@Column("count")
|
||||||
private Long count;
|
private Long count;
|
||||||
|
|
||||||
|
@Column("type")
|
||||||
|
private Integer type;
|
||||||
|
|
||||||
|
@Column(value = "update_time",onUpdateValue = "now()",onInsertValue ="now()" )
|
||||||
|
private Date updateTime;
|
||||||
|
|
||||||
|
@Column("size")
|
||||||
|
private Long size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -2,6 +2,9 @@ package com.schisandra.oss.infra.basic.service;
|
|||||||
|
|
||||||
import com.schisandra.oss.infra.basic.entity.SchisandraFileHeatmap;
|
import com.schisandra.oss.infra.basic.entity.SchisandraFileHeatmap;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文件上传热力图表 表服务接口
|
* 文件上传热力图表 表服务接口
|
||||||
*
|
*
|
||||||
@@ -42,5 +45,18 @@ public interface SchisandraFileHeatmapService {
|
|||||||
*/
|
*/
|
||||||
boolean deleteById(Long id);
|
boolean deleteById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description: 将redis中的热力图数据保存到mysql中
|
||||||
|
* @param: [schisandraFileHeatmaps]
|
||||||
|
* @return: boolean
|
||||||
|
* @author zlg
|
||||||
|
* @date: 2024/7/11 16:05
|
||||||
|
*/
|
||||||
|
int insertFileHeatmapBatch(List<SchisandraFileHeatmap> schisandraFileHeatmaps);
|
||||||
|
|
||||||
|
Long selectUserUploadAndDownloadflow (String userId,int type);
|
||||||
|
|
||||||
|
Long selectUserUploadAndDownloadCount(String userId ,int type);
|
||||||
|
HashMap<Object,Object>selectFileDiagramPerMonth(String userId,int type);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -46,7 +46,7 @@ public interface SchisandraOssMinioService {
|
|||||||
*/
|
*/
|
||||||
boolean deleteById(Long id);
|
boolean deleteById(Long id);
|
||||||
|
|
||||||
|
List<SchisandraOssMinio> getAllMinioInfoByUserId(Long userId);
|
||||||
SchisandraOssMinio getMinioConfig(Long userId);
|
SchisandraOssMinio getMinioConfig(Long userId);
|
||||||
|
|
||||||
List<SchisandraOssMinio> getAllMinioInfo();
|
List<SchisandraOssMinio> getAllMinioInfo();
|
||||||
|
@@ -1,11 +1,21 @@
|
|||||||
package com.schisandra.oss.infra.basic.service.impl;
|
package com.schisandra.oss.infra.basic.service.impl;
|
||||||
|
|
||||||
import com.schisandra.oss.infra.basic.entity.SchisandraFileHeatmap;
|
import com.mybatisflex.core.query.QueryWrapper;
|
||||||
|
import com.mybatisflex.core.row.Db;
|
||||||
import com.schisandra.oss.infra.basic.dao.SchisandraFileHeatmapDao;
|
import com.schisandra.oss.infra.basic.dao.SchisandraFileHeatmapDao;
|
||||||
|
import com.schisandra.oss.infra.basic.entity.SchisandraFileHeatmap;
|
||||||
|
import com.schisandra.oss.infra.basic.entity.table.SchisandraFileHeatmapTableDef;
|
||||||
import com.schisandra.oss.infra.basic.service.SchisandraFileHeatmapService;
|
import com.schisandra.oss.infra.basic.service.SchisandraFileHeatmapService;
|
||||||
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.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static com.mybatisflex.core.query.QueryMethods.*;
|
||||||
|
import static io.lettuce.core.protocol.CommandKeyword.DB;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文件上传热力图表 表服务实现类
|
* 文件上传热力图表 表服务实现类
|
||||||
@@ -49,7 +59,7 @@ public class SchisandraFileHeatmapServiceImpl implements SchisandraFileHeatmapSe
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int update(SchisandraFileHeatmap schisandraFileHeatmap) {
|
public int update(SchisandraFileHeatmap schisandraFileHeatmap) {
|
||||||
return this.schisandraFileHeatmapDao.update(schisandraFileHeatmap,true);
|
return this.schisandraFileHeatmapDao.update(schisandraFileHeatmap, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -63,5 +73,60 @@ public class SchisandraFileHeatmapServiceImpl implements SchisandraFileHeatmapSe
|
|||||||
return this.schisandraFileHeatmapDao.deleteById(id) > 0;
|
return this.schisandraFileHeatmapDao.deleteById(id) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description: 将redis中的数据同步到mysql中
|
||||||
|
* @param: [schisandraFileHeatmaps]
|
||||||
|
* @return: boolean
|
||||||
|
* @author zlg
|
||||||
|
* @date: 2024/7/11 16:06
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int insertFileHeatmapBatch(List<SchisandraFileHeatmap> schisandraFileHeatmaps) {
|
||||||
|
return schisandraFileHeatmapDao.insertBatch(schisandraFileHeatmaps);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long selectUserUploadAndDownloadflow(String userId, int type) {
|
||||||
|
QueryWrapper queryFlow = new QueryWrapper().select(sum(SchisandraFileHeatmapTableDef.SCHISANDRA_FILE_HEATMAP.SIZE))
|
||||||
|
.from(SchisandraFileHeatmapTableDef.SCHISANDRA_FILE_HEATMAP)
|
||||||
|
.where(SchisandraFileHeatmapTableDef.SCHISANDRA_FILE_HEATMAP.USER_ID.eq(userId))
|
||||||
|
.and(SchisandraFileHeatmapTableDef.SCHISANDRA_FILE_HEATMAP.TYPE.eq(type));
|
||||||
|
Long count = schisandraFileHeatmapDao.selectOneByQueryAs(queryFlow, Long.class);
|
||||||
|
if (count == null) {
|
||||||
|
return 0L;
|
||||||
|
} else {
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long selectUserUploadAndDownloadCount(String userId, int type) {
|
||||||
|
QueryWrapper queryFlow = new QueryWrapper().select(sum(SchisandraFileHeatmapTableDef.SCHISANDRA_FILE_HEATMAP.COUNT))
|
||||||
|
.from(SchisandraFileHeatmapTableDef.SCHISANDRA_FILE_HEATMAP)
|
||||||
|
.where(SchisandraFileHeatmapTableDef.SCHISANDRA_FILE_HEATMAP.USER_ID.eq(userId))
|
||||||
|
.and(SchisandraFileHeatmapTableDef.SCHISANDRA_FILE_HEATMAP.TYPE.eq(type));
|
||||||
|
Long count = schisandraFileHeatmapDao.selectOneByQueryAs(queryFlow, Long.class);
|
||||||
|
if (count == null) {
|
||||||
|
return 0L;
|
||||||
|
} else {
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HashMap<Object,Object> selectFileDiagramPerMonth(String userId, int type) {
|
||||||
|
QueryWrapper queryFlow = new QueryWrapper().select(sum(SchisandraFileHeatmapTableDef.SCHISANDRA_FILE_HEATMAP.COUNT).as("count"),
|
||||||
|
dateFormat(SchisandraFileHeatmapTableDef.SCHISANDRA_FILE_HEATMAP.UPDATE_TIME,"%Y-%m").as("date"))
|
||||||
|
.from(SchisandraFileHeatmapTableDef.SCHISANDRA_FILE_HEATMAP)
|
||||||
|
.groupBy(dateFormat(SchisandraFileHeatmapTableDef.SCHISANDRA_FILE_HEATMAP.UPDATE_TIME, "%Y-%m"))
|
||||||
|
.where(SchisandraFileHeatmapTableDef.SCHISANDRA_FILE_HEATMAP.USER_ID.eq(userId))
|
||||||
|
.and(SchisandraFileHeatmapTableDef.SCHISANDRA_FILE_HEATMAP.TYPE.eq(type));
|
||||||
|
|
||||||
|
HashMap<Object, Object> map = new HashMap<>();
|
||||||
|
map.put("month", schisandraFileHeatmapDao.selectRowsByQuery(queryFlow));
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -73,6 +73,12 @@ public class SchisandraOssMinioServiceImpl implements SchisandraOssMinioService
|
|||||||
return this.schisandraOssMinioDao.deleteById(id) > 0;
|
return this.schisandraOssMinioDao.deleteById(id) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<SchisandraOssMinio> getAllMinioInfoByUserId(Long userId) {
|
||||||
|
return schisandraOssMinioDao.selectListByCondition(SchisandraOssMinioTableDef.SCHISANDRA_OSS_MINIO.USER_ID.eq(userId)
|
||||||
|
.and(SchisandraOssMinioTableDef.SCHISANDRA_OSS_MINIO.STATUS.eq("true")));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SchisandraOssMinio getMinioConfig(Long userId) {
|
public SchisandraOssMinio getMinioConfig(Long userId) {
|
||||||
|
@@ -5,8 +5,11 @@
|
|||||||
<resultMap id="BaseResultMap" type="com.schisandra.oss.infra.basic.entity.SchisandraFileHeatmap">
|
<resultMap id="BaseResultMap" type="com.schisandra.oss.infra.basic.entity.SchisandraFileHeatmap">
|
||||||
<id column="id" jdbcType="BIGINT" property="id"/>
|
<id column="id" jdbcType="BIGINT" property="id"/>
|
||||||
<result column="user_id" jdbcType="BIGINT" property="userId"/>
|
<result column="user_id" jdbcType="BIGINT" property="userId"/>
|
||||||
<result column="date" jdbcType="DATE" property="date"/>
|
|
||||||
<result column="count" jdbcType="BIGINT" property="count"/>
|
<result column="count" jdbcType="BIGINT" property="count"/>
|
||||||
|
<result column="size" jdbcType="BIGINT" property="size"/>
|
||||||
|
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
|
||||||
|
<result column="type" jdbcType="INTEGER" property="type"/>
|
||||||
|
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
@@ -58,6 +58,11 @@
|
|||||||
<artifactId>schisandra-cloud-storage-oss-infra</artifactId>
|
<artifactId>schisandra-cloud-storage-oss-infra</artifactId>
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.schisandra</groupId>
|
||||||
|
<artifactId>schisandra-cloud-storage-oss-application-job</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
@@ -3,6 +3,7 @@ package com.schisandra.oss;
|
|||||||
import org.mybatis.spring.annotation.MapperScan;
|
import org.mybatis.spring.annotation.MapperScan;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.cache.annotation.EnableCaching;
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -14,6 +15,7 @@ import org.springframework.context.annotation.ComponentScan;
|
|||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
@ComponentScan("com.schisandra")
|
@ComponentScan("com.schisandra")
|
||||||
@MapperScan("com.schisandra.**.dao")
|
@MapperScan("com.schisandra.**.dao")
|
||||||
|
@EnableCaching
|
||||||
public class OssApplication {
|
public class OssApplication {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(OssApplication.class);
|
SpringApplication.run(OssApplication.class);
|
||||||
|
@@ -63,3 +63,16 @@ mybatis-flex:
|
|||||||
mapper-locations:
|
mapper-locations:
|
||||||
- "classpath*:/mapper/**/*.xml"
|
- "classpath*:/mapper/**/*.xml"
|
||||||
|
|
||||||
|
# xxl-job配置
|
||||||
|
xxl:
|
||||||
|
job:
|
||||||
|
admin:
|
||||||
|
addresses: http://127.0.0.1:8080/xxl-job-admin
|
||||||
|
accessToken: default_token
|
||||||
|
executor:
|
||||||
|
appname: schisandra-cloud-storage-oss
|
||||||
|
address:
|
||||||
|
ip: 127.0.0.1
|
||||||
|
port: 9999
|
||||||
|
logpath: /data/applogs/xxl-job/jobhandler
|
||||||
|
logretentiondays: 30
|
@@ -35,4 +35,5 @@ public class GenerateAccessTokenJob {
|
|||||||
XxlJobHelper.log("generateAccessTokenJobHandler.error");
|
XxlJobHelper.log("generateAccessTokenJobHandler.error");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//ossHeatMapRedisToMysqlHandler
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user