release
This commit is contained in:
parent
9b87c13f1e
commit
735ec3dd89
7
pom.xml
7
pom.xml
|
|
@ -217,6 +217,12 @@
|
|||
<version>${ruoyi.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-minio</artifactId>
|
||||
<version>${ruoyi.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
|
|
@ -229,6 +235,7 @@
|
|||
<module>ruoyi-common</module>
|
||||
<module>ruoyi-file</module>
|
||||
<module>business</module>
|
||||
<module>ruoyi-minio</module>
|
||||
</modules>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
|
|
|
|||
|
|
@ -88,6 +88,11 @@
|
|||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-file</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-minio</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
|||
|
|
@ -133,3 +133,10 @@ xss:
|
|||
swagger:
|
||||
# 是否开启swagger
|
||||
enabled: true
|
||||
|
||||
minio:
|
||||
url: http://032t.com:9999/
|
||||
accessKey: admin
|
||||
secretKey: R1@31qaz
|
||||
bucketName: huaping
|
||||
startfile: index.html
|
||||
|
|
|
|||
|
|
@ -0,0 +1,26 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>ruoyi</artifactId>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<version>4.3.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>ruoyi-minio</artifactId>
|
||||
<dependencies>
|
||||
<!-- 通用工具-->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-common</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.minio</groupId>
|
||||
<artifactId>minio</artifactId>
|
||||
<version>7.0.2</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
|
@ -0,0 +1,139 @@
|
|||
package com.ruoyi.minio;
|
||||
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import io.minio.MinioClient;
|
||||
import io.minio.PutObjectOptions;
|
||||
import io.minio.Result;
|
||||
import io.minio.errors.*;
|
||||
import io.minio.messages.Bucket;
|
||||
import io.minio.messages.Item;
|
||||
import javafx.application.Application;
|
||||
import javafx.stage.Stage;
|
||||
import org.apache.commons.collections4.map.LinkedMap;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.*;
|
||||
import java.util.stream.DoubleStream;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/minio")
|
||||
public class MimioController {
|
||||
|
||||
@Autowired
|
||||
MinioClient minioClient;
|
||||
|
||||
@Value("${minio.bucketName}")
|
||||
private String bucketName;
|
||||
|
||||
@Value("${minio.startfile}")
|
||||
private String startfile;
|
||||
|
||||
|
||||
@RequestMapping("/index")
|
||||
public String index(String path,String openfile,ModelMap mmap) throws IOException, InvalidResponseException,
|
||||
InvalidKeyException, NoSuchAlgorithmException, InternalException, XmlParserException,
|
||||
InvalidBucketNameException, InsufficientDataException, ErrorResponseException {
|
||||
|
||||
mmap.put("dirlist", getDirList(path));
|
||||
|
||||
if(openfile==null)
|
||||
mmap.put("openfile",startfile);
|
||||
else
|
||||
mmap.put("openfile",openfile);
|
||||
|
||||
return "minio/index";
|
||||
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/getdirlist")
|
||||
@ResponseBody
|
||||
public ArrayList<Map<String,Object>> getDirList(String dir) throws IOException, InvalidResponseException,
|
||||
InvalidKeyException, NoSuchAlgorithmException, ErrorResponseException,
|
||||
XmlParserException, InvalidBucketNameException, InsufficientDataException,
|
||||
InternalException {
|
||||
|
||||
return listObjects(dir);
|
||||
|
||||
}
|
||||
|
||||
@RequestMapping("/save")
|
||||
@ResponseBody
|
||||
public Object save(String filepath,String content) throws IOException, InvalidKeyException,
|
||||
InvalidResponseException, InsufficientDataException, NoSuchAlgorithmException,
|
||||
InternalException, XmlParserException, InvalidBucketNameException, ErrorResponseException {
|
||||
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8.name()));
|
||||
minioClient.putObject(bucketName,filepath,byteArrayInputStream,new PutObjectOptions(byteArrayInputStream.available(), -1));
|
||||
|
||||
return AjaxResult.success("保存成功");
|
||||
}
|
||||
|
||||
@RequestMapping("/getfile")
|
||||
@ResponseBody
|
||||
public Object getFile(String filepath) throws IOException, InvalidResponseException,
|
||||
InvalidKeyException, NoSuchAlgorithmException, ErrorResponseException,
|
||||
XmlParserException, InvalidBucketNameException, InsufficientDataException,
|
||||
InternalException {
|
||||
|
||||
InputStream inputStream = fileIo(filepath);
|
||||
ByteArrayOutputStream result = new ByteArrayOutputStream();
|
||||
byte[] buffer = new byte[1024];
|
||||
int length;
|
||||
while ((length = inputStream.read(buffer)) != -1) {
|
||||
result.write(buffer, 0, length);
|
||||
}
|
||||
String str = result.toString(StandardCharsets.UTF_8.name());
|
||||
return AjaxResult.success("success",str);
|
||||
|
||||
}
|
||||
|
||||
public InputStream fileIo(String objname) throws IOException,
|
||||
InvalidKeyException, InvalidResponseException,
|
||||
InsufficientDataException, NoSuchAlgorithmException,
|
||||
InternalException, XmlParserException, InvalidBucketNameException,
|
||||
ErrorResponseException {
|
||||
|
||||
InputStream object = minioClient.getObject(bucketName, objname);
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
//获取指定文件列表
|
||||
public ArrayList<Map<String,Object>> listObjects(String prefix) throws IOException, InvalidKeyException,
|
||||
InvalidResponseException, InsufficientDataException, NoSuchAlgorithmException,
|
||||
InternalException, XmlParserException, InvalidBucketNameException,
|
||||
ErrorResponseException {
|
||||
|
||||
Iterable<Result<Item>> results = minioClient.listObjects(bucketName, prefix, false);
|
||||
ArrayList<Map<String,Object>> items = new ArrayList<>();
|
||||
|
||||
for(Result<Item> i:results){
|
||||
Item item = i.get();
|
||||
HashMap<String, Object> data = new HashMap<>();
|
||||
data.put("isDir",item.isDir());
|
||||
data.put("objname", item.objectName());
|
||||
String[] split = item.objectName().split("/");
|
||||
data.put("name",split[split.length-1]);
|
||||
data.put("lastModified",!item.isDir()?item.lastModified():null);
|
||||
data.put("size",item.size());
|
||||
items.add(data);
|
||||
}
|
||||
Collections.reverse(items);
|
||||
return items;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
package com.ruoyi.minio;
|
||||
|
||||
import io.minio.MinioClient;
|
||||
import io.minio.errors.InvalidEndpointException;
|
||||
import io.minio.errors.InvalidPortException;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class MyConfigration {
|
||||
|
||||
@Value("${minio.url}")
|
||||
private String url;
|
||||
|
||||
@Value("${minio.accessKey}")
|
||||
private String accessKey;
|
||||
|
||||
@Value("${minio.secretKey}")
|
||||
private String secretKey;
|
||||
|
||||
@Bean
|
||||
public MinioClient minioClient() throws InvalidPortException, InvalidEndpointException {
|
||||
|
||||
MinioClient minioClient = new MinioClient(url, accessKey, secretKey);
|
||||
return minioClient;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,145 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta name="keywords" content="">
|
||||
<meta name="description" content="">
|
||||
<title>在线编辑</title>
|
||||
<link href="/layui/css/layui.css" rel="stylesheet"/>
|
||||
<script src="/vscode/vs/loader.js"></script>
|
||||
<script src="/js/jquery.min.js"></script>
|
||||
<script src="/layui/layui.all.js"></script>
|
||||
</head>
|
||||
<body style="background-color: #f3f3f3">
|
||||
|
||||
<div>
|
||||
<div class="layui-row">
|
||||
<div class="layui-col-md9">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-header">
|
||||
<span style="margin-right: 30px;margin-left: 30px;">VSCODE 编辑器</span>
|
||||
<input type="button" class="layui-btn" value="保存" onclick="save();"/>
|
||||
</div>
|
||||
<div class="layui-card-body" id="text">
|
||||
<div id="container"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-col-md3">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-header">目录</div>
|
||||
<div class="layui-card-body" id="dir">
|
||||
|
||||
<table class="layui-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>类型</th>
|
||||
<th>名称</th>
|
||||
<th>大小</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr th:each="o : ${dirlist}" th:onclick="initEditor([[${o.objname}]],[[${o.isDir}]]);">
|
||||
<td th:switch="${o.isDir}">
|
||||
<i th:case="true" class="layui-icon"></i>
|
||||
<i th:case="false" class="layui-icon"></i>
|
||||
</td>
|
||||
|
||||
<td th:text="${o['name']}"></td>
|
||||
<td th:text="${o['size']+ 'b'}"></td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<script th:inline="javascript">
|
||||
var editor;
|
||||
var m;
|
||||
var openfile = [[ ${openfile} ]];
|
||||
|
||||
require.config({
|
||||
paths: { 'vs': '/vscode/vs'},
|
||||
|
||||
});
|
||||
require(['vs/editor/editor.main'], function() {
|
||||
m = monaco;
|
||||
editor = monaco.editor.create(document.getElementById('container'), {});
|
||||
$.post(
|
||||
"/minio/getfile",
|
||||
{filepath:openfile},function (e) {
|
||||
console.log(e);
|
||||
m.editor.setModelLanguage(editor.getModel(),"html")
|
||||
editor.setValue(e.data);
|
||||
openfile = "index.html";
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
$(function () {
|
||||
$("#container").width($("#text").width());
|
||||
let height = $(document).height()
|
||||
$("#container").height(height-((height/100)*10));
|
||||
})
|
||||
|
||||
function initEditor(file,isdir) {
|
||||
|
||||
if(isdir){
|
||||
getDirsFile(file);
|
||||
}else{
|
||||
getfile(file);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function getfile(filename){
|
||||
var loading = layer.msg('正在加载', {icon: 16, shade: 0.3, time: 0});
|
||||
$.post(
|
||||
"/minio/getfile",
|
||||
{
|
||||
filepath:filename
|
||||
|
||||
},function (e) {
|
||||
if(e.code==0){
|
||||
var index = filename.lastIndexOf(".");
|
||||
var suffix = filename.substring(index+1);
|
||||
if(suffix=="js") suffix = "javascript";
|
||||
m.editor.setModelLanguage(editor.getModel(),suffix);
|
||||
editor.setValue(e.data);
|
||||
openfile = filename;
|
||||
layer.close(loading);
|
||||
}else{
|
||||
layer.close(loading);
|
||||
layer.msg(e.msg);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function getDirsFile(path) {
|
||||
location.href="/minio/index?path="+path+"&openfile="+openfile;
|
||||
}
|
||||
|
||||
function save() {
|
||||
var loading = layer.msg('正在提交', {icon: 16, shade: 0.3, time: 0});
|
||||
$.post(
|
||||
"/minio/save",
|
||||
{
|
||||
filepath:openfile,
|
||||
content:editor.getValue()
|
||||
},function (e) {
|
||||
layer.close(loading);
|
||||
layer.msg(e.msg);
|
||||
|
||||
}
|
||||
);
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Reference in New Issue