Pre Merge pull request !44 from zhangmrit/master
This commit is contained in:
commit
87bf2585b5
26
README.md
26
README.md
|
|
@ -1,20 +1,16 @@
|
||||||
## 平台简介
|
## 平台简介
|
||||||
|
|
||||||
|
本项目FORK自 [若依/RuoYi](https://gitee.com/y_project/RuoYi)
|
||||||
2018年度最受欢迎中国开源软件评选
|
暂时花了几分钟时间把自己整合过的功能传上来:
|
||||||
请给若依/RuoYi 投票,谢谢大家。
|
###### 多数据源切面
|
||||||
https://www.oschina.net/project/top_cn_2018?sort=1
|
删了多数据源注解,改成根据方法名自动切换,默认主从分离(当然主从地址一样),当只有一个数据源的时候虽然会打印日志,实际主从还是同一个,膈应就自己改一下
|
||||||
|
###### 集成通用mapper
|
||||||
|
一开始想整合mybatis-plus,这玩意太重了,而且crud和本项目很多地方八字不合。mapper继承com.ruoyi.common.base.BaseMapper<T>后就可以策马奔腾啦,谁用谁知道
|
||||||
一直想做一款后台管理系统,看了很多优秀的开源项目但是发现没有合适的。于是利用空闲休息时间开始自己写了一套后台系统。如此有了若依。她可以用于所有的Web应用程序,如网站管理后台,网站会员中心,CMS,CRM,OA。所有前端后台代码封装过后十分精简易上手,出错概率低。同时支持移动客户端访问。系统会陆续更新一些实用功能。
|
###### 控制台日志分等级彩色渲染和多环境修改
|
||||||
|
具体看logback-spring.xml和application.xml改动
|
||||||
寓意:你若不离不弃,我必生死相依
|
###### 集成七牛云,阿里云,腾讯云OSS
|
||||||
|
- 先去七牛注册一下(推荐,10g免费空间)
|
||||||
若依基于hplus和inspinia两套后台系统模板开发。有需要可自行到群内下载。
|
- 详见sql/oss.sql,在上传页面配置好相关参数即可使用
|
||||||
|
|
||||||
> RuoYi从3.0开始,进行模块拆分,将原先的单应用转变为多模块,如需单应用,请移步 [RuoYi-fast](https://gitee.com/y_project/RuoYi-fast)
|
|
||||||
|
|
||||||
> 推荐使用阿里云部署,通用云产品代金券 :[点我领取](https://promotion.aliyun.com/ntms/yunparter/invite.html?userCode=brki8iof)
|
|
||||||
|
|
||||||
## 内置功能
|
## 内置功能
|
||||||
|
|
||||||
|
|
|
||||||
4
pom.xml
4
pom.xml
|
|
@ -25,6 +25,10 @@
|
||||||
<kaptcha.version>2.3.2</kaptcha.version>
|
<kaptcha.version>2.3.2</kaptcha.version>
|
||||||
<swagger.version>2.7.0</swagger.version>
|
<swagger.version>2.7.0</swagger.version>
|
||||||
<pagehelper.boot.version>1.2.5</pagehelper.boot.version>
|
<pagehelper.boot.version>1.2.5</pagehelper.boot.version>
|
||||||
|
<qiniu.version>[7.2.0, 7.2.99]</qiniu.version>
|
||||||
|
<aliyun.oss.version>2.5.0</aliyun.oss.version>
|
||||||
|
<qcloud.cos.version>4.4</qcloud.cos.version>
|
||||||
|
<fastjson.version>1.2.49</fastjson.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
|
|
|
||||||
|
|
@ -1,81 +1,110 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
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">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<parent>
|
<parent>
|
||||||
<artifactId>ruoyi</artifactId>
|
<artifactId>ruoyi</artifactId>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<version>3.0</version>
|
<version>3.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<artifactId>ruoyi-admin</artifactId>
|
<artifactId>ruoyi-admin</artifactId>
|
||||||
|
|
||||||
<description>
|
<description>
|
||||||
web服务入口
|
web服务入口
|
||||||
</description>
|
</description>
|
||||||
|
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
<!-- spring-boot-devtools -->
|
<!-- spring-boot-devtools -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-devtools</artifactId>
|
<artifactId>spring-boot-devtools</artifactId>
|
||||||
<optional>true</optional> <!-- 表示依赖不会传递 -->
|
<optional>true</optional> <!-- 表示依赖不会传递 -->
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- swagger2-->
|
<!-- swagger2 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.springfox</groupId>
|
<groupId>io.springfox</groupId>
|
||||||
<artifactId>springfox-swagger2</artifactId>
|
<artifactId>springfox-swagger2</artifactId>
|
||||||
<version>${swagger.version}</version>
|
<version>${swagger.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- swagger2-UI-->
|
<!-- swagger2-UI -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.springfox</groupId>
|
<groupId>io.springfox</groupId>
|
||||||
<artifactId>springfox-swagger-ui</artifactId>
|
<artifactId>springfox-swagger-ui</artifactId>
|
||||||
<version>${swagger.version}</version>
|
<version>${swagger.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 核心模块-->
|
<!-- 核心模块 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-framework</artifactId>
|
<artifactId>ruoyi-framework</artifactId>
|
||||||
<version>${ruoyi.version}</version>
|
<version>${ruoyi.version}</version>
|
||||||
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
<!-- oss -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.qiniu</groupId>
|
||||||
|
<artifactId>qiniu-java-sdk</artifactId>
|
||||||
|
<version>${qiniu.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.aliyun.oss</groupId>
|
||||||
|
<artifactId>aliyun-sdk-oss</artifactId>
|
||||||
|
<version>${aliyun.oss.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.qcloud</groupId>
|
||||||
|
<artifactId>cos_api</artifactId>
|
||||||
|
<version>${qcloud.cos.version}</version>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.slf4j</groupId>
|
||||||
|
<artifactId>slf4j-log4j12</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<build>
|
<dependency>
|
||||||
<plugins>
|
<groupId>com.alibaba</groupId>
|
||||||
<plugin>
|
<artifactId>fastjson</artifactId>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<version>${fastjson.version}</version>
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
</dependency>
|
||||||
<configuration>
|
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
<fork>true</fork> <!-- 如果没有该配置,devtools不会生效 -->
|
<fork>true</fork> <!-- 如果没有该配置,devtools不会生效 -->
|
||||||
</configuration>
|
</configuration>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<goals>
|
<goals>
|
||||||
<goal>repackage</goal>
|
<goal>repackage</goal>
|
||||||
</goals>
|
</goals>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-war-plugin</artifactId>
|
<artifactId>maven-war-plugin</artifactId>
|
||||||
<version>3.0.0</version>
|
<version>3.0.0</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<failOnMissingWebXml>false</failOnMissingWebXml>
|
<failOnMissingWebXml>false</failOnMissingWebXml>
|
||||||
<warName>${artifactId}</warName>
|
<warName>${artifactId}</warName>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
<finalName>${artifactId}</finalName>
|
<finalName>${artifactId}</finalName>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
@ -1,10 +1,11 @@
|
||||||
package com.ruoyi;
|
package com.ruoyi;
|
||||||
|
|
||||||
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.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||||
|
|
||||||
|
import tk.mybatis.spring.annotation.MapperScan;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 启动程序
|
* 启动程序
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,178 @@
|
||||||
|
package com.ruoyi.web.controller.system;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.ruoyi.common.base.AjaxResult;
|
||||||
|
import com.ruoyi.framework.util.ShiroUtils;
|
||||||
|
import com.ruoyi.framework.util.ValidatorUtils;
|
||||||
|
import com.ruoyi.framework.web.base.BaseController;
|
||||||
|
import com.ruoyi.framework.web.exception.user.OssException;
|
||||||
|
import com.ruoyi.framework.web.page.TableDataInfo;
|
||||||
|
import com.ruoyi.system.domain.SysOss;
|
||||||
|
import com.ruoyi.system.service.ISysConfigService;
|
||||||
|
import com.ruoyi.system.service.ISysOssService;
|
||||||
|
import com.ruoyi.web.controller.system.cloud.CloudConstant;
|
||||||
|
import com.ruoyi.web.controller.system.cloud.CloudConstant.CloudService;
|
||||||
|
import com.ruoyi.web.controller.system.cloud.CloudStorageConfig;
|
||||||
|
import com.ruoyi.web.controller.system.cloud.CloudStorageService;
|
||||||
|
import com.ruoyi.web.controller.system.cloud.OSSFactory;
|
||||||
|
import com.ruoyi.web.controller.system.cloud.valdator.AliyunGroup;
|
||||||
|
import com.ruoyi.web.controller.system.cloud.valdator.QcloudGroup;
|
||||||
|
import com.ruoyi.web.controller.system.cloud.valdator.QiniuGroup;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件上传
|
||||||
|
*/
|
||||||
|
@Controller
|
||||||
|
@RequestMapping("system/oss")
|
||||||
|
public class SysOssController extends BaseController
|
||||||
|
{
|
||||||
|
private String prefix = "system/oss";
|
||||||
|
|
||||||
|
private final static String KEY = CloudConstant.CLOUD_STORAGE_CONFIG_KEY;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ISysOssService sysOssService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ISysConfigService sysConfigService;
|
||||||
|
|
||||||
|
@RequiresPermissions("system:dept:view")
|
||||||
|
@GetMapping()
|
||||||
|
public String dept()
|
||||||
|
{
|
||||||
|
return prefix + "/oss";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 列表
|
||||||
|
*/
|
||||||
|
@RequestMapping("list")
|
||||||
|
@RequiresPermissions("sys:oss:list")
|
||||||
|
@ResponseBody
|
||||||
|
public TableDataInfo list(SysOss sysOss)
|
||||||
|
{
|
||||||
|
startPage();
|
||||||
|
List<SysOss> list = sysOssService.getList(sysOss);
|
||||||
|
return getDataTable(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 云存储配置信息
|
||||||
|
*/
|
||||||
|
@RequestMapping("config")
|
||||||
|
@RequiresPermissions("sys:oss:config")
|
||||||
|
public String config(Model model)
|
||||||
|
{
|
||||||
|
String jsonconfig = sysConfigService.selectConfigByKey(CloudConstant.CLOUD_STORAGE_CONFIG_KEY);
|
||||||
|
// 获取云存储配置信息
|
||||||
|
CloudStorageConfig config = JSON.parseObject(jsonconfig, CloudStorageConfig.class);
|
||||||
|
model.addAttribute("config", config);
|
||||||
|
return prefix + "/config";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存云存储配置信息
|
||||||
|
*/
|
||||||
|
@RequestMapping("saveConfig")
|
||||||
|
@RequiresPermissions("sys:oss:config")
|
||||||
|
@ResponseBody
|
||||||
|
public AjaxResult saveConfig(CloudStorageConfig config)
|
||||||
|
{
|
||||||
|
// 校验类型
|
||||||
|
ValidatorUtils.validateEntity(config);
|
||||||
|
if (config.getType() == CloudService.QINIU.getValue())
|
||||||
|
{
|
||||||
|
// 校验七牛数据
|
||||||
|
ValidatorUtils.validateEntity(config, QiniuGroup.class);
|
||||||
|
}
|
||||||
|
else if (config.getType() == CloudService.ALIYUN.getValue())
|
||||||
|
{
|
||||||
|
// 校验阿里云数据
|
||||||
|
ValidatorUtils.validateEntity(config, AliyunGroup.class);
|
||||||
|
}
|
||||||
|
else if (config.getType() == CloudService.QCLOUD.getValue())
|
||||||
|
{
|
||||||
|
// 校验腾讯云数据
|
||||||
|
ValidatorUtils.validateEntity(config, QcloudGroup.class);
|
||||||
|
}
|
||||||
|
return toAjax(sysConfigService.updateValueByKey(KEY, new Gson().toJson(config)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上传文件
|
||||||
|
*/
|
||||||
|
@RequestMapping("/upload")
|
||||||
|
@RequiresPermissions("sys:oss:add")
|
||||||
|
@ResponseBody
|
||||||
|
public AjaxResult upload(@RequestParam("file") MultipartFile file) throws Exception
|
||||||
|
{
|
||||||
|
if (file.isEmpty())
|
||||||
|
{
|
||||||
|
throw new OssException("上传文件不能为空");
|
||||||
|
}
|
||||||
|
// 上传文件
|
||||||
|
String fileName = file.getOriginalFilename();
|
||||||
|
String suffix = fileName.substring(fileName.lastIndexOf("."));
|
||||||
|
CloudStorageService storage=OSSFactory.build();
|
||||||
|
String url = storage.uploadSuffix(file.getBytes(), suffix);
|
||||||
|
// 保存文件信息
|
||||||
|
SysOss ossEntity = new SysOss();
|
||||||
|
ossEntity.setUrl(url);
|
||||||
|
ossEntity.setFileSuffix(suffix);
|
||||||
|
ossEntity.setCreateBy(ShiroUtils.getLoginName());
|
||||||
|
ossEntity.setFileName(fileName);
|
||||||
|
ossEntity.setCreateTime(new Date());
|
||||||
|
ossEntity.setService(storage.getService());
|
||||||
|
return toAjax(sysOssService.save(ossEntity));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改
|
||||||
|
*/
|
||||||
|
@GetMapping("edit/{ossId}")
|
||||||
|
@RequiresPermissions("sys:oss:edit")
|
||||||
|
public String edit(@PathVariable("ossId") Long ossId, Model model)
|
||||||
|
{
|
||||||
|
SysOss sysOss = sysOssService.findById(ossId);
|
||||||
|
model.addAttribute("sysOss", sysOss);
|
||||||
|
return prefix + "/edit";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改
|
||||||
|
*/
|
||||||
|
@PostMapping("edit")
|
||||||
|
@RequiresPermissions("sys:oss:edit")
|
||||||
|
@ResponseBody
|
||||||
|
public AjaxResult editSave(SysOss sysOss)
|
||||||
|
{
|
||||||
|
return toAjax(sysOssService.update(sysOss));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除
|
||||||
|
*/
|
||||||
|
@RequestMapping("remove")
|
||||||
|
@RequiresPermissions("sys:oss:remove")
|
||||||
|
@ResponseBody
|
||||||
|
public AjaxResult delete(String ids)
|
||||||
|
{
|
||||||
|
return toAjax(sysOssService.deleteByIds(ids));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,60 @@
|
||||||
|
package com.ruoyi.web.controller.system.cloud;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
import com.aliyun.oss.OSSClient;
|
||||||
|
import com.ruoyi.framework.web.exception.user.OssException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 阿里云存储
|
||||||
|
*/
|
||||||
|
public class AliyunCloudStorageService extends CloudStorageService
|
||||||
|
{
|
||||||
|
private OSSClient client;
|
||||||
|
|
||||||
|
public AliyunCloudStorageService(CloudStorageConfig config)
|
||||||
|
{
|
||||||
|
this.config = config;
|
||||||
|
// 初始化
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void init()
|
||||||
|
{
|
||||||
|
client = new OSSClient(config.getAliyunEndPoint(), config.getAliyunAccessKeyId(),
|
||||||
|
config.getAliyunAccessKeySecret());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String upload(byte[] data, String path)
|
||||||
|
{
|
||||||
|
return upload(new ByteArrayInputStream(data), path);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String upload(InputStream inputStream, String path)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
client.putObject(config.getAliyunBucketName(), path, inputStream);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
throw new OssException("上传文件失败,请检查配置信息");
|
||||||
|
}
|
||||||
|
return config.getAliyunDomain() + "/" + path;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String uploadSuffix(byte[] data, String suffix)
|
||||||
|
{
|
||||||
|
return upload(data, getPath(config.getAliyunPrefix(), suffix));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String uploadSuffix(InputStream inputStream, String suffix)
|
||||||
|
{
|
||||||
|
return upload(inputStream, getPath(config.getAliyunPrefix(), suffix));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
package com.ruoyi.web.controller.system.cloud;
|
||||||
|
|
||||||
|
public class CloudConstant
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 云存储配置KEY
|
||||||
|
*/
|
||||||
|
public final static String CLOUD_STORAGE_CONFIG_KEY = "sys.oss.cloudStorage";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 云服务商
|
||||||
|
*/
|
||||||
|
public enum CloudService
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 七牛云
|
||||||
|
*/
|
||||||
|
QINIU(1),
|
||||||
|
/**
|
||||||
|
* 阿里云
|
||||||
|
*/
|
||||||
|
ALIYUN(2),
|
||||||
|
/**
|
||||||
|
* 腾讯云
|
||||||
|
*/
|
||||||
|
QCLOUD(3);
|
||||||
|
private int value;
|
||||||
|
|
||||||
|
CloudService(int value)
|
||||||
|
{
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getValue()
|
||||||
|
{
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,288 @@
|
||||||
|
package com.ruoyi.web.controller.system.cloud;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
import org.hibernate.validator.constraints.Range;
|
||||||
|
import org.hibernate.validator.constraints.URL;
|
||||||
|
|
||||||
|
import com.ruoyi.web.controller.system.cloud.valdator.AliyunGroup;
|
||||||
|
import com.ruoyi.web.controller.system.cloud.valdator.QcloudGroup;
|
||||||
|
import com.ruoyi.web.controller.system.cloud.valdator.QiniuGroup;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 云存储配置信息
|
||||||
|
*/
|
||||||
|
public class CloudStorageConfig implements Serializable
|
||||||
|
{
|
||||||
|
//
|
||||||
|
private static final long serialVersionUID = 9035033846176792944L;
|
||||||
|
|
||||||
|
// 类型 1:七牛 2:阿里云 3:腾讯云
|
||||||
|
@Range(min = 1, max = 3, message = "类型错误")
|
||||||
|
private Integer type;
|
||||||
|
|
||||||
|
// 七牛绑定的域名
|
||||||
|
@NotBlank(message = "七牛绑定的域名不能为空", groups = QiniuGroup.class)
|
||||||
|
@URL(message = "七牛绑定的域名格式不正确", groups = QiniuGroup.class)
|
||||||
|
private String qiniuDomain;
|
||||||
|
|
||||||
|
// 七牛路径前缀
|
||||||
|
private String qiniuPrefix;
|
||||||
|
|
||||||
|
// 七牛ACCESS_KEY
|
||||||
|
@NotBlank(message = "七牛AccessKey不能为空", groups = QiniuGroup.class)
|
||||||
|
private String qiniuAccessKey;
|
||||||
|
|
||||||
|
// 七牛SECRET_KEY
|
||||||
|
@NotBlank(message = "七牛SecretKey不能为空", groups = QiniuGroup.class)
|
||||||
|
private String qiniuSecretKey;
|
||||||
|
|
||||||
|
// 七牛存储空间名
|
||||||
|
@NotBlank(message = "七牛空间名不能为空", groups = QiniuGroup.class)
|
||||||
|
private String qiniuBucketName;
|
||||||
|
|
||||||
|
// 阿里云绑定的域名
|
||||||
|
@NotBlank(message = "阿里云绑定的域名不能为空", groups = AliyunGroup.class)
|
||||||
|
@URL(message = "阿里云绑定的域名格式不正确", groups = AliyunGroup.class)
|
||||||
|
private String aliyunDomain;
|
||||||
|
|
||||||
|
// 阿里云路径前缀
|
||||||
|
private String aliyunPrefix;
|
||||||
|
|
||||||
|
// 阿里云EndPoint
|
||||||
|
@NotBlank(message = "阿里云EndPoint不能为空", groups = AliyunGroup.class)
|
||||||
|
private String aliyunEndPoint;
|
||||||
|
|
||||||
|
// 阿里云AccessKeyId
|
||||||
|
@NotBlank(message = "阿里云AccessKeyId不能为空", groups = AliyunGroup.class)
|
||||||
|
private String aliyunAccessKeyId;
|
||||||
|
|
||||||
|
// 阿里云AccessKeySecret
|
||||||
|
@NotBlank(message = "阿里云AccessKeySecret不能为空", groups = AliyunGroup.class)
|
||||||
|
private String aliyunAccessKeySecret;
|
||||||
|
|
||||||
|
// 阿里云BucketName
|
||||||
|
@NotBlank(message = "阿里云BucketName不能为空", groups = AliyunGroup.class)
|
||||||
|
private String aliyunBucketName;
|
||||||
|
|
||||||
|
// 腾讯云绑定的域名
|
||||||
|
@NotBlank(message = "腾讯云绑定的域名不能为空", groups = QcloudGroup.class)
|
||||||
|
@URL(message = "腾讯云绑定的域名格式不正确", groups = QcloudGroup.class)
|
||||||
|
private String qcloudDomain;
|
||||||
|
|
||||||
|
// 腾讯云路径前缀
|
||||||
|
private String qcloudPrefix;
|
||||||
|
|
||||||
|
// 腾讯云AppId
|
||||||
|
@NotNull(message = "腾讯云AppId不能为空", groups = QcloudGroup.class)
|
||||||
|
private Integer qcloudAppId;
|
||||||
|
|
||||||
|
// 腾讯云SecretId
|
||||||
|
@NotBlank(message = "腾讯云SecretId不能为空", groups = QcloudGroup.class)
|
||||||
|
private String qcloudSecretId;
|
||||||
|
|
||||||
|
// 腾讯云SecretKey
|
||||||
|
@NotBlank(message = "腾讯云SecretKey不能为空", groups = QcloudGroup.class)
|
||||||
|
private String qcloudSecretKey;
|
||||||
|
|
||||||
|
// 腾讯云BucketName
|
||||||
|
@NotBlank(message = "腾讯云BucketName不能为空", groups = QcloudGroup.class)
|
||||||
|
private String qcloudBucketName;
|
||||||
|
|
||||||
|
// 腾讯云COS所属地区
|
||||||
|
@NotBlank(message = "所属地区不能为空", groups = QcloudGroup.class)
|
||||||
|
private String qcloudRegion;
|
||||||
|
|
||||||
|
public Integer getType()
|
||||||
|
{
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(Integer type)
|
||||||
|
{
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getQiniuDomain()
|
||||||
|
{
|
||||||
|
return qiniuDomain;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setQiniuDomain(String qiniuDomain)
|
||||||
|
{
|
||||||
|
this.qiniuDomain = qiniuDomain;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getQiniuAccessKey()
|
||||||
|
{
|
||||||
|
return qiniuAccessKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setQiniuAccessKey(String qiniuAccessKey)
|
||||||
|
{
|
||||||
|
this.qiniuAccessKey = qiniuAccessKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getQiniuSecretKey()
|
||||||
|
{
|
||||||
|
return qiniuSecretKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setQiniuSecretKey(String qiniuSecretKey)
|
||||||
|
{
|
||||||
|
this.qiniuSecretKey = qiniuSecretKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getQiniuBucketName()
|
||||||
|
{
|
||||||
|
return qiniuBucketName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setQiniuBucketName(String qiniuBucketName)
|
||||||
|
{
|
||||||
|
this.qiniuBucketName = qiniuBucketName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getQiniuPrefix()
|
||||||
|
{
|
||||||
|
return qiniuPrefix;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setQiniuPrefix(String qiniuPrefix)
|
||||||
|
{
|
||||||
|
this.qiniuPrefix = qiniuPrefix;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAliyunDomain()
|
||||||
|
{
|
||||||
|
return aliyunDomain;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAliyunDomain(String aliyunDomain)
|
||||||
|
{
|
||||||
|
this.aliyunDomain = aliyunDomain;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAliyunPrefix()
|
||||||
|
{
|
||||||
|
return aliyunPrefix;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAliyunPrefix(String aliyunPrefix)
|
||||||
|
{
|
||||||
|
this.aliyunPrefix = aliyunPrefix;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAliyunEndPoint()
|
||||||
|
{
|
||||||
|
return aliyunEndPoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAliyunEndPoint(String aliyunEndPoint)
|
||||||
|
{
|
||||||
|
this.aliyunEndPoint = aliyunEndPoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAliyunAccessKeyId()
|
||||||
|
{
|
||||||
|
return aliyunAccessKeyId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAliyunAccessKeyId(String aliyunAccessKeyId)
|
||||||
|
{
|
||||||
|
this.aliyunAccessKeyId = aliyunAccessKeyId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAliyunAccessKeySecret()
|
||||||
|
{
|
||||||
|
return aliyunAccessKeySecret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAliyunAccessKeySecret(String aliyunAccessKeySecret)
|
||||||
|
{
|
||||||
|
this.aliyunAccessKeySecret = aliyunAccessKeySecret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAliyunBucketName()
|
||||||
|
{
|
||||||
|
return aliyunBucketName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAliyunBucketName(String aliyunBucketName)
|
||||||
|
{
|
||||||
|
this.aliyunBucketName = aliyunBucketName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getQcloudDomain()
|
||||||
|
{
|
||||||
|
return qcloudDomain;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setQcloudDomain(String qcloudDomain)
|
||||||
|
{
|
||||||
|
this.qcloudDomain = qcloudDomain;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getQcloudPrefix()
|
||||||
|
{
|
||||||
|
return qcloudPrefix;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setQcloudPrefix(String qcloudPrefix)
|
||||||
|
{
|
||||||
|
this.qcloudPrefix = qcloudPrefix;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getQcloudAppId()
|
||||||
|
{
|
||||||
|
return qcloudAppId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setQcloudAppId(Integer qcloudAppId)
|
||||||
|
{
|
||||||
|
this.qcloudAppId = qcloudAppId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getQcloudSecretId()
|
||||||
|
{
|
||||||
|
return qcloudSecretId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setQcloudSecretId(String qcloudSecretId)
|
||||||
|
{
|
||||||
|
this.qcloudSecretId = qcloudSecretId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getQcloudSecretKey()
|
||||||
|
{
|
||||||
|
return qcloudSecretKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setQcloudSecretKey(String qcloudSecretKey)
|
||||||
|
{
|
||||||
|
this.qcloudSecretKey = qcloudSecretKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getQcloudBucketName()
|
||||||
|
{
|
||||||
|
return qcloudBucketName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setQcloudBucketName(String qcloudBucketName)
|
||||||
|
{
|
||||||
|
this.qcloudBucketName = qcloudBucketName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getQcloudRegion()
|
||||||
|
{
|
||||||
|
return qcloudRegion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setQcloudRegion(String qcloudRegion)
|
||||||
|
{
|
||||||
|
this.qcloudRegion = qcloudRegion;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,73 @@
|
||||||
|
package com.ruoyi.web.controller.system.cloud;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
|
||||||
|
import com.ruoyi.common.utils.DateUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 云存储(支持七牛、阿里云、腾讯云、又拍云)
|
||||||
|
*/
|
||||||
|
public abstract class CloudStorageService
|
||||||
|
{
|
||||||
|
/** 云存储配置信息 */
|
||||||
|
CloudStorageConfig config;
|
||||||
|
|
||||||
|
public int getService()
|
||||||
|
{
|
||||||
|
return config.getType();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件路径
|
||||||
|
* @param prefix 前缀
|
||||||
|
* @param suffix 后缀
|
||||||
|
* @return 返回上传路径
|
||||||
|
*/
|
||||||
|
public String getPath(String prefix, String suffix)
|
||||||
|
{
|
||||||
|
// 生成uuid
|
||||||
|
String uuid = UUID.randomUUID().toString().replaceAll("-", "");
|
||||||
|
// 文件路径
|
||||||
|
String path = DateUtils.dateTime() + "/" + uuid;
|
||||||
|
if (StringUtils.isNotBlank(prefix))
|
||||||
|
{
|
||||||
|
path = prefix + "/" + path;
|
||||||
|
}
|
||||||
|
return path + suffix;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件上传
|
||||||
|
* @param data 文件字节数组
|
||||||
|
* @param path 文件路径,包含文件名
|
||||||
|
* @return 返回http地址
|
||||||
|
*/
|
||||||
|
public abstract String upload(byte[] data, String path);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件上传
|
||||||
|
* @param data 文件字节数组
|
||||||
|
* @param suffix 后缀
|
||||||
|
* @return 返回http地址
|
||||||
|
*/
|
||||||
|
public abstract String uploadSuffix(byte[] data, String suffix);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件上传
|
||||||
|
* @param inputStream 字节流
|
||||||
|
* @param path 文件路径,包含文件名
|
||||||
|
* @return 返回http地址
|
||||||
|
*/
|
||||||
|
public abstract String upload(InputStream inputStream, String path);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件上传
|
||||||
|
* @param inputStream 字节流
|
||||||
|
* @param suffix 后缀
|
||||||
|
* @return 返回http地址
|
||||||
|
*/
|
||||||
|
public abstract String uploadSuffix(InputStream inputStream, String suffix);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,38 @@
|
||||||
|
package com.ruoyi.web.controller.system.cloud;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.ruoyi.framework.util.SpringUtils;
|
||||||
|
import com.ruoyi.system.service.ISysConfigService;
|
||||||
|
import com.ruoyi.web.controller.system.cloud.CloudConstant.CloudService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件上传Factory
|
||||||
|
*/
|
||||||
|
public final class OSSFactory
|
||||||
|
{
|
||||||
|
private static ISysConfigService sysConfigService;
|
||||||
|
static
|
||||||
|
{
|
||||||
|
OSSFactory.sysConfigService = (ISysConfigService) SpringUtils.getBean(ISysConfigService.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CloudStorageService build()
|
||||||
|
{
|
||||||
|
String jsonconfig = sysConfigService.selectConfigByKey(CloudConstant.CLOUD_STORAGE_CONFIG_KEY);
|
||||||
|
// 获取云存储配置信息
|
||||||
|
CloudStorageConfig config = JSON.parseObject(jsonconfig, CloudStorageConfig.class);
|
||||||
|
if (config.getType() == CloudService.QINIU.getValue())
|
||||||
|
{
|
||||||
|
return new QiniuCloudStorageService(config);
|
||||||
|
}
|
||||||
|
else if (config.getType() == CloudService.ALIYUN.getValue())
|
||||||
|
{
|
||||||
|
return new AliyunCloudStorageService(config);
|
||||||
|
}
|
||||||
|
else if (config.getType() == CloudService.QCLOUD.getValue())
|
||||||
|
{
|
||||||
|
return new QcloudCloudStorageService(config);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,85 @@
|
||||||
|
package com.ruoyi.web.controller.system.cloud;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
import org.apache.commons.io.IOUtils;
|
||||||
|
|
||||||
|
import com.qcloud.cos.COSClient;
|
||||||
|
import com.qcloud.cos.ClientConfig;
|
||||||
|
import com.qcloud.cos.request.UploadFileRequest;
|
||||||
|
import com.qcloud.cos.sign.Credentials;
|
||||||
|
import com.ruoyi.framework.web.exception.user.OssException;
|
||||||
|
|
||||||
|
import net.sf.json.JSONObject;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 腾讯云存储
|
||||||
|
*/
|
||||||
|
public class QcloudCloudStorageService extends CloudStorageService
|
||||||
|
{
|
||||||
|
private COSClient client;
|
||||||
|
|
||||||
|
public QcloudCloudStorageService(CloudStorageConfig config)
|
||||||
|
{
|
||||||
|
this.config = config;
|
||||||
|
// 初始化
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void init()
|
||||||
|
{
|
||||||
|
Credentials credentials = new Credentials(config.getQcloudAppId(), config.getQcloudSecretId(),
|
||||||
|
config.getQcloudSecretKey());
|
||||||
|
// 初始化客户端配置
|
||||||
|
ClientConfig clientConfig = new ClientConfig();
|
||||||
|
// 设置bucket所在的区域,华南:gz 华北:tj 华东:sh
|
||||||
|
clientConfig.setRegion(config.getQcloudRegion());
|
||||||
|
client = new COSClient(clientConfig, credentials);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String upload(byte[] data, String path)
|
||||||
|
{
|
||||||
|
// 腾讯云必需要以"/"开头
|
||||||
|
if (!path.startsWith("/"))
|
||||||
|
{
|
||||||
|
path = "/" + path;
|
||||||
|
}
|
||||||
|
// 上传到腾讯云
|
||||||
|
UploadFileRequest request = new UploadFileRequest(config.getQcloudBucketName(), path, data);
|
||||||
|
String response = client.uploadFile(request);
|
||||||
|
JSONObject jsonObject = JSONObject.fromObject(response);
|
||||||
|
if (jsonObject.getInt("code") != 0)
|
||||||
|
{
|
||||||
|
throw new OssException("文件上传失败," + jsonObject.getString("message"));
|
||||||
|
}
|
||||||
|
return config.getQcloudDomain() + path;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String upload(InputStream inputStream, String path)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
byte[] data = IOUtils.toByteArray(inputStream);
|
||||||
|
return this.upload(data, path);
|
||||||
|
}
|
||||||
|
catch (IOException e)
|
||||||
|
{
|
||||||
|
throw new OssException("上传文件失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String uploadSuffix(byte[] data, String suffix)
|
||||||
|
{
|
||||||
|
return upload(data, getPath(config.getQcloudPrefix(), suffix));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String uploadSuffix(InputStream inputStream, String suffix)
|
||||||
|
{
|
||||||
|
return upload(inputStream, getPath(config.getQcloudPrefix(), suffix));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,81 @@
|
||||||
|
package com.ruoyi.web.controller.system.cloud;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
import org.apache.commons.io.IOUtils;
|
||||||
|
|
||||||
|
import com.qiniu.common.Zone;
|
||||||
|
import com.qiniu.http.Response;
|
||||||
|
import com.qiniu.storage.Configuration;
|
||||||
|
import com.qiniu.storage.UploadManager;
|
||||||
|
import com.qiniu.util.Auth;
|
||||||
|
import com.ruoyi.framework.web.exception.user.OssException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 七牛云存储
|
||||||
|
*/
|
||||||
|
public class QiniuCloudStorageService extends CloudStorageService
|
||||||
|
{
|
||||||
|
private UploadManager uploadManager;
|
||||||
|
|
||||||
|
private String token;
|
||||||
|
|
||||||
|
public QiniuCloudStorageService(CloudStorageConfig config)
|
||||||
|
{
|
||||||
|
this.config = config;
|
||||||
|
// 初始化
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void init()
|
||||||
|
{
|
||||||
|
uploadManager = new UploadManager(new Configuration(Zone.autoZone()));
|
||||||
|
token = Auth.create(config.getQiniuAccessKey(), config.getQiniuSecretKey())
|
||||||
|
.uploadToken(config.getQiniuBucketName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String upload(byte[] data, String path)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Response res = uploadManager.put(data, path, token);
|
||||||
|
if (!res.isOK())
|
||||||
|
{
|
||||||
|
throw new RuntimeException("上传七牛出错:" + res.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
throw new OssException("上传文件失败,请核对七牛配置信息");
|
||||||
|
}
|
||||||
|
return config.getQiniuDomain() + "/" + path;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String upload(InputStream inputStream, String path)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
byte[] data = IOUtils.toByteArray(inputStream);
|
||||||
|
return this.upload(data, path);
|
||||||
|
}
|
||||||
|
catch (IOException e)
|
||||||
|
{
|
||||||
|
throw new OssException("上传文件失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String uploadSuffix(byte[] data, String suffix)
|
||||||
|
{
|
||||||
|
return upload(data, getPath(config.getQiniuPrefix(), suffix));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String uploadSuffix(InputStream inputStream, String suffix)
|
||||||
|
{
|
||||||
|
return upload(inputStream, getPath(config.getQiniuPrefix(), suffix));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
package com.ruoyi.web.controller.system.cloud.valdator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 阿里云
|
||||||
|
*/
|
||||||
|
public interface AliyunGroup
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
package com.ruoyi.web.controller.system.cloud.valdator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 腾讯云
|
||||||
|
*/
|
||||||
|
public interface QcloudGroup
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
package com.ruoyi.web.controller.system.cloud.valdator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 七牛
|
||||||
|
*/
|
||||||
|
public interface QiniuGroup
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
@ -2,7 +2,14 @@ package com.ruoyi.web.core.config;
|
||||||
|
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
import com.google.common.base.Function;
|
||||||
|
import com.google.common.base.Optional;
|
||||||
|
import com.google.common.base.Predicate;
|
||||||
import com.ruoyi.common.config.Global;
|
import com.ruoyi.common.config.Global;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import springfox.documentation.RequestHandler;
|
||||||
import springfox.documentation.builders.ApiInfoBuilder;
|
import springfox.documentation.builders.ApiInfoBuilder;
|
||||||
import springfox.documentation.builders.PathSelectors;
|
import springfox.documentation.builders.PathSelectors;
|
||||||
import springfox.documentation.builders.RequestHandlerSelectors;
|
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||||
|
|
@ -29,13 +36,12 @@ public class SwaggerConfig
|
||||||
{
|
{
|
||||||
return new Docket(DocumentationType.SWAGGER_2)
|
return new Docket(DocumentationType.SWAGGER_2)
|
||||||
// 详细定制
|
// 详细定制
|
||||||
.apiInfo(apiInfo())
|
.apiInfo(apiInfo()).select().apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
|
||||||
.select()
|
|
||||||
// 指定当前包路径
|
// 指定当前包路径
|
||||||
.apis(RequestHandlerSelectors.basePackage("com.ruoyi.web.controller.tool"))
|
// .apis(RequestHandlerSelectors.basePackage("com.ruoyi.web.controller.tool"))
|
||||||
|
// .apis(basePackage("com.ruoyi.web.controller.system,com.ruoyi.web.controller.tool"))
|
||||||
// 扫描所有 .apis(RequestHandlerSelectors.any())
|
// 扫描所有 .apis(RequestHandlerSelectors.any())
|
||||||
.paths(PathSelectors.any())
|
.paths(PathSelectors.any()).build();
|
||||||
.build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -44,11 +50,62 @@ public class SwaggerConfig
|
||||||
private ApiInfo apiInfo()
|
private ApiInfo apiInfo()
|
||||||
{
|
{
|
||||||
// 用ApiInfoBuilder进行定制
|
// 用ApiInfoBuilder进行定制
|
||||||
return new ApiInfoBuilder()
|
return new ApiInfoBuilder().title("标题:若依管理系统_接口文档").description("描述:用于管理集团旗下公司的人员信息,具体包括XXX,XXX模块...")
|
||||||
.title("标题:若依管理系统_接口文档")
|
.contact(new Contact(Global.getName(), null, null)).version("版本号:" + Global.getVersion()).build();
|
||||||
.description("描述:用于管理集团旗下公司的人员信息,具体包括XXX,XXX模块...")
|
}
|
||||||
.contact(new Contact(Global.getName(), null, null))
|
|
||||||
.version("版本号:" + Global.getVersion())
|
/**
|
||||||
.build();
|
* Predicate that matches RequestHandler with given base package name for the class of the handler method.
|
||||||
|
* This predicate includes all request handlers matching the provided basePackage
|
||||||
|
*
|
||||||
|
* @param basePackage - base package of the classes
|
||||||
|
* @return this
|
||||||
|
*/
|
||||||
|
public static Predicate<RequestHandler> basePackage(final String basePackage)
|
||||||
|
{
|
||||||
|
return new Predicate<RequestHandler>()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public boolean apply(RequestHandler input)
|
||||||
|
{
|
||||||
|
return declaringClass(input).transform(handlerPackage(basePackage)).or(true);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理包路径配置规则,支持多路径扫描匹配以逗号隔开
|
||||||
|
*
|
||||||
|
* @param basePackage 扫描包路径
|
||||||
|
* @return Function
|
||||||
|
*/
|
||||||
|
private static Function<Class<?>, Boolean> handlerPackage(final String basePackage)
|
||||||
|
{
|
||||||
|
return new Function<Class<?>, Boolean>()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public Boolean apply(Class<?> input)
|
||||||
|
{
|
||||||
|
for (String strPackage : basePackage.split(","))
|
||||||
|
{
|
||||||
|
boolean isMatch = input.getPackage().getName().startsWith(strPackage);
|
||||||
|
if (isMatch)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param input RequestHandler
|
||||||
|
* @return Optional
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
private static Optional<? extends Class<?>> declaringClass(RequestHandler input)
|
||||||
|
{
|
||||||
|
return Optional.fromNullable(input.declaringClass());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
# 数据源配置
|
||||||
|
spring:
|
||||||
|
datasource:
|
||||||
|
type: com.alibaba.druid.pool.DruidDataSource
|
||||||
|
driverClassName: com.mysql.jdbc.Driver
|
||||||
|
druid:
|
||||||
|
# 主库数据源
|
||||||
|
master:
|
||||||
|
url: jdbc:mysql://localhost:3306/ry?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true
|
||||||
|
username: root
|
||||||
|
password: root
|
||||||
|
# 从库数据源
|
||||||
|
slave:
|
||||||
|
# 从数据源开关/默认关闭
|
||||||
|
enabled: true
|
||||||
|
url: jdbc:mysql://localhost:3306/ry?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true
|
||||||
|
username: root
|
||||||
|
password: root
|
||||||
|
# 初始连接数
|
||||||
|
initial-size: 10
|
||||||
|
# 最大连接池数量
|
||||||
|
max-active: 100
|
||||||
|
# 最小连接池数量
|
||||||
|
min-idle: 10
|
||||||
|
# 配置获取连接等待超时的时间
|
||||||
|
max-wait: 60000
|
||||||
|
# 打开PSCache,并且指定每个连接上PSCache的大小
|
||||||
|
pool-prepared-statements: true
|
||||||
|
max-pool-prepared-statement-per-connection-size: 20
|
||||||
|
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
|
||||||
|
timeBetweenEvictionRunsMillis: 60000
|
||||||
|
# 配置一个连接在池中最小生存的时间,单位是毫秒
|
||||||
|
min-evictable-idle-time-millis: 300000
|
||||||
|
validation-query: SELECT 1 FROM DUAL
|
||||||
|
test-while-idle: true
|
||||||
|
test-on-borrow: false
|
||||||
|
test-on-return: false
|
||||||
|
stat-view-servlet:
|
||||||
|
enabled: true
|
||||||
|
url-pattern: /monitor/druid/*
|
||||||
|
filter:
|
||||||
|
stat:
|
||||||
|
log-slow-sql: true
|
||||||
|
slow-sql-millis: 1000
|
||||||
|
merge-sql: false
|
||||||
|
wall:
|
||||||
|
config:
|
||||||
|
multi-statement-allow: true
|
||||||
|
|
@ -8,7 +8,7 @@ spring:
|
||||||
master:
|
master:
|
||||||
url: jdbc:mysql://localhost:3306/ry?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true
|
url: jdbc:mysql://localhost:3306/ry?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true
|
||||||
username: root
|
username: root
|
||||||
password: password
|
password: root
|
||||||
# 从库数据源
|
# 从库数据源
|
||||||
slave:
|
slave:
|
||||||
# 从数据源开关/默认关闭
|
# 从数据源开关/默认关闭
|
||||||
|
|
@ -55,7 +55,7 @@ spring:
|
||||||
time-zone: GMT+8
|
time-zone: GMT+8
|
||||||
date-format: yyyy-MM-dd HH:mm:ss
|
date-format: yyyy-MM-dd HH:mm:ss
|
||||||
profiles:
|
profiles:
|
||||||
active: druid
|
active: dev
|
||||||
# 文件上传
|
# 文件上传
|
||||||
servlet:
|
servlet:
|
||||||
multipart:
|
multipart:
|
||||||
|
|
@ -66,6 +66,9 @@ spring:
|
||||||
restart:
|
restart:
|
||||||
# 热部署开关
|
# 热部署开关
|
||||||
enabled: true
|
enabled: true
|
||||||
|
output:
|
||||||
|
ansi:
|
||||||
|
enabled: always
|
||||||
|
|
||||||
# MyBatis
|
# MyBatis
|
||||||
mybatis:
|
mybatis:
|
||||||
|
|
@ -73,8 +76,10 @@ mybatis:
|
||||||
typeAliasesPackage: com.ruoyi
|
typeAliasesPackage: com.ruoyi
|
||||||
# 配置mapper的扫描,找到所有的mapper.xml映射文件
|
# 配置mapper的扫描,找到所有的mapper.xml映射文件
|
||||||
mapperLocations: classpath*:mapper/**/*Mapper.xml
|
mapperLocations: classpath*:mapper/**/*Mapper.xml
|
||||||
# 加载全局的配置文件
|
|
||||||
configLocation: classpath:mapper/mybatis-config.xml
|
mapper:
|
||||||
|
not-empty: true
|
||||||
|
identity: MYSQL
|
||||||
|
|
||||||
# PageHelper分页插件
|
# PageHelper分页插件
|
||||||
pagehelper:
|
pagehelper:
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,206 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!-- 日志级别从低到高分为TRACE < DEBUG < INFO < WARN < ERROR < FATAL,如果设置为WARN,则低于WARN的信息都不会输出 -->
|
||||||
|
<!-- scan:当此属性设置为true时,配置文档如果发生改变,将会被重新加载,默认值为true -->
|
||||||
|
<!-- scanPeriod:设置监测配置文档是否有修改的时间间隔,如果没有给出时间单位,默认单位是毫秒。 当scan为true时,此属性生效。默认的时间间隔为1分钟。 -->
|
||||||
|
<!-- debug:当此属性设置为true时,将打印出logback内部日志信息,实时查看logback运行状态。默认值为false。 -->
|
||||||
|
<configuration scan="true" scanPeriod="60 seconds"
|
||||||
|
debug="false">
|
||||||
|
<contextName>ruoyi</contextName>
|
||||||
|
|
||||||
|
<!-- <springProperty scope="context" name="logPath" source="logging.path"
|
||||||
|
defaultValue="logs"/> -->
|
||||||
|
<!-- name的值是变量的名称,value的值时变量定义的值。通过定义的值会被插入到logger上下文中。定义后,可以使“${}”来使用变量。 -->
|
||||||
|
<property name="log.path" value="logs/" />
|
||||||
|
|
||||||
|
<!--0. 日志格式和颜色渲染 -->
|
||||||
|
<!-- 彩色日志依赖的渲染类 -->
|
||||||
|
<conversionRule conversionWord="clr"
|
||||||
|
converterClass="org.springframework.boot.logging.logback.ColorConverter" />
|
||||||
|
<conversionRule conversionWord="wex"
|
||||||
|
converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter" />
|
||||||
|
<conversionRule conversionWord="wEx"
|
||||||
|
converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter" />
|
||||||
|
<!-- 彩色日志格式 -->
|
||||||
|
<property name="CONSOLE_LOG_PATTERN"
|
||||||
|
value="${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}" />
|
||||||
|
|
||||||
|
<!--1. 输出到控制台 -->
|
||||||
|
<appender name="CONSOLE"
|
||||||
|
class="ch.qos.logback.core.ConsoleAppender">
|
||||||
|
<!-- 此日志appender是为开发使用,只配置最底级别,控制台输出的日志级别是大于或等于此级别的日志信息 -->
|
||||||
|
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
|
||||||
|
<level>debug</level>
|
||||||
|
</filter>
|
||||||
|
<encoder>
|
||||||
|
<Pattern>${CONSOLE_LOG_PATTERN}</Pattern>
|
||||||
|
<!-- 设置字符集 -->
|
||||||
|
<charset>UTF-8</charset>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!--2. 输出到文档 -->
|
||||||
|
<!-- 2.1 level为 DEBUG 日志,时间滚动输出 -->
|
||||||
|
<appender name="DEBUG_FILE"
|
||||||
|
class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
|
<!-- 正在记录的日志文档的路径及文档名 -->
|
||||||
|
<file>${log.path}/web_debug.log</file>
|
||||||
|
<!--日志文档输出格式 -->
|
||||||
|
<encoder>
|
||||||
|
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} -
|
||||||
|
%msg%n</pattern>
|
||||||
|
<charset>UTF-8</charset> <!-- 设置字符集 -->
|
||||||
|
</encoder>
|
||||||
|
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
|
||||||
|
<rollingPolicy
|
||||||
|
class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||||
|
<!-- 日志归档 -->
|
||||||
|
<fileNamePattern>${log.path}/web-debug-%d{yyyy-MM-dd}.%i.log
|
||||||
|
</fileNamePattern>
|
||||||
|
<timeBasedFileNamingAndTriggeringPolicy
|
||||||
|
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
|
||||||
|
<maxFileSize>100MB</maxFileSize>
|
||||||
|
</timeBasedFileNamingAndTriggeringPolicy>
|
||||||
|
<!--日志文档保留天数 -->
|
||||||
|
<maxHistory>15</maxHistory>
|
||||||
|
</rollingPolicy>
|
||||||
|
<!-- 此日志文档只记录debug级别的 -->
|
||||||
|
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||||
|
<level>debug</level>
|
||||||
|
<onMatch>ACCEPT</onMatch>
|
||||||
|
<onMismatch>DENY</onMismatch>
|
||||||
|
</filter>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<!-- 2.2 level为 INFO 日志,时间滚动输出 -->
|
||||||
|
<appender name="INFO_FILE"
|
||||||
|
class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
|
<!-- 正在记录的日志文档的路径及文档名 -->
|
||||||
|
<file>${log.path}/web_info.log</file>
|
||||||
|
<!--日志文档输出格式 -->
|
||||||
|
<encoder>
|
||||||
|
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} -
|
||||||
|
%msg%n</pattern>
|
||||||
|
<charset>UTF-8</charset>
|
||||||
|
</encoder>
|
||||||
|
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
|
||||||
|
<rollingPolicy
|
||||||
|
class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||||
|
<!-- 每天日志归档路径以及格式 -->
|
||||||
|
<fileNamePattern>${log.path}/web-info-%d{yyyy-MM-dd}.%i.log
|
||||||
|
</fileNamePattern>
|
||||||
|
<timeBasedFileNamingAndTriggeringPolicy
|
||||||
|
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
|
||||||
|
<maxFileSize>100MB</maxFileSize>
|
||||||
|
</timeBasedFileNamingAndTriggeringPolicy>
|
||||||
|
<!--日志文档保留天数 -->
|
||||||
|
<maxHistory>15</maxHistory>
|
||||||
|
</rollingPolicy>
|
||||||
|
<!-- 此日志文档只记录info级别的 -->
|
||||||
|
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||||
|
<level>info</level>
|
||||||
|
<onMatch>ACCEPT</onMatch>
|
||||||
|
<onMismatch>DENY</onMismatch>
|
||||||
|
</filter>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<!-- 2.3 level为 WARN 日志,时间滚动输出 -->
|
||||||
|
<appender name="WARN_FILE"
|
||||||
|
class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
|
<!-- 正在记录的日志文档的路径及文档名 -->
|
||||||
|
<file>${log.path}/web_warn.log</file>
|
||||||
|
<!--日志文档输出格式 -->
|
||||||
|
<encoder>
|
||||||
|
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} -
|
||||||
|
%msg%n</pattern>
|
||||||
|
<charset>UTF-8</charset> <!-- 此处设置字符集 -->
|
||||||
|
</encoder>
|
||||||
|
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
|
||||||
|
<rollingPolicy
|
||||||
|
class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||||
|
<fileNamePattern>${log.path}/web-warn-%d{yyyy-MM-dd}.%i.log
|
||||||
|
</fileNamePattern>
|
||||||
|
<timeBasedFileNamingAndTriggeringPolicy
|
||||||
|
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
|
||||||
|
<maxFileSize>100MB</maxFileSize>
|
||||||
|
</timeBasedFileNamingAndTriggeringPolicy>
|
||||||
|
<!--日志文档保留天数 -->
|
||||||
|
<maxHistory>15</maxHistory>
|
||||||
|
</rollingPolicy>
|
||||||
|
<!-- 此日志文档只记录warn级别的 -->
|
||||||
|
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||||
|
<level>warn</level>
|
||||||
|
<onMatch>ACCEPT</onMatch>
|
||||||
|
<onMismatch>DENY</onMismatch>
|
||||||
|
</filter>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<!-- 2.4 level为 ERROR 日志,时间滚动输出 -->
|
||||||
|
<appender name="ERROR_FILE"
|
||||||
|
class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
|
<!-- 正在记录的日志文档的路径及文档名 -->
|
||||||
|
<file>${log.path}/web_error.log</file>
|
||||||
|
<!--日志文档输出格式 -->
|
||||||
|
<encoder>
|
||||||
|
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} -
|
||||||
|
%msg%n</pattern>
|
||||||
|
<charset>UTF-8</charset> <!-- 此处设置字符集 -->
|
||||||
|
</encoder>
|
||||||
|
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
|
||||||
|
<rollingPolicy
|
||||||
|
class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||||
|
<fileNamePattern>${log.path}/web-error-%d{yyyy-MM-dd}.%i.log
|
||||||
|
</fileNamePattern>
|
||||||
|
<timeBasedFileNamingAndTriggeringPolicy
|
||||||
|
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
|
||||||
|
<maxFileSize>100MB</maxFileSize>
|
||||||
|
</timeBasedFileNamingAndTriggeringPolicy>
|
||||||
|
<!--日志文档保留天数 -->
|
||||||
|
<maxHistory>15</maxHistory>
|
||||||
|
</rollingPolicy>
|
||||||
|
<!-- 此日志文档只记录ERROR级别的 -->
|
||||||
|
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||||
|
<level>ERROR</level>
|
||||||
|
<onMatch>ACCEPT</onMatch>
|
||||||
|
<onMismatch>DENY</onMismatch>
|
||||||
|
</filter>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- <logger>用来设置某一个包或者具体的某一个类的日志打印级别、 以及指定<appender>。<logger>仅有一个name属性,
|
||||||
|
一个可选的level和一个可选的addtivity属性。 name:用来指定受此logger约束的某一个包或者具体的某一个类。 level:用来设置打印级别,大小写无关:TRACE,
|
||||||
|
DEBUG, INFO, WARN, ERROR, ALL 和 OFF, 还有一个特俗值INHERITED或者同义词NULL,代表强制执行上级的级别。
|
||||||
|
如果未设置此属性,那么当前logger将会继承上级的级别。 addtivity:是否向上级logger传递打印信息。默认是true。 <logger
|
||||||
|
name="org.springframework.web" level="info"/> <logger name="org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor"
|
||||||
|
level="INFO"/> -->
|
||||||
|
|
||||||
|
<!-- 使用mybatis的时候,sql语句是debug下才会打印,而这里我们只配置了info,所以想要查看sql语句的话,有以下两种操作:
|
||||||
|
第一种把<root level="info">改成<root level="DEBUG">这样就会打印sql,不过这样日志那边会出现很多其他消息
|
||||||
|
第二种就是单独给dao下目录配置debug模式,代码如下,这样配置sql语句会打印,其他还是正常info级别: 【logging.level.org.mybatis=debug
|
||||||
|
logging.level.dao=debug】 -->
|
||||||
|
|
||||||
|
<!-- root节点是必选节点,用来指定最基础的日志输出级别,只有一个level属性 level:用来设置打印级别,大小写无关:TRACE,
|
||||||
|
DEBUG, INFO, WARN, ERROR, ALL 和 OFF, 不能设置为INHERITED或者同义词NULL。默认是DEBUG 可以包含零个或多个元素,标识这个appender将会添加到这个logger。 -->
|
||||||
|
|
||||||
|
<!-- 4. 最终的策略 -->
|
||||||
|
<!-- 4.1 开发环境:打印控制台 -->
|
||||||
|
<springProfile name="dev">
|
||||||
|
<root level="info">
|
||||||
|
<appender-ref ref="CONSOLE" />
|
||||||
|
</root>
|
||||||
|
</springProfile>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- 4.2 生产环境:输出到文档 -->
|
||||||
|
<springProfile name="prod">
|
||||||
|
<root level="info">
|
||||||
|
<appender-ref ref="CONSOLE" />
|
||||||
|
<appender-ref ref="DEBUG_FILE" />
|
||||||
|
<appender-ref ref="INFO_FILE" />
|
||||||
|
<appender-ref ref="WARN_FILE" />
|
||||||
|
<appender-ref ref="ERROR_FILE" />
|
||||||
|
</root>
|
||||||
|
</springProfile>
|
||||||
|
|
||||||
|
</configuration>
|
||||||
|
|
@ -1,86 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<configuration>
|
|
||||||
|
|
||||||
<property name="log.path" value="/home/ruoyi/logs" />
|
|
||||||
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />
|
|
||||||
|
|
||||||
<!-- 控制台输出 -->
|
|
||||||
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
|
||||||
<encoder>
|
|
||||||
<pattern>${log.pattern}</pattern>
|
|
||||||
</encoder>
|
|
||||||
</appender>
|
|
||||||
|
|
||||||
<!-- 系统日志输出 -->
|
|
||||||
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
|
||||||
<file>${log.path}/sys-info.log</file>
|
|
||||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
|
||||||
<!-- 按天回滚 daily -->
|
|
||||||
<fileNamePattern>${log.path}/sys-info.%d{yyyy-MM-dd}.log</fileNamePattern>
|
|
||||||
<!-- 日志最大的历史 60天 -->
|
|
||||||
<maxHistory>60</maxHistory>
|
|
||||||
</rollingPolicy>
|
|
||||||
<encoder>
|
|
||||||
<pattern>${log.pattern}</pattern>
|
|
||||||
</encoder>
|
|
||||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
|
||||||
<level>INFO</level>
|
|
||||||
<onMatch>ACCEPT</onMatch>
|
|
||||||
<onMismatch>DENY</onMismatch>
|
|
||||||
</filter>
|
|
||||||
</appender>
|
|
||||||
|
|
||||||
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
|
||||||
<file>${log.path}/sys-error.log</file>
|
|
||||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
|
||||||
<fileNamePattern>${log.path}/sys-error.%d{yyyy-MM-dd}.log</fileNamePattern>
|
|
||||||
<!-- 日志最大的历史 60天 -->
|
|
||||||
<maxHistory>60</maxHistory>
|
|
||||||
</rollingPolicy>
|
|
||||||
<encoder>
|
|
||||||
<pattern>${log.pattern}</pattern>
|
|
||||||
</encoder>
|
|
||||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
|
||||||
<level>ERROR</level>
|
|
||||||
<onMatch>ACCEPT</onMatch>
|
|
||||||
<onMismatch>DENY</onMismatch>
|
|
||||||
</filter>
|
|
||||||
</appender>
|
|
||||||
|
|
||||||
<!-- 用户访问日志输出 -->
|
|
||||||
<appender name="sys-user" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
|
||||||
<file>${log.path}/sys-user.log</file>
|
|
||||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
|
||||||
<!-- 按天回滚 daily -->
|
|
||||||
<fileNamePattern>${log.path}/sys-user.%d{yyyy-MM-dd}.log</fileNamePattern>
|
|
||||||
<!-- 日志最大的历史 60天 -->
|
|
||||||
<maxHistory>60</maxHistory>
|
|
||||||
</rollingPolicy>
|
|
||||||
<encoder>
|
|
||||||
<pattern>${log.pattern}</pattern>
|
|
||||||
</encoder>
|
|
||||||
</appender>
|
|
||||||
|
|
||||||
<!-- 显示形成的sql、使用的参数、结果集 -->
|
|
||||||
<!--
|
|
||||||
<logger name="java.sql" level="debug" />
|
|
||||||
<logger name="org.springframework.jdbc" level="debug" />
|
|
||||||
-->
|
|
||||||
|
|
||||||
<logger name="com.ruoyi" level="info" />
|
|
||||||
|
|
||||||
<root level="info">
|
|
||||||
<appender-ref ref="console" />
|
|
||||||
</root>
|
|
||||||
|
|
||||||
<!--系统操作日志-->
|
|
||||||
<root level="info">
|
|
||||||
<appender-ref ref="file_info" />
|
|
||||||
<appender-ref ref="file_error" />
|
|
||||||
</root>
|
|
||||||
|
|
||||||
<!--系统用户操作日志-->
|
|
||||||
<logger name="sys-user" level="info">
|
|
||||||
<appender-ref ref="sys-user"/>
|
|
||||||
</logger>
|
|
||||||
</configuration>
|
|
||||||
|
|
@ -0,0 +1,673 @@
|
||||||
|
/**
|
||||||
|
* AJAX Upload ( http://valums.com/ajax-upload/ )
|
||||||
|
* Copyright (c) Andris Valums
|
||||||
|
* Licensed under the MIT license ( http://valums.com/mit-license/ )
|
||||||
|
* Thanks to Gary Haran, David Mark, Corey Burns and others for contributions
|
||||||
|
*/
|
||||||
|
(function () {
|
||||||
|
/* global window */
|
||||||
|
/* jslint browser: true, devel: true, undef: true, nomen: true, bitwise: true, regexp: true, newcap: true, immed: true */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wrapper for FireBug's console.log
|
||||||
|
*/
|
||||||
|
function log(){
|
||||||
|
if (typeof(console) != 'undefined' && typeof(console.log) == 'function'){
|
||||||
|
Array.prototype.unshift.call(arguments, '[Ajax Upload]');
|
||||||
|
console.log( Array.prototype.join.call(arguments, ' '));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attaches event to a dom element.
|
||||||
|
* @param {Element} el
|
||||||
|
* @param type event name
|
||||||
|
* @param fn callback This refers to the passed element
|
||||||
|
*/
|
||||||
|
function addEvent(el, type, fn){
|
||||||
|
if (el.addEventListener) {
|
||||||
|
el.addEventListener(type, fn, false);
|
||||||
|
} else if (el.attachEvent) {
|
||||||
|
el.attachEvent('on' + type, function(){
|
||||||
|
fn.call(el);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
throw new Error('not supported or DOM not loaded');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attaches resize event to a window, limiting
|
||||||
|
* number of event fired. Fires only when encounteres
|
||||||
|
* delay of 100 after series of events.
|
||||||
|
*
|
||||||
|
* Some browsers fire event multiple times when resizing
|
||||||
|
* http://www.quirksmode.org/dom/events/resize.html
|
||||||
|
*
|
||||||
|
* @param fn callback This refers to the passed element
|
||||||
|
*/
|
||||||
|
function addResizeEvent(fn){
|
||||||
|
var timeout;
|
||||||
|
|
||||||
|
addEvent(window, 'resize', function(){
|
||||||
|
if (timeout){
|
||||||
|
clearTimeout(timeout);
|
||||||
|
}
|
||||||
|
timeout = setTimeout(fn, 100);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Needs more testing, will be rewriten for next version
|
||||||
|
// getOffset function copied from jQuery lib (http://jquery.com/)
|
||||||
|
if (document.documentElement.getBoundingClientRect){
|
||||||
|
// Get Offset using getBoundingClientRect
|
||||||
|
// http://ejohn.org/blog/getboundingclientrect-is-awesome/
|
||||||
|
var getOffset = function(el){
|
||||||
|
var box = el.getBoundingClientRect();
|
||||||
|
var doc = el.ownerDocument;
|
||||||
|
var body = doc.body;
|
||||||
|
var docElem = doc.documentElement; // for ie
|
||||||
|
var clientTop = docElem.clientTop || body.clientTop || 0;
|
||||||
|
var clientLeft = docElem.clientLeft || body.clientLeft || 0;
|
||||||
|
|
||||||
|
// In Internet Explorer 7 getBoundingClientRect property is treated as physical,
|
||||||
|
// while others are logical. Make all logical, like in IE8.
|
||||||
|
var zoom = 1;
|
||||||
|
if (body.getBoundingClientRect) {
|
||||||
|
var bound = body.getBoundingClientRect();
|
||||||
|
zoom = (bound.right - bound.left) / body.clientWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (zoom > 1) {
|
||||||
|
clientTop = 0;
|
||||||
|
clientLeft = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
var top = box.top / zoom + (window.pageYOffset || docElem && docElem.scrollTop / zoom || body.scrollTop / zoom) - clientTop, left = box.left / zoom + (window.pageXOffset || docElem && docElem.scrollLeft / zoom || body.scrollLeft / zoom) - clientLeft;
|
||||||
|
|
||||||
|
return {
|
||||||
|
top: top,
|
||||||
|
left: left
|
||||||
|
};
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
// Get offset adding all offsets
|
||||||
|
var getOffset = function(el){
|
||||||
|
var top = 0, left = 0;
|
||||||
|
do {
|
||||||
|
top += el.offsetTop || 0;
|
||||||
|
left += el.offsetLeft || 0;
|
||||||
|
el = el.offsetParent;
|
||||||
|
} while (el);
|
||||||
|
|
||||||
|
return {
|
||||||
|
left: left,
|
||||||
|
top: top
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns left, top, right and bottom properties describing the border-box,
|
||||||
|
* in pixels, with the top-left relative to the body
|
||||||
|
* @param {Element} el
|
||||||
|
* @return {Object} Contains left, top, right,bottom
|
||||||
|
*/
|
||||||
|
function getBox(el){
|
||||||
|
var left, right, top, bottom;
|
||||||
|
var offset = getOffset(el);
|
||||||
|
left = offset.left;
|
||||||
|
top = offset.top;
|
||||||
|
|
||||||
|
right = left + el.offsetWidth;
|
||||||
|
bottom = top + el.offsetHeight;
|
||||||
|
|
||||||
|
return {
|
||||||
|
left: left,
|
||||||
|
right: right,
|
||||||
|
top: top,
|
||||||
|
bottom: bottom
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper that takes object literal
|
||||||
|
* and add all properties to element.style
|
||||||
|
* @param {Element} el
|
||||||
|
* @param {Object} styles
|
||||||
|
*/
|
||||||
|
function addStyles(el, styles){
|
||||||
|
for (var name in styles) {
|
||||||
|
if (styles.hasOwnProperty(name)) {
|
||||||
|
el.style[name] = styles[name];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function places an absolutely positioned
|
||||||
|
* element on top of the specified element
|
||||||
|
* copying position and dimentions.
|
||||||
|
* @param {Element} from
|
||||||
|
* @param {Element} to
|
||||||
|
*/
|
||||||
|
function copyLayout(from, to){
|
||||||
|
var box = getBox(from);
|
||||||
|
|
||||||
|
addStyles(to, {
|
||||||
|
position: 'absolute',
|
||||||
|
left : box.left + 'px',
|
||||||
|
top : box.top + 'px',
|
||||||
|
width : from.offsetWidth + 'px',
|
||||||
|
height : from.offsetHeight + 'px'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates and returns element from html chunk
|
||||||
|
* Uses innerHTML to create an element
|
||||||
|
*/
|
||||||
|
var toElement = (function(){
|
||||||
|
var div = document.createElement('div');
|
||||||
|
return function(html){
|
||||||
|
div.innerHTML = html;
|
||||||
|
var el = div.firstChild;
|
||||||
|
return div.removeChild(el);
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function generates unique id
|
||||||
|
* @return unique id
|
||||||
|
*/
|
||||||
|
var getUID = (function(){
|
||||||
|
var id = 0;
|
||||||
|
return function(){
|
||||||
|
return 'ValumsAjaxUpload' + id++;
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get file name from path
|
||||||
|
* @param {String} file path to file
|
||||||
|
* @return filename
|
||||||
|
*/
|
||||||
|
function fileFromPath(file){
|
||||||
|
return file.replace(/.*(\/|\\)/, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get file extension lowercase
|
||||||
|
* @param {String} file name
|
||||||
|
* @return file extenstion
|
||||||
|
*/
|
||||||
|
function getExt(file){
|
||||||
|
return (-1 !== file.indexOf('.')) ? file.replace(/.*[.]/, '') : '';
|
||||||
|
}
|
||||||
|
|
||||||
|
function hasClass(el, name){
|
||||||
|
var re = new RegExp('\\b' + name + '\\b');
|
||||||
|
return re.test(el.className);
|
||||||
|
}
|
||||||
|
function addClass(el, name){
|
||||||
|
if ( ! hasClass(el, name)){
|
||||||
|
el.className += ' ' + name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function removeClass(el, name){
|
||||||
|
var re = new RegExp('\\b' + name + '\\b');
|
||||||
|
el.className = el.className.replace(re, '');
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeNode(el){
|
||||||
|
el.parentNode.removeChild(el);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Easy styling and uploading
|
||||||
|
* @constructor
|
||||||
|
* @param button An element you want convert to
|
||||||
|
* upload button. Tested dimentions up to 500x500px
|
||||||
|
* @param {Object} options See defaults below.
|
||||||
|
*/
|
||||||
|
window.AjaxUpload = function(button, options){
|
||||||
|
this._settings = {
|
||||||
|
// Location of the server-side upload script
|
||||||
|
action: 'upload.php',
|
||||||
|
// File upload name
|
||||||
|
name: 'userfile',
|
||||||
|
// Additional data to send
|
||||||
|
data: {},
|
||||||
|
// Submit file as soon as it's selected
|
||||||
|
autoSubmit: true,
|
||||||
|
// The type of data that you're expecting back from the server.
|
||||||
|
// html and xml are detected automatically.
|
||||||
|
// Only useful when you are using json data as a response.
|
||||||
|
// Set to "json" in that case.
|
||||||
|
responseType: false,
|
||||||
|
// Class applied to button when mouse is hovered
|
||||||
|
hoverClass: 'hover',
|
||||||
|
// Class applied to button when AU is disabled
|
||||||
|
disabledClass: 'disabled',
|
||||||
|
// When user selects a file, useful with autoSubmit disabled
|
||||||
|
// You can return false to cancel upload
|
||||||
|
onChange: function(file, extension){
|
||||||
|
},
|
||||||
|
// Callback to fire before file is uploaded
|
||||||
|
// You can return false to cancel upload
|
||||||
|
onSubmit: function(file, extension){
|
||||||
|
},
|
||||||
|
// Fired when file upload is completed
|
||||||
|
// WARNING! DO NOT USE "FALSE" STRING AS A RESPONSE!
|
||||||
|
onComplete: function(file, response){
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Merge the users options with our defaults
|
||||||
|
for (var i in options) {
|
||||||
|
if (options.hasOwnProperty(i)){
|
||||||
|
this._settings[i] = options[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// button isn't necessary a dom element
|
||||||
|
if (button.jquery){
|
||||||
|
// jQuery object was passed
|
||||||
|
button = button[0];
|
||||||
|
} else if (typeof button == "string") {
|
||||||
|
if (/^#.*/.test(button)){
|
||||||
|
// If jQuery user passes #elementId don't break it
|
||||||
|
button = button.slice(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
button = document.getElementById(button);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! button || button.nodeType !== 1){
|
||||||
|
throw new Error("Please make sure that you're passing a valid element");
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( button.nodeName.toUpperCase() == 'A'){
|
||||||
|
// disable link
|
||||||
|
addEvent(button, 'click', function(e){
|
||||||
|
if (e && e.preventDefault){
|
||||||
|
e.preventDefault();
|
||||||
|
} else if (window.event){
|
||||||
|
window.event.returnValue = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// DOM element
|
||||||
|
this._button = button;
|
||||||
|
// DOM element
|
||||||
|
this._input = null;
|
||||||
|
// If disabled clicking on button won't do anything
|
||||||
|
this._disabled = false;
|
||||||
|
|
||||||
|
// if the button was disabled before refresh if will remain
|
||||||
|
// disabled in FireFox, let's fix it
|
||||||
|
this.enable();
|
||||||
|
|
||||||
|
this._rerouteClicks();
|
||||||
|
};
|
||||||
|
|
||||||
|
// assigning methods to our class
|
||||||
|
AjaxUpload.prototype = {
|
||||||
|
setData: function(data){
|
||||||
|
this._settings.data = data;
|
||||||
|
},
|
||||||
|
disable: function(){
|
||||||
|
addClass(this._button, this._settings.disabledClass);
|
||||||
|
this._disabled = true;
|
||||||
|
|
||||||
|
var nodeName = this._button.nodeName.toUpperCase();
|
||||||
|
if (nodeName == 'INPUT' || nodeName == 'BUTTON'){
|
||||||
|
this._button.setAttribute('disabled', 'disabled');
|
||||||
|
}
|
||||||
|
|
||||||
|
// hide input
|
||||||
|
if (this._input){
|
||||||
|
// We use visibility instead of display to fix problem with Safari 4
|
||||||
|
// The problem is that the value of input doesn't change if it
|
||||||
|
// has display none when user selects a file
|
||||||
|
this._input.parentNode.style.visibility = 'hidden';
|
||||||
|
}
|
||||||
|
},
|
||||||
|
enable: function(){
|
||||||
|
removeClass(this._button, this._settings.disabledClass);
|
||||||
|
this._button.removeAttribute('disabled');
|
||||||
|
this._disabled = false;
|
||||||
|
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* Creates invisible file input
|
||||||
|
* that will hover above the button
|
||||||
|
* <div><input type='file' /></div>
|
||||||
|
*/
|
||||||
|
_createInput: function(){
|
||||||
|
var self = this;
|
||||||
|
|
||||||
|
var input = document.createElement("input");
|
||||||
|
input.setAttribute('type', 'file');
|
||||||
|
input.setAttribute('name', this._settings.name);
|
||||||
|
|
||||||
|
addStyles(input, {
|
||||||
|
'position' : 'absolute',
|
||||||
|
// in Opera only 'browse' button
|
||||||
|
// is clickable and it is located at
|
||||||
|
// the right side of the input
|
||||||
|
'right' : 0,
|
||||||
|
'margin' : 0,
|
||||||
|
'padding' : 0,
|
||||||
|
'fontSize' : '480px',
|
||||||
|
'cursor' : 'pointer'
|
||||||
|
});
|
||||||
|
|
||||||
|
var div = document.createElement("div");
|
||||||
|
addStyles(div, {
|
||||||
|
'display' : 'block',
|
||||||
|
'position' : 'absolute',
|
||||||
|
'overflow' : 'hidden',
|
||||||
|
'margin' : 0,
|
||||||
|
'padding' : 0,
|
||||||
|
'opacity' : 0,
|
||||||
|
// Make sure browse button is in the right side
|
||||||
|
// in Internet Explorer
|
||||||
|
'direction' : 'ltr',
|
||||||
|
//Max zIndex supported by Opera 9.0-9.2
|
||||||
|
'zIndex': 2147483583
|
||||||
|
});
|
||||||
|
|
||||||
|
// Make sure that element opacity exists.
|
||||||
|
// Otherwise use IE filter
|
||||||
|
if ( div.style.opacity !== "0") {
|
||||||
|
if (typeof(div.filters) == 'undefined'){
|
||||||
|
throw new Error('Opacity not supported by the browser');
|
||||||
|
}
|
||||||
|
div.style.filter = "alpha(opacity=0)";
|
||||||
|
}
|
||||||
|
|
||||||
|
addEvent(input, 'change', function(){
|
||||||
|
|
||||||
|
if ( ! input || input.value === ''){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get filename from input, required
|
||||||
|
// as some browsers have path instead of it
|
||||||
|
var file = fileFromPath(input.value);
|
||||||
|
|
||||||
|
if (false === self._settings.onChange.call(self, file, getExt(file))){
|
||||||
|
self._clearInput();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Submit form when value is changed
|
||||||
|
if (self._settings.autoSubmit) {
|
||||||
|
self.submit();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
addEvent(input, 'mouseover', function(){
|
||||||
|
addClass(self._button, self._settings.hoverClass);
|
||||||
|
});
|
||||||
|
|
||||||
|
addEvent(input, 'mouseout', function(){
|
||||||
|
removeClass(self._button, self._settings.hoverClass);
|
||||||
|
|
||||||
|
// We use visibility instead of display to fix problem with Safari 4
|
||||||
|
// The problem is that the value of input doesn't change if it
|
||||||
|
// has display none when user selects a file
|
||||||
|
input.parentNode.style.visibility = 'hidden';
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
div.appendChild(input);
|
||||||
|
document.body.appendChild(div);
|
||||||
|
|
||||||
|
this._input = input;
|
||||||
|
},
|
||||||
|
_clearInput : function(){
|
||||||
|
if (!this._input){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// this._input.value = ''; Doesn't work in IE6
|
||||||
|
removeNode(this._input.parentNode);
|
||||||
|
this._input = null;
|
||||||
|
this._createInput();
|
||||||
|
|
||||||
|
removeClass(this._button, this._settings.hoverClass);
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* Function makes sure that when user clicks upload button,
|
||||||
|
* the this._input is clicked instead
|
||||||
|
*/
|
||||||
|
_rerouteClicks: function(){
|
||||||
|
var self = this;
|
||||||
|
|
||||||
|
// IE will later display 'access denied' error
|
||||||
|
// if you use using self._input.click()
|
||||||
|
// other browsers just ignore click()
|
||||||
|
|
||||||
|
addEvent(self._button, 'mouseover', function(){
|
||||||
|
if (self._disabled){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! self._input){
|
||||||
|
self._createInput();
|
||||||
|
}
|
||||||
|
|
||||||
|
var div = self._input.parentNode;
|
||||||
|
copyLayout(self._button, div);
|
||||||
|
div.style.visibility = 'visible';
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// commented because we now hide input on mouseleave
|
||||||
|
/**
|
||||||
|
* When the window is resized the elements
|
||||||
|
* can be misaligned if button position depends
|
||||||
|
* on window size
|
||||||
|
*/
|
||||||
|
//addResizeEvent(function(){
|
||||||
|
// if (self._input){
|
||||||
|
// copyLayout(self._button, self._input.parentNode);
|
||||||
|
// }
|
||||||
|
//});
|
||||||
|
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* Creates iframe with unique name
|
||||||
|
* @return {Element} iframe
|
||||||
|
*/
|
||||||
|
_createIframe: function(){
|
||||||
|
// We can't use getTime, because it sometimes return
|
||||||
|
// same value in safari :(
|
||||||
|
var id = getUID();
|
||||||
|
|
||||||
|
// We can't use following code as the name attribute
|
||||||
|
// won't be properly registered in IE6, and new window
|
||||||
|
// on form submit will open
|
||||||
|
// var iframe = document.createElement('iframe');
|
||||||
|
// iframe.setAttribute('name', id);
|
||||||
|
|
||||||
|
var iframe = toElement('<iframe src="javascript:false;" name="' + id + '" />');
|
||||||
|
// src="javascript:false; was added
|
||||||
|
// because it possibly removes ie6 prompt
|
||||||
|
// "This page contains both secure and nonsecure items"
|
||||||
|
// Anyway, it doesn't do any harm.
|
||||||
|
iframe.setAttribute('id', id);
|
||||||
|
|
||||||
|
iframe.style.display = 'none';
|
||||||
|
document.body.appendChild(iframe);
|
||||||
|
|
||||||
|
return iframe;
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* Creates form, that will be submitted to iframe
|
||||||
|
* @param {Element} iframe Where to submit
|
||||||
|
* @return {Element} form
|
||||||
|
*/
|
||||||
|
_createForm: function(iframe){
|
||||||
|
var settings = this._settings;
|
||||||
|
|
||||||
|
// We can't use the following code in IE6
|
||||||
|
// var form = document.createElement('form');
|
||||||
|
// form.setAttribute('method', 'post');
|
||||||
|
// form.setAttribute('enctype', 'multipart/form-data');
|
||||||
|
// Because in this case file won't be attached to request
|
||||||
|
var form = toElement('<form method="post" enctype="multipart/form-data"></form>');
|
||||||
|
|
||||||
|
form.setAttribute('action', settings.action);
|
||||||
|
form.setAttribute('target', iframe.name);
|
||||||
|
form.style.display = 'none';
|
||||||
|
document.body.appendChild(form);
|
||||||
|
|
||||||
|
// Create hidden input element for each data key
|
||||||
|
for (var prop in settings.data) {
|
||||||
|
if (settings.data.hasOwnProperty(prop)){
|
||||||
|
var el = document.createElement("input");
|
||||||
|
el.setAttribute('type', 'hidden');
|
||||||
|
el.setAttribute('name', prop);
|
||||||
|
el.setAttribute('value', settings.data[prop]);
|
||||||
|
form.appendChild(el);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return form;
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* Gets response from iframe and fires onComplete event when ready
|
||||||
|
* @param iframe
|
||||||
|
* @param file Filename to use in onComplete callback
|
||||||
|
*/
|
||||||
|
_getResponse : function(iframe, file){
|
||||||
|
// getting response
|
||||||
|
var toDeleteFlag = false, self = this, settings = this._settings;
|
||||||
|
|
||||||
|
addEvent(iframe, 'load', function(){
|
||||||
|
|
||||||
|
if (// For Safari
|
||||||
|
iframe.src == "javascript:'%3Chtml%3E%3C/html%3E';" ||
|
||||||
|
// For FF, IE
|
||||||
|
iframe.src == "javascript:'<html></html>';"){
|
||||||
|
// First time around, do not delete.
|
||||||
|
// We reload to blank page, so that reloading main page
|
||||||
|
// does not re-submit the post.
|
||||||
|
|
||||||
|
if (toDeleteFlag) {
|
||||||
|
// Fix busy state in FF3
|
||||||
|
setTimeout(function(){
|
||||||
|
removeNode(iframe);
|
||||||
|
}, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var doc = iframe.contentDocument ? iframe.contentDocument : window.frames[iframe.id].document;
|
||||||
|
|
||||||
|
// fixing Opera 9.26,10.00
|
||||||
|
if (doc.readyState && doc.readyState != 'complete') {
|
||||||
|
// Opera fires load event multiple times
|
||||||
|
// Even when the DOM is not ready yet
|
||||||
|
// this fix should not affect other browsers
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// fixing Opera 9.64
|
||||||
|
if (doc.body && doc.body.innerHTML == "false") {
|
||||||
|
// In Opera 9.64 event was fired second time
|
||||||
|
// when body.innerHTML changed from false
|
||||||
|
// to server response approx. after 1 sec
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var response;
|
||||||
|
|
||||||
|
if (doc.XMLDocument) {
|
||||||
|
// response is a xml document Internet Explorer property
|
||||||
|
response = doc.XMLDocument;
|
||||||
|
} else if (doc.body){
|
||||||
|
// response is html document or plain text
|
||||||
|
response = doc.body.innerHTML;
|
||||||
|
|
||||||
|
if (settings.responseType && settings.responseType.toLowerCase() == 'json') {
|
||||||
|
// If the document was sent as 'application/javascript' or
|
||||||
|
// 'text/javascript', then the browser wraps the text in a <pre>
|
||||||
|
// tag and performs html encoding on the contents. In this case,
|
||||||
|
// we need to pull the original text content from the text node's
|
||||||
|
// nodeValue property to retrieve the unmangled content.
|
||||||
|
// Note that IE6 only understands text/html
|
||||||
|
if (doc.body.firstChild && doc.body.firstChild.nodeName.toUpperCase() == 'PRE') {
|
||||||
|
response = doc.body.firstChild.firstChild.nodeValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (response) {
|
||||||
|
response = eval("(" + response + ")");
|
||||||
|
} else {
|
||||||
|
response = {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// response is a xml document
|
||||||
|
response = doc;
|
||||||
|
}
|
||||||
|
|
||||||
|
settings.onComplete.call(self, file, response);
|
||||||
|
|
||||||
|
// Reload blank page, so that reloading main page
|
||||||
|
// does not re-submit the post. Also, remember to
|
||||||
|
// delete the frame
|
||||||
|
toDeleteFlag = true;
|
||||||
|
|
||||||
|
// Fix IE mixed content issue
|
||||||
|
iframe.src = "javascript:'<html></html>';";
|
||||||
|
});
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* Upload file contained in this._input
|
||||||
|
*/
|
||||||
|
submit: function(){
|
||||||
|
var self = this, settings = this._settings;
|
||||||
|
|
||||||
|
if ( ! this._input || this._input.value === ''){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var file = fileFromPath(this._input.value);
|
||||||
|
|
||||||
|
// user returned false to cancel upload
|
||||||
|
if (false === settings.onSubmit.call(this, file, getExt(file))){
|
||||||
|
this._clearInput();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// sending request
|
||||||
|
var iframe = this._createIframe();
|
||||||
|
var form = this._createForm(iframe);
|
||||||
|
|
||||||
|
// assuming following structure
|
||||||
|
// div -> input type='file'
|
||||||
|
removeNode(this._input.parentNode);
|
||||||
|
removeClass(self._button, self._settings.hoverClass);
|
||||||
|
|
||||||
|
form.appendChild(this._input);
|
||||||
|
|
||||||
|
form.submit();
|
||||||
|
|
||||||
|
// request set, clean up
|
||||||
|
removeNode(form); form = null;
|
||||||
|
removeNode(this._input); this._input = null;
|
||||||
|
|
||||||
|
// Get response from iframe and fire onComplete event when ready
|
||||||
|
this._getResponse(iframe, file);
|
||||||
|
|
||||||
|
// get ready for next request
|
||||||
|
this._createInput();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
|
@ -44,6 +44,5 @@
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<div th:include="include :: footer"></div>
|
<div th:include="include :: footer"></div>
|
||||||
</script>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
@ -0,0 +1,166 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<head th:include="include :: header"></head>
|
||||||
|
<body class="white-bg">
|
||||||
|
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
|
||||||
|
<form class="form-horizontal m" id="form-config-edit" th:object="${config}">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">存储类型:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<label class="radio-box"> <input type="radio" th:field="*{type}" name="type" value="1" /> 七牛 </label>
|
||||||
|
<label class="radio-box"> <input type="radio" th:field="*{type}" value="2" /> 阿里云 </label>
|
||||||
|
<label class="radio-box"> <input type="radio" th:field="*{type}" value="3" /> 腾讯云 </label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div id="qiniuDiv">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">域名:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input class="form-control" type="text" name="qiniuDomain" id="qiniuDomain" th:field="*{qiniuDomain}">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">路径前缀:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input id="qiniuPrefix" name="qiniuPrefix" class="form-control" type="text" th:field="*{qiniuPrefix}">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">AccessKey:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input id="qiniuAccessKey" name="qiniuAccessKey" class="form-control" type="text" th:field="*{qiniuAccessKey}">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">SecretKey:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input id="qiniuSecretKey" name="qiniuSecretKey" class="form-control" type="text" th:field="*{qiniuSecretKey}">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">空间名:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input id="qiniuBucketName" name="qiniuBucketName" class="form-control" type="text" th:field="*{qiniuBucketName}">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div id="aliyunDiv">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">域名:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input id="aliyunDomain" name="aliyunDomain" class="form-control" type="text" th:field="*{aliyunDomain}">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">路径前缀:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input id="aliyunPrefix" name="aliyunPrefix" class="form-control" type="text" th:field="*{aliyunPrefix}">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">EndPoint:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input id="aliyunEndPoint" name="aliyunEndPoint" class="form-control" type="text" th:field="*{aliyunEndPoint}">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">AccessKeyId:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input id="aliyunAccessKeyId" name="aliyunAccessKeyId" class="form-control" type="text" th:field="*{aliyunAccessKeyId}">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">AccessKeySecret:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input id="aliyunAccessKeySecret" name="aliyunAccessKeySecret" class="form-control" type="text" th:field="*{aliyunAccessKeySecret}">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">BucketName:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input id="aliyunBucketName" name="aliyunBucketName" class="form-control" type="text" th:field="*{aliyunBucketName}">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div id="qcloudDiv">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">域名:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input id="qcloudDomain" name="qcloudDomain" class="form-control" type="text" th:field="*{qcloudDomain}">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">路径前缀:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input id="qcloudPrefix" name="qcloudPrefix" class="form-control" type="text" th:field="*{qcloudPrefix}">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">腾讯云AppId:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input id="qcloudAppId" name="qcloudAppId" class="form-control" type="text" th:field="*{qcloudAppId}">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">腾讯云SecretId:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input id="qcloudSecretId" name="qcloudSecretId" class="form-control" type="text" th:field="*{qcloudSecretId}">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">腾讯云BucketName:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input id="qcloudBucketName" name="qcloudBucketName" class="form-control" type="text" th:field="*{qcloudBucketName}">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">Bucket所属地区:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input id="qcloudRegion" name="qcloudRegion" class="form-control" type="text" th:field="*{qcloudRegion}" placeholder="如:sh()可选值 ,华南:gz 华北:tj 华东:sh)"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<div th:include="include::footer"></div>
|
||||||
|
<script>
|
||||||
|
var prefix = ctx + "system/oss";
|
||||||
|
|
||||||
|
$(function() {
|
||||||
|
var menuType = $('input[name="type"]:checked').val();
|
||||||
|
menuVisible(menuType);
|
||||||
|
});
|
||||||
|
|
||||||
|
function submitHandler() {
|
||||||
|
if ($.validate.form()) {
|
||||||
|
$.operate.save(prefix + "/saveConfig", $('#form-config-edit').serialize());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$(function() {
|
||||||
|
$('input').on('ifChecked',
|
||||||
|
function(event) {
|
||||||
|
var menuType = $(event.target).val();
|
||||||
|
menuVisible(menuType);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
function menuVisible(menuType) {
|
||||||
|
if (menuType == "1") {
|
||||||
|
$("#qiniuDiv").show();
|
||||||
|
$("#aliyunDiv").hide();
|
||||||
|
$("#qcloudDiv").hide();
|
||||||
|
} else if (menuType == "2") {
|
||||||
|
$("#qiniuDiv").hide();
|
||||||
|
$("#aliyunDiv").show();
|
||||||
|
$("#qcloudDiv").hide();
|
||||||
|
} else if (menuType == "3") {
|
||||||
|
$("#qiniuDiv").hide();
|
||||||
|
$("#aliyunDiv").hide();
|
||||||
|
$("#qcloudDiv").show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
@ -0,0 +1,60 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<head th:include="include :: header"></head>
|
||||||
|
<body class="white-bg">
|
||||||
|
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
|
||||||
|
<form class="form-horizontal m" id="form-oss-edit" th:object="${sysOss}">
|
||||||
|
<input name="id" type="hidden" th:field="*{id}" />
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label ">文件名:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input class="form-control" type="text" name="fileName" id="fileName" th:field="*{fileName}"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label ">文件后缀:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<p class="form-control-static" th:text="*{fileSuffix}"></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label ">文件地址:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<p class="form-control-static" th:text="*{url}"></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label ">上传时间:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<p class="form-control-static" th:text="*{#dates.format(createTime, 'yyyy-MM-dd HH:mm:ss')}"></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label ">上传人:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<p class="form-control-static" th:text="*{createBy}"></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<div th:include="include::footer"></div>
|
||||||
|
<script type="text/javascript">
|
||||||
|
var prefix = ctx + "system/oss";
|
||||||
|
|
||||||
|
$("#form-oss-edit").validate({
|
||||||
|
rules:{
|
||||||
|
fileName:{
|
||||||
|
required:true,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
function submitHandler() {
|
||||||
|
if ($.validate.form()) {
|
||||||
|
$.operate.save(prefix + "/edit", $('#form-oss-edit').serialize());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
@ -0,0 +1,160 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="zh" xmlns:th="http://www.thymeleaf.org"
|
||||||
|
xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<head th:include="include :: header"></head>
|
||||||
|
<body class="gray-bg">
|
||||||
|
|
||||||
|
<div class="container-div">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-sm-12 search-collapse">
|
||||||
|
<form id="data-form">
|
||||||
|
<div class="select-list">
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
文件名:<input type="text" name="fileName"/>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
文件后缀:<input type="text" name="fileSuffix"/>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
上传人:<input type="text" name="createBy"/>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i> 搜索</a>
|
||||||
|
<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i> 重置</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="btn-group-sm hidden-xs" id="toolbar" role="group">
|
||||||
|
<a class="btn btn-success" id="upload" shiro:hasPermission="system:dict:add">
|
||||||
|
<i class="fa fa-plus"></i> 上传
|
||||||
|
</a>
|
||||||
|
<a class="btn btn-danger btn-del disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:dict:remove">
|
||||||
|
<i class="fa fa-remove"></i> 删除
|
||||||
|
</a>
|
||||||
|
<a class="btn btn-primary" onclick="javascript:ossfig()" shiro:hasPermission="system:dict:config">
|
||||||
|
<i class="fa fa-cogs"></i> 云储存配置
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-sm-12 select-table table-striped">
|
||||||
|
<table id="bootstrap-table" data-mobile-responsive="true"></table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div th:include="include :: footer"></div>
|
||||||
|
<script th:src="@{/ajax/libs/ajaxfile/ajaxupload.js}"></script>
|
||||||
|
<script th:inline="javascript">
|
||||||
|
var editFlag = [[${@permission.hasPermi('system:oss:edit')}]];
|
||||||
|
var removeFlag = [[${@permission.hasPermi('system:oss:remove')}]];
|
||||||
|
var prefix = ctx + "system/oss";
|
||||||
|
|
||||||
|
$(function() {
|
||||||
|
var options = {
|
||||||
|
url: prefix + "/list",
|
||||||
|
createUrl: prefix + "/add/{id}",
|
||||||
|
updateUrl: prefix + "/edit/{id}",
|
||||||
|
removeUrl: prefix + "/remove",
|
||||||
|
queryParams: queryParams,
|
||||||
|
sortName: "createTime",
|
||||||
|
sortOrder: "desc",
|
||||||
|
modalName: "文件",
|
||||||
|
search: false,
|
||||||
|
showExport: false,
|
||||||
|
columns: [{
|
||||||
|
checkbox: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'id',
|
||||||
|
title: '文件编号'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'fileName',
|
||||||
|
title: '文件名'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'fileSuffix',
|
||||||
|
title: '文件后缀'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'url',
|
||||||
|
title: '文件地址'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'createTime',
|
||||||
|
title: '创建时间',
|
||||||
|
sortable: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'createBy',
|
||||||
|
title: '上传人'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'service',
|
||||||
|
title: '服务商',
|
||||||
|
formatter: function(value, item, index) {
|
||||||
|
if (item.service == '1') {
|
||||||
|
return '七牛';
|
||||||
|
}
|
||||||
|
else if (item.service == '2') {
|
||||||
|
return '阿里云';
|
||||||
|
}
|
||||||
|
else if (item.service == '3') {
|
||||||
|
return '腾讯云';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '操作',
|
||||||
|
align: 'center',
|
||||||
|
formatter: function(value, row, index) {
|
||||||
|
var actions = [];
|
||||||
|
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
|
||||||
|
actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
|
||||||
|
return actions.join('');
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
};
|
||||||
|
$.table.init(options);
|
||||||
|
});
|
||||||
|
|
||||||
|
function queryParams(params) {
|
||||||
|
return {
|
||||||
|
dictType: $("#dictType").val(),
|
||||||
|
pageSize: params.limit,
|
||||||
|
pageNum: params.offset / params.limit + 1,
|
||||||
|
searchValue: params.search,
|
||||||
|
orderByColumn: params.sort,
|
||||||
|
isAsc: params.order
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
//调度日志查询
|
||||||
|
function ossfig(id) {
|
||||||
|
var url = prefix+'/config';
|
||||||
|
$.modal.open("云储存配置", url);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
new AjaxUpload('#upload', {
|
||||||
|
action: prefix+"/upload",
|
||||||
|
name: 'file',
|
||||||
|
autoSubmit:true,
|
||||||
|
responseType:"json",
|
||||||
|
onSubmit:function(file, extension){
|
||||||
|
if (!(extension && /^(jpg|jpeg|png|gif)$/.test(extension.toLowerCase()))){
|
||||||
|
alert('只支持jpg、png、gif格式的图片!');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onComplete : function(file, r){
|
||||||
|
$.operate.ajaxSuccess(r);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
@ -20,6 +20,7 @@
|
||||||
<commons.fileupload.version>1.3.3</commons.fileupload.version>
|
<commons.fileupload.version>1.3.3</commons.fileupload.version>
|
||||||
<jsoup.version>1.11.3</jsoup.version>
|
<jsoup.version>1.11.3</jsoup.version>
|
||||||
<poi.version>3.17</poi.version>
|
<poi.version>3.17</poi.version>
|
||||||
|
<mapper.starter.version>2.0.4</mapper.starter.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
@ -70,6 +71,13 @@
|
||||||
<artifactId>snakeyaml</artifactId>
|
<artifactId>snakeyaml</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!--mapper -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>tk.mybatis</groupId>
|
||||||
|
<artifactId>mapper-spring-boot-starter</artifactId>
|
||||||
|
<version>${mapper.starter.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
@ -1,22 +0,0 @@
|
||||||
package com.ruoyi.common.annotation;
|
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
|
||||||
import java.lang.annotation.Retention;
|
|
||||||
import java.lang.annotation.RetentionPolicy;
|
|
||||||
import java.lang.annotation.Target;
|
|
||||||
import com.ruoyi.common.enums.DataSourceType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 自定义多数据源切换注解
|
|
||||||
*
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
@Target(ElementType.METHOD)
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
|
||||||
public @interface DataSource
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* 切换数据源名称
|
|
||||||
*/
|
|
||||||
public DataSourceType value() default DataSourceType.MASTER;
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
/*
|
||||||
|
* @(#)BaseMapper.java 2016-3-30 下午5:57:15
|
||||||
|
* Copyright 2016 张孟如, Inc. All rights reserved.
|
||||||
|
* PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
|
||||||
|
*/
|
||||||
|
package com.ruoyi.common.base;
|
||||||
|
|
||||||
|
import tk.mybatis.mapper.common.ConditionMapper;
|
||||||
|
import tk.mybatis.mapper.common.IdsMapper;
|
||||||
|
import tk.mybatis.mapper.common.Mapper;
|
||||||
|
import tk.mybatis.mapper.common.special.InsertListMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>File:BaseMapper.java</p>
|
||||||
|
* <p>Title: </p>
|
||||||
|
* <p>Description:</p>
|
||||||
|
* <p>Copyright: Copyright (c) 2016 2016-3-30 下午5:57:15</p>
|
||||||
|
* <p>Company: </p>
|
||||||
|
* @author 张孟如
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
public interface BaseMapper<T> extends Mapper<T>, IdsMapper<T>,InsertListMapper<T>,ConditionMapper<T>
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
@ -1,23 +1,20 @@
|
||||||
package com.ruoyi.framework.aspectj;
|
package com.ruoyi.framework.aspectj;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.aspectj.lang.ProceedingJoinPoint;
|
import org.aspectj.lang.ProceedingJoinPoint;
|
||||||
import org.aspectj.lang.annotation.Around;
|
import org.aspectj.lang.annotation.Around;
|
||||||
import org.aspectj.lang.annotation.Aspect;
|
import org.aspectj.lang.annotation.Aspect;
|
||||||
import org.aspectj.lang.annotation.Pointcut;
|
|
||||||
import org.aspectj.lang.reflect.MethodSignature;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.core.annotation.Order;
|
import org.springframework.core.annotation.Order;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import com.ruoyi.common.annotation.DataSource;
|
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.enums.DataSourceType;
|
||||||
import com.ruoyi.framework.datasource.DynamicDataSourceContextHolder;
|
import com.ruoyi.framework.datasource.DynamicDataSourceContextHolder;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 多数据源处理
|
* 多数据源处理
|
||||||
*
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
*/
|
||||||
@Aspect
|
@Aspect
|
||||||
@Order(1)
|
@Order(1)
|
||||||
|
|
@ -26,26 +23,21 @@ public class DataSourceAspect
|
||||||
{
|
{
|
||||||
protected Logger logger = LoggerFactory.getLogger(getClass());
|
protected Logger logger = LoggerFactory.getLogger(getClass());
|
||||||
|
|
||||||
@Pointcut("@annotation(com.ruoyi.common.annotation.DataSource)")
|
@Around("execution(* com.ruoyi..*ServiceImpl.*(..))")
|
||||||
public void dsPointCut()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Around("dsPointCut()")
|
|
||||||
public Object around(ProceedingJoinPoint point) throws Throwable
|
public Object around(ProceedingJoinPoint point) throws Throwable
|
||||||
{
|
{
|
||||||
MethodSignature signature = (MethodSignature) point.getSignature();
|
// 获取到当前执行的方法名
|
||||||
|
String methodName = point.getSignature().getName();
|
||||||
Method method = signature.getMethod();
|
if (isSlave(methodName))
|
||||||
|
|
||||||
DataSource dataSource = method.getAnnotation(DataSource.class);
|
|
||||||
|
|
||||||
if (StringUtils.isNotNull(dataSource))
|
|
||||||
{
|
{
|
||||||
DynamicDataSourceContextHolder.setDateSoureType(dataSource.value().name());
|
// 标记为读库,可以自定义选择数据源
|
||||||
|
DynamicDataSourceContextHolder.setDateSoureType(DataSourceType.SLAVE.name());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// 标记为写库
|
||||||
|
DynamicDataSourceContextHolder.setDateSoureType(DataSourceType.MASTER.name());
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return point.proceed();
|
return point.proceed();
|
||||||
|
|
@ -56,4 +48,16 @@ public class DataSourceAspect
|
||||||
DynamicDataSourceContextHolder.clearDateSoureType();
|
DynamicDataSourceContextHolder.clearDateSoureType();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断是否为读库
|
||||||
|
*
|
||||||
|
* @param methodName
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private boolean isSlave(String methodName)
|
||||||
|
{
|
||||||
|
// 方法名以query、find、get开头的方法名走从库
|
||||||
|
return StringUtils.startsWithAny(methodName, new String[]{"query", "find", "get", "select"});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
package com.ruoyi.framework.util;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.validation.ConstraintViolation;
|
||||||
|
import javax.validation.Validation;
|
||||||
|
import javax.validation.Validator;
|
||||||
|
|
||||||
|
import com.ruoyi.framework.web.exception.base.BaseException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* hibernate-validator校验工具类
|
||||||
|
* 参考文档:http://docs.jboss.org/hibernate/validator/5.4/reference/en-US/html_single/
|
||||||
|
*/
|
||||||
|
public class ValidatorUtils
|
||||||
|
{
|
||||||
|
private static Validator validator;
|
||||||
|
static
|
||||||
|
{
|
||||||
|
validator = Validation.buildDefaultValidatorFactory().getValidator();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验对象
|
||||||
|
* @param object 待校验对象
|
||||||
|
* @param groups 待校验的组
|
||||||
|
* @throws RRException 校验不通过,则报RRException异常
|
||||||
|
*/
|
||||||
|
public static void validateEntity(Object object, Class<?> ... groups) throws BaseException
|
||||||
|
{
|
||||||
|
Set<ConstraintViolation<Object>> constraintViolations = validator.validate(object, groups);
|
||||||
|
if (!constraintViolations.isEmpty())
|
||||||
|
{
|
||||||
|
ConstraintViolation<Object> constraint = (ConstraintViolation<Object>) constraintViolations.iterator()
|
||||||
|
.next();
|
||||||
|
throw new BaseException(constraint.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
package com.ruoyi.framework.web.exception.user;
|
||||||
|
|
||||||
|
import com.ruoyi.framework.web.exception.base.BaseException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* OSS信息异常类
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
*/
|
||||||
|
public class OssException extends BaseException
|
||||||
|
{
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
public OssException(String msg)
|
||||||
|
{
|
||||||
|
super("oss", new Object[]{msg});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,113 @@
|
||||||
|
package com.ruoyi.system.domain;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import javax.persistence.Id;
|
||||||
|
import javax.persistence.Table;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件上传
|
||||||
|
*/
|
||||||
|
@Table(name = "sys_oss")
|
||||||
|
public class SysOss implements Serializable
|
||||||
|
{
|
||||||
|
//
|
||||||
|
private static final long serialVersionUID = 1356257283938225230L;
|
||||||
|
|
||||||
|
@Id
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/** 文件名 */
|
||||||
|
private String fileName;
|
||||||
|
|
||||||
|
/** 文件后缀 */
|
||||||
|
private String fileSuffix;
|
||||||
|
|
||||||
|
/** URL地址 */
|
||||||
|
private String url;
|
||||||
|
|
||||||
|
/** 创建时间 */
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
/** 上传者 */
|
||||||
|
private String createBy;
|
||||||
|
|
||||||
|
/** 服务商 */
|
||||||
|
private Integer service;
|
||||||
|
|
||||||
|
public Long getId()
|
||||||
|
{
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(Long id)
|
||||||
|
{
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFileName()
|
||||||
|
{
|
||||||
|
return fileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFileName(String fileName)
|
||||||
|
{
|
||||||
|
this.fileName = fileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFileSuffix()
|
||||||
|
{
|
||||||
|
return fileSuffix;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFileSuffix(String fileSuffix)
|
||||||
|
{
|
||||||
|
this.fileSuffix = fileSuffix;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUrl()
|
||||||
|
{
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUrl(String url)
|
||||||
|
{
|
||||||
|
this.url = url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getCreateTime()
|
||||||
|
{
|
||||||
|
return createTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreateTime(Date createTime)
|
||||||
|
{
|
||||||
|
this.createTime = createTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCreateBy()
|
||||||
|
{
|
||||||
|
return createBy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreateBy(String createBy)
|
||||||
|
{
|
||||||
|
this.createBy = createBy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getService()
|
||||||
|
{
|
||||||
|
return service;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setService(Integer service)
|
||||||
|
{
|
||||||
|
this.service = service;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
package com.ruoyi.system.mapper;
|
||||||
|
|
||||||
|
import com.ruoyi.common.base.BaseMapper;
|
||||||
|
import com.ruoyi.system.domain.SysOss;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件上传
|
||||||
|
*/
|
||||||
|
public interface SysOssMapper extends BaseMapper<SysOss>
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.ruoyi.system.service;
|
package com.ruoyi.system.service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.ruoyi.system.domain.SysConfig;
|
import com.ruoyi.system.domain.SysConfig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -65,4 +66,11 @@ public interface ISysConfigService
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public String checkConfigKeyUnique(SysConfig config);
|
public String checkConfigKeyUnique(SysConfig config);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param key
|
||||||
|
* @param configValue
|
||||||
|
* @author zmr
|
||||||
|
*/
|
||||||
|
public int updateValueByKey(String key, String configValue);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,46 @@
|
||||||
|
package com.ruoyi.system.service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.ruoyi.system.domain.SysOss;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件上传
|
||||||
|
*/
|
||||||
|
public interface ISysOssService
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 列表查询方法
|
||||||
|
* @param sysOss
|
||||||
|
* @return
|
||||||
|
* @author zmr
|
||||||
|
*/
|
||||||
|
List<SysOss> getList(SysOss sysOss);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param ossEntity
|
||||||
|
* @author zmr
|
||||||
|
*/
|
||||||
|
int save(SysOss ossEntity);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param ossId
|
||||||
|
* @return
|
||||||
|
* @author zmr
|
||||||
|
*/
|
||||||
|
SysOss findById(Long ossId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param sysOss
|
||||||
|
* @return
|
||||||
|
* @author zmr
|
||||||
|
*/
|
||||||
|
int update(SysOss sysOss);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param ids
|
||||||
|
* @return
|
||||||
|
* @author zmr
|
||||||
|
*/
|
||||||
|
int deleteByIds(String ids);
|
||||||
|
}
|
||||||
|
|
@ -1,8 +1,10 @@
|
||||||
package com.ruoyi.system.service.impl;
|
package com.ruoyi.system.service.impl;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import com.ruoyi.common.constant.UserConstants;
|
import com.ruoyi.common.constant.UserConstants;
|
||||||
import com.ruoyi.common.support.Convert;
|
import com.ruoyi.common.support.Convert;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
|
|
@ -115,4 +117,19 @@ public class SysConfigServiceImpl implements ISysConfigService
|
||||||
}
|
}
|
||||||
return UserConstants.CONFIG_KEY_UNIQUE;
|
return UserConstants.CONFIG_KEY_UNIQUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see com.ruoyi.system.service.ISysConfigService#updateValueByKey(java.lang.String, java.lang.String)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int updateValueByKey(String key, String configValue)
|
||||||
|
{
|
||||||
|
SysConfig info = configMapper.checkConfigKeyUnique(key);
|
||||||
|
if (StringUtils.isNotNull(info))
|
||||||
|
{
|
||||||
|
info.setConfigValue(configValue);
|
||||||
|
return updateConfig(info);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,84 @@
|
||||||
|
package com.ruoyi.system.service.impl;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import com.ruoyi.system.domain.SysOss;
|
||||||
|
import com.ruoyi.system.mapper.SysOssMapper;
|
||||||
|
import com.ruoyi.system.service.ISysOssService;
|
||||||
|
|
||||||
|
import tk.mybatis.mapper.entity.Example;
|
||||||
|
import tk.mybatis.mapper.entity.Example.Criteria;
|
||||||
|
|
||||||
|
@Service("sysOssService")
|
||||||
|
public class SysOssServiceImpl implements ISysOssService
|
||||||
|
{
|
||||||
|
@Autowired
|
||||||
|
private SysOssMapper sysOssMapper;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see
|
||||||
|
* com.zmr.wind.modules.sys.service.ISysOssService#getList(com.zmr.wind.
|
||||||
|
* modules.sys.entity.SysOss)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<SysOss> getList(SysOss sysOss)
|
||||||
|
{
|
||||||
|
Example example = new Example(SysOss.class);
|
||||||
|
Criteria criteria = example.createCriteria();
|
||||||
|
if (StringUtils.isNotBlank(sysOss.getFileName()))
|
||||||
|
{
|
||||||
|
criteria.andLike("fileName", "%" + sysOss.getFileName() + "%");
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotBlank(sysOss.getFileSuffix()))
|
||||||
|
{
|
||||||
|
criteria.andEqualTo("fileSuffix", sysOss.getFileSuffix());
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotBlank(sysOss.getCreateBy()))
|
||||||
|
{
|
||||||
|
criteria.andLike("createBy", sysOss.getCreateBy());
|
||||||
|
}
|
||||||
|
return sysOssMapper.selectByExample(example);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see com.ruoyi.system.service.ISysOssService#save(com.ruoyi.system.domain.SysOss)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int save(SysOss ossEntity)
|
||||||
|
{
|
||||||
|
return sysOssMapper.insertSelective(ossEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see com.ruoyi.system.service.ISysOssService#findById(java.lang.Long)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public SysOss findById(Long ossId)
|
||||||
|
{
|
||||||
|
return sysOssMapper.selectByPrimaryKey(ossId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see com.ruoyi.system.service.ISysOssService#update(com.ruoyi.system.domain.SysOss)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int update(SysOss sysOss)
|
||||||
|
{
|
||||||
|
return sysOssMapper.updateByPrimaryKeySelective(sysOss);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see com.ruoyi.system.service.ISysOssService#deleteByIds(java.lang.String)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int deleteByIds(String ids)
|
||||||
|
{
|
||||||
|
return sysOssMapper.deleteByIds(ids);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
|
||||||
<!DOCTYPE configuration
|
|
||||||
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
|
|
||||||
"http://mybatis.org/dtd/mybatis-3-config.dtd">
|
|
||||||
<configuration>
|
|
||||||
|
|
||||||
<settings>
|
|
||||||
<setting name="cacheEnabled" value="true" /> <!-- 全局映射器启用缓存 -->
|
|
||||||
<setting name="useGeneratedKeys" value="true" /> <!-- 允许 JDBC 支持自动生成主键 -->
|
|
||||||
<setting name="defaultExecutorType" value="REUSE" /> <!-- 配置默认的执行器 -->
|
|
||||||
<setting name="logImpl" value="SLF4J" /> <!-- 指定 MyBatis 所用日志的具体实现 -->
|
|
||||||
<!-- <setting name="mapUnderscoreToCamelCase" value="true"/> 驼峰式命名 -->
|
|
||||||
</settings>
|
|
||||||
|
|
||||||
</configuration>
|
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
CREATE TABLE `sys_oss` (
|
||||||
|
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||||
|
`file_name` varchar(64) NOT NULL DEFAULT '' COMMENT '文件名',
|
||||||
|
`file_suffix` varchar(10) NOT NULL DEFAULT '' COMMENT '文件后缀名',
|
||||||
|
`url` varchar(200) NOT NULL COMMENT 'URL地址',
|
||||||
|
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||||||
|
`create_by` varchar(64) NOT NULL DEFAULT '' COMMENT '上传人',
|
||||||
|
`service` tinyint(2) NOT NULL DEFAULT '1' COMMENT '服务商',
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8 COMMENT='文件上传';
|
||||||
|
|
||||||
|
INSERT INTO `ry`.`sys_config` (`config_id`, `config_name`, `config_key`, `config_value`, `config_type`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES ('3', 'oss存储配置', 'sys.oss.cloudStorage', '{\"aliyunAccessKeyId\":\"\",\"aliyunAccessKeySecret\":\"\",\"aliyunBucketName\":\"\",\"aliyunDomain\":\"\",\"aliyunEndPoint\":\"\",\"aliyunPrefix\":\"\",\"qcloudBucketName\":\"\",\"qcloudDomain\":\"\",\"qcloudPrefix\":\"\",\"qcloudSecretId\":\"\",\"qcloudSecretKey\":\"\",\"qiniuAccessKey\":\"\",\"qiniuBucketName\":\"ios-app\",\"qiniuDomain\":\"\",\"qiniuPrefix\":\"upload\",\"qiniuSecretKey\":\"\",\"type\":1}', 'Y', 'admin', '2018-03-16 11:33:00', '', '2018-03-16 11:33:00', 'oss存储配置');
|
||||||
|
INSERT INTO `ry`.`sys_menu` (`menu_id`, `menu_name`, `parent_id`, `order_num`, `url`, `menu_type`, `visible`, `perms`, `icon`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES ('1056', '文件管理', '1', '10', '/system/oss', 'C', '0', 'system:oss:view', '#', 'admin', '2018-11-16 13:59:45', '', NULL, '');
|
||||||
|
INSERT INTO `ry`.`sys_menu` (`menu_id`, `menu_name`, `parent_id`, `order_num`, `url`, `menu_type`, `visible`, `perms`, `icon`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES ('1057', '文件上传', '1056', '1', '#', 'F', '0', 'system:oss:add', '#', 'admin', '2018-11-16 13:59:45', '', NULL, '');
|
||||||
|
INSERT INTO `ry`.`sys_menu` (`menu_id`, `menu_name`, `parent_id`, `order_num`, `url`, `menu_type`, `visible`, `perms`, `icon`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES ('1058', '文件删除', '1056', '2', '#', 'F', '0', 'system:oss:remove', '#', 'admin', '2018-11-16 13:59:45', '', NULL, '');
|
||||||
|
INSERT INTO `ry`.`sys_menu` (`menu_id`, `menu_name`, `parent_id`, `order_num`, `url`, `menu_type`, `visible`, `perms`, `icon`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES ('1059', '文件配置', '1056', '3', '#', 'F', '0', 'system:oss:config', '#', 'admin', '2018-11-16 13:59:45', '', NULL, '');
|
||||||
|
INSERT INTO `ry`.`sys_menu` (`menu_id`, `menu_name`, `parent_id`, `order_num`, `url`, `menu_type`, `visible`, `perms`, `icon`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES ('1060', '文件修改', '1056', '4', '#', 'F', '0', 'system:oss:remove', '#', 'admin', '2018-11-16 13:59:45', '', NULL, '');
|
||||||
Loading…
Reference in New Issue