mirror of
https://gitee.com/y_project/RuoYi-Vue.git
synced 2025-12-08 15:02:29 +08:00
Compare commits
147 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a854e0ca8e | |||
| de1766abde | |||
| 01a566c794 | |||
| 5362a633e6 | |||
| b2c3f45141 | |||
| d5f9b5b74a | |||
| 2043d1f439 | |||
| 61034d4dde | |||
| 6605bf35a8 | |||
| b2b93e5060 | |||
| 098286fcaf | |||
| eaa12de740 | |||
| 857054179c | |||
| 0a3fcfd9f4 | |||
| 0271aa5414 | |||
| a0364f0758 | |||
| ed693e89c9 | |||
| 526957e0ac | |||
| 420a43cdd5 | |||
| 5e8ccda522 | |||
| 62fc38078c | |||
| bc4f844cd8 | |||
| f15f8e3295 | |||
| 6130bebbb3 | |||
| 9f944c043f | |||
| 092b3214c5 | |||
| 07dfef48be | |||
| e9571fc2e2 | |||
| 22f7ccc11d | |||
| 4bd5009ec1 | |||
| cb8f5de5af | |||
| ac030b7275 | |||
| 9370747479 | |||
| 45efd9290e | |||
| 96edba7eec | |||
| 927b05713a | |||
| 8f23ff7274 | |||
| 158e883e47 | |||
| e62e8e372c | |||
| bb65cd1976 | |||
| 1086c00929 | |||
| 9aaa9ce8aa | |||
| cb5a6d29e2 | |||
| 4d8bd8805b | |||
| c8c57b545a | |||
| d0f7a317e4 | |||
| aa9ed2e863 | |||
| 54c6c4e547 | |||
| 986b48cf36 | |||
| 3bb9b03add | |||
| f05aa674ab | |||
| 965bdc9986 | |||
| e793138031 | |||
| d734bfc34f | |||
| 84fe0737de | |||
| 81630a096f | |||
| 21780d8106 | |||
| b7b4364db2 | |||
| d9859de756 | |||
| 5e6fd0d1e1 | |||
| a91d7cdd72 | |||
| d00dc3b03a | |||
| f5c69bae30 | |||
| 89fe17f419 | |||
| c491257359 | |||
| dd5e514d92 | |||
| 2532e40f9c | |||
| 50236ae4e5 | |||
| c99eb98001 | |||
| a29201a248 | |||
| 6f0c59d7be | |||
| a6ed5667ab | |||
| 612c4293d1 | |||
| 8007b22b85 | |||
| 35664d818d | |||
| 1fe08f49c7 | |||
| 48b007543a | |||
| dccb3ac6c6 | |||
| 89cd2106ed | |||
| 74f991b8c5 | |||
| a966b95a5b | |||
| 15f05b602f | |||
| 9e51d3f250 | |||
| d7ca248bc8 | |||
| 3980b2f2ff | |||
| bed9fcea46 | |||
| b1b82857ba | |||
| 869dcf73f8 | |||
| 96a34d1ad7 | |||
| 766361ac83 | |||
| 9bd7509e87 | |||
| 9f7acd4cf9 | |||
| eb11337f7d | |||
| d2872539e3 | |||
| 1a5b024df6 | |||
| 578d65dfb4 | |||
| db4c2d3dd5 | |||
| 47842a1611 | |||
| f4f4cd9b1f | |||
| b7452cc281 | |||
| 8ba91fc9dd | |||
| c8d9b3f8fc | |||
| c9d19cbe56 | |||
| 10ae0bce65 | |||
| 7bc15245aa | |||
| cb6228800b | |||
| 6ef899d000 | |||
| 6353f4ff09 | |||
| bb1af390a7 | |||
| f65cd6245d | |||
| 530b2a51d5 | |||
| d51e7cbb51 | |||
| f244fe1855 | |||
| 1294f68265 | |||
| 0e771a6c1b | |||
| e4df0c6da1 | |||
| 7b23b6db6f | |||
| be412faf6c | |||
| fd3a699ad8 | |||
| c28aa299bd | |||
| a028b566ed | |||
| ca2405c104 | |||
| e5647793ce | |||
| 903b5aebca | |||
| 7492dcc9e6 | |||
| 8978012f9d | |||
| 7cf4a5da87 | |||
| 47b67331d4 | |||
| 6e14601c7c | |||
| fef7ead0d5 | |||
| 06aef0587a | |||
| bf7c259cdd | |||
| 43d76e5990 | |||
| d365a52cd6 | |||
| e1c7115d8c | |||
| bb4d75aff0 | |||
| 2743785aaf | |||
| 2a235917dc | |||
| 44ce6774dc | |||
| b911d7f78f | |||
| 4644176e26 | |||
| 850b98337b | |||
| 7f2921f26b | |||
| 836017f2b9 | |||
| 4de4763baf | |||
| 965ebd0f03 | |||
| 2c3f1c28e5 |
1
.github/FUNDING.yml
vendored
Normal file
1
.github/FUNDING.yml
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
custom: http://doc.ruoyi.vip/ruoyi-vue/other/donate.html
|
||||||
3
.gitignore
vendored
3
.gitignore
vendored
@ -25,6 +25,9 @@ target/
|
|||||||
*.iml
|
*.iml
|
||||||
*.ipr
|
*.ipr
|
||||||
|
|
||||||
|
### JRebel ###
|
||||||
|
rebel.xml
|
||||||
|
|
||||||
### NetBeans ###
|
### NetBeans ###
|
||||||
nbproject/private/
|
nbproject/private/
|
||||||
build/*
|
build/*
|
||||||
|
|||||||
13
README.md
13
README.md
@ -1,3 +1,14 @@
|
|||||||
|
<p align="center">
|
||||||
|
<img alt="logo" src="https://oscimg.oschina.net/oscnet/up-d3d0a9303e11d522a06cd263f3079027715.png">
|
||||||
|
</p>
|
||||||
|
<h1 align="center" style="margin: 30px 0 30px; font-weight: bold;">RuoYi v3.8.1</h1>
|
||||||
|
<h4 align="center">基于SpringBoot+Vue前后端分离的Java快速开发框架</h4>
|
||||||
|
<p align="center">
|
||||||
|
<a href="https://gitee.com/y_project/RuoYi-Vue/stargazers"><img src="https://gitee.com/y_project/RuoYi-Vue/badge/star.svg?theme=dark"></a>
|
||||||
|
<a href="https://gitee.com/y_project/RuoYi-Vue"><img src="https://img.shields.io/badge/RuoYi-v3.8.1-brightgreen.svg"></a>
|
||||||
|
<a href="https://gitee.com/y_project/RuoYi-Vue/blob/master/LICENSE"><img src="https://img.shields.io/github/license/mashape/apistatus.svg"></a>
|
||||||
|
</p>
|
||||||
|
|
||||||
## 平台简介
|
## 平台简介
|
||||||
|
|
||||||
若依是一套全部开源的快速开发平台,毫无保留给个人及企业免费使用。
|
若依是一套全部开源的快速开发平台,毫无保留给个人及企业免费使用。
|
||||||
@ -83,4 +94,4 @@
|
|||||||
|
|
||||||
## 若依前后端分离交流群
|
## 若依前后端分离交流群
|
||||||
|
|
||||||
QQ群: [](https://jq.qq.com/?_wv=1027&k=5bVB1og) [](https://jq.qq.com/?_wv=1027&k=5eiA4DH) [](https://jq.qq.com/?_wv=1027&k=5AxMKlC) [](https://jq.qq.com/?_wv=1027&k=51G72yr) [](https://jq.qq.com/?_wv=1027&k=VvjN2nvu) [](https://jq.qq.com/?_wv=1027&k=5vYAqA05) [](https://jq.qq.com/?_wv=1027&k=kOIINEb5) [](https://jq.qq.com/?_wv=1027&k=UKtX5jhs) 点击按钮入群。
|
QQ群: [](https://jq.qq.com/?_wv=1027&k=5bVB1og) [](https://jq.qq.com/?_wv=1027&k=5eiA4DH) [](https://jq.qq.com/?_wv=1027&k=5AxMKlC) [](https://jq.qq.com/?_wv=1027&k=51G72yr) [](https://jq.qq.com/?_wv=1027&k=VvjN2nvu) [](https://jq.qq.com/?_wv=1027&k=5vYAqA05) [](https://jq.qq.com/?_wv=1027&k=kOIINEb5) [](https://jq.qq.com/?_wv=1027&k=UKtX5jhs) [](https://jq.qq.com/?_wv=1027&k=EI9an8lJ) [](https://jq.qq.com/?_wv=1027&k=SWCtLnMz) 点击按钮入群。
|
||||||
16
pom.xml
16
pom.xml
@ -6,14 +6,14 @@
|
|||||||
|
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi</artifactId>
|
<artifactId>ruoyi</artifactId>
|
||||||
<version>3.8.0</version>
|
<version>3.8.2</version>
|
||||||
|
|
||||||
<name>ruoyi</name>
|
<name>ruoyi</name>
|
||||||
<url>http://www.ruoyi.vip</url>
|
<url>http://www.ruoyi.vip</url>
|
||||||
<description>若依管理系统</description>
|
<description>若依管理系统</description>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<ruoyi.version>3.8.0</ruoyi.version>
|
<ruoyi.version>3.8.2</ruoyi.version>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
<java.version>1.8</java.version>
|
<java.version>1.8</java.version>
|
||||||
@ -22,11 +22,11 @@
|
|||||||
<bitwalker.version>1.21</bitwalker.version>
|
<bitwalker.version>1.21</bitwalker.version>
|
||||||
<swagger.version>3.0.0</swagger.version>
|
<swagger.version>3.0.0</swagger.version>
|
||||||
<kaptcha.version>2.3.2</kaptcha.version>
|
<kaptcha.version>2.3.2</kaptcha.version>
|
||||||
<mybatis-spring-boot.version>2.2.0</mybatis-spring-boot.version>
|
<mybatis-spring-boot.version>2.2.2</mybatis-spring-boot.version>
|
||||||
<pagehelper.boot.version>1.4.0</pagehelper.boot.version>
|
<pagehelper.boot.version>1.4.1</pagehelper.boot.version>
|
||||||
<fastjson.version>1.2.78</fastjson.version>
|
<fastjson.version>1.2.80</fastjson.version>
|
||||||
<oshi.version>5.8.2</oshi.version>
|
<oshi.version>6.1.2</oshi.version>
|
||||||
<jna.version>5.9.0</jna.version>
|
<jna.version>5.10.0</jna.version>
|
||||||
<commons.io.version>2.11.0</commons.io.version>
|
<commons.io.version>2.11.0</commons.io.version>
|
||||||
<commons.fileupload.version>1.4</commons.fileupload.version>
|
<commons.fileupload.version>1.4</commons.fileupload.version>
|
||||||
<commons.collections.version>3.2.2</commons.collections.version>
|
<commons.collections.version>3.2.2</commons.collections.version>
|
||||||
@ -43,7 +43,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-dependencies</artifactId>
|
<artifactId>spring-boot-dependencies</artifactId>
|
||||||
<version>2.5.6</version>
|
<version>2.5.11</version>
|
||||||
<type>pom</type>
|
<type>pom</type>
|
||||||
<scope>import</scope>
|
<scope>import</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>ruoyi</artifactId>
|
<artifactId>ruoyi</artifactId>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<version>3.8.0</version>
|
<version>3.8.2</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
package com.ruoyi.web.controller.common;
|
package com.ruoyi.web.controller.common;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@ -8,6 +10,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import com.ruoyi.common.config.RuoYiConfig;
|
import com.ruoyi.common.config.RuoYiConfig;
|
||||||
@ -24,6 +27,7 @@ import com.ruoyi.framework.config.ServerConfig;
|
|||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
|
@RequestMapping("/common")
|
||||||
public class CommonController
|
public class CommonController
|
||||||
{
|
{
|
||||||
private static final Logger log = LoggerFactory.getLogger(CommonController.class);
|
private static final Logger log = LoggerFactory.getLogger(CommonController.class);
|
||||||
@ -31,13 +35,15 @@ public class CommonController
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ServerConfig serverConfig;
|
private ServerConfig serverConfig;
|
||||||
|
|
||||||
|
private static final String FILE_DELIMETER = ",";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通用下载请求
|
* 通用下载请求
|
||||||
*
|
*
|
||||||
* @param fileName 文件名称
|
* @param fileName 文件名称
|
||||||
* @param delete 是否删除
|
* @param delete 是否删除
|
||||||
*/
|
*/
|
||||||
@GetMapping("common/download")
|
@GetMapping("/download")
|
||||||
public void fileDownload(String fileName, Boolean delete, HttpServletResponse response, HttpServletRequest request)
|
public void fileDownload(String fileName, Boolean delete, HttpServletResponse response, HttpServletRequest request)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -64,9 +70,9 @@ public class CommonController
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通用上传请求
|
* 通用上传请求(单个)
|
||||||
*/
|
*/
|
||||||
@PostMapping("/common/upload")
|
@PostMapping("/upload")
|
||||||
public AjaxResult uploadFile(MultipartFile file) throws Exception
|
public AjaxResult uploadFile(MultipartFile file) throws Exception
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -77,8 +83,47 @@ public class CommonController
|
|||||||
String fileName = FileUploadUtils.upload(filePath, file);
|
String fileName = FileUploadUtils.upload(filePath, file);
|
||||||
String url = serverConfig.getUrl() + fileName;
|
String url = serverConfig.getUrl() + fileName;
|
||||||
AjaxResult ajax = AjaxResult.success();
|
AjaxResult ajax = AjaxResult.success();
|
||||||
ajax.put("fileName", fileName);
|
|
||||||
ajax.put("url", url);
|
ajax.put("url", url);
|
||||||
|
ajax.put("fileName", fileName);
|
||||||
|
ajax.put("newFileName", FileUtils.getName(fileName));
|
||||||
|
ajax.put("originalFilename", file.getOriginalFilename());
|
||||||
|
return ajax;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
return AjaxResult.error(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通用上传请求(多个)
|
||||||
|
*/
|
||||||
|
@PostMapping("/uploads")
|
||||||
|
public AjaxResult uploadFiles(List<MultipartFile> files) throws Exception
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// 上传文件路径
|
||||||
|
String filePath = RuoYiConfig.getUploadPath();
|
||||||
|
List<String> urls = new ArrayList<String>();
|
||||||
|
List<String> fileNames = new ArrayList<String>();
|
||||||
|
List<String> newFileNames = new ArrayList<String>();
|
||||||
|
List<String> originalFilenames = new ArrayList<String>();
|
||||||
|
for (MultipartFile file : files)
|
||||||
|
{
|
||||||
|
// 上传并返回新文件名称
|
||||||
|
String fileName = FileUploadUtils.upload(filePath, file);
|
||||||
|
String url = serverConfig.getUrl() + fileName;
|
||||||
|
urls.add(url);
|
||||||
|
fileNames.add(fileName);
|
||||||
|
newFileNames.add(FileUtils.getName(fileName));
|
||||||
|
originalFilenames.add(file.getOriginalFilename());
|
||||||
|
}
|
||||||
|
AjaxResult ajax = AjaxResult.success();
|
||||||
|
ajax.put("urls", StringUtils.join(urls, FILE_DELIMETER));
|
||||||
|
ajax.put("fileNames", StringUtils.join(fileNames, FILE_DELIMETER));
|
||||||
|
ajax.put("newFileNames", StringUtils.join(newFileNames, FILE_DELIMETER));
|
||||||
|
ajax.put("originalFilenames", StringUtils.join(originalFilenames, FILE_DELIMETER));
|
||||||
return ajax;
|
return ajax;
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@ -90,7 +135,7 @@ public class CommonController
|
|||||||
/**
|
/**
|
||||||
* 本地资源通用下载
|
* 本地资源通用下载
|
||||||
*/
|
*/
|
||||||
@GetMapping("/common/download/resource")
|
@GetMapping("/download/resource")
|
||||||
public void resourceDownload(String resource, HttpServletRequest request, HttpServletResponse response)
|
public void resourceDownload(String resource, HttpServletRequest request, HttpServletResponse response)
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
|
|||||||
@ -125,16 +125,17 @@ public class SysDeptController extends BaseController
|
|||||||
@PutMapping
|
@PutMapping
|
||||||
public AjaxResult edit(@Validated @RequestBody SysDept dept)
|
public AjaxResult edit(@Validated @RequestBody SysDept dept)
|
||||||
{
|
{
|
||||||
|
Long deptId = dept.getDeptId();
|
||||||
|
deptService.checkDeptDataScope(deptId);
|
||||||
if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept)))
|
if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept)))
|
||||||
{
|
{
|
||||||
return AjaxResult.error("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在");
|
return AjaxResult.error("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在");
|
||||||
}
|
}
|
||||||
else if (dept.getParentId().equals(dept.getDeptId()))
|
else if (dept.getParentId().equals(deptId))
|
||||||
{
|
{
|
||||||
return AjaxResult.error("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己");
|
return AjaxResult.error("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己");
|
||||||
}
|
}
|
||||||
else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus())
|
else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus()) && deptService.selectNormalChildrenDeptById(deptId) > 0)
|
||||||
&& deptService.selectNormalChildrenDeptById(dept.getDeptId()) > 0)
|
|
||||||
{
|
{
|
||||||
return AjaxResult.error("该部门包含未停用的子部门!");
|
return AjaxResult.error("该部门包含未停用的子部门!");
|
||||||
}
|
}
|
||||||
@ -158,6 +159,7 @@ public class SysDeptController extends BaseController
|
|||||||
{
|
{
|
||||||
return AjaxResult.error("部门存在用户,不允许删除");
|
return AjaxResult.error("部门存在用户,不允许删除");
|
||||||
}
|
}
|
||||||
|
deptService.checkDeptDataScope(deptId);
|
||||||
return toAjax(deptService.deleteDeptById(deptId));
|
return toAjax(deptService.deleteDeptById(deptId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -111,6 +111,7 @@ public class SysRoleController extends BaseController
|
|||||||
public AjaxResult edit(@Validated @RequestBody SysRole role)
|
public AjaxResult edit(@Validated @RequestBody SysRole role)
|
||||||
{
|
{
|
||||||
roleService.checkRoleAllowed(role);
|
roleService.checkRoleAllowed(role);
|
||||||
|
roleService.checkRoleDataScope(role.getRoleId());
|
||||||
if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role)))
|
if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role)))
|
||||||
{
|
{
|
||||||
return AjaxResult.error("修改角色'" + role.getRoleName() + "'失败,角色名称已存在");
|
return AjaxResult.error("修改角色'" + role.getRoleName() + "'失败,角色名称已存在");
|
||||||
@ -145,6 +146,7 @@ public class SysRoleController extends BaseController
|
|||||||
public AjaxResult dataScope(@RequestBody SysRole role)
|
public AjaxResult dataScope(@RequestBody SysRole role)
|
||||||
{
|
{
|
||||||
roleService.checkRoleAllowed(role);
|
roleService.checkRoleAllowed(role);
|
||||||
|
roleService.checkRoleDataScope(role.getRoleId());
|
||||||
return toAjax(roleService.authDataScope(role));
|
return toAjax(roleService.authDataScope(role));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,6 +159,7 @@ public class SysRoleController extends BaseController
|
|||||||
public AjaxResult changeStatus(@RequestBody SysRole role)
|
public AjaxResult changeStatus(@RequestBody SysRole role)
|
||||||
{
|
{
|
||||||
roleService.checkRoleAllowed(role);
|
roleService.checkRoleAllowed(role);
|
||||||
|
roleService.checkRoleDataScope(role.getRoleId());
|
||||||
role.setUpdateBy(getUsername());
|
role.setUpdateBy(getUsername());
|
||||||
return toAjax(roleService.updateRoleStatus(role));
|
return toAjax(roleService.updateRoleStatus(role));
|
||||||
}
|
}
|
||||||
@ -236,6 +239,7 @@ public class SysRoleController extends BaseController
|
|||||||
@PutMapping("/authUser/selectAll")
|
@PutMapping("/authUser/selectAll")
|
||||||
public AjaxResult selectAuthUserAll(Long roleId, Long[] userIds)
|
public AjaxResult selectAuthUserAll(Long roleId, Long[] userIds)
|
||||||
{
|
{
|
||||||
|
roleService.checkRoleDataScope(roleId);
|
||||||
return toAjax(roleService.insertAuthUsers(roleId, userIds));
|
return toAjax(roleService.insertAuthUsers(roleId, userIds));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -104,9 +104,10 @@ public class SysUserController extends BaseController
|
|||||||
ajax.put("posts", postService.selectPostAll());
|
ajax.put("posts", postService.selectPostAll());
|
||||||
if (StringUtils.isNotNull(userId))
|
if (StringUtils.isNotNull(userId))
|
||||||
{
|
{
|
||||||
ajax.put(AjaxResult.DATA_TAG, userService.selectUserById(userId));
|
SysUser sysUser = userService.selectUserById(userId);
|
||||||
|
ajax.put(AjaxResult.DATA_TAG, sysUser);
|
||||||
ajax.put("postIds", postService.selectPostListByUserId(userId));
|
ajax.put("postIds", postService.selectPostListByUserId(userId));
|
||||||
ajax.put("roleIds", roleService.selectRoleListByUserId(userId));
|
ajax.put("roleIds", sysUser.getRoles().stream().map(SysRole::getRoleId).collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
return ajax;
|
return ajax;
|
||||||
}
|
}
|
||||||
@ -147,6 +148,7 @@ public class SysUserController extends BaseController
|
|||||||
public AjaxResult edit(@Validated @RequestBody SysUser user)
|
public AjaxResult edit(@Validated @RequestBody SysUser user)
|
||||||
{
|
{
|
||||||
userService.checkUserAllowed(user);
|
userService.checkUserAllowed(user);
|
||||||
|
userService.checkUserDataScope(user.getUserId());
|
||||||
if (StringUtils.isNotEmpty(user.getPhonenumber())
|
if (StringUtils.isNotEmpty(user.getPhonenumber())
|
||||||
&& UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user)))
|
&& UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user)))
|
||||||
{
|
{
|
||||||
@ -185,6 +187,7 @@ public class SysUserController extends BaseController
|
|||||||
public AjaxResult resetPwd(@RequestBody SysUser user)
|
public AjaxResult resetPwd(@RequestBody SysUser user)
|
||||||
{
|
{
|
||||||
userService.checkUserAllowed(user);
|
userService.checkUserAllowed(user);
|
||||||
|
userService.checkUserDataScope(user.getUserId());
|
||||||
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
|
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
|
||||||
user.setUpdateBy(getUsername());
|
user.setUpdateBy(getUsername());
|
||||||
return toAjax(userService.resetPwd(user));
|
return toAjax(userService.resetPwd(user));
|
||||||
@ -199,6 +202,7 @@ public class SysUserController extends BaseController
|
|||||||
public AjaxResult changeStatus(@RequestBody SysUser user)
|
public AjaxResult changeStatus(@RequestBody SysUser user)
|
||||||
{
|
{
|
||||||
userService.checkUserAllowed(user);
|
userService.checkUserAllowed(user);
|
||||||
|
userService.checkUserDataScope(user.getUserId());
|
||||||
user.setUpdateBy(getUsername());
|
user.setUpdateBy(getUsername());
|
||||||
return toAjax(userService.updateUserStatus(user));
|
return toAjax(userService.updateUserStatus(user));
|
||||||
}
|
}
|
||||||
@ -226,6 +230,7 @@ public class SysUserController extends BaseController
|
|||||||
@PutMapping("/authRole")
|
@PutMapping("/authRole")
|
||||||
public AjaxResult insertAuthRole(Long userId, Long[] roleIds)
|
public AjaxResult insertAuthRole(Long userId, Long[] roleIds)
|
||||||
{
|
{
|
||||||
|
userService.checkUserDataScope(userId);
|
||||||
userService.insertUserAuth(userId, roleIds);
|
userService.insertUserAuth(userId, roleIds);
|
||||||
return success();
|
return success();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,9 +3,9 @@ ruoyi:
|
|||||||
# 名称
|
# 名称
|
||||||
name: RuoYi
|
name: RuoYi
|
||||||
# 版本
|
# 版本
|
||||||
version: 3.8.0
|
version: 3.8.2
|
||||||
# 版权年份
|
# 版权年份
|
||||||
copyrightYear: 2021
|
copyrightYear: 2022
|
||||||
# 实例演示开关
|
# 实例演示开关
|
||||||
demoEnabled: true
|
demoEnabled: true
|
||||||
# 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath)
|
# 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath)
|
||||||
@ -25,10 +25,13 @@ server:
|
|||||||
tomcat:
|
tomcat:
|
||||||
# tomcat的URI编码
|
# tomcat的URI编码
|
||||||
uri-encoding: UTF-8
|
uri-encoding: UTF-8
|
||||||
# tomcat最大线程数,默认为200
|
# 连接数满后的排队数,默认为100
|
||||||
max-threads: 800
|
accept-count: 1000
|
||||||
# Tomcat启动初始化的线程数,默认值25
|
threads:
|
||||||
min-spare-threads: 30
|
# tomcat最大线程数,默认为200
|
||||||
|
max: 800
|
||||||
|
# Tomcat启动初始化的线程数,默认值10
|
||||||
|
min-spare: 100
|
||||||
|
|
||||||
# 日志配置
|
# 日志配置
|
||||||
logging:
|
logging:
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>ruoyi</artifactId>
|
<artifactId>ruoyi</artifactId>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<version>3.8.0</version>
|
<version>3.8.2</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@ -142,16 +142,26 @@ public class Constants
|
|||||||
/**
|
/**
|
||||||
* RMI 远程方法调用
|
* RMI 远程方法调用
|
||||||
*/
|
*/
|
||||||
public static final String LOOKUP_RMI = "rmi://";
|
public static final String LOOKUP_RMI = "rmi:";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* LDAP 远程方法调用
|
* LDAP 远程方法调用
|
||||||
*/
|
*/
|
||||||
public static final String LOOKUP_LDAP = "ldap://";
|
public static final String LOOKUP_LDAP = "ldap:";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LDAPS 远程方法调用
|
||||||
|
*/
|
||||||
|
public static final String LOOKUP_LDAPS = "ldaps:";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 定时任务白名单配置(仅允许访问的包名,如其他需要可以自行添加)
|
||||||
|
*/
|
||||||
|
public static final String[] JOB_WHITELIST_STR = { "com.ruoyi" };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 定时任务违规的字符
|
* 定时任务违规的字符
|
||||||
*/
|
*/
|
||||||
public static final String[] JOB_ERROR_STR = { "java.net.URL", "javax.naming.InitialContext", "org.yaml.snakeyaml",
|
public static final String[] JOB_ERROR_STR = { "java.net.URL", "javax.naming.InitialContext", "org.yaml.snakeyaml",
|
||||||
"org.springframework.jndi" };
|
"org.springframework", "org.apache", "com.ruoyi.common.utils.file" };
|
||||||
}
|
}
|
||||||
|
|||||||
@ -109,6 +109,9 @@ public class GenConstants
|
|||||||
/** 模糊查询 */
|
/** 模糊查询 */
|
||||||
public static final String QUERY_LIKE = "LIKE";
|
public static final String QUERY_LIKE = "LIKE";
|
||||||
|
|
||||||
|
/** 相等查询 */
|
||||||
|
public static final String QUERY_EQ = "EQ";
|
||||||
|
|
||||||
/** 需要 */
|
/** 需要 */
|
||||||
public static final String REQUIRE = "1";
|
public static final String REQUIRE = "1";
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,6 +16,7 @@ import com.ruoyi.common.core.page.PageDomain;
|
|||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
import com.ruoyi.common.core.page.TableSupport;
|
import com.ruoyi.common.core.page.TableSupport;
|
||||||
import com.ruoyi.common.utils.DateUtils;
|
import com.ruoyi.common.utils.DateUtils;
|
||||||
|
import com.ruoyi.common.utils.PageUtils;
|
||||||
import com.ruoyi.common.utils.SecurityUtils;
|
import com.ruoyi.common.utils.SecurityUtils;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
import com.ruoyi.common.utils.sql.SqlUtil;
|
import com.ruoyi.common.utils.sql.SqlUtil;
|
||||||
@ -51,15 +52,7 @@ public class BaseController
|
|||||||
*/
|
*/
|
||||||
protected void startPage()
|
protected void startPage()
|
||||||
{
|
{
|
||||||
PageDomain pageDomain = TableSupport.buildPageRequest();
|
PageUtils.startPage();
|
||||||
Integer pageNum = pageDomain.getPageNum();
|
|
||||||
Integer pageSize = pageDomain.getPageSize();
|
|
||||||
if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize))
|
|
||||||
{
|
|
||||||
String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy());
|
|
||||||
Boolean reasonable = pageDomain.getReasonable();
|
|
||||||
PageHelper.startPage(pageNum, pageSize, orderBy).setReasonable(reasonable);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -75,6 +68,14 @@ public class BaseController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 清理分页的线程变量
|
||||||
|
*/
|
||||||
|
protected void clearPage()
|
||||||
|
{
|
||||||
|
PageUtils.clearPage();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 响应请求分页数据
|
* 响应请求分页数据
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -3,6 +3,7 @@ package com.ruoyi.common.core.domain.entity;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
import javax.validation.constraints.Size;
|
import javax.validation.constraints.Size;
|
||||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
@ -30,7 +31,7 @@ public class SysMenu extends BaseEntity
|
|||||||
private Long parentId;
|
private Long parentId;
|
||||||
|
|
||||||
/** 显示顺序 */
|
/** 显示顺序 */
|
||||||
private String orderNum;
|
private Integer orderNum;
|
||||||
|
|
||||||
/** 路由地址 */
|
/** 路由地址 */
|
||||||
private String path;
|
private String path;
|
||||||
@ -107,13 +108,13 @@ public class SysMenu extends BaseEntity
|
|||||||
this.parentId = parentId;
|
this.parentId = parentId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotBlank(message = "显示顺序不能为空")
|
@NotNull(message = "显示顺序不能为空")
|
||||||
public String getOrderNum()
|
public Integer getOrderNum()
|
||||||
{
|
{
|
||||||
return orderNum;
|
return orderNum;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOrderNum(String orderNum)
|
public void setOrderNum(Integer orderNum)
|
||||||
{
|
{
|
||||||
this.orderNum = orderNum;
|
this.orderNum = orderNum;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,9 +2,7 @@ package com.ruoyi.common.core.domain.entity;
|
|||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.validation.constraints.Email;
|
import javax.validation.constraints.*;
|
||||||
import javax.validation.constraints.NotBlank;
|
|
||||||
import javax.validation.constraints.Size;
|
|
||||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
@ -14,6 +12,7 @@ import com.ruoyi.common.annotation.Excel.ColumnType;
|
|||||||
import com.ruoyi.common.annotation.Excel.Type;
|
import com.ruoyi.common.annotation.Excel.Type;
|
||||||
import com.ruoyi.common.annotation.Excels;
|
import com.ruoyi.common.annotation.Excels;
|
||||||
import com.ruoyi.common.core.domain.BaseEntity;
|
import com.ruoyi.common.core.domain.BaseEntity;
|
||||||
|
import com.ruoyi.common.xss.Xss;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户对象 sys_user
|
* 用户对象 sys_user
|
||||||
@ -135,6 +134,7 @@ public class SysUser extends BaseEntity
|
|||||||
this.deptId = deptId;
|
this.deptId = deptId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Xss(message = "用户昵称不能包含脚本字符")
|
||||||
@Size(min = 0, max = 30, message = "用户昵称长度不能超过30个字符")
|
@Size(min = 0, max = 30, message = "用户昵称长度不能超过30个字符")
|
||||||
public String getNickName()
|
public String getNickName()
|
||||||
{
|
{
|
||||||
@ -146,6 +146,7 @@ public class SysUser extends BaseEntity
|
|||||||
this.nickName = nickName;
|
this.nickName = nickName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Xss(message = "用户账号不能包含脚本字符")
|
||||||
@NotBlank(message = "用户账号不能为空")
|
@NotBlank(message = "用户账号不能为空")
|
||||||
@Size(min = 0, max = 30, message = "用户账号长度不能超过30个字符")
|
@Size(min = 0, max = 30, message = "用户账号长度不能超过30个字符")
|
||||||
public String getUserName()
|
public String getUserName()
|
||||||
|
|||||||
@ -25,7 +25,7 @@ public class LoginBody
|
|||||||
/**
|
/**
|
||||||
* 唯一标识
|
* 唯一标识
|
||||||
*/
|
*/
|
||||||
private String uuid = "";
|
private String uuid;
|
||||||
|
|
||||||
public String getUsername()
|
public String getUsername()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -213,12 +213,12 @@ public class RedisCache
|
|||||||
* 删除Hash中的数据
|
* 删除Hash中的数据
|
||||||
*
|
*
|
||||||
* @param key
|
* @param key
|
||||||
* @param mapkey
|
* @param hKey
|
||||||
*/
|
*/
|
||||||
public void delCacheMapValue(final String key, final String hkey)
|
public void delCacheMapValue(final String key, final String hKey)
|
||||||
{
|
{
|
||||||
HashOperations hashOperations = redisTemplate.opsForHash();
|
HashOperations hashOperations = redisTemplate.opsForHash();
|
||||||
hashOperations.delete(key, hkey);
|
hashOperations.delete(key, hKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -3,6 +3,11 @@ package com.ruoyi.common.utils;
|
|||||||
import java.lang.management.ManagementFactory;
|
import java.lang.management.ManagementFactory;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.LocalTime;
|
||||||
|
import java.time.ZoneId;
|
||||||
|
import java.time.ZonedDateTime;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import org.apache.commons.lang3.time.DateFormatUtils;
|
import org.apache.commons.lang3.time.DateFormatUtils;
|
||||||
|
|
||||||
@ -22,7 +27,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
|
|||||||
public static String YYYYMMDDHHMMSS = "yyyyMMddHHmmss";
|
public static String YYYYMMDDHHMMSS = "yyyyMMddHHmmss";
|
||||||
|
|
||||||
public static String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
|
public static String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
|
||||||
|
|
||||||
private static String[] parsePatterns = {
|
private static String[] parsePatterns = {
|
||||||
"yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM",
|
"yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM",
|
||||||
"yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM",
|
"yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM",
|
||||||
@ -121,7 +126,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取服务器启动时间
|
* 获取服务器启动时间
|
||||||
*/
|
*/
|
||||||
@ -131,6 +136,14 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
|
|||||||
return new Date(time);
|
return new Date(time);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计算相差天数
|
||||||
|
*/
|
||||||
|
public static int differentDaysByMillisecond(Date date1, Date date2)
|
||||||
|
{
|
||||||
|
return Math.abs((int) ((date2.getTime() - date1.getTime()) / (1000 * 3600 * 24)));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 计算两个时间差
|
* 计算两个时间差
|
||||||
*/
|
*/
|
||||||
@ -152,4 +165,23 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
|
|||||||
// long sec = diff % nd % nh % nm / ns;
|
// long sec = diff % nd % nh % nm / ns;
|
||||||
return day + "天" + hour + "小时" + min + "分钟";
|
return day + "天" + hour + "小时" + min + "分钟";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 增加 LocalDateTime ==> Date
|
||||||
|
*/
|
||||||
|
public static Date toDate(LocalDateTime temporalAccessor)
|
||||||
|
{
|
||||||
|
ZonedDateTime zdt = temporalAccessor.atZone(ZoneId.systemDefault());
|
||||||
|
return Date.from(zdt.toInstant());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 增加 LocalDate ==> Date
|
||||||
|
*/
|
||||||
|
public static Date toDate(LocalDate temporalAccessor)
|
||||||
|
{
|
||||||
|
LocalDateTime localDateTime = LocalDateTime.of(temporalAccessor, LocalTime.of(0, 0, 0));
|
||||||
|
ZonedDateTime zdt = localDateTime.atZone(ZoneId.systemDefault());
|
||||||
|
return Date.from(zdt.toInstant());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -41,8 +41,7 @@ public class DictUtils
|
|||||||
Object cacheObj = SpringUtils.getBean(RedisCache.class).getCacheObject(getCacheKey(key));
|
Object cacheObj = SpringUtils.getBean(RedisCache.class).getCacheObject(getCacheKey(key));
|
||||||
if (StringUtils.isNotNull(cacheObj))
|
if (StringUtils.isNotNull(cacheObj))
|
||||||
{
|
{
|
||||||
List<SysDictData> dictDatas = StringUtils.cast(cacheObj);
|
return StringUtils.cast(cacheObj);
|
||||||
return dictDatas;
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -92,7 +91,7 @@ public class DictUtils
|
|||||||
{
|
{
|
||||||
if (value.equals(dict.getDictValue()))
|
if (value.equals(dict.getDictValue()))
|
||||||
{
|
{
|
||||||
propertyString.append(dict.getDictLabel() + separator);
|
propertyString.append(dict.getDictLabel()).append(separator);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -132,7 +131,7 @@ public class DictUtils
|
|||||||
{
|
{
|
||||||
if (label.equals(dict.getDictLabel()))
|
if (label.equals(dict.getDictLabel()))
|
||||||
{
|
{
|
||||||
propertyString.append(dict.getDictValue() + separator);
|
propertyString.append(dict.getDictValue()).append(separator);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,8 +18,7 @@ public class ExceptionUtil
|
|||||||
{
|
{
|
||||||
StringWriter sw = new StringWriter();
|
StringWriter sw = new StringWriter();
|
||||||
e.printStackTrace(new PrintWriter(sw, true));
|
e.printStackTrace(new PrintWriter(sw, true));
|
||||||
String str = sw.toString();
|
return sw.toString();
|
||||||
return str;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getRootErrorMessage(Exception e)
|
public static String getRootErrorMessage(Exception e)
|
||||||
|
|||||||
@ -0,0 +1,38 @@
|
|||||||
|
package com.ruoyi.common.utils;
|
||||||
|
|
||||||
|
import com.github.pagehelper.PageHelper;
|
||||||
|
import com.ruoyi.common.core.page.PageDomain;
|
||||||
|
import com.ruoyi.common.core.page.TableSupport;
|
||||||
|
import com.ruoyi.common.utils.sql.SqlUtil;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页工具类
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
*/
|
||||||
|
public class PageUtils extends PageHelper
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 设置请求分页数据
|
||||||
|
*/
|
||||||
|
public static void startPage()
|
||||||
|
{
|
||||||
|
PageDomain pageDomain = TableSupport.buildPageRequest();
|
||||||
|
Integer pageNum = pageDomain.getPageNum();
|
||||||
|
Integer pageSize = pageDomain.getPageSize();
|
||||||
|
if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize))
|
||||||
|
{
|
||||||
|
String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy());
|
||||||
|
Boolean reasonable = pageDomain.getReasonable();
|
||||||
|
PageHelper.startPage(pageNum, pageSize, orderBy).setReasonable(reasonable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 清理分页的线程变量
|
||||||
|
*/
|
||||||
|
public static void clearPage()
|
||||||
|
{
|
||||||
|
PageHelper.clearPage();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -99,9 +99,8 @@ public class ServletUtils
|
|||||||
*
|
*
|
||||||
* @param response 渲染对象
|
* @param response 渲染对象
|
||||||
* @param string 待渲染的字符串
|
* @param string 待渲染的字符串
|
||||||
* @return null
|
|
||||||
*/
|
*/
|
||||||
public static String renderString(HttpServletResponse response, String string)
|
public static void renderString(HttpServletResponse response, String string)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -114,7 +113,6 @@ public class ServletUtils
|
|||||||
{
|
{
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -125,13 +123,13 @@ public class ServletUtils
|
|||||||
public static boolean isAjaxRequest(HttpServletRequest request)
|
public static boolean isAjaxRequest(HttpServletRequest request)
|
||||||
{
|
{
|
||||||
String accept = request.getHeader("accept");
|
String accept = request.getHeader("accept");
|
||||||
if (accept != null && accept.indexOf("application/json") != -1)
|
if (accept != null && accept.contains("application/json"))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
String xRequestedWith = request.getHeader("X-Requested-With");
|
String xRequestedWith = request.getHeader("X-Requested-With");
|
||||||
if (xRequestedWith != null && xRequestedWith.indexOf("XMLHttpRequest") != -1)
|
if (xRequestedWith != null && xRequestedWith.contains("XMLHttpRequest"))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -143,10 +141,6 @@ public class ServletUtils
|
|||||||
}
|
}
|
||||||
|
|
||||||
String ajax = request.getParameter("__ajax");
|
String ajax = request.getParameter("__ajax");
|
||||||
if (StringUtils.inStringIgnoreCase(ajax, "json", "xml"))
|
return StringUtils.inStringIgnoreCase(ajax, "json", "xml");
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -531,4 +531,53 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
|
|||||||
{
|
{
|
||||||
return (T) obj;
|
return (T) obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数字左边补齐0,使之达到指定长度。注意,如果数字转换为字符串后,长度大于size,则只保留 最后size个字符。
|
||||||
|
*
|
||||||
|
* @param num 数字对象
|
||||||
|
* @param size 字符串指定长度
|
||||||
|
* @return 返回数字的字符串格式,该字符串为指定长度。
|
||||||
|
*/
|
||||||
|
public static final String padl(final Number num, final int size)
|
||||||
|
{
|
||||||
|
return padl(num.toString(), size, '0');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字符串左补齐。如果原始字符串s长度大于size,则只保留最后size个字符。
|
||||||
|
*
|
||||||
|
* @param s 原始字符串
|
||||||
|
* @param size 字符串指定长度
|
||||||
|
* @param c 用于补齐的字符
|
||||||
|
* @return 返回指定长度的字符串,由原字符串左补齐或截取得到。
|
||||||
|
*/
|
||||||
|
public static final String padl(final String s, final int size, final char c)
|
||||||
|
{
|
||||||
|
final StringBuilder sb = new StringBuilder(size);
|
||||||
|
if (s != null)
|
||||||
|
{
|
||||||
|
final int len = s.length();
|
||||||
|
if (s.length() <= size)
|
||||||
|
{
|
||||||
|
for (int i = size - len; i > 0; i--)
|
||||||
|
{
|
||||||
|
sb.append(c);
|
||||||
|
}
|
||||||
|
sb.append(s);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return s.substring(len - size, len);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (int i = size; i > 0; i--)
|
||||||
|
{
|
||||||
|
sb.append(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -1,228 +0,0 @@
|
|||||||
package com.ruoyi.common.utils;
|
|
||||||
|
|
||||||
import java.awt.Color;
|
|
||||||
import java.awt.Font;
|
|
||||||
import java.awt.Graphics;
|
|
||||||
import java.awt.Graphics2D;
|
|
||||||
import java.awt.RenderingHints;
|
|
||||||
import java.awt.geom.AffineTransform;
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.OutputStream;
|
|
||||||
import java.security.SecureRandom;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Random;
|
|
||||||
import javax.imageio.ImageIO;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 验证码工具类
|
|
||||||
*
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
public class VerifyCodeUtils
|
|
||||||
{
|
|
||||||
// 使用到Algerian字体,系统里没有的话需要安装字体,字体只显示大写,去掉了1,0,i,o几个容易混淆的字符
|
|
||||||
public static final String VERIFY_CODES = "123456789ABCDEFGHJKLMNPQRSTUVWXYZ";
|
|
||||||
|
|
||||||
private static Random random = new SecureRandom();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 使用系统默认字符源生成验证码
|
|
||||||
*
|
|
||||||
* @param verifySize 验证码长度
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static String generateVerifyCode(int verifySize)
|
|
||||||
{
|
|
||||||
return generateVerifyCode(verifySize, VERIFY_CODES);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 使用指定源生成验证码
|
|
||||||
*
|
|
||||||
* @param verifySize 验证码长度
|
|
||||||
* @param sources 验证码字符源
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static String generateVerifyCode(int verifySize, String sources)
|
|
||||||
{
|
|
||||||
if (sources == null || sources.length() == 0)
|
|
||||||
{
|
|
||||||
sources = VERIFY_CODES;
|
|
||||||
}
|
|
||||||
int codesLen = sources.length();
|
|
||||||
Random rand = new Random(System.currentTimeMillis());
|
|
||||||
StringBuilder verifyCode = new StringBuilder(verifySize);
|
|
||||||
for (int i = 0; i < verifySize; i++)
|
|
||||||
{
|
|
||||||
verifyCode.append(sources.charAt(rand.nextInt(codesLen - 1)));
|
|
||||||
}
|
|
||||||
return verifyCode.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 输出指定验证码图片流
|
|
||||||
*
|
|
||||||
* @param w
|
|
||||||
* @param h
|
|
||||||
* @param os
|
|
||||||
* @param code
|
|
||||||
* @throws IOException
|
|
||||||
*/
|
|
||||||
public static void outputImage(int w, int h, OutputStream os, String code) throws IOException
|
|
||||||
{
|
|
||||||
int verifySize = code.length();
|
|
||||||
BufferedImage image = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
|
|
||||||
Random rand = new Random();
|
|
||||||
Graphics2D g2 = image.createGraphics();
|
|
||||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
|
||||||
Color[] colors = new Color[5];
|
|
||||||
Color[] colorSpaces = new Color[] { Color.WHITE, Color.CYAN, Color.GRAY, Color.LIGHT_GRAY, Color.MAGENTA,
|
|
||||||
Color.ORANGE, Color.PINK, Color.YELLOW };
|
|
||||||
float[] fractions = new float[colors.length];
|
|
||||||
for (int i = 0; i < colors.length; i++)
|
|
||||||
{
|
|
||||||
colors[i] = colorSpaces[rand.nextInt(colorSpaces.length)];
|
|
||||||
fractions[i] = rand.nextFloat();
|
|
||||||
}
|
|
||||||
Arrays.sort(fractions);
|
|
||||||
|
|
||||||
g2.setColor(Color.GRAY);// 设置边框色
|
|
||||||
g2.fillRect(0, 0, w, h);
|
|
||||||
|
|
||||||
Color c = getRandColor(200, 250);
|
|
||||||
g2.setColor(c);// 设置背景色
|
|
||||||
g2.fillRect(0, 2, w, h - 4);
|
|
||||||
|
|
||||||
// 绘制干扰线
|
|
||||||
Random random = new Random();
|
|
||||||
g2.setColor(getRandColor(160, 200));// 设置线条的颜色
|
|
||||||
for (int i = 0; i < 20; i++)
|
|
||||||
{
|
|
||||||
int x = random.nextInt(w - 1);
|
|
||||||
int y = random.nextInt(h - 1);
|
|
||||||
int xl = random.nextInt(6) + 1;
|
|
||||||
int yl = random.nextInt(12) + 1;
|
|
||||||
g2.drawLine(x, y, x + xl + 40, y + yl + 20);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 添加噪点
|
|
||||||
float yawpRate = 0.05f;// 噪声率
|
|
||||||
int area = (int) (yawpRate * w * h);
|
|
||||||
for (int i = 0; i < area; i++)
|
|
||||||
{
|
|
||||||
int x = random.nextInt(w);
|
|
||||||
int y = random.nextInt(h);
|
|
||||||
int rgb = getRandomIntColor();
|
|
||||||
image.setRGB(x, y, rgb);
|
|
||||||
}
|
|
||||||
|
|
||||||
shear(g2, w, h, c);// 使图片扭曲
|
|
||||||
|
|
||||||
g2.setColor(getRandColor(100, 160));
|
|
||||||
int fontSize = h - 4;
|
|
||||||
Font font = new Font("Algerian", Font.ITALIC, fontSize);
|
|
||||||
g2.setFont(font);
|
|
||||||
char[] chars = code.toCharArray();
|
|
||||||
for (int i = 0; i < verifySize; i++)
|
|
||||||
{
|
|
||||||
AffineTransform affine = new AffineTransform();
|
|
||||||
affine.setToRotation(Math.PI / 4 * rand.nextDouble() * (rand.nextBoolean() ? 1 : -1),
|
|
||||||
(w / verifySize) * i + fontSize / 2, h / 2);
|
|
||||||
g2.setTransform(affine);
|
|
||||||
g2.drawChars(chars, i, 1, ((w - 10) / verifySize) * i + 5, h / 2 + fontSize / 2 - 10);
|
|
||||||
}
|
|
||||||
|
|
||||||
g2.dispose();
|
|
||||||
ImageIO.write(image, "jpg", os);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Color getRandColor(int fc, int bc)
|
|
||||||
{
|
|
||||||
if (fc > 255) {
|
|
||||||
fc = 255;
|
|
||||||
}
|
|
||||||
if (bc > 255) {
|
|
||||||
bc = 255;
|
|
||||||
}
|
|
||||||
int r = fc + random.nextInt(bc - fc);
|
|
||||||
int g = fc + random.nextInt(bc - fc);
|
|
||||||
int b = fc + random.nextInt(bc - fc);
|
|
||||||
return new Color(r, g, b);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static int getRandomIntColor()
|
|
||||||
{
|
|
||||||
int[] rgb = getRandomRgb();
|
|
||||||
int color = 0;
|
|
||||||
for (int c : rgb)
|
|
||||||
{
|
|
||||||
color = color << 8;
|
|
||||||
color = color | c;
|
|
||||||
}
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static int[] getRandomRgb()
|
|
||||||
{
|
|
||||||
int[] rgb = new int[3];
|
|
||||||
for (int i = 0; i < 3; i++)
|
|
||||||
{
|
|
||||||
rgb[i] = random.nextInt(255);
|
|
||||||
}
|
|
||||||
return rgb;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void shear(Graphics g, int w1, int h1, Color color)
|
|
||||||
{
|
|
||||||
shearX(g, w1, h1, color);
|
|
||||||
shearY(g, w1, h1, color);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void shearX(Graphics g, int w1, int h1, Color color)
|
|
||||||
{
|
|
||||||
|
|
||||||
int period = random.nextInt(2);
|
|
||||||
|
|
||||||
boolean borderGap = true;
|
|
||||||
int frames = 1;
|
|
||||||
int phase = random.nextInt(2);
|
|
||||||
|
|
||||||
for (int i = 0; i < h1; i++)
|
|
||||||
{
|
|
||||||
double d = (double) (period >> 1)
|
|
||||||
* Math.sin((double) i / (double) period + (6.2831853071795862D * (double) phase) / (double) frames);
|
|
||||||
g.copyArea(0, i, w1, 1, (int) d, 0);
|
|
||||||
if (borderGap)
|
|
||||||
{
|
|
||||||
g.setColor(color);
|
|
||||||
g.drawLine((int) d, i, 0, i);
|
|
||||||
g.drawLine((int) d + w1, i, w1, i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void shearY(Graphics g, int w1, int h1, Color color)
|
|
||||||
{
|
|
||||||
|
|
||||||
int period = random.nextInt(40) + 10; // 50;
|
|
||||||
|
|
||||||
boolean borderGap = true;
|
|
||||||
int frames = 20;
|
|
||||||
int phase = 7;
|
|
||||||
for (int i = 0; i < w1; i++)
|
|
||||||
{
|
|
||||||
double d = (double) (period >> 1)
|
|
||||||
* Math.sin((double) i / (double) period + (6.2831853071795862D * (double) phase) / (double) frames);
|
|
||||||
g.copyArea(i, 0, 1, h1, 0, (int) d);
|
|
||||||
if (borderGap)
|
|
||||||
{
|
|
||||||
g.setColor(color);
|
|
||||||
g.drawLine(i, (int) d, i, 0);
|
|
||||||
g.drawLine(i, (int) d + h1, i, h1);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -0,0 +1,24 @@
|
|||||||
|
package com.ruoyi.common.utils.bean;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
import javax.validation.ConstraintViolation;
|
||||||
|
import javax.validation.ConstraintViolationException;
|
||||||
|
import javax.validation.Validator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* bean对象属性验证
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
*/
|
||||||
|
public class BeanValidators
|
||||||
|
{
|
||||||
|
public static void validateWithException(Validator validator, Object object, Class<?>... groups)
|
||||||
|
throws ConstraintViolationException
|
||||||
|
{
|
||||||
|
Set<ConstraintViolation<Object>> constraintViolations = validator.validate(object, groups);
|
||||||
|
if (!constraintViolations.isEmpty())
|
||||||
|
{
|
||||||
|
throw new ConstraintViolationException(constraintViolations);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -2,6 +2,8 @@ package com.ruoyi.common.utils.file;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
import java.util.Objects;
|
||||||
import org.apache.commons.io.FilenameUtils;
|
import org.apache.commons.io.FilenameUtils;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import com.ruoyi.common.config.RuoYiConfig;
|
import com.ruoyi.common.config.RuoYiConfig;
|
||||||
@ -11,7 +13,7 @@ import com.ruoyi.common.exception.file.FileSizeLimitExceededException;
|
|||||||
import com.ruoyi.common.exception.file.InvalidExtensionException;
|
import com.ruoyi.common.exception.file.InvalidExtensionException;
|
||||||
import com.ruoyi.common.utils.DateUtils;
|
import com.ruoyi.common.utils.DateUtils;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
import com.ruoyi.common.utils.uuid.IdUtils;
|
import com.ruoyi.common.utils.uuid.Seq;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文件上传工具类
|
* 文件上传工具类
|
||||||
@ -100,7 +102,7 @@ public class FileUploadUtils
|
|||||||
throws FileSizeLimitExceededException, IOException, FileNameLengthLimitExceededException,
|
throws FileSizeLimitExceededException, IOException, FileNameLengthLimitExceededException,
|
||||||
InvalidExtensionException
|
InvalidExtensionException
|
||||||
{
|
{
|
||||||
int fileNamelength = file.getOriginalFilename().length();
|
int fileNamelength = Objects.requireNonNull(file.getOriginalFilename()).length();
|
||||||
if (fileNamelength > FileUploadUtils.DEFAULT_FILE_NAME_LENGTH)
|
if (fileNamelength > FileUploadUtils.DEFAULT_FILE_NAME_LENGTH)
|
||||||
{
|
{
|
||||||
throw new FileNameLengthLimitExceededException(FileUploadUtils.DEFAULT_FILE_NAME_LENGTH);
|
throw new FileNameLengthLimitExceededException(FileUploadUtils.DEFAULT_FILE_NAME_LENGTH);
|
||||||
@ -110,10 +112,9 @@ public class FileUploadUtils
|
|||||||
|
|
||||||
String fileName = extractFilename(file);
|
String fileName = extractFilename(file);
|
||||||
|
|
||||||
File desc = getAbsoluteFile(baseDir, fileName);
|
String absPath = getAbsoluteFile(baseDir, fileName).getAbsolutePath();
|
||||||
file.transferTo(desc);
|
file.transferTo(Paths.get(absPath));
|
||||||
String pathFileName = getPathFileName(baseDir, fileName);
|
return getPathFileName(baseDir, fileName);
|
||||||
return pathFileName;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -121,10 +122,8 @@ public class FileUploadUtils
|
|||||||
*/
|
*/
|
||||||
public static final String extractFilename(MultipartFile file)
|
public static final String extractFilename(MultipartFile file)
|
||||||
{
|
{
|
||||||
String fileName = file.getOriginalFilename();
|
return StringUtils.format("{}/{}_{}.{}", DateUtils.datePath(),
|
||||||
String extension = getExtension(file);
|
FilenameUtils.getBaseName(file.getOriginalFilename()), Seq.getId(Seq.uploadSeqType), getExtension(file));
|
||||||
fileName = DateUtils.datePath() + "/" + IdUtils.fastUUID() + "." + extension;
|
|
||||||
return fileName;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final File getAbsoluteFile(String uploadDir, String fileName) throws IOException
|
public static final File getAbsoluteFile(String uploadDir, String fileName) throws IOException
|
||||||
@ -145,8 +144,7 @@ public class FileUploadUtils
|
|||||||
{
|
{
|
||||||
int dirLastIndex = RuoYiConfig.getProfile().length() + 1;
|
int dirLastIndex = RuoYiConfig.getProfile().length() + 1;
|
||||||
String currentDir = StringUtils.substring(uploadDir, dirLastIndex);
|
String currentDir = StringUtils.substring(uploadDir, dirLastIndex);
|
||||||
String pathFileName = Constants.RESOURCE_PREFIX + "/" + currentDir + "/" + fileName;
|
return Constants.RESOURCE_PREFIX + "/" + currentDir + "/" + fileName;
|
||||||
return pathFileName;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -161,7 +159,7 @@ public class FileUploadUtils
|
|||||||
throws FileSizeLimitExceededException, InvalidExtensionException
|
throws FileSizeLimitExceededException, InvalidExtensionException
|
||||||
{
|
{
|
||||||
long size = file.getSize();
|
long size = file.getSize();
|
||||||
if (DEFAULT_MAX_SIZE != -1 && size > DEFAULT_MAX_SIZE)
|
if (size > DEFAULT_MAX_SIZE)
|
||||||
{
|
{
|
||||||
throw new FileSizeLimitExceededException(DEFAULT_MAX_SIZE / 1024 / 1024);
|
throw new FileSizeLimitExceededException(DEFAULT_MAX_SIZE / 1024 / 1024);
|
||||||
}
|
}
|
||||||
@ -228,7 +226,7 @@ public class FileUploadUtils
|
|||||||
String extension = FilenameUtils.getExtension(file.getOriginalFilename());
|
String extension = FilenameUtils.getExtension(file.getOriginalFilename());
|
||||||
if (StringUtils.isEmpty(extension))
|
if (StringUtils.isEmpty(extension))
|
||||||
{
|
{
|
||||||
extension = MimeTypeUtils.getExtension(file.getContentType());
|
extension = MimeTypeUtils.getExtension(Objects.requireNonNull(file.getContentType()));
|
||||||
}
|
}
|
||||||
return extension;
|
return extension;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -196,7 +196,6 @@ public class FileUtils
|
|||||||
*
|
*
|
||||||
* @param response 响应对象
|
* @param response 响应对象
|
||||||
* @param realFileName 真实文件名
|
* @param realFileName 真实文件名
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public static void setAttachmentResponseHeader(HttpServletResponse response, String realFileName) throws UnsupportedEncodingException
|
public static void setAttachmentResponseHeader(HttpServletResponse response, String realFileName) throws UnsupportedEncodingException
|
||||||
{
|
{
|
||||||
@ -210,7 +209,6 @@ public class FileUtils
|
|||||||
.append("utf-8''")
|
.append("utf-8''")
|
||||||
.append(percentEncodedFileName);
|
.append(percentEncodedFileName);
|
||||||
|
|
||||||
response.addHeader("Access-Control-Allow-Origin", "*");
|
|
||||||
response.addHeader("Access-Control-Expose-Headers", "Content-Disposition,download-filename");
|
response.addHeader("Access-Control-Expose-Headers", "Content-Disposition,download-filename");
|
||||||
response.setHeader("Content-disposition", contentDispositionValue.toString());
|
response.setHeader("Content-disposition", contentDispositionValue.toString());
|
||||||
response.setHeader("download-filename", percentEncodedFileName);
|
response.setHeader("download-filename", percentEncodedFileName);
|
||||||
@ -256,4 +254,22 @@ public class FileUtils
|
|||||||
}
|
}
|
||||||
return strFileExtendName;
|
return strFileExtendName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取名称
|
||||||
|
*
|
||||||
|
* @param fileName 路径名称
|
||||||
|
* @return 没有文件路径的名称
|
||||||
|
*/
|
||||||
|
public static String getName(String fileName)
|
||||||
|
{
|
||||||
|
if (fileName == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
int lastUnixPos = fileName.lastIndexOf('/');
|
||||||
|
int lastWindowsPos = fileName.lastIndexOf('\\');
|
||||||
|
int index = Math.max(lastUnixPos, lastWindowsPos);
|
||||||
|
return fileName.substring(index + 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
package com.ruoyi.common.utils.file;
|
package com.ruoyi.common.utils.file;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
@ -59,13 +58,12 @@ public class ImageUtils
|
|||||||
/**
|
/**
|
||||||
* 读取文件为字节数据
|
* 读取文件为字节数据
|
||||||
*
|
*
|
||||||
* @param key 地址
|
* @param url 地址
|
||||||
* @return 字节数据
|
* @return 字节数据
|
||||||
*/
|
*/
|
||||||
public static byte[] readFile(String url)
|
public static byte[] readFile(String url)
|
||||||
{
|
{
|
||||||
InputStream in = null;
|
InputStream in = null;
|
||||||
ByteArrayOutputStream baos = null;
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (url.startsWith("http"))
|
if (url.startsWith("http"))
|
||||||
@ -95,7 +93,6 @@ public class ImageUtils
|
|||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
IOUtils.closeQuietly(in);
|
IOUtils.closeQuietly(in);
|
||||||
IOUtils.closeQuietly(baos);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import java.io.BufferedReader;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.StandardCharsets;
|
||||||
import javax.servlet.ServletRequest;
|
import javax.servlet.ServletRequest;
|
||||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@ -25,7 +25,7 @@ public class HttpHelper
|
|||||||
BufferedReader reader = null;
|
BufferedReader reader = null;
|
||||||
try (InputStream inputStream = request.getInputStream())
|
try (InputStream inputStream = request.getInputStream())
|
||||||
{
|
{
|
||||||
reader = new BufferedReader(new InputStreamReader(inputStream, Charset.forName("UTF-8")));
|
reader = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8));
|
||||||
String line = "";
|
String line = "";
|
||||||
while ((line = reader.readLine()) != null)
|
while ((line = reader.readLine()) != null)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -9,6 +9,7 @@ import java.net.ConnectException;
|
|||||||
import java.net.SocketTimeoutException;
|
import java.net.SocketTimeoutException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLConnection;
|
import java.net.URLConnection;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.security.cert.X509Certificate;
|
import java.security.cert.X509Certificate;
|
||||||
import javax.net.ssl.HostnameVerifier;
|
import javax.net.ssl.HostnameVerifier;
|
||||||
import javax.net.ssl.HttpsURLConnection;
|
import javax.net.ssl.HttpsURLConnection;
|
||||||
@ -130,9 +131,8 @@ public class HttpUtils
|
|||||||
StringBuilder result = new StringBuilder();
|
StringBuilder result = new StringBuilder();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
String urlNameString = url;
|
log.info("sendPost - {}", url);
|
||||||
log.info("sendPost - {}", urlNameString);
|
URL realUrl = new URL(url);
|
||||||
URL realUrl = new URL(urlNameString);
|
|
||||||
URLConnection conn = realUrl.openConnection();
|
URLConnection conn = realUrl.openConnection();
|
||||||
conn.setRequestProperty("accept", "*/*");
|
conn.setRequestProperty("accept", "*/*");
|
||||||
conn.setRequestProperty("connection", "Keep-Alive");
|
conn.setRequestProperty("connection", "Keep-Alive");
|
||||||
@ -144,7 +144,7 @@ public class HttpUtils
|
|||||||
out = new PrintWriter(conn.getOutputStream());
|
out = new PrintWriter(conn.getOutputStream());
|
||||||
out.print(param);
|
out.print(param);
|
||||||
out.flush();
|
out.flush();
|
||||||
in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "utf-8"));
|
in = new BufferedReader(new InputStreamReader(conn.getInputStream(), StandardCharsets.UTF_8));
|
||||||
String line;
|
String line;
|
||||||
while ((line = in.readLine()) != null)
|
while ((line = in.readLine()) != null)
|
||||||
{
|
{
|
||||||
@ -218,7 +218,7 @@ public class HttpUtils
|
|||||||
{
|
{
|
||||||
if (ret != null && !"".equals(ret.trim()))
|
if (ret != null && !"".equals(ret.trim()))
|
||||||
{
|
{
|
||||||
result.append(new String(ret.getBytes("ISO-8859-1"), "utf-8"));
|
result.append(new String(ret.getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log.info("recv - {}", result);
|
log.info("recv - {}", result);
|
||||||
|
|||||||
@ -25,7 +25,6 @@ public class AddressUtils
|
|||||||
|
|
||||||
public static String getRealAddressByIP(String ip)
|
public static String getRealAddressByIP(String ip)
|
||||||
{
|
{
|
||||||
String address = UNKNOWN;
|
|
||||||
// 内网不查询
|
// 内网不查询
|
||||||
if (IpUtils.internalIp(ip))
|
if (IpUtils.internalIp(ip))
|
||||||
{
|
{
|
||||||
@ -51,6 +50,6 @@ public class AddressUtils
|
|||||||
log.error("获取地理位置异常 {}", ip);
|
log.error("获取地理位置异常 {}", ip);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return address;
|
return UNKNOWN;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,7 +4,6 @@ import java.net.InetAddress;
|
|||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
import com.ruoyi.common.utils.html.EscapeUtil;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取IP方法
|
* 获取IP方法
|
||||||
@ -13,6 +12,12 @@ import com.ruoyi.common.utils.html.EscapeUtil;
|
|||||||
*/
|
*/
|
||||||
public class IpUtils
|
public class IpUtils
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* 获取客户端IP
|
||||||
|
*
|
||||||
|
* @param request 请求对象
|
||||||
|
* @return IP地址
|
||||||
|
*/
|
||||||
public static String getIpAddr(HttpServletRequest request)
|
public static String getIpAddr(HttpServletRequest request)
|
||||||
{
|
{
|
||||||
if (request == null)
|
if (request == null)
|
||||||
@ -41,15 +46,28 @@ public class IpUtils
|
|||||||
{
|
{
|
||||||
ip = request.getRemoteAddr();
|
ip = request.getRemoteAddr();
|
||||||
}
|
}
|
||||||
return "0:0:0:0:0:0:0:1".equals(ip) ? "127.0.0.1" : EscapeUtil.clean(ip);
|
|
||||||
|
return "0:0:0:0:0:0:0:1".equals(ip) ? "127.0.0.1" : getMultistageReverseProxyIp(ip);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查是否为内部IP地址
|
||||||
|
*
|
||||||
|
* @param ip IP地址
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
public static boolean internalIp(String ip)
|
public static boolean internalIp(String ip)
|
||||||
{
|
{
|
||||||
byte[] addr = textToNumericFormatV4(ip);
|
byte[] addr = textToNumericFormatV4(ip);
|
||||||
return internalIp(addr) || "127.0.0.1".equals(ip);
|
return internalIp(addr) || "127.0.0.1".equals(ip);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查是否为内部IP地址
|
||||||
|
*
|
||||||
|
* @param addr byte地址
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
private static boolean internalIp(byte[] addr)
|
private static boolean internalIp(byte[] addr)
|
||||||
{
|
{
|
||||||
if (StringUtils.isNull(addr) || addr.length < 2)
|
if (StringUtils.isNull(addr) || addr.length < 2)
|
||||||
@ -110,7 +128,8 @@ public class IpUtils
|
|||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
l = Long.parseLong(elements[0]);
|
l = Long.parseLong(elements[0]);
|
||||||
if ((l < 0L) || (l > 4294967295L)) {
|
if ((l < 0L) || (l > 4294967295L))
|
||||||
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
bytes[0] = (byte) (int) (l >> 24 & 0xFF);
|
bytes[0] = (byte) (int) (l >> 24 & 0xFF);
|
||||||
@ -120,12 +139,14 @@ public class IpUtils
|
|||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
l = Integer.parseInt(elements[0]);
|
l = Integer.parseInt(elements[0]);
|
||||||
if ((l < 0L) || (l > 255L)) {
|
if ((l < 0L) || (l > 255L))
|
||||||
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
bytes[0] = (byte) (int) (l & 0xFF);
|
bytes[0] = (byte) (int) (l & 0xFF);
|
||||||
l = Integer.parseInt(elements[1]);
|
l = Integer.parseInt(elements[1]);
|
||||||
if ((l < 0L) || (l > 16777215L)) {
|
if ((l < 0L) || (l > 16777215L))
|
||||||
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
bytes[1] = (byte) (int) (l >> 16 & 0xFF);
|
bytes[1] = (byte) (int) (l >> 16 & 0xFF);
|
||||||
@ -136,13 +157,15 @@ public class IpUtils
|
|||||||
for (i = 0; i < 2; ++i)
|
for (i = 0; i < 2; ++i)
|
||||||
{
|
{
|
||||||
l = Integer.parseInt(elements[i]);
|
l = Integer.parseInt(elements[i]);
|
||||||
if ((l < 0L) || (l > 255L)) {
|
if ((l < 0L) || (l > 255L))
|
||||||
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
bytes[i] = (byte) (int) (l & 0xFF);
|
bytes[i] = (byte) (int) (l & 0xFF);
|
||||||
}
|
}
|
||||||
l = Integer.parseInt(elements[2]);
|
l = Integer.parseInt(elements[2]);
|
||||||
if ((l < 0L) || (l > 65535L)) {
|
if ((l < 0L) || (l > 65535L))
|
||||||
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
bytes[2] = (byte) (int) (l >> 8 & 0xFF);
|
bytes[2] = (byte) (int) (l >> 8 & 0xFF);
|
||||||
@ -152,7 +175,8 @@ public class IpUtils
|
|||||||
for (i = 0; i < 4; ++i)
|
for (i = 0; i < 4; ++i)
|
||||||
{
|
{
|
||||||
l = Integer.parseInt(elements[i]);
|
l = Integer.parseInt(elements[i]);
|
||||||
if ((l < 0L) || (l > 255L)) {
|
if ((l < 0L) || (l > 255L))
|
||||||
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
bytes[i] = (byte) (int) (l & 0xFF);
|
bytes[i] = (byte) (int) (l & 0xFF);
|
||||||
@ -169,6 +193,11 @@ public class IpUtils
|
|||||||
return bytes;
|
return bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取IP地址
|
||||||
|
*
|
||||||
|
* @return 本地IP地址
|
||||||
|
*/
|
||||||
public static String getHostIp()
|
public static String getHostIp()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -181,6 +210,11 @@ public class IpUtils
|
|||||||
return "127.0.0.1";
|
return "127.0.0.1";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取主机名
|
||||||
|
*
|
||||||
|
* @return 本地主机名
|
||||||
|
*/
|
||||||
public static String getHostName()
|
public static String getHostName()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -192,4 +226,39 @@ public class IpUtils
|
|||||||
}
|
}
|
||||||
return "未知";
|
return "未知";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从多级反向代理中获得第一个非unknown IP地址
|
||||||
|
*
|
||||||
|
* @param ip 获得的IP地址
|
||||||
|
* @return 第一个非unknown IP地址
|
||||||
|
*/
|
||||||
|
public static String getMultistageReverseProxyIp(String ip)
|
||||||
|
{
|
||||||
|
// 多级反向代理检测
|
||||||
|
if (ip != null && ip.indexOf(",") > 0)
|
||||||
|
{
|
||||||
|
final String[] ips = ip.trim().split(",");
|
||||||
|
for (String subIp : ips)
|
||||||
|
{
|
||||||
|
if (false == isUnknown(subIp))
|
||||||
|
{
|
||||||
|
ip = subIp;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ip;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检测给定字符串是否为未知,多用于检测HTTP请求相关
|
||||||
|
*
|
||||||
|
* @param checkString 被检测的字符串
|
||||||
|
* @return 是否未知
|
||||||
|
*/
|
||||||
|
public static boolean isUnknown(String checkString)
|
||||||
|
{
|
||||||
|
return StringUtils.isBlank(checkString) || "unknown".equalsIgnoreCase(checkString);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -9,6 +9,8 @@ import java.lang.reflect.Field;
|
|||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
@ -20,6 +22,7 @@ import java.util.Set;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import org.apache.commons.lang3.RegExUtils;
|
||||||
import org.apache.poi.hssf.usermodel.HSSFClientAnchor;
|
import org.apache.poi.hssf.usermodel.HSSFClientAnchor;
|
||||||
import org.apache.poi.hssf.usermodel.HSSFPicture;
|
import org.apache.poi.hssf.usermodel.HSSFPicture;
|
||||||
import org.apache.poi.hssf.usermodel.HSSFPictureData;
|
import org.apache.poi.hssf.usermodel.HSSFPictureData;
|
||||||
@ -86,6 +89,10 @@ public class ExcelUtil<T>
|
|||||||
{
|
{
|
||||||
private static final Logger log = LoggerFactory.getLogger(ExcelUtil.class);
|
private static final Logger log = LoggerFactory.getLogger(ExcelUtil.class);
|
||||||
|
|
||||||
|
public static final String FORMULA_REGEX_STR = "=|-|\\+|@";
|
||||||
|
|
||||||
|
public static final String[] FORMULA_STR = { "=", "-", "+", "@" };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Excel sheet最大行数,默认65536
|
* Excel sheet最大行数,默认65536
|
||||||
*/
|
*/
|
||||||
@ -130,7 +137,7 @@ public class ExcelUtil<T>
|
|||||||
* 当前行号
|
* 当前行号
|
||||||
*/
|
*/
|
||||||
private int rownum;
|
private int rownum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 标题
|
* 标题
|
||||||
*/
|
*/
|
||||||
@ -312,7 +319,7 @@ public class ExcelUtil<T>
|
|||||||
String dateFormat = field.getAnnotation(Excel.class).dateFormat();
|
String dateFormat = field.getAnnotation(Excel.class).dateFormat();
|
||||||
if (StringUtils.isNotEmpty(dateFormat))
|
if (StringUtils.isNotEmpty(dateFormat))
|
||||||
{
|
{
|
||||||
val = DateUtils.parseDateToStr(dateFormat, (Date) val);
|
val = parseDateToStr(dateFormat, val);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -324,7 +331,7 @@ public class ExcelUtil<T>
|
|||||||
{
|
{
|
||||||
val = Convert.toInt(val);
|
val = Convert.toInt(val);
|
||||||
}
|
}
|
||||||
else if (Long.TYPE == fieldType || Long.class == fieldType)
|
else if ((Long.TYPE == fieldType || Long.class == fieldType) && StringUtils.isNumeric(Convert.toStr(val)))
|
||||||
{
|
{
|
||||||
val = Convert.toLong(val);
|
val = Convert.toLong(val);
|
||||||
}
|
}
|
||||||
@ -407,7 +414,7 @@ public class ExcelUtil<T>
|
|||||||
{
|
{
|
||||||
return exportExcel(list, sheetName, StringUtils.EMPTY);
|
return exportExcel(list, sheetName, StringUtils.EMPTY);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 对list数据源将其里面的数据导入到excel表单
|
* 对list数据源将其里面的数据导入到excel表单
|
||||||
*
|
*
|
||||||
@ -429,7 +436,6 @@ public class ExcelUtil<T>
|
|||||||
* @param list 导出数据集合
|
* @param list 导出数据集合
|
||||||
* @param sheetName 工作表的名称
|
* @param sheetName 工作表的名称
|
||||||
* @return 结果
|
* @return 结果
|
||||||
* @throws IOException
|
|
||||||
*/
|
*/
|
||||||
public void exportExcel(HttpServletResponse response, List<T> list, String sheetName)
|
public void exportExcel(HttpServletResponse response, List<T> list, String sheetName)
|
||||||
{
|
{
|
||||||
@ -444,7 +450,6 @@ public class ExcelUtil<T>
|
|||||||
* @param sheetName 工作表的名称
|
* @param sheetName 工作表的名称
|
||||||
* @param title 标题
|
* @param title 标题
|
||||||
* @return 结果
|
* @return 结果
|
||||||
* @throws IOException
|
|
||||||
*/
|
*/
|
||||||
public void exportExcel(HttpServletResponse response, List<T> list, String sheetName, String title)
|
public void exportExcel(HttpServletResponse response, List<T> list, String sheetName, String title)
|
||||||
{
|
{
|
||||||
@ -710,7 +715,13 @@ public class ExcelUtil<T>
|
|||||||
{
|
{
|
||||||
if (ColumnType.STRING == attr.cellType())
|
if (ColumnType.STRING == attr.cellType())
|
||||||
{
|
{
|
||||||
cell.setCellValue(StringUtils.isNull(value) ? attr.defaultValue() : value + attr.suffix());
|
String cellValue = Convert.toStr(value);
|
||||||
|
// 对于任何以表达式触发字符 =-+@开头的单元格,直接使用tab字符作为前缀,防止CSV注入。
|
||||||
|
if (StringUtils.startsWithAny(cellValue, FORMULA_STR))
|
||||||
|
{
|
||||||
|
cellValue = RegExUtils.replaceFirst(cellValue, FORMULA_REGEX_STR, "\t$0");
|
||||||
|
}
|
||||||
|
cell.setCellValue(StringUtils.isNull(cellValue) ? attr.defaultValue() : cellValue + attr.suffix());
|
||||||
}
|
}
|
||||||
else if (ColumnType.NUMERIC == attr.cellType())
|
else if (ColumnType.NUMERIC == attr.cellType())
|
||||||
{
|
{
|
||||||
@ -815,7 +826,7 @@ public class ExcelUtil<T>
|
|||||||
String dictType = attr.dictType();
|
String dictType = attr.dictType();
|
||||||
if (StringUtils.isNotEmpty(dateFormat) && StringUtils.isNotNull(value))
|
if (StringUtils.isNotEmpty(dateFormat) && StringUtils.isNotNull(value))
|
||||||
{
|
{
|
||||||
cell.setCellValue(DateUtils.parseDateToStr(dateFormat, (Date) value));
|
cell.setCellValue(parseDateToStr(dateFormat, value));
|
||||||
}
|
}
|
||||||
else if (StringUtils.isNotEmpty(readConverterExp) && StringUtils.isNotNull(value))
|
else if (StringUtils.isNotEmpty(readConverterExp) && StringUtils.isNotNull(value))
|
||||||
{
|
{
|
||||||
@ -1113,7 +1124,7 @@ public class ExcelUtil<T>
|
|||||||
if (StringUtils.isNotEmpty(excel.targetAttr()))
|
if (StringUtils.isNotEmpty(excel.targetAttr()))
|
||||||
{
|
{
|
||||||
String target = excel.targetAttr();
|
String target = excel.targetAttr();
|
||||||
if (target.indexOf(".") > -1)
|
if (target.contains("."))
|
||||||
{
|
{
|
||||||
String[] targets = target.split("[.]");
|
String[] targets = target.split("[.]");
|
||||||
for (String name : targets)
|
for (String name : targets)
|
||||||
@ -1208,7 +1219,7 @@ public class ExcelUtil<T>
|
|||||||
for (Object[] os : this.fields)
|
for (Object[] os : this.fields)
|
||||||
{
|
{
|
||||||
Excel excel = (Excel) os[1];
|
Excel excel = (Excel) os[1];
|
||||||
maxHeight = maxHeight > excel.height() ? maxHeight : excel.height();
|
maxHeight = Math.max(maxHeight, excel.height());
|
||||||
}
|
}
|
||||||
return (short) (maxHeight * 20);
|
return (short) (maxHeight * 20);
|
||||||
}
|
}
|
||||||
@ -1388,4 +1399,37 @@ public class ExcelUtil<T>
|
|||||||
}
|
}
|
||||||
return sheetIndexPicMap;
|
return sheetIndexPicMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 格式化不同类型的日期对象
|
||||||
|
*
|
||||||
|
* @param dateFormat 日期格式
|
||||||
|
* @param val 被格式化的日期对象
|
||||||
|
* @return 格式化后的日期字符
|
||||||
|
*/
|
||||||
|
public String parseDateToStr(String dateFormat, Object val)
|
||||||
|
{
|
||||||
|
if (val == null)
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
String str;
|
||||||
|
if (val instanceof Date)
|
||||||
|
{
|
||||||
|
str = DateUtils.parseDateToStr(dateFormat, (Date) val);
|
||||||
|
}
|
||||||
|
else if (val instanceof LocalDateTime)
|
||||||
|
{
|
||||||
|
str = DateUtils.parseDateToStr(dateFormat, DateUtils.toDate((LocalDateTime) val));
|
||||||
|
}
|
||||||
|
else if (val instanceof LocalDate)
|
||||||
|
{
|
||||||
|
str = DateUtils.parseDateToStr(dateFormat, DateUtils.toDate((LocalDate) val));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
str = val.toString();
|
||||||
|
}
|
||||||
|
return str;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
package com.ruoyi.common.utils.sign;
|
package com.ruoyi.common.utils.sign;
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.security.MessageDigest;
|
import java.security.MessageDigest;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@ -55,7 +56,7 @@ public class Md5Utils
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return new String(toHex(md5(s)).getBytes("UTF-8"), "UTF-8");
|
return new String(toHex(md5(s)).getBytes(StandardCharsets.UTF_8), StandardCharsets.UTF_8);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -10,6 +10,11 @@ import com.ruoyi.common.utils.StringUtils;
|
|||||||
*/
|
*/
|
||||||
public class SqlUtil
|
public class SqlUtil
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* 定义常用的 sql关键字
|
||||||
|
*/
|
||||||
|
public static String SQL_REGEX = "select |insert |delete |update |drop |count |exec |chr |mid |master |truncate |char |and |declare ";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 仅支持字母、数字、下划线、空格、逗号、小数点(支持多个字段排序)
|
* 仅支持字母、数字、下划线、空格、逗号、小数点(支持多个字段排序)
|
||||||
*/
|
*/
|
||||||
@ -34,4 +39,23 @@ public class SqlUtil
|
|||||||
{
|
{
|
||||||
return value.matches(SQL_PATTERN);
|
return value.matches(SQL_PATTERN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SQL关键字检查
|
||||||
|
*/
|
||||||
|
public static void filterKeyword(String value)
|
||||||
|
{
|
||||||
|
if (StringUtils.isEmpty(value))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String[] sqlKeywords = StringUtils.split(SQL_REGEX, "\\|");
|
||||||
|
for (String sqlKeyword : sqlKeywords)
|
||||||
|
{
|
||||||
|
if (StringUtils.indexOfIgnoreCase(value, sqlKeyword) > -1)
|
||||||
|
{
|
||||||
|
throw new UtilException("参数存在SQL注入风险");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,86 @@
|
|||||||
|
package com.ruoyi.common.utils.uuid;
|
||||||
|
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
import com.ruoyi.common.utils.DateUtils;
|
||||||
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author ruoyi 序列生成类
|
||||||
|
*/
|
||||||
|
public class Seq
|
||||||
|
{
|
||||||
|
// 通用序列类型
|
||||||
|
public static final String commSeqType = "COMMON";
|
||||||
|
|
||||||
|
// 上传序列类型
|
||||||
|
public static final String uploadSeqType = "UPLOAD";
|
||||||
|
|
||||||
|
// 通用接口序列数
|
||||||
|
private static AtomicInteger commSeq = new AtomicInteger(1);
|
||||||
|
|
||||||
|
// 上传接口序列数
|
||||||
|
private static AtomicInteger uploadSeq = new AtomicInteger(1);
|
||||||
|
|
||||||
|
// 机器标识
|
||||||
|
private static String machineCode = "A";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取通用序列号
|
||||||
|
*
|
||||||
|
* @return 序列值
|
||||||
|
*/
|
||||||
|
public static String getId()
|
||||||
|
{
|
||||||
|
return getId(commSeqType);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 默认16位序列号 yyMMddHHmmss + 一位机器标识 + 3长度循环递增字符串
|
||||||
|
*
|
||||||
|
* @return 序列值
|
||||||
|
*/
|
||||||
|
public static String getId(String type)
|
||||||
|
{
|
||||||
|
AtomicInteger atomicInt = commSeq;
|
||||||
|
if (uploadSeqType.equals(type))
|
||||||
|
{
|
||||||
|
atomicInt = uploadSeq;
|
||||||
|
}
|
||||||
|
return getId(atomicInt, 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通用接口序列号 yyMMddHHmmss + 一位机器标识 + length长度循环递增字符串
|
||||||
|
*
|
||||||
|
* @param atomicInt 序列数
|
||||||
|
* @param length 数值长度
|
||||||
|
* @return 序列值
|
||||||
|
*/
|
||||||
|
public static String getId(AtomicInteger atomicInt, int length)
|
||||||
|
{
|
||||||
|
String result = DateUtils.dateTimeNow();
|
||||||
|
result += machineCode;
|
||||||
|
result += getSeq(atomicInt, length);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 序列循环递增字符串[1, 10 的 (length)幂次方), 用0左补齐length位数
|
||||||
|
*
|
||||||
|
* @return 序列值
|
||||||
|
*/
|
||||||
|
private synchronized static String getSeq(AtomicInteger atomicInt, int length)
|
||||||
|
{
|
||||||
|
// 先取值再+1
|
||||||
|
int value = atomicInt.getAndIncrement();
|
||||||
|
|
||||||
|
// 如果更新后值>=10 的 (length)幂次方则重置为1
|
||||||
|
int maxSeq = (int) Math.pow(10, length);
|
||||||
|
if (atomicInt.get() >= maxSeq)
|
||||||
|
{
|
||||||
|
atomicInt.set(1);
|
||||||
|
}
|
||||||
|
// 转字符串,用0左补齐
|
||||||
|
return StringUtils.padl(value, length);
|
||||||
|
}
|
||||||
|
}
|
||||||
27
ruoyi-common/src/main/java/com/ruoyi/common/xss/Xss.java
Normal file
27
ruoyi-common/src/main/java/com/ruoyi/common/xss/Xss.java
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
package com.ruoyi.common.xss;
|
||||||
|
|
||||||
|
import javax.validation.Constraint;
|
||||||
|
import javax.validation.Payload;
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自定义xss校验注解
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
*/
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Target(value = { ElementType.METHOD, ElementType.FIELD, ElementType.CONSTRUCTOR, ElementType.PARAMETER })
|
||||||
|
@Constraint(validatedBy = { XssValidator.class })
|
||||||
|
public @interface Xss
|
||||||
|
{
|
||||||
|
String message()
|
||||||
|
|
||||||
|
default "不允许任何脚本运行";
|
||||||
|
|
||||||
|
Class<?>[] groups() default {};
|
||||||
|
|
||||||
|
Class<? extends Payload>[] payload() default {};
|
||||||
|
}
|
||||||
@ -0,0 +1,34 @@
|
|||||||
|
package com.ruoyi.common.xss;
|
||||||
|
|
||||||
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
|
import javax.validation.ConstraintValidator;
|
||||||
|
import javax.validation.ConstraintValidatorContext;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自定义xss校验注解实现
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
*/
|
||||||
|
public class XssValidator implements ConstraintValidator<Xss, String>
|
||||||
|
{
|
||||||
|
private static final String HTML_PATTERN = "<(\\S*?)[^>]*>.*?|<.*? />";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isValid(String value, ConstraintValidatorContext constraintValidatorContext)
|
||||||
|
{
|
||||||
|
if (StringUtils.isBlank(value))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return !containsHtml(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean containsHtml(String value)
|
||||||
|
{
|
||||||
|
Pattern pattern = Pattern.compile(HTML_PATTERN);
|
||||||
|
Matcher matcher = pattern.matcher(value);
|
||||||
|
return matcher.matches();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>ruoyi</artifactId>
|
<artifactId>ruoyi</artifactId>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<version>3.8.0</version>
|
<version>3.8.2</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@ -65,7 +65,6 @@ public class LogAspect
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
// 获取当前的用户
|
// 获取当前的用户
|
||||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||||
|
|
||||||
|
|||||||
@ -1,13 +1,13 @@
|
|||||||
package com.ruoyi.framework.config;
|
package com.ruoyi.framework.config;
|
||||||
|
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import com.ruoyi.common.utils.Threads;
|
||||||
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
|
||||||
import java.util.concurrent.ThreadPoolExecutor;
|
|
||||||
import org.apache.commons.lang3.concurrent.BasicThreadFactory;
|
import org.apache.commons.lang3.concurrent.BasicThreadFactory;
|
||||||
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 org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||||
import com.ruoyi.common.utils.Threads;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
|
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
||||||
|
import java.util.concurrent.ThreadPoolExecutor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 线程池配置
|
* 线程池配置
|
||||||
@ -49,7 +49,8 @@ public class ThreadPoolConfig
|
|||||||
protected ScheduledExecutorService scheduledExecutorService()
|
protected ScheduledExecutorService scheduledExecutorService()
|
||||||
{
|
{
|
||||||
return new ScheduledThreadPoolExecutor(corePoolSize,
|
return new ScheduledThreadPoolExecutor(corePoolSize,
|
||||||
new BasicThreadFactory.Builder().namingPattern("schedule-pool-%d").daemon(true).build())
|
new BasicThreadFactory.Builder().namingPattern("schedule-pool-%d").daemon(true).build(),
|
||||||
|
new ThreadPoolExecutor.CallerRunsPolicy())
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
protected void afterExecute(Runnable r, Throwable t)
|
protected void afterExecute(Runnable r, Throwable t)
|
||||||
|
|||||||
@ -60,14 +60,10 @@ public class SameUrlDataInterceptor extends RepeatSubmitInterceptor
|
|||||||
String url = request.getRequestURI();
|
String url = request.getRequestURI();
|
||||||
|
|
||||||
// 唯一值(没有消息头则使用请求地址)
|
// 唯一值(没有消息头则使用请求地址)
|
||||||
String submitKey = request.getHeader(header);
|
String submitKey = StringUtils.trimToEmpty(request.getHeader(header));
|
||||||
if (StringUtils.isEmpty(submitKey))
|
|
||||||
{
|
|
||||||
submitKey = url;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 唯一标识(指定key + 消息头)
|
// 唯一标识(指定key + url + 消息头)
|
||||||
String cacheRepeatKey = Constants.REPEAT_SUBMIT_KEY + submitKey;
|
String cacheRepeatKey = Constants.REPEAT_SUBMIT_KEY + url + submitKey;
|
||||||
|
|
||||||
Object sessionObj = redisCache.getCacheObject(cacheRepeatKey);
|
Object sessionObj = redisCache.getCacheObject(cacheRepeatKey);
|
||||||
if (sessionObj != null)
|
if (sessionObj != null)
|
||||||
|
|||||||
@ -119,4 +119,12 @@ public class Jvm
|
|||||||
{
|
{
|
||||||
return DateUtils.getDatePoor(DateUtils.getNowDate(), DateUtils.getServerStartDate());
|
return DateUtils.getDatePoor(DateUtils.getNowDate(), DateUtils.getServerStartDate());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 运行参数
|
||||||
|
*/
|
||||||
|
public String getInputArgs()
|
||||||
|
{
|
||||||
|
return ManagementFactory.getRuntimeMXBean().getInputArguments().toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,6 +17,7 @@ import com.ruoyi.common.exception.user.CaptchaExpireException;
|
|||||||
import com.ruoyi.common.exception.user.UserPasswordNotMatchException;
|
import com.ruoyi.common.exception.user.UserPasswordNotMatchException;
|
||||||
import com.ruoyi.common.utils.DateUtils;
|
import com.ruoyi.common.utils.DateUtils;
|
||||||
import com.ruoyi.common.utils.MessageUtils;
|
import com.ruoyi.common.utils.MessageUtils;
|
||||||
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
import com.ruoyi.common.utils.ServletUtils;
|
import com.ruoyi.common.utils.ServletUtils;
|
||||||
import com.ruoyi.common.utils.ip.IpUtils;
|
import com.ruoyi.common.utils.ip.IpUtils;
|
||||||
import com.ruoyi.framework.manager.AsyncManager;
|
import com.ruoyi.framework.manager.AsyncManager;
|
||||||
@ -102,7 +103,7 @@ public class SysLoginService
|
|||||||
*/
|
*/
|
||||||
public void validateCaptcha(String username, String code, String uuid)
|
public void validateCaptcha(String username, String code, String uuid)
|
||||||
{
|
{
|
||||||
String verifyKey = Constants.CAPTCHA_CODE_KEY + uuid;
|
String verifyKey = Constants.CAPTCHA_CODE_KEY + StringUtils.nvl(uuid, "");
|
||||||
String captcha = redisCache.getCacheObject(verifyKey);
|
String captcha = redisCache.getCacheObject(verifyKey);
|
||||||
redisCache.deleteObject(verifyKey);
|
redisCache.deleteObject(verifyKey);
|
||||||
if (captcha == null)
|
if (captcha == null)
|
||||||
|
|||||||
@ -100,7 +100,7 @@ public class SysRegisterService
|
|||||||
*/
|
*/
|
||||||
public void validateCaptcha(String username, String code, String uuid)
|
public void validateCaptcha(String username, String code, String uuid)
|
||||||
{
|
{
|
||||||
String verifyKey = Constants.CAPTCHA_CODE_KEY + uuid;
|
String verifyKey = Constants.CAPTCHA_CODE_KEY + StringUtils.nvl(uuid, "");
|
||||||
String captcha = redisCache.getCacheObject(verifyKey);
|
String captcha = redisCache.getCacheObject(verifyKey);
|
||||||
redisCache.deleteObject(verifyKey);
|
redisCache.deleteObject(verifyKey);
|
||||||
if (captcha == null)
|
if (captcha == null)
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>ruoyi</artifactId>
|
<artifactId>ruoyi</artifactId>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<version>3.8.0</version>
|
<version>3.8.2</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@ -59,12 +59,12 @@ public class GenController extends BaseController
|
|||||||
* 修改代码生成业务
|
* 修改代码生成业务
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('tool:gen:query')")
|
@PreAuthorize("@ss.hasPermi('tool:gen:query')")
|
||||||
@GetMapping(value = "/{talbleId}")
|
@GetMapping(value = "/{tableId}")
|
||||||
public AjaxResult getInfo(@PathVariable Long talbleId)
|
public AjaxResult getInfo(@PathVariable Long tableId)
|
||||||
{
|
{
|
||||||
GenTable table = genTableService.selectGenTableById(talbleId);
|
GenTable table = genTableService.selectGenTableById(tableId);
|
||||||
List<GenTable> tables = genTableService.selectGenTableAll();
|
List<GenTable> tables = genTableService.selectGenTableAll();
|
||||||
List<GenTableColumn> list = genTableColumnService.selectGenTableColumnListByTableId(talbleId);
|
List<GenTableColumn> list = genTableColumnService.selectGenTableColumnListByTableId(tableId);
|
||||||
Map<String, Object> map = new HashMap<String, Object>();
|
Map<String, Object> map = new HashMap<String, Object>();
|
||||||
map.put("info", table);
|
map.put("info", table);
|
||||||
map.put("rows", list);
|
map.put("rows", list);
|
||||||
@ -88,7 +88,7 @@ public class GenController extends BaseController
|
|||||||
* 查询数据表字段列表
|
* 查询数据表字段列表
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('tool:gen:list')")
|
@PreAuthorize("@ss.hasPermi('tool:gen:list')")
|
||||||
@GetMapping(value = "/column/{talbleId}")
|
@GetMapping(value = "/column/{tableId}")
|
||||||
public TableDataInfo columnList(Long tableId)
|
public TableDataInfo columnList(Long tableId)
|
||||||
{
|
{
|
||||||
TableDataInfo dataInfo = new TableDataInfo();
|
TableDataInfo dataInfo = new TableDataInfo();
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import java.io.StringWriter;
|
|||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
import java.util.zip.ZipOutputStream;
|
import java.util.zip.ZipOutputStream;
|
||||||
@ -286,7 +287,7 @@ public class GenTableServiceImpl implements IGenTableService
|
|||||||
{
|
{
|
||||||
GenTable table = genTableMapper.selectGenTableByName(tableName);
|
GenTable table = genTableMapper.selectGenTableByName(tableName);
|
||||||
List<GenTableColumn> tableColumns = table.getColumns();
|
List<GenTableColumn> tableColumns = table.getColumns();
|
||||||
List<String> tableColumnNames = tableColumns.stream().map(GenTableColumn::getColumnName).collect(Collectors.toList());
|
Map<String, GenTableColumn> tableColumnMap = tableColumns.stream().collect(Collectors.toMap(GenTableColumn::getColumnName, Function.identity()));
|
||||||
|
|
||||||
List<GenTableColumn> dbTableColumns = genTableColumnMapper.selectDbTableColumnsByName(tableName);
|
List<GenTableColumn> dbTableColumns = genTableColumnMapper.selectDbTableColumnsByName(tableName);
|
||||||
if (StringUtils.isEmpty(dbTableColumns))
|
if (StringUtils.isEmpty(dbTableColumns))
|
||||||
@ -296,9 +297,29 @@ public class GenTableServiceImpl implements IGenTableService
|
|||||||
List<String> dbTableColumnNames = dbTableColumns.stream().map(GenTableColumn::getColumnName).collect(Collectors.toList());
|
List<String> dbTableColumnNames = dbTableColumns.stream().map(GenTableColumn::getColumnName).collect(Collectors.toList());
|
||||||
|
|
||||||
dbTableColumns.forEach(column -> {
|
dbTableColumns.forEach(column -> {
|
||||||
if (!tableColumnNames.contains(column.getColumnName()))
|
GenUtils.initColumnField(column, table);
|
||||||
|
if (tableColumnMap.containsKey(column.getColumnName()))
|
||||||
|
{
|
||||||
|
GenTableColumn prevColumn = tableColumnMap.get(column.getColumnName());
|
||||||
|
column.setColumnId(prevColumn.getColumnId());
|
||||||
|
if (column.isList())
|
||||||
|
{
|
||||||
|
// 如果是列表,继续保留查询方式/字典类型选项
|
||||||
|
column.setDictType(prevColumn.getDictType());
|
||||||
|
column.setQueryType(prevColumn.getQueryType());
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotEmpty(prevColumn.getIsRequired()) && !column.isPk()
|
||||||
|
&& (column.isInsert() || column.isEdit())
|
||||||
|
&& ((column.isUsableColumn()) || (!column.isSuperColumn())))
|
||||||
|
{
|
||||||
|
// 如果是(新增/修改&非主键/非忽略及父属性),继续保留必填/显示类型选项
|
||||||
|
column.setIsRequired(prevColumn.getIsRequired());
|
||||||
|
column.setHtmlType(prevColumn.getHtmlType());
|
||||||
|
}
|
||||||
|
genTableColumnMapper.updateGenTableColumn(column);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
GenUtils.initColumnField(column, table);
|
|
||||||
genTableColumnMapper.insertGenTableColumn(column);
|
genTableColumnMapper.insertGenTableColumn(column);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -359,7 +380,7 @@ public class GenTableServiceImpl implements IGenTableService
|
|||||||
zip.putNextEntry(new ZipEntry(VelocityUtils.getFileName(template, table)));
|
zip.putNextEntry(new ZipEntry(VelocityUtils.getFileName(template, table)));
|
||||||
IOUtils.write(sw.toString(), zip, Constants.UTF8);
|
IOUtils.write(sw.toString(), zip, Constants.UTF8);
|
||||||
IOUtils.closeQuietly(sw);
|
IOUtils.closeQuietly(sw);
|
||||||
zip.flush();
|
zip.flush();
|
||||||
zip.closeEntry();
|
zip.closeEntry();
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
@ -472,7 +493,7 @@ public class GenTableServiceImpl implements IGenTableService
|
|||||||
String treeName = paramsObj.getString(GenConstants.TREE_NAME);
|
String treeName = paramsObj.getString(GenConstants.TREE_NAME);
|
||||||
String parentMenuId = paramsObj.getString(GenConstants.PARENT_MENU_ID);
|
String parentMenuId = paramsObj.getString(GenConstants.PARENT_MENU_ID);
|
||||||
String parentMenuName = paramsObj.getString(GenConstants.PARENT_MENU_NAME);
|
String parentMenuName = paramsObj.getString(GenConstants.PARENT_MENU_NAME);
|
||||||
|
|
||||||
genTable.setTreeCode(treeCode);
|
genTable.setTreeCode(treeCode);
|
||||||
genTable.setTreeParentCode(treeParentCode);
|
genTable.setTreeParentCode(treeParentCode);
|
||||||
genTable.setTreeName(treeName);
|
genTable.setTreeName(treeName);
|
||||||
|
|||||||
@ -42,6 +42,7 @@ public class GenUtils
|
|||||||
column.setJavaField(StringUtils.toCamelCase(columnName));
|
column.setJavaField(StringUtils.toCamelCase(columnName));
|
||||||
// 设置默认类型
|
// 设置默认类型
|
||||||
column.setJavaType(GenConstants.TYPE_STRING);
|
column.setJavaType(GenConstants.TYPE_STRING);
|
||||||
|
column.setQueryType(GenConstants.QUERY_EQ);
|
||||||
|
|
||||||
if (arraysContains(GenConstants.COLUMNTYPE_STR, dataType) || arraysContains(GenConstants.COLUMNTYPE_TEXT, dataType))
|
if (arraysContains(GenConstants.COLUMNTYPE_STR, dataType) || arraysContains(GenConstants.COLUMNTYPE_TEXT, dataType))
|
||||||
{
|
{
|
||||||
@ -151,8 +152,7 @@ public class GenUtils
|
|||||||
{
|
{
|
||||||
int lastIndex = packageName.lastIndexOf(".");
|
int lastIndex = packageName.lastIndexOf(".");
|
||||||
int nameLength = packageName.length();
|
int nameLength = packageName.length();
|
||||||
String moduleName = StringUtils.substring(packageName, lastIndex + 1, nameLength);
|
return StringUtils.substring(packageName, lastIndex + 1, nameLength);
|
||||||
return moduleName;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -165,8 +165,7 @@ public class GenUtils
|
|||||||
{
|
{
|
||||||
int lastIndex = tableName.lastIndexOf("_");
|
int lastIndex = tableName.lastIndexOf("_");
|
||||||
int nameLength = tableName.length();
|
int nameLength = tableName.length();
|
||||||
String businessName = StringUtils.substring(tableName, lastIndex + 1, nameLength);
|
return StringUtils.substring(tableName, lastIndex + 1, nameLength);
|
||||||
return businessName;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -3,6 +3,7 @@ package com.ruoyi.generator.util;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
import org.apache.velocity.VelocityContext;
|
import org.apache.velocity.VelocityContext;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.ruoyi.common.constant.GenConstants;
|
import com.ruoyi.common.constant.GenConstants;
|
||||||
@ -227,8 +228,7 @@ public class VelocityUtils
|
|||||||
public static String getPackagePrefix(String packageName)
|
public static String getPackagePrefix(String packageName)
|
||||||
{
|
{
|
||||||
int lastIndex = packageName.lastIndexOf(".");
|
int lastIndex = packageName.lastIndexOf(".");
|
||||||
String basePackage = StringUtils.substring(packageName, 0, lastIndex);
|
return StringUtils.substring(packageName, 0, lastIndex);
|
||||||
return basePackage;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -270,7 +270,24 @@ public class VelocityUtils
|
|||||||
public static String getDicts(GenTable genTable)
|
public static String getDicts(GenTable genTable)
|
||||||
{
|
{
|
||||||
List<GenTableColumn> columns = genTable.getColumns();
|
List<GenTableColumn> columns = genTable.getColumns();
|
||||||
List<String> dicts = new ArrayList<String>();
|
Set<String> dicts = new HashSet<String>();
|
||||||
|
addDicts(dicts, columns);
|
||||||
|
if (StringUtils.isNotNull(genTable.getSubTable()))
|
||||||
|
{
|
||||||
|
List<GenTableColumn> subColumns = genTable.getSubTable().getColumns();
|
||||||
|
addDicts(dicts, subColumns);
|
||||||
|
}
|
||||||
|
return StringUtils.join(dicts, ", ");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加字典列表
|
||||||
|
*
|
||||||
|
* @param dicts 字典列表
|
||||||
|
* @param columns 列集合
|
||||||
|
*/
|
||||||
|
public static void addDicts(Set<String> dicts, List<GenTableColumn> columns)
|
||||||
|
{
|
||||||
for (GenTableColumn column : columns)
|
for (GenTableColumn column : columns)
|
||||||
{
|
{
|
||||||
if (!column.isSuperColumn() && StringUtils.isNotEmpty(column.getDictType()) && StringUtils.equalsAny(
|
if (!column.isSuperColumn() && StringUtils.isNotEmpty(column.getDictType()) && StringUtils.equalsAny(
|
||||||
@ -280,7 +297,6 @@ public class VelocityUtils
|
|||||||
dicts.add("'" + column.getDictType() + "'");
|
dicts.add("'" + column.getDictType() + "'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return StringUtils.join(dicts, ", ");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="app-container">
|
<div class="app-container">
|
||||||
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
|
||||||
#foreach($column in $columns)
|
#foreach($column in $columns)
|
||||||
#if($column.query)
|
#if($column.query)
|
||||||
#set($dictType=$column.dictType)
|
#set($dictType=$column.dictType)
|
||||||
@ -17,13 +17,12 @@
|
|||||||
v-model="queryParams.${column.javaField}"
|
v-model="queryParams.${column.javaField}"
|
||||||
placeholder="请输入${comment}"
|
placeholder="请输入${comment}"
|
||||||
clearable
|
clearable
|
||||||
size="small"
|
|
||||||
@keyup.enter.native="handleQuery"
|
@keyup.enter.native="handleQuery"
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && "" != $dictType)
|
#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && "" != $dictType)
|
||||||
<el-form-item label="${comment}" prop="${column.javaField}">
|
<el-form-item label="${comment}" prop="${column.javaField}">
|
||||||
<el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable size="small">
|
<el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable>
|
||||||
<el-option
|
<el-option
|
||||||
v-for="dict in dict.type.${dictType}"
|
v-for="dict in dict.type.${dictType}"
|
||||||
:key="dict.value"
|
:key="dict.value"
|
||||||
@ -34,13 +33,13 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && $dictType)
|
#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && $dictType)
|
||||||
<el-form-item label="${comment}" prop="${column.javaField}">
|
<el-form-item label="${comment}" prop="${column.javaField}">
|
||||||
<el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable size="small">
|
<el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable>
|
||||||
<el-option label="请选择字典生成" value="" />
|
<el-option label="请选择字典生成" value="" />
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
#elseif($column.htmlType == "datetime" && $column.queryType != "BETWEEN")
|
#elseif($column.htmlType == "datetime" && $column.queryType != "BETWEEN")
|
||||||
<el-form-item label="${comment}" prop="${column.javaField}">
|
<el-form-item label="${comment}" prop="${column.javaField}">
|
||||||
<el-date-picker clearable size="small"
|
<el-date-picker clearable
|
||||||
v-model="queryParams.${column.javaField}"
|
v-model="queryParams.${column.javaField}"
|
||||||
type="date"
|
type="date"
|
||||||
value-format="yyyy-MM-dd"
|
value-format="yyyy-MM-dd"
|
||||||
@ -51,7 +50,6 @@
|
|||||||
<el-form-item label="${comment}">
|
<el-form-item label="${comment}">
|
||||||
<el-date-picker
|
<el-date-picker
|
||||||
v-model="daterange${AttrName}"
|
v-model="daterange${AttrName}"
|
||||||
size="small"
|
|
||||||
style="width: 240px"
|
style="width: 240px"
|
||||||
value-format="yyyy-MM-dd"
|
value-format="yyyy-MM-dd"
|
||||||
type="daterange"
|
type="daterange"
|
||||||
@ -105,6 +103,12 @@
|
|||||||
<span>{{ parseTime(scope.row.${javaField}, '{y}-{m}-{d}') }}</span>
|
<span>{{ parseTime(scope.row.${javaField}, '{y}-{m}-{d}') }}</span>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
#elseif($column.list && $column.htmlType == "imageUpload")
|
||||||
|
<el-table-column label="${comment}" align="center" prop="${javaField}" width="100">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<image-preview :src="scope.row.${javaField}" :width="50" :height="50"/>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
#elseif($column.list && "" != $column.dictType)
|
#elseif($column.list && "" != $column.dictType)
|
||||||
<el-table-column label="${comment}" align="center" prop="${javaField}">
|
<el-table-column label="${comment}" align="center" prop="${javaField}">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
@ -174,11 +178,11 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
#elseif($column.htmlType == "imageUpload")
|
#elseif($column.htmlType == "imageUpload")
|
||||||
<el-form-item label="${comment}">
|
<el-form-item label="${comment}">
|
||||||
<imageUpload v-model="form.${field}"/>
|
<image-upload v-model="form.${field}"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
#elseif($column.htmlType == "fileUpload")
|
#elseif($column.htmlType == "fileUpload")
|
||||||
<el-form-item label="${comment}">
|
<el-form-item label="${comment}">
|
||||||
<fileUpload v-model="form.${field}"/>
|
<file-upload v-model="form.${field}"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
#elseif($column.htmlType == "editor")
|
#elseif($column.htmlType == "editor")
|
||||||
<el-form-item label="${comment}">
|
<el-form-item label="${comment}">
|
||||||
@ -238,7 +242,7 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
#elseif($column.htmlType == "datetime")
|
#elseif($column.htmlType == "datetime")
|
||||||
<el-form-item label="${comment}" prop="${field}">
|
<el-form-item label="${comment}" prop="${field}">
|
||||||
<el-date-picker clearable size="small"
|
<el-date-picker clearable
|
||||||
v-model="form.${field}"
|
v-model="form.${field}"
|
||||||
type="date"
|
type="date"
|
||||||
value-format="yyyy-MM-dd"
|
value-format="yyyy-MM-dd"
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="app-container">
|
<div class="app-container">
|
||||||
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
|
||||||
#foreach($column in $columns)
|
#foreach($column in $columns)
|
||||||
#if($column.query)
|
#if($column.query)
|
||||||
#set($dictType=$column.dictType)
|
#set($dictType=$column.dictType)
|
||||||
@ -17,13 +17,12 @@
|
|||||||
v-model="queryParams.${column.javaField}"
|
v-model="queryParams.${column.javaField}"
|
||||||
placeholder="请输入${comment}"
|
placeholder="请输入${comment}"
|
||||||
clearable
|
clearable
|
||||||
size="small"
|
|
||||||
@keyup.enter.native="handleQuery"
|
@keyup.enter.native="handleQuery"
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && "" != $dictType)
|
#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && "" != $dictType)
|
||||||
<el-form-item label="${comment}" prop="${column.javaField}">
|
<el-form-item label="${comment}" prop="${column.javaField}">
|
||||||
<el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable size="small">
|
<el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable>
|
||||||
<el-option
|
<el-option
|
||||||
v-for="dict in dict.type.${dictType}"
|
v-for="dict in dict.type.${dictType}"
|
||||||
:key="dict.value"
|
:key="dict.value"
|
||||||
@ -34,24 +33,23 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && $dictType)
|
#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && $dictType)
|
||||||
<el-form-item label="${comment}" prop="${column.javaField}">
|
<el-form-item label="${comment}" prop="${column.javaField}">
|
||||||
<el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable size="small">
|
<el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable>
|
||||||
<el-option label="请选择字典生成" value="" />
|
<el-option label="请选择字典生成" value="" />
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
#elseif($column.htmlType == "datetime" && $column.queryType != "BETWEEN")
|
#elseif($column.htmlType == "datetime" && $column.queryType != "BETWEEN")
|
||||||
<el-form-item label="${comment}" prop="${column.javaField}">
|
<el-form-item label="${comment}" prop="${column.javaField}">
|
||||||
<el-date-picker clearable size="small"
|
<el-date-picker clearable
|
||||||
v-model="queryParams.${column.javaField}"
|
v-model="queryParams.${column.javaField}"
|
||||||
type="date"
|
type="date"
|
||||||
value-format="yyyy-MM-dd"
|
value-format="yyyy-MM-dd"
|
||||||
placeholder="选择${comment}">
|
placeholder="请选择${comment}">
|
||||||
</el-date-picker>
|
</el-date-picker>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
#elseif($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
#elseif($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||||
<el-form-item label="${comment}">
|
<el-form-item label="${comment}">
|
||||||
<el-date-picker
|
<el-date-picker
|
||||||
v-model="daterange${AttrName}"
|
v-model="daterange${AttrName}"
|
||||||
size="small"
|
|
||||||
style="width: 240px"
|
style="width: 240px"
|
||||||
value-format="yyyy-MM-dd"
|
value-format="yyyy-MM-dd"
|
||||||
type="daterange"
|
type="daterange"
|
||||||
@ -133,6 +131,12 @@
|
|||||||
<span>{{ parseTime(scope.row.${javaField}, '{y}-{m}-{d}') }}</span>
|
<span>{{ parseTime(scope.row.${javaField}, '{y}-{m}-{d}') }}</span>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
#elseif($column.list && $column.htmlType == "imageUpload")
|
||||||
|
<el-table-column label="${comment}" align="center" prop="${javaField}" width="100">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<image-preview :src="scope.row.${javaField}" :width="50" :height="50"/>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
#elseif($column.list && "" != $column.dictType)
|
#elseif($column.list && "" != $column.dictType)
|
||||||
<el-table-column label="${comment}" align="center" prop="${javaField}">
|
<el-table-column label="${comment}" align="center" prop="${javaField}">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
@ -195,11 +199,11 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
#elseif($column.htmlType == "imageUpload")
|
#elseif($column.htmlType == "imageUpload")
|
||||||
<el-form-item label="${comment}">
|
<el-form-item label="${comment}">
|
||||||
<imageUpload v-model="form.${field}"/>
|
<image-upload v-model="form.${field}"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
#elseif($column.htmlType == "fileUpload")
|
#elseif($column.htmlType == "fileUpload")
|
||||||
<el-form-item label="${comment}">
|
<el-form-item label="${comment}">
|
||||||
<fileUpload v-model="form.${field}"/>
|
<file-upload v-model="form.${field}"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
#elseif($column.htmlType == "editor")
|
#elseif($column.htmlType == "editor")
|
||||||
<el-form-item label="${comment}">
|
<el-form-item label="${comment}">
|
||||||
@ -259,11 +263,11 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
#elseif($column.htmlType == "datetime")
|
#elseif($column.htmlType == "datetime")
|
||||||
<el-form-item label="${comment}" prop="${field}">
|
<el-form-item label="${comment}" prop="${field}">
|
||||||
<el-date-picker clearable size="small"
|
<el-date-picker clearable
|
||||||
v-model="form.${field}"
|
v-model="form.${field}"
|
||||||
type="date"
|
type="date"
|
||||||
value-format="yyyy-MM-dd"
|
value-format="yyyy-MM-dd"
|
||||||
placeholder="选择${comment}">
|
placeholder="请选择${comment}">
|
||||||
</el-date-picker>
|
</el-date-picker>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
#elseif($column.htmlType == "textarea")
|
#elseif($column.htmlType == "textarea")
|
||||||
@ -296,12 +300,39 @@
|
|||||||
#set($comment=$column.columnComment)
|
#set($comment=$column.columnComment)
|
||||||
#end
|
#end
|
||||||
#if($column.pk || $javaField == ${subTableFkclassName})
|
#if($column.pk || $javaField == ${subTableFkclassName})
|
||||||
#elseif($column.list && "" != $javaField)
|
#elseif($column.list && $column.htmlType == "input")
|
||||||
<el-table-column label="$comment" prop="${javaField}">
|
<el-table-column label="$comment" prop="${javaField}" width="150">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-input v-model="scope.row.$javaField" placeholder="请输入$comment" />
|
<el-input v-model="scope.row.$javaField" placeholder="请输入$comment" />
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
#elseif($column.list && $column.htmlType == "datetime")
|
||||||
|
<el-table-column label="$comment" prop="${javaField}" width="240">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-date-picker clearable v-model="scope.row.$javaField" type="date" value-format="yyyy-MM-dd" placeholder="请选择$comment" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
#elseif($column.list && ($column.htmlType == "select" || $column.htmlType == "radio") && "" != $column.dictType)
|
||||||
|
<el-table-column label="$comment" prop="${javaField}" width="150">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-select v-model="scope.row.$javaField" placeholder="请选择$comment">
|
||||||
|
<el-option
|
||||||
|
v-for="dict in dict.type.$column.dictType"
|
||||||
|
:key="dict.value"
|
||||||
|
:label="dict.label"
|
||||||
|
:value="dict.value"
|
||||||
|
></el-option>
|
||||||
|
</el-select>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
#elseif($column.list && ($column.htmlType == "select" || $column.htmlType == "radio") && "" == $column.dictType)
|
||||||
|
<el-table-column label="$comment" prop="${javaField}" width="150">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-select v-model="scope.row.$javaField" placeholder="请选择$comment">
|
||||||
|
<el-option label="请选择字典生成" value="" />
|
||||||
|
</el-select>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
</el-table>
|
</el-table>
|
||||||
|
|||||||
464
ruoyi-generator/src/main/resources/vm/vue/v3/index-tree.vue.vm
Normal file
464
ruoyi-generator/src/main/resources/vm/vue/v3/index-tree.vue.vm
Normal file
@ -0,0 +1,464 @@
|
|||||||
|
<template>
|
||||||
|
<div class="app-container">
|
||||||
|
<el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px">
|
||||||
|
#foreach($column in $columns)
|
||||||
|
#if($column.query)
|
||||||
|
#set($dictType=$column.dictType)
|
||||||
|
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||||
|
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
||||||
|
#if($parentheseIndex != -1)
|
||||||
|
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
||||||
|
#else
|
||||||
|
#set($comment=$column.columnComment)
|
||||||
|
#end
|
||||||
|
#if($column.htmlType == "input")
|
||||||
|
<el-form-item label="${comment}" prop="${column.javaField}">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.${column.javaField}"
|
||||||
|
placeholder="请输入${comment}"
|
||||||
|
clearable
|
||||||
|
@keyup.enter="handleQuery"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && "" != $dictType)
|
||||||
|
<el-form-item label="${comment}" prop="${column.javaField}">
|
||||||
|
<el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable>
|
||||||
|
<el-option
|
||||||
|
v-for="dict in ${dictType}"
|
||||||
|
:key="dict.value"
|
||||||
|
:label="dict.label"
|
||||||
|
:value="dict.value"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && $dictType)
|
||||||
|
<el-form-item label="${comment}" prop="${column.javaField}">
|
||||||
|
<el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable>
|
||||||
|
<el-option label="请选择字典生成" value="" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
#elseif($column.htmlType == "datetime" && $column.queryType != "BETWEEN")
|
||||||
|
<el-form-item label="${comment}" prop="${column.javaField}">
|
||||||
|
<el-date-picker clearable
|
||||||
|
v-model="queryParams.${column.javaField}"
|
||||||
|
type="date"
|
||||||
|
value-format="YYYY-MM-DD"
|
||||||
|
placeholder="选择${comment}">
|
||||||
|
</el-date-picker>
|
||||||
|
</el-form-item>
|
||||||
|
#elseif($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||||
|
<el-form-item label="${comment}" style="width: 308px">
|
||||||
|
<el-date-picker
|
||||||
|
v-model="daterange${AttrName}"
|
||||||
|
value-format="YYYY-MM-DD"
|
||||||
|
type="daterange"
|
||||||
|
range-separator="-"
|
||||||
|
start-placeholder="开始日期"
|
||||||
|
end-placeholder="结束日期"
|
||||||
|
></el-date-picker>
|
||||||
|
</el-form-item>
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
<el-form-item>
|
||||||
|
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
|
||||||
|
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
|
||||||
|
<el-row :gutter="10" class="mb8">
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
plain
|
||||||
|
icon="Plus"
|
||||||
|
@click="handleAdd"
|
||||||
|
v-hasPermi="['${moduleName}:${businessName}:add']"
|
||||||
|
>新增</el-button>
|
||||||
|
</el-col>
|
||||||
|
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
<el-table
|
||||||
|
v-loading="loading"
|
||||||
|
:data="${businessName}List"
|
||||||
|
row-key="${treeCode}"
|
||||||
|
default-expand-all
|
||||||
|
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
|
||||||
|
>
|
||||||
|
#foreach($column in $columns)
|
||||||
|
#set($javaField=$column.javaField)
|
||||||
|
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
||||||
|
#if($parentheseIndex != -1)
|
||||||
|
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
||||||
|
#else
|
||||||
|
#set($comment=$column.columnComment)
|
||||||
|
#end
|
||||||
|
#if($column.pk)
|
||||||
|
#elseif($column.list && $column.htmlType == "datetime")
|
||||||
|
<el-table-column label="${comment}" align="center" prop="${javaField}" width="180">
|
||||||
|
<template #default="scope">
|
||||||
|
<span>{{ parseTime(scope.row.${javaField}, '{y}-{m}-{d}') }}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
#elseif($column.list && $column.htmlType == "imageUpload")
|
||||||
|
<el-table-column label="${comment}" align="center" prop="${javaField}" width="100">
|
||||||
|
<template #default="scope">
|
||||||
|
<image-preview :src="scope.row.${javaField}" :width="50" :height="50"/>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
#elseif($column.list && "" != $column.dictType)
|
||||||
|
<el-table-column label="${comment}" align="center" prop="${javaField}">
|
||||||
|
<template #default="scope">
|
||||||
|
#if($column.htmlType == "checkbox")
|
||||||
|
<dict-tag :options="${column.dictType}" :value="scope.row.${javaField} ? scope.row.${javaField}.split(',') : []"/>
|
||||||
|
#else
|
||||||
|
<dict-tag :options="${column.dictType}" :value="scope.row.${javaField}"/>
|
||||||
|
#end
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
#elseif($column.list && "" != $javaField)
|
||||||
|
#if(${foreach.index} == 1)
|
||||||
|
<el-table-column label="${comment}" prop="${javaField}" />
|
||||||
|
#else
|
||||||
|
<el-table-column label="${comment}" align="center" prop="${javaField}" />
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-button
|
||||||
|
type="text"
|
||||||
|
icon="Edit"
|
||||||
|
@click="handleUpdate(scope.row)"
|
||||||
|
v-hasPermi="['${moduleName}:${businessName}:edit']"
|
||||||
|
>修改</el-button>
|
||||||
|
<el-button
|
||||||
|
type="text"
|
||||||
|
icon="Plus"
|
||||||
|
@click="handleAdd(scope.row)"
|
||||||
|
v-hasPermi="['${moduleName}:${businessName}:add']"
|
||||||
|
>新增</el-button>
|
||||||
|
<el-button
|
||||||
|
type="text"
|
||||||
|
icon="Delete"
|
||||||
|
@click="handleDelete(scope.row)"
|
||||||
|
v-hasPermi="['${moduleName}:${businessName}:remove']"
|
||||||
|
>删除</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
|
||||||
|
<!-- 添加或修改${functionName}对话框 -->
|
||||||
|
<el-dialog :title="title" v-model="open" width="500px" append-to-body>
|
||||||
|
<el-form ref="${businessName}Ref" :model="form" :rules="rules" label-width="80px">
|
||||||
|
#foreach($column in $columns)
|
||||||
|
#set($field=$column.javaField)
|
||||||
|
#if($column.insert && !$column.pk)
|
||||||
|
#if(($column.usableColumn) || (!$column.superColumn))
|
||||||
|
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
||||||
|
#if($parentheseIndex != -1)
|
||||||
|
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
||||||
|
#else
|
||||||
|
#set($comment=$column.columnComment)
|
||||||
|
#end
|
||||||
|
#set($dictType=$column.dictType)
|
||||||
|
#if("" != $treeParentCode && $column.javaField == $treeParentCode)
|
||||||
|
<el-form-item label="${comment}" prop="${treeParentCode}">
|
||||||
|
<tree-select
|
||||||
|
v-model:value="form.${treeParentCode}"
|
||||||
|
:options="${businessName}Options"
|
||||||
|
:objMap="{ value: '${treeCode}', label: '${treeName}', children: 'children' }"
|
||||||
|
placeholder="请选择${comment}"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
#elseif($column.htmlType == "input")
|
||||||
|
<el-form-item label="${comment}" prop="${field}">
|
||||||
|
<el-input v-model="form.${field}" placeholder="请输入${comment}" />
|
||||||
|
</el-form-item>
|
||||||
|
#elseif($column.htmlType == "imageUpload")
|
||||||
|
<el-form-item label="${comment}">
|
||||||
|
<image-upload v-model="form.${field}"/>
|
||||||
|
</el-form-item>
|
||||||
|
#elseif($column.htmlType == "fileUpload")
|
||||||
|
<el-form-item label="${comment}">
|
||||||
|
<file-upload v-model="form.${field}"/>
|
||||||
|
</el-form-item>
|
||||||
|
#elseif($column.htmlType == "editor")
|
||||||
|
<el-form-item label="${comment}">
|
||||||
|
<editor v-model="form.${field}" :min-height="192"/>
|
||||||
|
</el-form-item>
|
||||||
|
#elseif($column.htmlType == "select" && "" != $dictType)
|
||||||
|
<el-form-item label="${comment}" prop="${field}">
|
||||||
|
<el-select v-model="form.${field}" placeholder="请选择${comment}">
|
||||||
|
<el-option
|
||||||
|
v-for="dict in ${dictType}"
|
||||||
|
:key="dict.value"
|
||||||
|
:label="dict.label"
|
||||||
|
#if($column.javaType == "Integer" || $column.javaType == "Long"):value="parseInt(dict.value)"#else:value="dict.value"#end
|
||||||
|
|
||||||
|
></el-option>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
#elseif($column.htmlType == "select" && $dictType)
|
||||||
|
<el-form-item label="${comment}" prop="${field}">
|
||||||
|
<el-select v-model="form.${field}" placeholder="请选择${comment}">
|
||||||
|
<el-option label="请选择字典生成" value="" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
#elseif($column.htmlType == "checkbox" && "" != $dictType)
|
||||||
|
<el-form-item label="${comment}">
|
||||||
|
<el-checkbox-group v-model="form.${field}">
|
||||||
|
<el-checkbox
|
||||||
|
v-for="dict in ${dictType}"
|
||||||
|
:key="dict.value"
|
||||||
|
:label="dict.value">
|
||||||
|
{{dict.label}}
|
||||||
|
</el-checkbox>
|
||||||
|
</el-checkbox-group>
|
||||||
|
</el-form-item>
|
||||||
|
#elseif($column.htmlType == "checkbox" && $dictType)
|
||||||
|
<el-form-item label="${comment}">
|
||||||
|
<el-checkbox-group v-model="form.${field}">
|
||||||
|
<el-checkbox>请选择字典生成</el-checkbox>
|
||||||
|
</el-checkbox-group>
|
||||||
|
</el-form-item>
|
||||||
|
#elseif($column.htmlType == "radio" && "" != $dictType)
|
||||||
|
<el-form-item label="${comment}">
|
||||||
|
<el-radio-group v-model="form.${field}">
|
||||||
|
<el-radio
|
||||||
|
v-for="dict in ${dictType}"
|
||||||
|
:key="dict.value"
|
||||||
|
#if($column.javaType == "Integer" || $column.javaType == "Long"):label="parseInt(dict.value)"#else:label="dict.value"#end
|
||||||
|
|
||||||
|
>{{dict.label}}</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
|
</el-form-item>
|
||||||
|
#elseif($column.htmlType == "radio" && $dictType)
|
||||||
|
<el-form-item label="${comment}">
|
||||||
|
<el-radio-group v-model="form.${field}">
|
||||||
|
<el-radio label="1">请选择字典生成</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
|
</el-form-item>
|
||||||
|
#elseif($column.htmlType == "datetime")
|
||||||
|
<el-form-item label="${comment}" prop="${field}">
|
||||||
|
<el-date-picker clearable
|
||||||
|
v-model="form.${field}"
|
||||||
|
type="date"
|
||||||
|
value-format="YYYY-MM-DD"
|
||||||
|
placeholder="选择${comment}">
|
||||||
|
</el-date-picker>
|
||||||
|
</el-form-item>
|
||||||
|
#elseif($column.htmlType == "textarea")
|
||||||
|
<el-form-item label="${comment}" prop="${field}">
|
||||||
|
<el-input v-model="form.${field}" type="textarea" placeholder="请输入内容" />
|
||||||
|
</el-form-item>
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
</el-form>
|
||||||
|
<template #footer>
|
||||||
|
<div class="dialog-footer">
|
||||||
|
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||||
|
<el-button @click="cancel">取 消</el-button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup name="${BusinessName}">
|
||||||
|
import { list${BusinessName}, get${BusinessName}, del${BusinessName}, add${BusinessName}, update${BusinessName} } from "@/api/${moduleName}/${businessName}";
|
||||||
|
|
||||||
|
const { proxy } = getCurrentInstance();
|
||||||
|
#if(${dicts} != '')
|
||||||
|
#set($dictsNoSymbol=$dicts.replace("'", ""))
|
||||||
|
const { ${dictsNoSymbol} } = proxy.useDict(${dicts});
|
||||||
|
#end
|
||||||
|
|
||||||
|
const ${businessName}List = ref([]);
|
||||||
|
const ${businessName}Options = ref([]);
|
||||||
|
const open = ref(false);
|
||||||
|
const loading = ref(true);
|
||||||
|
const showSearch = ref(true);
|
||||||
|
const title = ref("");
|
||||||
|
#foreach ($column in $columns)
|
||||||
|
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||||
|
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||||
|
const daterange${AttrName} = ref([]);
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
|
||||||
|
const data = reactive({
|
||||||
|
form: {},
|
||||||
|
queryParams: {
|
||||||
|
#foreach ($column in $columns)
|
||||||
|
#if($column.query)
|
||||||
|
$column.javaField: null#if($foreach.count != $columns.size()),#end
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
#foreach ($column in $columns)
|
||||||
|
#if($column.required)
|
||||||
|
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
||||||
|
#if($parentheseIndex != -1)
|
||||||
|
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
||||||
|
#else
|
||||||
|
#set($comment=$column.columnComment)
|
||||||
|
#end
|
||||||
|
$column.javaField: [
|
||||||
|
{ required: true, message: "$comment不能为空", trigger: #if($column.htmlType == "select")"change"#else"blur"#end }
|
||||||
|
]#if($foreach.count != $columns.size()),#end
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const { queryParams, form, rules } = toRefs(data);
|
||||||
|
|
||||||
|
/** 查询${functionName}列表 */
|
||||||
|
function getList() {
|
||||||
|
loading.value = true;
|
||||||
|
#foreach ($column in $columns)
|
||||||
|
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||||
|
queryParams.value.params = {};
|
||||||
|
#break
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
#foreach ($column in $columns)
|
||||||
|
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||||
|
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||||
|
if (null != daterange${AttrName} && '' != daterange${AttrName}) {
|
||||||
|
queryParams.value.params["begin${AttrName}"] = daterange${AttrName}.value[0];
|
||||||
|
queryParams.value.params["end${AttrName}"] = daterange${AttrName}.value[1];
|
||||||
|
}
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
list${BusinessName}(queryParams.value).then(response => {
|
||||||
|
${businessName}List.value = proxy.handleTree(response.data, "${treeCode}", "${treeParentCode}");
|
||||||
|
loading.value = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查询${functionName}下拉树结构 */
|
||||||
|
async function getTreeselect() {
|
||||||
|
await list${BusinessName}().then(response => {
|
||||||
|
${businessName}Options.value = [];
|
||||||
|
const data = { ${treeCode}: 0, ${treeName}: '顶级节点', children: [] };
|
||||||
|
data.children = proxy.handleTree(response.data, "${treeCode}", "${treeParentCode}");
|
||||||
|
${businessName}Options.value.push(data);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 取消按钮
|
||||||
|
function cancel() {
|
||||||
|
open.value = false;
|
||||||
|
reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 表单重置
|
||||||
|
function reset() {
|
||||||
|
form.value = {
|
||||||
|
#foreach ($column in $columns)
|
||||||
|
#if($column.htmlType == "radio")
|
||||||
|
$column.javaField: #if($column.javaType == "Integer" || $column.javaType == "Long")0#else"0"#end#if($foreach.count != $columns.size()),#end
|
||||||
|
|
||||||
|
#elseif($column.htmlType == "checkbox")
|
||||||
|
$column.javaField: []#if($foreach.count != $columns.size()),#end
|
||||||
|
#else
|
||||||
|
$column.javaField: null#if($foreach.count != $columns.size()),#end
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
};
|
||||||
|
proxy.resetForm("${businessName}Ref");
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 搜索按钮操作 */
|
||||||
|
function handleQuery() {
|
||||||
|
getList();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 重置按钮操作 */
|
||||||
|
function resetQuery() {
|
||||||
|
#foreach ($column in $columns)
|
||||||
|
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||||
|
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||||
|
daterange${AttrName}.value = [];
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
proxy.resetForm("queryRef");
|
||||||
|
handleQuery();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 新增按钮操作 */
|
||||||
|
async function handleAdd(row) {
|
||||||
|
reset();
|
||||||
|
await getTreeselect();
|
||||||
|
if (row != null && row.${treeCode}) {
|
||||||
|
form.value.${treeParentCode} = row.${treeCode};
|
||||||
|
} else {
|
||||||
|
form.value.${treeParentCode} = 0;
|
||||||
|
}
|
||||||
|
open.value = true;
|
||||||
|
title.value = "添加${functionName}";
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 修改按钮操作 */
|
||||||
|
async function handleUpdate(row) {
|
||||||
|
reset();
|
||||||
|
await getTreeselect();
|
||||||
|
if (row != null) {
|
||||||
|
form.value.${treeParentCode} = row.${treeCode};
|
||||||
|
}
|
||||||
|
get${BusinessName}(row.${pkColumn.javaField}).then(response => {
|
||||||
|
form.value = response.data;
|
||||||
|
#foreach ($column in $columns)
|
||||||
|
#if($column.htmlType == "checkbox")
|
||||||
|
form.value.$column.javaField = form.value.${column.javaField}.split(",");
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
open.value = true;
|
||||||
|
title.value = "修改${functionName}";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 提交按钮 */
|
||||||
|
function submitForm() {
|
||||||
|
proxy.#[[$]]#refs["${businessName}Ref"].validate(valid => {
|
||||||
|
if (valid) {
|
||||||
|
#foreach ($column in $columns)
|
||||||
|
#if($column.htmlType == "checkbox")
|
||||||
|
form.value.$column.javaField = form.value.${column.javaField}.join(",");
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
if (form.value.${pkColumn.javaField} != null) {
|
||||||
|
update${BusinessName}(form.value).then(response => {
|
||||||
|
proxy.#[[$modal]]#.msgSuccess("修改成功");
|
||||||
|
open.value = false;
|
||||||
|
getList();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
add${BusinessName}(form.value).then(response => {
|
||||||
|
proxy.#[[$modal]]#.msgSuccess("新增成功");
|
||||||
|
open.value = false;
|
||||||
|
getList();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除按钮操作 */
|
||||||
|
function handleDelete(row) {
|
||||||
|
proxy.#[[$modal]]#.confirm('是否确认删除${functionName}编号为"' + row.${pkColumn.javaField} + '"的数据项?').then(function() {
|
||||||
|
return del${BusinessName}(row.${pkColumn.javaField});
|
||||||
|
}).then(() => {
|
||||||
|
getList();
|
||||||
|
proxy.#[[$modal]]#.msgSuccess("删除成功");
|
||||||
|
}).catch(() => {});
|
||||||
|
}
|
||||||
|
|
||||||
|
getList();
|
||||||
|
</script>
|
||||||
596
ruoyi-generator/src/main/resources/vm/vue/v3/index.vue.vm
Normal file
596
ruoyi-generator/src/main/resources/vm/vue/v3/index.vue.vm
Normal file
@ -0,0 +1,596 @@
|
|||||||
|
<template>
|
||||||
|
<div class="app-container">
|
||||||
|
<el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px">
|
||||||
|
#foreach($column in $columns)
|
||||||
|
#if($column.query)
|
||||||
|
#set($dictType=$column.dictType)
|
||||||
|
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||||
|
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
||||||
|
#if($parentheseIndex != -1)
|
||||||
|
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
||||||
|
#else
|
||||||
|
#set($comment=$column.columnComment)
|
||||||
|
#end
|
||||||
|
#if($column.htmlType == "input")
|
||||||
|
<el-form-item label="${comment}" prop="${column.javaField}">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.${column.javaField}"
|
||||||
|
placeholder="请输入${comment}"
|
||||||
|
clearable
|
||||||
|
@keyup.enter="handleQuery"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && "" != $dictType)
|
||||||
|
<el-form-item label="${comment}" prop="${column.javaField}">
|
||||||
|
<el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable>
|
||||||
|
<el-option
|
||||||
|
v-for="dict in ${dictType}"
|
||||||
|
:key="dict.value"
|
||||||
|
:label="dict.label"
|
||||||
|
:value="dict.value"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && $dictType)
|
||||||
|
<el-form-item label="${comment}" prop="${column.javaField}">
|
||||||
|
<el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable>
|
||||||
|
<el-option label="请选择字典生成" value="" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
#elseif($column.htmlType == "datetime" && $column.queryType != "BETWEEN")
|
||||||
|
<el-form-item label="${comment}" prop="${column.javaField}">
|
||||||
|
<el-date-picker clearable
|
||||||
|
v-model="queryParams.${column.javaField}"
|
||||||
|
type="date"
|
||||||
|
value-format="YYYY-MM-DD"
|
||||||
|
placeholder="请选择${comment}">
|
||||||
|
</el-date-picker>
|
||||||
|
</el-form-item>
|
||||||
|
#elseif($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||||
|
<el-form-item label="${comment}" style="width: 308px">
|
||||||
|
<el-date-picker
|
||||||
|
v-model="daterange${AttrName}"
|
||||||
|
value-format="YYYY-MM-DD"
|
||||||
|
type="daterange"
|
||||||
|
range-separator="-"
|
||||||
|
start-placeholder="开始日期"
|
||||||
|
end-placeholder="结束日期"
|
||||||
|
></el-date-picker>
|
||||||
|
</el-form-item>
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
<el-form-item>
|
||||||
|
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
|
||||||
|
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
|
||||||
|
<el-row :gutter="10" class="mb8">
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
plain
|
||||||
|
icon="Plus"
|
||||||
|
@click="handleAdd"
|
||||||
|
v-hasPermi="['${moduleName}:${businessName}:add']"
|
||||||
|
>新增</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="success"
|
||||||
|
plain
|
||||||
|
icon="Edit"
|
||||||
|
:disabled="single"
|
||||||
|
@click="handleUpdate"
|
||||||
|
v-hasPermi="['${moduleName}:${businessName}:edit']"
|
||||||
|
>修改</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="danger"
|
||||||
|
plain
|
||||||
|
icon="Delete"
|
||||||
|
:disabled="multiple"
|
||||||
|
@click="handleDelete"
|
||||||
|
v-hasPermi="['${moduleName}:${businessName}:remove']"
|
||||||
|
>删除</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="warning"
|
||||||
|
plain
|
||||||
|
icon="Download"
|
||||||
|
@click="handleExport"
|
||||||
|
v-hasPermi="['${moduleName}:${businessName}:export']"
|
||||||
|
>导出</el-button>
|
||||||
|
</el-col>
|
||||||
|
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
<el-table v-loading="loading" :data="${businessName}List" @selection-change="handleSelectionChange">
|
||||||
|
<el-table-column type="selection" width="55" align="center" />
|
||||||
|
#foreach($column in $columns)
|
||||||
|
#set($javaField=$column.javaField)
|
||||||
|
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
||||||
|
#if($parentheseIndex != -1)
|
||||||
|
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
||||||
|
#else
|
||||||
|
#set($comment=$column.columnComment)
|
||||||
|
#end
|
||||||
|
#if($column.pk)
|
||||||
|
<el-table-column label="${comment}" align="center" prop="${javaField}" />
|
||||||
|
#elseif($column.list && $column.htmlType == "datetime")
|
||||||
|
<el-table-column label="${comment}" align="center" prop="${javaField}" width="180">
|
||||||
|
<template #default="scope">
|
||||||
|
<span>{{ parseTime(scope.row.${javaField}, '{y}-{m}-{d}') }}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
#elseif($column.list && $column.htmlType == "imageUpload")
|
||||||
|
<el-table-column label="${comment}" align="center" prop="${javaField}" width="100">
|
||||||
|
<template #default="scope">
|
||||||
|
<image-preview :src="scope.row.${javaField}" :width="50" :height="50"/>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
#elseif($column.list && "" != $column.dictType)
|
||||||
|
<el-table-column label="${comment}" align="center" prop="${javaField}">
|
||||||
|
<template #default="scope">
|
||||||
|
#if($column.htmlType == "checkbox")
|
||||||
|
<dict-tag :options="${column.dictType}" :value="scope.row.${javaField} ? scope.row.${javaField}.split(',') : []"/>
|
||||||
|
#else
|
||||||
|
<dict-tag :options="${column.dictType}" :value="scope.row.${javaField}"/>
|
||||||
|
#end
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
#elseif($column.list && "" != $javaField)
|
||||||
|
<el-table-column label="${comment}" align="center" prop="${javaField}" />
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-button
|
||||||
|
type="text"
|
||||||
|
icon="Edit"
|
||||||
|
@click="handleUpdate(scope.row)"
|
||||||
|
v-hasPermi="['${moduleName}:${businessName}:edit']"
|
||||||
|
>修改</el-button>
|
||||||
|
<el-button
|
||||||
|
type="text"
|
||||||
|
icon="Delete"
|
||||||
|
@click="handleDelete(scope.row)"
|
||||||
|
v-hasPermi="['${moduleName}:${businessName}:remove']"
|
||||||
|
>删除</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
|
||||||
|
<pagination
|
||||||
|
v-show="total>0"
|
||||||
|
:total="total"
|
||||||
|
v-model:page="queryParams.pageNum"
|
||||||
|
v-model:limit="queryParams.pageSize"
|
||||||
|
@pagination="getList"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<!-- 添加或修改${functionName}对话框 -->
|
||||||
|
<el-dialog :title="title" v-model="open" width="500px" append-to-body>
|
||||||
|
<el-form ref="${businessName}Ref" :model="form" :rules="rules" label-width="80px">
|
||||||
|
#foreach($column in $columns)
|
||||||
|
#set($field=$column.javaField)
|
||||||
|
#if($column.insert && !$column.pk)
|
||||||
|
#if(($column.usableColumn) || (!$column.superColumn))
|
||||||
|
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
||||||
|
#if($parentheseIndex != -1)
|
||||||
|
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
||||||
|
#else
|
||||||
|
#set($comment=$column.columnComment)
|
||||||
|
#end
|
||||||
|
#set($dictType=$column.dictType)
|
||||||
|
#if($column.htmlType == "input")
|
||||||
|
<el-form-item label="${comment}" prop="${field}">
|
||||||
|
<el-input v-model="form.${field}" placeholder="请输入${comment}" />
|
||||||
|
</el-form-item>
|
||||||
|
#elseif($column.htmlType == "imageUpload")
|
||||||
|
<el-form-item label="${comment}">
|
||||||
|
<image-upload v-model="form.${field}"/>
|
||||||
|
</el-form-item>
|
||||||
|
#elseif($column.htmlType == "fileUpload")
|
||||||
|
<el-form-item label="${comment}">
|
||||||
|
<file-upload v-model="form.${field}"/>
|
||||||
|
</el-form-item>
|
||||||
|
#elseif($column.htmlType == "editor")
|
||||||
|
<el-form-item label="${comment}">
|
||||||
|
<editor v-model="form.${field}" :min-height="192"/>
|
||||||
|
</el-form-item>
|
||||||
|
#elseif($column.htmlType == "select" && "" != $dictType)
|
||||||
|
<el-form-item label="${comment}" prop="${field}">
|
||||||
|
<el-select v-model="form.${field}" placeholder="请选择${comment}">
|
||||||
|
<el-option
|
||||||
|
v-for="dict in ${dictType}"
|
||||||
|
:key="dict.value"
|
||||||
|
:label="dict.label"
|
||||||
|
#if($column.javaType == "Integer" || $column.javaType == "Long"):value="parseInt(dict.value)"#else:value="dict.value"#end
|
||||||
|
|
||||||
|
></el-option>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
#elseif($column.htmlType == "select" && $dictType)
|
||||||
|
<el-form-item label="${comment}" prop="${field}">
|
||||||
|
<el-select v-model="form.${field}" placeholder="请选择${comment}">
|
||||||
|
<el-option label="请选择字典生成" value="" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
#elseif($column.htmlType == "checkbox" && "" != $dictType)
|
||||||
|
<el-form-item label="${comment}">
|
||||||
|
<el-checkbox-group v-model="form.${field}">
|
||||||
|
<el-checkbox
|
||||||
|
v-for="dict in ${dictType}"
|
||||||
|
:key="dict.value"
|
||||||
|
:label="dict.value">
|
||||||
|
{{dict.label}}
|
||||||
|
</el-checkbox>
|
||||||
|
</el-checkbox-group>
|
||||||
|
</el-form-item>
|
||||||
|
#elseif($column.htmlType == "checkbox" && $dictType)
|
||||||
|
<el-form-item label="${comment}">
|
||||||
|
<el-checkbox-group v-model="form.${field}">
|
||||||
|
<el-checkbox>请选择字典生成</el-checkbox>
|
||||||
|
</el-checkbox-group>
|
||||||
|
</el-form-item>
|
||||||
|
#elseif($column.htmlType == "radio" && "" != $dictType)
|
||||||
|
<el-form-item label="${comment}">
|
||||||
|
<el-radio-group v-model="form.${field}">
|
||||||
|
<el-radio
|
||||||
|
v-for="dict in ${dictType}"
|
||||||
|
:key="dict.value"
|
||||||
|
#if($column.javaType == "Integer" || $column.javaType == "Long"):label="parseInt(dict.value)"#else:label="dict.value"#end
|
||||||
|
|
||||||
|
>{{dict.label}}</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
|
</el-form-item>
|
||||||
|
#elseif($column.htmlType == "radio" && $dictType)
|
||||||
|
<el-form-item label="${comment}">
|
||||||
|
<el-radio-group v-model="form.${field}">
|
||||||
|
<el-radio label="1">请选择字典生成</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
|
</el-form-item>
|
||||||
|
#elseif($column.htmlType == "datetime")
|
||||||
|
<el-form-item label="${comment}" prop="${field}">
|
||||||
|
<el-date-picker clearable
|
||||||
|
v-model="form.${field}"
|
||||||
|
type="date"
|
||||||
|
value-format="YYYY-MM-DD"
|
||||||
|
placeholder="请选择${comment}">
|
||||||
|
</el-date-picker>
|
||||||
|
</el-form-item>
|
||||||
|
#elseif($column.htmlType == "textarea")
|
||||||
|
<el-form-item label="${comment}" prop="${field}">
|
||||||
|
<el-input v-model="form.${field}" type="textarea" placeholder="请输入内容" />
|
||||||
|
</el-form-item>
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
#if($table.sub)
|
||||||
|
<el-divider content-position="center">${subTable.functionName}信息</el-divider>
|
||||||
|
<el-row :gutter="10" class="mb8">
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button type="primary" icon="Plus" @click="handleAdd${subClassName}">添加</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button type="danger" icon="Delete" @click="handleDelete${subClassName}">删除</el-button>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-table :data="${subclassName}List" :row-class-name="row${subClassName}Index" @selection-change="handle${subClassName}SelectionChange" ref="${subclassName}">
|
||||||
|
<el-table-column type="selection" width="50" align="center" />
|
||||||
|
<el-table-column label="序号" align="center" prop="index" width="50"/>
|
||||||
|
#foreach($column in $subTable.columns)
|
||||||
|
#set($javaField=$column.javaField)
|
||||||
|
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
||||||
|
#if($parentheseIndex != -1)
|
||||||
|
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
||||||
|
#else
|
||||||
|
#set($comment=$column.columnComment)
|
||||||
|
#end
|
||||||
|
#if($column.pk || $javaField == ${subTableFkclassName})
|
||||||
|
#elseif($column.list && $column.htmlType == "input")
|
||||||
|
<el-table-column label="$comment" prop="${javaField}" width="150">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-input v-model="scope.row.$javaField" placeholder="请输入$comment" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
#elseif($column.list && $column.htmlType == "datetime")
|
||||||
|
<el-table-column label="$comment" prop="${javaField}" width="240">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-date-picker clearable
|
||||||
|
v-model="scope.row.$javaField"
|
||||||
|
type="date"
|
||||||
|
value-format="YYYY-MM-DD"
|
||||||
|
placeholder="请选择$comment">
|
||||||
|
</el-date-picker>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
#elseif($column.list && ($column.htmlType == "select" || $column.htmlType == "radio") && "" != $column.dictType)
|
||||||
|
<el-table-column label="$comment" prop="${javaField}" width="150">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-select v-model="scope.row.$javaField" placeholder="请选择$comment">
|
||||||
|
<el-option
|
||||||
|
v-for="dict in $column.dictType"
|
||||||
|
:key="dict.value"
|
||||||
|
:label="dict.label"
|
||||||
|
:value="dict.value"
|
||||||
|
></el-option>
|
||||||
|
</el-select>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
#elseif($column.list && ($column.htmlType == "select" || $column.htmlType == "radio") && "" == $column.dictType)
|
||||||
|
<el-table-column label="$comment" prop="${javaField}" width="150">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-select v-model="scope.row.$javaField" placeholder="请选择$comment">
|
||||||
|
<el-option label="请选择字典生成" value="" />
|
||||||
|
</el-select>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
</el-table>
|
||||||
|
#end
|
||||||
|
</el-form>
|
||||||
|
<template #footer>
|
||||||
|
<div class="dialog-footer">
|
||||||
|
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||||
|
<el-button @click="cancel">取 消</el-button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup name="${BusinessName}">
|
||||||
|
import { list${BusinessName}, get${BusinessName}, del${BusinessName}, add${BusinessName}, update${BusinessName} } from "@/api/${moduleName}/${businessName}";
|
||||||
|
|
||||||
|
const { proxy } = getCurrentInstance();
|
||||||
|
#if(${dicts} != '')
|
||||||
|
#set($dictsNoSymbol=$dicts.replace("'", ""))
|
||||||
|
const { ${dictsNoSymbol} } = proxy.useDict(${dicts});
|
||||||
|
#end
|
||||||
|
|
||||||
|
const ${businessName}List = ref([]);
|
||||||
|
#if($table.sub)
|
||||||
|
const ${subclassName}List = ref([]);
|
||||||
|
#end
|
||||||
|
const open = ref(false);
|
||||||
|
const loading = ref(true);
|
||||||
|
const showSearch = ref(true);
|
||||||
|
const ids = ref([]);
|
||||||
|
#if($table.sub)
|
||||||
|
const checked${subClassName} = ref([]);
|
||||||
|
#end
|
||||||
|
const single = ref(true);
|
||||||
|
const multiple = ref(true);
|
||||||
|
const total = ref(0);
|
||||||
|
const title = ref("");
|
||||||
|
#foreach ($column in $columns)
|
||||||
|
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||||
|
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||||
|
const daterange${AttrName} = ref([]);
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
|
||||||
|
const data = reactive({
|
||||||
|
form: {},
|
||||||
|
queryParams: {
|
||||||
|
pageNum: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
#foreach ($column in $columns)
|
||||||
|
#if($column.query)
|
||||||
|
$column.javaField: null#if($foreach.count != $columns.size()),#end
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
#foreach ($column in $columns)
|
||||||
|
#if($column.required)
|
||||||
|
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
||||||
|
#if($parentheseIndex != -1)
|
||||||
|
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
||||||
|
#else
|
||||||
|
#set($comment=$column.columnComment)
|
||||||
|
#end
|
||||||
|
$column.javaField: [
|
||||||
|
{ required: true, message: "$comment不能为空", trigger: #if($column.htmlType == "select")"change"#else"blur"#end }
|
||||||
|
]#if($foreach.count != $columns.size()),#end
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const { queryParams, form, rules } = toRefs(data);
|
||||||
|
|
||||||
|
/** 查询${functionName}列表 */
|
||||||
|
function getList() {
|
||||||
|
loading.value = true;
|
||||||
|
#foreach ($column in $columns)
|
||||||
|
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||||
|
queryParams.value.params = {};
|
||||||
|
#break
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
#foreach ($column in $columns)
|
||||||
|
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||||
|
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||||
|
if (null != daterange${AttrName} && '' != daterange${AttrName}) {
|
||||||
|
queryParams.value.params["begin${AttrName}"] = daterange${AttrName}.value[0];
|
||||||
|
queryParams.value.params["end${AttrName}"] = daterange${AttrName}.value[1];
|
||||||
|
}
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
list${BusinessName}(queryParams.value).then(response => {
|
||||||
|
${businessName}List.value = response.rows;
|
||||||
|
total.value = response.total;
|
||||||
|
loading.value = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 取消按钮
|
||||||
|
function cancel() {
|
||||||
|
open.value = false;
|
||||||
|
reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 表单重置
|
||||||
|
function reset() {
|
||||||
|
form.value = {
|
||||||
|
#foreach ($column in $columns)
|
||||||
|
#if($column.htmlType == "radio")
|
||||||
|
$column.javaField: #if($column.javaType == "Integer" || $column.javaType == "Long")0#else"0"#end#if($foreach.count != $columns.size()),#end
|
||||||
|
#elseif($column.htmlType == "checkbox")
|
||||||
|
$column.javaField: []#if($foreach.count != $columns.size()),#end
|
||||||
|
#else
|
||||||
|
$column.javaField: null#if($foreach.count != $columns.size()),#end
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
};
|
||||||
|
#if($table.sub)
|
||||||
|
${subclassName}List.value = [];
|
||||||
|
#end
|
||||||
|
proxy.resetForm("${businessName}Ref");
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 搜索按钮操作 */
|
||||||
|
function handleQuery() {
|
||||||
|
queryParams.value.pageNum = 1;
|
||||||
|
getList();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 重置按钮操作 */
|
||||||
|
function resetQuery() {
|
||||||
|
#foreach ($column in $columns)
|
||||||
|
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||||
|
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||||
|
daterange${AttrName}.value = [];
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
proxy.resetForm("queryRef");
|
||||||
|
handleQuery();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 多选框选中数据
|
||||||
|
function handleSelectionChange(selection) {
|
||||||
|
ids.value = selection.map(item => item.${pkColumn.javaField});
|
||||||
|
single.value = selection.length != 1;
|
||||||
|
multiple.value = !selection.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 新增按钮操作 */
|
||||||
|
function handleAdd() {
|
||||||
|
reset();
|
||||||
|
open.value = true;
|
||||||
|
title.value = "添加${functionName}";
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 修改按钮操作 */
|
||||||
|
function handleUpdate(row) {
|
||||||
|
reset();
|
||||||
|
const ${pkColumn.javaField} = row.${pkColumn.javaField} || ids.value
|
||||||
|
get${BusinessName}(${pkColumn.javaField}).then(response => {
|
||||||
|
form.value = response.data;
|
||||||
|
#foreach ($column in $columns)
|
||||||
|
#if($column.htmlType == "checkbox")
|
||||||
|
form.value.$column.javaField = form.value.${column.javaField}.split(",");
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
#if($table.sub)
|
||||||
|
${subclassName}List.value = response.data.${subclassName}List;
|
||||||
|
#end
|
||||||
|
open.value = true;
|
||||||
|
title.value = "修改${functionName}";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 提交按钮 */
|
||||||
|
function submitForm() {
|
||||||
|
proxy.#[[$]]#refs["${businessName}Ref"].validate(valid => {
|
||||||
|
if (valid) {
|
||||||
|
#foreach ($column in $columns)
|
||||||
|
#if($column.htmlType == "checkbox")
|
||||||
|
form.value.$column.javaField = form.value.${column.javaField}.join(",");
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
#if($table.sub)
|
||||||
|
form.value.${subclassName}List = ${subclassName}List.value;
|
||||||
|
#end
|
||||||
|
if (form.value.${pkColumn.javaField} != null) {
|
||||||
|
update${BusinessName}(form.value).then(response => {
|
||||||
|
proxy.#[[$modal]]#.msgSuccess("修改成功");
|
||||||
|
open.value = false;
|
||||||
|
getList();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
add${BusinessName}(form.value).then(response => {
|
||||||
|
proxy.#[[$modal]]#.msgSuccess("新增成功");
|
||||||
|
open.value = false;
|
||||||
|
getList();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除按钮操作 */
|
||||||
|
function handleDelete(row) {
|
||||||
|
const ${pkColumn.javaField}s = row.${pkColumn.javaField} || ids.value;
|
||||||
|
proxy.#[[$modal]]#.confirm('是否确认删除${functionName}编号为"' + ${pkColumn.javaField}s + '"的数据项?').then(function() {
|
||||||
|
return del${BusinessName}(${pkColumn.javaField}s);
|
||||||
|
}).then(() => {
|
||||||
|
getList();
|
||||||
|
proxy.#[[$modal]]#.msgSuccess("删除成功");
|
||||||
|
}).catch(() => {});
|
||||||
|
}
|
||||||
|
|
||||||
|
#if($table.sub)
|
||||||
|
/** ${subTable.functionName}序号 */
|
||||||
|
function row${subClassName}Index({ row, rowIndex }) {
|
||||||
|
row.index = rowIndex + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** ${subTable.functionName}添加按钮操作 */
|
||||||
|
function handleAdd${subClassName}() {
|
||||||
|
let obj = {};
|
||||||
|
#foreach($column in $subTable.columns)
|
||||||
|
#if($column.pk || $column.javaField == ${subTableFkclassName})
|
||||||
|
#elseif($column.list && "" != $javaField)
|
||||||
|
obj.$column.javaField = "";
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
${subclassName}List.value.push(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** ${subTable.functionName}删除按钮操作 */
|
||||||
|
function handleDelete${subClassName}() {
|
||||||
|
if (checked${subClassName}.value.length == 0) {
|
||||||
|
proxy.#[[$modal]]#.msgError("请先选择要删除的${subTable.functionName}数据");
|
||||||
|
} else {
|
||||||
|
const ${subclassName}s = ${subclassName}List.value;
|
||||||
|
const checked${subClassName}s = checked${subClassName}.value;
|
||||||
|
${subclassName}List.value = ${subclassName}s.filter(function(item) {
|
||||||
|
return checked${subClassName}s.indexOf(item.index) == -1
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 复选框选中数据 */
|
||||||
|
function handle${subClassName}SelectionChange(selection) {
|
||||||
|
checked${subClassName}.value = selection.map(item => item.index)
|
||||||
|
}
|
||||||
|
|
||||||
|
#end
|
||||||
|
/** 导出按钮操作 */
|
||||||
|
function handleExport() {
|
||||||
|
proxy.download('${moduleName}/${businessName}/export', {
|
||||||
|
...queryParams.value
|
||||||
|
}, `${businessName}_#[[${new Date().getTime()}]]#.xlsx`)
|
||||||
|
}
|
||||||
|
|
||||||
|
getList();
|
||||||
|
</script>
|
||||||
1
ruoyi-generator/src/main/resources/vm/vue/v3/readme.txt
Normal file
1
ruoyi-generator/src/main/resources/vm/vue/v3/readme.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD>õ<EFBFBD><EFBFBD><EFBFBD>RuoYi-Vue3ǰ<33>ˣ<EFBFBD><CBA3><EFBFBD>ô<EFBFBD><C3B4>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>һ<EFBFBD>´<EFBFBD>Ŀ¼<C4BF><C2BC>ģ<EFBFBD><C4A3>index.vue.vm<76><6D>index-tree.vue.vm<76>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>ϼ<EFBFBD>vueĿ¼<C4BF><C2BC>
|
||||||
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>ruoyi</artifactId>
|
<artifactId>ruoyi</artifactId>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<version>3.8.0</version>
|
<version>3.8.2</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@ -1,57 +1,57 @@
|
|||||||
package com.ruoyi.quartz.config;
|
//package com.ruoyi.quartz.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 org.springframework.scheduling.quartz.SchedulerFactoryBean;
|
//import org.springframework.scheduling.quartz.SchedulerFactoryBean;
|
||||||
import javax.sql.DataSource;
|
//import javax.sql.DataSource;
|
||||||
import java.util.Properties;
|
//import java.util.Properties;
|
||||||
|
//
|
||||||
/**
|
///**
|
||||||
* 定时任务配置(单机部署建议删除此类和qrtz数据库表,默认走内存会最高效)
|
// * 定时任务配置(单机部署建议删除此类和qrtz数据库表,默认走内存会最高效)
|
||||||
*
|
// *
|
||||||
* @author ruoyi
|
// * @author ruoyi
|
||||||
*/
|
// */
|
||||||
@Configuration
|
//@Configuration
|
||||||
public class ScheduleConfig
|
//public class ScheduleConfig
|
||||||
{
|
//{
|
||||||
@Bean
|
// @Bean
|
||||||
public SchedulerFactoryBean schedulerFactoryBean(DataSource dataSource)
|
// public SchedulerFactoryBean schedulerFactoryBean(DataSource dataSource)
|
||||||
{
|
// {
|
||||||
SchedulerFactoryBean factory = new SchedulerFactoryBean();
|
// SchedulerFactoryBean factory = new SchedulerFactoryBean();
|
||||||
factory.setDataSource(dataSource);
|
// factory.setDataSource(dataSource);
|
||||||
|
//
|
||||||
// quartz参数
|
// // quartz参数
|
||||||
Properties prop = new Properties();
|
// Properties prop = new Properties();
|
||||||
prop.put("org.quartz.scheduler.instanceName", "RuoyiScheduler");
|
// prop.put("org.quartz.scheduler.instanceName", "RuoyiScheduler");
|
||||||
prop.put("org.quartz.scheduler.instanceId", "AUTO");
|
// prop.put("org.quartz.scheduler.instanceId", "AUTO");
|
||||||
// 线程池配置
|
// // 线程池配置
|
||||||
prop.put("org.quartz.threadPool.class", "org.quartz.simpl.SimpleThreadPool");
|
// prop.put("org.quartz.threadPool.class", "org.quartz.simpl.SimpleThreadPool");
|
||||||
prop.put("org.quartz.threadPool.threadCount", "20");
|
// prop.put("org.quartz.threadPool.threadCount", "20");
|
||||||
prop.put("org.quartz.threadPool.threadPriority", "5");
|
// prop.put("org.quartz.threadPool.threadPriority", "5");
|
||||||
// JobStore配置
|
// // JobStore配置
|
||||||
prop.put("org.quartz.jobStore.class", "org.quartz.impl.jdbcjobstore.JobStoreTX");
|
// prop.put("org.quartz.jobStore.class", "org.springframework.scheduling.quartz.LocalDataSourceJobStore");
|
||||||
// 集群配置
|
// // 集群配置
|
||||||
prop.put("org.quartz.jobStore.isClustered", "true");
|
// prop.put("org.quartz.jobStore.isClustered", "true");
|
||||||
prop.put("org.quartz.jobStore.clusterCheckinInterval", "15000");
|
// prop.put("org.quartz.jobStore.clusterCheckinInterval", "15000");
|
||||||
prop.put("org.quartz.jobStore.maxMisfiresToHandleAtATime", "1");
|
// prop.put("org.quartz.jobStore.maxMisfiresToHandleAtATime", "1");
|
||||||
prop.put("org.quartz.jobStore.txIsolationLevelSerializable", "true");
|
// prop.put("org.quartz.jobStore.txIsolationLevelSerializable", "true");
|
||||||
|
//
|
||||||
// sqlserver 启用
|
// // sqlserver 启用
|
||||||
// prop.put("org.quartz.jobStore.selectWithLockSQL", "SELECT * FROM {0}LOCKS UPDLOCK WHERE LOCK_NAME = ?");
|
// // prop.put("org.quartz.jobStore.selectWithLockSQL", "SELECT * FROM {0}LOCKS UPDLOCK WHERE LOCK_NAME = ?");
|
||||||
prop.put("org.quartz.jobStore.misfireThreshold", "12000");
|
// prop.put("org.quartz.jobStore.misfireThreshold", "12000");
|
||||||
prop.put("org.quartz.jobStore.tablePrefix", "QRTZ_");
|
// prop.put("org.quartz.jobStore.tablePrefix", "QRTZ_");
|
||||||
factory.setQuartzProperties(prop);
|
// factory.setQuartzProperties(prop);
|
||||||
|
//
|
||||||
factory.setSchedulerName("RuoyiScheduler");
|
// factory.setSchedulerName("RuoyiScheduler");
|
||||||
// 延时启动
|
// // 延时启动
|
||||||
factory.setStartupDelay(1);
|
// factory.setStartupDelay(1);
|
||||||
factory.setApplicationContextSchedulerContextKey("applicationContextKey");
|
// factory.setApplicationContextSchedulerContextKey("applicationContextKey");
|
||||||
// 可选,QuartzScheduler
|
// // 可选,QuartzScheduler
|
||||||
// 启动时更新己存在的Job,这样就不用每次修改targetObject后删除qrtz_job_details表对应记录了
|
// // 启动时更新己存在的Job,这样就不用每次修改targetObject后删除qrtz_job_details表对应记录了
|
||||||
factory.setOverwriteExistingJobs(true);
|
// factory.setOverwriteExistingJobs(true);
|
||||||
// 设置自动启动,默认为true
|
// // 设置自动启动,默认为true
|
||||||
factory.setAutoStartup(true);
|
// factory.setAutoStartup(true);
|
||||||
|
//
|
||||||
return factory;
|
// return factory;
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|||||||
@ -25,6 +25,7 @@ import com.ruoyi.common.utils.poi.ExcelUtil;
|
|||||||
import com.ruoyi.quartz.domain.SysJob;
|
import com.ruoyi.quartz.domain.SysJob;
|
||||||
import com.ruoyi.quartz.service.ISysJobService;
|
import com.ruoyi.quartz.service.ISysJobService;
|
||||||
import com.ruoyi.quartz.util.CronUtils;
|
import com.ruoyi.quartz.util.CronUtils;
|
||||||
|
import com.ruoyi.quartz.util.ScheduleUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 调度任务信息操作处理
|
* 调度任务信息操作处理
|
||||||
@ -87,20 +88,24 @@ public class SysJobController extends BaseController
|
|||||||
}
|
}
|
||||||
else if (StringUtils.containsIgnoreCase(job.getInvokeTarget(), Constants.LOOKUP_RMI))
|
else if (StringUtils.containsIgnoreCase(job.getInvokeTarget(), Constants.LOOKUP_RMI))
|
||||||
{
|
{
|
||||||
return error("新增任务'" + job.getJobName() + "'失败,目标字符串不允许'rmi://'调用");
|
return error("新增任务'" + job.getJobName() + "'失败,目标字符串不允许'rmi'调用");
|
||||||
}
|
}
|
||||||
else if (StringUtils.containsIgnoreCase(job.getInvokeTarget(), Constants.LOOKUP_LDAP))
|
else if (StringUtils.containsAnyIgnoreCase(job.getInvokeTarget(), new String[] { Constants.LOOKUP_LDAP, Constants.LOOKUP_LDAPS }))
|
||||||
{
|
{
|
||||||
return error("新增任务'" + job.getJobName() + "'失败,目标字符串不允许'ldap://'调用");
|
return error("新增任务'" + job.getJobName() + "'失败,目标字符串不允许'ldap(s)'调用");
|
||||||
}
|
}
|
||||||
else if (StringUtils.containsAnyIgnoreCase(job.getInvokeTarget(), new String[] { Constants.HTTP, Constants.HTTPS }))
|
else if (StringUtils.containsAnyIgnoreCase(job.getInvokeTarget(), new String[] { Constants.HTTP, Constants.HTTPS }))
|
||||||
{
|
{
|
||||||
return error("新增任务'" + job.getJobName() + "'失败,目标字符串不允许'http(s)//'调用");
|
return error("新增任务'" + job.getJobName() + "'失败,目标字符串不允许'http(s)'调用");
|
||||||
}
|
}
|
||||||
else if (StringUtils.containsAnyIgnoreCase(job.getInvokeTarget(), Constants.JOB_ERROR_STR))
|
else if (StringUtils.containsAnyIgnoreCase(job.getInvokeTarget(), Constants.JOB_ERROR_STR))
|
||||||
{
|
{
|
||||||
return error("新增任务'" + job.getJobName() + "'失败,目标字符串存在违规");
|
return error("新增任务'" + job.getJobName() + "'失败,目标字符串存在违规");
|
||||||
}
|
}
|
||||||
|
else if (!ScheduleUtils.whiteList(job.getInvokeTarget()))
|
||||||
|
{
|
||||||
|
return error("新增任务'" + job.getJobName() + "'失败,目标字符串不在白名单内");
|
||||||
|
}
|
||||||
job.setCreateBy(getUsername());
|
job.setCreateBy(getUsername());
|
||||||
return toAjax(jobService.insertJob(job));
|
return toAjax(jobService.insertJob(job));
|
||||||
}
|
}
|
||||||
@ -119,20 +124,24 @@ public class SysJobController extends BaseController
|
|||||||
}
|
}
|
||||||
else if (StringUtils.containsIgnoreCase(job.getInvokeTarget(), Constants.LOOKUP_RMI))
|
else if (StringUtils.containsIgnoreCase(job.getInvokeTarget(), Constants.LOOKUP_RMI))
|
||||||
{
|
{
|
||||||
return error("修改任务'" + job.getJobName() + "'失败,目标字符串不允许'rmi://'调用");
|
return error("修改任务'" + job.getJobName() + "'失败,目标字符串不允许'rmi'调用");
|
||||||
}
|
}
|
||||||
else if (StringUtils.containsIgnoreCase(job.getInvokeTarget(), Constants.LOOKUP_LDAP))
|
else if (StringUtils.containsAnyIgnoreCase(job.getInvokeTarget(), new String[] { Constants.LOOKUP_LDAP, Constants.LOOKUP_LDAPS }))
|
||||||
{
|
{
|
||||||
return error("修改任务'" + job.getJobName() + "'失败,目标字符串不允许'ldap://'调用");
|
return error("修改任务'" + job.getJobName() + "'失败,目标字符串不允许'ldap(s)'调用");
|
||||||
}
|
}
|
||||||
else if (StringUtils.containsAnyIgnoreCase(job.getInvokeTarget(), new String[] { Constants.HTTP, Constants.HTTPS }))
|
else if (StringUtils.containsAnyIgnoreCase(job.getInvokeTarget(), new String[] { Constants.HTTP, Constants.HTTPS }))
|
||||||
{
|
{
|
||||||
return error("修改任务'" + job.getJobName() + "'失败,目标字符串不允许'http(s)//'调用");
|
return error("修改任务'" + job.getJobName() + "'失败,目标字符串不允许'http(s)'调用");
|
||||||
}
|
}
|
||||||
else if (StringUtils.containsAnyIgnoreCase(job.getInvokeTarget(), Constants.JOB_ERROR_STR))
|
else if (StringUtils.containsAnyIgnoreCase(job.getInvokeTarget(), Constants.JOB_ERROR_STR))
|
||||||
{
|
{
|
||||||
return error("修改任务'" + job.getJobName() + "'失败,目标字符串存在违规");
|
return error("修改任务'" + job.getJobName() + "'失败,目标字符串存在违规");
|
||||||
}
|
}
|
||||||
|
else if (!ScheduleUtils.whiteList(job.getInvokeTarget()))
|
||||||
|
{
|
||||||
|
return error("修改任务'" + job.getJobName() + "'失败,目标字符串不在白名单内");
|
||||||
|
}
|
||||||
job.setUpdateBy(getUsername());
|
job.setUpdateBy(getUsername());
|
||||||
return toAjax(jobService.updateJob(job));
|
return toAjax(jobService.updateJob(job));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -65,7 +65,7 @@ public class JobInvokeUtil
|
|||||||
/**
|
/**
|
||||||
* 校验是否为为class包名
|
* 校验是否为为class包名
|
||||||
*
|
*
|
||||||
* @param str 名称
|
* @param invokeTarget 名称
|
||||||
* @return true是 false否
|
* @return true是 false否
|
||||||
*/
|
*/
|
||||||
public static boolean isValidClassName(String invokeTarget)
|
public static boolean isValidClassName(String invokeTarget)
|
||||||
@ -110,30 +110,30 @@ public class JobInvokeUtil
|
|||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
String[] methodParams = methodStr.split(",(?=(?:[^\']*\"[^\']*\')*[^\']*$)");
|
String[] methodParams = methodStr.split(",(?=([^\"']*[\"'][^\"']*[\"'])*[^\"']*$)");
|
||||||
List<Object[]> classs = new LinkedList<>();
|
List<Object[]> classs = new LinkedList<>();
|
||||||
for (int i = 0; i < methodParams.length; i++)
|
for (int i = 0; i < methodParams.length; i++)
|
||||||
{
|
{
|
||||||
String str = StringUtils.trimToEmpty(methodParams[i]);
|
String str = StringUtils.trimToEmpty(methodParams[i]);
|
||||||
// String字符串类型,包含'
|
// String字符串类型,以'或"开头
|
||||||
if (StringUtils.contains(str, "'"))
|
if (StringUtils.startsWithAny(str, "'", "\""))
|
||||||
{
|
{
|
||||||
classs.add(new Object[] { StringUtils.replace(str, "'", ""), String.class });
|
classs.add(new Object[] { StringUtils.substring(str, 1, str.length() - 1), String.class });
|
||||||
}
|
}
|
||||||
// boolean布尔类型,等于true或者false
|
// boolean布尔类型,等于true或者false
|
||||||
else if (StringUtils.equals(str, "true") || StringUtils.equalsIgnoreCase(str, "false"))
|
else if ("true".equalsIgnoreCase(str) || "false".equalsIgnoreCase(str))
|
||||||
{
|
{
|
||||||
classs.add(new Object[] { Boolean.valueOf(str), Boolean.class });
|
classs.add(new Object[] { Boolean.valueOf(str), Boolean.class });
|
||||||
}
|
}
|
||||||
// long长整形,包含L
|
// long长整形,以L结尾
|
||||||
else if (StringUtils.containsIgnoreCase(str, "L"))
|
else if (StringUtils.endsWith(str, "L"))
|
||||||
{
|
{
|
||||||
classs.add(new Object[] { Long.valueOf(StringUtils.replaceIgnoreCase(str, "L", "")), Long.class });
|
classs.add(new Object[] { Long.valueOf(StringUtils.substring(str, 0, str.length() - 1)), Long.class });
|
||||||
}
|
}
|
||||||
// double浮点类型,包含D
|
// double浮点类型,以D结尾
|
||||||
else if (StringUtils.containsIgnoreCase(str, "D"))
|
else if (StringUtils.endsWith(str, "D"))
|
||||||
{
|
{
|
||||||
classs.add(new Object[] { Double.valueOf(StringUtils.replaceIgnoreCase(str, "D", "")), Double.class });
|
classs.add(new Object[] { Double.valueOf(StringUtils.substring(str, 0, str.length() - 1)), Double.class });
|
||||||
}
|
}
|
||||||
// 其他类型归类为整形
|
// 其他类型归类为整形
|
||||||
else
|
else
|
||||||
|
|||||||
@ -10,9 +10,11 @@ import org.quartz.Scheduler;
|
|||||||
import org.quartz.SchedulerException;
|
import org.quartz.SchedulerException;
|
||||||
import org.quartz.TriggerBuilder;
|
import org.quartz.TriggerBuilder;
|
||||||
import org.quartz.TriggerKey;
|
import org.quartz.TriggerKey;
|
||||||
|
import com.ruoyi.common.constant.Constants;
|
||||||
import com.ruoyi.common.constant.ScheduleConstants;
|
import com.ruoyi.common.constant.ScheduleConstants;
|
||||||
import com.ruoyi.common.exception.job.TaskException;
|
import com.ruoyi.common.exception.job.TaskException;
|
||||||
import com.ruoyi.common.exception.job.TaskException.Code;
|
import com.ruoyi.common.exception.job.TaskException.Code;
|
||||||
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
import com.ruoyi.quartz.domain.SysJob;
|
import com.ruoyi.quartz.domain.SysJob;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -110,4 +112,21 @@ public class ScheduleUtils
|
|||||||
+ "' cannot be used in cron schedule tasks", Code.CONFIG_ERROR);
|
+ "' cannot be used in cron schedule tasks", Code.CONFIG_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查包名是否为白名单配置
|
||||||
|
*
|
||||||
|
* @param invokeTarget 目标字符串
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public static boolean whiteList(String invokeTarget)
|
||||||
|
{
|
||||||
|
String packageName = StringUtils.substringBefore(invokeTarget, "(");
|
||||||
|
int count = StringUtils.countMatches(packageName, ".");
|
||||||
|
if (count > 1)
|
||||||
|
{
|
||||||
|
return StringUtils.containsAnyIgnoreCase(invokeTarget, Constants.JOB_WHITELIST_STR);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>ruoyi</artifactId>
|
<artifactId>ruoyi</artifactId>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<version>3.8.0</version>
|
<version>3.8.2</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import javax.validation.constraints.Size;
|
|||||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
import com.ruoyi.common.core.domain.BaseEntity;
|
import com.ruoyi.common.core.domain.BaseEntity;
|
||||||
|
import com.ruoyi.common.xss.Xss;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通知公告表 sys_notice
|
* 通知公告表 sys_notice
|
||||||
@ -45,6 +46,7 @@ public class SysNotice extends BaseEntity
|
|||||||
this.noticeTitle = noticeTitle;
|
this.noticeTitle = noticeTitle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Xss(message = "公告标题不能包含脚本字符")
|
||||||
@NotBlank(message = "公告标题不能为空")
|
@NotBlank(message = "公告标题不能为空")
|
||||||
@Size(min = 0, max = 50, message = "公告标题不能超过50个字符")
|
@Size(min = 0, max = 50, message = "公告标题不能超过50个字符")
|
||||||
public String getNoticeTitle()
|
public String getNoticeTitle()
|
||||||
|
|||||||
@ -26,7 +26,7 @@ public interface SysDeptMapper
|
|||||||
* @param deptCheckStrictly 部门树选择项是否关联显示
|
* @param deptCheckStrictly 部门树选择项是否关联显示
|
||||||
* @return 选中部门列表
|
* @return 选中部门列表
|
||||||
*/
|
*/
|
||||||
public List<Integer> selectDeptListByRoleId(@Param("roleId") Long roleId, @Param("deptCheckStrictly") boolean deptCheckStrictly);
|
public List<Long> selectDeptListByRoleId(@Param("roleId") Long roleId, @Param("deptCheckStrictly") boolean deptCheckStrictly);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据部门ID查询信息
|
* 根据部门ID查询信息
|
||||||
|
|||||||
@ -64,7 +64,7 @@ public interface SysMenuMapper
|
|||||||
* @param menuCheckStrictly 菜单树选择项是否关联显示
|
* @param menuCheckStrictly 菜单树选择项是否关联显示
|
||||||
* @return 选中菜单列表
|
* @return 选中菜单列表
|
||||||
*/
|
*/
|
||||||
public List<Integer> selectMenuListByRoleId(@Param("roleId") Long roleId, @Param("menuCheckStrictly") boolean menuCheckStrictly);
|
public List<Long> selectMenuListByRoleId(@Param("roleId") Long roleId, @Param("menuCheckStrictly") boolean menuCheckStrictly);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据菜单ID查询信息
|
* 根据菜单ID查询信息
|
||||||
|
|||||||
@ -39,7 +39,7 @@ public interface SysPostMapper
|
|||||||
* @param userId 用户ID
|
* @param userId 用户ID
|
||||||
* @return 选中岗位ID列表
|
* @return 选中岗位ID列表
|
||||||
*/
|
*/
|
||||||
public List<Integer> selectPostListByUserId(Long userId);
|
public List<Long> selectPostListByUserId(Long userId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询用户所属岗位组
|
* 查询用户所属岗位组
|
||||||
|
|||||||
@ -20,7 +20,7 @@ public interface SysUserMapper
|
|||||||
public List<SysUser> selectUserList(SysUser sysUser);
|
public List<SysUser> selectUserList(SysUser sysUser);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据条件分页查询未已配用户角色列表
|
* 根据条件分页查询已配用户角色列表
|
||||||
*
|
*
|
||||||
* @param user 用户信息
|
* @param user 用户信息
|
||||||
* @return 用户信息集合信息
|
* @return 用户信息集合信息
|
||||||
|
|||||||
@ -61,7 +61,6 @@ public interface ISysConfigService
|
|||||||
* 批量删除参数信息
|
* 批量删除参数信息
|
||||||
*
|
*
|
||||||
* @param configIds 需要删除的参数ID
|
* @param configIds 需要删除的参数ID
|
||||||
* @return 结果
|
|
||||||
*/
|
*/
|
||||||
public void deleteConfigByIds(Long[] configIds);
|
public void deleteConfigByIds(Long[] configIds);
|
||||||
|
|
||||||
|
|||||||
@ -41,7 +41,7 @@ public interface ISysDeptService
|
|||||||
* @param roleId 角色ID
|
* @param roleId 角色ID
|
||||||
* @return 选中部门列表
|
* @return 选中部门列表
|
||||||
*/
|
*/
|
||||||
public List<Integer> selectDeptListByRoleId(Long roleId);
|
public List<Long> selectDeptListByRoleId(Long roleId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据部门ID查询信息
|
* 根据部门ID查询信息
|
||||||
|
|||||||
@ -39,7 +39,6 @@ public interface ISysDictDataService
|
|||||||
* 批量删除字典数据信息
|
* 批量删除字典数据信息
|
||||||
*
|
*
|
||||||
* @param dictCodes 需要删除的字典数据ID
|
* @param dictCodes 需要删除的字典数据ID
|
||||||
* @return 结果
|
|
||||||
*/
|
*/
|
||||||
public void deleteDictDataByIds(Long[] dictCodes);
|
public void deleteDictDataByIds(Long[] dictCodes);
|
||||||
|
|
||||||
|
|||||||
@ -54,7 +54,6 @@ public interface ISysDictTypeService
|
|||||||
* 批量删除字典信息
|
* 批量删除字典信息
|
||||||
*
|
*
|
||||||
* @param dictIds 需要删除的字典ID
|
* @param dictIds 需要删除的字典ID
|
||||||
* @return 结果
|
|
||||||
*/
|
*/
|
||||||
public void deleteDictTypeByIds(Long[] dictIds);
|
public void deleteDictTypeByIds(Long[] dictIds);
|
||||||
|
|
||||||
|
|||||||
@ -29,7 +29,7 @@ public interface ISysLogininforService
|
|||||||
* 批量删除系统登录日志
|
* 批量删除系统登录日志
|
||||||
*
|
*
|
||||||
* @param infoIds 需要删除的登录日志ID
|
* @param infoIds 需要删除的登录日志ID
|
||||||
* @return
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int deleteLogininforByIds(Long[] infoIds);
|
public int deleteLogininforByIds(Long[] infoIds);
|
||||||
|
|
||||||
|
|||||||
@ -52,7 +52,7 @@ public interface ISysMenuService
|
|||||||
* @param roleId 角色ID
|
* @param roleId 角色ID
|
||||||
* @return 选中菜单列表
|
* @return 选中菜单列表
|
||||||
*/
|
*/
|
||||||
public List<Integer> selectMenuListByRoleId(Long roleId);
|
public List<Long> selectMenuListByRoleId(Long roleId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 构建前端路由所需要的菜单
|
* 构建前端路由所需要的菜单
|
||||||
|
|||||||
@ -39,7 +39,7 @@ public interface ISysPostService
|
|||||||
* @param userId 用户ID
|
* @param userId 用户ID
|
||||||
* @return 选中岗位ID列表
|
* @return 选中岗位ID列表
|
||||||
*/
|
*/
|
||||||
public List<Integer> selectPostListByUserId(Long userId);
|
public List<Long> selectPostListByUserId(Long userId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 校验岗位名称
|
* 校验岗位名称
|
||||||
@ -78,7 +78,6 @@ public interface ISysPostService
|
|||||||
*
|
*
|
||||||
* @param postIds 需要删除的岗位ID
|
* @param postIds 需要删除的岗位ID
|
||||||
* @return 结果
|
* @return 结果
|
||||||
* @throws Exception 异常
|
|
||||||
*/
|
*/
|
||||||
public int deletePostByIds(Long[] postIds);
|
public int deletePostByIds(Long[] postIds);
|
||||||
|
|
||||||
|
|||||||
@ -146,7 +146,6 @@ public class SysConfigServiceImpl implements ISysConfigService
|
|||||||
* 批量删除参数信息
|
* 批量删除参数信息
|
||||||
*
|
*
|
||||||
* @param configIds 需要删除的参数ID
|
* @param configIds 需要删除的参数ID
|
||||||
* @return 结果
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void deleteConfigByIds(Long[] configIds)
|
public void deleteConfigByIds(Long[] configIds)
|
||||||
|
|||||||
@ -63,9 +63,8 @@ public class SysDeptServiceImpl implements ISysDeptService
|
|||||||
{
|
{
|
||||||
tempList.add(dept.getDeptId());
|
tempList.add(dept.getDeptId());
|
||||||
}
|
}
|
||||||
for (Iterator<SysDept> iterator = depts.iterator(); iterator.hasNext();)
|
for (SysDept dept : depts)
|
||||||
{
|
{
|
||||||
SysDept dept = (SysDept) iterator.next();
|
|
||||||
// 如果是顶级节点, 遍历该父节点的所有子节点
|
// 如果是顶级节点, 遍历该父节点的所有子节点
|
||||||
if (!tempList.contains(dept.getParentId()))
|
if (!tempList.contains(dept.getParentId()))
|
||||||
{
|
{
|
||||||
@ -100,7 +99,7 @@ public class SysDeptServiceImpl implements ISysDeptService
|
|||||||
* @return 选中部门列表
|
* @return 选中部门列表
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<Integer> selectDeptListByRoleId(Long roleId)
|
public List<Long> selectDeptListByRoleId(Long roleId)
|
||||||
{
|
{
|
||||||
SysRole role = roleMapper.selectRoleById(roleId);
|
SysRole role = roleMapper.selectRoleById(roleId);
|
||||||
return deptMapper.selectDeptListByRoleId(roleId, role.isDeptCheckStrictly());
|
return deptMapper.selectDeptListByRoleId(roleId, role.isDeptCheckStrictly());
|
||||||
|
|||||||
@ -60,7 +60,6 @@ public class SysDictDataServiceImpl implements ISysDictDataService
|
|||||||
* 批量删除字典数据信息
|
* 批量删除字典数据信息
|
||||||
*
|
*
|
||||||
* @param dictCodes 需要删除的字典数据ID
|
* @param dictCodes 需要删除的字典数据ID
|
||||||
* @return 结果
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void deleteDictDataByIds(Long[] dictCodes)
|
public void deleteDictDataByIds(Long[] dictCodes)
|
||||||
|
|||||||
@ -1,5 +1,13 @@
|
|||||||
package com.ruoyi.system.service.impl;
|
package com.ruoyi.system.service.impl;
|
||||||
|
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import javax.annotation.PostConstruct;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import com.ruoyi.common.constant.UserConstants;
|
import com.ruoyi.common.constant.UserConstants;
|
||||||
import com.ruoyi.common.core.domain.entity.SysDictData;
|
import com.ruoyi.common.core.domain.entity.SysDictData;
|
||||||
import com.ruoyi.common.core.domain.entity.SysDictType;
|
import com.ruoyi.common.core.domain.entity.SysDictType;
|
||||||
@ -9,11 +17,6 @@ import com.ruoyi.common.utils.StringUtils;
|
|||||||
import com.ruoyi.system.mapper.SysDictDataMapper;
|
import com.ruoyi.system.mapper.SysDictDataMapper;
|
||||||
import com.ruoyi.system.mapper.SysDictTypeMapper;
|
import com.ruoyi.system.mapper.SysDictTypeMapper;
|
||||||
import com.ruoyi.system.service.ISysDictTypeService;
|
import com.ruoyi.system.service.ISysDictTypeService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
import javax.annotation.PostConstruct;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字典 业务层处理
|
* 字典 业务层处理
|
||||||
@ -112,7 +115,6 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService
|
|||||||
* 批量删除字典类型信息
|
* 批量删除字典类型信息
|
||||||
*
|
*
|
||||||
* @param dictIds 需要删除的字典ID
|
* @param dictIds 需要删除的字典ID
|
||||||
* @return 结果
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void deleteDictTypeByIds(Long[] dictIds)
|
public void deleteDictTypeByIds(Long[] dictIds)
|
||||||
@ -135,11 +137,12 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService
|
|||||||
@Override
|
@Override
|
||||||
public void loadingDictCache()
|
public void loadingDictCache()
|
||||||
{
|
{
|
||||||
List<SysDictType> dictTypeList = dictTypeMapper.selectDictTypeAll();
|
SysDictData dictData = new SysDictData();
|
||||||
for (SysDictType dictType : dictTypeList)
|
dictData.setStatus("0");
|
||||||
|
Map<String, List<SysDictData>> dictDataMap = dictDataMapper.selectDictDataList(dictData).stream().collect(Collectors.groupingBy(SysDictData::getDictType));
|
||||||
|
for (Map.Entry<String, List<SysDictData>> entry : dictDataMap.entrySet())
|
||||||
{
|
{
|
||||||
List<SysDictData> dictDatas = dictDataMapper.selectDictDataByType(dictType.getDictType());
|
DictUtils.setDictCache(entry.getKey(), entry.getValue().stream().sorted(Comparator.comparing(SysDictData::getDictSort)).collect(Collectors.toList()));
|
||||||
DictUtils.setDictCache(dictType.getDictType(), dictDatas);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -46,7 +46,7 @@ public class SysLogininforServiceImpl implements ISysLogininforService
|
|||||||
* 批量删除系统登录日志
|
* 批量删除系统登录日志
|
||||||
*
|
*
|
||||||
* @param infoIds 需要删除的登录日志ID
|
* @param infoIds 需要删除的登录日志ID
|
||||||
* @return
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int deleteLogininforByIds(Long[] infoIds)
|
public int deleteLogininforByIds(Long[] infoIds)
|
||||||
|
|||||||
@ -128,7 +128,7 @@ public class SysMenuServiceImpl implements ISysMenuService
|
|||||||
* @return 选中菜单列表
|
* @return 选中菜单列表
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<Integer> selectMenuListByRoleId(Long roleId)
|
public List<Long> selectMenuListByRoleId(Long roleId)
|
||||||
{
|
{
|
||||||
SysRole role = roleMapper.selectRoleById(roleId);
|
SysRole role = roleMapper.selectRoleById(roleId);
|
||||||
return menuMapper.selectMenuListByRoleId(roleId, role.isMenuCheckStrictly());
|
return menuMapper.selectMenuListByRoleId(roleId, role.isMenuCheckStrictly());
|
||||||
@ -176,7 +176,7 @@ public class SysMenuServiceImpl implements ISysMenuService
|
|||||||
else if (menu.getParentId().intValue() == 0 && isInnerLink(menu))
|
else if (menu.getParentId().intValue() == 0 && isInnerLink(menu))
|
||||||
{
|
{
|
||||||
router.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon()));
|
router.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon()));
|
||||||
router.setPath("/inner");
|
router.setPath("/");
|
||||||
List<RouterVo> childrenList = new ArrayList<RouterVo>();
|
List<RouterVo> childrenList = new ArrayList<RouterVo>();
|
||||||
RouterVo children = new RouterVo();
|
RouterVo children = new RouterVo();
|
||||||
String routerPath = innerLinkReplaceEach(menu.getPath());
|
String routerPath = innerLinkReplaceEach(menu.getPath());
|
||||||
@ -498,7 +498,7 @@ public class SysMenuServiceImpl implements ISysMenuService
|
|||||||
*/
|
*/
|
||||||
private boolean hasChild(List<SysMenu> list, SysMenu t)
|
private boolean hasChild(List<SysMenu> list, SysMenu t)
|
||||||
{
|
{
|
||||||
return getChildList(list, t).size() > 0 ? true : false;
|
return getChildList(list, t).size() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -67,7 +67,7 @@ public class SysPostServiceImpl implements ISysPostService
|
|||||||
* @return 选中岗位ID列表
|
* @return 选中岗位ID列表
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<Integer> selectPostListByUserId(Long userId)
|
public List<Long> selectPostListByUserId(Long userId)
|
||||||
{
|
{
|
||||||
return postMapper.selectPostListByUserId(userId);
|
return postMapper.selectPostListByUserId(userId);
|
||||||
}
|
}
|
||||||
@ -137,7 +137,6 @@ public class SysPostServiceImpl implements ISysPostService
|
|||||||
*
|
*
|
||||||
* @param postIds 需要删除的岗位ID
|
* @param postIds 需要删除的岗位ID
|
||||||
* @return 结果
|
* @return 结果
|
||||||
* @throws Exception 异常
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int deletePostByIds(Long[] postIds)
|
public int deletePostByIds(Long[] postIds)
|
||||||
|
|||||||
@ -361,6 +361,7 @@ public class SysRoleServiceImpl implements ISysRoleService
|
|||||||
for (Long roleId : roleIds)
|
for (Long roleId : roleIds)
|
||||||
{
|
{
|
||||||
checkRoleAllowed(new SysRole(roleId));
|
checkRoleAllowed(new SysRole(roleId));
|
||||||
|
checkRoleDataScope(roleId);
|
||||||
SysRole role = selectRoleById(roleId);
|
SysRole role = selectRoleById(roleId);
|
||||||
if (countUserRoleByRoleId(roleId) > 0)
|
if (countUserRoleByRoleId(roleId) > 0)
|
||||||
{
|
{
|
||||||
@ -403,7 +404,7 @@ public class SysRoleServiceImpl implements ISysRoleService
|
|||||||
* 批量选择授权用户角色
|
* 批量选择授权用户角色
|
||||||
*
|
*
|
||||||
* @param roleId 角色ID
|
* @param roleId 角色ID
|
||||||
* @param userIds 需要删除的用户数据ID
|
* @param userIds 需要授权的用户数据ID
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -2,11 +2,14 @@ package com.ruoyi.system.service.impl;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import javax.validation.Validator;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
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 org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
import com.ruoyi.common.annotation.DataScope;
|
import com.ruoyi.common.annotation.DataScope;
|
||||||
import com.ruoyi.common.constant.UserConstants;
|
import com.ruoyi.common.constant.UserConstants;
|
||||||
import com.ruoyi.common.core.domain.entity.SysRole;
|
import com.ruoyi.common.core.domain.entity.SysRole;
|
||||||
@ -14,6 +17,7 @@ import com.ruoyi.common.core.domain.entity.SysUser;
|
|||||||
import com.ruoyi.common.exception.ServiceException;
|
import com.ruoyi.common.exception.ServiceException;
|
||||||
import com.ruoyi.common.utils.SecurityUtils;
|
import com.ruoyi.common.utils.SecurityUtils;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
|
import com.ruoyi.common.utils.bean.BeanValidators;
|
||||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||||
import com.ruoyi.system.domain.SysPost;
|
import com.ruoyi.system.domain.SysPost;
|
||||||
import com.ruoyi.system.domain.SysUserPost;
|
import com.ruoyi.system.domain.SysUserPost;
|
||||||
@ -54,6 +58,9 @@ public class SysUserServiceImpl implements ISysUserService
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ISysConfigService configService;
|
private ISysConfigService configService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
protected Validator validator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据条件分页查询用户列表
|
* 根据条件分页查询用户列表
|
||||||
*
|
*
|
||||||
@ -127,16 +134,11 @@ public class SysUserServiceImpl implements ISysUserService
|
|||||||
public String selectUserRoleGroup(String userName)
|
public String selectUserRoleGroup(String userName)
|
||||||
{
|
{
|
||||||
List<SysRole> list = roleMapper.selectRolesByUserName(userName);
|
List<SysRole> list = roleMapper.selectRolesByUserName(userName);
|
||||||
StringBuffer idsStr = new StringBuffer();
|
if (CollectionUtils.isEmpty(list))
|
||||||
for (SysRole role : list)
|
|
||||||
{
|
{
|
||||||
idsStr.append(role.getRoleName()).append(",");
|
return StringUtils.EMPTY;
|
||||||
}
|
}
|
||||||
if (StringUtils.isNotEmpty(idsStr.toString()))
|
return list.stream().map(SysRole::getRoleName).collect(Collectors.joining(","));
|
||||||
{
|
|
||||||
return idsStr.substring(0, idsStr.length() - 1);
|
|
||||||
}
|
|
||||||
return idsStr.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -149,16 +151,11 @@ public class SysUserServiceImpl implements ISysUserService
|
|||||||
public String selectUserPostGroup(String userName)
|
public String selectUserPostGroup(String userName)
|
||||||
{
|
{
|
||||||
List<SysPost> list = postMapper.selectPostsByUserName(userName);
|
List<SysPost> list = postMapper.selectPostsByUserName(userName);
|
||||||
StringBuffer idsStr = new StringBuffer();
|
if (CollectionUtils.isEmpty(list))
|
||||||
for (SysPost post : list)
|
|
||||||
{
|
{
|
||||||
idsStr.append(post.getPostName()).append(",");
|
return StringUtils.EMPTY;
|
||||||
}
|
}
|
||||||
if (StringUtils.isNotEmpty(idsStr.toString()))
|
return list.stream().map(SysPost::getPostName).collect(Collectors.joining(","));
|
||||||
{
|
|
||||||
return idsStr.substring(0, idsStr.length() - 1);
|
|
||||||
}
|
|
||||||
return idsStr.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -485,6 +482,7 @@ public class SysUserServiceImpl implements ISysUserService
|
|||||||
for (Long userId : userIds)
|
for (Long userId : userIds)
|
||||||
{
|
{
|
||||||
checkUserAllowed(new SysUser(userId));
|
checkUserAllowed(new SysUser(userId));
|
||||||
|
checkUserDataScope(userId);
|
||||||
}
|
}
|
||||||
// 删除用户与角色关联
|
// 删除用户与角色关联
|
||||||
userRoleMapper.deleteUserRole(userIds);
|
userRoleMapper.deleteUserRole(userIds);
|
||||||
@ -521,6 +519,7 @@ public class SysUserServiceImpl implements ISysUserService
|
|||||||
SysUser u = userMapper.selectUserByUserName(user.getUserName());
|
SysUser u = userMapper.selectUserByUserName(user.getUserName());
|
||||||
if (StringUtils.isNull(u))
|
if (StringUtils.isNull(u))
|
||||||
{
|
{
|
||||||
|
BeanValidators.validateWithException(validator, user);
|
||||||
user.setPassword(SecurityUtils.encryptPassword(password));
|
user.setPassword(SecurityUtils.encryptPassword(password));
|
||||||
user.setCreateBy(operName);
|
user.setCreateBy(operName);
|
||||||
this.insertUser(user);
|
this.insertUser(user);
|
||||||
@ -529,6 +528,7 @@ public class SysUserServiceImpl implements ISysUserService
|
|||||||
}
|
}
|
||||||
else if (isUpdateSupport)
|
else if (isUpdateSupport)
|
||||||
{
|
{
|
||||||
|
BeanValidators.validateWithException(validator, user);
|
||||||
user.setUpdateBy(operName);
|
user.setUpdateBy(operName);
|
||||||
this.updateUser(user);
|
this.updateUser(user);
|
||||||
successNum++;
|
successNum++;
|
||||||
|
|||||||
@ -47,7 +47,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
order by d.parent_id, d.order_num
|
order by d.parent_id, d.order_num
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectDeptListByRoleId" resultType="Integer">
|
<select id="selectDeptListByRoleId" resultType="Long">
|
||||||
select d.dept_id
|
select d.dept_id
|
||||||
from sys_dept d
|
from sys_dept d
|
||||||
left join sys_role_dept rd on d.dept_id = rd.dept_id
|
left join sys_role_dept rd on d.dept_id = rd.dept_id
|
||||||
|
|||||||
@ -28,7 +28,7 @@
|
|||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectMenuVo">
|
<sql id="selectMenuVo">
|
||||||
select menu_id, menu_name, parent_id, order_num, path, component, query, is_frame, is_cache, menu_type, visible, status, ifnull(perms,'') as perms, icon, create_time
|
select menu_id, menu_name, parent_id, order_num, path, component, `query`, is_frame, is_cache, menu_type, visible, status, ifnull(perms,'') as perms, icon, create_time
|
||||||
from sys_menu
|
from sys_menu
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
@ -49,13 +49,13 @@
|
|||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectMenuTreeAll" resultMap="SysMenuResult">
|
<select id="selectMenuTreeAll" resultMap="SysMenuResult">
|
||||||
select distinct m.menu_id, m.parent_id, m.menu_name, m.path, m.component, m.query, m.visible, m.status, ifnull(m.perms,'') as perms, m.is_frame, m.is_cache, m.menu_type, m.icon, m.order_num, m.create_time
|
select distinct m.menu_id, m.parent_id, m.menu_name, m.path, m.component, m.`query`, m.visible, m.status, ifnull(m.perms,'') as perms, m.is_frame, m.is_cache, m.menu_type, m.icon, m.order_num, m.create_time
|
||||||
from sys_menu m where m.menu_type in ('M', 'C') and m.status = 0
|
from sys_menu m where m.menu_type in ('M', 'C') and m.status = 0
|
||||||
order by m.parent_id, m.order_num
|
order by m.parent_id, m.order_num
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectMenuListByUserId" parameterType="SysMenu" resultMap="SysMenuResult">
|
<select id="selectMenuListByUserId" parameterType="SysMenu" resultMap="SysMenuResult">
|
||||||
select distinct m.menu_id, m.parent_id, m.menu_name, m.path, m.component, m.query, m.visible, m.status, ifnull(m.perms,'') as perms, m.is_frame, m.is_cache, m.menu_type, m.icon, m.order_num, m.create_time
|
select distinct m.menu_id, m.parent_id, m.menu_name, m.path, m.component, m.`query`, m.visible, m.status, ifnull(m.perms,'') as perms, m.is_frame, m.is_cache, m.menu_type, m.icon, m.order_num, m.create_time
|
||||||
from sys_menu m
|
from sys_menu m
|
||||||
left join sys_role_menu rm on m.menu_id = rm.menu_id
|
left join sys_role_menu rm on m.menu_id = rm.menu_id
|
||||||
left join sys_user_role ur on rm.role_id = ur.role_id
|
left join sys_user_role ur on rm.role_id = ur.role_id
|
||||||
@ -74,7 +74,7 @@
|
|||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectMenuTreeByUserId" parameterType="Long" resultMap="SysMenuResult">
|
<select id="selectMenuTreeByUserId" parameterType="Long" resultMap="SysMenuResult">
|
||||||
select distinct m.menu_id, m.parent_id, m.menu_name, m.path, m.component, m.query, m.visible, m.status, ifnull(m.perms,'') as perms, m.is_frame, m.is_cache, m.menu_type, m.icon, m.order_num, m.create_time
|
select distinct m.menu_id, m.parent_id, m.menu_name, m.path, m.component, m.`query`, m.visible, m.status, ifnull(m.perms,'') as perms, m.is_frame, m.is_cache, m.menu_type, m.icon, m.order_num, m.create_time
|
||||||
from sys_menu m
|
from sys_menu m
|
||||||
left join sys_role_menu rm on m.menu_id = rm.menu_id
|
left join sys_role_menu rm on m.menu_id = rm.menu_id
|
||||||
left join sys_user_role ur on rm.role_id = ur.role_id
|
left join sys_user_role ur on rm.role_id = ur.role_id
|
||||||
@ -84,7 +84,7 @@
|
|||||||
order by m.parent_id, m.order_num
|
order by m.parent_id, m.order_num
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectMenuListByRoleId" resultType="Integer">
|
<select id="selectMenuListByRoleId" resultType="Long">
|
||||||
select m.menu_id
|
select m.menu_id
|
||||||
from sys_menu m
|
from sys_menu m
|
||||||
left join sys_role_menu rm on m.menu_id = rm.menu_id
|
left join sys_role_menu rm on m.menu_id = rm.menu_id
|
||||||
@ -133,7 +133,7 @@
|
|||||||
<if test="orderNum != null and orderNum != ''">order_num = #{orderNum},</if>
|
<if test="orderNum != null and orderNum != ''">order_num = #{orderNum},</if>
|
||||||
<if test="path != null and path != ''">path = #{path},</if>
|
<if test="path != null and path != ''">path = #{path},</if>
|
||||||
<if test="component != null">component = #{component},</if>
|
<if test="component != null">component = #{component},</if>
|
||||||
<if test="query != null">query = #{query},</if>
|
<if test="query != null">`query` = #{query},</if>
|
||||||
<if test="isFrame != null and isFrame != ''">is_frame = #{isFrame},</if>
|
<if test="isFrame != null and isFrame != ''">is_frame = #{isFrame},</if>
|
||||||
<if test="isCache != null and isCache != ''">is_cache = #{isCache},</if>
|
<if test="isCache != null and isCache != ''">is_cache = #{isCache},</if>
|
||||||
<if test="menuType != null and menuType != ''">menu_type = #{menuType},</if>
|
<if test="menuType != null and menuType != ''">menu_type = #{menuType},</if>
|
||||||
@ -156,7 +156,7 @@
|
|||||||
<if test="orderNum != null and orderNum != ''">order_num,</if>
|
<if test="orderNum != null and orderNum != ''">order_num,</if>
|
||||||
<if test="path != null and path != ''">path,</if>
|
<if test="path != null and path != ''">path,</if>
|
||||||
<if test="component != null and component != ''">component,</if>
|
<if test="component != null and component != ''">component,</if>
|
||||||
<if test="query != null and query != ''">query,</if>
|
<if test="query != null and query != ''">`query`,</if>
|
||||||
<if test="isFrame != null and isFrame != ''">is_frame,</if>
|
<if test="isFrame != null and isFrame != ''">is_frame,</if>
|
||||||
<if test="isCache != null and isCache != ''">is_cache,</if>
|
<if test="isCache != null and isCache != ''">is_cache,</if>
|
||||||
<if test="menuType != null and menuType != ''">menu_type,</if>
|
<if test="menuType != null and menuType != ''">menu_type,</if>
|
||||||
|
|||||||
@ -46,7 +46,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
where post_id = #{postId}
|
where post_id = #{postId}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectPostListByUserId" parameterType="Long" resultType="Integer">
|
<select id="selectPostListByUserId" parameterType="Long" resultType="Long">
|
||||||
select p.post_id
|
select p.post_id
|
||||||
from sys_post p
|
from sys_post p
|
||||||
left join sys_user_post up on up.post_id = p.post_id
|
left join sys_user_post up on up.post_id = p.post_id
|
||||||
|
|||||||
@ -11,7 +11,7 @@ cd ruoyi-ui
|
|||||||
npm install
|
npm install
|
||||||
|
|
||||||
# 建议不要直接使用 cnpm 安装依赖,会有各种诡异的 bug。可以通过如下操作解决 npm 下载速度慢的问题
|
# 建议不要直接使用 cnpm 安装依赖,会有各种诡异的 bug。可以通过如下操作解决 npm 下载速度慢的问题
|
||||||
npm install --registry=https://registry.npm.taobao.org
|
npm install --registry=https://registry.npmmirror.com
|
||||||
|
|
||||||
# 启动服务
|
# 启动服务
|
||||||
npm run dev
|
npm run dev
|
||||||
|
|||||||
@ -7,6 +7,6 @@ echo.
|
|||||||
cd %~dp0
|
cd %~dp0
|
||||||
|
|
||||||
cd ..
|
cd ..
|
||||||
npm install --registry=https://registry.npm.taobao.org
|
npm install --registry=https://registry.npmmirror.com
|
||||||
|
|
||||||
pause
|
pause
|
||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ruoyi",
|
"name": "ruoyi",
|
||||||
"version": "3.8.0",
|
"version": "3.8.2",
|
||||||
"description": "若依管理系统",
|
"description": "若依管理系统",
|
||||||
"author": "若依",
|
"author": "若依",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
@ -38,7 +38,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@riophae/vue-treeselect": "0.4.0",
|
"@riophae/vue-treeselect": "0.4.0",
|
||||||
"axios": "0.24.0",
|
"axios": "0.24.0",
|
||||||
"clipboard": "2.0.6",
|
"clipboard": "2.0.8",
|
||||||
"core-js": "3.19.1",
|
"core-js": "3.19.1",
|
||||||
"echarts": "4.9.0",
|
"echarts": "4.9.0",
|
||||||
"element-ui": "2.15.6",
|
"element-ui": "2.15.6",
|
||||||
@ -65,7 +65,9 @@
|
|||||||
"@vue/cli-plugin-eslint": "4.4.6",
|
"@vue/cli-plugin-eslint": "4.4.6",
|
||||||
"@vue/cli-service": "4.4.6",
|
"@vue/cli-service": "4.4.6",
|
||||||
"babel-eslint": "10.1.0",
|
"babel-eslint": "10.1.0",
|
||||||
|
"babel-plugin-dynamic-import-node": "2.3.3",
|
||||||
"chalk": "4.1.0",
|
"chalk": "4.1.0",
|
||||||
|
"compression-webpack-plugin": "5.0.2",
|
||||||
"connect": "3.6.6",
|
"connect": "3.6.6",
|
||||||
"eslint": "7.15.0",
|
"eslint": "7.15.0",
|
||||||
"eslint-plugin-vue": "7.2.0",
|
"eslint-plugin-vue": "7.2.0",
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import request from '@/utils/request'
|
import request from '@/utils/request'
|
||||||
import { praseStrEmpty } from "@/utils/ruoyi";
|
import { parseStrEmpty } from "@/utils/ruoyi";
|
||||||
|
|
||||||
// 查询用户列表
|
// 查询用户列表
|
||||||
export function listUser(query) {
|
export function listUser(query) {
|
||||||
@ -13,7 +13,7 @@ export function listUser(query) {
|
|||||||
// 查询用户详细
|
// 查询用户详细
|
||||||
export function getUser(userId) {
|
export function getUser(userId) {
|
||||||
return request({
|
return request({
|
||||||
url: '/system/user/' + praseStrEmpty(userId),
|
url: '/system/user/' + parseStrEmpty(userId),
|
||||||
method: 'get'
|
method: 'get'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@ -37,7 +37,7 @@
|
|||||||
.mb10 {
|
.mb10 {
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
}
|
}
|
||||||
.ml0 {
|
.ml10 {
|
||||||
margin-left: 10px;
|
margin-left: 10px;
|
||||||
}
|
}
|
||||||
.mt20 {
|
.mt20 {
|
||||||
@ -49,7 +49,7 @@
|
|||||||
.mb20 {
|
.mb20 {
|
||||||
margin-bottom: 20px;
|
margin-bottom: 20px;
|
||||||
}
|
}
|
||||||
.m20 {
|
.ml20 {
|
||||||
margin-left: 20px;
|
margin-left: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -7,6 +7,10 @@
|
|||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.sidebarHide {
|
||||||
|
margin-left: 0!important;
|
||||||
|
}
|
||||||
|
|
||||||
.sidebar-container {
|
.sidebar-container {
|
||||||
-webkit-transition: width .28s;
|
-webkit-transition: width .28s;
|
||||||
transition: width 0.28s;
|
transition: width 0.28s;
|
||||||
|
|||||||
@ -1,114 +1,114 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-form size="small">
|
<el-form size="small">
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-radio v-model='radioValue' :label="1">
|
<el-radio v-model='radioValue' :label="1">
|
||||||
小时,允许的通配符[, - * /]
|
小时,允许的通配符[, - * /]
|
||||||
</el-radio>
|
</el-radio>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-radio v-model='radioValue' :label="2">
|
<el-radio v-model='radioValue' :label="2">
|
||||||
周期从
|
周期从
|
||||||
<el-input-number v-model='cycle01' :min="0" :max="22" /> -
|
<el-input-number v-model='cycle01' :min="0" :max="22" /> -
|
||||||
<el-input-number v-model='cycle02' :min="cycle01 ? cycle01 + 1 : 1" :max="23" /> 小时
|
<el-input-number v-model='cycle02' :min="cycle01 ? cycle01 + 1 : 1" :max="23" /> 小时
|
||||||
</el-radio>
|
</el-radio>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-radio v-model='radioValue' :label="3">
|
<el-radio v-model='radioValue' :label="3">
|
||||||
从
|
从
|
||||||
<el-input-number v-model='average01' :min="0" :max="22" /> 小时开始,每
|
<el-input-number v-model='average01' :min="0" :max="22" /> 小时开始,每
|
||||||
<el-input-number v-model='average02' :min="1" :max="23 - average01 || 0" /> 小时执行一次
|
<el-input-number v-model='average02' :min="1" :max="23 - average01 || 0" /> 小时执行一次
|
||||||
</el-radio>
|
</el-radio>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-radio v-model='radioValue' :label="4">
|
<el-radio v-model='radioValue' :label="4">
|
||||||
指定
|
指定
|
||||||
<el-select clearable v-model="checkboxList" placeholder="可多选" multiple style="width:100%">
|
<el-select clearable v-model="checkboxList" placeholder="可多选" multiple style="width:100%">
|
||||||
<el-option v-for="item in 60" :key="item" :value="item-1">{{item-1}}</el-option>
|
<el-option v-for="item in 24" :key="item" :value="item-1">{{item-1}}</el-option>
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-radio>
|
</el-radio>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
radioValue: 1,
|
radioValue: 1,
|
||||||
cycle01: 0,
|
cycle01: 0,
|
||||||
cycle02: 1,
|
cycle02: 1,
|
||||||
average01: 0,
|
average01: 0,
|
||||||
average02: 1,
|
average02: 1,
|
||||||
checkboxList: [],
|
checkboxList: [],
|
||||||
checkNum: this.$options.propsData.check
|
checkNum: this.$options.propsData.check
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
name: 'crontab-hour',
|
name: 'crontab-hour',
|
||||||
props: ['check', 'cron'],
|
props: ['check', 'cron'],
|
||||||
methods: {
|
methods: {
|
||||||
// 单选按钮值变化时
|
// 单选按钮值变化时
|
||||||
radioChange() {
|
radioChange() {
|
||||||
switch (this.radioValue) {
|
switch (this.radioValue) {
|
||||||
case 1:
|
case 1:
|
||||||
this.$emit('update', 'hour', '*')
|
this.$emit('update', 'hour', '*')
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
this.$emit('update', 'hour', this.cycleTotal);
|
this.$emit('update', 'hour', this.cycleTotal);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
this.$emit('update', 'hour', this.averageTotal);
|
this.$emit('update', 'hour', this.averageTotal);
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
this.$emit('update', 'hour', this.checkboxString);
|
this.$emit('update', 'hour', this.checkboxString);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// 周期两个值变化时
|
// 周期两个值变化时
|
||||||
cycleChange() {
|
cycleChange() {
|
||||||
if (this.radioValue == '2') {
|
if (this.radioValue == '2') {
|
||||||
this.$emit('update', 'hour', this.cycleTotal);
|
this.$emit('update', 'hour', this.cycleTotal);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// 平均两个值变化时
|
// 平均两个值变化时
|
||||||
averageChange() {
|
averageChange() {
|
||||||
if (this.radioValue == '3') {
|
if (this.radioValue == '3') {
|
||||||
this.$emit('update', 'hour', this.averageTotal);
|
this.$emit('update', 'hour', this.averageTotal);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// checkbox值变化时
|
// checkbox值变化时
|
||||||
checkboxChange() {
|
checkboxChange() {
|
||||||
if (this.radioValue == '4') {
|
if (this.radioValue == '4') {
|
||||||
this.$emit('update', 'hour', this.checkboxString);
|
this.$emit('update', 'hour', this.checkboxString);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
'radioValue': 'radioChange',
|
'radioValue': 'radioChange',
|
||||||
'cycleTotal': 'cycleChange',
|
'cycleTotal': 'cycleChange',
|
||||||
'averageTotal': 'averageChange',
|
'averageTotal': 'averageChange',
|
||||||
'checkboxString': 'checkboxChange'
|
'checkboxString': 'checkboxChange'
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
// 计算两个周期值
|
// 计算两个周期值
|
||||||
cycleTotal: function () {
|
cycleTotal: function () {
|
||||||
const cycle01 = this.checkNum(this.cycle01, 0, 22)
|
const cycle01 = this.checkNum(this.cycle01, 0, 22)
|
||||||
const cycle02 = this.checkNum(this.cycle02, cycle01 ? cycle01 + 1 : 1, 23)
|
const cycle02 = this.checkNum(this.cycle02, cycle01 ? cycle01 + 1 : 1, 23)
|
||||||
return cycle01 + '-' + cycle02;
|
return cycle01 + '-' + cycle02;
|
||||||
},
|
},
|
||||||
// 计算平均用到的值
|
// 计算平均用到的值
|
||||||
averageTotal: function () {
|
averageTotal: function () {
|
||||||
const average01 = this.checkNum(this.average01, 0, 22)
|
const average01 = this.checkNum(this.average01, 0, 22)
|
||||||
const average02 = this.checkNum(this.average02, 1, 23 - average01 || 0)
|
const average02 = this.checkNum(this.average02, 1, 23 - average01 || 0)
|
||||||
return average01 + '/' + average02;
|
return average01 + '/' + average02;
|
||||||
},
|
},
|
||||||
// 计算勾选的checkbox值合集
|
// 计算勾选的checkbox值合集
|
||||||
checkboxString: function () {
|
checkboxString: function () {
|
||||||
let str = this.checkboxList.join();
|
let str = this.checkboxList.join();
|
||||||
return str == '' ? '*' : str;
|
return str == '' ? '*' : str;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@ -273,7 +273,7 @@ export default {
|
|||||||
insValue = 5;
|
insValue = 5;
|
||||||
} else {
|
} else {
|
||||||
this.$refs[refName].checkboxList = value.split(",");
|
this.$refs[refName].checkboxList = value.split(",");
|
||||||
insValue = 7;
|
insValue = 6;
|
||||||
}
|
}
|
||||||
} else if (name == "year") {
|
} else if (name == "year") {
|
||||||
if (value == "") {
|
if (value == "") {
|
||||||
|
|||||||
@ -60,7 +60,7 @@
|
|||||||
<el-radio v-model='radioValue' :label="6">
|
<el-radio v-model='radioValue' :label="6">
|
||||||
指定
|
指定
|
||||||
<el-select clearable v-model="checkboxList" placeholder="可多选" multiple style="width:100%">
|
<el-select clearable v-model="checkboxList" placeholder="可多选" multiple style="width:100%">
|
||||||
<el-option v-for="(item,index) of weekList" :key="index" :label="item.value" :value="item.key">{{item.value}}</el-option>
|
<el-option v-for="(item,index) of weekList" :key="index" :label="item.value" :value="String(item.key)">{{item.value}}</el-option>
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-radio>
|
</el-radio>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|||||||
@ -1,198 +1,209 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="upload-file">
|
<div class="upload-file">
|
||||||
<el-upload
|
<el-upload
|
||||||
:action="uploadFileUrl"
|
multiple
|
||||||
:before-upload="handleBeforeUpload"
|
:action="uploadFileUrl"
|
||||||
:file-list="fileList"
|
:before-upload="handleBeforeUpload"
|
||||||
:limit="limit"
|
:file-list="fileList"
|
||||||
:on-error="handleUploadError"
|
:limit="limit"
|
||||||
:on-exceed="handleExceed"
|
:on-error="handleUploadError"
|
||||||
:on-success="handleUploadSuccess"
|
:on-exceed="handleExceed"
|
||||||
:show-file-list="false"
|
:on-success="handleUploadSuccess"
|
||||||
:headers="headers"
|
:show-file-list="false"
|
||||||
class="upload-file-uploader"
|
:headers="headers"
|
||||||
ref="upload"
|
class="upload-file-uploader"
|
||||||
>
|
ref="upload"
|
||||||
<!-- 上传按钮 -->
|
>
|
||||||
<el-button size="mini" type="primary">选取文件</el-button>
|
<!-- 上传按钮 -->
|
||||||
<!-- 上传提示 -->
|
<el-button size="mini" type="primary">选取文件</el-button>
|
||||||
<div class="el-upload__tip" slot="tip" v-if="showTip">
|
<!-- 上传提示 -->
|
||||||
请上传
|
<div class="el-upload__tip" slot="tip" v-if="showTip">
|
||||||
<template v-if="fileSize"> 大小不超过 <b style="color: #f56c6c">{{ fileSize }}MB</b> </template>
|
请上传
|
||||||
<template v-if="fileType"> 格式为 <b style="color: #f56c6c">{{ fileType.join("/") }}</b> </template>
|
<template v-if="fileSize"> 大小不超过 <b style="color: #f56c6c">{{ fileSize }}MB</b> </template>
|
||||||
的文件
|
<template v-if="fileType"> 格式为 <b style="color: #f56c6c">{{ fileType.join("/") }}</b> </template>
|
||||||
</div>
|
的文件
|
||||||
</el-upload>
|
</div>
|
||||||
|
</el-upload>
|
||||||
<!-- 文件列表 -->
|
|
||||||
<transition-group class="upload-file-list el-upload-list el-upload-list--text" name="el-fade-in-linear" tag="ul">
|
<!-- 文件列表 -->
|
||||||
<li :key="file.uid" class="el-upload-list__item ele-upload-list__item-content" v-for="(file, index) in fileList">
|
<transition-group class="upload-file-list el-upload-list el-upload-list--text" name="el-fade-in-linear" tag="ul">
|
||||||
<el-link :href="`${baseUrl}${file.url}`" :underline="false" target="_blank">
|
<li :key="file.url" class="el-upload-list__item ele-upload-list__item-content" v-for="(file, index) in fileList">
|
||||||
<span class="el-icon-document"> {{ getFileName(file.name) }} </span>
|
<el-link :href="`${baseUrl}${file.url}`" :underline="false" target="_blank">
|
||||||
</el-link>
|
<span class="el-icon-document"> {{ getFileName(file.name) }} </span>
|
||||||
<div class="ele-upload-list__item-content-action">
|
</el-link>
|
||||||
<el-link :underline="false" @click="handleDelete(index)" type="danger">删除</el-link>
|
<div class="ele-upload-list__item-content-action">
|
||||||
</div>
|
<el-link :underline="false" @click="handleDelete(index)" type="danger">删除</el-link>
|
||||||
</li>
|
</div>
|
||||||
</transition-group>
|
</li>
|
||||||
</div>
|
</transition-group>
|
||||||
</template>
|
</div>
|
||||||
|
</template>
|
||||||
<script>
|
|
||||||
import { getToken } from "@/utils/auth";
|
<script>
|
||||||
|
import { getToken } from "@/utils/auth";
|
||||||
export default {
|
|
||||||
name: "FileUpload",
|
export default {
|
||||||
props: {
|
name: "FileUpload",
|
||||||
// 值
|
props: {
|
||||||
value: [String, Object, Array],
|
// 值
|
||||||
// 数量限制
|
value: [String, Object, Array],
|
||||||
limit: {
|
// 数量限制
|
||||||
type: Number,
|
limit: {
|
||||||
default: 5,
|
type: Number,
|
||||||
},
|
default: 5,
|
||||||
// 大小限制(MB)
|
},
|
||||||
fileSize: {
|
// 大小限制(MB)
|
||||||
type: Number,
|
fileSize: {
|
||||||
default: 5,
|
type: Number,
|
||||||
},
|
default: 5,
|
||||||
// 文件类型, 例如['png', 'jpg', 'jpeg']
|
},
|
||||||
fileType: {
|
// 文件类型, 例如['png', 'jpg', 'jpeg']
|
||||||
type: Array,
|
fileType: {
|
||||||
default: () => ["doc", "xls", "ppt", "txt", "pdf"],
|
type: Array,
|
||||||
},
|
default: () => ["doc", "xls", "ppt", "txt", "pdf"],
|
||||||
// 是否显示提示
|
},
|
||||||
isShowTip: {
|
// 是否显示提示
|
||||||
type: Boolean,
|
isShowTip: {
|
||||||
default: true
|
type: Boolean,
|
||||||
}
|
default: true
|
||||||
},
|
}
|
||||||
data() {
|
},
|
||||||
return {
|
data() {
|
||||||
baseUrl: process.env.VUE_APP_BASE_API,
|
return {
|
||||||
uploadFileUrl: process.env.VUE_APP_BASE_API + "/common/upload", // 上传的图片服务器地址
|
number: 0,
|
||||||
headers: {
|
uploadList: [],
|
||||||
Authorization: "Bearer " + getToken(),
|
baseUrl: process.env.VUE_APP_BASE_API,
|
||||||
},
|
uploadFileUrl: process.env.VUE_APP_BASE_API + "/common/upload", // 上传的图片服务器地址
|
||||||
fileList: [],
|
headers: {
|
||||||
};
|
Authorization: "Bearer " + getToken(),
|
||||||
},
|
},
|
||||||
watch: {
|
fileList: [],
|
||||||
value: {
|
};
|
||||||
handler(val) {
|
},
|
||||||
if (val) {
|
watch: {
|
||||||
let temp = 1;
|
value: {
|
||||||
// 首先将值转为数组
|
handler(val) {
|
||||||
const list = Array.isArray(val) ? val : this.value.split(',');
|
if (val) {
|
||||||
// 然后将数组转为对象数组
|
let temp = 1;
|
||||||
this.fileList = list.map(item => {
|
// 首先将值转为数组
|
||||||
if (typeof item === "string") {
|
const list = Array.isArray(val) ? val : this.value.split(',');
|
||||||
item = { name: item, url: item };
|
// 然后将数组转为对象数组
|
||||||
}
|
this.fileList = list.map(item => {
|
||||||
item.uid = item.uid || new Date().getTime() + temp++;
|
if (typeof item === "string") {
|
||||||
return item;
|
item = { name: item, url: item };
|
||||||
});
|
}
|
||||||
} else {
|
item.uid = item.uid || new Date().getTime() + temp++;
|
||||||
this.fileList = [];
|
return item;
|
||||||
return [];
|
});
|
||||||
}
|
} else {
|
||||||
},
|
this.fileList = [];
|
||||||
deep: true,
|
return [];
|
||||||
immediate: true
|
}
|
||||||
}
|
},
|
||||||
},
|
deep: true,
|
||||||
computed: {
|
immediate: true
|
||||||
// 是否显示提示
|
}
|
||||||
showTip() {
|
},
|
||||||
return this.isShowTip && (this.fileType || this.fileSize);
|
computed: {
|
||||||
},
|
// 是否显示提示
|
||||||
},
|
showTip() {
|
||||||
methods: {
|
return this.isShowTip && (this.fileType || this.fileSize);
|
||||||
// 上传前校检格式和大小
|
},
|
||||||
handleBeforeUpload(file) {
|
},
|
||||||
// 校检文件类型
|
methods: {
|
||||||
if (this.fileType) {
|
// 上传前校检格式和大小
|
||||||
let fileExtension = "";
|
handleBeforeUpload(file) {
|
||||||
if (file.name.lastIndexOf(".") > -1) {
|
// 校检文件类型
|
||||||
fileExtension = file.name.slice(file.name.lastIndexOf(".") + 1);
|
if (this.fileType) {
|
||||||
}
|
let fileExtension = "";
|
||||||
const isTypeOk = this.fileType.some((type) => {
|
if (file.name.lastIndexOf(".") > -1) {
|
||||||
if (file.type.indexOf(type) > -1) return true;
|
fileExtension = file.name.slice(file.name.lastIndexOf(".") + 1);
|
||||||
if (fileExtension && fileExtension.indexOf(type) > -1) return true;
|
}
|
||||||
return false;
|
const isTypeOk = this.fileType.some((type) => {
|
||||||
});
|
if (file.type.indexOf(type) > -1) return true;
|
||||||
if (!isTypeOk) {
|
if (fileExtension && fileExtension.indexOf(type) > -1) return true;
|
||||||
this.$message.error(`文件格式不正确, 请上传${this.fileType.join("/")}格式文件!`);
|
return false;
|
||||||
return false;
|
});
|
||||||
}
|
if (!isTypeOk) {
|
||||||
}
|
this.$modal.msgError(`文件格式不正确, 请上传${this.fileType.join("/")}格式文件!`);
|
||||||
// 校检文件大小
|
return false;
|
||||||
if (this.fileSize) {
|
}
|
||||||
const isLt = file.size / 1024 / 1024 < this.fileSize;
|
}
|
||||||
if (!isLt) {
|
// 校检文件大小
|
||||||
this.$message.error(`上传文件大小不能超过 ${this.fileSize} MB!`);
|
if (this.fileSize) {
|
||||||
return false;
|
const isLt = file.size / 1024 / 1024 < this.fileSize;
|
||||||
}
|
if (!isLt) {
|
||||||
}
|
this.$modal.msgError(`上传文件大小不能超过 ${this.fileSize} MB!`);
|
||||||
return true;
|
return false;
|
||||||
},
|
}
|
||||||
// 文件个数超出
|
}
|
||||||
handleExceed() {
|
this.$modal.loading("正在上传文件,请稍候...");
|
||||||
this.$message.error(`上传文件数量不能超过 ${this.limit} 个!`);
|
this.number++;
|
||||||
},
|
return true;
|
||||||
// 上传失败
|
},
|
||||||
handleUploadError(err) {
|
// 文件个数超出
|
||||||
this.$message.error("上传失败, 请重试");
|
handleExceed() {
|
||||||
},
|
this.$modal.msgError(`上传文件数量不能超过 ${this.limit} 个!`);
|
||||||
// 上传成功回调
|
},
|
||||||
handleUploadSuccess(res, file) {
|
// 上传失败
|
||||||
this.$message.success("上传成功");
|
handleUploadError(err) {
|
||||||
this.fileList.push({ name: res.fileName, url: res.fileName });
|
this.$modal.msgError("上传图片失败,请重试");
|
||||||
this.$emit("input", this.listToString(this.fileList));
|
this.$modal.closeLoading()
|
||||||
},
|
},
|
||||||
// 删除文件
|
// 上传成功回调
|
||||||
handleDelete(index) {
|
handleUploadSuccess(res) {
|
||||||
this.fileList.splice(index, 1);
|
this.uploadList.push({ name: res.fileName, url: res.fileName });
|
||||||
this.$emit("input", this.listToString(this.fileList));
|
if (this.uploadList.length === this.number) {
|
||||||
},
|
this.fileList = this.fileList.concat(this.uploadList);
|
||||||
// 获取文件名称
|
this.uploadList = [];
|
||||||
getFileName(name) {
|
this.number = 0;
|
||||||
if (name.lastIndexOf("/") > -1) {
|
this.$emit("input", this.listToString(this.fileList));
|
||||||
return name.slice(name.lastIndexOf("/") + 1).toLowerCase();
|
this.$modal.closeLoading();
|
||||||
} else {
|
}
|
||||||
return "";
|
},
|
||||||
}
|
// 删除文件
|
||||||
},
|
handleDelete(index) {
|
||||||
// 对象转成指定字符串分隔
|
this.fileList.splice(index, 1);
|
||||||
listToString(list, separator) {
|
this.$emit("input", this.listToString(this.fileList));
|
||||||
let strs = "";
|
},
|
||||||
separator = separator || ",";
|
// 获取文件名称
|
||||||
for (let i in list) {
|
getFileName(name) {
|
||||||
strs += list[i].url + separator;
|
if (name.lastIndexOf("/") > -1) {
|
||||||
}
|
return name.slice(name.lastIndexOf("/") + 1);
|
||||||
return strs != '' ? strs.substr(0, strs.length - 1) : '';
|
} else {
|
||||||
}
|
return "";
|
||||||
}
|
}
|
||||||
};
|
},
|
||||||
</script>
|
// 对象转成指定字符串分隔
|
||||||
|
listToString(list, separator) {
|
||||||
<style scoped lang="scss">
|
let strs = "";
|
||||||
.upload-file-uploader {
|
separator = separator || ",";
|
||||||
margin-bottom: 5px;
|
for (let i in list) {
|
||||||
}
|
strs += list[i].url + separator;
|
||||||
.upload-file-list .el-upload-list__item {
|
}
|
||||||
border: 1px solid #e4e7ed;
|
return strs != '' ? strs.substr(0, strs.length - 1) : '';
|
||||||
line-height: 2;
|
}
|
||||||
margin-bottom: 10px;
|
}
|
||||||
position: relative;
|
};
|
||||||
}
|
</script>
|
||||||
.upload-file-list .ele-upload-list__item-content {
|
|
||||||
display: flex;
|
<style scoped lang="scss">
|
||||||
justify-content: space-between;
|
.upload-file-uploader {
|
||||||
align-items: center;
|
margin-bottom: 5px;
|
||||||
color: inherit;
|
}
|
||||||
}
|
.upload-file-list .el-upload-list__item {
|
||||||
.ele-upload-list__item-content-action .el-link {
|
border: 1px solid #e4e7ed;
|
||||||
margin-right: 10px;
|
line-height: 2;
|
||||||
}
|
margin-bottom: 10px;
|
||||||
</style>
|
position: relative;
|
||||||
|
}
|
||||||
|
.upload-file-list .ele-upload-list__item-content {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
color: inherit;
|
||||||
|
}
|
||||||
|
.ele-upload-list__item-content-action .el-link {
|
||||||
|
margin-right: 10px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
84
ruoyi-ui/src/components/ImagePreview/index.vue
Normal file
84
ruoyi-ui/src/components/ImagePreview/index.vue
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
<template>
|
||||||
|
<el-image
|
||||||
|
:src="`${realSrc}`"
|
||||||
|
fit="cover"
|
||||||
|
:style="`width:${realWidth};height:${realHeight};`"
|
||||||
|
:preview-src-list="realSrcList"
|
||||||
|
>
|
||||||
|
<div slot="error" class="image-slot">
|
||||||
|
<i class="el-icon-picture-outline"></i>
|
||||||
|
</div>
|
||||||
|
</el-image>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { isExternal } from "@/utils/validate";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: "ImagePreview",
|
||||||
|
props: {
|
||||||
|
src: {
|
||||||
|
type: String,
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
width: {
|
||||||
|
type: [Number, String],
|
||||||
|
default: ""
|
||||||
|
},
|
||||||
|
height: {
|
||||||
|
type: [Number, String],
|
||||||
|
default: ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
realSrc() {
|
||||||
|
let real_src = this.src.split(",")[0];
|
||||||
|
if (isExternal(real_src)) {
|
||||||
|
return real_src;
|
||||||
|
}
|
||||||
|
return process.env.VUE_APP_BASE_API + real_src;
|
||||||
|
},
|
||||||
|
realSrcList() {
|
||||||
|
let real_src_list = this.src.split(",");
|
||||||
|
let srcList = [];
|
||||||
|
real_src_list.forEach(item => {
|
||||||
|
if (isExternal(item)) {
|
||||||
|
return srcList.push(item);
|
||||||
|
}
|
||||||
|
return srcList.push(process.env.VUE_APP_BASE_API + item);
|
||||||
|
});
|
||||||
|
return srcList;
|
||||||
|
},
|
||||||
|
realWidth() {
|
||||||
|
return typeof this.width == "string" ? this.width : `${this.width}px`;
|
||||||
|
},
|
||||||
|
realHeight() {
|
||||||
|
return typeof this.height == "string" ? this.height : `${this.height}px`;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.el-image {
|
||||||
|
border-radius: 5px;
|
||||||
|
background-color: #ebeef5;
|
||||||
|
box-shadow: 0 0 5px 1px #ccc;
|
||||||
|
::v-deep .el-image__inner {
|
||||||
|
transition: all 0.3s;
|
||||||
|
cursor: pointer;
|
||||||
|
&:hover {
|
||||||
|
transform: scale(1.2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
::v-deep .image-slot {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
color: #909399;
|
||||||
|
font-size: 30px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@ -1,6 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="component-upload-image">
|
<div class="component-upload-image">
|
||||||
<el-upload
|
<el-upload
|
||||||
|
multiple
|
||||||
:action="uploadImgUrl"
|
:action="uploadImgUrl"
|
||||||
list-type="picture-card"
|
list-type="picture-card"
|
||||||
:on-success="handleUploadSuccess"
|
:on-success="handleUploadSuccess"
|
||||||
@ -70,6 +71,8 @@ export default {
|
|||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
number: 0,
|
||||||
|
uploadList: [],
|
||||||
dialogImageUrl: "",
|
dialogImageUrl: "",
|
||||||
dialogVisible: false,
|
dialogVisible: false,
|
||||||
hideUpload: false,
|
hideUpload: false,
|
||||||
@ -124,9 +127,14 @@ export default {
|
|||||||
},
|
},
|
||||||
// 上传成功回调
|
// 上传成功回调
|
||||||
handleUploadSuccess(res) {
|
handleUploadSuccess(res) {
|
||||||
this.fileList.push({ name: res.fileName, url: res.fileName });
|
this.uploadList.push({ name: res.fileName, url: res.fileName });
|
||||||
this.$emit("input", this.listToString(this.fileList));
|
if (this.uploadList.length === this.number) {
|
||||||
this.loading.close();
|
this.fileList = this.fileList.concat(this.uploadList);
|
||||||
|
this.uploadList = [];
|
||||||
|
this.number = 0;
|
||||||
|
this.$emit("input", this.listToString(this.fileList));
|
||||||
|
this.$modal.closeLoading();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
// 上传前loading加载
|
// 上传前loading加载
|
||||||
handleBeforeUpload(file) {
|
handleBeforeUpload(file) {
|
||||||
@ -146,35 +154,27 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!isImg) {
|
if (!isImg) {
|
||||||
this.$message.error(
|
this.$modal.msgError(`文件格式不正确, 请上传${this.fileType.join("/")}图片格式文件!`);
|
||||||
`文件格式不正确, 请上传${this.fileType.join("/")}图片格式文件!`
|
|
||||||
);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (this.fileSize) {
|
if (this.fileSize) {
|
||||||
const isLt = file.size / 1024 / 1024 < this.fileSize;
|
const isLt = file.size / 1024 / 1024 < this.fileSize;
|
||||||
if (!isLt) {
|
if (!isLt) {
|
||||||
this.$message.error(`上传头像图片大小不能超过 ${this.fileSize} MB!`);
|
this.$modal.msgError(`上传头像图片大小不能超过 ${this.fileSize} MB!`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.loading = this.$loading({
|
this.$modal.loading("正在上传图片,请稍候...");
|
||||||
lock: true,
|
this.number++;
|
||||||
text: "上传中",
|
|
||||||
background: "rgba(0, 0, 0, 0.7)",
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
// 文件个数超出
|
// 文件个数超出
|
||||||
handleExceed() {
|
handleExceed() {
|
||||||
this.$message.error(`上传文件数量不能超过 ${this.limit} 个!`);
|
this.$modal.msgError(`上传文件数量不能超过 ${this.limit} 个!`);
|
||||||
},
|
},
|
||||||
// 上传失败
|
// 上传失败
|
||||||
handleUploadError() {
|
handleUploadError() {
|
||||||
this.$message({
|
this.$modal.msgError("上传图片失败,请重试");
|
||||||
type: "error",
|
this.$modal.closeLoading();
|
||||||
message: "上传失败",
|
|
||||||
});
|
|
||||||
this.loading.close();
|
|
||||||
},
|
},
|
||||||
// 预览
|
// 预览
|
||||||
handlePictureCardPreview(file) {
|
handlePictureCardPreview(file) {
|
||||||
|
|||||||
@ -61,6 +61,10 @@ export default {
|
|||||||
default: false
|
default: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
};
|
||||||
|
},
|
||||||
computed: {
|
computed: {
|
||||||
currentPage: {
|
currentPage: {
|
||||||
get() {
|
get() {
|
||||||
@ -81,6 +85,9 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
handleSizeChange(val) {
|
handleSizeChange(val) {
|
||||||
|
if (this.currentPage * val > this.total) {
|
||||||
|
this.currentPage = 1
|
||||||
|
}
|
||||||
this.$emit('pagination', { page: this.currentPage, limit: val })
|
this.$emit('pagination', { page: this.currentPage, limit: val })
|
||||||
if (this.autoScroll) {
|
if (this.autoScroll) {
|
||||||
scrollTo(0, 800)
|
scrollTo(0, 800)
|
||||||
|
|||||||
@ -30,13 +30,14 @@
|
|||||||
<script>
|
<script>
|
||||||
import { constantRoutes } from "@/router";
|
import { constantRoutes } from "@/router";
|
||||||
|
|
||||||
|
// 隐藏侧边栏路由
|
||||||
|
const hideList = ['/index', '/user/profile'];
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
// 顶部栏初始数
|
// 顶部栏初始数
|
||||||
visibleNumber: 5,
|
visibleNumber: 5,
|
||||||
// 是否为首次加载
|
|
||||||
isFrist: false,
|
|
||||||
// 当前激活菜单的 index
|
// 当前激活菜单的 index
|
||||||
currentIndex: undefined
|
currentIndex: undefined
|
||||||
};
|
};
|
||||||
@ -71,7 +72,7 @@ export default {
|
|||||||
for (var item in router.children) {
|
for (var item in router.children) {
|
||||||
if (router.children[item].parentPath === undefined) {
|
if (router.children[item].parentPath === undefined) {
|
||||||
if(router.path === "/") {
|
if(router.path === "/") {
|
||||||
router.children[item].path = "/redirect/" + router.children[item].path;
|
router.children[item].path = "/" + router.children[item].path;
|
||||||
} else {
|
} else {
|
||||||
if(!this.ishttp(router.children[item].path)) {
|
if(!this.ishttp(router.children[item].path)) {
|
||||||
router.children[item].path = router.path + "/" + router.children[item].path;
|
router.children[item].path = router.path + "/" + router.children[item].path;
|
||||||
@ -87,22 +88,16 @@ export default {
|
|||||||
// 默认激活的菜单
|
// 默认激活的菜单
|
||||||
activeMenu() {
|
activeMenu() {
|
||||||
const path = this.$route.path;
|
const path = this.$route.path;
|
||||||
let activePath = this.defaultRouter();
|
let activePath = path;
|
||||||
if (path.lastIndexOf("/") > 0) {
|
if (path !== undefined && path.lastIndexOf("/") > 0 && hideList.indexOf(path) === -1) {
|
||||||
const tmpPath = path.substring(1, path.length);
|
const tmpPath = path.substring(1, path.length);
|
||||||
activePath = "/" + tmpPath.substring(0, tmpPath.indexOf("/"));
|
activePath = "/" + tmpPath.substring(0, tmpPath.indexOf("/"));
|
||||||
} else if ("/index" == path || "" == path) {
|
this.$store.dispatch('app/toggleSideBarHide', false);
|
||||||
if (!this.isFrist) {
|
} else if(!this.$route.children) {
|
||||||
this.isFrist = true;
|
activePath = path;
|
||||||
} else {
|
this.$store.dispatch('app/toggleSideBarHide', true);
|
||||||
activePath = "index";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var routes = this.activeRoutes(activePath);
|
|
||||||
if (routes.length === 0) {
|
|
||||||
activePath = this.currentIndex || this.defaultRouter()
|
|
||||||
this.activeRoutes(activePath);
|
|
||||||
}
|
}
|
||||||
|
this.activeRoutes(activePath);
|
||||||
return activePath;
|
return activePath;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -121,29 +116,21 @@ export default {
|
|||||||
const width = document.body.getBoundingClientRect().width / 3;
|
const width = document.body.getBoundingClientRect().width / 3;
|
||||||
this.visibleNumber = parseInt(width / 85);
|
this.visibleNumber = parseInt(width / 85);
|
||||||
},
|
},
|
||||||
// 默认激活的路由
|
|
||||||
defaultRouter() {
|
|
||||||
let router;
|
|
||||||
Object.keys(this.routers).some((key) => {
|
|
||||||
if (!this.routers[key].hidden) {
|
|
||||||
router = this.routers[key].path;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return router;
|
|
||||||
},
|
|
||||||
// 菜单选择事件
|
// 菜单选择事件
|
||||||
handleSelect(key, keyPath) {
|
handleSelect(key, keyPath) {
|
||||||
this.currentIndex = key;
|
this.currentIndex = key;
|
||||||
|
const route = this.routers.find(item => item.path === key);
|
||||||
if (this.ishttp(key)) {
|
if (this.ishttp(key)) {
|
||||||
// http(s):// 路径新窗口打开
|
// http(s):// 路径新窗口打开
|
||||||
window.open(key, "_blank");
|
window.open(key, "_blank");
|
||||||
} else if (key.indexOf("/redirect") !== -1) {
|
} else if (!route || !route.children) {
|
||||||
// /redirect 路径内部打开
|
// 没有子路由路径内部打开
|
||||||
this.$router.push({ path: key.replace("/redirect", "") });
|
this.$router.push({ path: key });
|
||||||
|
this.$store.dispatch('app/toggleSideBarHide', true);
|
||||||
} else {
|
} else {
|
||||||
// 显示左侧联动菜单
|
// 显示左侧联动菜单
|
||||||
this.activeRoutes(key);
|
this.activeRoutes(key);
|
||||||
|
this.$store.dispatch('app/toggleSideBarHide', false);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// 当前激活的路由
|
// 当前激活的路由
|
||||||
@ -159,9 +146,8 @@ export default {
|
|||||||
if(routes.length > 0) {
|
if(routes.length > 0) {
|
||||||
this.$store.commit("SET_SIDEBAR_ROUTERS", routes);
|
this.$store.commit("SET_SIDEBAR_ROUTERS", routes);
|
||||||
}
|
}
|
||||||
return routes;
|
|
||||||
},
|
},
|
||||||
ishttp(url) {
|
ishttp(url) {
|
||||||
return url.indexOf('http://') !== -1 || url.indexOf('https://') !== -1
|
return url.indexOf('http://') !== -1 || url.indexOf('https://') !== -1
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user