增加模块
This commit is contained in:
parent
ea6cbfb0ba
commit
42582707ce
2
pom.xml
2
pom.xml
|
|
@ -215,6 +215,8 @@
|
||||||
<module>ruoyi-common</module>
|
<module>ruoyi-common</module>
|
||||||
<module>ruoyi-imark</module>
|
<module>ruoyi-imark</module>
|
||||||
<module>ruoyi-cloud</module>
|
<module>ruoyi-cloud</module>
|
||||||
|
<module>ruoyi-alg</module>
|
||||||
|
<module>ruoyi-tts</module>
|
||||||
</modules>
|
</modules>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,30 +1,30 @@
|
||||||
package com.ruoyi;
|
package com.ruoyi;
|
||||||
|
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 启动程序
|
* 启动程序
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
|
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
|
||||||
public class RuoYiApplication
|
public class RuoYiApplication
|
||||||
{
|
{
|
||||||
public static void main(String[] args)
|
public static void main(String[] args)
|
||||||
{
|
{
|
||||||
// System.setProperty("spring.devtools.restart.enabled", "false");
|
// System.setProperty("spring.devtools.restart.enabled", "false");
|
||||||
SpringApplication.run(RuoYiApplication.class, args);
|
SpringApplication.run(RuoYiApplication.class, args);
|
||||||
System.out.println("(♥◠‿◠)ノ゙ 若依启动成功 ლ(´ڡ`ლ)゙ \n" +
|
System.out.println("(♥◠‿◠)ノ゙ 若依启动成功 ლ(´ڡ`ლ)゙ \n" +
|
||||||
" .-------. ____ __ \n" +
|
" .-------. ____ __ \n" +
|
||||||
" | _ _ \\ \\ \\ / / \n" +
|
" | _ _ \\ \\ \\ / / \n" +
|
||||||
" | ( ' ) | \\ _. / ' \n" +
|
" | ( ' ) | \\ _. / ' \n" +
|
||||||
" |(_ o _) / _( )_ .' \n" +
|
" |(_ o _) / _( )_ .' \n" +
|
||||||
" | (_,_).' __ ___(_ o _)' \n" +
|
" | (_,_).' __ ___(_ o _)' \n" +
|
||||||
" | |\\ \\ | || |(_,_)' \n" +
|
" | |\\ \\ | || |(_,_)' \n" +
|
||||||
" | | \\ `' /| `-' / \n" +
|
" | | \\ `' /| `-' / \n" +
|
||||||
" | | \\ / \\ / \n" +
|
" | | \\ / \\ / \n" +
|
||||||
" ''-' `'-' `-..-' ");
|
" ''-' `'-' `-..-' ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,18 +1,18 @@
|
||||||
package com.ruoyi;
|
package com.ruoyi;
|
||||||
|
|
||||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||||
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
|
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* web容器中进行部署
|
* web容器中进行部署
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class RuoYiServletInitializer extends SpringBootServletInitializer
|
public class RuoYiServletInitializer extends SpringBootServletInitializer
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
protected SpringApplicationBuilder configure(SpringApplicationBuilder application)
|
protected SpringApplicationBuilder configure(SpringApplicationBuilder application)
|
||||||
{
|
{
|
||||||
return application.sources(RuoYiApplication.class);
|
return application.sources(RuoYiApplication.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,112 +1,112 @@
|
||||||
package com.ruoyi.web.controller.common;
|
package com.ruoyi.web.controller.common;
|
||||||
|
|
||||||
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;
|
||||||
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.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
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.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import com.ruoyi.common.config.Global;
|
import com.ruoyi.common.config.Global;
|
||||||
import com.ruoyi.common.config.ServerConfig;
|
import com.ruoyi.common.config.ServerConfig;
|
||||||
import com.ruoyi.common.constant.Constants;
|
import com.ruoyi.common.constant.Constants;
|
||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
import com.ruoyi.common.utils.file.FileUploadUtils;
|
import com.ruoyi.common.utils.file.FileUploadUtils;
|
||||||
import com.ruoyi.common.utils.file.FileUtils;
|
import com.ruoyi.common.utils.file.FileUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通用请求处理
|
* 通用请求处理
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@Controller
|
@Controller
|
||||||
public class CommonController
|
public class CommonController
|
||||||
{
|
{
|
||||||
private static final Logger log = LoggerFactory.getLogger(CommonController.class);
|
private static final Logger log = LoggerFactory.getLogger(CommonController.class);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ServerConfig serverConfig;
|
private ServerConfig serverConfig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通用下载请求
|
* 通用下载请求
|
||||||
*
|
*
|
||||||
* @param fileName 文件名称
|
* @param fileName 文件名称
|
||||||
* @param delete 是否删除
|
* @param delete 是否删除
|
||||||
*/
|
*/
|
||||||
@GetMapping("common/download")
|
@GetMapping("common/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
|
||||||
{
|
{
|
||||||
if (!FileUtils.isValidFilename(fileName))
|
if (!FileUtils.isValidFilename(fileName))
|
||||||
{
|
{
|
||||||
throw new Exception(StringUtils.format("文件名称({})非法,不允许下载。 ", fileName));
|
throw new Exception(StringUtils.format("文件名称({})非法,不允许下载。 ", fileName));
|
||||||
}
|
}
|
||||||
String realFileName = System.currentTimeMillis() + fileName.substring(fileName.indexOf("_") + 1);
|
String realFileName = System.currentTimeMillis() + fileName.substring(fileName.indexOf("_") + 1);
|
||||||
String filePath = Global.getDownloadPath() + fileName;
|
String filePath = Global.getDownloadPath() + fileName;
|
||||||
|
|
||||||
response.setCharacterEncoding("utf-8");
|
response.setCharacterEncoding("utf-8");
|
||||||
response.setContentType("multipart/form-data");
|
response.setContentType("multipart/form-data");
|
||||||
response.setHeader("Content-Disposition",
|
response.setHeader("Content-Disposition",
|
||||||
"attachment;fileName=" + FileUtils.setFileDownloadHeader(request, realFileName));
|
"attachment;fileName=" + FileUtils.setFileDownloadHeader(request, realFileName));
|
||||||
FileUtils.writeBytes(filePath, response.getOutputStream());
|
FileUtils.writeBytes(filePath, response.getOutputStream());
|
||||||
if (delete)
|
if (delete)
|
||||||
{
|
{
|
||||||
FileUtils.deleteFile(filePath);
|
FileUtils.deleteFile(filePath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
log.error("下载文件失败", e);
|
log.error("下载文件失败", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通用上传请求
|
* 通用上传请求
|
||||||
*/
|
*/
|
||||||
@PostMapping("/common/upload")
|
@PostMapping("/common/upload")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult uploadFile(MultipartFile file) throws Exception
|
public AjaxResult uploadFile(MultipartFile file) throws Exception
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// 上传文件路径
|
// 上传文件路径
|
||||||
String filePath = Global.getUploadPath();
|
String filePath = Global.getUploadPath();
|
||||||
// 上传并返回新文件名称
|
// 上传并返回新文件名称
|
||||||
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("fileName", fileName);
|
||||||
ajax.put("url", url);
|
ajax.put("url", url);
|
||||||
return ajax;
|
return ajax;
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
return AjaxResult.error(e.getMessage());
|
return AjaxResult.error(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 本地资源通用下载
|
* 本地资源通用下载
|
||||||
*/
|
*/
|
||||||
@GetMapping("/common/download/resource")
|
@GetMapping("/common/download/resource")
|
||||||
public void resourceDownload(String resource, HttpServletRequest request, HttpServletResponse response)
|
public void resourceDownload(String resource, HttpServletRequest request, HttpServletResponse response)
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
// 本地资源路径
|
// 本地资源路径
|
||||||
String localPath = Global.getProfile();
|
String localPath = Global.getProfile();
|
||||||
// 数据库资源地址
|
// 数据库资源地址
|
||||||
String downloadPath = localPath + StringUtils.substringAfter(resource, Constants.RESOURCE_PREFIX);
|
String downloadPath = localPath + StringUtils.substringAfter(resource, Constants.RESOURCE_PREFIX);
|
||||||
// 下载名称
|
// 下载名称
|
||||||
String downloadName = StringUtils.substringAfterLast(downloadPath, "/");
|
String downloadName = StringUtils.substringAfterLast(downloadPath, "/");
|
||||||
response.setCharacterEncoding("utf-8");
|
response.setCharacterEncoding("utf-8");
|
||||||
response.setContentType("multipart/form-data");
|
response.setContentType("multipart/form-data");
|
||||||
response.setHeader("Content-Disposition",
|
response.setHeader("Content-Disposition",
|
||||||
"attachment;fileName=" + FileUtils.setFileDownloadHeader(request, downloadName));
|
"attachment;fileName=" + FileUtils.setFileDownloadHeader(request, downloadName));
|
||||||
FileUtils.writeBytes(downloadPath, response.getOutputStream());
|
FileUtils.writeBytes(downloadPath, response.getOutputStream());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,80 +1,80 @@
|
||||||
package com.ruoyi.web.controller.demo.controller;
|
package com.ruoyi.web.controller.demo.controller;
|
||||||
|
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 模态窗口
|
* 模态窗口
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@Controller
|
@Controller
|
||||||
@RequestMapping("/demo/modal")
|
@RequestMapping("/demo/modal")
|
||||||
public class DemoDialogController
|
public class DemoDialogController
|
||||||
{
|
{
|
||||||
private String prefix = "demo/modal";
|
private String prefix = "demo/modal";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 模态窗口
|
* 模态窗口
|
||||||
*/
|
*/
|
||||||
@GetMapping("/dialog")
|
@GetMapping("/dialog")
|
||||||
public String dialog()
|
public String dialog()
|
||||||
{
|
{
|
||||||
return prefix + "/dialog";
|
return prefix + "/dialog";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 弹层组件
|
* 弹层组件
|
||||||
*/
|
*/
|
||||||
@GetMapping("/layer")
|
@GetMapping("/layer")
|
||||||
public String layer()
|
public String layer()
|
||||||
{
|
{
|
||||||
return prefix + "/layer";
|
return prefix + "/layer";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 表单
|
* 表单
|
||||||
*/
|
*/
|
||||||
@GetMapping("/form")
|
@GetMapping("/form")
|
||||||
public String form()
|
public String form()
|
||||||
{
|
{
|
||||||
return prefix + "/form";
|
return prefix + "/form";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 表格
|
* 表格
|
||||||
*/
|
*/
|
||||||
@GetMapping("/table")
|
@GetMapping("/table")
|
||||||
public String table()
|
public String table()
|
||||||
{
|
{
|
||||||
return prefix + "/table";
|
return prefix + "/table";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 表格check
|
* 表格check
|
||||||
*/
|
*/
|
||||||
@GetMapping("/check")
|
@GetMapping("/check")
|
||||||
public String check()
|
public String check()
|
||||||
{
|
{
|
||||||
return prefix + "/table/check";
|
return prefix + "/table/check";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 表格radio
|
* 表格radio
|
||||||
*/
|
*/
|
||||||
@GetMapping("/radio")
|
@GetMapping("/radio")
|
||||||
public String radio()
|
public String radio()
|
||||||
{
|
{
|
||||||
return prefix + "/table/radio";
|
return prefix + "/table/radio";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 表格回传父窗体
|
* 表格回传父窗体
|
||||||
*/
|
*/
|
||||||
@GetMapping("/parent")
|
@GetMapping("/parent")
|
||||||
public String parent()
|
public String parent()
|
||||||
{
|
{
|
||||||
return prefix + "/table/parent";
|
return prefix + "/table/parent";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -1,35 +1,35 @@
|
||||||
package com.ruoyi.web.controller.demo.controller;
|
package com.ruoyi.web.controller.demo.controller;
|
||||||
|
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 图标相关
|
* 图标相关
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@Controller
|
@Controller
|
||||||
@RequestMapping("/demo/icon")
|
@RequestMapping("/demo/icon")
|
||||||
public class DemoIconController
|
public class DemoIconController
|
||||||
{
|
{
|
||||||
private String prefix = "demo/icon";
|
private String prefix = "demo/icon";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FontAwesome图标
|
* FontAwesome图标
|
||||||
*/
|
*/
|
||||||
@GetMapping("/fontawesome")
|
@GetMapping("/fontawesome")
|
||||||
public String fontAwesome()
|
public String fontAwesome()
|
||||||
{
|
{
|
||||||
return prefix + "/fontawesome";
|
return prefix + "/fontawesome";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Glyphicons图标
|
* Glyphicons图标
|
||||||
*/
|
*/
|
||||||
@GetMapping("/glyphicons")
|
@GetMapping("/glyphicons")
|
||||||
public String glyphicons()
|
public String glyphicons()
|
||||||
{
|
{
|
||||||
return prefix + "/glyphicons";
|
return prefix + "/glyphicons";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,326 +1,326 @@
|
||||||
package com.ruoyi.web.controller.demo.controller;
|
package com.ruoyi.web.controller.demo.controller;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
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 org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.ModelMap;
|
import org.springframework.ui.ModelMap;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
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.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
import com.ruoyi.common.core.page.PageDomain;
|
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.core.text.Convert;
|
import com.ruoyi.common.core.text.Convert;
|
||||||
import com.ruoyi.common.exception.BusinessException;
|
import com.ruoyi.common.exception.BusinessException;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||||
import com.ruoyi.web.controller.demo.domain.CustomerModel;
|
import com.ruoyi.web.controller.demo.domain.CustomerModel;
|
||||||
import com.ruoyi.web.controller.demo.domain.UserOperateModel;
|
import com.ruoyi.web.controller.demo.domain.UserOperateModel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 操作控制
|
* 操作控制
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@Controller
|
@Controller
|
||||||
@RequestMapping("/demo/operate")
|
@RequestMapping("/demo/operate")
|
||||||
public class DemoOperateController extends BaseController
|
public class DemoOperateController extends BaseController
|
||||||
{
|
{
|
||||||
private String prefix = "demo/operate";
|
private String prefix = "demo/operate";
|
||||||
|
|
||||||
private final static Map<Integer, UserOperateModel> users = new LinkedHashMap<Integer, UserOperateModel>();
|
private final static Map<Integer, UserOperateModel> users = new LinkedHashMap<Integer, UserOperateModel>();
|
||||||
{
|
{
|
||||||
users.put(1, new UserOperateModel(1, "1000001", "测试1", "0", "15888888888", "ry@qq.com", 150.0, "0"));
|
users.put(1, new UserOperateModel(1, "1000001", "测试1", "0", "15888888888", "ry@qq.com", 150.0, "0"));
|
||||||
users.put(2, new UserOperateModel(2, "1000002", "测试2", "1", "15666666666", "ry@qq.com", 180.0, "1"));
|
users.put(2, new UserOperateModel(2, "1000002", "测试2", "1", "15666666666", "ry@qq.com", 180.0, "1"));
|
||||||
users.put(3, new UserOperateModel(3, "1000003", "测试3", "0", "15666666666", "ry@qq.com", 110.0, "1"));
|
users.put(3, new UserOperateModel(3, "1000003", "测试3", "0", "15666666666", "ry@qq.com", 110.0, "1"));
|
||||||
users.put(4, new UserOperateModel(4, "1000004", "测试4", "1", "15666666666", "ry@qq.com", 220.0, "1"));
|
users.put(4, new UserOperateModel(4, "1000004", "测试4", "1", "15666666666", "ry@qq.com", 220.0, "1"));
|
||||||
users.put(5, new UserOperateModel(5, "1000005", "测试5", "0", "15666666666", "ry@qq.com", 140.0, "1"));
|
users.put(5, new UserOperateModel(5, "1000005", "测试5", "0", "15666666666", "ry@qq.com", 140.0, "1"));
|
||||||
users.put(6, new UserOperateModel(6, "1000006", "测试6", "1", "15666666666", "ry@qq.com", 330.0, "1"));
|
users.put(6, new UserOperateModel(6, "1000006", "测试6", "1", "15666666666", "ry@qq.com", 330.0, "1"));
|
||||||
users.put(7, new UserOperateModel(7, "1000007", "测试7", "0", "15666666666", "ry@qq.com", 160.0, "1"));
|
users.put(7, new UserOperateModel(7, "1000007", "测试7", "0", "15666666666", "ry@qq.com", 160.0, "1"));
|
||||||
users.put(8, new UserOperateModel(8, "1000008", "测试8", "1", "15666666666", "ry@qq.com", 170.0, "1"));
|
users.put(8, new UserOperateModel(8, "1000008", "测试8", "1", "15666666666", "ry@qq.com", 170.0, "1"));
|
||||||
users.put(9, new UserOperateModel(9, "1000009", "测试9", "0", "15666666666", "ry@qq.com", 180.0, "1"));
|
users.put(9, new UserOperateModel(9, "1000009", "测试9", "0", "15666666666", "ry@qq.com", 180.0, "1"));
|
||||||
users.put(10, new UserOperateModel(10, "1000010", "测试10", "0", "15666666666", "ry@qq.com", 210.0, "1"));
|
users.put(10, new UserOperateModel(10, "1000010", "测试10", "0", "15666666666", "ry@qq.com", 210.0, "1"));
|
||||||
users.put(11, new UserOperateModel(11, "1000011", "测试11", "1", "15666666666", "ry@qq.com", 110.0, "1"));
|
users.put(11, new UserOperateModel(11, "1000011", "测试11", "1", "15666666666", "ry@qq.com", 110.0, "1"));
|
||||||
users.put(12, new UserOperateModel(12, "1000012", "测试12", "0", "15666666666", "ry@qq.com", 120.0, "1"));
|
users.put(12, new UserOperateModel(12, "1000012", "测试12", "0", "15666666666", "ry@qq.com", 120.0, "1"));
|
||||||
users.put(13, new UserOperateModel(13, "1000013", "测试13", "1", "15666666666", "ry@qq.com", 380.0, "1"));
|
users.put(13, new UserOperateModel(13, "1000013", "测试13", "1", "15666666666", "ry@qq.com", 380.0, "1"));
|
||||||
users.put(14, new UserOperateModel(14, "1000014", "测试14", "0", "15666666666", "ry@qq.com", 280.0, "1"));
|
users.put(14, new UserOperateModel(14, "1000014", "测试14", "0", "15666666666", "ry@qq.com", 280.0, "1"));
|
||||||
users.put(15, new UserOperateModel(15, "1000015", "测试15", "0", "15666666666", "ry@qq.com", 570.0, "1"));
|
users.put(15, new UserOperateModel(15, "1000015", "测试15", "0", "15666666666", "ry@qq.com", 570.0, "1"));
|
||||||
users.put(16, new UserOperateModel(16, "1000016", "测试16", "1", "15666666666", "ry@qq.com", 260.0, "1"));
|
users.put(16, new UserOperateModel(16, "1000016", "测试16", "1", "15666666666", "ry@qq.com", 260.0, "1"));
|
||||||
users.put(17, new UserOperateModel(17, "1000017", "测试17", "1", "15666666666", "ry@qq.com", 210.0, "1"));
|
users.put(17, new UserOperateModel(17, "1000017", "测试17", "1", "15666666666", "ry@qq.com", 210.0, "1"));
|
||||||
users.put(18, new UserOperateModel(18, "1000018", "测试18", "1", "15666666666", "ry@qq.com", 340.0, "1"));
|
users.put(18, new UserOperateModel(18, "1000018", "测试18", "1", "15666666666", "ry@qq.com", 340.0, "1"));
|
||||||
users.put(19, new UserOperateModel(19, "1000019", "测试19", "1", "15666666666", "ry@qq.com", 160.0, "1"));
|
users.put(19, new UserOperateModel(19, "1000019", "测试19", "1", "15666666666", "ry@qq.com", 160.0, "1"));
|
||||||
users.put(20, new UserOperateModel(20, "1000020", "测试20", "1", "15666666666", "ry@qq.com", 220.0, "1"));
|
users.put(20, new UserOperateModel(20, "1000020", "测试20", "1", "15666666666", "ry@qq.com", 220.0, "1"));
|
||||||
users.put(21, new UserOperateModel(21, "1000021", "测试21", "1", "15666666666", "ry@qq.com", 120.0, "1"));
|
users.put(21, new UserOperateModel(21, "1000021", "测试21", "1", "15666666666", "ry@qq.com", 120.0, "1"));
|
||||||
users.put(22, new UserOperateModel(22, "1000022", "测试22", "1", "15666666666", "ry@qq.com", 130.0, "1"));
|
users.put(22, new UserOperateModel(22, "1000022", "测试22", "1", "15666666666", "ry@qq.com", 130.0, "1"));
|
||||||
users.put(23, new UserOperateModel(23, "1000023", "测试23", "1", "15666666666", "ry@qq.com", 490.0, "1"));
|
users.put(23, new UserOperateModel(23, "1000023", "测试23", "1", "15666666666", "ry@qq.com", 490.0, "1"));
|
||||||
users.put(24, new UserOperateModel(24, "1000024", "测试24", "1", "15666666666", "ry@qq.com", 570.0, "1"));
|
users.put(24, new UserOperateModel(24, "1000024", "测试24", "1", "15666666666", "ry@qq.com", 570.0, "1"));
|
||||||
users.put(25, new UserOperateModel(25, "1000025", "测试25", "1", "15666666666", "ry@qq.com", 250.0, "1"));
|
users.put(25, new UserOperateModel(25, "1000025", "测试25", "1", "15666666666", "ry@qq.com", 250.0, "1"));
|
||||||
users.put(26, new UserOperateModel(26, "1000026", "测试26", "1", "15666666666", "ry@qq.com", 250.0, "1"));
|
users.put(26, new UserOperateModel(26, "1000026", "测试26", "1", "15666666666", "ry@qq.com", 250.0, "1"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 表格
|
* 表格
|
||||||
*/
|
*/
|
||||||
@GetMapping("/table")
|
@GetMapping("/table")
|
||||||
public String table()
|
public String table()
|
||||||
{
|
{
|
||||||
return prefix + "/table";
|
return prefix + "/table";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 其他
|
* 其他
|
||||||
*/
|
*/
|
||||||
@GetMapping("/other")
|
@GetMapping("/other")
|
||||||
public String other()
|
public String other()
|
||||||
{
|
{
|
||||||
return prefix + "/other";
|
return prefix + "/other";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询数据
|
* 查询数据
|
||||||
*/
|
*/
|
||||||
@PostMapping("/list")
|
@PostMapping("/list")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public TableDataInfo list(UserOperateModel userModel)
|
public TableDataInfo list(UserOperateModel userModel)
|
||||||
{
|
{
|
||||||
TableDataInfo rspData = new TableDataInfo();
|
TableDataInfo rspData = new TableDataInfo();
|
||||||
List<UserOperateModel> userList = new ArrayList<UserOperateModel>(users.values());
|
List<UserOperateModel> userList = new ArrayList<UserOperateModel>(users.values());
|
||||||
// 查询条件过滤
|
// 查询条件过滤
|
||||||
if (StringUtils.isNotEmpty(userModel.getSearchValue()))
|
if (StringUtils.isNotEmpty(userModel.getSearchValue()))
|
||||||
{
|
{
|
||||||
userList.clear();
|
userList.clear();
|
||||||
for (Map.Entry<Integer, UserOperateModel> entry : users.entrySet())
|
for (Map.Entry<Integer, UserOperateModel> entry : users.entrySet())
|
||||||
{
|
{
|
||||||
if (entry.getValue().getUserName().equals(userModel.getSearchValue()))
|
if (entry.getValue().getUserName().equals(userModel.getSearchValue()))
|
||||||
{
|
{
|
||||||
userList.add(entry.getValue());
|
userList.add(entry.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (StringUtils.isNotEmpty(userModel.getUserName()))
|
else if (StringUtils.isNotEmpty(userModel.getUserName()))
|
||||||
{
|
{
|
||||||
userList.clear();
|
userList.clear();
|
||||||
for (Map.Entry<Integer, UserOperateModel> entry : users.entrySet())
|
for (Map.Entry<Integer, UserOperateModel> entry : users.entrySet())
|
||||||
{
|
{
|
||||||
if (entry.getValue().getUserName().equals(userModel.getUserName()))
|
if (entry.getValue().getUserName().equals(userModel.getUserName()))
|
||||||
{
|
{
|
||||||
userList.add(entry.getValue());
|
userList.add(entry.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PageDomain pageDomain = TableSupport.buildPageRequest();
|
PageDomain pageDomain = TableSupport.buildPageRequest();
|
||||||
if (null == pageDomain.getPageNum() || null == pageDomain.getPageSize())
|
if (null == pageDomain.getPageNum() || null == pageDomain.getPageSize())
|
||||||
{
|
{
|
||||||
rspData.setRows(userList);
|
rspData.setRows(userList);
|
||||||
rspData.setTotal(userList.size());
|
rspData.setTotal(userList.size());
|
||||||
return rspData;
|
return rspData;
|
||||||
}
|
}
|
||||||
Integer pageNum = (pageDomain.getPageNum() - 1) * 10;
|
Integer pageNum = (pageDomain.getPageNum() - 1) * 10;
|
||||||
Integer pageSize = pageDomain.getPageNum() * 10;
|
Integer pageSize = pageDomain.getPageNum() * 10;
|
||||||
if (pageSize > userList.size())
|
if (pageSize > userList.size())
|
||||||
{
|
{
|
||||||
pageSize = userList.size();
|
pageSize = userList.size();
|
||||||
}
|
}
|
||||||
rspData.setRows(userList.subList(pageNum, pageSize));
|
rspData.setRows(userList.subList(pageNum, pageSize));
|
||||||
rspData.setTotal(userList.size());
|
rspData.setTotal(userList.size());
|
||||||
return rspData;
|
return rspData;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增用户
|
* 新增用户
|
||||||
*/
|
*/
|
||||||
@GetMapping("/add")
|
@GetMapping("/add")
|
||||||
public String add(ModelMap mmap)
|
public String add(ModelMap mmap)
|
||||||
{
|
{
|
||||||
return prefix + "/add";
|
return prefix + "/add";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增保存用户
|
* 新增保存用户
|
||||||
*/
|
*/
|
||||||
@PostMapping("/add")
|
@PostMapping("/add")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult addSave(UserOperateModel user)
|
public AjaxResult addSave(UserOperateModel user)
|
||||||
{
|
{
|
||||||
Integer userId = users.size() + 1;
|
Integer userId = users.size() + 1;
|
||||||
user.setUserId(userId);
|
user.setUserId(userId);
|
||||||
return AjaxResult.success(users.put(userId, user));
|
return AjaxResult.success(users.put(userId, user));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增保存主子表信息
|
* 新增保存主子表信息
|
||||||
*/
|
*/
|
||||||
@PostMapping("/customer/add")
|
@PostMapping("/customer/add")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult addSave(CustomerModel customerModel)
|
public AjaxResult addSave(CustomerModel customerModel)
|
||||||
{
|
{
|
||||||
System.out.println(customerModel.toString());
|
System.out.println(customerModel.toString());
|
||||||
return AjaxResult.success();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改用户
|
* 修改用户
|
||||||
*/
|
*/
|
||||||
@GetMapping("/edit/{userId}")
|
@GetMapping("/edit/{userId}")
|
||||||
public String edit(@PathVariable("userId") Integer userId, ModelMap mmap)
|
public String edit(@PathVariable("userId") Integer userId, ModelMap mmap)
|
||||||
{
|
{
|
||||||
mmap.put("user", users.get(userId));
|
mmap.put("user", users.get(userId));
|
||||||
return prefix + "/edit";
|
return prefix + "/edit";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改保存用户
|
* 修改保存用户
|
||||||
*/
|
*/
|
||||||
@PostMapping("/edit")
|
@PostMapping("/edit")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult editSave(UserOperateModel user)
|
public AjaxResult editSave(UserOperateModel user)
|
||||||
{
|
{
|
||||||
return AjaxResult.success(users.put(user.getUserId(), user));
|
return AjaxResult.success(users.put(user.getUserId(), user));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出
|
* 导出
|
||||||
*/
|
*/
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult export(UserOperateModel user)
|
public AjaxResult export(UserOperateModel user)
|
||||||
{
|
{
|
||||||
List<UserOperateModel> list = new ArrayList<UserOperateModel>(users.values());
|
List<UserOperateModel> list = new ArrayList<UserOperateModel>(users.values());
|
||||||
ExcelUtil<UserOperateModel> util = new ExcelUtil<UserOperateModel>(UserOperateModel.class);
|
ExcelUtil<UserOperateModel> util = new ExcelUtil<UserOperateModel>(UserOperateModel.class);
|
||||||
return util.exportExcel(list, "用户数据");
|
return util.exportExcel(list, "用户数据");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 下载模板
|
* 下载模板
|
||||||
*/
|
*/
|
||||||
@GetMapping("/importTemplate")
|
@GetMapping("/importTemplate")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult importTemplate()
|
public AjaxResult importTemplate()
|
||||||
{
|
{
|
||||||
ExcelUtil<UserOperateModel> util = new ExcelUtil<UserOperateModel>(UserOperateModel.class);
|
ExcelUtil<UserOperateModel> util = new ExcelUtil<UserOperateModel>(UserOperateModel.class);
|
||||||
return util.importTemplateExcel("用户数据");
|
return util.importTemplateExcel("用户数据");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导入数据
|
* 导入数据
|
||||||
*/
|
*/
|
||||||
@PostMapping("/importData")
|
@PostMapping("/importData")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception
|
public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception
|
||||||
{
|
{
|
||||||
ExcelUtil<UserOperateModel> util = new ExcelUtil<UserOperateModel>(UserOperateModel.class);
|
ExcelUtil<UserOperateModel> util = new ExcelUtil<UserOperateModel>(UserOperateModel.class);
|
||||||
List<UserOperateModel> userList = util.importExcel(file.getInputStream());
|
List<UserOperateModel> userList = util.importExcel(file.getInputStream());
|
||||||
String message = importUser(userList, updateSupport);
|
String message = importUser(userList, updateSupport);
|
||||||
return AjaxResult.success(message);
|
return AjaxResult.success(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除用户
|
* 删除用户
|
||||||
*/
|
*/
|
||||||
@PostMapping("/remove")
|
@PostMapping("/remove")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult remove(String ids)
|
public AjaxResult remove(String ids)
|
||||||
{
|
{
|
||||||
Integer[] userIds = Convert.toIntArray(ids);
|
Integer[] userIds = Convert.toIntArray(ids);
|
||||||
for (Integer userId : userIds)
|
for (Integer userId : userIds)
|
||||||
{
|
{
|
||||||
users.remove(userId);
|
users.remove(userId);
|
||||||
}
|
}
|
||||||
return AjaxResult.success();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查看详细
|
* 查看详细
|
||||||
*/
|
*/
|
||||||
@GetMapping("/detail/{userId}")
|
@GetMapping("/detail/{userId}")
|
||||||
public String detail(@PathVariable("userId") Integer userId, ModelMap mmap)
|
public String detail(@PathVariable("userId") Integer userId, ModelMap mmap)
|
||||||
{
|
{
|
||||||
mmap.put("user", users.get(userId));
|
mmap.put("user", users.get(userId));
|
||||||
return prefix + "/detail";
|
return prefix + "/detail";
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/clean")
|
@PostMapping("/clean")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult clean()
|
public AjaxResult clean()
|
||||||
{
|
{
|
||||||
users.clear();
|
users.clear();
|
||||||
return success();
|
return success();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导入用户数据
|
* 导入用户数据
|
||||||
*
|
*
|
||||||
* @param userList 用户数据列表
|
* @param userList 用户数据列表
|
||||||
* @param isUpdateSupport 是否更新支持,如果已存在,则进行更新数据
|
* @param isUpdateSupport 是否更新支持,如果已存在,则进行更新数据
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public String importUser(List<UserOperateModel> userList, Boolean isUpdateSupport)
|
public String importUser(List<UserOperateModel> userList, Boolean isUpdateSupport)
|
||||||
{
|
{
|
||||||
if (StringUtils.isNull(userList) || userList.size() == 0)
|
if (StringUtils.isNull(userList) || userList.size() == 0)
|
||||||
{
|
{
|
||||||
throw new BusinessException("导入用户数据不能为空!");
|
throw new BusinessException("导入用户数据不能为空!");
|
||||||
}
|
}
|
||||||
int successNum = 0;
|
int successNum = 0;
|
||||||
int failureNum = 0;
|
int failureNum = 0;
|
||||||
StringBuilder successMsg = new StringBuilder();
|
StringBuilder successMsg = new StringBuilder();
|
||||||
StringBuilder failureMsg = new StringBuilder();
|
StringBuilder failureMsg = new StringBuilder();
|
||||||
for (UserOperateModel user : userList)
|
for (UserOperateModel user : userList)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// 验证是否存在这个用户
|
// 验证是否存在这个用户
|
||||||
boolean userFlag = false;
|
boolean userFlag = false;
|
||||||
for (Map.Entry<Integer, UserOperateModel> entry : users.entrySet())
|
for (Map.Entry<Integer, UserOperateModel> entry : users.entrySet())
|
||||||
{
|
{
|
||||||
if (entry.getValue().getUserName().equals(user.getUserName()))
|
if (entry.getValue().getUserName().equals(user.getUserName()))
|
||||||
{
|
{
|
||||||
userFlag = true;
|
userFlag = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!userFlag)
|
if (!userFlag)
|
||||||
{
|
{
|
||||||
Integer userId = users.size() + 1;
|
Integer userId = users.size() + 1;
|
||||||
user.setUserId(userId);
|
user.setUserId(userId);
|
||||||
users.put(userId, user);
|
users.put(userId, user);
|
||||||
successNum++;
|
successNum++;
|
||||||
successMsg.append("<br/>" + successNum + "、用户 " + user.getUserName() + " 导入成功");
|
successMsg.append("<br/>" + successNum + "、用户 " + user.getUserName() + " 导入成功");
|
||||||
}
|
}
|
||||||
else if (isUpdateSupport)
|
else if (isUpdateSupport)
|
||||||
{
|
{
|
||||||
users.put(user.getUserId(), user);
|
users.put(user.getUserId(), user);
|
||||||
successNum++;
|
successNum++;
|
||||||
successMsg.append("<br/>" + successNum + "、用户 " + user.getUserName() + " 更新成功");
|
successMsg.append("<br/>" + successNum + "、用户 " + user.getUserName() + " 更新成功");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
failureNum++;
|
failureNum++;
|
||||||
failureMsg.append("<br/>" + failureNum + "、用户 " + user.getUserName() + " 已存在");
|
failureMsg.append("<br/>" + failureNum + "、用户 " + user.getUserName() + " 已存在");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
failureNum++;
|
failureNum++;
|
||||||
String msg = "<br/>" + failureNum + "、账号 " + user.getUserName() + " 导入失败:";
|
String msg = "<br/>" + failureNum + "、账号 " + user.getUserName() + " 导入失败:";
|
||||||
failureMsg.append(msg + e.getMessage());
|
failureMsg.append(msg + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (failureNum > 0)
|
if (failureNum > 0)
|
||||||
{
|
{
|
||||||
failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
|
failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
|
||||||
throw new BusinessException(failureMsg.toString());
|
throw new BusinessException(failureMsg.toString());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
|
successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
|
||||||
}
|
}
|
||||||
return successMsg.toString();
|
return successMsg.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,53 +1,53 @@
|
||||||
package com.ruoyi.web.controller.demo.controller;
|
package com.ruoyi.web.controller.demo.controller;
|
||||||
|
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 报表
|
* 报表
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@Controller
|
@Controller
|
||||||
@RequestMapping("/demo/report")
|
@RequestMapping("/demo/report")
|
||||||
public class DemoReportController
|
public class DemoReportController
|
||||||
{
|
{
|
||||||
private String prefix = "demo/report";
|
private String prefix = "demo/report";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 百度ECharts
|
* 百度ECharts
|
||||||
*/
|
*/
|
||||||
@GetMapping("/echarts")
|
@GetMapping("/echarts")
|
||||||
public String echarts()
|
public String echarts()
|
||||||
{
|
{
|
||||||
return prefix + "/echarts";
|
return prefix + "/echarts";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 图表插件
|
* 图表插件
|
||||||
*/
|
*/
|
||||||
@GetMapping("/peity")
|
@GetMapping("/peity")
|
||||||
public String peity()
|
public String peity()
|
||||||
{
|
{
|
||||||
return prefix + "/peity";
|
return prefix + "/peity";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 线状图插件
|
* 线状图插件
|
||||||
*/
|
*/
|
||||||
@GetMapping("/sparkline")
|
@GetMapping("/sparkline")
|
||||||
public String sparkline()
|
public String sparkline()
|
||||||
{
|
{
|
||||||
return prefix + "/sparkline";
|
return prefix + "/sparkline";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 图表组合
|
* 图表组合
|
||||||
*/
|
*/
|
||||||
@GetMapping("/metrics")
|
@GetMapping("/metrics")
|
||||||
public String metrics()
|
public String metrics()
|
||||||
{
|
{
|
||||||
return prefix + "/metrics";
|
return prefix + "/metrics";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,423 +1,423 @@
|
||||||
package com.ruoyi.web.controller.demo.controller;
|
package com.ruoyi.web.controller.demo.controller;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.ModelMap;
|
import org.springframework.ui.ModelMap;
|
||||||
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.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
import com.ruoyi.common.core.page.PageDomain;
|
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.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 表格相关
|
* 表格相关
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@Controller
|
@Controller
|
||||||
@RequestMapping("/demo/table")
|
@RequestMapping("/demo/table")
|
||||||
public class DemoTableController extends BaseController
|
public class DemoTableController extends BaseController
|
||||||
{
|
{
|
||||||
private String prefix = "demo/table";
|
private String prefix = "demo/table";
|
||||||
|
|
||||||
private final static List<UserTableModel> users = new ArrayList<UserTableModel>();
|
private final static List<UserTableModel> users = new ArrayList<UserTableModel>();
|
||||||
{
|
{
|
||||||
users.add(new UserTableModel(1, "1000001", "测试1", "0", "15888888888", "ry@qq.com", 150.0, "0"));
|
users.add(new UserTableModel(1, "1000001", "测试1", "0", "15888888888", "ry@qq.com", 150.0, "0"));
|
||||||
users.add(new UserTableModel(2, "1000002", "测试2", "1", "15666666666", "ry@qq.com", 180.0, "1"));
|
users.add(new UserTableModel(2, "1000002", "测试2", "1", "15666666666", "ry@qq.com", 180.0, "1"));
|
||||||
users.add(new UserTableModel(3, "1000003", "测试3", "0", "15666666666", "ry@qq.com", 110.0, "1"));
|
users.add(new UserTableModel(3, "1000003", "测试3", "0", "15666666666", "ry@qq.com", 110.0, "1"));
|
||||||
users.add(new UserTableModel(4, "1000004", "测试4", "1", "15666666666", "ry@qq.com", 220.0, "1"));
|
users.add(new UserTableModel(4, "1000004", "测试4", "1", "15666666666", "ry@qq.com", 220.0, "1"));
|
||||||
users.add(new UserTableModel(5, "1000005", "测试5", "0", "15666666666", "ry@qq.com", 140.0, "1"));
|
users.add(new UserTableModel(5, "1000005", "测试5", "0", "15666666666", "ry@qq.com", 140.0, "1"));
|
||||||
users.add(new UserTableModel(6, "1000006", "测试6", "1", "15666666666", "ry@qq.com", 330.0, "1"));
|
users.add(new UserTableModel(6, "1000006", "测试6", "1", "15666666666", "ry@qq.com", 330.0, "1"));
|
||||||
users.add(new UserTableModel(7, "1000007", "测试7", "0", "15666666666", "ry@qq.com", 160.0, "1"));
|
users.add(new UserTableModel(7, "1000007", "测试7", "0", "15666666666", "ry@qq.com", 160.0, "1"));
|
||||||
users.add(new UserTableModel(8, "1000008", "测试8", "1", "15666666666", "ry@qq.com", 170.0, "1"));
|
users.add(new UserTableModel(8, "1000008", "测试8", "1", "15666666666", "ry@qq.com", 170.0, "1"));
|
||||||
users.add(new UserTableModel(9, "1000009", "测试9", "0", "15666666666", "ry@qq.com", 180.0, "1"));
|
users.add(new UserTableModel(9, "1000009", "测试9", "0", "15666666666", "ry@qq.com", 180.0, "1"));
|
||||||
users.add(new UserTableModel(10, "1000010", "测试10", "0", "15666666666", "ry@qq.com", 210.0, "1"));
|
users.add(new UserTableModel(10, "1000010", "测试10", "0", "15666666666", "ry@qq.com", 210.0, "1"));
|
||||||
users.add(new UserTableModel(11, "1000011", "测试11", "1", "15666666666", "ry@qq.com", 110.0, "1"));
|
users.add(new UserTableModel(11, "1000011", "测试11", "1", "15666666666", "ry@qq.com", 110.0, "1"));
|
||||||
users.add(new UserTableModel(12, "1000012", "测试12", "0", "15666666666", "ry@qq.com", 120.0, "1"));
|
users.add(new UserTableModel(12, "1000012", "测试12", "0", "15666666666", "ry@qq.com", 120.0, "1"));
|
||||||
users.add(new UserTableModel(13, "1000013", "测试13", "1", "15666666666", "ry@qq.com", 380.0, "1"));
|
users.add(new UserTableModel(13, "1000013", "测试13", "1", "15666666666", "ry@qq.com", 380.0, "1"));
|
||||||
users.add(new UserTableModel(14, "1000014", "测试14", "0", "15666666666", "ry@qq.com", 280.0, "1"));
|
users.add(new UserTableModel(14, "1000014", "测试14", "0", "15666666666", "ry@qq.com", 280.0, "1"));
|
||||||
users.add(new UserTableModel(15, "1000015", "测试15", "0", "15666666666", "ry@qq.com", 570.0, "1"));
|
users.add(new UserTableModel(15, "1000015", "测试15", "0", "15666666666", "ry@qq.com", 570.0, "1"));
|
||||||
users.add(new UserTableModel(16, "1000016", "测试16", "1", "15666666666", "ry@qq.com", 260.0, "1"));
|
users.add(new UserTableModel(16, "1000016", "测试16", "1", "15666666666", "ry@qq.com", 260.0, "1"));
|
||||||
users.add(new UserTableModel(17, "1000017", "测试17", "1", "15666666666", "ry@qq.com", 210.0, "1"));
|
users.add(new UserTableModel(17, "1000017", "测试17", "1", "15666666666", "ry@qq.com", 210.0, "1"));
|
||||||
users.add(new UserTableModel(18, "1000018", "测试18", "1", "15666666666", "ry@qq.com", 340.0, "1"));
|
users.add(new UserTableModel(18, "1000018", "测试18", "1", "15666666666", "ry@qq.com", 340.0, "1"));
|
||||||
users.add(new UserTableModel(19, "1000019", "测试19", "1", "15666666666", "ry@qq.com", 160.0, "1"));
|
users.add(new UserTableModel(19, "1000019", "测试19", "1", "15666666666", "ry@qq.com", 160.0, "1"));
|
||||||
users.add(new UserTableModel(20, "1000020", "测试20", "1", "15666666666", "ry@qq.com", 220.0, "1"));
|
users.add(new UserTableModel(20, "1000020", "测试20", "1", "15666666666", "ry@qq.com", 220.0, "1"));
|
||||||
users.add(new UserTableModel(21, "1000021", "测试21", "1", "15666666666", "ry@qq.com", 120.0, "1"));
|
users.add(new UserTableModel(21, "1000021", "测试21", "1", "15666666666", "ry@qq.com", 120.0, "1"));
|
||||||
users.add(new UserTableModel(22, "1000022", "测试22", "1", "15666666666", "ry@qq.com", 130.0, "1"));
|
users.add(new UserTableModel(22, "1000022", "测试22", "1", "15666666666", "ry@qq.com", 130.0, "1"));
|
||||||
users.add(new UserTableModel(23, "1000023", "测试23", "1", "15666666666", "ry@qq.com", 490.0, "1"));
|
users.add(new UserTableModel(23, "1000023", "测试23", "1", "15666666666", "ry@qq.com", 490.0, "1"));
|
||||||
users.add(new UserTableModel(24, "1000024", "测试24", "1", "15666666666", "ry@qq.com", 570.0, "1"));
|
users.add(new UserTableModel(24, "1000024", "测试24", "1", "15666666666", "ry@qq.com", 570.0, "1"));
|
||||||
users.add(new UserTableModel(25, "1000025", "测试25", "1", "15666666666", "ry@qq.com", 250.0, "1"));
|
users.add(new UserTableModel(25, "1000025", "测试25", "1", "15666666666", "ry@qq.com", 250.0, "1"));
|
||||||
users.add(new UserTableModel(26, "1000026", "测试26", "1", "15666666666", "ry@qq.com", 250.0, "1"));
|
users.add(new UserTableModel(26, "1000026", "测试26", "1", "15666666666", "ry@qq.com", 250.0, "1"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 搜索相关
|
* 搜索相关
|
||||||
*/
|
*/
|
||||||
@GetMapping("/search")
|
@GetMapping("/search")
|
||||||
public String search()
|
public String search()
|
||||||
{
|
{
|
||||||
return prefix + "/search";
|
return prefix + "/search";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数据汇总
|
* 数据汇总
|
||||||
*/
|
*/
|
||||||
@GetMapping("/footer")
|
@GetMapping("/footer")
|
||||||
public String footer()
|
public String footer()
|
||||||
{
|
{
|
||||||
return prefix + "/footer";
|
return prefix + "/footer";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 组合表头
|
* 组合表头
|
||||||
*/
|
*/
|
||||||
@GetMapping("/groupHeader")
|
@GetMapping("/groupHeader")
|
||||||
public String groupHeader()
|
public String groupHeader()
|
||||||
{
|
{
|
||||||
return prefix + "/groupHeader";
|
return prefix + "/groupHeader";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 表格导出
|
* 表格导出
|
||||||
*/
|
*/
|
||||||
@GetMapping("/export")
|
@GetMapping("/export")
|
||||||
public String export()
|
public String export()
|
||||||
{
|
{
|
||||||
return prefix + "/export";
|
return prefix + "/export";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 翻页记住选择
|
* 翻页记住选择
|
||||||
*/
|
*/
|
||||||
@GetMapping("/remember")
|
@GetMapping("/remember")
|
||||||
public String remember()
|
public String remember()
|
||||||
{
|
{
|
||||||
return prefix + "/remember";
|
return prefix + "/remember";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 跳转至指定页
|
* 跳转至指定页
|
||||||
*/
|
*/
|
||||||
@GetMapping("/pageGo")
|
@GetMapping("/pageGo")
|
||||||
public String pageGo()
|
public String pageGo()
|
||||||
{
|
{
|
||||||
return prefix + "/pageGo";
|
return prefix + "/pageGo";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 自定义查询参数
|
* 自定义查询参数
|
||||||
*/
|
*/
|
||||||
@GetMapping("/params")
|
@GetMapping("/params")
|
||||||
public String params()
|
public String params()
|
||||||
{
|
{
|
||||||
return prefix + "/params";
|
return prefix + "/params";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 多表格
|
* 多表格
|
||||||
*/
|
*/
|
||||||
@GetMapping("/multi")
|
@GetMapping("/multi")
|
||||||
public String multi()
|
public String multi()
|
||||||
{
|
{
|
||||||
return prefix + "/multi";
|
return prefix + "/multi";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 点击按钮加载表格
|
* 点击按钮加载表格
|
||||||
*/
|
*/
|
||||||
@GetMapping("/button")
|
@GetMapping("/button")
|
||||||
public String button()
|
public String button()
|
||||||
{
|
{
|
||||||
return prefix + "/button";
|
return prefix + "/button";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 直接加载表格数据
|
* 直接加载表格数据
|
||||||
*/
|
*/
|
||||||
@GetMapping("/data")
|
@GetMapping("/data")
|
||||||
public String data(ModelMap mmap)
|
public String data(ModelMap mmap)
|
||||||
{
|
{
|
||||||
mmap.put("users", users);
|
mmap.put("users", users);
|
||||||
return prefix + "/data";
|
return prefix + "/data";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 表格冻结列
|
* 表格冻结列
|
||||||
*/
|
*/
|
||||||
@GetMapping("/fixedColumns")
|
@GetMapping("/fixedColumns")
|
||||||
public String fixedColumns()
|
public String fixedColumns()
|
||||||
{
|
{
|
||||||
return prefix + "/fixedColumns";
|
return prefix + "/fixedColumns";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 自定义触发事件
|
* 自定义触发事件
|
||||||
*/
|
*/
|
||||||
@GetMapping("/event")
|
@GetMapping("/event")
|
||||||
public String event()
|
public String event()
|
||||||
{
|
{
|
||||||
return prefix + "/event";
|
return prefix + "/event";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 表格细节视图
|
* 表格细节视图
|
||||||
*/
|
*/
|
||||||
@GetMapping("/detail")
|
@GetMapping("/detail")
|
||||||
public String detail()
|
public String detail()
|
||||||
{
|
{
|
||||||
return prefix + "/detail";
|
return prefix + "/detail";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 表格父子视图
|
* 表格父子视图
|
||||||
*/
|
*/
|
||||||
@GetMapping("/child")
|
@GetMapping("/child")
|
||||||
public String child()
|
public String child()
|
||||||
{
|
{
|
||||||
return prefix + "/child";
|
return prefix + "/child";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 表格图片预览
|
* 表格图片预览
|
||||||
*/
|
*/
|
||||||
@GetMapping("/image")
|
@GetMapping("/image")
|
||||||
public String image()
|
public String image()
|
||||||
{
|
{
|
||||||
return prefix + "/image";
|
return prefix + "/image";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 动态增删改查
|
* 动态增删改查
|
||||||
*/
|
*/
|
||||||
@GetMapping("/curd")
|
@GetMapping("/curd")
|
||||||
public String curd()
|
public String curd()
|
||||||
{
|
{
|
||||||
return prefix + "/curd";
|
return prefix + "/curd";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 表格拖拽操作
|
* 表格拖拽操作
|
||||||
*/
|
*/
|
||||||
@GetMapping("/reorder")
|
@GetMapping("/reorder")
|
||||||
public String reorder()
|
public String reorder()
|
||||||
{
|
{
|
||||||
return prefix + "/reorder";
|
return prefix + "/reorder";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 表格行内编辑操作
|
* 表格行内编辑操作
|
||||||
*/
|
*/
|
||||||
@GetMapping("/editable")
|
@GetMapping("/editable")
|
||||||
public String editable()
|
public String editable()
|
||||||
{
|
{
|
||||||
return prefix + "/editable";
|
return prefix + "/editable";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 主子表提交
|
* 主子表提交
|
||||||
*/
|
*/
|
||||||
@GetMapping("/subdata")
|
@GetMapping("/subdata")
|
||||||
public String subdata()
|
public String subdata()
|
||||||
{
|
{
|
||||||
return prefix + "/subdata";
|
return prefix + "/subdata";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 表格其他操作
|
* 表格其他操作
|
||||||
*/
|
*/
|
||||||
@GetMapping("/other")
|
@GetMapping("/other")
|
||||||
public String other()
|
public String other()
|
||||||
{
|
{
|
||||||
return prefix + "/other";
|
return prefix + "/other";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询数据
|
* 查询数据
|
||||||
*/
|
*/
|
||||||
@PostMapping("/list")
|
@PostMapping("/list")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public TableDataInfo list(UserTableModel userModel)
|
public TableDataInfo list(UserTableModel userModel)
|
||||||
{
|
{
|
||||||
TableDataInfo rspData = new TableDataInfo();
|
TableDataInfo rspData = new TableDataInfo();
|
||||||
List<UserTableModel> userList = new ArrayList<UserTableModel>(Arrays.asList(new UserTableModel[users.size()]));
|
List<UserTableModel> userList = new ArrayList<UserTableModel>(Arrays.asList(new UserTableModel[users.size()]));
|
||||||
Collections.copy(userList, users);
|
Collections.copy(userList, users);
|
||||||
// 查询条件过滤
|
// 查询条件过滤
|
||||||
if (StringUtils.isNotEmpty(userModel.getUserName()))
|
if (StringUtils.isNotEmpty(userModel.getUserName()))
|
||||||
{
|
{
|
||||||
userList.clear();
|
userList.clear();
|
||||||
for (UserTableModel user : users)
|
for (UserTableModel user : users)
|
||||||
{
|
{
|
||||||
if (user.getUserName().equals(userModel.getUserName()))
|
if (user.getUserName().equals(userModel.getUserName()))
|
||||||
{
|
{
|
||||||
userList.add(user);
|
userList.add(user);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PageDomain pageDomain = TableSupport.buildPageRequest();
|
PageDomain pageDomain = TableSupport.buildPageRequest();
|
||||||
if (null == pageDomain.getPageNum() || null == pageDomain.getPageSize())
|
if (null == pageDomain.getPageNum() || null == pageDomain.getPageSize())
|
||||||
{
|
{
|
||||||
rspData.setRows(userList);
|
rspData.setRows(userList);
|
||||||
rspData.setTotal(userList.size());
|
rspData.setTotal(userList.size());
|
||||||
return rspData;
|
return rspData;
|
||||||
}
|
}
|
||||||
Integer pageNum = (pageDomain.getPageNum() - 1) * 10;
|
Integer pageNum = (pageDomain.getPageNum() - 1) * 10;
|
||||||
Integer pageSize = pageDomain.getPageNum() * 10;
|
Integer pageSize = pageDomain.getPageNum() * 10;
|
||||||
if (pageSize > userList.size())
|
if (pageSize > userList.size())
|
||||||
{
|
{
|
||||||
pageSize = userList.size();
|
pageSize = userList.size();
|
||||||
}
|
}
|
||||||
rspData.setRows(userList.subList(pageNum, pageSize));
|
rspData.setRows(userList.subList(pageNum, pageSize));
|
||||||
rspData.setTotal(userList.size());
|
rspData.setTotal(userList.size());
|
||||||
return rspData;
|
return rspData;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class UserTableModel
|
class UserTableModel
|
||||||
{
|
{
|
||||||
/** 用户ID */
|
/** 用户ID */
|
||||||
private int userId;
|
private int userId;
|
||||||
|
|
||||||
/** 用户编号 */
|
/** 用户编号 */
|
||||||
private String userCode;
|
private String userCode;
|
||||||
|
|
||||||
/** 用户姓名 */
|
/** 用户姓名 */
|
||||||
private String userName;
|
private String userName;
|
||||||
|
|
||||||
/** 用户性别 */
|
/** 用户性别 */
|
||||||
private String userSex;
|
private String userSex;
|
||||||
|
|
||||||
/** 用户手机 */
|
/** 用户手机 */
|
||||||
private String userPhone;
|
private String userPhone;
|
||||||
|
|
||||||
/** 用户邮箱 */
|
/** 用户邮箱 */
|
||||||
private String userEmail;
|
private String userEmail;
|
||||||
|
|
||||||
/** 用户余额 */
|
/** 用户余额 */
|
||||||
private double userBalance;
|
private double userBalance;
|
||||||
|
|
||||||
/** 用户状态(0正常 1停用) */
|
/** 用户状态(0正常 1停用) */
|
||||||
private String status;
|
private String status;
|
||||||
|
|
||||||
/** 创建时间 */
|
/** 创建时间 */
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
private Date createTime;
|
private Date createTime;
|
||||||
|
|
||||||
public UserTableModel()
|
public UserTableModel()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public UserTableModel(int userId, String userCode, String userName, String userSex, String userPhone,
|
public UserTableModel(int userId, String userCode, String userName, String userSex, String userPhone,
|
||||||
String userEmail, double userBalance, String status)
|
String userEmail, double userBalance, String status)
|
||||||
{
|
{
|
||||||
this.userId = userId;
|
this.userId = userId;
|
||||||
this.userCode = userCode;
|
this.userCode = userCode;
|
||||||
this.userName = userName;
|
this.userName = userName;
|
||||||
this.userSex = userSex;
|
this.userSex = userSex;
|
||||||
this.userPhone = userPhone;
|
this.userPhone = userPhone;
|
||||||
this.userEmail = userEmail;
|
this.userEmail = userEmail;
|
||||||
this.userBalance = userBalance;
|
this.userBalance = userBalance;
|
||||||
this.status = status;
|
this.status = status;
|
||||||
this.createTime = DateUtils.getNowDate();
|
this.createTime = DateUtils.getNowDate();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getUserId()
|
public int getUserId()
|
||||||
{
|
{
|
||||||
return userId;
|
return userId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUserId(int userId)
|
public void setUserId(int userId)
|
||||||
{
|
{
|
||||||
this.userId = userId;
|
this.userId = userId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUserCode()
|
public String getUserCode()
|
||||||
{
|
{
|
||||||
return userCode;
|
return userCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUserCode(String userCode)
|
public void setUserCode(String userCode)
|
||||||
{
|
{
|
||||||
this.userCode = userCode;
|
this.userCode = userCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUserName()
|
public String getUserName()
|
||||||
{
|
{
|
||||||
return userName;
|
return userName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUserName(String userName)
|
public void setUserName(String userName)
|
||||||
{
|
{
|
||||||
this.userName = userName;
|
this.userName = userName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUserSex()
|
public String getUserSex()
|
||||||
{
|
{
|
||||||
return userSex;
|
return userSex;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUserSex(String userSex)
|
public void setUserSex(String userSex)
|
||||||
{
|
{
|
||||||
this.userSex = userSex;
|
this.userSex = userSex;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUserPhone()
|
public String getUserPhone()
|
||||||
{
|
{
|
||||||
return userPhone;
|
return userPhone;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUserPhone(String userPhone)
|
public void setUserPhone(String userPhone)
|
||||||
{
|
{
|
||||||
this.userPhone = userPhone;
|
this.userPhone = userPhone;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUserEmail()
|
public String getUserEmail()
|
||||||
{
|
{
|
||||||
return userEmail;
|
return userEmail;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUserEmail(String userEmail)
|
public void setUserEmail(String userEmail)
|
||||||
{
|
{
|
||||||
this.userEmail = userEmail;
|
this.userEmail = userEmail;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getUserBalance()
|
public double getUserBalance()
|
||||||
{
|
{
|
||||||
return userBalance;
|
return userBalance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUserBalance(double userBalance)
|
public void setUserBalance(double userBalance)
|
||||||
{
|
{
|
||||||
this.userBalance = userBalance;
|
this.userBalance = userBalance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getStatus()
|
public String getStatus()
|
||||||
{
|
{
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStatus(String status)
|
public void setStatus(String status)
|
||||||
{
|
{
|
||||||
this.status = status;
|
this.status = status;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Date getCreateTime()
|
public Date getCreateTime()
|
||||||
{
|
{
|
||||||
return createTime;
|
return createTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCreateTime(Date createTime)
|
public void setCreateTime(Date createTime)
|
||||||
{
|
{
|
||||||
this.createTime = createTime;
|
this.createTime = createTime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,116 +1,116 @@
|
||||||
package com.ruoyi.web.controller.demo.domain;
|
package com.ruoyi.web.controller.demo.domain;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 客户测试信息
|
* 客户测试信息
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class CustomerModel
|
public class CustomerModel
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* 客户姓名
|
* 客户姓名
|
||||||
*/
|
*/
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 客户手机
|
* 客户手机
|
||||||
*/
|
*/
|
||||||
private String phonenumber;
|
private String phonenumber;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 客户性别
|
* 客户性别
|
||||||
*/
|
*/
|
||||||
private String sex;
|
private String sex;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 客户生日
|
* 客户生日
|
||||||
*/
|
*/
|
||||||
private String birthday;
|
private String birthday;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 客户描述
|
* 客户描述
|
||||||
*/
|
*/
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 商品信息
|
* 商品信息
|
||||||
*/
|
*/
|
||||||
private List<GoodsModel> goods;
|
private List<GoodsModel> goods;
|
||||||
|
|
||||||
public String getName()
|
public String getName()
|
||||||
{
|
{
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setName(String name)
|
public void setName(String name)
|
||||||
{
|
{
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPhonenumber()
|
public String getPhonenumber()
|
||||||
{
|
{
|
||||||
return phonenumber;
|
return phonenumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPhonenumber(String phonenumber)
|
public void setPhonenumber(String phonenumber)
|
||||||
{
|
{
|
||||||
this.phonenumber = phonenumber;
|
this.phonenumber = phonenumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getSex()
|
public String getSex()
|
||||||
{
|
{
|
||||||
return sex;
|
return sex;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSex(String sex)
|
public void setSex(String sex)
|
||||||
{
|
{
|
||||||
this.sex = sex;
|
this.sex = sex;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getBirthday()
|
public String getBirthday()
|
||||||
{
|
{
|
||||||
return birthday;
|
return birthday;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBirthday(String birthday)
|
public void setBirthday(String birthday)
|
||||||
{
|
{
|
||||||
this.birthday = birthday;
|
this.birthday = birthday;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRemark()
|
public String getRemark()
|
||||||
{
|
{
|
||||||
return remark;
|
return remark;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRemark(String remark)
|
public void setRemark(String remark)
|
||||||
{
|
{
|
||||||
this.remark = remark;
|
this.remark = remark;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<GoodsModel> getGoods()
|
public List<GoodsModel> getGoods()
|
||||||
{
|
{
|
||||||
return goods;
|
return goods;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGoods(List<GoodsModel> goods)
|
public void setGoods(List<GoodsModel> goods)
|
||||||
{
|
{
|
||||||
this.goods = goods;
|
this.goods = goods;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||||
.append("name", getName())
|
.append("name", getName())
|
||||||
.append("phonenumber", getPhonenumber())
|
.append("phonenumber", getPhonenumber())
|
||||||
.append("sex", getSex())
|
.append("sex", getSex())
|
||||||
.append("birthday", getBirthday())
|
.append("birthday", getBirthday())
|
||||||
.append("goods", getGoods())
|
.append("goods", getGoods())
|
||||||
.append("remark", getRemark())
|
.append("remark", getRemark())
|
||||||
.toString();
|
.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,82 +1,82 @@
|
||||||
package com.ruoyi.web.controller.demo.domain;
|
package com.ruoyi.web.controller.demo.domain;
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 商品测试信息
|
* 商品测试信息
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class GoodsModel
|
public class GoodsModel
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* 商品名称
|
* 商品名称
|
||||||
*/
|
*/
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 商品重量
|
* 商品重量
|
||||||
*/
|
*/
|
||||||
private Integer weight;
|
private Integer weight;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 商品价格
|
* 商品价格
|
||||||
*/
|
*/
|
||||||
private Double price;
|
private Double price;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 商品种类
|
* 商品种类
|
||||||
*/
|
*/
|
||||||
private String type;
|
private String type;
|
||||||
|
|
||||||
public String getName()
|
public String getName()
|
||||||
{
|
{
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setName(String name)
|
public void setName(String name)
|
||||||
{
|
{
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getWeight()
|
public Integer getWeight()
|
||||||
{
|
{
|
||||||
return weight;
|
return weight;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setWeight(Integer weight)
|
public void setWeight(Integer weight)
|
||||||
{
|
{
|
||||||
this.weight = weight;
|
this.weight = weight;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Double getPrice()
|
public Double getPrice()
|
||||||
{
|
{
|
||||||
return price;
|
return price;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPrice(Double price)
|
public void setPrice(Double price)
|
||||||
{
|
{
|
||||||
this.price = price;
|
this.price = price;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getType()
|
public String getType()
|
||||||
{
|
{
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setType(String type)
|
public void setType(String type)
|
||||||
{
|
{
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||||
.append("name", getName())
|
.append("name", getName())
|
||||||
.append("weight", getWeight())
|
.append("weight", getWeight())
|
||||||
.append("price", getPrice())
|
.append("price", getPrice())
|
||||||
.append("type", getType())
|
.append("type", getType())
|
||||||
.toString();
|
.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,149 +1,149 @@
|
||||||
package com.ruoyi.web.controller.demo.domain;
|
package com.ruoyi.web.controller.demo.domain;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import com.ruoyi.common.annotation.Excel;
|
import com.ruoyi.common.annotation.Excel;
|
||||||
import com.ruoyi.common.annotation.Excel.Type;
|
import com.ruoyi.common.annotation.Excel.Type;
|
||||||
import com.ruoyi.common.core.domain.BaseEntity;
|
import com.ruoyi.common.core.domain.BaseEntity;
|
||||||
import com.ruoyi.common.utils.DateUtils;
|
import com.ruoyi.common.utils.DateUtils;
|
||||||
|
|
||||||
public class UserOperateModel extends BaseEntity
|
public class UserOperateModel extends BaseEntity
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private int userId;
|
private int userId;
|
||||||
|
|
||||||
@Excel(name = "用户编号")
|
@Excel(name = "用户编号")
|
||||||
private String userCode;
|
private String userCode;
|
||||||
|
|
||||||
@Excel(name = "用户姓名")
|
@Excel(name = "用户姓名")
|
||||||
private String userName;
|
private String userName;
|
||||||
|
|
||||||
@Excel(name = "用户性别", readConverterExp = "0=男,1=女,2=未知")
|
@Excel(name = "用户性别", readConverterExp = "0=男,1=女,2=未知")
|
||||||
private String userSex;
|
private String userSex;
|
||||||
|
|
||||||
@Excel(name = "用户手机")
|
@Excel(name = "用户手机")
|
||||||
private String userPhone;
|
private String userPhone;
|
||||||
|
|
||||||
@Excel(name = "用户邮箱")
|
@Excel(name = "用户邮箱")
|
||||||
private String userEmail;
|
private String userEmail;
|
||||||
|
|
||||||
@Excel(name = "用户余额")
|
@Excel(name = "用户余额")
|
||||||
private double userBalance;
|
private double userBalance;
|
||||||
|
|
||||||
@Excel(name = "用户状态", readConverterExp = "0=正常,1=停用")
|
@Excel(name = "用户状态", readConverterExp = "0=正常,1=停用")
|
||||||
private String status;
|
private String status;
|
||||||
|
|
||||||
@Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", type = Type.EXPORT)
|
@Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", type = Type.EXPORT)
|
||||||
private Date createTime;
|
private Date createTime;
|
||||||
|
|
||||||
public UserOperateModel()
|
public UserOperateModel()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public UserOperateModel(int userId, String userCode, String userName, String userSex, String userPhone,
|
public UserOperateModel(int userId, String userCode, String userName, String userSex, String userPhone,
|
||||||
String userEmail, double userBalance, String status)
|
String userEmail, double userBalance, String status)
|
||||||
{
|
{
|
||||||
this.userId = userId;
|
this.userId = userId;
|
||||||
this.userCode = userCode;
|
this.userCode = userCode;
|
||||||
this.userName = userName;
|
this.userName = userName;
|
||||||
this.userSex = userSex;
|
this.userSex = userSex;
|
||||||
this.userPhone = userPhone;
|
this.userPhone = userPhone;
|
||||||
this.userEmail = userEmail;
|
this.userEmail = userEmail;
|
||||||
this.userBalance = userBalance;
|
this.userBalance = userBalance;
|
||||||
this.status = status;
|
this.status = status;
|
||||||
this.createTime = DateUtils.getNowDate();
|
this.createTime = DateUtils.getNowDate();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getUserId()
|
public int getUserId()
|
||||||
{
|
{
|
||||||
return userId;
|
return userId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUserId(int userId)
|
public void setUserId(int userId)
|
||||||
{
|
{
|
||||||
this.userId = userId;
|
this.userId = userId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUserCode()
|
public String getUserCode()
|
||||||
{
|
{
|
||||||
return userCode;
|
return userCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUserCode(String userCode)
|
public void setUserCode(String userCode)
|
||||||
{
|
{
|
||||||
this.userCode = userCode;
|
this.userCode = userCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUserName()
|
public String getUserName()
|
||||||
{
|
{
|
||||||
return userName;
|
return userName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUserName(String userName)
|
public void setUserName(String userName)
|
||||||
{
|
{
|
||||||
this.userName = userName;
|
this.userName = userName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUserSex()
|
public String getUserSex()
|
||||||
{
|
{
|
||||||
return userSex;
|
return userSex;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUserSex(String userSex)
|
public void setUserSex(String userSex)
|
||||||
{
|
{
|
||||||
this.userSex = userSex;
|
this.userSex = userSex;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUserPhone()
|
public String getUserPhone()
|
||||||
{
|
{
|
||||||
return userPhone;
|
return userPhone;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUserPhone(String userPhone)
|
public void setUserPhone(String userPhone)
|
||||||
{
|
{
|
||||||
this.userPhone = userPhone;
|
this.userPhone = userPhone;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUserEmail()
|
public String getUserEmail()
|
||||||
{
|
{
|
||||||
return userEmail;
|
return userEmail;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUserEmail(String userEmail)
|
public void setUserEmail(String userEmail)
|
||||||
{
|
{
|
||||||
this.userEmail = userEmail;
|
this.userEmail = userEmail;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getUserBalance()
|
public double getUserBalance()
|
||||||
{
|
{
|
||||||
return userBalance;
|
return userBalance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUserBalance(double userBalance)
|
public void setUserBalance(double userBalance)
|
||||||
{
|
{
|
||||||
this.userBalance = userBalance;
|
this.userBalance = userBalance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getStatus()
|
public String getStatus()
|
||||||
{
|
{
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStatus(String status)
|
public void setStatus(String status)
|
||||||
{
|
{
|
||||||
this.status = status;
|
this.status = status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Date getCreateTime()
|
public Date getCreateTime()
|
||||||
{
|
{
|
||||||
return createTime;
|
return createTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setCreateTime(Date createTime)
|
public void setCreateTime(Date createTime)
|
||||||
{
|
{
|
||||||
this.createTime = createTime;
|
this.createTime = createTime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,26 +1,26 @@
|
||||||
package com.ruoyi.web.controller.monitor;
|
package com.ruoyi.web.controller.monitor;
|
||||||
|
|
||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* druid 监控
|
* druid 监控
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@Controller
|
@Controller
|
||||||
@RequestMapping("/monitor/data")
|
@RequestMapping("/monitor/data")
|
||||||
public class DruidController extends BaseController
|
public class DruidController extends BaseController
|
||||||
{
|
{
|
||||||
private String prefix = "/druid";
|
private String prefix = "/druid";
|
||||||
|
|
||||||
@RequiresPermissions("monitor:data:view")
|
@RequiresPermissions("monitor:data:view")
|
||||||
@GetMapping()
|
@GetMapping()
|
||||||
public String index()
|
public String index()
|
||||||
{
|
{
|
||||||
return redirect(prefix + "/index");
|
return redirect(prefix + "/index");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,31 +1,31 @@
|
||||||
package com.ruoyi.web.controller.monitor;
|
package com.ruoyi.web.controller.monitor;
|
||||||
|
|
||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.ModelMap;
|
import org.springframework.ui.ModelMap;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
import com.ruoyi.framework.web.domain.Server;
|
import com.ruoyi.framework.web.domain.Server;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 服务器监控
|
* 服务器监控
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@Controller
|
@Controller
|
||||||
@RequestMapping("/monitor/server")
|
@RequestMapping("/monitor/server")
|
||||||
public class ServerController extends BaseController
|
public class ServerController extends BaseController
|
||||||
{
|
{
|
||||||
private String prefix = "monitor/server";
|
private String prefix = "monitor/server";
|
||||||
|
|
||||||
@RequiresPermissions("monitor:server:view")
|
@RequiresPermissions("monitor:server:view")
|
||||||
@GetMapping()
|
@GetMapping()
|
||||||
public String server(ModelMap mmap) throws Exception
|
public String server(ModelMap mmap) throws Exception
|
||||||
{
|
{
|
||||||
Server server = new Server();
|
Server server = new Server();
|
||||||
server.copyTo();
|
server.copyTo();
|
||||||
mmap.put("server", server);
|
mmap.put("server", server);
|
||||||
return prefix + "/server";
|
return prefix + "/server";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,94 +1,94 @@
|
||||||
package com.ruoyi.web.controller.monitor;
|
package com.ruoyi.web.controller.monitor;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import com.ruoyi.framework.shiro.service.SysPasswordService;
|
import com.ruoyi.framework.shiro.service.SysPasswordService;
|
||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
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.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
import com.ruoyi.common.annotation.Log;
|
import com.ruoyi.common.annotation.Log;
|
||||||
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
import com.ruoyi.common.enums.BusinessType;
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||||
import com.ruoyi.system.domain.SysLogininfor;
|
import com.ruoyi.system.domain.SysLogininfor;
|
||||||
import com.ruoyi.system.service.ISysLogininforService;
|
import com.ruoyi.system.service.ISysLogininforService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 系统访问记录
|
* 系统访问记录
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@Controller
|
@Controller
|
||||||
@RequestMapping("/monitor/logininfor")
|
@RequestMapping("/monitor/logininfor")
|
||||||
public class SysLogininforController extends BaseController
|
public class SysLogininforController extends BaseController
|
||||||
{
|
{
|
||||||
private String prefix = "monitor/logininfor";
|
private String prefix = "monitor/logininfor";
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysLogininforService logininforService;
|
private ISysLogininforService logininforService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SysPasswordService passwordService;
|
private SysPasswordService passwordService;
|
||||||
|
|
||||||
@RequiresPermissions("monitor:logininfor:view")
|
@RequiresPermissions("monitor:logininfor:view")
|
||||||
@GetMapping()
|
@GetMapping()
|
||||||
public String logininfor()
|
public String logininfor()
|
||||||
{
|
{
|
||||||
return prefix + "/logininfor";
|
return prefix + "/logininfor";
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiresPermissions("monitor:logininfor:list")
|
@RequiresPermissions("monitor:logininfor:list")
|
||||||
@PostMapping("/list")
|
@PostMapping("/list")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public TableDataInfo list(SysLogininfor logininfor)
|
public TableDataInfo list(SysLogininfor logininfor)
|
||||||
{
|
{
|
||||||
startPage();
|
startPage();
|
||||||
List<SysLogininfor> list = logininforService.selectLogininforList(logininfor);
|
List<SysLogininfor> list = logininforService.selectLogininforList(logininfor);
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Log(title = "登陆日志", businessType = BusinessType.EXPORT)
|
@Log(title = "登陆日志", businessType = BusinessType.EXPORT)
|
||||||
@RequiresPermissions("monitor:logininfor:export")
|
@RequiresPermissions("monitor:logininfor:export")
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult export(SysLogininfor logininfor)
|
public AjaxResult export(SysLogininfor logininfor)
|
||||||
{
|
{
|
||||||
List<SysLogininfor> list = logininforService.selectLogininforList(logininfor);
|
List<SysLogininfor> list = logininforService.selectLogininforList(logininfor);
|
||||||
ExcelUtil<SysLogininfor> util = new ExcelUtil<SysLogininfor>(SysLogininfor.class);
|
ExcelUtil<SysLogininfor> util = new ExcelUtil<SysLogininfor>(SysLogininfor.class);
|
||||||
return util.exportExcel(list, "登陆日志");
|
return util.exportExcel(list, "登陆日志");
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiresPermissions("monitor:logininfor:remove")
|
@RequiresPermissions("monitor:logininfor:remove")
|
||||||
@Log(title = "登陆日志", businessType = BusinessType.DELETE)
|
@Log(title = "登陆日志", businessType = BusinessType.DELETE)
|
||||||
@PostMapping("/remove")
|
@PostMapping("/remove")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult remove(String ids)
|
public AjaxResult remove(String ids)
|
||||||
{
|
{
|
||||||
return toAjax(logininforService.deleteLogininforByIds(ids));
|
return toAjax(logininforService.deleteLogininforByIds(ids));
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiresPermissions("monitor:logininfor:remove")
|
@RequiresPermissions("monitor:logininfor:remove")
|
||||||
@Log(title = "登陆日志", businessType = BusinessType.CLEAN)
|
@Log(title = "登陆日志", businessType = BusinessType.CLEAN)
|
||||||
@PostMapping("/clean")
|
@PostMapping("/clean")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult clean()
|
public AjaxResult clean()
|
||||||
{
|
{
|
||||||
logininforService.cleanLogininfor();
|
logininforService.cleanLogininfor();
|
||||||
return success();
|
return success();
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiresPermissions("monitor:logininfor:unlock")
|
@RequiresPermissions("monitor:logininfor:unlock")
|
||||||
@Log(title = "账户解锁", businessType = BusinessType.OTHER)
|
@Log(title = "账户解锁", businessType = BusinessType.OTHER)
|
||||||
@PostMapping("/unlock")
|
@PostMapping("/unlock")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult unlock(String loginName)
|
public AjaxResult unlock(String loginName)
|
||||||
{
|
{
|
||||||
passwordService.unlock(loginName);
|
passwordService.unlock(loginName);
|
||||||
return success();
|
return success();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,89 +1,89 @@
|
||||||
package com.ruoyi.web.controller.monitor;
|
package com.ruoyi.web.controller.monitor;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.ModelMap;
|
import org.springframework.ui.ModelMap;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
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.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
import com.ruoyi.common.annotation.Log;
|
import com.ruoyi.common.annotation.Log;
|
||||||
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
import com.ruoyi.common.enums.BusinessType;
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||||
import com.ruoyi.system.domain.SysOperLog;
|
import com.ruoyi.system.domain.SysOperLog;
|
||||||
import com.ruoyi.system.service.ISysOperLogService;
|
import com.ruoyi.system.service.ISysOperLogService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 操作日志记录
|
* 操作日志记录
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@Controller
|
@Controller
|
||||||
@RequestMapping("/monitor/operlog")
|
@RequestMapping("/monitor/operlog")
|
||||||
public class SysOperlogController extends BaseController
|
public class SysOperlogController extends BaseController
|
||||||
{
|
{
|
||||||
private String prefix = "monitor/operlog";
|
private String prefix = "monitor/operlog";
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysOperLogService operLogService;
|
private ISysOperLogService operLogService;
|
||||||
|
|
||||||
@RequiresPermissions("monitor:operlog:view")
|
@RequiresPermissions("monitor:operlog:view")
|
||||||
@GetMapping()
|
@GetMapping()
|
||||||
public String operlog()
|
public String operlog()
|
||||||
{
|
{
|
||||||
return prefix + "/operlog";
|
return prefix + "/operlog";
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiresPermissions("monitor:operlog:list")
|
@RequiresPermissions("monitor:operlog:list")
|
||||||
@PostMapping("/list")
|
@PostMapping("/list")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public TableDataInfo list(SysOperLog operLog)
|
public TableDataInfo list(SysOperLog operLog)
|
||||||
{
|
{
|
||||||
startPage();
|
startPage();
|
||||||
List<SysOperLog> list = operLogService.selectOperLogList(operLog);
|
List<SysOperLog> list = operLogService.selectOperLogList(operLog);
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Log(title = "操作日志", businessType = BusinessType.EXPORT)
|
@Log(title = "操作日志", businessType = BusinessType.EXPORT)
|
||||||
@RequiresPermissions("monitor:operlog:export")
|
@RequiresPermissions("monitor:operlog:export")
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult export(SysOperLog operLog)
|
public AjaxResult export(SysOperLog operLog)
|
||||||
{
|
{
|
||||||
List<SysOperLog> list = operLogService.selectOperLogList(operLog);
|
List<SysOperLog> list = operLogService.selectOperLogList(operLog);
|
||||||
ExcelUtil<SysOperLog> util = new ExcelUtil<SysOperLog>(SysOperLog.class);
|
ExcelUtil<SysOperLog> util = new ExcelUtil<SysOperLog>(SysOperLog.class);
|
||||||
return util.exportExcel(list, "操作日志");
|
return util.exportExcel(list, "操作日志");
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiresPermissions("monitor:operlog:remove")
|
@RequiresPermissions("monitor:operlog:remove")
|
||||||
@PostMapping("/remove")
|
@PostMapping("/remove")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult remove(String ids)
|
public AjaxResult remove(String ids)
|
||||||
{
|
{
|
||||||
return toAjax(operLogService.deleteOperLogByIds(ids));
|
return toAjax(operLogService.deleteOperLogByIds(ids));
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiresPermissions("monitor:operlog:detail")
|
@RequiresPermissions("monitor:operlog:detail")
|
||||||
@GetMapping("/detail/{operId}")
|
@GetMapping("/detail/{operId}")
|
||||||
public String detail(@PathVariable("operId") Long operId, ModelMap mmap)
|
public String detail(@PathVariable("operId") Long operId, ModelMap mmap)
|
||||||
{
|
{
|
||||||
mmap.put("operLog", operLogService.selectOperLogById(operId));
|
mmap.put("operLog", operLogService.selectOperLogById(operId));
|
||||||
return prefix + "/detail";
|
return prefix + "/detail";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Log(title = "操作日志", businessType = BusinessType.CLEAN)
|
@Log(title = "操作日志", businessType = BusinessType.CLEAN)
|
||||||
@RequiresPermissions("monitor:operlog:remove")
|
@RequiresPermissions("monitor:operlog:remove")
|
||||||
@PostMapping("/clean")
|
@PostMapping("/clean")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult clean()
|
public AjaxResult clean()
|
||||||
{
|
{
|
||||||
operLogService.cleanOperLog();
|
operLogService.cleanOperLog();
|
||||||
return success();
|
return success();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,88 +1,88 @@
|
||||||
package com.ruoyi.web.controller.monitor;
|
package com.ruoyi.web.controller.monitor;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.apache.shiro.authz.annotation.Logical;
|
import org.apache.shiro.authz.annotation.Logical;
|
||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
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.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
import com.ruoyi.common.annotation.Log;
|
import com.ruoyi.common.annotation.Log;
|
||||||
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
import com.ruoyi.common.core.text.Convert;
|
import com.ruoyi.common.core.text.Convert;
|
||||||
import com.ruoyi.common.enums.BusinessType;
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
import com.ruoyi.common.enums.OnlineStatus;
|
import com.ruoyi.common.enums.OnlineStatus;
|
||||||
import com.ruoyi.framework.shiro.session.OnlineSession;
|
import com.ruoyi.framework.shiro.session.OnlineSession;
|
||||||
import com.ruoyi.framework.shiro.session.OnlineSessionDAO;
|
import com.ruoyi.framework.shiro.session.OnlineSessionDAO;
|
||||||
import com.ruoyi.framework.util.ShiroUtils;
|
import com.ruoyi.framework.util.ShiroUtils;
|
||||||
import com.ruoyi.system.domain.SysUserOnline;
|
import com.ruoyi.system.domain.SysUserOnline;
|
||||||
import com.ruoyi.system.service.ISysUserOnlineService;
|
import com.ruoyi.system.service.ISysUserOnlineService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 在线用户监控
|
* 在线用户监控
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@Controller
|
@Controller
|
||||||
@RequestMapping("/monitor/online")
|
@RequestMapping("/monitor/online")
|
||||||
public class SysUserOnlineController extends BaseController
|
public class SysUserOnlineController extends BaseController
|
||||||
{
|
{
|
||||||
private String prefix = "monitor/online";
|
private String prefix = "monitor/online";
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysUserOnlineService userOnlineService;
|
private ISysUserOnlineService userOnlineService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private OnlineSessionDAO onlineSessionDAO;
|
private OnlineSessionDAO onlineSessionDAO;
|
||||||
|
|
||||||
@RequiresPermissions("monitor:online:view")
|
@RequiresPermissions("monitor:online:view")
|
||||||
@GetMapping()
|
@GetMapping()
|
||||||
public String online()
|
public String online()
|
||||||
{
|
{
|
||||||
return prefix + "/online";
|
return prefix + "/online";
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiresPermissions("monitor:online:list")
|
@RequiresPermissions("monitor:online:list")
|
||||||
@PostMapping("/list")
|
@PostMapping("/list")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public TableDataInfo list(SysUserOnline userOnline)
|
public TableDataInfo list(SysUserOnline userOnline)
|
||||||
{
|
{
|
||||||
startPage();
|
startPage();
|
||||||
List<SysUserOnline> list = userOnlineService.selectUserOnlineList(userOnline);
|
List<SysUserOnline> list = userOnlineService.selectUserOnlineList(userOnline);
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiresPermissions(value = { "monitor:online:batchForceLogout", "monitor:online:forceLogout" }, logical = Logical.OR)
|
@RequiresPermissions(value = { "monitor:online:batchForceLogout", "monitor:online:forceLogout" }, logical = Logical.OR)
|
||||||
@Log(title = "在线用户", businessType = BusinessType.FORCE)
|
@Log(title = "在线用户", businessType = BusinessType.FORCE)
|
||||||
@PostMapping("/batchForceLogout")
|
@PostMapping("/batchForceLogout")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult batchForceLogout(String ids)
|
public AjaxResult batchForceLogout(String ids)
|
||||||
{
|
{
|
||||||
for (String sessionId : Convert.toStrArray(ids))
|
for (String sessionId : Convert.toStrArray(ids))
|
||||||
{
|
{
|
||||||
SysUserOnline online = userOnlineService.selectOnlineById(sessionId);
|
SysUserOnline online = userOnlineService.selectOnlineById(sessionId);
|
||||||
if (online == null)
|
if (online == null)
|
||||||
{
|
{
|
||||||
return error("用户已下线");
|
return error("用户已下线");
|
||||||
}
|
}
|
||||||
OnlineSession onlineSession = (OnlineSession) onlineSessionDAO.readSession(online.getSessionId());
|
OnlineSession onlineSession = (OnlineSession) onlineSessionDAO.readSession(online.getSessionId());
|
||||||
if (onlineSession == null)
|
if (onlineSession == null)
|
||||||
{
|
{
|
||||||
return error("用户已下线");
|
return error("用户已下线");
|
||||||
}
|
}
|
||||||
if (sessionId.equals(ShiroUtils.getSessionId()))
|
if (sessionId.equals(ShiroUtils.getSessionId()))
|
||||||
{
|
{
|
||||||
return error("当前登陆用户无法强退");
|
return error("当前登陆用户无法强退");
|
||||||
}
|
}
|
||||||
onlineSession.setStatus(OnlineStatus.off_line);
|
onlineSession.setStatus(OnlineStatus.off_line);
|
||||||
onlineSessionDAO.update(onlineSession);
|
onlineSessionDAO.update(onlineSession);
|
||||||
online.setStatus(OnlineStatus.off_line);
|
online.setStatus(OnlineStatus.off_line);
|
||||||
userOnlineService.saveOnline(online);
|
userOnlineService.saveOnline(online);
|
||||||
}
|
}
|
||||||
return success();
|
return success();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,92 +1,92 @@
|
||||||
package com.ruoyi.web.controller.system;
|
package com.ruoyi.web.controller.system;
|
||||||
|
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
import javax.servlet.ServletOutputStream;
|
import javax.servlet.ServletOutputStream;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import javax.servlet.http.HttpSession;
|
import javax.servlet.http.HttpSession;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.servlet.ModelAndView;
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
import com.google.code.kaptcha.Constants;
|
import com.google.code.kaptcha.Constants;
|
||||||
import com.google.code.kaptcha.Producer;
|
import com.google.code.kaptcha.Producer;
|
||||||
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 图片验证码(支持算术形式)
|
* 图片验证码(支持算术形式)
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@Controller
|
@Controller
|
||||||
@RequestMapping("/captcha")
|
@RequestMapping("/captcha")
|
||||||
public class SysCaptchaController extends BaseController
|
public class SysCaptchaController extends BaseController
|
||||||
{
|
{
|
||||||
@Resource(name = "captchaProducer")
|
@Resource(name = "captchaProducer")
|
||||||
private Producer captchaProducer;
|
private Producer captchaProducer;
|
||||||
|
|
||||||
@Resource(name = "captchaProducerMath")
|
@Resource(name = "captchaProducerMath")
|
||||||
private Producer captchaProducerMath;
|
private Producer captchaProducerMath;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 验证码生成
|
* 验证码生成
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "/captchaImage")
|
@GetMapping(value = "/captchaImage")
|
||||||
public ModelAndView getKaptchaImage(HttpServletRequest request, HttpServletResponse response)
|
public ModelAndView getKaptchaImage(HttpServletRequest request, HttpServletResponse response)
|
||||||
{
|
{
|
||||||
ServletOutputStream out = null;
|
ServletOutputStream out = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
HttpSession session = request.getSession();
|
HttpSession session = request.getSession();
|
||||||
response.setDateHeader("Expires", 0);
|
response.setDateHeader("Expires", 0);
|
||||||
response.setHeader("Cache-Control", "no-store, no-cache, must-revalidate");
|
response.setHeader("Cache-Control", "no-store, no-cache, must-revalidate");
|
||||||
response.addHeader("Cache-Control", "post-check=0, pre-check=0");
|
response.addHeader("Cache-Control", "post-check=0, pre-check=0");
|
||||||
response.setHeader("Pragma", "no-cache");
|
response.setHeader("Pragma", "no-cache");
|
||||||
response.setContentType("image/jpeg");
|
response.setContentType("image/jpeg");
|
||||||
|
|
||||||
String type = request.getParameter("type");
|
String type = request.getParameter("type");
|
||||||
String capStr = null;
|
String capStr = null;
|
||||||
String code = null;
|
String code = null;
|
||||||
BufferedImage bi = null;
|
BufferedImage bi = null;
|
||||||
if ("math".equals(type))
|
if ("math".equals(type))
|
||||||
{
|
{
|
||||||
String capText = captchaProducerMath.createText();
|
String capText = captchaProducerMath.createText();
|
||||||
capStr = capText.substring(0, capText.lastIndexOf("@"));
|
capStr = capText.substring(0, capText.lastIndexOf("@"));
|
||||||
code = capText.substring(capText.lastIndexOf("@") + 1);
|
code = capText.substring(capText.lastIndexOf("@") + 1);
|
||||||
bi = captchaProducerMath.createImage(capStr);
|
bi = captchaProducerMath.createImage(capStr);
|
||||||
}
|
}
|
||||||
else if ("char".equals(type))
|
else if ("char".equals(type))
|
||||||
{
|
{
|
||||||
capStr = code = captchaProducer.createText();
|
capStr = code = captchaProducer.createText();
|
||||||
bi = captchaProducer.createImage(capStr);
|
bi = captchaProducer.createImage(capStr);
|
||||||
}
|
}
|
||||||
session.setAttribute(Constants.KAPTCHA_SESSION_KEY, code);
|
session.setAttribute(Constants.KAPTCHA_SESSION_KEY, code);
|
||||||
out = response.getOutputStream();
|
out = response.getOutputStream();
|
||||||
ImageIO.write(bi, "jpg", out);
|
ImageIO.write(bi, "jpg", out);
|
||||||
out.flush();
|
out.flush();
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (out != null)
|
if (out != null)
|
||||||
{
|
{
|
||||||
out.close();
|
out.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,157 +1,157 @@
|
||||||
package com.ruoyi.web.controller.system;
|
package com.ruoyi.web.controller.system;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.ModelMap;
|
import org.springframework.ui.ModelMap;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
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.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
import com.ruoyi.common.annotation.Log;
|
import com.ruoyi.common.annotation.Log;
|
||||||
import com.ruoyi.common.constant.UserConstants;
|
import com.ruoyi.common.constant.UserConstants;
|
||||||
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
import com.ruoyi.common.enums.BusinessType;
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||||
import com.ruoyi.framework.util.ShiroUtils;
|
import com.ruoyi.framework.util.ShiroUtils;
|
||||||
import com.ruoyi.system.domain.SysConfig;
|
import com.ruoyi.system.domain.SysConfig;
|
||||||
import com.ruoyi.system.service.ISysConfigService;
|
import com.ruoyi.system.service.ISysConfigService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 参数配置 信息操作处理
|
* 参数配置 信息操作处理
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@Controller
|
@Controller
|
||||||
@RequestMapping("/system/config")
|
@RequestMapping("/system/config")
|
||||||
public class SysConfigController extends BaseController
|
public class SysConfigController extends BaseController
|
||||||
{
|
{
|
||||||
private String prefix = "system/config";
|
private String prefix = "system/config";
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysConfigService configService;
|
private ISysConfigService configService;
|
||||||
|
|
||||||
@RequiresPermissions("system:config:view")
|
@RequiresPermissions("system:config:view")
|
||||||
@GetMapping()
|
@GetMapping()
|
||||||
public String config()
|
public String config()
|
||||||
{
|
{
|
||||||
return prefix + "/config";
|
return prefix + "/config";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询参数配置列表
|
* 查询参数配置列表
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("system:config:list")
|
@RequiresPermissions("system:config:list")
|
||||||
@PostMapping("/list")
|
@PostMapping("/list")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public TableDataInfo list(SysConfig config)
|
public TableDataInfo list(SysConfig config)
|
||||||
{
|
{
|
||||||
startPage();
|
startPage();
|
||||||
List<SysConfig> list = configService.selectConfigList(config);
|
List<SysConfig> list = configService.selectConfigList(config);
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Log(title = "参数管理", businessType = BusinessType.EXPORT)
|
@Log(title = "参数管理", businessType = BusinessType.EXPORT)
|
||||||
@RequiresPermissions("system:config:export")
|
@RequiresPermissions("system:config:export")
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult export(SysConfig config)
|
public AjaxResult export(SysConfig config)
|
||||||
{
|
{
|
||||||
List<SysConfig> list = configService.selectConfigList(config);
|
List<SysConfig> list = configService.selectConfigList(config);
|
||||||
ExcelUtil<SysConfig> util = new ExcelUtil<SysConfig>(SysConfig.class);
|
ExcelUtil<SysConfig> util = new ExcelUtil<SysConfig>(SysConfig.class);
|
||||||
return util.exportExcel(list, "参数数据");
|
return util.exportExcel(list, "参数数据");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增参数配置
|
* 新增参数配置
|
||||||
*/
|
*/
|
||||||
@GetMapping("/add")
|
@GetMapping("/add")
|
||||||
public String add()
|
public String add()
|
||||||
{
|
{
|
||||||
return prefix + "/add";
|
return prefix + "/add";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增保存参数配置
|
* 新增保存参数配置
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("system:config:add")
|
@RequiresPermissions("system:config:add")
|
||||||
@Log(title = "参数管理", businessType = BusinessType.INSERT)
|
@Log(title = "参数管理", businessType = BusinessType.INSERT)
|
||||||
@PostMapping("/add")
|
@PostMapping("/add")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult addSave(@Validated SysConfig config)
|
public AjaxResult addSave(@Validated SysConfig config)
|
||||||
{
|
{
|
||||||
if (UserConstants.CONFIG_KEY_NOT_UNIQUE.equals(configService.checkConfigKeyUnique(config)))
|
if (UserConstants.CONFIG_KEY_NOT_UNIQUE.equals(configService.checkConfigKeyUnique(config)))
|
||||||
{
|
{
|
||||||
return error("新增参数'" + config.getConfigName() + "'失败,参数键名已存在");
|
return error("新增参数'" + config.getConfigName() + "'失败,参数键名已存在");
|
||||||
}
|
}
|
||||||
config.setCreateBy(ShiroUtils.getLoginName());
|
config.setCreateBy(ShiroUtils.getLoginName());
|
||||||
return toAjax(configService.insertConfig(config));
|
return toAjax(configService.insertConfig(config));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改参数配置
|
* 修改参数配置
|
||||||
*/
|
*/
|
||||||
@GetMapping("/edit/{configId}")
|
@GetMapping("/edit/{configId}")
|
||||||
public String edit(@PathVariable("configId") Long configId, ModelMap mmap)
|
public String edit(@PathVariable("configId") Long configId, ModelMap mmap)
|
||||||
{
|
{
|
||||||
mmap.put("config", configService.selectConfigById(configId));
|
mmap.put("config", configService.selectConfigById(configId));
|
||||||
return prefix + "/edit";
|
return prefix + "/edit";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改保存参数配置
|
* 修改保存参数配置
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("system:config:edit")
|
@RequiresPermissions("system:config:edit")
|
||||||
@Log(title = "参数管理", businessType = BusinessType.UPDATE)
|
@Log(title = "参数管理", businessType = BusinessType.UPDATE)
|
||||||
@PostMapping("/edit")
|
@PostMapping("/edit")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult editSave(@Validated SysConfig config)
|
public AjaxResult editSave(@Validated SysConfig config)
|
||||||
{
|
{
|
||||||
if (UserConstants.CONFIG_KEY_NOT_UNIQUE.equals(configService.checkConfigKeyUnique(config)))
|
if (UserConstants.CONFIG_KEY_NOT_UNIQUE.equals(configService.checkConfigKeyUnique(config)))
|
||||||
{
|
{
|
||||||
return error("修改参数'" + config.getConfigName() + "'失败,参数键名已存在");
|
return error("修改参数'" + config.getConfigName() + "'失败,参数键名已存在");
|
||||||
}
|
}
|
||||||
config.setUpdateBy(ShiroUtils.getLoginName());
|
config.setUpdateBy(ShiroUtils.getLoginName());
|
||||||
return toAjax(configService.updateConfig(config));
|
return toAjax(configService.updateConfig(config));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除参数配置
|
* 删除参数配置
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("system:config:remove")
|
@RequiresPermissions("system:config:remove")
|
||||||
@Log(title = "参数管理", businessType = BusinessType.DELETE)
|
@Log(title = "参数管理", businessType = BusinessType.DELETE)
|
||||||
@PostMapping("/remove")
|
@PostMapping("/remove")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult remove(String ids)
|
public AjaxResult remove(String ids)
|
||||||
{
|
{
|
||||||
return toAjax(configService.deleteConfigByIds(ids));
|
return toAjax(configService.deleteConfigByIds(ids));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 清空缓存
|
* 清空缓存
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("system:config:remove")
|
@RequiresPermissions("system:config:remove")
|
||||||
@Log(title = "参数管理", businessType = BusinessType.CLEAN)
|
@Log(title = "参数管理", businessType = BusinessType.CLEAN)
|
||||||
@GetMapping("/clearCache")
|
@GetMapping("/clearCache")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult clearCache()
|
public AjaxResult clearCache()
|
||||||
{
|
{
|
||||||
configService.clearCache();
|
configService.clearCache();
|
||||||
return success();
|
return success();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 校验参数键名
|
* 校验参数键名
|
||||||
*/
|
*/
|
||||||
@PostMapping("/checkConfigKeyUnique")
|
@PostMapping("/checkConfigKeyUnique")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String checkConfigKeyUnique(SysConfig config)
|
public String checkConfigKeyUnique(SysConfig config)
|
||||||
{
|
{
|
||||||
return configService.checkConfigKeyUnique(config);
|
return configService.checkConfigKeyUnique(config);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,203 +1,203 @@
|
||||||
package com.ruoyi.web.controller.system;
|
package com.ruoyi.web.controller.system;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.ModelMap;
|
import org.springframework.ui.ModelMap;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
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.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
import com.ruoyi.common.annotation.Log;
|
import com.ruoyi.common.annotation.Log;
|
||||||
import com.ruoyi.common.constant.UserConstants;
|
import com.ruoyi.common.constant.UserConstants;
|
||||||
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
import com.ruoyi.common.core.domain.Ztree;
|
import com.ruoyi.common.core.domain.Ztree;
|
||||||
import com.ruoyi.common.enums.BusinessType;
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
import com.ruoyi.framework.util.ShiroUtils;
|
import com.ruoyi.framework.util.ShiroUtils;
|
||||||
import com.ruoyi.system.domain.SysDept;
|
import com.ruoyi.system.domain.SysDept;
|
||||||
import com.ruoyi.system.domain.SysRole;
|
import com.ruoyi.system.domain.SysRole;
|
||||||
import com.ruoyi.system.service.ISysDeptService;
|
import com.ruoyi.system.service.ISysDeptService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 部门信息
|
* 部门信息
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@Controller
|
@Controller
|
||||||
@RequestMapping("/system/dept")
|
@RequestMapping("/system/dept")
|
||||||
public class SysDeptController extends BaseController
|
public class SysDeptController extends BaseController
|
||||||
{
|
{
|
||||||
private String prefix = "system/dept";
|
private String prefix = "system/dept";
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysDeptService deptService;
|
private ISysDeptService deptService;
|
||||||
|
|
||||||
@RequiresPermissions("system:dept:view")
|
@RequiresPermissions("system:dept:view")
|
||||||
@GetMapping()
|
@GetMapping()
|
||||||
public String dept()
|
public String dept()
|
||||||
{
|
{
|
||||||
return prefix + "/dept";
|
return prefix + "/dept";
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiresPermissions("system:dept:list")
|
@RequiresPermissions("system:dept:list")
|
||||||
@PostMapping("/list")
|
@PostMapping("/list")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public List<SysDept> list(SysDept dept)
|
public List<SysDept> list(SysDept dept)
|
||||||
{
|
{
|
||||||
List<SysDept> deptList = deptService.selectDeptList(dept);
|
List<SysDept> deptList = deptService.selectDeptList(dept);
|
||||||
return deptList;
|
return deptList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增部门
|
* 新增部门
|
||||||
*/
|
*/
|
||||||
@GetMapping("/add/{parentId}")
|
@GetMapping("/add/{parentId}")
|
||||||
public String add(@PathVariable("parentId") Long parentId, ModelMap mmap)
|
public String add(@PathVariable("parentId") Long parentId, ModelMap mmap)
|
||||||
{
|
{
|
||||||
mmap.put("dept", deptService.selectDeptById(parentId));
|
mmap.put("dept", deptService.selectDeptById(parentId));
|
||||||
return prefix + "/add";
|
return prefix + "/add";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增保存部门
|
* 新增保存部门
|
||||||
*/
|
*/
|
||||||
@Log(title = "部门管理", businessType = BusinessType.INSERT)
|
@Log(title = "部门管理", businessType = BusinessType.INSERT)
|
||||||
@RequiresPermissions("system:dept:add")
|
@RequiresPermissions("system:dept:add")
|
||||||
@PostMapping("/add")
|
@PostMapping("/add")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult addSave(@Validated SysDept dept)
|
public AjaxResult addSave(@Validated SysDept dept)
|
||||||
{
|
{
|
||||||
if (UserConstants.DEPT_NAME_NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept)))
|
if (UserConstants.DEPT_NAME_NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept)))
|
||||||
{
|
{
|
||||||
return error("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在");
|
return error("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在");
|
||||||
}
|
}
|
||||||
dept.setCreateBy(ShiroUtils.getLoginName());
|
dept.setCreateBy(ShiroUtils.getLoginName());
|
||||||
return toAjax(deptService.insertDept(dept));
|
return toAjax(deptService.insertDept(dept));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改
|
* 修改
|
||||||
*/
|
*/
|
||||||
@GetMapping("/edit/{deptId}")
|
@GetMapping("/edit/{deptId}")
|
||||||
public String edit(@PathVariable("deptId") Long deptId, ModelMap mmap)
|
public String edit(@PathVariable("deptId") Long deptId, ModelMap mmap)
|
||||||
{
|
{
|
||||||
SysDept dept = deptService.selectDeptById(deptId);
|
SysDept dept = deptService.selectDeptById(deptId);
|
||||||
if (StringUtils.isNotNull(dept) && 100L == deptId)
|
if (StringUtils.isNotNull(dept) && 100L == deptId)
|
||||||
{
|
{
|
||||||
dept.setParentName("无");
|
dept.setParentName("无");
|
||||||
}
|
}
|
||||||
mmap.put("dept", dept);
|
mmap.put("dept", dept);
|
||||||
return prefix + "/edit";
|
return prefix + "/edit";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存
|
* 保存
|
||||||
*/
|
*/
|
||||||
@Log(title = "部门管理", businessType = BusinessType.UPDATE)
|
@Log(title = "部门管理", businessType = BusinessType.UPDATE)
|
||||||
@RequiresPermissions("system:dept:edit")
|
@RequiresPermissions("system:dept:edit")
|
||||||
@PostMapping("/edit")
|
@PostMapping("/edit")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult editSave(@Validated SysDept dept)
|
public AjaxResult editSave(@Validated SysDept dept)
|
||||||
{
|
{
|
||||||
if (UserConstants.DEPT_NAME_NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept)))
|
if (UserConstants.DEPT_NAME_NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept)))
|
||||||
{
|
{
|
||||||
return error("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在");
|
return error("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在");
|
||||||
}
|
}
|
||||||
else if (dept.getParentId().equals(dept.getDeptId()))
|
else if (dept.getParentId().equals(dept.getDeptId()))
|
||||||
{
|
{
|
||||||
return error("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己");
|
return error("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己");
|
||||||
}
|
}
|
||||||
else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus())
|
else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus())
|
||||||
&& deptService.selectNormalChildrenDeptById(dept.getDeptId()) > 0)
|
&& deptService.selectNormalChildrenDeptById(dept.getDeptId()) > 0)
|
||||||
{
|
{
|
||||||
return AjaxResult.error("该部门包含未停用的子部门!");
|
return AjaxResult.error("该部门包含未停用的子部门!");
|
||||||
}
|
}
|
||||||
dept.setUpdateBy(ShiroUtils.getLoginName());
|
dept.setUpdateBy(ShiroUtils.getLoginName());
|
||||||
return toAjax(deptService.updateDept(dept));
|
return toAjax(deptService.updateDept(dept));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除
|
* 删除
|
||||||
*/
|
*/
|
||||||
@Log(title = "部门管理", businessType = BusinessType.DELETE)
|
@Log(title = "部门管理", businessType = BusinessType.DELETE)
|
||||||
@RequiresPermissions("system:dept:remove")
|
@RequiresPermissions("system:dept:remove")
|
||||||
@GetMapping("/remove/{deptId}")
|
@GetMapping("/remove/{deptId}")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult remove(@PathVariable("deptId") Long deptId)
|
public AjaxResult remove(@PathVariable("deptId") Long deptId)
|
||||||
{
|
{
|
||||||
if (deptService.selectDeptCount(deptId) > 0)
|
if (deptService.selectDeptCount(deptId) > 0)
|
||||||
{
|
{
|
||||||
return AjaxResult.warn("存在下级部门,不允许删除");
|
return AjaxResult.warn("存在下级部门,不允许删除");
|
||||||
}
|
}
|
||||||
if (deptService.checkDeptExistUser(deptId))
|
if (deptService.checkDeptExistUser(deptId))
|
||||||
{
|
{
|
||||||
return AjaxResult.warn("部门存在用户,不允许删除");
|
return AjaxResult.warn("部门存在用户,不允许删除");
|
||||||
}
|
}
|
||||||
return toAjax(deptService.deleteDeptById(deptId));
|
return toAjax(deptService.deleteDeptById(deptId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 校验部门名称
|
* 校验部门名称
|
||||||
*/
|
*/
|
||||||
@PostMapping("/checkDeptNameUnique")
|
@PostMapping("/checkDeptNameUnique")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String checkDeptNameUnique(SysDept dept)
|
public String checkDeptNameUnique(SysDept dept)
|
||||||
{
|
{
|
||||||
return deptService.checkDeptNameUnique(dept);
|
return deptService.checkDeptNameUnique(dept);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 选择部门树
|
* 选择部门树
|
||||||
*
|
*
|
||||||
* @param deptId 部门ID
|
* @param deptId 部门ID
|
||||||
* @param excludeId 排除ID
|
* @param excludeId 排除ID
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = { "/selectDeptTree/{deptId}", "/selectDeptTree/{deptId}/{excludeId}" })
|
@GetMapping(value = { "/selectDeptTree/{deptId}", "/selectDeptTree/{deptId}/{excludeId}" })
|
||||||
public String selectDeptTree(@PathVariable("deptId") Long deptId,
|
public String selectDeptTree(@PathVariable("deptId") Long deptId,
|
||||||
@PathVariable(value = "excludeId", required = false) String excludeId, ModelMap mmap)
|
@PathVariable(value = "excludeId", required = false) String excludeId, ModelMap mmap)
|
||||||
{
|
{
|
||||||
mmap.put("dept", deptService.selectDeptById(deptId));
|
mmap.put("dept", deptService.selectDeptById(deptId));
|
||||||
mmap.put("excludeId", excludeId);
|
mmap.put("excludeId", excludeId);
|
||||||
return prefix + "/tree";
|
return prefix + "/tree";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 加载部门列表树
|
* 加载部门列表树
|
||||||
*/
|
*/
|
||||||
@GetMapping("/treeData")
|
@GetMapping("/treeData")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public List<Ztree> treeData()
|
public List<Ztree> treeData()
|
||||||
{
|
{
|
||||||
List<Ztree> ztrees = deptService.selectDeptTree(new SysDept());
|
List<Ztree> ztrees = deptService.selectDeptTree(new SysDept());
|
||||||
return ztrees;
|
return ztrees;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 加载部门列表树(排除下级)
|
* 加载部门列表树(排除下级)
|
||||||
*/
|
*/
|
||||||
@GetMapping("/treeData/{excludeId}")
|
@GetMapping("/treeData/{excludeId}")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public List<Ztree> treeDataExcludeChild(@PathVariable(value = "excludeId", required = false) Long excludeId)
|
public List<Ztree> treeDataExcludeChild(@PathVariable(value = "excludeId", required = false) Long excludeId)
|
||||||
{
|
{
|
||||||
SysDept dept = new SysDept();
|
SysDept dept = new SysDept();
|
||||||
dept.setDeptId(excludeId);
|
dept.setDeptId(excludeId);
|
||||||
List<Ztree> ztrees = deptService.selectDeptTreeExcludeChild(dept);
|
List<Ztree> ztrees = deptService.selectDeptTreeExcludeChild(dept);
|
||||||
return ztrees;
|
return ztrees;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 加载角色部门(数据权限)列表树
|
* 加载角色部门(数据权限)列表树
|
||||||
*/
|
*/
|
||||||
@GetMapping("/roleDeptTreeData")
|
@GetMapping("/roleDeptTreeData")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public List<Ztree> deptTreeData(SysRole role)
|
public List<Ztree> deptTreeData(SysRole role)
|
||||||
{
|
{
|
||||||
List<Ztree> ztrees = deptService.roleDeptTreeData(role);
|
List<Ztree> ztrees = deptService.roleDeptTreeData(role);
|
||||||
return ztrees;
|
return ztrees;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,120 +1,120 @@
|
||||||
package com.ruoyi.web.controller.system;
|
package com.ruoyi.web.controller.system;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.ModelMap;
|
import org.springframework.ui.ModelMap;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
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.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
import com.ruoyi.common.annotation.Log;
|
import com.ruoyi.common.annotation.Log;
|
||||||
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
import com.ruoyi.common.enums.BusinessType;
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||||
import com.ruoyi.framework.util.ShiroUtils;
|
import com.ruoyi.framework.util.ShiroUtils;
|
||||||
import com.ruoyi.system.domain.SysDictData;
|
import com.ruoyi.system.domain.SysDictData;
|
||||||
import com.ruoyi.system.service.ISysDictDataService;
|
import com.ruoyi.system.service.ISysDictDataService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数据字典信息
|
* 数据字典信息
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@Controller
|
@Controller
|
||||||
@RequestMapping("/system/dict/data")
|
@RequestMapping("/system/dict/data")
|
||||||
public class SysDictDataController extends BaseController
|
public class SysDictDataController extends BaseController
|
||||||
{
|
{
|
||||||
private String prefix = "system/dict/data";
|
private String prefix = "system/dict/data";
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysDictDataService dictDataService;
|
private ISysDictDataService dictDataService;
|
||||||
|
|
||||||
@RequiresPermissions("system:dict:view")
|
@RequiresPermissions("system:dict:view")
|
||||||
@GetMapping()
|
@GetMapping()
|
||||||
public String dictData()
|
public String dictData()
|
||||||
{
|
{
|
||||||
return prefix + "/data";
|
return prefix + "/data";
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/list")
|
@PostMapping("/list")
|
||||||
@RequiresPermissions("system:dict:list")
|
@RequiresPermissions("system:dict:list")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public TableDataInfo list(SysDictData dictData)
|
public TableDataInfo list(SysDictData dictData)
|
||||||
{
|
{
|
||||||
startPage();
|
startPage();
|
||||||
List<SysDictData> list = dictDataService.selectDictDataList(dictData);
|
List<SysDictData> list = dictDataService.selectDictDataList(dictData);
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Log(title = "字典数据", businessType = BusinessType.EXPORT)
|
@Log(title = "字典数据", businessType = BusinessType.EXPORT)
|
||||||
@RequiresPermissions("system:dict:export")
|
@RequiresPermissions("system:dict:export")
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult export(SysDictData dictData)
|
public AjaxResult export(SysDictData dictData)
|
||||||
{
|
{
|
||||||
List<SysDictData> list = dictDataService.selectDictDataList(dictData);
|
List<SysDictData> list = dictDataService.selectDictDataList(dictData);
|
||||||
ExcelUtil<SysDictData> util = new ExcelUtil<SysDictData>(SysDictData.class);
|
ExcelUtil<SysDictData> util = new ExcelUtil<SysDictData>(SysDictData.class);
|
||||||
return util.exportExcel(list, "字典数据");
|
return util.exportExcel(list, "字典数据");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增字典类型
|
* 新增字典类型
|
||||||
*/
|
*/
|
||||||
@GetMapping("/add/{dictType}")
|
@GetMapping("/add/{dictType}")
|
||||||
public String add(@PathVariable("dictType") String dictType, ModelMap mmap)
|
public String add(@PathVariable("dictType") String dictType, ModelMap mmap)
|
||||||
{
|
{
|
||||||
mmap.put("dictType", dictType);
|
mmap.put("dictType", dictType);
|
||||||
return prefix + "/add";
|
return prefix + "/add";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增保存字典类型
|
* 新增保存字典类型
|
||||||
*/
|
*/
|
||||||
@Log(title = "字典数据", businessType = BusinessType.INSERT)
|
@Log(title = "字典数据", businessType = BusinessType.INSERT)
|
||||||
@RequiresPermissions("system:dict:add")
|
@RequiresPermissions("system:dict:add")
|
||||||
@PostMapping("/add")
|
@PostMapping("/add")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult addSave(@Validated SysDictData dict)
|
public AjaxResult addSave(@Validated SysDictData dict)
|
||||||
{
|
{
|
||||||
dict.setCreateBy(ShiroUtils.getLoginName());
|
dict.setCreateBy(ShiroUtils.getLoginName());
|
||||||
return toAjax(dictDataService.insertDictData(dict));
|
return toAjax(dictDataService.insertDictData(dict));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改字典类型
|
* 修改字典类型
|
||||||
*/
|
*/
|
||||||
@GetMapping("/edit/{dictCode}")
|
@GetMapping("/edit/{dictCode}")
|
||||||
public String edit(@PathVariable("dictCode") Long dictCode, ModelMap mmap)
|
public String edit(@PathVariable("dictCode") Long dictCode, ModelMap mmap)
|
||||||
{
|
{
|
||||||
mmap.put("dict", dictDataService.selectDictDataById(dictCode));
|
mmap.put("dict", dictDataService.selectDictDataById(dictCode));
|
||||||
return prefix + "/edit";
|
return prefix + "/edit";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改保存字典类型
|
* 修改保存字典类型
|
||||||
*/
|
*/
|
||||||
@Log(title = "字典数据", businessType = BusinessType.UPDATE)
|
@Log(title = "字典数据", businessType = BusinessType.UPDATE)
|
||||||
@RequiresPermissions("system:dict:edit")
|
@RequiresPermissions("system:dict:edit")
|
||||||
@PostMapping("/edit")
|
@PostMapping("/edit")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult editSave(@Validated SysDictData dict)
|
public AjaxResult editSave(@Validated SysDictData dict)
|
||||||
{
|
{
|
||||||
dict.setUpdateBy(ShiroUtils.getLoginName());
|
dict.setUpdateBy(ShiroUtils.getLoginName());
|
||||||
return toAjax(dictDataService.updateDictData(dict));
|
return toAjax(dictDataService.updateDictData(dict));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Log(title = "字典数据", businessType = BusinessType.DELETE)
|
@Log(title = "字典数据", businessType = BusinessType.DELETE)
|
||||||
@RequiresPermissions("system:dict:remove")
|
@RequiresPermissions("system:dict:remove")
|
||||||
@PostMapping("/remove")
|
@PostMapping("/remove")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult remove(String ids)
|
public AjaxResult remove(String ids)
|
||||||
{
|
{
|
||||||
return toAjax(dictDataService.deleteDictDataByIds(ids));
|
return toAjax(dictDataService.deleteDictDataByIds(ids));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,188 +1,188 @@
|
||||||
package com.ruoyi.web.controller.system;
|
package com.ruoyi.web.controller.system;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.ModelMap;
|
import org.springframework.ui.ModelMap;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
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.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
import com.ruoyi.common.annotation.Log;
|
import com.ruoyi.common.annotation.Log;
|
||||||
import com.ruoyi.common.constant.UserConstants;
|
import com.ruoyi.common.constant.UserConstants;
|
||||||
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
import com.ruoyi.common.core.domain.Ztree;
|
import com.ruoyi.common.core.domain.Ztree;
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
import com.ruoyi.common.enums.BusinessType;
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||||
import com.ruoyi.framework.util.ShiroUtils;
|
import com.ruoyi.framework.util.ShiroUtils;
|
||||||
import com.ruoyi.system.domain.SysDictType;
|
import com.ruoyi.system.domain.SysDictType;
|
||||||
import com.ruoyi.system.service.ISysDictTypeService;
|
import com.ruoyi.system.service.ISysDictTypeService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数据字典信息
|
* 数据字典信息
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@Controller
|
@Controller
|
||||||
@RequestMapping("/system/dict")
|
@RequestMapping("/system/dict")
|
||||||
public class SysDictTypeController extends BaseController
|
public class SysDictTypeController extends BaseController
|
||||||
{
|
{
|
||||||
private String prefix = "system/dict/type";
|
private String prefix = "system/dict/type";
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysDictTypeService dictTypeService;
|
private ISysDictTypeService dictTypeService;
|
||||||
|
|
||||||
@RequiresPermissions("system:dict:view")
|
@RequiresPermissions("system:dict:view")
|
||||||
@GetMapping()
|
@GetMapping()
|
||||||
public String dictType()
|
public String dictType()
|
||||||
{
|
{
|
||||||
return prefix + "/type";
|
return prefix + "/type";
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/list")
|
@PostMapping("/list")
|
||||||
@RequiresPermissions("system:dict:list")
|
@RequiresPermissions("system:dict:list")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public TableDataInfo list(SysDictType dictType)
|
public TableDataInfo list(SysDictType dictType)
|
||||||
{
|
{
|
||||||
startPage();
|
startPage();
|
||||||
List<SysDictType> list = dictTypeService.selectDictTypeList(dictType);
|
List<SysDictType> list = dictTypeService.selectDictTypeList(dictType);
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Log(title = "字典类型", businessType = BusinessType.EXPORT)
|
@Log(title = "字典类型", businessType = BusinessType.EXPORT)
|
||||||
@RequiresPermissions("system:dict:export")
|
@RequiresPermissions("system:dict:export")
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult export(SysDictType dictType)
|
public AjaxResult export(SysDictType dictType)
|
||||||
{
|
{
|
||||||
|
|
||||||
List<SysDictType> list = dictTypeService.selectDictTypeList(dictType);
|
List<SysDictType> list = dictTypeService.selectDictTypeList(dictType);
|
||||||
ExcelUtil<SysDictType> util = new ExcelUtil<SysDictType>(SysDictType.class);
|
ExcelUtil<SysDictType> util = new ExcelUtil<SysDictType>(SysDictType.class);
|
||||||
return util.exportExcel(list, "字典类型");
|
return util.exportExcel(list, "字典类型");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增字典类型
|
* 新增字典类型
|
||||||
*/
|
*/
|
||||||
@GetMapping("/add")
|
@GetMapping("/add")
|
||||||
public String add()
|
public String add()
|
||||||
{
|
{
|
||||||
return prefix + "/add";
|
return prefix + "/add";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增保存字典类型
|
* 新增保存字典类型
|
||||||
*/
|
*/
|
||||||
@Log(title = "字典类型", businessType = BusinessType.INSERT)
|
@Log(title = "字典类型", businessType = BusinessType.INSERT)
|
||||||
@RequiresPermissions("system:dict:add")
|
@RequiresPermissions("system:dict:add")
|
||||||
@PostMapping("/add")
|
@PostMapping("/add")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult addSave(@Validated SysDictType dict)
|
public AjaxResult addSave(@Validated SysDictType dict)
|
||||||
{
|
{
|
||||||
if (UserConstants.DICT_TYPE_NOT_UNIQUE.equals(dictTypeService.checkDictTypeUnique(dict)))
|
if (UserConstants.DICT_TYPE_NOT_UNIQUE.equals(dictTypeService.checkDictTypeUnique(dict)))
|
||||||
{
|
{
|
||||||
return error("新增字典'" + dict.getDictName() + "'失败,字典类型已存在");
|
return error("新增字典'" + dict.getDictName() + "'失败,字典类型已存在");
|
||||||
}
|
}
|
||||||
dict.setCreateBy(ShiroUtils.getLoginName());
|
dict.setCreateBy(ShiroUtils.getLoginName());
|
||||||
return toAjax(dictTypeService.insertDictType(dict));
|
return toAjax(dictTypeService.insertDictType(dict));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改字典类型
|
* 修改字典类型
|
||||||
*/
|
*/
|
||||||
@GetMapping("/edit/{dictId}")
|
@GetMapping("/edit/{dictId}")
|
||||||
public String edit(@PathVariable("dictId") Long dictId, ModelMap mmap)
|
public String edit(@PathVariable("dictId") Long dictId, ModelMap mmap)
|
||||||
{
|
{
|
||||||
mmap.put("dict", dictTypeService.selectDictTypeById(dictId));
|
mmap.put("dict", dictTypeService.selectDictTypeById(dictId));
|
||||||
return prefix + "/edit";
|
return prefix + "/edit";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改保存字典类型
|
* 修改保存字典类型
|
||||||
*/
|
*/
|
||||||
@Log(title = "字典类型", businessType = BusinessType.UPDATE)
|
@Log(title = "字典类型", businessType = BusinessType.UPDATE)
|
||||||
@RequiresPermissions("system:dict:edit")
|
@RequiresPermissions("system:dict:edit")
|
||||||
@PostMapping("/edit")
|
@PostMapping("/edit")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult editSave(@Validated SysDictType dict)
|
public AjaxResult editSave(@Validated SysDictType dict)
|
||||||
{
|
{
|
||||||
if (UserConstants.DICT_TYPE_NOT_UNIQUE.equals(dictTypeService.checkDictTypeUnique(dict)))
|
if (UserConstants.DICT_TYPE_NOT_UNIQUE.equals(dictTypeService.checkDictTypeUnique(dict)))
|
||||||
{
|
{
|
||||||
return error("修改字典'" + dict.getDictName() + "'失败,字典类型已存在");
|
return error("修改字典'" + dict.getDictName() + "'失败,字典类型已存在");
|
||||||
}
|
}
|
||||||
dict.setUpdateBy(ShiroUtils.getLoginName());
|
dict.setUpdateBy(ShiroUtils.getLoginName());
|
||||||
return toAjax(dictTypeService.updateDictType(dict));
|
return toAjax(dictTypeService.updateDictType(dict));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Log(title = "字典类型", businessType = BusinessType.DELETE)
|
@Log(title = "字典类型", businessType = BusinessType.DELETE)
|
||||||
@RequiresPermissions("system:dict:remove")
|
@RequiresPermissions("system:dict:remove")
|
||||||
@PostMapping("/remove")
|
@PostMapping("/remove")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult remove(String ids)
|
public AjaxResult remove(String ids)
|
||||||
{
|
{
|
||||||
return toAjax(dictTypeService.deleteDictTypeByIds(ids));
|
return toAjax(dictTypeService.deleteDictTypeByIds(ids));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 清空缓存
|
* 清空缓存
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("system:dict:remove")
|
@RequiresPermissions("system:dict:remove")
|
||||||
@Log(title = "字典类型", businessType = BusinessType.CLEAN)
|
@Log(title = "字典类型", businessType = BusinessType.CLEAN)
|
||||||
@GetMapping("/clearCache")
|
@GetMapping("/clearCache")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult clearCache()
|
public AjaxResult clearCache()
|
||||||
{
|
{
|
||||||
dictTypeService.clearCache();
|
dictTypeService.clearCache();
|
||||||
return success();
|
return success();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询字典详细
|
* 查询字典详细
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("system:dict:list")
|
@RequiresPermissions("system:dict:list")
|
||||||
@GetMapping("/detail/{dictId}")
|
@GetMapping("/detail/{dictId}")
|
||||||
public String detail(@PathVariable("dictId") Long dictId, ModelMap mmap)
|
public String detail(@PathVariable("dictId") Long dictId, ModelMap mmap)
|
||||||
{
|
{
|
||||||
mmap.put("dict", dictTypeService.selectDictTypeById(dictId));
|
mmap.put("dict", dictTypeService.selectDictTypeById(dictId));
|
||||||
mmap.put("dictList", dictTypeService.selectDictTypeAll());
|
mmap.put("dictList", dictTypeService.selectDictTypeAll());
|
||||||
return "system/dict/data/data";
|
return "system/dict/data/data";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 校验字典类型
|
* 校验字典类型
|
||||||
*/
|
*/
|
||||||
@PostMapping("/checkDictTypeUnique")
|
@PostMapping("/checkDictTypeUnique")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String checkDictTypeUnique(SysDictType dictType)
|
public String checkDictTypeUnique(SysDictType dictType)
|
||||||
{
|
{
|
||||||
return dictTypeService.checkDictTypeUnique(dictType);
|
return dictTypeService.checkDictTypeUnique(dictType);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 选择字典树
|
* 选择字典树
|
||||||
*/
|
*/
|
||||||
@GetMapping("/selectDictTree/{columnId}/{dictType}")
|
@GetMapping("/selectDictTree/{columnId}/{dictType}")
|
||||||
public String selectDeptTree(@PathVariable("columnId") Long columnId, @PathVariable("dictType") String dictType,
|
public String selectDeptTree(@PathVariable("columnId") Long columnId, @PathVariable("dictType") String dictType,
|
||||||
ModelMap mmap)
|
ModelMap mmap)
|
||||||
{
|
{
|
||||||
mmap.put("columnId", columnId);
|
mmap.put("columnId", columnId);
|
||||||
mmap.put("dict", dictTypeService.selectDictTypeByType(dictType));
|
mmap.put("dict", dictTypeService.selectDictTypeByType(dictType));
|
||||||
return prefix + "/tree";
|
return prefix + "/tree";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 加载字典列表树
|
* 加载字典列表树
|
||||||
*/
|
*/
|
||||||
@GetMapping("/treeData")
|
@GetMapping("/treeData")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public List<Ztree> treeData()
|
public List<Ztree> treeData()
|
||||||
{
|
{
|
||||||
List<Ztree> ztrees = dictTypeService.selectDictTree(new SysDictType());
|
List<Ztree> ztrees = dictTypeService.selectDictTree(new SysDictType());
|
||||||
return ztrees;
|
return ztrees;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,61 +1,61 @@
|
||||||
package com.ruoyi.web.controller.system;
|
package com.ruoyi.web.controller.system;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.ModelMap;
|
import org.springframework.ui.ModelMap;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import com.ruoyi.common.config.Global;
|
import com.ruoyi.common.config.Global;
|
||||||
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
import com.ruoyi.framework.util.ShiroUtils;
|
import com.ruoyi.framework.util.ShiroUtils;
|
||||||
import com.ruoyi.system.domain.SysMenu;
|
import com.ruoyi.system.domain.SysMenu;
|
||||||
import com.ruoyi.system.domain.SysUser;
|
import com.ruoyi.system.domain.SysUser;
|
||||||
import com.ruoyi.system.service.ISysConfigService;
|
import com.ruoyi.system.service.ISysConfigService;
|
||||||
import com.ruoyi.system.service.ISysMenuService;
|
import com.ruoyi.system.service.ISysMenuService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 首页 业务处理
|
* 首页 业务处理
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@Controller
|
@Controller
|
||||||
public class SysIndexController extends BaseController
|
public class SysIndexController extends BaseController
|
||||||
{
|
{
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysMenuService menuService;
|
private ISysMenuService menuService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysConfigService configService;
|
private ISysConfigService configService;
|
||||||
|
|
||||||
// 系统首页
|
// 系统首页
|
||||||
@GetMapping("/index")
|
@GetMapping("/index")
|
||||||
public String index(ModelMap mmap)
|
public String index(ModelMap mmap)
|
||||||
{
|
{
|
||||||
// 取身份信息
|
// 取身份信息
|
||||||
SysUser user = ShiroUtils.getSysUser();
|
SysUser user = ShiroUtils.getSysUser();
|
||||||
// 根据用户id取出菜单
|
// 根据用户id取出菜单
|
||||||
List<SysMenu> menus = menuService.selectMenusByUser(user);
|
List<SysMenu> menus = menuService.selectMenusByUser(user);
|
||||||
mmap.put("menus", menus);
|
mmap.put("menus", menus);
|
||||||
mmap.put("user", user);
|
mmap.put("user", user);
|
||||||
mmap.put("sideTheme", configService.selectConfigByKey("sys.index.sideTheme"));
|
mmap.put("sideTheme", configService.selectConfigByKey("sys.index.sideTheme"));
|
||||||
mmap.put("skinName", configService.selectConfigByKey("sys.index.skinName"));
|
mmap.put("skinName", configService.selectConfigByKey("sys.index.skinName"));
|
||||||
mmap.put("copyrightYear", Global.getCopyrightYear());
|
mmap.put("copyrightYear", Global.getCopyrightYear());
|
||||||
mmap.put("demoEnabled", Global.isDemoEnabled());
|
mmap.put("demoEnabled", Global.isDemoEnabled());
|
||||||
return "index";
|
return "index";
|
||||||
}
|
}
|
||||||
|
|
||||||
// 切换主题
|
// 切换主题
|
||||||
@GetMapping("/system/switchSkin")
|
@GetMapping("/system/switchSkin")
|
||||||
public String switchSkin(ModelMap mmap)
|
public String switchSkin(ModelMap mmap)
|
||||||
{
|
{
|
||||||
return "skin";
|
return "skin";
|
||||||
}
|
}
|
||||||
|
|
||||||
// 系统介绍
|
// 系统介绍
|
||||||
@GetMapping("/system/main")
|
@GetMapping("/system/main")
|
||||||
public String main(ModelMap mmap)
|
public String main(ModelMap mmap)
|
||||||
{
|
{
|
||||||
mmap.put("version", Global.getVersion());
|
mmap.put("version", Global.getVersion());
|
||||||
return "main";
|
return "main";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,196 +1,196 @@
|
||||||
package com.ruoyi.web.controller.system;
|
package com.ruoyi.web.controller.system;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.ModelMap;
|
import org.springframework.ui.ModelMap;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
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.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
import com.ruoyi.common.annotation.Log;
|
import com.ruoyi.common.annotation.Log;
|
||||||
import com.ruoyi.common.constant.UserConstants;
|
import com.ruoyi.common.constant.UserConstants;
|
||||||
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
import com.ruoyi.common.core.domain.Ztree;
|
import com.ruoyi.common.core.domain.Ztree;
|
||||||
import com.ruoyi.common.enums.BusinessType;
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
import com.ruoyi.framework.util.ShiroUtils;
|
import com.ruoyi.framework.util.ShiroUtils;
|
||||||
import com.ruoyi.system.domain.SysMenu;
|
import com.ruoyi.system.domain.SysMenu;
|
||||||
import com.ruoyi.system.domain.SysRole;
|
import com.ruoyi.system.domain.SysRole;
|
||||||
import com.ruoyi.system.service.ISysMenuService;
|
import com.ruoyi.system.service.ISysMenuService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 菜单信息
|
* 菜单信息
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@Controller
|
@Controller
|
||||||
@RequestMapping("/system/menu")
|
@RequestMapping("/system/menu")
|
||||||
public class SysMenuController extends BaseController
|
public class SysMenuController extends BaseController
|
||||||
{
|
{
|
||||||
private String prefix = "system/menu";
|
private String prefix = "system/menu";
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysMenuService menuService;
|
private ISysMenuService menuService;
|
||||||
|
|
||||||
@RequiresPermissions("system:menu:view")
|
@RequiresPermissions("system:menu:view")
|
||||||
@GetMapping()
|
@GetMapping()
|
||||||
public String menu()
|
public String menu()
|
||||||
{
|
{
|
||||||
return prefix + "/menu";
|
return prefix + "/menu";
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiresPermissions("system:menu:list")
|
@RequiresPermissions("system:menu:list")
|
||||||
@PostMapping("/list")
|
@PostMapping("/list")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public List<SysMenu> list(SysMenu menu)
|
public List<SysMenu> list(SysMenu menu)
|
||||||
{
|
{
|
||||||
Long userId = ShiroUtils.getUserId();
|
Long userId = ShiroUtils.getUserId();
|
||||||
List<SysMenu> menuList = menuService.selectMenuList(menu, userId);
|
List<SysMenu> menuList = menuService.selectMenuList(menu, userId);
|
||||||
return menuList;
|
return menuList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除菜单
|
* 删除菜单
|
||||||
*/
|
*/
|
||||||
@Log(title = "菜单管理", businessType = BusinessType.DELETE)
|
@Log(title = "菜单管理", businessType = BusinessType.DELETE)
|
||||||
@RequiresPermissions("system:menu:remove")
|
@RequiresPermissions("system:menu:remove")
|
||||||
@GetMapping("/remove/{menuId}")
|
@GetMapping("/remove/{menuId}")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult remove(@PathVariable("menuId") Long menuId)
|
public AjaxResult remove(@PathVariable("menuId") Long menuId)
|
||||||
{
|
{
|
||||||
if (menuService.selectCountMenuByParentId(menuId) > 0)
|
if (menuService.selectCountMenuByParentId(menuId) > 0)
|
||||||
{
|
{
|
||||||
return AjaxResult.warn("存在子菜单,不允许删除");
|
return AjaxResult.warn("存在子菜单,不允许删除");
|
||||||
}
|
}
|
||||||
if (menuService.selectCountRoleMenuByMenuId(menuId) > 0)
|
if (menuService.selectCountRoleMenuByMenuId(menuId) > 0)
|
||||||
{
|
{
|
||||||
return AjaxResult.warn("菜单已分配,不允许删除");
|
return AjaxResult.warn("菜单已分配,不允许删除");
|
||||||
}
|
}
|
||||||
ShiroUtils.clearCachedAuthorizationInfo();
|
ShiroUtils.clearCachedAuthorizationInfo();
|
||||||
return toAjax(menuService.deleteMenuById(menuId));
|
return toAjax(menuService.deleteMenuById(menuId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增
|
* 新增
|
||||||
*/
|
*/
|
||||||
@GetMapping("/add/{parentId}")
|
@GetMapping("/add/{parentId}")
|
||||||
public String add(@PathVariable("parentId") Long parentId, ModelMap mmap)
|
public String add(@PathVariable("parentId") Long parentId, ModelMap mmap)
|
||||||
{
|
{
|
||||||
SysMenu menu = null;
|
SysMenu menu = null;
|
||||||
if (0L != parentId)
|
if (0L != parentId)
|
||||||
{
|
{
|
||||||
menu = menuService.selectMenuById(parentId);
|
menu = menuService.selectMenuById(parentId);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
menu = new SysMenu();
|
menu = new SysMenu();
|
||||||
menu.setMenuId(0L);
|
menu.setMenuId(0L);
|
||||||
menu.setMenuName("主目录");
|
menu.setMenuName("主目录");
|
||||||
}
|
}
|
||||||
mmap.put("menu", menu);
|
mmap.put("menu", menu);
|
||||||
return prefix + "/add";
|
return prefix + "/add";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增保存菜单
|
* 新增保存菜单
|
||||||
*/
|
*/
|
||||||
@Log(title = "菜单管理", businessType = BusinessType.INSERT)
|
@Log(title = "菜单管理", businessType = BusinessType.INSERT)
|
||||||
@RequiresPermissions("system:menu:add")
|
@RequiresPermissions("system:menu:add")
|
||||||
@PostMapping("/add")
|
@PostMapping("/add")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult addSave(@Validated SysMenu menu)
|
public AjaxResult addSave(@Validated SysMenu menu)
|
||||||
{
|
{
|
||||||
if (UserConstants.MENU_NAME_NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu)))
|
if (UserConstants.MENU_NAME_NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu)))
|
||||||
{
|
{
|
||||||
return error("新增菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
|
return error("新增菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
|
||||||
}
|
}
|
||||||
menu.setCreateBy(ShiroUtils.getLoginName());
|
menu.setCreateBy(ShiroUtils.getLoginName());
|
||||||
ShiroUtils.clearCachedAuthorizationInfo();
|
ShiroUtils.clearCachedAuthorizationInfo();
|
||||||
return toAjax(menuService.insertMenu(menu));
|
return toAjax(menuService.insertMenu(menu));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改菜单
|
* 修改菜单
|
||||||
*/
|
*/
|
||||||
@GetMapping("/edit/{menuId}")
|
@GetMapping("/edit/{menuId}")
|
||||||
public String edit(@PathVariable("menuId") Long menuId, ModelMap mmap)
|
public String edit(@PathVariable("menuId") Long menuId, ModelMap mmap)
|
||||||
{
|
{
|
||||||
mmap.put("menu", menuService.selectMenuById(menuId));
|
mmap.put("menu", menuService.selectMenuById(menuId));
|
||||||
return prefix + "/edit";
|
return prefix + "/edit";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改保存菜单
|
* 修改保存菜单
|
||||||
*/
|
*/
|
||||||
@Log(title = "菜单管理", businessType = BusinessType.UPDATE)
|
@Log(title = "菜单管理", businessType = BusinessType.UPDATE)
|
||||||
@RequiresPermissions("system:menu:edit")
|
@RequiresPermissions("system:menu:edit")
|
||||||
@PostMapping("/edit")
|
@PostMapping("/edit")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult editSave(@Validated SysMenu menu)
|
public AjaxResult editSave(@Validated SysMenu menu)
|
||||||
{
|
{
|
||||||
if (UserConstants.MENU_NAME_NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu)))
|
if (UserConstants.MENU_NAME_NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu)))
|
||||||
{
|
{
|
||||||
return error("修改菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
|
return error("修改菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
|
||||||
}
|
}
|
||||||
menu.setUpdateBy(ShiroUtils.getLoginName());
|
menu.setUpdateBy(ShiroUtils.getLoginName());
|
||||||
ShiroUtils.clearCachedAuthorizationInfo();
|
ShiroUtils.clearCachedAuthorizationInfo();
|
||||||
return toAjax(menuService.updateMenu(menu));
|
return toAjax(menuService.updateMenu(menu));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 选择菜单图标
|
* 选择菜单图标
|
||||||
*/
|
*/
|
||||||
@GetMapping("/icon")
|
@GetMapping("/icon")
|
||||||
public String icon()
|
public String icon()
|
||||||
{
|
{
|
||||||
return prefix + "/icon";
|
return prefix + "/icon";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 校验菜单名称
|
* 校验菜单名称
|
||||||
*/
|
*/
|
||||||
@PostMapping("/checkMenuNameUnique")
|
@PostMapping("/checkMenuNameUnique")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String checkMenuNameUnique(SysMenu menu)
|
public String checkMenuNameUnique(SysMenu menu)
|
||||||
{
|
{
|
||||||
return menuService.checkMenuNameUnique(menu);
|
return menuService.checkMenuNameUnique(menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 加载角色菜单列表树
|
* 加载角色菜单列表树
|
||||||
*/
|
*/
|
||||||
@GetMapping("/roleMenuTreeData")
|
@GetMapping("/roleMenuTreeData")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public List<Ztree> roleMenuTreeData(SysRole role)
|
public List<Ztree> roleMenuTreeData(SysRole role)
|
||||||
{
|
{
|
||||||
Long userId = ShiroUtils.getUserId();
|
Long userId = ShiroUtils.getUserId();
|
||||||
List<Ztree> ztrees = menuService.roleMenuTreeData(role, userId);
|
List<Ztree> ztrees = menuService.roleMenuTreeData(role, userId);
|
||||||
return ztrees;
|
return ztrees;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 加载所有菜单列表树
|
* 加载所有菜单列表树
|
||||||
*/
|
*/
|
||||||
@GetMapping("/menuTreeData")
|
@GetMapping("/menuTreeData")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public List<Ztree> menuTreeData()
|
public List<Ztree> menuTreeData()
|
||||||
{
|
{
|
||||||
Long userId = ShiroUtils.getUserId();
|
Long userId = ShiroUtils.getUserId();
|
||||||
List<Ztree> ztrees = menuService.menuTreeData(userId);
|
List<Ztree> ztrees = menuService.menuTreeData(userId);
|
||||||
return ztrees;
|
return ztrees;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 选择菜单树
|
* 选择菜单树
|
||||||
*/
|
*/
|
||||||
@GetMapping("/selectMenuTree/{menuId}")
|
@GetMapping("/selectMenuTree/{menuId}")
|
||||||
public String selectMenuTree(@PathVariable("menuId") Long menuId, ModelMap mmap)
|
public String selectMenuTree(@PathVariable("menuId") Long menuId, ModelMap mmap)
|
||||||
{
|
{
|
||||||
mmap.put("menu", menuService.selectMenuById(menuId));
|
mmap.put("menu", menuService.selectMenuById(menuId));
|
||||||
return prefix + "/tree";
|
return prefix + "/tree";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,112 +1,112 @@
|
||||||
package com.ruoyi.web.controller.system;
|
package com.ruoyi.web.controller.system;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.ModelMap;
|
import org.springframework.ui.ModelMap;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
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.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
import com.ruoyi.common.annotation.Log;
|
import com.ruoyi.common.annotation.Log;
|
||||||
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
import com.ruoyi.common.enums.BusinessType;
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
import com.ruoyi.framework.util.ShiroUtils;
|
import com.ruoyi.framework.util.ShiroUtils;
|
||||||
import com.ruoyi.system.domain.SysNotice;
|
import com.ruoyi.system.domain.SysNotice;
|
||||||
import com.ruoyi.system.service.ISysNoticeService;
|
import com.ruoyi.system.service.ISysNoticeService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 公告 信息操作处理
|
* 公告 信息操作处理
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@Controller
|
@Controller
|
||||||
@RequestMapping("/system/notice")
|
@RequestMapping("/system/notice")
|
||||||
public class SysNoticeController extends BaseController
|
public class SysNoticeController extends BaseController
|
||||||
{
|
{
|
||||||
private String prefix = "system/notice";
|
private String prefix = "system/notice";
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysNoticeService noticeService;
|
private ISysNoticeService noticeService;
|
||||||
|
|
||||||
@RequiresPermissions("system:notice:view")
|
@RequiresPermissions("system:notice:view")
|
||||||
@GetMapping()
|
@GetMapping()
|
||||||
public String notice()
|
public String notice()
|
||||||
{
|
{
|
||||||
return prefix + "/notice";
|
return prefix + "/notice";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询公告列表
|
* 查询公告列表
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("system:notice:list")
|
@RequiresPermissions("system:notice:list")
|
||||||
@PostMapping("/list")
|
@PostMapping("/list")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public TableDataInfo list(SysNotice notice)
|
public TableDataInfo list(SysNotice notice)
|
||||||
{
|
{
|
||||||
startPage();
|
startPage();
|
||||||
List<SysNotice> list = noticeService.selectNoticeList(notice);
|
List<SysNotice> list = noticeService.selectNoticeList(notice);
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增公告
|
* 新增公告
|
||||||
*/
|
*/
|
||||||
@GetMapping("/add")
|
@GetMapping("/add")
|
||||||
public String add()
|
public String add()
|
||||||
{
|
{
|
||||||
return prefix + "/add";
|
return prefix + "/add";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增保存公告
|
* 新增保存公告
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("system:notice:add")
|
@RequiresPermissions("system:notice:add")
|
||||||
@Log(title = "通知公告", businessType = BusinessType.INSERT)
|
@Log(title = "通知公告", businessType = BusinessType.INSERT)
|
||||||
@PostMapping("/add")
|
@PostMapping("/add")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult addSave(SysNotice notice)
|
public AjaxResult addSave(SysNotice notice)
|
||||||
{
|
{
|
||||||
notice.setCreateBy(ShiroUtils.getLoginName());
|
notice.setCreateBy(ShiroUtils.getLoginName());
|
||||||
return toAjax(noticeService.insertNotice(notice));
|
return toAjax(noticeService.insertNotice(notice));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改公告
|
* 修改公告
|
||||||
*/
|
*/
|
||||||
@GetMapping("/edit/{noticeId}")
|
@GetMapping("/edit/{noticeId}")
|
||||||
public String edit(@PathVariable("noticeId") Long noticeId, ModelMap mmap)
|
public String edit(@PathVariable("noticeId") Long noticeId, ModelMap mmap)
|
||||||
{
|
{
|
||||||
mmap.put("notice", noticeService.selectNoticeById(noticeId));
|
mmap.put("notice", noticeService.selectNoticeById(noticeId));
|
||||||
return prefix + "/edit";
|
return prefix + "/edit";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改保存公告
|
* 修改保存公告
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("system:notice:edit")
|
@RequiresPermissions("system:notice:edit")
|
||||||
@Log(title = "通知公告", businessType = BusinessType.UPDATE)
|
@Log(title = "通知公告", businessType = BusinessType.UPDATE)
|
||||||
@PostMapping("/edit")
|
@PostMapping("/edit")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult editSave(SysNotice notice)
|
public AjaxResult editSave(SysNotice notice)
|
||||||
{
|
{
|
||||||
notice.setUpdateBy(ShiroUtils.getLoginName());
|
notice.setUpdateBy(ShiroUtils.getLoginName());
|
||||||
return toAjax(noticeService.updateNotice(notice));
|
return toAjax(noticeService.updateNotice(notice));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除公告
|
* 删除公告
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("system:notice:remove")
|
@RequiresPermissions("system:notice:remove")
|
||||||
@Log(title = "通知公告", businessType = BusinessType.DELETE)
|
@Log(title = "通知公告", businessType = BusinessType.DELETE)
|
||||||
@PostMapping("/remove")
|
@PostMapping("/remove")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult remove(String ids)
|
public AjaxResult remove(String ids)
|
||||||
{
|
{
|
||||||
return toAjax(noticeService.deleteNoticeByIds(ids));
|
return toAjax(noticeService.deleteNoticeByIds(ids));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,163 +1,163 @@
|
||||||
package com.ruoyi.web.controller.system;
|
package com.ruoyi.web.controller.system;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.ModelMap;
|
import org.springframework.ui.ModelMap;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
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.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
import com.ruoyi.common.annotation.Log;
|
import com.ruoyi.common.annotation.Log;
|
||||||
import com.ruoyi.common.constant.UserConstants;
|
import com.ruoyi.common.constant.UserConstants;
|
||||||
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
import com.ruoyi.common.enums.BusinessType;
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||||
import com.ruoyi.framework.util.ShiroUtils;
|
import com.ruoyi.framework.util.ShiroUtils;
|
||||||
import com.ruoyi.system.domain.SysPost;
|
import com.ruoyi.system.domain.SysPost;
|
||||||
import com.ruoyi.system.service.ISysPostService;
|
import com.ruoyi.system.service.ISysPostService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 岗位信息操作处理
|
* 岗位信息操作处理
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@Controller
|
@Controller
|
||||||
@RequestMapping("/system/post")
|
@RequestMapping("/system/post")
|
||||||
public class SysPostController extends BaseController
|
public class SysPostController extends BaseController
|
||||||
{
|
{
|
||||||
private String prefix = "system/post";
|
private String prefix = "system/post";
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysPostService postService;
|
private ISysPostService postService;
|
||||||
|
|
||||||
@RequiresPermissions("system:post:view")
|
@RequiresPermissions("system:post:view")
|
||||||
@GetMapping()
|
@GetMapping()
|
||||||
public String operlog()
|
public String operlog()
|
||||||
{
|
{
|
||||||
return prefix + "/post";
|
return prefix + "/post";
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiresPermissions("system:post:list")
|
@RequiresPermissions("system:post:list")
|
||||||
@PostMapping("/list")
|
@PostMapping("/list")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public TableDataInfo list(SysPost post)
|
public TableDataInfo list(SysPost post)
|
||||||
{
|
{
|
||||||
startPage();
|
startPage();
|
||||||
List<SysPost> list = postService.selectPostList(post);
|
List<SysPost> list = postService.selectPostList(post);
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Log(title = "岗位管理", businessType = BusinessType.EXPORT)
|
@Log(title = "岗位管理", businessType = BusinessType.EXPORT)
|
||||||
@RequiresPermissions("system:post:export")
|
@RequiresPermissions("system:post:export")
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult export(SysPost post)
|
public AjaxResult export(SysPost post)
|
||||||
{
|
{
|
||||||
List<SysPost> list = postService.selectPostList(post);
|
List<SysPost> list = postService.selectPostList(post);
|
||||||
ExcelUtil<SysPost> util = new ExcelUtil<SysPost>(SysPost.class);
|
ExcelUtil<SysPost> util = new ExcelUtil<SysPost>(SysPost.class);
|
||||||
return util.exportExcel(list, "岗位数据");
|
return util.exportExcel(list, "岗位数据");
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiresPermissions("system:post:remove")
|
@RequiresPermissions("system:post:remove")
|
||||||
@Log(title = "岗位管理", businessType = BusinessType.DELETE)
|
@Log(title = "岗位管理", businessType = BusinessType.DELETE)
|
||||||
@PostMapping("/remove")
|
@PostMapping("/remove")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult remove(String ids)
|
public AjaxResult remove(String ids)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return toAjax(postService.deletePostByIds(ids));
|
return toAjax(postService.deletePostByIds(ids));
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
return error(e.getMessage());
|
return error(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增岗位
|
* 新增岗位
|
||||||
*/
|
*/
|
||||||
@GetMapping("/add")
|
@GetMapping("/add")
|
||||||
public String add()
|
public String add()
|
||||||
{
|
{
|
||||||
return prefix + "/add";
|
return prefix + "/add";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增保存岗位
|
* 新增保存岗位
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("system:post:add")
|
@RequiresPermissions("system:post:add")
|
||||||
@Log(title = "岗位管理", businessType = BusinessType.INSERT)
|
@Log(title = "岗位管理", businessType = BusinessType.INSERT)
|
||||||
@PostMapping("/add")
|
@PostMapping("/add")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult addSave(@Validated SysPost post)
|
public AjaxResult addSave(@Validated SysPost post)
|
||||||
{
|
{
|
||||||
if (UserConstants.POST_NAME_NOT_UNIQUE.equals(postService.checkPostNameUnique(post)))
|
if (UserConstants.POST_NAME_NOT_UNIQUE.equals(postService.checkPostNameUnique(post)))
|
||||||
{
|
{
|
||||||
return error("新增岗位'" + post.getPostName() + "'失败,岗位名称已存在");
|
return error("新增岗位'" + post.getPostName() + "'失败,岗位名称已存在");
|
||||||
}
|
}
|
||||||
else if (UserConstants.POST_CODE_NOT_UNIQUE.equals(postService.checkPostCodeUnique(post)))
|
else if (UserConstants.POST_CODE_NOT_UNIQUE.equals(postService.checkPostCodeUnique(post)))
|
||||||
{
|
{
|
||||||
return error("新增岗位'" + post.getPostName() + "'失败,岗位编码已存在");
|
return error("新增岗位'" + post.getPostName() + "'失败,岗位编码已存在");
|
||||||
}
|
}
|
||||||
post.setCreateBy(ShiroUtils.getLoginName());
|
post.setCreateBy(ShiroUtils.getLoginName());
|
||||||
return toAjax(postService.insertPost(post));
|
return toAjax(postService.insertPost(post));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改岗位
|
* 修改岗位
|
||||||
*/
|
*/
|
||||||
@GetMapping("/edit/{postId}")
|
@GetMapping("/edit/{postId}")
|
||||||
public String edit(@PathVariable("postId") Long postId, ModelMap mmap)
|
public String edit(@PathVariable("postId") Long postId, ModelMap mmap)
|
||||||
{
|
{
|
||||||
mmap.put("post", postService.selectPostById(postId));
|
mmap.put("post", postService.selectPostById(postId));
|
||||||
return prefix + "/edit";
|
return prefix + "/edit";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改保存岗位
|
* 修改保存岗位
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("system:post:edit")
|
@RequiresPermissions("system:post:edit")
|
||||||
@Log(title = "岗位管理", businessType = BusinessType.UPDATE)
|
@Log(title = "岗位管理", businessType = BusinessType.UPDATE)
|
||||||
@PostMapping("/edit")
|
@PostMapping("/edit")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult editSave(@Validated SysPost post)
|
public AjaxResult editSave(@Validated SysPost post)
|
||||||
{
|
{
|
||||||
if (UserConstants.POST_NAME_NOT_UNIQUE.equals(postService.checkPostNameUnique(post)))
|
if (UserConstants.POST_NAME_NOT_UNIQUE.equals(postService.checkPostNameUnique(post)))
|
||||||
{
|
{
|
||||||
return error("修改岗位'" + post.getPostName() + "'失败,岗位名称已存在");
|
return error("修改岗位'" + post.getPostName() + "'失败,岗位名称已存在");
|
||||||
}
|
}
|
||||||
else if (UserConstants.POST_CODE_NOT_UNIQUE.equals(postService.checkPostCodeUnique(post)))
|
else if (UserConstants.POST_CODE_NOT_UNIQUE.equals(postService.checkPostCodeUnique(post)))
|
||||||
{
|
{
|
||||||
return error("修改岗位'" + post.getPostName() + "'失败,岗位编码已存在");
|
return error("修改岗位'" + post.getPostName() + "'失败,岗位编码已存在");
|
||||||
}
|
}
|
||||||
post.setUpdateBy(ShiroUtils.getLoginName());
|
post.setUpdateBy(ShiroUtils.getLoginName());
|
||||||
return toAjax(postService.updatePost(post));
|
return toAjax(postService.updatePost(post));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 校验岗位名称
|
* 校验岗位名称
|
||||||
*/
|
*/
|
||||||
@PostMapping("/checkPostNameUnique")
|
@PostMapping("/checkPostNameUnique")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String checkPostNameUnique(SysPost post)
|
public String checkPostNameUnique(SysPost post)
|
||||||
{
|
{
|
||||||
return postService.checkPostNameUnique(post);
|
return postService.checkPostNameUnique(post);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 校验岗位编码
|
* 校验岗位编码
|
||||||
*/
|
*/
|
||||||
@PostMapping("/checkPostCodeUnique")
|
@PostMapping("/checkPostCodeUnique")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String checkPostCodeUnique(SysPost post)
|
public String checkPostCodeUnique(SysPost post)
|
||||||
{
|
{
|
||||||
return postService.checkPostCodeUnique(post);
|
return postService.checkPostCodeUnique(post);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,173 +1,173 @@
|
||||||
package com.ruoyi.web.controller.system;
|
package com.ruoyi.web.controller.system;
|
||||||
|
|
||||||
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.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.ModelMap;
|
import org.springframework.ui.ModelMap;
|
||||||
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.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import com.ruoyi.common.annotation.Log;
|
import com.ruoyi.common.annotation.Log;
|
||||||
import com.ruoyi.common.config.Global;
|
import com.ruoyi.common.config.Global;
|
||||||
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
import com.ruoyi.common.enums.BusinessType;
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
import com.ruoyi.common.utils.file.FileUploadUtils;
|
import com.ruoyi.common.utils.file.FileUploadUtils;
|
||||||
import com.ruoyi.framework.shiro.service.SysPasswordService;
|
import com.ruoyi.framework.shiro.service.SysPasswordService;
|
||||||
import com.ruoyi.framework.util.ShiroUtils;
|
import com.ruoyi.framework.util.ShiroUtils;
|
||||||
import com.ruoyi.system.domain.SysUser;
|
import com.ruoyi.system.domain.SysUser;
|
||||||
import com.ruoyi.system.service.ISysUserService;
|
import com.ruoyi.system.service.ISysUserService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 个人信息 业务处理
|
* 个人信息 业务处理
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@Controller
|
@Controller
|
||||||
@RequestMapping("/system/user/profile")
|
@RequestMapping("/system/user/profile")
|
||||||
public class SysProfileController extends BaseController
|
public class SysProfileController extends BaseController
|
||||||
{
|
{
|
||||||
private static final Logger log = LoggerFactory.getLogger(SysProfileController.class);
|
private static final Logger log = LoggerFactory.getLogger(SysProfileController.class);
|
||||||
|
|
||||||
private String prefix = "system/user/profile";
|
private String prefix = "system/user/profile";
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysUserService userService;
|
private ISysUserService userService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SysPasswordService passwordService;
|
private SysPasswordService passwordService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 个人信息
|
* 个人信息
|
||||||
*/
|
*/
|
||||||
@GetMapping()
|
@GetMapping()
|
||||||
public String profile(ModelMap mmap)
|
public String profile(ModelMap mmap)
|
||||||
{
|
{
|
||||||
SysUser user = ShiroUtils.getSysUser();
|
SysUser user = ShiroUtils.getSysUser();
|
||||||
mmap.put("user", user);
|
mmap.put("user", user);
|
||||||
mmap.put("roleGroup", userService.selectUserRoleGroup(user.getUserId()));
|
mmap.put("roleGroup", userService.selectUserRoleGroup(user.getUserId()));
|
||||||
mmap.put("postGroup", userService.selectUserPostGroup(user.getUserId()));
|
mmap.put("postGroup", userService.selectUserPostGroup(user.getUserId()));
|
||||||
return prefix + "/profile";
|
return prefix + "/profile";
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/checkPassword")
|
@GetMapping("/checkPassword")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public boolean checkPassword(String password)
|
public boolean checkPassword(String password)
|
||||||
{
|
{
|
||||||
SysUser user = ShiroUtils.getSysUser();
|
SysUser user = ShiroUtils.getSysUser();
|
||||||
if (passwordService.matches(user, password))
|
if (passwordService.matches(user, password))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/resetPwd")
|
@GetMapping("/resetPwd")
|
||||||
public String resetPwd(ModelMap mmap)
|
public String resetPwd(ModelMap mmap)
|
||||||
{
|
{
|
||||||
SysUser user = ShiroUtils.getSysUser();
|
SysUser user = ShiroUtils.getSysUser();
|
||||||
mmap.put("user", userService.selectUserById(user.getUserId()));
|
mmap.put("user", userService.selectUserById(user.getUserId()));
|
||||||
return prefix + "/resetPwd";
|
return prefix + "/resetPwd";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Log(title = "重置密码", businessType = BusinessType.UPDATE)
|
@Log(title = "重置密码", businessType = BusinessType.UPDATE)
|
||||||
@PostMapping("/resetPwd")
|
@PostMapping("/resetPwd")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult resetPwd(String oldPassword, String newPassword)
|
public AjaxResult resetPwd(String oldPassword, String newPassword)
|
||||||
{
|
{
|
||||||
SysUser user = ShiroUtils.getSysUser();
|
SysUser user = ShiroUtils.getSysUser();
|
||||||
if (StringUtils.isNotEmpty(newPassword) && passwordService.matches(user, oldPassword))
|
if (StringUtils.isNotEmpty(newPassword) && passwordService.matches(user, oldPassword))
|
||||||
{
|
{
|
||||||
user.setSalt(ShiroUtils.randomSalt());
|
user.setSalt(ShiroUtils.randomSalt());
|
||||||
user.setPassword(passwordService.encryptPassword(user.getLoginName(), newPassword, user.getSalt()));
|
user.setPassword(passwordService.encryptPassword(user.getLoginName(), newPassword, user.getSalt()));
|
||||||
if (userService.resetUserPwd(user) > 0)
|
if (userService.resetUserPwd(user) > 0)
|
||||||
{
|
{
|
||||||
ShiroUtils.setSysUser(userService.selectUserById(user.getUserId()));
|
ShiroUtils.setSysUser(userService.selectUserById(user.getUserId()));
|
||||||
return success();
|
return success();
|
||||||
}
|
}
|
||||||
return error();
|
return error();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return error("修改密码失败,旧密码错误");
|
return error("修改密码失败,旧密码错误");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改用户
|
* 修改用户
|
||||||
*/
|
*/
|
||||||
@GetMapping("/edit")
|
@GetMapping("/edit")
|
||||||
public String edit(ModelMap mmap)
|
public String edit(ModelMap mmap)
|
||||||
{
|
{
|
||||||
SysUser user = ShiroUtils.getSysUser();
|
SysUser user = ShiroUtils.getSysUser();
|
||||||
mmap.put("user", userService.selectUserById(user.getUserId()));
|
mmap.put("user", userService.selectUserById(user.getUserId()));
|
||||||
return prefix + "/edit";
|
return prefix + "/edit";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改头像
|
* 修改头像
|
||||||
*/
|
*/
|
||||||
@GetMapping("/avatar")
|
@GetMapping("/avatar")
|
||||||
public String avatar(ModelMap mmap)
|
public String avatar(ModelMap mmap)
|
||||||
{
|
{
|
||||||
SysUser user = ShiroUtils.getSysUser();
|
SysUser user = ShiroUtils.getSysUser();
|
||||||
mmap.put("user", userService.selectUserById(user.getUserId()));
|
mmap.put("user", userService.selectUserById(user.getUserId()));
|
||||||
return prefix + "/avatar";
|
return prefix + "/avatar";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改用户
|
* 修改用户
|
||||||
*/
|
*/
|
||||||
@Log(title = "个人信息", businessType = BusinessType.UPDATE)
|
@Log(title = "个人信息", businessType = BusinessType.UPDATE)
|
||||||
@PostMapping("/update")
|
@PostMapping("/update")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult update(SysUser user)
|
public AjaxResult update(SysUser user)
|
||||||
{
|
{
|
||||||
SysUser currentUser = ShiroUtils.getSysUser();
|
SysUser currentUser = ShiroUtils.getSysUser();
|
||||||
currentUser.setUserName(user.getUserName());
|
currentUser.setUserName(user.getUserName());
|
||||||
currentUser.setEmail(user.getEmail());
|
currentUser.setEmail(user.getEmail());
|
||||||
currentUser.setPhonenumber(user.getPhonenumber());
|
currentUser.setPhonenumber(user.getPhonenumber());
|
||||||
currentUser.setSex(user.getSex());
|
currentUser.setSex(user.getSex());
|
||||||
if (userService.updateUserInfo(currentUser) > 0)
|
if (userService.updateUserInfo(currentUser) > 0)
|
||||||
{
|
{
|
||||||
ShiroUtils.setSysUser(userService.selectUserById(currentUser.getUserId()));
|
ShiroUtils.setSysUser(userService.selectUserById(currentUser.getUserId()));
|
||||||
return success();
|
return success();
|
||||||
}
|
}
|
||||||
return error();
|
return error();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存头像
|
* 保存头像
|
||||||
*/
|
*/
|
||||||
@Log(title = "个人信息", businessType = BusinessType.UPDATE)
|
@Log(title = "个人信息", businessType = BusinessType.UPDATE)
|
||||||
@PostMapping("/updateAvatar")
|
@PostMapping("/updateAvatar")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult updateAvatar(@RequestParam("avatarfile") MultipartFile file)
|
public AjaxResult updateAvatar(@RequestParam("avatarfile") MultipartFile file)
|
||||||
{
|
{
|
||||||
SysUser currentUser = ShiroUtils.getSysUser();
|
SysUser currentUser = ShiroUtils.getSysUser();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!file.isEmpty())
|
if (!file.isEmpty())
|
||||||
{
|
{
|
||||||
String avatar = FileUploadUtils.upload(Global.getAvatarPath(), file);
|
String avatar = FileUploadUtils.upload(Global.getAvatarPath(), file);
|
||||||
currentUser.setAvatar(avatar);
|
currentUser.setAvatar(avatar);
|
||||||
if (userService.updateUserInfo(currentUser) > 0)
|
if (userService.updateUserInfo(currentUser) > 0)
|
||||||
{
|
{
|
||||||
ShiroUtils.setSysUser(userService.selectUserById(currentUser.getUserId()));
|
ShiroUtils.setSysUser(userService.selectUserById(currentUser.getUserId()));
|
||||||
return success();
|
return success();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return error();
|
return error();
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
log.error("修改头像失败!", e);
|
log.error("修改头像失败!", e);
|
||||||
return error(e.getMessage());
|
return error(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,46 +1,46 @@
|
||||||
package com.ruoyi.web.controller.system;
|
package com.ruoyi.web.controller.system;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
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.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
import com.ruoyi.framework.shiro.service.SysRegisterService;
|
import com.ruoyi.framework.shiro.service.SysRegisterService;
|
||||||
import com.ruoyi.system.domain.SysUser;
|
import com.ruoyi.system.domain.SysUser;
|
||||||
import com.ruoyi.system.service.ISysConfigService;
|
import com.ruoyi.system.service.ISysConfigService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 注册验证
|
* 注册验证
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@Controller
|
@Controller
|
||||||
public class SysRegisterController extends BaseController
|
public class SysRegisterController extends BaseController
|
||||||
{
|
{
|
||||||
@Autowired
|
@Autowired
|
||||||
private SysRegisterService registerService;
|
private SysRegisterService registerService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysConfigService configService;
|
private ISysConfigService configService;
|
||||||
|
|
||||||
@GetMapping("/register")
|
@GetMapping("/register")
|
||||||
public String register()
|
public String register()
|
||||||
{
|
{
|
||||||
return "register";
|
return "register";
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/register")
|
@PostMapping("/register")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult ajaxRegister(SysUser user)
|
public AjaxResult ajaxRegister(SysUser user)
|
||||||
{
|
{
|
||||||
if (!("true".equals(configService.selectConfigByKey("sys.account.registerUser"))))
|
if (!("true".equals(configService.selectConfigByKey("sys.account.registerUser"))))
|
||||||
{
|
{
|
||||||
return error("当前系统没有开启注册功能!");
|
return error("当前系统没有开启注册功能!");
|
||||||
}
|
}
|
||||||
String msg = registerService.register(user);
|
String msg = registerService.register(user);
|
||||||
return StringUtils.isEmpty(msg) ? success() : error(msg);
|
return StringUtils.isEmpty(msg) ? success() : error(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,304 +1,304 @@
|
||||||
package com.ruoyi.web.controller.system;
|
package com.ruoyi.web.controller.system;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.ModelMap;
|
import org.springframework.ui.ModelMap;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
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.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
import com.ruoyi.common.annotation.Log;
|
import com.ruoyi.common.annotation.Log;
|
||||||
import com.ruoyi.common.constant.UserConstants;
|
import com.ruoyi.common.constant.UserConstants;
|
||||||
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
import com.ruoyi.common.enums.BusinessType;
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||||
import com.ruoyi.framework.util.ShiroUtils;
|
import com.ruoyi.framework.util.ShiroUtils;
|
||||||
import com.ruoyi.system.domain.SysRole;
|
import com.ruoyi.system.domain.SysRole;
|
||||||
import com.ruoyi.system.domain.SysUser;
|
import com.ruoyi.system.domain.SysUser;
|
||||||
import com.ruoyi.system.domain.SysUserRole;
|
import com.ruoyi.system.domain.SysUserRole;
|
||||||
import com.ruoyi.system.service.ISysRoleService;
|
import com.ruoyi.system.service.ISysRoleService;
|
||||||
import com.ruoyi.system.service.ISysUserService;
|
import com.ruoyi.system.service.ISysUserService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 角色信息
|
* 角色信息
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@Controller
|
@Controller
|
||||||
@RequestMapping("/system/role")
|
@RequestMapping("/system/role")
|
||||||
public class SysRoleController extends BaseController
|
public class SysRoleController extends BaseController
|
||||||
{
|
{
|
||||||
private String prefix = "system/role";
|
private String prefix = "system/role";
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysRoleService roleService;
|
private ISysRoleService roleService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysUserService userService;
|
private ISysUserService userService;
|
||||||
|
|
||||||
@RequiresPermissions("system:role:view")
|
@RequiresPermissions("system:role:view")
|
||||||
@GetMapping()
|
@GetMapping()
|
||||||
public String role()
|
public String role()
|
||||||
{
|
{
|
||||||
return prefix + "/role";
|
return prefix + "/role";
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiresPermissions("system:role:list")
|
@RequiresPermissions("system:role:list")
|
||||||
@PostMapping("/list")
|
@PostMapping("/list")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public TableDataInfo list(SysRole role)
|
public TableDataInfo list(SysRole role)
|
||||||
{
|
{
|
||||||
startPage();
|
startPage();
|
||||||
List<SysRole> list = roleService.selectRoleList(role);
|
List<SysRole> list = roleService.selectRoleList(role);
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Log(title = "角色管理", businessType = BusinessType.EXPORT)
|
@Log(title = "角色管理", businessType = BusinessType.EXPORT)
|
||||||
@RequiresPermissions("system:role:export")
|
@RequiresPermissions("system:role:export")
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult export(SysRole role)
|
public AjaxResult export(SysRole role)
|
||||||
{
|
{
|
||||||
List<SysRole> list = roleService.selectRoleList(role);
|
List<SysRole> list = roleService.selectRoleList(role);
|
||||||
ExcelUtil<SysRole> util = new ExcelUtil<SysRole>(SysRole.class);
|
ExcelUtil<SysRole> util = new ExcelUtil<SysRole>(SysRole.class);
|
||||||
return util.exportExcel(list, "角色数据");
|
return util.exportExcel(list, "角色数据");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增角色
|
* 新增角色
|
||||||
*/
|
*/
|
||||||
@GetMapping("/add")
|
@GetMapping("/add")
|
||||||
public String add()
|
public String add()
|
||||||
{
|
{
|
||||||
return prefix + "/add";
|
return prefix + "/add";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增保存角色
|
* 新增保存角色
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("system:role:add")
|
@RequiresPermissions("system:role:add")
|
||||||
@Log(title = "角色管理", businessType = BusinessType.INSERT)
|
@Log(title = "角色管理", businessType = BusinessType.INSERT)
|
||||||
@PostMapping("/add")
|
@PostMapping("/add")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult addSave(@Validated SysRole role)
|
public AjaxResult addSave(@Validated SysRole role)
|
||||||
{
|
{
|
||||||
if (UserConstants.ROLE_NAME_NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role)))
|
if (UserConstants.ROLE_NAME_NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role)))
|
||||||
{
|
{
|
||||||
return error("新增角色'" + role.getRoleName() + "'失败,角色名称已存在");
|
return error("新增角色'" + role.getRoleName() + "'失败,角色名称已存在");
|
||||||
}
|
}
|
||||||
else if (UserConstants.ROLE_KEY_NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role)))
|
else if (UserConstants.ROLE_KEY_NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role)))
|
||||||
{
|
{
|
||||||
return error("新增角色'" + role.getRoleName() + "'失败,角色权限已存在");
|
return error("新增角色'" + role.getRoleName() + "'失败,角色权限已存在");
|
||||||
}
|
}
|
||||||
role.setCreateBy(ShiroUtils.getLoginName());
|
role.setCreateBy(ShiroUtils.getLoginName());
|
||||||
ShiroUtils.clearCachedAuthorizationInfo();
|
ShiroUtils.clearCachedAuthorizationInfo();
|
||||||
return toAjax(roleService.insertRole(role));
|
return toAjax(roleService.insertRole(role));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改角色
|
* 修改角色
|
||||||
*/
|
*/
|
||||||
@GetMapping("/edit/{roleId}")
|
@GetMapping("/edit/{roleId}")
|
||||||
public String edit(@PathVariable("roleId") Long roleId, ModelMap mmap)
|
public String edit(@PathVariable("roleId") Long roleId, ModelMap mmap)
|
||||||
{
|
{
|
||||||
mmap.put("role", roleService.selectRoleById(roleId));
|
mmap.put("role", roleService.selectRoleById(roleId));
|
||||||
return prefix + "/edit";
|
return prefix + "/edit";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改保存角色
|
* 修改保存角色
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("system:role:edit")
|
@RequiresPermissions("system:role:edit")
|
||||||
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
|
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
|
||||||
@PostMapping("/edit")
|
@PostMapping("/edit")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult editSave(@Validated SysRole role)
|
public AjaxResult editSave(@Validated SysRole role)
|
||||||
{
|
{
|
||||||
roleService.checkRoleAllowed(role);
|
roleService.checkRoleAllowed(role);
|
||||||
if (UserConstants.ROLE_NAME_NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role)))
|
if (UserConstants.ROLE_NAME_NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role)))
|
||||||
{
|
{
|
||||||
return error("修改角色'" + role.getRoleName() + "'失败,角色名称已存在");
|
return error("修改角色'" + role.getRoleName() + "'失败,角色名称已存在");
|
||||||
}
|
}
|
||||||
else if (UserConstants.ROLE_KEY_NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role)))
|
else if (UserConstants.ROLE_KEY_NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role)))
|
||||||
{
|
{
|
||||||
return error("修改角色'" + role.getRoleName() + "'失败,角色权限已存在");
|
return error("修改角色'" + role.getRoleName() + "'失败,角色权限已存在");
|
||||||
}
|
}
|
||||||
role.setUpdateBy(ShiroUtils.getLoginName());
|
role.setUpdateBy(ShiroUtils.getLoginName());
|
||||||
ShiroUtils.clearCachedAuthorizationInfo();
|
ShiroUtils.clearCachedAuthorizationInfo();
|
||||||
return toAjax(roleService.updateRole(role));
|
return toAjax(roleService.updateRole(role));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 角色分配数据权限
|
* 角色分配数据权限
|
||||||
*/
|
*/
|
||||||
@GetMapping("/authDataScope/{roleId}")
|
@GetMapping("/authDataScope/{roleId}")
|
||||||
public String authDataScope(@PathVariable("roleId") Long roleId, ModelMap mmap)
|
public String authDataScope(@PathVariable("roleId") Long roleId, ModelMap mmap)
|
||||||
{
|
{
|
||||||
mmap.put("role", roleService.selectRoleById(roleId));
|
mmap.put("role", roleService.selectRoleById(roleId));
|
||||||
return prefix + "/dataScope";
|
return prefix + "/dataScope";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存角色分配数据权限
|
* 保存角色分配数据权限
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("system:role:edit")
|
@RequiresPermissions("system:role:edit")
|
||||||
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
|
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
|
||||||
@PostMapping("/authDataScope")
|
@PostMapping("/authDataScope")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult authDataScopeSave(SysRole role)
|
public AjaxResult authDataScopeSave(SysRole role)
|
||||||
{
|
{
|
||||||
roleService.checkRoleAllowed(role);
|
roleService.checkRoleAllowed(role);
|
||||||
role.setUpdateBy(ShiroUtils.getLoginName());
|
role.setUpdateBy(ShiroUtils.getLoginName());
|
||||||
if (roleService.authDataScope(role) > 0)
|
if (roleService.authDataScope(role) > 0)
|
||||||
{
|
{
|
||||||
ShiroUtils.setSysUser(userService.selectUserById(ShiroUtils.getSysUser().getUserId()));
|
ShiroUtils.setSysUser(userService.selectUserById(ShiroUtils.getSysUser().getUserId()));
|
||||||
return success();
|
return success();
|
||||||
}
|
}
|
||||||
return error();
|
return error();
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiresPermissions("system:role:remove")
|
@RequiresPermissions("system:role:remove")
|
||||||
@Log(title = "角色管理", businessType = BusinessType.DELETE)
|
@Log(title = "角色管理", businessType = BusinessType.DELETE)
|
||||||
@PostMapping("/remove")
|
@PostMapping("/remove")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult remove(String ids)
|
public AjaxResult remove(String ids)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return toAjax(roleService.deleteRoleByIds(ids));
|
return toAjax(roleService.deleteRoleByIds(ids));
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
return error(e.getMessage());
|
return error(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 校验角色名称
|
* 校验角色名称
|
||||||
*/
|
*/
|
||||||
@PostMapping("/checkRoleNameUnique")
|
@PostMapping("/checkRoleNameUnique")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String checkRoleNameUnique(SysRole role)
|
public String checkRoleNameUnique(SysRole role)
|
||||||
{
|
{
|
||||||
return roleService.checkRoleNameUnique(role);
|
return roleService.checkRoleNameUnique(role);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 校验角色权限
|
* 校验角色权限
|
||||||
*/
|
*/
|
||||||
@PostMapping("/checkRoleKeyUnique")
|
@PostMapping("/checkRoleKeyUnique")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String checkRoleKeyUnique(SysRole role)
|
public String checkRoleKeyUnique(SysRole role)
|
||||||
{
|
{
|
||||||
return roleService.checkRoleKeyUnique(role);
|
return roleService.checkRoleKeyUnique(role);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 选择菜单树
|
* 选择菜单树
|
||||||
*/
|
*/
|
||||||
@GetMapping("/selectMenuTree")
|
@GetMapping("/selectMenuTree")
|
||||||
public String selectMenuTree()
|
public String selectMenuTree()
|
||||||
{
|
{
|
||||||
return prefix + "/tree";
|
return prefix + "/tree";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 角色状态修改
|
* 角色状态修改
|
||||||
*/
|
*/
|
||||||
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
|
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
|
||||||
@RequiresPermissions("system:role:edit")
|
@RequiresPermissions("system:role:edit")
|
||||||
@PostMapping("/changeStatus")
|
@PostMapping("/changeStatus")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult changeStatus(SysRole role)
|
public AjaxResult changeStatus(SysRole role)
|
||||||
{
|
{
|
||||||
roleService.checkRoleAllowed(role);
|
roleService.checkRoleAllowed(role);
|
||||||
return toAjax(roleService.changeStatus(role));
|
return toAjax(roleService.changeStatus(role));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分配用户
|
* 分配用户
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("system:role:edit")
|
@RequiresPermissions("system:role:edit")
|
||||||
@GetMapping("/authUser/{roleId}")
|
@GetMapping("/authUser/{roleId}")
|
||||||
public String authUser(@PathVariable("roleId") Long roleId, ModelMap mmap)
|
public String authUser(@PathVariable("roleId") Long roleId, ModelMap mmap)
|
||||||
{
|
{
|
||||||
mmap.put("role", roleService.selectRoleById(roleId));
|
mmap.put("role", roleService.selectRoleById(roleId));
|
||||||
return prefix + "/authUser";
|
return prefix + "/authUser";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询已分配用户角色列表
|
* 查询已分配用户角色列表
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("system:role:list")
|
@RequiresPermissions("system:role:list")
|
||||||
@PostMapping("/authUser/allocatedList")
|
@PostMapping("/authUser/allocatedList")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public TableDataInfo allocatedList(SysUser user)
|
public TableDataInfo allocatedList(SysUser user)
|
||||||
{
|
{
|
||||||
startPage();
|
startPage();
|
||||||
List<SysUser> list = userService.selectAllocatedList(user);
|
List<SysUser> list = userService.selectAllocatedList(user);
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 取消授权
|
* 取消授权
|
||||||
*/
|
*/
|
||||||
@Log(title = "角色管理", businessType = BusinessType.GRANT)
|
@Log(title = "角色管理", businessType = BusinessType.GRANT)
|
||||||
@PostMapping("/authUser/cancel")
|
@PostMapping("/authUser/cancel")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult cancelAuthUser(SysUserRole userRole)
|
public AjaxResult cancelAuthUser(SysUserRole userRole)
|
||||||
{
|
{
|
||||||
return toAjax(roleService.deleteAuthUser(userRole));
|
return toAjax(roleService.deleteAuthUser(userRole));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量取消授权
|
* 批量取消授权
|
||||||
*/
|
*/
|
||||||
@Log(title = "角色管理", businessType = BusinessType.GRANT)
|
@Log(title = "角色管理", businessType = BusinessType.GRANT)
|
||||||
@PostMapping("/authUser/cancelAll")
|
@PostMapping("/authUser/cancelAll")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult cancelAuthUserAll(Long roleId, String userIds)
|
public AjaxResult cancelAuthUserAll(Long roleId, String userIds)
|
||||||
{
|
{
|
||||||
return toAjax(roleService.deleteAuthUsers(roleId, userIds));
|
return toAjax(roleService.deleteAuthUsers(roleId, userIds));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 选择用户
|
* 选择用户
|
||||||
*/
|
*/
|
||||||
@GetMapping("/authUser/selectUser/{roleId}")
|
@GetMapping("/authUser/selectUser/{roleId}")
|
||||||
public String selectUser(@PathVariable("roleId") Long roleId, ModelMap mmap)
|
public String selectUser(@PathVariable("roleId") Long roleId, ModelMap mmap)
|
||||||
{
|
{
|
||||||
mmap.put("role", roleService.selectRoleById(roleId));
|
mmap.put("role", roleService.selectRoleById(roleId));
|
||||||
return prefix + "/selectUser";
|
return prefix + "/selectUser";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询未分配用户角色列表
|
* 查询未分配用户角色列表
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("system:role:list")
|
@RequiresPermissions("system:role:list")
|
||||||
@PostMapping("/authUser/unallocatedList")
|
@PostMapping("/authUser/unallocatedList")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public TableDataInfo unallocatedList(SysUser user)
|
public TableDataInfo unallocatedList(SysUser user)
|
||||||
{
|
{
|
||||||
startPage();
|
startPage();
|
||||||
List<SysUser> list = userService.selectUnallocatedList(user);
|
List<SysUser> list = userService.selectUnallocatedList(user);
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量选择用户授权
|
* 批量选择用户授权
|
||||||
*/
|
*/
|
||||||
@Log(title = "角色管理", businessType = BusinessType.GRANT)
|
@Log(title = "角色管理", businessType = BusinessType.GRANT)
|
||||||
@PostMapping("/authUser/selectAll")
|
@PostMapping("/authUser/selectAll")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult selectAuthUserAll(Long roleId, String userIds)
|
public AjaxResult selectAuthUserAll(Long roleId, String userIds)
|
||||||
{
|
{
|
||||||
return toAjax(roleService.insertAuthUsers(roleId, userIds));
|
return toAjax(roleService.insertAuthUsers(roleId, userIds));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,292 +1,292 @@
|
||||||
package com.ruoyi.web.controller.system;
|
package com.ruoyi.web.controller.system;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.ModelMap;
|
import org.springframework.ui.ModelMap;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
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.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import com.ruoyi.common.annotation.Log;
|
import com.ruoyi.common.annotation.Log;
|
||||||
import com.ruoyi.common.constant.UserConstants;
|
import com.ruoyi.common.constant.UserConstants;
|
||||||
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
import com.ruoyi.common.enums.BusinessType;
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||||
import com.ruoyi.framework.shiro.service.SysPasswordService;
|
import com.ruoyi.framework.shiro.service.SysPasswordService;
|
||||||
import com.ruoyi.framework.util.ShiroUtils;
|
import com.ruoyi.framework.util.ShiroUtils;
|
||||||
import com.ruoyi.system.domain.SysRole;
|
import com.ruoyi.system.domain.SysRole;
|
||||||
import com.ruoyi.system.domain.SysUser;
|
import com.ruoyi.system.domain.SysUser;
|
||||||
import com.ruoyi.system.domain.SysUserRole;
|
import com.ruoyi.system.domain.SysUserRole;
|
||||||
import com.ruoyi.system.service.ISysPostService;
|
import com.ruoyi.system.service.ISysPostService;
|
||||||
import com.ruoyi.system.service.ISysRoleService;
|
import com.ruoyi.system.service.ISysRoleService;
|
||||||
import com.ruoyi.system.service.ISysUserService;
|
import com.ruoyi.system.service.ISysUserService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户信息
|
* 用户信息
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@Controller
|
@Controller
|
||||||
@RequestMapping("/system/user")
|
@RequestMapping("/system/user")
|
||||||
public class SysUserController extends BaseController
|
public class SysUserController extends BaseController
|
||||||
{
|
{
|
||||||
private String prefix = "system/user";
|
private String prefix = "system/user";
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysUserService userService;
|
private ISysUserService userService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysRoleService roleService;
|
private ISysRoleService roleService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysPostService postService;
|
private ISysPostService postService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SysPasswordService passwordService;
|
private SysPasswordService passwordService;
|
||||||
|
|
||||||
@RequiresPermissions("system:user:view")
|
@RequiresPermissions("system:user:view")
|
||||||
@GetMapping()
|
@GetMapping()
|
||||||
public String user()
|
public String user()
|
||||||
{
|
{
|
||||||
return prefix + "/user";
|
return prefix + "/user";
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiresPermissions("system:user:list")
|
@RequiresPermissions("system:user:list")
|
||||||
@PostMapping("/list")
|
@PostMapping("/list")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public TableDataInfo list(SysUser user)
|
public TableDataInfo list(SysUser user)
|
||||||
{
|
{
|
||||||
startPage();
|
startPage();
|
||||||
List<SysUser> list = userService.selectUserList(user);
|
List<SysUser> list = userService.selectUserList(user);
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Log(title = "用户管理", businessType = BusinessType.EXPORT)
|
@Log(title = "用户管理", businessType = BusinessType.EXPORT)
|
||||||
@RequiresPermissions("system:user:export")
|
@RequiresPermissions("system:user:export")
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult export(SysUser user)
|
public AjaxResult export(SysUser user)
|
||||||
{
|
{
|
||||||
List<SysUser> list = userService.selectUserList(user);
|
List<SysUser> list = userService.selectUserList(user);
|
||||||
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
|
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
|
||||||
return util.exportExcel(list, "用户数据");
|
return util.exportExcel(list, "用户数据");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Log(title = "用户管理", businessType = BusinessType.IMPORT)
|
@Log(title = "用户管理", businessType = BusinessType.IMPORT)
|
||||||
@RequiresPermissions("system:user:import")
|
@RequiresPermissions("system:user:import")
|
||||||
@PostMapping("/importData")
|
@PostMapping("/importData")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception
|
public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception
|
||||||
{
|
{
|
||||||
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
|
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
|
||||||
List<SysUser> userList = util.importExcel(file.getInputStream());
|
List<SysUser> userList = util.importExcel(file.getInputStream());
|
||||||
String operName = ShiroUtils.getSysUser().getLoginName();
|
String operName = ShiroUtils.getSysUser().getLoginName();
|
||||||
String message = userService.importUser(userList, updateSupport, operName);
|
String message = userService.importUser(userList, updateSupport, operName);
|
||||||
return AjaxResult.success(message);
|
return AjaxResult.success(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiresPermissions("system:user:view")
|
@RequiresPermissions("system:user:view")
|
||||||
@GetMapping("/importTemplate")
|
@GetMapping("/importTemplate")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult importTemplate()
|
public AjaxResult importTemplate()
|
||||||
{
|
{
|
||||||
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
|
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
|
||||||
return util.importTemplateExcel("用户数据");
|
return util.importTemplateExcel("用户数据");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增用户
|
* 新增用户
|
||||||
*/
|
*/
|
||||||
@GetMapping("/add")
|
@GetMapping("/add")
|
||||||
public String add(ModelMap mmap)
|
public String add(ModelMap mmap)
|
||||||
{
|
{
|
||||||
mmap.put("roles", roleService.selectRoleAll().stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
|
mmap.put("roles", roleService.selectRoleAll().stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
|
||||||
mmap.put("posts", postService.selectPostAll());
|
mmap.put("posts", postService.selectPostAll());
|
||||||
return prefix + "/add";
|
return prefix + "/add";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增保存用户
|
* 新增保存用户
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("system:user:add")
|
@RequiresPermissions("system:user:add")
|
||||||
@Log(title = "用户管理", businessType = BusinessType.INSERT)
|
@Log(title = "用户管理", businessType = BusinessType.INSERT)
|
||||||
@PostMapping("/add")
|
@PostMapping("/add")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult addSave(@Validated SysUser user)
|
public AjaxResult addSave(@Validated SysUser user)
|
||||||
{
|
{
|
||||||
if (UserConstants.USER_NAME_NOT_UNIQUE.equals(userService.checkLoginNameUnique(user.getLoginName())))
|
if (UserConstants.USER_NAME_NOT_UNIQUE.equals(userService.checkLoginNameUnique(user.getLoginName())))
|
||||||
{
|
{
|
||||||
return error("新增用户'" + user.getLoginName() + "'失败,登录账号已存在");
|
return error("新增用户'" + user.getLoginName() + "'失败,登录账号已存在");
|
||||||
}
|
}
|
||||||
else if (UserConstants.USER_PHONE_NOT_UNIQUE.equals(userService.checkPhoneUnique(user)))
|
else if (UserConstants.USER_PHONE_NOT_UNIQUE.equals(userService.checkPhoneUnique(user)))
|
||||||
{
|
{
|
||||||
return error("新增用户'" + user.getLoginName() + "'失败,手机号码已存在");
|
return error("新增用户'" + user.getLoginName() + "'失败,手机号码已存在");
|
||||||
}
|
}
|
||||||
else if (UserConstants.USER_EMAIL_NOT_UNIQUE.equals(userService.checkEmailUnique(user)))
|
else if (UserConstants.USER_EMAIL_NOT_UNIQUE.equals(userService.checkEmailUnique(user)))
|
||||||
{
|
{
|
||||||
return error("新增用户'" + user.getLoginName() + "'失败,邮箱账号已存在");
|
return error("新增用户'" + user.getLoginName() + "'失败,邮箱账号已存在");
|
||||||
}
|
}
|
||||||
user.setSalt(ShiroUtils.randomSalt());
|
user.setSalt(ShiroUtils.randomSalt());
|
||||||
user.setPassword(passwordService.encryptPassword(user.getLoginName(), user.getPassword(), user.getSalt()));
|
user.setPassword(passwordService.encryptPassword(user.getLoginName(), user.getPassword(), user.getSalt()));
|
||||||
user.setCreateBy(ShiroUtils.getLoginName());
|
user.setCreateBy(ShiroUtils.getLoginName());
|
||||||
return toAjax(userService.insertUser(user));
|
return toAjax(userService.insertUser(user));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改用户
|
* 修改用户
|
||||||
*/
|
*/
|
||||||
@GetMapping("/edit/{userId}")
|
@GetMapping("/edit/{userId}")
|
||||||
public String edit(@PathVariable("userId") Long userId, ModelMap mmap)
|
public String edit(@PathVariable("userId") Long userId, ModelMap mmap)
|
||||||
{
|
{
|
||||||
List<SysRole> roles = roleService.selectRolesByUserId(userId);
|
List<SysRole> roles = roleService.selectRolesByUserId(userId);
|
||||||
mmap.put("user", userService.selectUserById(userId));
|
mmap.put("user", userService.selectUserById(userId));
|
||||||
mmap.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
|
mmap.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
|
||||||
mmap.put("posts", postService.selectPostsByUserId(userId));
|
mmap.put("posts", postService.selectPostsByUserId(userId));
|
||||||
return prefix + "/edit";
|
return prefix + "/edit";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改保存用户
|
* 修改保存用户
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("system:user:edit")
|
@RequiresPermissions("system:user:edit")
|
||||||
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
||||||
@PostMapping("/edit")
|
@PostMapping("/edit")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult editSave(@Validated SysUser user)
|
public AjaxResult editSave(@Validated SysUser user)
|
||||||
{
|
{
|
||||||
userService.checkUserAllowed(user);
|
userService.checkUserAllowed(user);
|
||||||
if (UserConstants.USER_PHONE_NOT_UNIQUE.equals(userService.checkPhoneUnique(user)))
|
if (UserConstants.USER_PHONE_NOT_UNIQUE.equals(userService.checkPhoneUnique(user)))
|
||||||
{
|
{
|
||||||
return error("修改用户'" + user.getLoginName() + "'失败,手机号码已存在");
|
return error("修改用户'" + user.getLoginName() + "'失败,手机号码已存在");
|
||||||
}
|
}
|
||||||
else if (UserConstants.USER_EMAIL_NOT_UNIQUE.equals(userService.checkEmailUnique(user)))
|
else if (UserConstants.USER_EMAIL_NOT_UNIQUE.equals(userService.checkEmailUnique(user)))
|
||||||
{
|
{
|
||||||
return error("修改用户'" + user.getLoginName() + "'失败,邮箱账号已存在");
|
return error("修改用户'" + user.getLoginName() + "'失败,邮箱账号已存在");
|
||||||
}
|
}
|
||||||
user.setUpdateBy(ShiroUtils.getLoginName());
|
user.setUpdateBy(ShiroUtils.getLoginName());
|
||||||
return toAjax(userService.updateUser(user));
|
return toAjax(userService.updateUser(user));
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiresPermissions("system:user:resetPwd")
|
@RequiresPermissions("system:user:resetPwd")
|
||||||
@Log(title = "重置密码", businessType = BusinessType.UPDATE)
|
@Log(title = "重置密码", businessType = BusinessType.UPDATE)
|
||||||
@GetMapping("/resetPwd/{userId}")
|
@GetMapping("/resetPwd/{userId}")
|
||||||
public String resetPwd(@PathVariable("userId") Long userId, ModelMap mmap)
|
public String resetPwd(@PathVariable("userId") Long userId, ModelMap mmap)
|
||||||
{
|
{
|
||||||
mmap.put("user", userService.selectUserById(userId));
|
mmap.put("user", userService.selectUserById(userId));
|
||||||
return prefix + "/resetPwd";
|
return prefix + "/resetPwd";
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiresPermissions("system:user:resetPwd")
|
@RequiresPermissions("system:user:resetPwd")
|
||||||
@Log(title = "重置密码", businessType = BusinessType.UPDATE)
|
@Log(title = "重置密码", businessType = BusinessType.UPDATE)
|
||||||
@PostMapping("/resetPwd")
|
@PostMapping("/resetPwd")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult resetPwdSave(SysUser user)
|
public AjaxResult resetPwdSave(SysUser user)
|
||||||
{
|
{
|
||||||
userService.checkUserAllowed(user);
|
userService.checkUserAllowed(user);
|
||||||
user.setSalt(ShiroUtils.randomSalt());
|
user.setSalt(ShiroUtils.randomSalt());
|
||||||
user.setPassword(passwordService.encryptPassword(user.getLoginName(), user.getPassword(), user.getSalt()));
|
user.setPassword(passwordService.encryptPassword(user.getLoginName(), user.getPassword(), user.getSalt()));
|
||||||
if (userService.resetUserPwd(user) > 0)
|
if (userService.resetUserPwd(user) > 0)
|
||||||
{
|
{
|
||||||
if (ShiroUtils.getUserId().longValue() == user.getUserId().longValue())
|
if (ShiroUtils.getUserId().longValue() == user.getUserId().longValue())
|
||||||
{
|
{
|
||||||
ShiroUtils.setSysUser(userService.selectUserById(user.getUserId()));
|
ShiroUtils.setSysUser(userService.selectUserById(user.getUserId()));
|
||||||
}
|
}
|
||||||
return success();
|
return success();
|
||||||
}
|
}
|
||||||
return error();
|
return error();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 进入授权角色页
|
* 进入授权角色页
|
||||||
*/
|
*/
|
||||||
@GetMapping("/authRole/{userId}")
|
@GetMapping("/authRole/{userId}")
|
||||||
public String authRole(@PathVariable("userId") Long userId, ModelMap mmap)
|
public String authRole(@PathVariable("userId") Long userId, ModelMap mmap)
|
||||||
{
|
{
|
||||||
SysUser user = userService.selectUserById(userId);
|
SysUser user = userService.selectUserById(userId);
|
||||||
// 获取用户所属的角色列表
|
// 获取用户所属的角色列表
|
||||||
List<SysUserRole> userRoles = userService.selectUserRoleByUserId(userId);
|
List<SysUserRole> userRoles = userService.selectUserRoleByUserId(userId);
|
||||||
mmap.put("user", user);
|
mmap.put("user", user);
|
||||||
mmap.put("userRoles", userRoles);
|
mmap.put("userRoles", userRoles);
|
||||||
return prefix + "/authRole";
|
return prefix + "/authRole";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户授权角色
|
* 用户授权角色
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("system:user:add")
|
@RequiresPermissions("system:user:add")
|
||||||
@Log(title = "用户管理", businessType = BusinessType.GRANT)
|
@Log(title = "用户管理", businessType = BusinessType.GRANT)
|
||||||
@PostMapping("/authRole/insertAuthRole")
|
@PostMapping("/authRole/insertAuthRole")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult insertAuthRole(Long userId, Long[] roleIds)
|
public AjaxResult insertAuthRole(Long userId, Long[] roleIds)
|
||||||
{
|
{
|
||||||
userService.insertUserAuth(userId, roleIds);
|
userService.insertUserAuth(userId, roleIds);
|
||||||
return success();
|
return success();
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiresPermissions("system:user:remove")
|
@RequiresPermissions("system:user:remove")
|
||||||
@Log(title = "用户管理", businessType = BusinessType.DELETE)
|
@Log(title = "用户管理", businessType = BusinessType.DELETE)
|
||||||
@PostMapping("/remove")
|
@PostMapping("/remove")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult remove(String ids)
|
public AjaxResult remove(String ids)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return toAjax(userService.deleteUserByIds(ids));
|
return toAjax(userService.deleteUserByIds(ids));
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
return error(e.getMessage());
|
return error(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 校验用户名
|
* 校验用户名
|
||||||
*/
|
*/
|
||||||
@PostMapping("/checkLoginNameUnique")
|
@PostMapping("/checkLoginNameUnique")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String checkLoginNameUnique(SysUser user)
|
public String checkLoginNameUnique(SysUser user)
|
||||||
{
|
{
|
||||||
return userService.checkLoginNameUnique(user.getLoginName());
|
return userService.checkLoginNameUnique(user.getLoginName());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 校验手机号码
|
* 校验手机号码
|
||||||
*/
|
*/
|
||||||
@PostMapping("/checkPhoneUnique")
|
@PostMapping("/checkPhoneUnique")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String checkPhoneUnique(SysUser user)
|
public String checkPhoneUnique(SysUser user)
|
||||||
{
|
{
|
||||||
return userService.checkPhoneUnique(user);
|
return userService.checkPhoneUnique(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 校验email邮箱
|
* 校验email邮箱
|
||||||
*/
|
*/
|
||||||
@PostMapping("/checkEmailUnique")
|
@PostMapping("/checkEmailUnique")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String checkEmailUnique(SysUser user)
|
public String checkEmailUnique(SysUser user)
|
||||||
{
|
{
|
||||||
return userService.checkEmailUnique(user);
|
return userService.checkEmailUnique(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户状态修改
|
* 用户状态修改
|
||||||
*/
|
*/
|
||||||
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
||||||
@RequiresPermissions("system:user:edit")
|
@RequiresPermissions("system:user:edit")
|
||||||
@PostMapping("/changeStatus")
|
@PostMapping("/changeStatus")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult changeStatus(SysUser user)
|
public AjaxResult changeStatus(SysUser user)
|
||||||
{
|
{
|
||||||
userService.checkUserAllowed(user);
|
userService.checkUserAllowed(user);
|
||||||
return toAjax(userService.changeStatus(user));
|
return toAjax(userService.changeStatus(user));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,26 +1,26 @@
|
||||||
package com.ruoyi.web.controller.tool;
|
package com.ruoyi.web.controller.tool;
|
||||||
|
|
||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* build 表单构建
|
* build 表单构建
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@Controller
|
@Controller
|
||||||
@RequestMapping("/tool/build")
|
@RequestMapping("/tool/build")
|
||||||
public class BuildController extends BaseController
|
public class BuildController extends BaseController
|
||||||
{
|
{
|
||||||
private String prefix = "tool/build";
|
private String prefix = "tool/build";
|
||||||
|
|
||||||
@RequiresPermissions("tool:build:view")
|
@RequiresPermissions("tool:build:view")
|
||||||
@GetMapping()
|
@GetMapping()
|
||||||
public String build()
|
public String build()
|
||||||
{
|
{
|
||||||
return prefix + "/build";
|
return prefix + "/build";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,24 +1,24 @@
|
||||||
package com.ruoyi.web.controller.tool;
|
package com.ruoyi.web.controller.tool;
|
||||||
|
|
||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* swagger 接口
|
* swagger 接口
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@Controller
|
@Controller
|
||||||
@RequestMapping("/tool/swagger")
|
@RequestMapping("/tool/swagger")
|
||||||
public class SwaggerController extends BaseController
|
public class SwaggerController extends BaseController
|
||||||
{
|
{
|
||||||
@RequiresPermissions("tool:swagger:view")
|
@RequiresPermissions("tool:swagger:view")
|
||||||
@GetMapping()
|
@GetMapping()
|
||||||
public String index()
|
public String index()
|
||||||
{
|
{
|
||||||
return redirect("/swagger-ui.html");
|
return redirect("/swagger-ui.html");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,175 +1,175 @@
|
||||||
package com.ruoyi.web.controller.tool;
|
package com.ruoyi.web.controller.tool;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
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 org.springframework.web.bind.annotation.DeleteMapping;
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.PutMapping;
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiImplicitParam;
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* swagger 用户测试方法
|
* swagger 用户测试方法
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@Api("用户信息管理")
|
@Api("用户信息管理")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/test/user")
|
@RequestMapping("/test/user")
|
||||||
public class TestController extends BaseController
|
public class TestController extends BaseController
|
||||||
{
|
{
|
||||||
private final static Map<Integer, UserEntity> users = new LinkedHashMap<Integer, UserEntity>();
|
private final static Map<Integer, UserEntity> users = new LinkedHashMap<Integer, UserEntity>();
|
||||||
{
|
{
|
||||||
users.put(1, new UserEntity(1, "admin", "admin123", "15888888888"));
|
users.put(1, new UserEntity(1, "admin", "admin123", "15888888888"));
|
||||||
users.put(2, new UserEntity(2, "ry", "admin123", "15666666666"));
|
users.put(2, new UserEntity(2, "ry", "admin123", "15666666666"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("获取用户列表")
|
@ApiOperation("获取用户列表")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public AjaxResult userList()
|
public AjaxResult userList()
|
||||||
{
|
{
|
||||||
List<UserEntity> userList = new ArrayList<UserEntity>(users.values());
|
List<UserEntity> userList = new ArrayList<UserEntity>(users.values());
|
||||||
return AjaxResult.success(userList);
|
return AjaxResult.success(userList);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("获取用户详细")
|
@ApiOperation("获取用户详细")
|
||||||
@ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path")
|
@ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path")
|
||||||
@GetMapping("/{userId}")
|
@GetMapping("/{userId}")
|
||||||
public AjaxResult getUser(@PathVariable Integer userId)
|
public AjaxResult getUser(@PathVariable Integer userId)
|
||||||
{
|
{
|
||||||
if (!users.isEmpty() && users.containsKey(userId))
|
if (!users.isEmpty() && users.containsKey(userId))
|
||||||
{
|
{
|
||||||
return AjaxResult.success(users.get(userId));
|
return AjaxResult.success(users.get(userId));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return error("用户不存在");
|
return error("用户不存在");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("新增用户")
|
@ApiOperation("新增用户")
|
||||||
@ApiImplicitParam(name = "userEntity", value = "新增用户信息", dataType = "UserEntity")
|
@ApiImplicitParam(name = "userEntity", value = "新增用户信息", dataType = "UserEntity")
|
||||||
@PostMapping("/save")
|
@PostMapping("/save")
|
||||||
public AjaxResult save(UserEntity user)
|
public AjaxResult save(UserEntity user)
|
||||||
{
|
{
|
||||||
if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId()))
|
if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId()))
|
||||||
{
|
{
|
||||||
return error("用户ID不能为空");
|
return error("用户ID不能为空");
|
||||||
}
|
}
|
||||||
return AjaxResult.success(users.put(user.getUserId(), user));
|
return AjaxResult.success(users.put(user.getUserId(), user));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("更新用户")
|
@ApiOperation("更新用户")
|
||||||
@ApiImplicitParam(name = "userEntity", value = "新增用户信息", dataType = "UserEntity")
|
@ApiImplicitParam(name = "userEntity", value = "新增用户信息", dataType = "UserEntity")
|
||||||
@PutMapping("/update")
|
@PutMapping("/update")
|
||||||
public AjaxResult update(UserEntity user)
|
public AjaxResult update(UserEntity user)
|
||||||
{
|
{
|
||||||
if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId()))
|
if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId()))
|
||||||
{
|
{
|
||||||
return error("用户ID不能为空");
|
return error("用户ID不能为空");
|
||||||
}
|
}
|
||||||
if (users.isEmpty() || !users.containsKey(user.getUserId()))
|
if (users.isEmpty() || !users.containsKey(user.getUserId()))
|
||||||
{
|
{
|
||||||
return error("用户不存在");
|
return error("用户不存在");
|
||||||
}
|
}
|
||||||
users.remove(user.getUserId());
|
users.remove(user.getUserId());
|
||||||
return AjaxResult.success(users.put(user.getUserId(), user));
|
return AjaxResult.success(users.put(user.getUserId(), user));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("删除用户信息")
|
@ApiOperation("删除用户信息")
|
||||||
@ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path")
|
@ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path")
|
||||||
@DeleteMapping("/{userId}")
|
@DeleteMapping("/{userId}")
|
||||||
public AjaxResult delete(@PathVariable Integer userId)
|
public AjaxResult delete(@PathVariable Integer userId)
|
||||||
{
|
{
|
||||||
if (!users.isEmpty() && users.containsKey(userId))
|
if (!users.isEmpty() && users.containsKey(userId))
|
||||||
{
|
{
|
||||||
users.remove(userId);
|
users.remove(userId);
|
||||||
return success();
|
return success();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return error("用户不存在");
|
return error("用户不存在");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiModel("用户实体")
|
@ApiModel("用户实体")
|
||||||
class UserEntity
|
class UserEntity
|
||||||
{
|
{
|
||||||
@ApiModelProperty("用户ID")
|
@ApiModelProperty("用户ID")
|
||||||
private Integer userId;
|
private Integer userId;
|
||||||
|
|
||||||
@ApiModelProperty("用户名称")
|
@ApiModelProperty("用户名称")
|
||||||
private String username;
|
private String username;
|
||||||
|
|
||||||
@ApiModelProperty("用户密码")
|
@ApiModelProperty("用户密码")
|
||||||
private String password;
|
private String password;
|
||||||
|
|
||||||
@ApiModelProperty("用户手机")
|
@ApiModelProperty("用户手机")
|
||||||
private String mobile;
|
private String mobile;
|
||||||
|
|
||||||
public UserEntity()
|
public UserEntity()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public UserEntity(Integer userId, String username, String password, String mobile)
|
public UserEntity(Integer userId, String username, String password, String mobile)
|
||||||
{
|
{
|
||||||
this.userId = userId;
|
this.userId = userId;
|
||||||
this.username = username;
|
this.username = username;
|
||||||
this.password = password;
|
this.password = password;
|
||||||
this.mobile = mobile;
|
this.mobile = mobile;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getUserId()
|
public Integer getUserId()
|
||||||
{
|
{
|
||||||
return userId;
|
return userId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUserId(Integer userId)
|
public void setUserId(Integer userId)
|
||||||
{
|
{
|
||||||
this.userId = userId;
|
this.userId = userId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUsername()
|
public String getUsername()
|
||||||
{
|
{
|
||||||
return username;
|
return username;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUsername(String username)
|
public void setUsername(String username)
|
||||||
{
|
{
|
||||||
this.username = username;
|
this.username = username;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPassword()
|
public String getPassword()
|
||||||
{
|
{
|
||||||
return password;
|
return password;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPassword(String password)
|
public void setPassword(String password)
|
||||||
{
|
{
|
||||||
this.password = password;
|
this.password = password;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMobile()
|
public String getMobile()
|
||||||
{
|
{
|
||||||
return mobile;
|
return mobile;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMobile(String mobile)
|
public void setMobile(String mobile)
|
||||||
{
|
{
|
||||||
this.mobile = mobile;
|
this.mobile = mobile;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,69 +1,69 @@
|
||||||
package com.ruoyi.web.core.config;
|
package com.ruoyi.web.core.config;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import com.ruoyi.common.config.Global;
|
import com.ruoyi.common.config.Global;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import springfox.documentation.builders.ApiInfoBuilder;
|
import springfox.documentation.builders.ApiInfoBuilder;
|
||||||
import springfox.documentation.builders.PathSelectors;
|
import springfox.documentation.builders.PathSelectors;
|
||||||
import springfox.documentation.builders.RequestHandlerSelectors;
|
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||||
import springfox.documentation.service.ApiInfo;
|
import springfox.documentation.service.ApiInfo;
|
||||||
import springfox.documentation.service.Contact;
|
import springfox.documentation.service.Contact;
|
||||||
import springfox.documentation.spi.DocumentationType;
|
import springfox.documentation.spi.DocumentationType;
|
||||||
import springfox.documentation.spring.web.plugins.Docket;
|
import springfox.documentation.spring.web.plugins.Docket;
|
||||||
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Swagger2的接口配置
|
* Swagger2的接口配置
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableSwagger2
|
@EnableSwagger2
|
||||||
public class SwaggerConfig
|
public class SwaggerConfig
|
||||||
{
|
{
|
||||||
/** 是否开启swagger */
|
/** 是否开启swagger */
|
||||||
@Value("${swagger.enabled}")
|
@Value("${swagger.enabled}")
|
||||||
private boolean enabled;
|
private boolean enabled;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建API
|
* 创建API
|
||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
public Docket createRestApi()
|
public Docket createRestApi()
|
||||||
{
|
{
|
||||||
return new Docket(DocumentationType.SWAGGER_2)
|
return new Docket(DocumentationType.SWAGGER_2)
|
||||||
// 是否启用Swagger
|
// 是否启用Swagger
|
||||||
.enable(enabled)
|
.enable(enabled)
|
||||||
// 用来创建该API的基本信息,展示在文档的页面中(自定义展示的信息)
|
// 用来创建该API的基本信息,展示在文档的页面中(自定义展示的信息)
|
||||||
.apiInfo(apiInfo())
|
.apiInfo(apiInfo())
|
||||||
// 设置哪些接口暴露给Swagger展示
|
// 设置哪些接口暴露给Swagger展示
|
||||||
.select()
|
.select()
|
||||||
// 扫描所有有注解的api,用这种方式更灵活
|
// 扫描所有有注解的api,用这种方式更灵活
|
||||||
.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
|
.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
|
||||||
// 扫描指定包中的swagger注解
|
// 扫描指定包中的swagger注解
|
||||||
//.apis(RequestHandlerSelectors.basePackage("com.ruoyi.project.tool.swagger"))
|
//.apis(RequestHandlerSelectors.basePackage("com.ruoyi.project.tool.swagger"))
|
||||||
// 扫描所有 .apis(RequestHandlerSelectors.any())
|
// 扫描所有 .apis(RequestHandlerSelectors.any())
|
||||||
.paths(PathSelectors.any())
|
.paths(PathSelectors.any())
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加摘要信息
|
* 添加摘要信息
|
||||||
*/
|
*/
|
||||||
private ApiInfo apiInfo()
|
private ApiInfo apiInfo()
|
||||||
{
|
{
|
||||||
// 用ApiInfoBuilder进行定制
|
// 用ApiInfoBuilder进行定制
|
||||||
return new ApiInfoBuilder()
|
return new ApiInfoBuilder()
|
||||||
// 设置标题
|
// 设置标题
|
||||||
.title("标题:若依管理系统_接口文档")
|
.title("标题:若依管理系统_接口文档")
|
||||||
// 描述
|
// 描述
|
||||||
.description("描述:用于管理集团旗下公司的人员信息,具体包括XXX,XXX模块...")
|
.description("描述:用于管理集团旗下公司的人员信息,具体包括XXX,XXX模块...")
|
||||||
// 作者信息
|
// 作者信息
|
||||||
.contact(new Contact(Global.getName(), null, null))
|
.contact(new Contact(Global.getName(), null, null))
|
||||||
// 版本
|
// 版本
|
||||||
.version("版本号:" + Global.getVersion())
|
.version("版本号:" + Global.getVersion())
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<parent>
|
||||||
|
<artifactId>ruoyi</artifactId>
|
||||||
|
<groupId>com.ruoyi</groupId>
|
||||||
|
<version>4.3.1</version>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<artifactId>ruoyi-alg</artifactId>
|
||||||
|
|
||||||
|
|
||||||
|
</project>
|
||||||
|
|
@ -1,28 +1,28 @@
|
||||||
package com.ruoyi.common.annotation;
|
package com.ruoyi.common.annotation;
|
||||||
|
|
||||||
import java.lang.annotation.Documented;
|
import java.lang.annotation.Documented;
|
||||||
import java.lang.annotation.ElementType;
|
import java.lang.annotation.ElementType;
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数据权限过滤注解
|
* 数据权限过滤注解
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@Target(ElementType.METHOD)
|
@Target(ElementType.METHOD)
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Documented
|
@Documented
|
||||||
public @interface DataScope
|
public @interface DataScope
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* 部门表的别名
|
* 部门表的别名
|
||||||
*/
|
*/
|
||||||
public String deptAlias() default "";
|
public String deptAlias() default "";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户表的别名
|
* 用户表的别名
|
||||||
*/
|
*/
|
||||||
public String userAlias() default "";
|
public String userAlias() default "";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,28 +1,28 @@
|
||||||
package com.ruoyi.common.annotation;
|
package com.ruoyi.common.annotation;
|
||||||
|
|
||||||
import java.lang.annotation.Documented;
|
import java.lang.annotation.Documented;
|
||||||
import java.lang.annotation.ElementType;
|
import java.lang.annotation.ElementType;
|
||||||
import java.lang.annotation.Inherited;
|
import java.lang.annotation.Inherited;
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
import com.ruoyi.common.enums.DataSourceType;
|
import com.ruoyi.common.enums.DataSourceType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 自定义多数据源切换注解
|
* 自定义多数据源切换注解
|
||||||
*
|
*
|
||||||
* 优先级:先方法,后类,如果方法覆盖了类上的数据源类型,以方法的为准,否则以类上的为准
|
* 优先级:先方法,后类,如果方法覆盖了类上的数据源类型,以方法的为准,否则以类上的为准
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@Target({ ElementType.METHOD, ElementType.TYPE })
|
@Target({ ElementType.METHOD, ElementType.TYPE })
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Documented
|
@Documented
|
||||||
@Inherited
|
@Inherited
|
||||||
public @interface DataSource
|
public @interface DataSource
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* 切换数据源名称
|
* 切换数据源名称
|
||||||
*/
|
*/
|
||||||
public DataSourceType value() default DataSourceType.MASTER;
|
public DataSourceType value() default DataSourceType.MASTER;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,123 +1,123 @@
|
||||||
package com.ruoyi.common.annotation;
|
package com.ruoyi.common.annotation;
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
import java.lang.annotation.ElementType;
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 自定义导出Excel数据注解
|
* 自定义导出Excel数据注解
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Target(ElementType.FIELD)
|
@Target(ElementType.FIELD)
|
||||||
public @interface Excel
|
public @interface Excel
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* 导出到Excel中的名字.
|
* 导出到Excel中的名字.
|
||||||
*/
|
*/
|
||||||
public String name() default "";
|
public String name() default "";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 日期格式, 如: yyyy-MM-dd
|
* 日期格式, 如: yyyy-MM-dd
|
||||||
*/
|
*/
|
||||||
public String dateFormat() default "";
|
public String dateFormat() default "";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 如果是字典类型,请设置字典的type值 (如: sys_user_sex)
|
* 如果是字典类型,请设置字典的type值 (如: sys_user_sex)
|
||||||
*/
|
*/
|
||||||
public String dictType() default "";
|
public String dictType() default "";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 读取内容转表达式 (如: 0=男,1=女,2=未知)
|
* 读取内容转表达式 (如: 0=男,1=女,2=未知)
|
||||||
*/
|
*/
|
||||||
public String readConverterExp() default "";
|
public String readConverterExp() default "";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分隔符,读取字符串组内容
|
* 分隔符,读取字符串组内容
|
||||||
*/
|
*/
|
||||||
public String separator() default ",";
|
public String separator() default ",";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出类型(0数字 1字符串)
|
* 导出类型(0数字 1字符串)
|
||||||
*/
|
*/
|
||||||
public ColumnType cellType() default ColumnType.STRING;
|
public ColumnType cellType() default ColumnType.STRING;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出时在excel中每个列的高度 单位为字符
|
* 导出时在excel中每个列的高度 单位为字符
|
||||||
*/
|
*/
|
||||||
public double height() default 14;
|
public double height() default 14;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出时在excel中每个列的宽 单位为字符
|
* 导出时在excel中每个列的宽 单位为字符
|
||||||
*/
|
*/
|
||||||
public double width() default 16;
|
public double width() default 16;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文字后缀,如% 90 变成90%
|
* 文字后缀,如% 90 变成90%
|
||||||
*/
|
*/
|
||||||
public String suffix() default "";
|
public String suffix() default "";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 当值为空时,字段的默认值
|
* 当值为空时,字段的默认值
|
||||||
*/
|
*/
|
||||||
public String defaultValue() default "";
|
public String defaultValue() default "";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 提示信息
|
* 提示信息
|
||||||
*/
|
*/
|
||||||
public String prompt() default "";
|
public String prompt() default "";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置只能选择不能输入的列内容.
|
* 设置只能选择不能输入的列内容.
|
||||||
*/
|
*/
|
||||||
public String[] combo() default {};
|
public String[] combo() default {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否导出数据,应对需求:有时我们需要导出一份模板,这是标题需要但内容需要用户手工填写.
|
* 是否导出数据,应对需求:有时我们需要导出一份模板,这是标题需要但内容需要用户手工填写.
|
||||||
*/
|
*/
|
||||||
public boolean isExport() default true;
|
public boolean isExport() default true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 另一个类中的属性名称,支持多级获取,以小数点隔开
|
* 另一个类中的属性名称,支持多级获取,以小数点隔开
|
||||||
*/
|
*/
|
||||||
public String targetAttr() default "";
|
public String targetAttr() default "";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字段类型(0:导出导入;1:仅导出;2:仅导入)
|
* 字段类型(0:导出导入;1:仅导出;2:仅导入)
|
||||||
*/
|
*/
|
||||||
Type type() default Type.ALL;
|
Type type() default Type.ALL;
|
||||||
|
|
||||||
public enum Type
|
public enum Type
|
||||||
{
|
{
|
||||||
ALL(0), EXPORT(1), IMPORT(2);
|
ALL(0), EXPORT(1), IMPORT(2);
|
||||||
private final int value;
|
private final int value;
|
||||||
|
|
||||||
Type(int value)
|
Type(int value)
|
||||||
{
|
{
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int value()
|
public int value()
|
||||||
{
|
{
|
||||||
return this.value;
|
return this.value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum ColumnType
|
public enum ColumnType
|
||||||
{
|
{
|
||||||
NUMERIC(0), STRING(1);
|
NUMERIC(0), STRING(1);
|
||||||
private final int value;
|
private final int value;
|
||||||
|
|
||||||
ColumnType(int value)
|
ColumnType(int value)
|
||||||
{
|
{
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int value()
|
public int value()
|
||||||
{
|
{
|
||||||
return this.value;
|
return this.value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,40 +1,40 @@
|
||||||
package com.ruoyi.common.annotation;
|
package com.ruoyi.common.annotation;
|
||||||
|
|
||||||
import java.lang.annotation.Documented;
|
import java.lang.annotation.Documented;
|
||||||
import java.lang.annotation.ElementType;
|
import java.lang.annotation.ElementType;
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
import com.ruoyi.common.enums.BusinessType;
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
import com.ruoyi.common.enums.OperatorType;
|
import com.ruoyi.common.enums.OperatorType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 自定义操作日志记录注解
|
* 自定义操作日志记录注解
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@Target({ ElementType.PARAMETER, ElementType.METHOD })
|
@Target({ ElementType.PARAMETER, ElementType.METHOD })
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Documented
|
@Documented
|
||||||
public @interface Log
|
public @interface Log
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* 模块
|
* 模块
|
||||||
*/
|
*/
|
||||||
public String title() default "";
|
public String title() default "";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 功能
|
* 功能
|
||||||
*/
|
*/
|
||||||
public BusinessType businessType() default BusinessType.OTHER;
|
public BusinessType businessType() default BusinessType.OTHER;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 操作人类别
|
* 操作人类别
|
||||||
*/
|
*/
|
||||||
public OperatorType operatorType() default OperatorType.MANAGE;
|
public OperatorType operatorType() default OperatorType.MANAGE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否保存请求的参数
|
* 是否保存请求的参数
|
||||||
*/
|
*/
|
||||||
public boolean isSaveRequestData() default true;
|
public boolean isSaveRequestData() default true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,116 +1,116 @@
|
||||||
package com.ruoyi.common.config;
|
package com.ruoyi.common.config;
|
||||||
|
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 全局配置类
|
* 全局配置类
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
@ConfigurationProperties(prefix = "ruoyi")
|
@ConfigurationProperties(prefix = "ruoyi")
|
||||||
public class Global
|
public class Global
|
||||||
{
|
{
|
||||||
/** 项目名称 */
|
/** 项目名称 */
|
||||||
private static String name;
|
private static String name;
|
||||||
|
|
||||||
/** 版本 */
|
/** 版本 */
|
||||||
private static String version;
|
private static String version;
|
||||||
|
|
||||||
/** 版权年份 */
|
/** 版权年份 */
|
||||||
private static String copyrightYear;
|
private static String copyrightYear;
|
||||||
|
|
||||||
/** 实例演示开关 */
|
/** 实例演示开关 */
|
||||||
private static boolean demoEnabled;
|
private static boolean demoEnabled;
|
||||||
|
|
||||||
/** 上传路径 */
|
/** 上传路径 */
|
||||||
private static String profile;
|
private static String profile;
|
||||||
|
|
||||||
/** 获取地址开关 */
|
/** 获取地址开关 */
|
||||||
private static boolean addressEnabled;
|
private static boolean addressEnabled;
|
||||||
|
|
||||||
public static String getName()
|
public static String getName()
|
||||||
{
|
{
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setName(String name)
|
public void setName(String name)
|
||||||
{
|
{
|
||||||
Global.name = name;
|
Global.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getVersion()
|
public static String getVersion()
|
||||||
{
|
{
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setVersion(String version)
|
public void setVersion(String version)
|
||||||
{
|
{
|
||||||
Global.version = version;
|
Global.version = version;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getCopyrightYear()
|
public static String getCopyrightYear()
|
||||||
{
|
{
|
||||||
return copyrightYear;
|
return copyrightYear;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCopyrightYear(String copyrightYear)
|
public void setCopyrightYear(String copyrightYear)
|
||||||
{
|
{
|
||||||
Global.copyrightYear = copyrightYear;
|
Global.copyrightYear = copyrightYear;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isDemoEnabled()
|
public static boolean isDemoEnabled()
|
||||||
{
|
{
|
||||||
return demoEnabled;
|
return demoEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDemoEnabled(boolean demoEnabled)
|
public void setDemoEnabled(boolean demoEnabled)
|
||||||
{
|
{
|
||||||
Global.demoEnabled = demoEnabled;
|
Global.demoEnabled = demoEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getProfile()
|
public static String getProfile()
|
||||||
{
|
{
|
||||||
return profile;
|
return profile;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setProfile(String profile)
|
public void setProfile(String profile)
|
||||||
{
|
{
|
||||||
Global.profile = profile;
|
Global.profile = profile;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isAddressEnabled()
|
public static boolean isAddressEnabled()
|
||||||
{
|
{
|
||||||
return addressEnabled;
|
return addressEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAddressEnabled(boolean addressEnabled)
|
public void setAddressEnabled(boolean addressEnabled)
|
||||||
{
|
{
|
||||||
Global.addressEnabled = addressEnabled;
|
Global.addressEnabled = addressEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取头像上传路径
|
* 获取头像上传路径
|
||||||
*/
|
*/
|
||||||
public static String getAvatarPath()
|
public static String getAvatarPath()
|
||||||
{
|
{
|
||||||
return getProfile() + "/avatar";
|
return getProfile() + "/avatar";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取下载路径
|
* 获取下载路径
|
||||||
*/
|
*/
|
||||||
public static String getDownloadPath()
|
public static String getDownloadPath()
|
||||||
{
|
{
|
||||||
return getProfile() + "/download/";
|
return getProfile() + "/download/";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取上传路径
|
* 获取上传路径
|
||||||
*/
|
*/
|
||||||
public static String getUploadPath()
|
public static String getUploadPath()
|
||||||
{
|
{
|
||||||
return getProfile() + "/upload";
|
return getProfile() + "/upload";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,33 +1,33 @@
|
||||||
package com.ruoyi.common.config;
|
package com.ruoyi.common.config;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import com.ruoyi.common.utils.ServletUtils;
|
import com.ruoyi.common.utils.ServletUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 服务相关配置
|
* 服务相关配置
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
public class ServerConfig
|
public class ServerConfig
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* 获取完整的请求路径,包括:域名,端口,上下文访问路径
|
* 获取完整的请求路径,包括:域名,端口,上下文访问路径
|
||||||
*
|
*
|
||||||
* @return 服务地址
|
* @return 服务地址
|
||||||
*/
|
*/
|
||||||
public String getUrl()
|
public String getUrl()
|
||||||
{
|
{
|
||||||
HttpServletRequest request = ServletUtils.getRequest();
|
HttpServletRequest request = ServletUtils.getRequest();
|
||||||
return getDomain(request);
|
return getDomain(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getDomain(HttpServletRequest request)
|
public static String getDomain(HttpServletRequest request)
|
||||||
{
|
{
|
||||||
StringBuffer url = request.getRequestURL();
|
StringBuffer url = request.getRequestURL();
|
||||||
String contextPath = request.getServletContext().getContextPath();
|
String contextPath = request.getServletContext().getContextPath();
|
||||||
return url.delete(url.length() - request.getRequestURI().length(), url.length()).append(contextPath).toString();
|
return url.delete(url.length() - request.getRequestURI().length(), url.length()).append(contextPath).toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,45 +1,45 @@
|
||||||
package com.ruoyi.common.config.datasource;
|
package com.ruoyi.common.config.datasource;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数据源切换处理
|
* 数据源切换处理
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class DynamicDataSourceContextHolder
|
public class DynamicDataSourceContextHolder
|
||||||
{
|
{
|
||||||
public static final Logger log = LoggerFactory.getLogger(DynamicDataSourceContextHolder.class);
|
public static final Logger log = LoggerFactory.getLogger(DynamicDataSourceContextHolder.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 使用ThreadLocal维护变量,ThreadLocal为每个使用该变量的线程提供独立的变量副本,
|
* 使用ThreadLocal维护变量,ThreadLocal为每个使用该变量的线程提供独立的变量副本,
|
||||||
* 所以每一个线程都可以独立地改变自己的副本,而不会影响其它线程所对应的副本。
|
* 所以每一个线程都可以独立地改变自己的副本,而不会影响其它线程所对应的副本。
|
||||||
*/
|
*/
|
||||||
private static final ThreadLocal<String> CONTEXT_HOLDER = new ThreadLocal<>();
|
private static final ThreadLocal<String> CONTEXT_HOLDER = new ThreadLocal<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置数据源的变量
|
* 设置数据源的变量
|
||||||
*/
|
*/
|
||||||
public static void setDataSourceType(String dsType)
|
public static void setDataSourceType(String dsType)
|
||||||
{
|
{
|
||||||
log.info("切换到{}数据源", dsType);
|
log.info("切换到{}数据源", dsType);
|
||||||
CONTEXT_HOLDER.set(dsType);
|
CONTEXT_HOLDER.set(dsType);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得数据源的变量
|
* 获得数据源的变量
|
||||||
*/
|
*/
|
||||||
public static String getDataSourceType()
|
public static String getDataSourceType()
|
||||||
{
|
{
|
||||||
return CONTEXT_HOLDER.get();
|
return CONTEXT_HOLDER.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 清空数据源变量
|
* 清空数据源变量
|
||||||
*/
|
*/
|
||||||
public static void clearDataSourceType()
|
public static void clearDataSourceType()
|
||||||
{
|
{
|
||||||
CONTEXT_HOLDER.remove();
|
CONTEXT_HOLDER.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,62 +1,62 @@
|
||||||
package com.ruoyi.common.config.thread;
|
package com.ruoyi.common.config.thread;
|
||||||
|
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
||||||
import java.util.concurrent.ThreadPoolExecutor;
|
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 com.ruoyi.common.utils.Threads;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 线程池配置
|
* 线程池配置
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
**/
|
**/
|
||||||
@Configuration
|
@Configuration
|
||||||
public class ThreadPoolConfig
|
public class ThreadPoolConfig
|
||||||
{
|
{
|
||||||
// 核心线程池大小
|
// 核心线程池大小
|
||||||
private int corePoolSize = 50;
|
private int corePoolSize = 50;
|
||||||
|
|
||||||
// 最大可创建的线程数
|
// 最大可创建的线程数
|
||||||
private int maxPoolSize = 200;
|
private int maxPoolSize = 200;
|
||||||
|
|
||||||
// 队列最大长度
|
// 队列最大长度
|
||||||
private int queueCapacity = 1000;
|
private int queueCapacity = 1000;
|
||||||
|
|
||||||
// 线程池维护线程所允许的空闲时间
|
// 线程池维护线程所允许的空闲时间
|
||||||
private int keepAliveSeconds = 300;
|
private int keepAliveSeconds = 300;
|
||||||
|
|
||||||
@Bean(name = "threadPoolTaskExecutor")
|
@Bean(name = "threadPoolTaskExecutor")
|
||||||
public ThreadPoolTaskExecutor threadPoolTaskExecutor()
|
public ThreadPoolTaskExecutor threadPoolTaskExecutor()
|
||||||
{
|
{
|
||||||
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
||||||
executor.setMaxPoolSize(maxPoolSize);
|
executor.setMaxPoolSize(maxPoolSize);
|
||||||
executor.setCorePoolSize(corePoolSize);
|
executor.setCorePoolSize(corePoolSize);
|
||||||
executor.setQueueCapacity(queueCapacity);
|
executor.setQueueCapacity(queueCapacity);
|
||||||
executor.setKeepAliveSeconds(keepAliveSeconds);
|
executor.setKeepAliveSeconds(keepAliveSeconds);
|
||||||
// 线程池对拒绝任务(无线程可用)的处理策略
|
// 线程池对拒绝任务(无线程可用)的处理策略
|
||||||
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
|
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
|
||||||
return executor;
|
return executor;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 执行周期性或定时任务
|
* 执行周期性或定时任务
|
||||||
*/
|
*/
|
||||||
@Bean(name = "scheduledExecutorService")
|
@Bean(name = "scheduledExecutorService")
|
||||||
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())
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
protected void afterExecute(Runnable r, Throwable t)
|
protected void afterExecute(Runnable r, Throwable t)
|
||||||
{
|
{
|
||||||
super.afterExecute(r, t);
|
super.afterExecute(r, t);
|
||||||
Threads.printException(r, t);
|
Threads.printException(r, t);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,94 +1,94 @@
|
||||||
package com.ruoyi.common.constant;
|
package com.ruoyi.common.constant;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通用常量信息
|
* 通用常量信息
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class Constants
|
public class Constants
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* UTF-8 字符集
|
* UTF-8 字符集
|
||||||
*/
|
*/
|
||||||
public static final String UTF8 = "UTF-8";
|
public static final String UTF8 = "UTF-8";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GBK 字符集
|
* GBK 字符集
|
||||||
*/
|
*/
|
||||||
public static final String GBK = "GBK";
|
public static final String GBK = "GBK";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通用成功标识
|
* 通用成功标识
|
||||||
*/
|
*/
|
||||||
public static final String SUCCESS = "0";
|
public static final String SUCCESS = "0";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通用失败标识
|
* 通用失败标识
|
||||||
*/
|
*/
|
||||||
public static final String FAIL = "1";
|
public static final String FAIL = "1";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 登录成功
|
* 登录成功
|
||||||
*/
|
*/
|
||||||
public static final String LOGIN_SUCCESS = "Success";
|
public static final String LOGIN_SUCCESS = "Success";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 注销
|
* 注销
|
||||||
*/
|
*/
|
||||||
public static final String LOGOUT = "Logout";
|
public static final String LOGOUT = "Logout";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 注册
|
* 注册
|
||||||
*/
|
*/
|
||||||
public static final String REGISTER = "Register";
|
public static final String REGISTER = "Register";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 登录失败
|
* 登录失败
|
||||||
*/
|
*/
|
||||||
public static final String LOGIN_FAIL = "Error";
|
public static final String LOGIN_FAIL = "Error";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 当前记录起始索引
|
* 当前记录起始索引
|
||||||
*/
|
*/
|
||||||
public static final String PAGE_NUM = "pageNum";
|
public static final String PAGE_NUM = "pageNum";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 每页显示记录数
|
* 每页显示记录数
|
||||||
*/
|
*/
|
||||||
public static final String PAGE_SIZE = "pageSize";
|
public static final String PAGE_SIZE = "pageSize";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 排序列
|
* 排序列
|
||||||
*/
|
*/
|
||||||
public static final String ORDER_BY_COLUMN = "orderByColumn";
|
public static final String ORDER_BY_COLUMN = "orderByColumn";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 排序的方向 "desc" 或者 "asc".
|
* 排序的方向 "desc" 或者 "asc".
|
||||||
*/
|
*/
|
||||||
public static final String IS_ASC = "isAsc";
|
public static final String IS_ASC = "isAsc";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 参数管理 cache name
|
* 参数管理 cache name
|
||||||
*/
|
*/
|
||||||
public static final String SYS_CONFIG_CACHE = "sys-config";
|
public static final String SYS_CONFIG_CACHE = "sys-config";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 参数管理 cache key
|
* 参数管理 cache key
|
||||||
*/
|
*/
|
||||||
public static final String SYS_CONFIG_KEY = "sys_config:";
|
public static final String SYS_CONFIG_KEY = "sys_config:";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字典管理 cache name
|
* 字典管理 cache name
|
||||||
*/
|
*/
|
||||||
public static final String SYS_DICT_CACHE = "sys-dict";
|
public static final String SYS_DICT_CACHE = "sys-dict";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字典管理 cache key
|
* 字典管理 cache key
|
||||||
*/
|
*/
|
||||||
public static final String SYS_DICT_KEY = "sys_dict:";
|
public static final String SYS_DICT_KEY = "sys_dict:";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 资源映射路径 前缀
|
* 资源映射路径 前缀
|
||||||
*/
|
*/
|
||||||
public static final String RESOURCE_PREFIX = "/profile";
|
public static final String RESOURCE_PREFIX = "/profile";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,97 +1,97 @@
|
||||||
package com.ruoyi.common.constant;
|
package com.ruoyi.common.constant;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 代码生成通用常量
|
* 代码生成通用常量
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class GenConstants
|
public class GenConstants
|
||||||
{
|
{
|
||||||
/** 单表(增删改查) */
|
/** 单表(增删改查) */
|
||||||
public static final String TPL_CRUD = "crud";
|
public static final String TPL_CRUD = "crud";
|
||||||
|
|
||||||
/** 树表(增删改查) */
|
/** 树表(增删改查) */
|
||||||
public static final String TPL_TREE = "tree";
|
public static final String TPL_TREE = "tree";
|
||||||
|
|
||||||
/** 主子表(增删改查) */
|
/** 主子表(增删改查) */
|
||||||
public static final String TPL_SUB = "sub";
|
public static final String TPL_SUB = "sub";
|
||||||
|
|
||||||
/** 树编码字段 */
|
/** 树编码字段 */
|
||||||
public static final String TREE_CODE = "treeCode";
|
public static final String TREE_CODE = "treeCode";
|
||||||
|
|
||||||
/** 树父编码字段 */
|
/** 树父编码字段 */
|
||||||
public static final String TREE_PARENT_CODE = "treeParentCode";
|
public static final String TREE_PARENT_CODE = "treeParentCode";
|
||||||
|
|
||||||
/** 树名称字段 */
|
/** 树名称字段 */
|
||||||
public static final String TREE_NAME = "treeName";
|
public static final String TREE_NAME = "treeName";
|
||||||
|
|
||||||
/** 数据库字符串类型 */
|
/** 数据库字符串类型 */
|
||||||
public static final String[] COLUMNTYPE_STR = { "char", "varchar", "narchar", "varchar2", "tinytext", "text",
|
public static final String[] COLUMNTYPE_STR = { "char", "varchar", "narchar", "varchar2", "tinytext", "text",
|
||||||
"mediumtext", "longtext" };
|
"mediumtext", "longtext" };
|
||||||
|
|
||||||
/** 数据库时间类型 */
|
/** 数据库时间类型 */
|
||||||
public static final String[] COLUMNTYPE_TIME = { "datetime", "time", "date", "timestamp" };
|
public static final String[] COLUMNTYPE_TIME = { "datetime", "time", "date", "timestamp" };
|
||||||
|
|
||||||
/** 数据库数字类型 */
|
/** 数据库数字类型 */
|
||||||
public static final String[] COLUMNTYPE_NUMBER = { "tinyint", "smallint", "mediumint", "int", "number", "integer",
|
public static final String[] COLUMNTYPE_NUMBER = { "tinyint", "smallint", "mediumint", "int", "number", "integer",
|
||||||
"bigint", "float", "float", "double", "decimal" };
|
"bigint", "float", "float", "double", "decimal" };
|
||||||
|
|
||||||
/** 页面不需要编辑字段 */
|
/** 页面不需要编辑字段 */
|
||||||
public static final String[] COLUMNNAME_NOT_EDIT = { "id", "create_by", "create_time", "del_flag" };
|
public static final String[] COLUMNNAME_NOT_EDIT = { "id", "create_by", "create_time", "del_flag" };
|
||||||
|
|
||||||
/** 页面不需要显示的列表字段 */
|
/** 页面不需要显示的列表字段 */
|
||||||
public static final String[] COLUMNNAME_NOT_LIST = { "id", "create_by", "create_time", "del_flag", "update_by",
|
public static final String[] COLUMNNAME_NOT_LIST = { "id", "create_by", "create_time", "del_flag", "update_by",
|
||||||
"update_time" };
|
"update_time" };
|
||||||
|
|
||||||
/** 页面不需要查询字段 */
|
/** 页面不需要查询字段 */
|
||||||
public static final String[] COLUMNNAME_NOT_QUERY = { "id", "create_by", "create_time", "del_flag", "update_by",
|
public static final String[] COLUMNNAME_NOT_QUERY = { "id", "create_by", "create_time", "del_flag", "update_by",
|
||||||
"update_time", "remark" };
|
"update_time", "remark" };
|
||||||
|
|
||||||
/** Entity基类字段 */
|
/** Entity基类字段 */
|
||||||
public static final String[] BASE_ENTITY = { "createBy", "createTime", "updateBy", "updateTime", "remark" };
|
public static final String[] BASE_ENTITY = { "createBy", "createTime", "updateBy", "updateTime", "remark" };
|
||||||
|
|
||||||
/** Tree基类字段 */
|
/** Tree基类字段 */
|
||||||
public static final String[] TREE_ENTITY = { "parentName", "parentId", "orderNum", "ancestors" };
|
public static final String[] TREE_ENTITY = { "parentName", "parentId", "orderNum", "ancestors" };
|
||||||
|
|
||||||
/** 文本框 */
|
/** 文本框 */
|
||||||
public static final String HTML_INPUT = "input";
|
public static final String HTML_INPUT = "input";
|
||||||
|
|
||||||
/** 文本域 */
|
/** 文本域 */
|
||||||
public static final String HTML_TEXTAREA = "textarea";
|
public static final String HTML_TEXTAREA = "textarea";
|
||||||
|
|
||||||
/** 下拉框 */
|
/** 下拉框 */
|
||||||
public static final String HTML_SELECT = "select";
|
public static final String HTML_SELECT = "select";
|
||||||
|
|
||||||
/** 单选框 */
|
/** 单选框 */
|
||||||
public static final String HTML_RADIO = "radio";
|
public static final String HTML_RADIO = "radio";
|
||||||
|
|
||||||
/** 复选框 */
|
/** 复选框 */
|
||||||
public static final String HTML_CHECKBOX = "checkbox";
|
public static final String HTML_CHECKBOX = "checkbox";
|
||||||
|
|
||||||
/** 日期控件 */
|
/** 日期控件 */
|
||||||
public static final String HTML_DATETIME = "datetime";
|
public static final String HTML_DATETIME = "datetime";
|
||||||
|
|
||||||
/** 字符串类型 */
|
/** 字符串类型 */
|
||||||
public static final String TYPE_STRING = "String";
|
public static final String TYPE_STRING = "String";
|
||||||
|
|
||||||
/** 整型 */
|
/** 整型 */
|
||||||
public static final String TYPE_INTEGER = "Integer";
|
public static final String TYPE_INTEGER = "Integer";
|
||||||
|
|
||||||
/** 长整型 */
|
/** 长整型 */
|
||||||
public static final String TYPE_LONG = "Long";
|
public static final String TYPE_LONG = "Long";
|
||||||
|
|
||||||
/** 浮点型 */
|
/** 浮点型 */
|
||||||
public static final String TYPE_DOUBLE = "Double";
|
public static final String TYPE_DOUBLE = "Double";
|
||||||
|
|
||||||
/** 高精度计算类型 */
|
/** 高精度计算类型 */
|
||||||
public static final String TYPE_BIGDECIMAL = "BigDecimal";
|
public static final String TYPE_BIGDECIMAL = "BigDecimal";
|
||||||
|
|
||||||
/** 时间类型 */
|
/** 时间类型 */
|
||||||
public static final String TYPE_DATE = "Date";
|
public static final String TYPE_DATE = "Date";
|
||||||
|
|
||||||
/** 模糊查询 */
|
/** 模糊查询 */
|
||||||
public static final String QUERY_LIKE = "LIKE";
|
public static final String QUERY_LIKE = "LIKE";
|
||||||
|
|
||||||
/** 需要 */
|
/** 需要 */
|
||||||
public static final String REQUIRE = "1";
|
public static final String REQUIRE = "1";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,27 @@
|
||||||
package com.ruoyi.common.constant;
|
package com.ruoyi.common.constant;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 权限通用常量
|
* 权限通用常量
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class PermissionConstants
|
public class PermissionConstants
|
||||||
{
|
{
|
||||||
/** 新增权限 */
|
/** 新增权限 */
|
||||||
public static final String ADD_PERMISSION = "add";
|
public static final String ADD_PERMISSION = "add";
|
||||||
|
|
||||||
/** 修改权限 */
|
/** 修改权限 */
|
||||||
public static final String EDIT_PERMISSION = "edit";
|
public static final String EDIT_PERMISSION = "edit";
|
||||||
|
|
||||||
/** 删除权限 */
|
/** 删除权限 */
|
||||||
public static final String REMOVE_PERMISSION = "remove";
|
public static final String REMOVE_PERMISSION = "remove";
|
||||||
|
|
||||||
/** 导出权限 */
|
/** 导出权限 */
|
||||||
public static final String EXPORT_PERMISSION = "export";
|
public static final String EXPORT_PERMISSION = "export";
|
||||||
|
|
||||||
/** 显示权限 */
|
/** 显示权限 */
|
||||||
public static final String VIEW_PERMISSION = "view";
|
public static final String VIEW_PERMISSION = "view";
|
||||||
|
|
||||||
/** 查询权限 */
|
/** 查询权限 */
|
||||||
public static final String LIST_PERMISSION = "list";
|
public static final String LIST_PERMISSION = "list";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,50 +1,50 @@
|
||||||
package com.ruoyi.common.constant;
|
package com.ruoyi.common.constant;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 任务调度通用常量
|
* 任务调度通用常量
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class ScheduleConstants
|
public class ScheduleConstants
|
||||||
{
|
{
|
||||||
public static final String TASK_CLASS_NAME = "TASK_CLASS_NAME";
|
public static final String TASK_CLASS_NAME = "TASK_CLASS_NAME";
|
||||||
|
|
||||||
/** 执行目标key */
|
/** 执行目标key */
|
||||||
public static final String TASK_PROPERTIES = "TASK_PROPERTIES";
|
public static final String TASK_PROPERTIES = "TASK_PROPERTIES";
|
||||||
|
|
||||||
/** 默认 */
|
/** 默认 */
|
||||||
public static final String MISFIRE_DEFAULT = "0";
|
public static final String MISFIRE_DEFAULT = "0";
|
||||||
|
|
||||||
/** 立即触发执行 */
|
/** 立即触发执行 */
|
||||||
public static final String MISFIRE_IGNORE_MISFIRES = "1";
|
public static final String MISFIRE_IGNORE_MISFIRES = "1";
|
||||||
|
|
||||||
/** 触发一次执行 */
|
/** 触发一次执行 */
|
||||||
public static final String MISFIRE_FIRE_AND_PROCEED = "2";
|
public static final String MISFIRE_FIRE_AND_PROCEED = "2";
|
||||||
|
|
||||||
/** 不触发立即执行 */
|
/** 不触发立即执行 */
|
||||||
public static final String MISFIRE_DO_NOTHING = "3";
|
public static final String MISFIRE_DO_NOTHING = "3";
|
||||||
|
|
||||||
public enum Status
|
public enum Status
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* 正常
|
* 正常
|
||||||
*/
|
*/
|
||||||
NORMAL("0"),
|
NORMAL("0"),
|
||||||
/**
|
/**
|
||||||
* 暂停
|
* 暂停
|
||||||
*/
|
*/
|
||||||
PAUSE("1");
|
PAUSE("1");
|
||||||
|
|
||||||
private String value;
|
private String value;
|
||||||
|
|
||||||
private Status(String value)
|
private Status(String value)
|
||||||
{
|
{
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getValue()
|
public String getValue()
|
||||||
{
|
{
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,74 +1,74 @@
|
||||||
package com.ruoyi.common.constant;
|
package com.ruoyi.common.constant;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shiro通用常量
|
* Shiro通用常量
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class ShiroConstants
|
public class ShiroConstants
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* 当前登录的用户
|
* 当前登录的用户
|
||||||
*/
|
*/
|
||||||
public static final String CURRENT_USER = "currentUser";
|
public static final String CURRENT_USER = "currentUser";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户名
|
* 用户名
|
||||||
*/
|
*/
|
||||||
public static final String CURRENT_USERNAME = "username";
|
public static final String CURRENT_USERNAME = "username";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 消息key
|
* 消息key
|
||||||
*/
|
*/
|
||||||
public static final String MESSAGE = "message";
|
public static final String MESSAGE = "message";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 错误key
|
* 错误key
|
||||||
*/
|
*/
|
||||||
public static final String ERROR = "errorMsg";
|
public static final String ERROR = "errorMsg";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 编码格式
|
* 编码格式
|
||||||
*/
|
*/
|
||||||
public static final String ENCODING = "UTF-8";
|
public static final String ENCODING = "UTF-8";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 当前在线会话
|
* 当前在线会话
|
||||||
*/
|
*/
|
||||||
public static final String ONLINE_SESSION = "online_session";
|
public static final String ONLINE_SESSION = "online_session";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 验证码key
|
* 验证码key
|
||||||
*/
|
*/
|
||||||
public static final String CURRENT_CAPTCHA = "captcha";
|
public static final String CURRENT_CAPTCHA = "captcha";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 验证码开关
|
* 验证码开关
|
||||||
*/
|
*/
|
||||||
public static final String CURRENT_ENABLED = "captchaEnabled";
|
public static final String CURRENT_ENABLED = "captchaEnabled";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 验证码类型
|
* 验证码类型
|
||||||
*/
|
*/
|
||||||
public static final String CURRENT_TYPE = "captchaType";
|
public static final String CURRENT_TYPE = "captchaType";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 验证码
|
* 验证码
|
||||||
*/
|
*/
|
||||||
public static final String CURRENT_VALIDATECODE = "validateCode";
|
public static final String CURRENT_VALIDATECODE = "validateCode";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 验证码错误
|
* 验证码错误
|
||||||
*/
|
*/
|
||||||
public static final String CAPTCHA_ERROR = "captchaError";
|
public static final String CAPTCHA_ERROR = "captchaError";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 登录记录缓存
|
* 登录记录缓存
|
||||||
*/
|
*/
|
||||||
public static final String LOGINRECORDCACHE = "loginRecordCache";
|
public static final String LOGINRECORDCACHE = "loginRecordCache";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 系统活跃用户缓存
|
* 系统活跃用户缓存
|
||||||
*/
|
*/
|
||||||
public static final String SYS_USERCACHE = "sys-userCache";
|
public static final String SYS_USERCACHE = "sys-userCache";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,110 +1,110 @@
|
||||||
package com.ruoyi.common.constant;
|
package com.ruoyi.common.constant;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户常量信息
|
* 用户常量信息
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class UserConstants
|
public class UserConstants
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* 平台内系统用户的唯一标志
|
* 平台内系统用户的唯一标志
|
||||||
*/
|
*/
|
||||||
public static final String SYS_USER = "SYS_USER";
|
public static final String SYS_USER = "SYS_USER";
|
||||||
|
|
||||||
/** 正常状态 */
|
/** 正常状态 */
|
||||||
public static final String NORMAL = "0";
|
public static final String NORMAL = "0";
|
||||||
|
|
||||||
/** 异常状态 */
|
/** 异常状态 */
|
||||||
public static final String EXCEPTION = "1";
|
public static final String EXCEPTION = "1";
|
||||||
|
|
||||||
/** 用户封禁状态 */
|
/** 用户封禁状态 */
|
||||||
public static final String USER_DISABLE = "1";
|
public static final String USER_DISABLE = "1";
|
||||||
|
|
||||||
/** 角色封禁状态 */
|
/** 角色封禁状态 */
|
||||||
public static final String ROLE_DISABLE = "1";
|
public static final String ROLE_DISABLE = "1";
|
||||||
|
|
||||||
/** 部门正常状态 */
|
/** 部门正常状态 */
|
||||||
public static final String DEPT_NORMAL = "0";
|
public static final String DEPT_NORMAL = "0";
|
||||||
|
|
||||||
/** 部门停用状态 */
|
/** 部门停用状态 */
|
||||||
public static final String DEPT_DISABLE = "1";
|
public static final String DEPT_DISABLE = "1";
|
||||||
|
|
||||||
/** 字典正常状态 */
|
/** 字典正常状态 */
|
||||||
public static final String DICT_NORMAL = "0";
|
public static final String DICT_NORMAL = "0";
|
||||||
|
|
||||||
/** 是否为系统默认(是) */
|
/** 是否为系统默认(是) */
|
||||||
public static final String YES = "Y";
|
public static final String YES = "Y";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户名长度限制
|
* 用户名长度限制
|
||||||
*/
|
*/
|
||||||
public static final int USERNAME_MIN_LENGTH = 2;
|
public static final int USERNAME_MIN_LENGTH = 2;
|
||||||
public static final int USERNAME_MAX_LENGTH = 20;
|
public static final int USERNAME_MAX_LENGTH = 20;
|
||||||
|
|
||||||
/** 登录名称是否唯一的返回结果码 */
|
/** 登录名称是否唯一的返回结果码 */
|
||||||
public final static String USER_NAME_UNIQUE = "0";
|
public final static String USER_NAME_UNIQUE = "0";
|
||||||
public final static String USER_NAME_NOT_UNIQUE = "1";
|
public final static String USER_NAME_NOT_UNIQUE = "1";
|
||||||
|
|
||||||
/** 手机号码是否唯一的返回结果 */
|
/** 手机号码是否唯一的返回结果 */
|
||||||
public final static String USER_PHONE_UNIQUE = "0";
|
public final static String USER_PHONE_UNIQUE = "0";
|
||||||
public final static String USER_PHONE_NOT_UNIQUE = "1";
|
public final static String USER_PHONE_NOT_UNIQUE = "1";
|
||||||
|
|
||||||
/** e-mail 是否唯一的返回结果 */
|
/** e-mail 是否唯一的返回结果 */
|
||||||
public final static String USER_EMAIL_UNIQUE = "0";
|
public final static String USER_EMAIL_UNIQUE = "0";
|
||||||
public final static String USER_EMAIL_NOT_UNIQUE = "1";
|
public final static String USER_EMAIL_NOT_UNIQUE = "1";
|
||||||
|
|
||||||
/** 部门名称是否唯一的返回结果码 */
|
/** 部门名称是否唯一的返回结果码 */
|
||||||
public final static String DEPT_NAME_UNIQUE = "0";
|
public final static String DEPT_NAME_UNIQUE = "0";
|
||||||
public final static String DEPT_NAME_NOT_UNIQUE = "1";
|
public final static String DEPT_NAME_NOT_UNIQUE = "1";
|
||||||
|
|
||||||
/** 角色名称是否唯一的返回结果码 */
|
/** 角色名称是否唯一的返回结果码 */
|
||||||
public final static String ROLE_NAME_UNIQUE = "0";
|
public final static String ROLE_NAME_UNIQUE = "0";
|
||||||
public final static String ROLE_NAME_NOT_UNIQUE = "1";
|
public final static String ROLE_NAME_NOT_UNIQUE = "1";
|
||||||
|
|
||||||
/** 岗位名称是否唯一的返回结果码 */
|
/** 岗位名称是否唯一的返回结果码 */
|
||||||
public final static String POST_NAME_UNIQUE = "0";
|
public final static String POST_NAME_UNIQUE = "0";
|
||||||
public final static String POST_NAME_NOT_UNIQUE = "1";
|
public final static String POST_NAME_NOT_UNIQUE = "1";
|
||||||
|
|
||||||
/** 角色权限是否唯一的返回结果码 */
|
/** 角色权限是否唯一的返回结果码 */
|
||||||
public final static String ROLE_KEY_UNIQUE = "0";
|
public final static String ROLE_KEY_UNIQUE = "0";
|
||||||
public final static String ROLE_KEY_NOT_UNIQUE = "1";
|
public final static String ROLE_KEY_NOT_UNIQUE = "1";
|
||||||
|
|
||||||
/** 岗位编码是否唯一的返回结果码 */
|
/** 岗位编码是否唯一的返回结果码 */
|
||||||
public final static String POST_CODE_UNIQUE = "0";
|
public final static String POST_CODE_UNIQUE = "0";
|
||||||
public final static String POST_CODE_NOT_UNIQUE = "1";
|
public final static String POST_CODE_NOT_UNIQUE = "1";
|
||||||
|
|
||||||
/** 菜单名称是否唯一的返回结果码 */
|
/** 菜单名称是否唯一的返回结果码 */
|
||||||
public final static String MENU_NAME_UNIQUE = "0";
|
public final static String MENU_NAME_UNIQUE = "0";
|
||||||
public final static String MENU_NAME_NOT_UNIQUE = "1";
|
public final static String MENU_NAME_NOT_UNIQUE = "1";
|
||||||
|
|
||||||
/** 字典类型是否唯一的返回结果码 */
|
/** 字典类型是否唯一的返回结果码 */
|
||||||
public final static String DICT_TYPE_UNIQUE = "0";
|
public final static String DICT_TYPE_UNIQUE = "0";
|
||||||
public final static String DICT_TYPE_NOT_UNIQUE = "1";
|
public final static String DICT_TYPE_NOT_UNIQUE = "1";
|
||||||
|
|
||||||
/** 参数键名是否唯一的返回结果码 */
|
/** 参数键名是否唯一的返回结果码 */
|
||||||
public final static String CONFIG_KEY_UNIQUE = "0";
|
public final static String CONFIG_KEY_UNIQUE = "0";
|
||||||
public final static String CONFIG_KEY_NOT_UNIQUE = "1";
|
public final static String CONFIG_KEY_NOT_UNIQUE = "1";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 密码长度限制
|
* 密码长度限制
|
||||||
*/
|
*/
|
||||||
public static final int PASSWORD_MIN_LENGTH = 5;
|
public static final int PASSWORD_MIN_LENGTH = 5;
|
||||||
public static final int PASSWORD_MAX_LENGTH = 20;
|
public static final int PASSWORD_MAX_LENGTH = 20;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户类型
|
* 用户类型
|
||||||
*/
|
*/
|
||||||
public static final String SYSTEM_USER_TYPE = "00";
|
public static final String SYSTEM_USER_TYPE = "00";
|
||||||
public static final String REGISTER_USER_TYPE = "01";
|
public static final String REGISTER_USER_TYPE = "01";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 手机号码格式限制
|
* 手机号码格式限制
|
||||||
*/
|
*/
|
||||||
public static final String MOBILE_PHONE_NUMBER_PATTERN = "^0{0,1}(13[0-9]|15[0-9]|14[0-9]|18[0-9])[0-9]{8}$";
|
public static final String MOBILE_PHONE_NUMBER_PATTERN = "^0{0,1}(13[0-9]|15[0-9]|14[0-9]|18[0-9])[0-9]{8}$";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 邮箱格式限制
|
* 邮箱格式限制
|
||||||
*/
|
*/
|
||||||
public static final String EMAIL_PATTERN = "^((([a-z]|\\d|[!#\\$%&'\\*\\+\\-\\/=\\?\\^_`{\\|}~]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])+(\\.([a-z]|\\d|[!#\\$%&'\\*\\+\\-\\/=\\?\\^_`{\\|}~]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])+)*)|((\\x22)((((\\x20|\\x09)*(\\x0d\\x0a))?(\\x20|\\x09)+)?(([\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x7f]|\\x21|[\\x23-\\x5b]|[\\x5d-\\x7e]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(\\\\([\\x01-\\x09\\x0b\\x0c\\x0d-\\x7f]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]))))*(((\\x20|\\x09)*(\\x0d\\x0a))?(\\x20|\\x09)+)?(\\x22)))@((([a-z]|\\d|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(([a-z]|\\d|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])([a-z]|\\d|-|\\.|_|~|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])*([a-z]|\\d|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])))\\.)+(([a-z]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(([a-z]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])([a-z]|\\d|-|\\.|_|~|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])*([a-z]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])))\\.?";
|
public static final String EMAIL_PATTERN = "^((([a-z]|\\d|[!#\\$%&'\\*\\+\\-\\/=\\?\\^_`{\\|}~]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])+(\\.([a-z]|\\d|[!#\\$%&'\\*\\+\\-\\/=\\?\\^_`{\\|}~]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])+)*)|((\\x22)((((\\x20|\\x09)*(\\x0d\\x0a))?(\\x20|\\x09)+)?(([\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x7f]|\\x21|[\\x23-\\x5b]|[\\x5d-\\x7e]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(\\\\([\\x01-\\x09\\x0b\\x0c\\x0d-\\x7f]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]))))*(((\\x20|\\x09)*(\\x0d\\x0a))?(\\x20|\\x09)+)?(\\x22)))@((([a-z]|\\d|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(([a-z]|\\d|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])([a-z]|\\d|-|\\.|_|~|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])*([a-z]|\\d|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])))\\.)+(([a-z]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(([a-z]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])([a-z]|\\d|-|\\.|_|~|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])*([a-z]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])))\\.?";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,185 +1,185 @@
|
||||||
package com.ruoyi.common.core.controller;
|
package com.ruoyi.common.core.controller;
|
||||||
|
|
||||||
import java.beans.PropertyEditorSupport;
|
import java.beans.PropertyEditorSupport;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
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 javax.servlet.http.HttpSession;
|
import javax.servlet.http.HttpSession;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.web.bind.WebDataBinder;
|
import org.springframework.web.bind.WebDataBinder;
|
||||||
import org.springframework.web.bind.annotation.InitBinder;
|
import org.springframework.web.bind.annotation.InitBinder;
|
||||||
import com.github.pagehelper.PageHelper;
|
import com.github.pagehelper.PageHelper;
|
||||||
import com.github.pagehelper.PageInfo;
|
import com.github.pagehelper.PageInfo;
|
||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
import com.ruoyi.common.core.domain.AjaxResult.Type;
|
import com.ruoyi.common.core.domain.AjaxResult.Type;
|
||||||
import com.ruoyi.common.core.page.PageDomain;
|
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.ServletUtils;
|
import com.ruoyi.common.utils.ServletUtils;
|
||||||
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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* web层通用数据处理
|
* web层通用数据处理
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class BaseController
|
public class BaseController
|
||||||
{
|
{
|
||||||
protected final Logger logger = LoggerFactory.getLogger(BaseController.class);
|
protected final Logger logger = LoggerFactory.getLogger(BaseController.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 将前台传递过来的日期格式的字符串,自动转化为Date类型
|
* 将前台传递过来的日期格式的字符串,自动转化为Date类型
|
||||||
*/
|
*/
|
||||||
@InitBinder
|
@InitBinder
|
||||||
public void initBinder(WebDataBinder binder)
|
public void initBinder(WebDataBinder binder)
|
||||||
{
|
{
|
||||||
// Date 类型转换
|
// Date 类型转换
|
||||||
binder.registerCustomEditor(Date.class, new PropertyEditorSupport()
|
binder.registerCustomEditor(Date.class, new PropertyEditorSupport()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void setAsText(String text)
|
public void setAsText(String text)
|
||||||
{
|
{
|
||||||
setValue(DateUtils.parseDate(text));
|
setValue(DateUtils.parseDate(text));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置请求分页数据
|
* 设置请求分页数据
|
||||||
*/
|
*/
|
||||||
protected void startPage()
|
protected void startPage()
|
||||||
{
|
{
|
||||||
PageDomain pageDomain = TableSupport.buildPageRequest();
|
PageDomain pageDomain = TableSupport.buildPageRequest();
|
||||||
Integer pageNum = pageDomain.getPageNum();
|
Integer pageNum = pageDomain.getPageNum();
|
||||||
Integer pageSize = pageDomain.getPageSize();
|
Integer pageSize = pageDomain.getPageSize();
|
||||||
if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize))
|
if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize))
|
||||||
{
|
{
|
||||||
String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy());
|
String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy());
|
||||||
PageHelper.startPage(pageNum, pageSize, orderBy);
|
PageHelper.startPage(pageNum, pageSize, orderBy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置请求排序数据
|
* 设置请求排序数据
|
||||||
*/
|
*/
|
||||||
protected void startOrderBy()
|
protected void startOrderBy()
|
||||||
{
|
{
|
||||||
PageDomain pageDomain = TableSupport.buildPageRequest();
|
PageDomain pageDomain = TableSupport.buildPageRequest();
|
||||||
if (StringUtils.isNotEmpty(pageDomain.getOrderBy()))
|
if (StringUtils.isNotEmpty(pageDomain.getOrderBy()))
|
||||||
{
|
{
|
||||||
String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy());
|
String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy());
|
||||||
PageHelper.orderBy(orderBy);
|
PageHelper.orderBy(orderBy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取request
|
* 获取request
|
||||||
*/
|
*/
|
||||||
public HttpServletRequest getRequest()
|
public HttpServletRequest getRequest()
|
||||||
{
|
{
|
||||||
return ServletUtils.getRequest();
|
return ServletUtils.getRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取response
|
* 获取response
|
||||||
*/
|
*/
|
||||||
public HttpServletResponse getResponse()
|
public HttpServletResponse getResponse()
|
||||||
{
|
{
|
||||||
return ServletUtils.getResponse();
|
return ServletUtils.getResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取session
|
* 获取session
|
||||||
*/
|
*/
|
||||||
public HttpSession getSession()
|
public HttpSession getSession()
|
||||||
{
|
{
|
||||||
return getRequest().getSession();
|
return getRequest().getSession();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 响应请求分页数据
|
* 响应请求分页数据
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||||
protected TableDataInfo getDataTable(List<?> list)
|
protected TableDataInfo getDataTable(List<?> list)
|
||||||
{
|
{
|
||||||
TableDataInfo rspData = new TableDataInfo();
|
TableDataInfo rspData = new TableDataInfo();
|
||||||
rspData.setCode(0);
|
rspData.setCode(0);
|
||||||
rspData.setRows(list);
|
rspData.setRows(list);
|
||||||
rspData.setTotal(new PageInfo(list).getTotal());
|
rspData.setTotal(new PageInfo(list).getTotal());
|
||||||
return rspData;
|
return rspData;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 响应返回结果
|
* 响应返回结果
|
||||||
*
|
*
|
||||||
* @param rows 影响行数
|
* @param rows 影响行数
|
||||||
* @return 操作结果
|
* @return 操作结果
|
||||||
*/
|
*/
|
||||||
protected AjaxResult toAjax(int rows)
|
protected AjaxResult toAjax(int rows)
|
||||||
{
|
{
|
||||||
return rows > 0 ? success() : error();
|
return rows > 0 ? success() : error();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 响应返回结果
|
* 响应返回结果
|
||||||
*
|
*
|
||||||
* @param result 结果
|
* @param result 结果
|
||||||
* @return 操作结果
|
* @return 操作结果
|
||||||
*/
|
*/
|
||||||
protected AjaxResult toAjax(boolean result)
|
protected AjaxResult toAjax(boolean result)
|
||||||
{
|
{
|
||||||
return result ? success() : error();
|
return result ? success() : error();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 返回成功
|
* 返回成功
|
||||||
*/
|
*/
|
||||||
public AjaxResult success()
|
public AjaxResult success()
|
||||||
{
|
{
|
||||||
return AjaxResult.success();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 返回失败消息
|
* 返回失败消息
|
||||||
*/
|
*/
|
||||||
public AjaxResult error()
|
public AjaxResult error()
|
||||||
{
|
{
|
||||||
return AjaxResult.error();
|
return AjaxResult.error();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 返回成功消息
|
* 返回成功消息
|
||||||
*/
|
*/
|
||||||
public AjaxResult success(String message)
|
public AjaxResult success(String message)
|
||||||
{
|
{
|
||||||
return AjaxResult.success(message);
|
return AjaxResult.success(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 返回失败消息
|
* 返回失败消息
|
||||||
*/
|
*/
|
||||||
public AjaxResult error(String message)
|
public AjaxResult error(String message)
|
||||||
{
|
{
|
||||||
return AjaxResult.error(message);
|
return AjaxResult.error(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 返回错误码消息
|
* 返回错误码消息
|
||||||
*/
|
*/
|
||||||
public AjaxResult error(Type type, String message)
|
public AjaxResult error(Type type, String message)
|
||||||
{
|
{
|
||||||
return new AjaxResult(type, message);
|
return new AjaxResult(type, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 页面跳转
|
* 页面跳转
|
||||||
*/
|
*/
|
||||||
public String redirect(String url)
|
public String redirect(String url)
|
||||||
{
|
{
|
||||||
return StringUtils.format("redirect:{}", url);
|
return StringUtils.format("redirect:{}", url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,182 +1,182 @@
|
||||||
package com.ruoyi.common.core.domain;
|
package com.ruoyi.common.core.domain;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 操作消息提醒
|
* 操作消息提醒
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class AjaxResult extends HashMap<String, Object>
|
public class AjaxResult extends HashMap<String, Object>
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/** 状态码 */
|
/** 状态码 */
|
||||||
public static final String CODE_TAG = "code";
|
public static final String CODE_TAG = "code";
|
||||||
|
|
||||||
/** 返回内容 */
|
/** 返回内容 */
|
||||||
public static final String MSG_TAG = "msg";
|
public static final String MSG_TAG = "msg";
|
||||||
|
|
||||||
/** 数据对象 */
|
/** 数据对象 */
|
||||||
public static final String DATA_TAG = "data";
|
public static final String DATA_TAG = "data";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 状态类型
|
* 状态类型
|
||||||
*/
|
*/
|
||||||
public enum Type
|
public enum Type
|
||||||
{
|
{
|
||||||
/** 成功 */
|
/** 成功 */
|
||||||
SUCCESS(0),
|
SUCCESS(0),
|
||||||
/** 警告 */
|
/** 警告 */
|
||||||
WARN(301),
|
WARN(301),
|
||||||
/** 错误 */
|
/** 错误 */
|
||||||
ERROR(500);
|
ERROR(500);
|
||||||
private final int value;
|
private final int value;
|
||||||
|
|
||||||
Type(int value)
|
Type(int value)
|
||||||
{
|
{
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int value()
|
public int value()
|
||||||
{
|
{
|
||||||
return this.value;
|
return this.value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 初始化一个新创建的 AjaxResult 对象,使其表示一个空消息。
|
* 初始化一个新创建的 AjaxResult 对象,使其表示一个空消息。
|
||||||
*/
|
*/
|
||||||
public AjaxResult()
|
public AjaxResult()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 初始化一个新创建的 AjaxResult 对象
|
* 初始化一个新创建的 AjaxResult 对象
|
||||||
*
|
*
|
||||||
* @param type 状态类型
|
* @param type 状态类型
|
||||||
* @param msg 返回内容
|
* @param msg 返回内容
|
||||||
*/
|
*/
|
||||||
public AjaxResult(Type type, String msg)
|
public AjaxResult(Type type, String msg)
|
||||||
{
|
{
|
||||||
super.put(CODE_TAG, type.value);
|
super.put(CODE_TAG, type.value);
|
||||||
super.put(MSG_TAG, msg);
|
super.put(MSG_TAG, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 初始化一个新创建的 AjaxResult 对象
|
* 初始化一个新创建的 AjaxResult 对象
|
||||||
*
|
*
|
||||||
* @param type 状态类型
|
* @param type 状态类型
|
||||||
* @param msg 返回内容
|
* @param msg 返回内容
|
||||||
* @param data 数据对象
|
* @param data 数据对象
|
||||||
*/
|
*/
|
||||||
public AjaxResult(Type type, String msg, Object data)
|
public AjaxResult(Type type, String msg, Object data)
|
||||||
{
|
{
|
||||||
super.put(CODE_TAG, type.value);
|
super.put(CODE_TAG, type.value);
|
||||||
super.put(MSG_TAG, msg);
|
super.put(MSG_TAG, msg);
|
||||||
if (StringUtils.isNotNull(data))
|
if (StringUtils.isNotNull(data))
|
||||||
{
|
{
|
||||||
super.put(DATA_TAG, data);
|
super.put(DATA_TAG, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 返回成功消息
|
* 返回成功消息
|
||||||
*
|
*
|
||||||
* @return 成功消息
|
* @return 成功消息
|
||||||
*/
|
*/
|
||||||
public static AjaxResult success()
|
public static AjaxResult success()
|
||||||
{
|
{
|
||||||
return AjaxResult.success("操作成功");
|
return AjaxResult.success("操作成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 返回成功数据
|
* 返回成功数据
|
||||||
*
|
*
|
||||||
* @return 成功消息
|
* @return 成功消息
|
||||||
*/
|
*/
|
||||||
public static AjaxResult success(Object data)
|
public static AjaxResult success(Object data)
|
||||||
{
|
{
|
||||||
return AjaxResult.success("操作成功", data);
|
return AjaxResult.success("操作成功", data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 返回成功消息
|
* 返回成功消息
|
||||||
*
|
*
|
||||||
* @param msg 返回内容
|
* @param msg 返回内容
|
||||||
* @return 成功消息
|
* @return 成功消息
|
||||||
*/
|
*/
|
||||||
public static AjaxResult success(String msg)
|
public static AjaxResult success(String msg)
|
||||||
{
|
{
|
||||||
return AjaxResult.success(msg, null);
|
return AjaxResult.success(msg, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 返回成功消息
|
* 返回成功消息
|
||||||
*
|
*
|
||||||
* @param msg 返回内容
|
* @param msg 返回内容
|
||||||
* @param data 数据对象
|
* @param data 数据对象
|
||||||
* @return 成功消息
|
* @return 成功消息
|
||||||
*/
|
*/
|
||||||
public static AjaxResult success(String msg, Object data)
|
public static AjaxResult success(String msg, Object data)
|
||||||
{
|
{
|
||||||
return new AjaxResult(Type.SUCCESS, msg, data);
|
return new AjaxResult(Type.SUCCESS, msg, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 返回警告消息
|
* 返回警告消息
|
||||||
*
|
*
|
||||||
* @param msg 返回内容
|
* @param msg 返回内容
|
||||||
* @return 警告消息
|
* @return 警告消息
|
||||||
*/
|
*/
|
||||||
public static AjaxResult warn(String msg)
|
public static AjaxResult warn(String msg)
|
||||||
{
|
{
|
||||||
return AjaxResult.warn(msg, null);
|
return AjaxResult.warn(msg, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 返回警告消息
|
* 返回警告消息
|
||||||
*
|
*
|
||||||
* @param msg 返回内容
|
* @param msg 返回内容
|
||||||
* @param data 数据对象
|
* @param data 数据对象
|
||||||
* @return 警告消息
|
* @return 警告消息
|
||||||
*/
|
*/
|
||||||
public static AjaxResult warn(String msg, Object data)
|
public static AjaxResult warn(String msg, Object data)
|
||||||
{
|
{
|
||||||
return new AjaxResult(Type.WARN, msg, data);
|
return new AjaxResult(Type.WARN, msg, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 返回错误消息
|
* 返回错误消息
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static AjaxResult error()
|
public static AjaxResult error()
|
||||||
{
|
{
|
||||||
return AjaxResult.error("操作失败");
|
return AjaxResult.error("操作失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 返回错误消息
|
* 返回错误消息
|
||||||
*
|
*
|
||||||
* @param msg 返回内容
|
* @param msg 返回内容
|
||||||
* @return 警告消息
|
* @return 警告消息
|
||||||
*/
|
*/
|
||||||
public static AjaxResult error(String msg)
|
public static AjaxResult error(String msg)
|
||||||
{
|
{
|
||||||
return AjaxResult.error(msg, null);
|
return AjaxResult.error(msg, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 返回错误消息
|
* 返回错误消息
|
||||||
*
|
*
|
||||||
* @param msg 返回内容
|
* @param msg 返回内容
|
||||||
* @param data 数据对象
|
* @param data 数据对象
|
||||||
* @return 警告消息
|
* @return 警告消息
|
||||||
*/
|
*/
|
||||||
public static AjaxResult error(String msg, Object data)
|
public static AjaxResult error(String msg, Object data)
|
||||||
{
|
{
|
||||||
return new AjaxResult(Type.ERROR, msg, data);
|
return new AjaxResult(Type.ERROR, msg, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,114 +1,114 @@
|
||||||
package com.ruoyi.common.core.domain;
|
package com.ruoyi.common.core.domain;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Entity基类
|
* Entity基类
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class BaseEntity implements Serializable
|
public class BaseEntity implements Serializable
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/** 搜索值 */
|
/** 搜索值 */
|
||||||
private String searchValue;
|
private String searchValue;
|
||||||
|
|
||||||
/** 创建者 */
|
/** 创建者 */
|
||||||
private String createBy;
|
private String createBy;
|
||||||
|
|
||||||
/** 创建时间 */
|
/** 创建时间 */
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
private Date createTime;
|
private Date createTime;
|
||||||
|
|
||||||
/** 更新者 */
|
/** 更新者 */
|
||||||
private String updateBy;
|
private String updateBy;
|
||||||
|
|
||||||
/** 更新时间 */
|
/** 更新时间 */
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
private Date updateTime;
|
private Date updateTime;
|
||||||
|
|
||||||
/** 备注 */
|
/** 备注 */
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
/** 请求参数 */
|
/** 请求参数 */
|
||||||
private Map<String, Object> params;
|
private Map<String, Object> params;
|
||||||
|
|
||||||
public String getSearchValue()
|
public String getSearchValue()
|
||||||
{
|
{
|
||||||
return searchValue;
|
return searchValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSearchValue(String searchValue)
|
public void setSearchValue(String searchValue)
|
||||||
{
|
{
|
||||||
this.searchValue = searchValue;
|
this.searchValue = searchValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCreateBy()
|
public String getCreateBy()
|
||||||
{
|
{
|
||||||
return createBy;
|
return createBy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCreateBy(String createBy)
|
public void setCreateBy(String createBy)
|
||||||
{
|
{
|
||||||
this.createBy = createBy;
|
this.createBy = createBy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Date getCreateTime()
|
public Date getCreateTime()
|
||||||
{
|
{
|
||||||
return createTime;
|
return createTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCreateTime(Date createTime)
|
public void setCreateTime(Date createTime)
|
||||||
{
|
{
|
||||||
this.createTime = createTime;
|
this.createTime = createTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUpdateBy()
|
public String getUpdateBy()
|
||||||
{
|
{
|
||||||
return updateBy;
|
return updateBy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUpdateBy(String updateBy)
|
public void setUpdateBy(String updateBy)
|
||||||
{
|
{
|
||||||
this.updateBy = updateBy;
|
this.updateBy = updateBy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Date getUpdateTime()
|
public Date getUpdateTime()
|
||||||
{
|
{
|
||||||
return updateTime;
|
return updateTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUpdateTime(Date updateTime)
|
public void setUpdateTime(Date updateTime)
|
||||||
{
|
{
|
||||||
this.updateTime = updateTime;
|
this.updateTime = updateTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRemark()
|
public String getRemark()
|
||||||
{
|
{
|
||||||
return remark;
|
return remark;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRemark(String remark)
|
public void setRemark(String remark)
|
||||||
{
|
{
|
||||||
this.remark = remark;
|
this.remark = remark;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, Object> getParams()
|
public Map<String, Object> getParams()
|
||||||
{
|
{
|
||||||
if (params == null)
|
if (params == null)
|
||||||
{
|
{
|
||||||
params = new HashMap<>();
|
params = new HashMap<>();
|
||||||
}
|
}
|
||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setParams(Map<String, Object> params)
|
public void setParams(Map<String, Object> params)
|
||||||
{
|
{
|
||||||
this.params = params;
|
this.params = params;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,69 +1,69 @@
|
||||||
package com.ruoyi.common.core.domain;
|
package com.ruoyi.common.core.domain;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CxSelect树结构实体类
|
* CxSelect树结构实体类
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class CxSelect implements Serializable
|
public class CxSelect implements Serializable
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数据值字段名称
|
* 数据值字段名称
|
||||||
*/
|
*/
|
||||||
private String v;
|
private String v;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数据标题字段名称
|
* 数据标题字段名称
|
||||||
*/
|
*/
|
||||||
private String n;
|
private String n;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 子集数据字段名称
|
* 子集数据字段名称
|
||||||
*/
|
*/
|
||||||
private List<CxSelect> s;
|
private List<CxSelect> s;
|
||||||
|
|
||||||
public CxSelect()
|
public CxSelect()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public CxSelect(String v, String n)
|
public CxSelect(String v, String n)
|
||||||
{
|
{
|
||||||
this.v = v;
|
this.v = v;
|
||||||
this.n = n;
|
this.n = n;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<CxSelect> getS()
|
public List<CxSelect> getS()
|
||||||
{
|
{
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setN(String n)
|
public void setN(String n)
|
||||||
{
|
{
|
||||||
this.n = n;
|
this.n = n;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getN()
|
public String getN()
|
||||||
{
|
{
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setS(List<CxSelect> s)
|
public void setS(List<CxSelect> s)
|
||||||
{
|
{
|
||||||
this.s = s;
|
this.s = s;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getV()
|
public String getV()
|
||||||
{
|
{
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setV(String v)
|
public void setV(String v)
|
||||||
{
|
{
|
||||||
this.v = v;
|
this.v = v;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,63 +1,63 @@
|
||||||
package com.ruoyi.common.core.domain;
|
package com.ruoyi.common.core.domain;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tree基类
|
* Tree基类
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class TreeEntity extends BaseEntity
|
public class TreeEntity extends BaseEntity
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/** 父菜单名称 */
|
/** 父菜单名称 */
|
||||||
private String parentName;
|
private String parentName;
|
||||||
|
|
||||||
/** 父菜单ID */
|
/** 父菜单ID */
|
||||||
private Long parentId;
|
private Long parentId;
|
||||||
|
|
||||||
/** 显示顺序 */
|
/** 显示顺序 */
|
||||||
private Integer orderNum;
|
private Integer orderNum;
|
||||||
|
|
||||||
/** 祖级列表 */
|
/** 祖级列表 */
|
||||||
private String ancestors;
|
private String ancestors;
|
||||||
|
|
||||||
public String getParentName()
|
public String getParentName()
|
||||||
{
|
{
|
||||||
return parentName;
|
return parentName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setParentName(String parentName)
|
public void setParentName(String parentName)
|
||||||
{
|
{
|
||||||
this.parentName = parentName;
|
this.parentName = parentName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getParentId()
|
public Long getParentId()
|
||||||
{
|
{
|
||||||
return parentId;
|
return parentId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setParentId(Long parentId)
|
public void setParentId(Long parentId)
|
||||||
{
|
{
|
||||||
this.parentId = parentId;
|
this.parentId = parentId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getOrderNum()
|
public Integer getOrderNum()
|
||||||
{
|
{
|
||||||
return orderNum;
|
return orderNum;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOrderNum(Integer orderNum)
|
public void setOrderNum(Integer orderNum)
|
||||||
{
|
{
|
||||||
this.orderNum = orderNum;
|
this.orderNum = orderNum;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getAncestors()
|
public String getAncestors()
|
||||||
{
|
{
|
||||||
return ancestors;
|
return ancestors;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAncestors(String ancestors)
|
public void setAncestors(String ancestors)
|
||||||
{
|
{
|
||||||
this.ancestors = ancestors;
|
this.ancestors = ancestors;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,104 +1,104 @@
|
||||||
package com.ruoyi.common.core.domain;
|
package com.ruoyi.common.core.domain;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ztree树结构实体类
|
* Ztree树结构实体类
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class Ztree implements Serializable
|
public class Ztree implements Serializable
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/** 节点ID */
|
/** 节点ID */
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
/** 节点父ID */
|
/** 节点父ID */
|
||||||
private Long pId;
|
private Long pId;
|
||||||
|
|
||||||
/** 节点名称 */
|
/** 节点名称 */
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
/** 节点标题 */
|
/** 节点标题 */
|
||||||
private String title;
|
private String title;
|
||||||
|
|
||||||
/** 是否勾选 */
|
/** 是否勾选 */
|
||||||
private boolean checked = false;
|
private boolean checked = false;
|
||||||
|
|
||||||
/** 是否展开 */
|
/** 是否展开 */
|
||||||
private boolean open = false;
|
private boolean open = false;
|
||||||
|
|
||||||
/** 是否能勾选 */
|
/** 是否能勾选 */
|
||||||
private boolean nocheck = false;
|
private boolean nocheck = false;
|
||||||
|
|
||||||
public Long getId()
|
public Long getId()
|
||||||
{
|
{
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setId(Long id)
|
public void setId(Long id)
|
||||||
{
|
{
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getpId()
|
public Long getpId()
|
||||||
{
|
{
|
||||||
return pId;
|
return pId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setpId(Long pId)
|
public void setpId(Long pId)
|
||||||
{
|
{
|
||||||
this.pId = pId;
|
this.pId = pId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName()
|
public String getName()
|
||||||
{
|
{
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setName(String name)
|
public void setName(String name)
|
||||||
{
|
{
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTitle()
|
public String getTitle()
|
||||||
{
|
{
|
||||||
return title;
|
return title;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTitle(String title)
|
public void setTitle(String title)
|
||||||
{
|
{
|
||||||
this.title = title;
|
this.title = title;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isChecked()
|
public boolean isChecked()
|
||||||
{
|
{
|
||||||
return checked;
|
return checked;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setChecked(boolean checked)
|
public void setChecked(boolean checked)
|
||||||
{
|
{
|
||||||
this.checked = checked;
|
this.checked = checked;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isOpen()
|
public boolean isOpen()
|
||||||
{
|
{
|
||||||
return open;
|
return open;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOpen(boolean open)
|
public void setOpen(boolean open)
|
||||||
{
|
{
|
||||||
this.open = open;
|
this.open = open;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isNocheck()
|
public boolean isNocheck()
|
||||||
{
|
{
|
||||||
return nocheck;
|
return nocheck;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNocheck(boolean nocheck)
|
public void setNocheck(boolean nocheck)
|
||||||
{
|
{
|
||||||
this.nocheck = nocheck;
|
this.nocheck = nocheck;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,72 +1,72 @@
|
||||||
package com.ruoyi.common.core.page;
|
package com.ruoyi.common.core.page;
|
||||||
|
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页数据
|
* 分页数据
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class PageDomain
|
public class PageDomain
|
||||||
{
|
{
|
||||||
/** 当前记录起始索引 */
|
/** 当前记录起始索引 */
|
||||||
private Integer pageNum;
|
private Integer pageNum;
|
||||||
|
|
||||||
/** 每页显示记录数 */
|
/** 每页显示记录数 */
|
||||||
private Integer pageSize;
|
private Integer pageSize;
|
||||||
|
|
||||||
/** 排序列 */
|
/** 排序列 */
|
||||||
private String orderByColumn;
|
private String orderByColumn;
|
||||||
|
|
||||||
/** 排序的方向 "desc" 或者 "asc". */
|
/** 排序的方向 "desc" 或者 "asc". */
|
||||||
private String isAsc;
|
private String isAsc;
|
||||||
|
|
||||||
public String getOrderBy()
|
public String getOrderBy()
|
||||||
{
|
{
|
||||||
if (StringUtils.isEmpty(orderByColumn))
|
if (StringUtils.isEmpty(orderByColumn))
|
||||||
{
|
{
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
return StringUtils.toUnderScoreCase(orderByColumn) + " " + isAsc;
|
return StringUtils.toUnderScoreCase(orderByColumn) + " " + isAsc;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getPageNum()
|
public Integer getPageNum()
|
||||||
{
|
{
|
||||||
return pageNum;
|
return pageNum;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPageNum(Integer pageNum)
|
public void setPageNum(Integer pageNum)
|
||||||
{
|
{
|
||||||
this.pageNum = pageNum;
|
this.pageNum = pageNum;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getPageSize()
|
public Integer getPageSize()
|
||||||
{
|
{
|
||||||
return pageSize;
|
return pageSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPageSize(Integer pageSize)
|
public void setPageSize(Integer pageSize)
|
||||||
{
|
{
|
||||||
this.pageSize = pageSize;
|
this.pageSize = pageSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getOrderByColumn()
|
public String getOrderByColumn()
|
||||||
{
|
{
|
||||||
return orderByColumn;
|
return orderByColumn;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOrderByColumn(String orderByColumn)
|
public void setOrderByColumn(String orderByColumn)
|
||||||
{
|
{
|
||||||
this.orderByColumn = orderByColumn;
|
this.orderByColumn = orderByColumn;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getIsAsc()
|
public String getIsAsc()
|
||||||
{
|
{
|
||||||
return isAsc;
|
return isAsc;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIsAsc(String isAsc)
|
public void setIsAsc(String isAsc)
|
||||||
{
|
{
|
||||||
this.isAsc = isAsc;
|
this.isAsc = isAsc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,85 +1,85 @@
|
||||||
package com.ruoyi.common.core.page;
|
package com.ruoyi.common.core.page;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 表格分页数据对象
|
* 表格分页数据对象
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class TableDataInfo implements Serializable
|
public class TableDataInfo implements Serializable
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/** 总记录数 */
|
/** 总记录数 */
|
||||||
private long total;
|
private long total;
|
||||||
|
|
||||||
/** 列表数据 */
|
/** 列表数据 */
|
||||||
private List<?> rows;
|
private List<?> rows;
|
||||||
|
|
||||||
/** 消息状态码 */
|
/** 消息状态码 */
|
||||||
private int code;
|
private int code;
|
||||||
|
|
||||||
/** 消息内容 */
|
/** 消息内容 */
|
||||||
private String msg;
|
private String msg;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 表格数据对象
|
* 表格数据对象
|
||||||
*/
|
*/
|
||||||
public TableDataInfo()
|
public TableDataInfo()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页
|
* 分页
|
||||||
*
|
*
|
||||||
* @param list 列表数据
|
* @param list 列表数据
|
||||||
* @param total 总记录数
|
* @param total 总记录数
|
||||||
*/
|
*/
|
||||||
public TableDataInfo(List<?> list, int total)
|
public TableDataInfo(List<?> list, int total)
|
||||||
{
|
{
|
||||||
this.rows = list;
|
this.rows = list;
|
||||||
this.total = total;
|
this.total = total;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getTotal()
|
public long getTotal()
|
||||||
{
|
{
|
||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTotal(long total)
|
public void setTotal(long total)
|
||||||
{
|
{
|
||||||
this.total = total;
|
this.total = total;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<?> getRows()
|
public List<?> getRows()
|
||||||
{
|
{
|
||||||
return rows;
|
return rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRows(List<?> rows)
|
public void setRows(List<?> rows)
|
||||||
{
|
{
|
||||||
this.rows = rows;
|
this.rows = rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCode()
|
public int getCode()
|
||||||
{
|
{
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCode(int code)
|
public void setCode(int code)
|
||||||
{
|
{
|
||||||
this.code = code;
|
this.code = code;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMsg()
|
public String getMsg()
|
||||||
{
|
{
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMsg(String msg)
|
public void setMsg(String msg)
|
||||||
{
|
{
|
||||||
this.msg = msg;
|
this.msg = msg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,30 +1,30 @@
|
||||||
package com.ruoyi.common.core.page;
|
package com.ruoyi.common.core.page;
|
||||||
|
|
||||||
import com.ruoyi.common.constant.Constants;
|
import com.ruoyi.common.constant.Constants;
|
||||||
import com.ruoyi.common.utils.ServletUtils;
|
import com.ruoyi.common.utils.ServletUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 表格数据处理
|
* 表格数据处理
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class TableSupport
|
public class TableSupport
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* 封装分页对象
|
* 封装分页对象
|
||||||
*/
|
*/
|
||||||
public static PageDomain getPageDomain()
|
public static PageDomain getPageDomain()
|
||||||
{
|
{
|
||||||
PageDomain pageDomain = new PageDomain();
|
PageDomain pageDomain = new PageDomain();
|
||||||
pageDomain.setPageNum(ServletUtils.getParameterToInt(Constants.PAGE_NUM));
|
pageDomain.setPageNum(ServletUtils.getParameterToInt(Constants.PAGE_NUM));
|
||||||
pageDomain.setPageSize(ServletUtils.getParameterToInt(Constants.PAGE_SIZE));
|
pageDomain.setPageSize(ServletUtils.getParameterToInt(Constants.PAGE_SIZE));
|
||||||
pageDomain.setOrderByColumn(ServletUtils.getParameter(Constants.ORDER_BY_COLUMN));
|
pageDomain.setOrderByColumn(ServletUtils.getParameter(Constants.ORDER_BY_COLUMN));
|
||||||
pageDomain.setIsAsc(ServletUtils.getParameter(Constants.IS_ASC));
|
pageDomain.setIsAsc(ServletUtils.getParameter(Constants.IS_ASC));
|
||||||
return pageDomain;
|
return pageDomain;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PageDomain buildPageRequest()
|
public static PageDomain buildPageRequest()
|
||||||
{
|
{
|
||||||
return getPageDomain();
|
return getPageDomain();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,86 +1,86 @@
|
||||||
package com.ruoyi.common.core.text;
|
package com.ruoyi.common.core.text;
|
||||||
|
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字符集工具类
|
* 字符集工具类
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class CharsetKit
|
public class CharsetKit
|
||||||
{
|
{
|
||||||
/** ISO-8859-1 */
|
/** ISO-8859-1 */
|
||||||
public static final String ISO_8859_1 = "ISO-8859-1";
|
public static final String ISO_8859_1 = "ISO-8859-1";
|
||||||
/** UTF-8 */
|
/** UTF-8 */
|
||||||
public static final String UTF_8 = "UTF-8";
|
public static final String UTF_8 = "UTF-8";
|
||||||
/** GBK */
|
/** GBK */
|
||||||
public static final String GBK = "GBK";
|
public static final String GBK = "GBK";
|
||||||
|
|
||||||
/** ISO-8859-1 */
|
/** ISO-8859-1 */
|
||||||
public static final Charset CHARSET_ISO_8859_1 = Charset.forName(ISO_8859_1);
|
public static final Charset CHARSET_ISO_8859_1 = Charset.forName(ISO_8859_1);
|
||||||
/** UTF-8 */
|
/** UTF-8 */
|
||||||
public static final Charset CHARSET_UTF_8 = Charset.forName(UTF_8);
|
public static final Charset CHARSET_UTF_8 = Charset.forName(UTF_8);
|
||||||
/** GBK */
|
/** GBK */
|
||||||
public static final Charset CHARSET_GBK = Charset.forName(GBK);
|
public static final Charset CHARSET_GBK = Charset.forName(GBK);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 转换为Charset对象
|
* 转换为Charset对象
|
||||||
*
|
*
|
||||||
* @param charset 字符集,为空则返回默认字符集
|
* @param charset 字符集,为空则返回默认字符集
|
||||||
* @return Charset
|
* @return Charset
|
||||||
*/
|
*/
|
||||||
public static Charset charset(String charset)
|
public static Charset charset(String charset)
|
||||||
{
|
{
|
||||||
return StringUtils.isEmpty(charset) ? Charset.defaultCharset() : Charset.forName(charset);
|
return StringUtils.isEmpty(charset) ? Charset.defaultCharset() : Charset.forName(charset);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 转换字符串的字符集编码
|
* 转换字符串的字符集编码
|
||||||
*
|
*
|
||||||
* @param source 字符串
|
* @param source 字符串
|
||||||
* @param srcCharset 源字符集,默认ISO-8859-1
|
* @param srcCharset 源字符集,默认ISO-8859-1
|
||||||
* @param destCharset 目标字符集,默认UTF-8
|
* @param destCharset 目标字符集,默认UTF-8
|
||||||
* @return 转换后的字符集
|
* @return 转换后的字符集
|
||||||
*/
|
*/
|
||||||
public static String convert(String source, String srcCharset, String destCharset)
|
public static String convert(String source, String srcCharset, String destCharset)
|
||||||
{
|
{
|
||||||
return convert(source, Charset.forName(srcCharset), Charset.forName(destCharset));
|
return convert(source, Charset.forName(srcCharset), Charset.forName(destCharset));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 转换字符串的字符集编码
|
* 转换字符串的字符集编码
|
||||||
*
|
*
|
||||||
* @param source 字符串
|
* @param source 字符串
|
||||||
* @param srcCharset 源字符集,默认ISO-8859-1
|
* @param srcCharset 源字符集,默认ISO-8859-1
|
||||||
* @param destCharset 目标字符集,默认UTF-8
|
* @param destCharset 目标字符集,默认UTF-8
|
||||||
* @return 转换后的字符集
|
* @return 转换后的字符集
|
||||||
*/
|
*/
|
||||||
public static String convert(String source, Charset srcCharset, Charset destCharset)
|
public static String convert(String source, Charset srcCharset, Charset destCharset)
|
||||||
{
|
{
|
||||||
if (null == srcCharset)
|
if (null == srcCharset)
|
||||||
{
|
{
|
||||||
srcCharset = StandardCharsets.ISO_8859_1;
|
srcCharset = StandardCharsets.ISO_8859_1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null == destCharset)
|
if (null == destCharset)
|
||||||
{
|
{
|
||||||
srcCharset = StandardCharsets.UTF_8;
|
srcCharset = StandardCharsets.UTF_8;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (StringUtils.isEmpty(source) || srcCharset.equals(destCharset))
|
if (StringUtils.isEmpty(source) || srcCharset.equals(destCharset))
|
||||||
{
|
{
|
||||||
return source;
|
return source;
|
||||||
}
|
}
|
||||||
return new String(source.getBytes(srcCharset), destCharset);
|
return new String(source.getBytes(srcCharset), destCharset);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return 系统字符集编码
|
* @return 系统字符集编码
|
||||||
*/
|
*/
|
||||||
public static String systemCharset()
|
public static String systemCharset()
|
||||||
{
|
{
|
||||||
return Charset.defaultCharset().name();
|
return Charset.defaultCharset().name();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,92 +1,92 @@
|
||||||
package com.ruoyi.common.core.text;
|
package com.ruoyi.common.core.text;
|
||||||
|
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字符串格式化
|
* 字符串格式化
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class StrFormatter
|
public class StrFormatter
|
||||||
{
|
{
|
||||||
public static final String EMPTY_JSON = "{}";
|
public static final String EMPTY_JSON = "{}";
|
||||||
public static final char C_BACKSLASH = '\\';
|
public static final char C_BACKSLASH = '\\';
|
||||||
public static final char C_DELIM_START = '{';
|
public static final char C_DELIM_START = '{';
|
||||||
public static final char C_DELIM_END = '}';
|
public static final char C_DELIM_END = '}';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 格式化字符串<br>
|
* 格式化字符串<br>
|
||||||
* 此方法只是简单将占位符 {} 按照顺序替换为参数<br>
|
* 此方法只是简单将占位符 {} 按照顺序替换为参数<br>
|
||||||
* 如果想输出 {} 使用 \\转义 { 即可,如果想输出 {} 之前的 \ 使用双转义符 \\\\ 即可<br>
|
* 如果想输出 {} 使用 \\转义 { 即可,如果想输出 {} 之前的 \ 使用双转义符 \\\\ 即可<br>
|
||||||
* 例:<br>
|
* 例:<br>
|
||||||
* 通常使用:format("this is {} for {}", "a", "b") -> this is a for b<br>
|
* 通常使用:format("this is {} for {}", "a", "b") -> this is a for b<br>
|
||||||
* 转义{}: format("this is \\{} for {}", "a", "b") -> this is \{} for a<br>
|
* 转义{}: format("this is \\{} for {}", "a", "b") -> this is \{} for a<br>
|
||||||
* 转义\: format("this is \\\\{} for {}", "a", "b") -> this is \a for b<br>
|
* 转义\: format("this is \\\\{} for {}", "a", "b") -> this is \a for b<br>
|
||||||
*
|
*
|
||||||
* @param strPattern 字符串模板
|
* @param strPattern 字符串模板
|
||||||
* @param argArray 参数列表
|
* @param argArray 参数列表
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public static String format(final String strPattern, final Object... argArray)
|
public static String format(final String strPattern, final Object... argArray)
|
||||||
{
|
{
|
||||||
if (StringUtils.isEmpty(strPattern) || StringUtils.isEmpty(argArray))
|
if (StringUtils.isEmpty(strPattern) || StringUtils.isEmpty(argArray))
|
||||||
{
|
{
|
||||||
return strPattern;
|
return strPattern;
|
||||||
}
|
}
|
||||||
final int strPatternLength = strPattern.length();
|
final int strPatternLength = strPattern.length();
|
||||||
|
|
||||||
// 初始化定义好的长度以获得更好的性能
|
// 初始化定义好的长度以获得更好的性能
|
||||||
StringBuilder sbuf = new StringBuilder(strPatternLength + 50);
|
StringBuilder sbuf = new StringBuilder(strPatternLength + 50);
|
||||||
|
|
||||||
int handledPosition = 0;
|
int handledPosition = 0;
|
||||||
int delimIndex;// 占位符所在位置
|
int delimIndex;// 占位符所在位置
|
||||||
for (int argIndex = 0; argIndex < argArray.length; argIndex++)
|
for (int argIndex = 0; argIndex < argArray.length; argIndex++)
|
||||||
{
|
{
|
||||||
delimIndex = strPattern.indexOf(EMPTY_JSON, handledPosition);
|
delimIndex = strPattern.indexOf(EMPTY_JSON, handledPosition);
|
||||||
if (delimIndex == -1)
|
if (delimIndex == -1)
|
||||||
{
|
{
|
||||||
if (handledPosition == 0)
|
if (handledPosition == 0)
|
||||||
{
|
{
|
||||||
return strPattern;
|
return strPattern;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // 字符串模板剩余部分不再包含占位符,加入剩余部分后返回结果
|
{ // 字符串模板剩余部分不再包含占位符,加入剩余部分后返回结果
|
||||||
sbuf.append(strPattern, handledPosition, strPatternLength);
|
sbuf.append(strPattern, handledPosition, strPatternLength);
|
||||||
return sbuf.toString();
|
return sbuf.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (delimIndex > 0 && strPattern.charAt(delimIndex - 1) == C_BACKSLASH)
|
if (delimIndex > 0 && strPattern.charAt(delimIndex - 1) == C_BACKSLASH)
|
||||||
{
|
{
|
||||||
if (delimIndex > 1 && strPattern.charAt(delimIndex - 2) == C_BACKSLASH)
|
if (delimIndex > 1 && strPattern.charAt(delimIndex - 2) == C_BACKSLASH)
|
||||||
{
|
{
|
||||||
// 转义符之前还有一个转义符,占位符依旧有效
|
// 转义符之前还有一个转义符,占位符依旧有效
|
||||||
sbuf.append(strPattern, handledPosition, delimIndex - 1);
|
sbuf.append(strPattern, handledPosition, delimIndex - 1);
|
||||||
sbuf.append(Convert.utf8Str(argArray[argIndex]));
|
sbuf.append(Convert.utf8Str(argArray[argIndex]));
|
||||||
handledPosition = delimIndex + 2;
|
handledPosition = delimIndex + 2;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// 占位符被转义
|
// 占位符被转义
|
||||||
argIndex--;
|
argIndex--;
|
||||||
sbuf.append(strPattern, handledPosition, delimIndex - 1);
|
sbuf.append(strPattern, handledPosition, delimIndex - 1);
|
||||||
sbuf.append(C_DELIM_START);
|
sbuf.append(C_DELIM_START);
|
||||||
handledPosition = delimIndex + 1;
|
handledPosition = delimIndex + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// 正常占位符
|
// 正常占位符
|
||||||
sbuf.append(strPattern, handledPosition, delimIndex);
|
sbuf.append(strPattern, handledPosition, delimIndex);
|
||||||
sbuf.append(Convert.utf8Str(argArray[argIndex]));
|
sbuf.append(Convert.utf8Str(argArray[argIndex]));
|
||||||
handledPosition = delimIndex + 2;
|
handledPosition = delimIndex + 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 加入最后一个占位符后所有的字符
|
// 加入最后一个占位符后所有的字符
|
||||||
sbuf.append(strPattern, handledPosition, strPattern.length());
|
sbuf.append(strPattern, handledPosition, strPattern.length());
|
||||||
|
|
||||||
return sbuf.toString();
|
return sbuf.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,19 @@
|
||||||
package com.ruoyi.common.enums;
|
package com.ruoyi.common.enums;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 操作状态
|
* 操作状态
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public enum BusinessStatus
|
public enum BusinessStatus
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* 成功
|
* 成功
|
||||||
*/
|
*/
|
||||||
SUCCESS,
|
SUCCESS,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 失败
|
* 失败
|
||||||
*/
|
*/
|
||||||
FAIL,
|
FAIL,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,59 +1,59 @@
|
||||||
package com.ruoyi.common.enums;
|
package com.ruoyi.common.enums;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 业务操作类型
|
* 业务操作类型
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public enum BusinessType
|
public enum BusinessType
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* 其它
|
* 其它
|
||||||
*/
|
*/
|
||||||
OTHER,
|
OTHER,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增
|
* 新增
|
||||||
*/
|
*/
|
||||||
INSERT,
|
INSERT,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改
|
* 修改
|
||||||
*/
|
*/
|
||||||
UPDATE,
|
UPDATE,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除
|
* 删除
|
||||||
*/
|
*/
|
||||||
DELETE,
|
DELETE,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 授权
|
* 授权
|
||||||
*/
|
*/
|
||||||
GRANT,
|
GRANT,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出
|
* 导出
|
||||||
*/
|
*/
|
||||||
EXPORT,
|
EXPORT,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导入
|
* 导入
|
||||||
*/
|
*/
|
||||||
IMPORT,
|
IMPORT,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 强退
|
* 强退
|
||||||
*/
|
*/
|
||||||
FORCE,
|
FORCE,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成代码
|
* 生成代码
|
||||||
*/
|
*/
|
||||||
GENCODE,
|
GENCODE,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 清空
|
* 清空
|
||||||
*/
|
*/
|
||||||
CLEAN,
|
CLEAN,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,19 @@
|
||||||
package com.ruoyi.common.enums;
|
package com.ruoyi.common.enums;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数据源
|
* 数据源
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public enum DataSourceType
|
public enum DataSourceType
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* 主库
|
* 主库
|
||||||
*/
|
*/
|
||||||
MASTER,
|
MASTER,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 从库
|
* 从库
|
||||||
*/
|
*/
|
||||||
SLAVE
|
SLAVE
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,24 +1,24 @@
|
||||||
package com.ruoyi.common.enums;
|
package com.ruoyi.common.enums;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户会话
|
* 用户会话
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public enum OnlineStatus
|
public enum OnlineStatus
|
||||||
{
|
{
|
||||||
/** 用户状态 */
|
/** 用户状态 */
|
||||||
on_line("在线"), off_line("离线");
|
on_line("在线"), off_line("离线");
|
||||||
|
|
||||||
private final String info;
|
private final String info;
|
||||||
|
|
||||||
private OnlineStatus(String info)
|
private OnlineStatus(String info)
|
||||||
{
|
{
|
||||||
this.info = info;
|
this.info = info;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getInfo()
|
public String getInfo()
|
||||||
{
|
{
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,24 +1,24 @@
|
||||||
package com.ruoyi.common.enums;
|
package com.ruoyi.common.enums;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 操作人类别
|
* 操作人类别
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public enum OperatorType
|
public enum OperatorType
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* 其它
|
* 其它
|
||||||
*/
|
*/
|
||||||
OTHER,
|
OTHER,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 后台用户
|
* 后台用户
|
||||||
*/
|
*/
|
||||||
MANAGE,
|
MANAGE,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 手机端用户
|
* 手机端用户
|
||||||
*/
|
*/
|
||||||
MOBILE
|
MOBILE
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,30 +1,30 @@
|
||||||
package com.ruoyi.common.enums;
|
package com.ruoyi.common.enums;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户状态
|
* 用户状态
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public enum UserStatus
|
public enum UserStatus
|
||||||
{
|
{
|
||||||
OK("0", "正常"), DISABLE("1", "停用"), DELETED("2", "删除");
|
OK("0", "正常"), DISABLE("1", "停用"), DELETED("2", "删除");
|
||||||
|
|
||||||
private final String code;
|
private final String code;
|
||||||
private final String info;
|
private final String info;
|
||||||
|
|
||||||
UserStatus(String code, String info)
|
UserStatus(String code, String info)
|
||||||
{
|
{
|
||||||
this.code = code;
|
this.code = code;
|
||||||
this.info = info;
|
this.info = info;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCode()
|
public String getCode()
|
||||||
{
|
{
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getInfo()
|
public String getInfo()
|
||||||
{
|
{
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,15 @@
|
||||||
package com.ruoyi.common.exception;
|
package com.ruoyi.common.exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 演示模式异常
|
* 演示模式异常
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class DemoModeException extends RuntimeException
|
public class DemoModeException extends RuntimeException
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public DemoModeException()
|
public DemoModeException()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,97 +1,97 @@
|
||||||
package com.ruoyi.common.exception.base;
|
package com.ruoyi.common.exception.base;
|
||||||
|
|
||||||
import com.ruoyi.common.utils.MessageUtils;
|
import com.ruoyi.common.utils.MessageUtils;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 基础异常
|
* 基础异常
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class BaseException extends RuntimeException
|
public class BaseException extends RuntimeException
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 所属模块
|
* 所属模块
|
||||||
*/
|
*/
|
||||||
private String module;
|
private String module;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 错误码
|
* 错误码
|
||||||
*/
|
*/
|
||||||
private String code;
|
private String code;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 错误码对应的参数
|
* 错误码对应的参数
|
||||||
*/
|
*/
|
||||||
private Object[] args;
|
private Object[] args;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 错误消息
|
* 错误消息
|
||||||
*/
|
*/
|
||||||
private String defaultMessage;
|
private String defaultMessage;
|
||||||
|
|
||||||
public BaseException(String module, String code, Object[] args, String defaultMessage)
|
public BaseException(String module, String code, Object[] args, String defaultMessage)
|
||||||
{
|
{
|
||||||
this.module = module;
|
this.module = module;
|
||||||
this.code = code;
|
this.code = code;
|
||||||
this.args = args;
|
this.args = args;
|
||||||
this.defaultMessage = defaultMessage;
|
this.defaultMessage = defaultMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BaseException(String module, String code, Object[] args)
|
public BaseException(String module, String code, Object[] args)
|
||||||
{
|
{
|
||||||
this(module, code, args, null);
|
this(module, code, args, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BaseException(String module, String defaultMessage)
|
public BaseException(String module, String defaultMessage)
|
||||||
{
|
{
|
||||||
this(module, null, null, defaultMessage);
|
this(module, null, null, defaultMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BaseException(String code, Object[] args)
|
public BaseException(String code, Object[] args)
|
||||||
{
|
{
|
||||||
this(null, code, args, null);
|
this(null, code, args, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BaseException(String defaultMessage)
|
public BaseException(String defaultMessage)
|
||||||
{
|
{
|
||||||
this(null, null, null, defaultMessage);
|
this(null, null, null, defaultMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getMessage()
|
public String getMessage()
|
||||||
{
|
{
|
||||||
String message = null;
|
String message = null;
|
||||||
if (!StringUtils.isEmpty(code))
|
if (!StringUtils.isEmpty(code))
|
||||||
{
|
{
|
||||||
message = MessageUtils.message(code, args);
|
message = MessageUtils.message(code, args);
|
||||||
}
|
}
|
||||||
if (message == null)
|
if (message == null)
|
||||||
{
|
{
|
||||||
message = defaultMessage;
|
message = defaultMessage;
|
||||||
}
|
}
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getModule()
|
public String getModule()
|
||||||
{
|
{
|
||||||
return module;
|
return module;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCode()
|
public String getCode()
|
||||||
{
|
{
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object[] getArgs()
|
public Object[] getArgs()
|
||||||
{
|
{
|
||||||
return args;
|
return args;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDefaultMessage()
|
public String getDefaultMessage()
|
||||||
{
|
{
|
||||||
return defaultMessage;
|
return defaultMessage;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,16 @@
|
||||||
package com.ruoyi.common.exception.file;
|
package com.ruoyi.common.exception.file;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文件名称超长限制异常类
|
* 文件名称超长限制异常类
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class FileNameLengthLimitExceededException extends FileException
|
public class FileNameLengthLimitExceededException extends FileException
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public FileNameLengthLimitExceededException(int defaultFileNameLength)
|
public FileNameLengthLimitExceededException(int defaultFileNameLength)
|
||||||
{
|
{
|
||||||
super("upload.filename.exceed.length", new Object[] { defaultFileNameLength });
|
super("upload.filename.exceed.length", new Object[] { defaultFileNameLength });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,71 +1,71 @@
|
||||||
package com.ruoyi.common.exception.file;
|
package com.ruoyi.common.exception.file;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import org.apache.commons.fileupload.FileUploadException;
|
import org.apache.commons.fileupload.FileUploadException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文件上传 误异常类
|
* 文件上传 误异常类
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class InvalidExtensionException extends FileUploadException
|
public class InvalidExtensionException extends FileUploadException
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private String[] allowedExtension;
|
private String[] allowedExtension;
|
||||||
private String extension;
|
private String extension;
|
||||||
private String filename;
|
private String filename;
|
||||||
|
|
||||||
public InvalidExtensionException(String[] allowedExtension, String extension, String filename)
|
public InvalidExtensionException(String[] allowedExtension, String extension, String filename)
|
||||||
{
|
{
|
||||||
super("filename : [" + filename + "], extension : [" + extension + "], allowed extension : [" + Arrays.toString(allowedExtension) + "]");
|
super("filename : [" + filename + "], extension : [" + extension + "], allowed extension : [" + Arrays.toString(allowedExtension) + "]");
|
||||||
this.allowedExtension = allowedExtension;
|
this.allowedExtension = allowedExtension;
|
||||||
this.extension = extension;
|
this.extension = extension;
|
||||||
this.filename = filename;
|
this.filename = filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String[] getAllowedExtension()
|
public String[] getAllowedExtension()
|
||||||
{
|
{
|
||||||
return allowedExtension;
|
return allowedExtension;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getExtension()
|
public String getExtension()
|
||||||
{
|
{
|
||||||
return extension;
|
return extension;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFilename()
|
public String getFilename()
|
||||||
{
|
{
|
||||||
return filename;
|
return filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class InvalidImageExtensionException extends InvalidExtensionException
|
public static class InvalidImageExtensionException extends InvalidExtensionException
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public InvalidImageExtensionException(String[] allowedExtension, String extension, String filename)
|
public InvalidImageExtensionException(String[] allowedExtension, String extension, String filename)
|
||||||
{
|
{
|
||||||
super(allowedExtension, extension, filename);
|
super(allowedExtension, extension, filename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class InvalidFlashExtensionException extends InvalidExtensionException
|
public static class InvalidFlashExtensionException extends InvalidExtensionException
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public InvalidFlashExtensionException(String[] allowedExtension, String extension, String filename)
|
public InvalidFlashExtensionException(String[] allowedExtension, String extension, String filename)
|
||||||
{
|
{
|
||||||
super(allowedExtension, extension, filename);
|
super(allowedExtension, extension, filename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class InvalidMediaExtensionException extends InvalidExtensionException
|
public static class InvalidMediaExtensionException extends InvalidExtensionException
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public InvalidMediaExtensionException(String[] allowedExtension, String extension, String filename)
|
public InvalidMediaExtensionException(String[] allowedExtension, String extension, String filename)
|
||||||
{
|
{
|
||||||
super(allowedExtension, extension, filename);
|
super(allowedExtension, extension, filename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,34 +1,34 @@
|
||||||
package com.ruoyi.common.exception.job;
|
package com.ruoyi.common.exception.job;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 计划策略异常
|
* 计划策略异常
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class TaskException extends Exception
|
public class TaskException extends Exception
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private Code code;
|
private Code code;
|
||||||
|
|
||||||
public TaskException(String msg, Code code)
|
public TaskException(String msg, Code code)
|
||||||
{
|
{
|
||||||
this(msg, code, null);
|
this(msg, code, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TaskException(String msg, Code code, Exception nestedEx)
|
public TaskException(String msg, Code code, Exception nestedEx)
|
||||||
{
|
{
|
||||||
super(msg, nestedEx);
|
super(msg, nestedEx);
|
||||||
this.code = code;
|
this.code = code;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Code getCode()
|
public Code getCode()
|
||||||
{
|
{
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum Code
|
public enum Code
|
||||||
{
|
{
|
||||||
TASK_EXISTS, NO_TASK_EXISTS, TASK_ALREADY_STARTED, UNKNOWN, CONFIG_ERROR, TASK_NODE_NOT_AVAILABLE
|
TASK_EXISTS, NO_TASK_EXISTS, TASK_ALREADY_STARTED, UNKNOWN, CONFIG_ERROR, TASK_NODE_NOT_AVAILABLE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,16 +1,16 @@
|
||||||
package com.ruoyi.common.exception.user;
|
package com.ruoyi.common.exception.user;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 验证码错误异常类
|
* 验证码错误异常类
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class CaptchaException extends UserException
|
public class CaptchaException extends UserException
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public CaptchaException()
|
public CaptchaException()
|
||||||
{
|
{
|
||||||
super("user.jcaptcha.error", null);
|
super("user.jcaptcha.error", null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,16 @@
|
||||||
package com.ruoyi.common.exception.user;
|
package com.ruoyi.common.exception.user;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 角色锁定异常类
|
* 角色锁定异常类
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class RoleBlockedException extends UserException
|
public class RoleBlockedException extends UserException
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public RoleBlockedException()
|
public RoleBlockedException()
|
||||||
{
|
{
|
||||||
super("role.blocked", null);
|
super("role.blocked", null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,16 @@
|
||||||
package com.ruoyi.common.exception.user;
|
package com.ruoyi.common.exception.user;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户锁定异常类
|
* 用户锁定异常类
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class UserBlockedException extends UserException
|
public class UserBlockedException extends UserException
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public UserBlockedException()
|
public UserBlockedException()
|
||||||
{
|
{
|
||||||
super("user.blocked", null);
|
super("user.blocked", null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,16 @@
|
||||||
package com.ruoyi.common.exception.user;
|
package com.ruoyi.common.exception.user;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户账号已被删除
|
* 用户账号已被删除
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class UserDeleteException extends UserException
|
public class UserDeleteException extends UserException
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public UserDeleteException()
|
public UserDeleteException()
|
||||||
{
|
{
|
||||||
super("user.password.delete", null);
|
super("user.password.delete", null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,18 @@
|
||||||
package com.ruoyi.common.exception.user;
|
package com.ruoyi.common.exception.user;
|
||||||
|
|
||||||
import com.ruoyi.common.exception.base.BaseException;
|
import com.ruoyi.common.exception.base.BaseException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户信息异常类
|
* 用户信息异常类
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class UserException extends BaseException
|
public class UserException extends BaseException
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public UserException(String code, Object[] args)
|
public UserException(String code, Object[] args)
|
||||||
{
|
{
|
||||||
super("user", code, args, null);
|
super("user", code, args, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,16 @@
|
||||||
package com.ruoyi.common.exception.user;
|
package com.ruoyi.common.exception.user;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户不存在异常类
|
* 用户不存在异常类
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class UserNotExistsException extends UserException
|
public class UserNotExistsException extends UserException
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public UserNotExistsException()
|
public UserNotExistsException()
|
||||||
{
|
{
|
||||||
super("user.not.exists", null);
|
super("user.not.exists", null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,16 @@
|
||||||
package com.ruoyi.common.exception.user;
|
package com.ruoyi.common.exception.user;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户密码不正确或不符合规范异常类
|
* 用户密码不正确或不符合规范异常类
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class UserPasswordNotMatchException extends UserException
|
public class UserPasswordNotMatchException extends UserException
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public UserPasswordNotMatchException()
|
public UserPasswordNotMatchException()
|
||||||
{
|
{
|
||||||
super("user.password.not.match", null);
|
super("user.password.not.match", null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,16 @@
|
||||||
package com.ruoyi.common.exception.user;
|
package com.ruoyi.common.exception.user;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户错误记数异常类
|
* 用户错误记数异常类
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class UserPasswordRetryLimitCountException extends UserException
|
public class UserPasswordRetryLimitCountException extends UserException
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public UserPasswordRetryLimitCountException(int retryLimitCount)
|
public UserPasswordRetryLimitCountException(int retryLimitCount)
|
||||||
{
|
{
|
||||||
super("user.password.retry.limit.count", new Object[] { retryLimitCount });
|
super("user.password.retry.limit.count", new Object[] { retryLimitCount });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,16 @@
|
||||||
package com.ruoyi.common.exception.user;
|
package com.ruoyi.common.exception.user;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户错误最大次数异常类
|
* 用户错误最大次数异常类
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class UserPasswordRetryLimitExceedException extends UserException
|
public class UserPasswordRetryLimitExceedException extends UserException
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public UserPasswordRetryLimitExceedException(int retryLimitCount)
|
public UserPasswordRetryLimitExceedException(int retryLimitCount)
|
||||||
{
|
{
|
||||||
super("user.password.retry.limit.exceed", new Object[] { retryLimitCount });
|
super("user.password.retry.limit.exceed", new Object[] { retryLimitCount });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,187 +1,187 @@
|
||||||
package com.ruoyi.common.json;
|
package com.ruoyi.common.json;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import com.fasterxml.jackson.core.JsonGenerationException;
|
import com.fasterxml.jackson.core.JsonGenerationException;
|
||||||
import com.fasterxml.jackson.core.JsonParseException;
|
import com.fasterxml.jackson.core.JsonParseException;
|
||||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.fasterxml.jackson.databind.ObjectWriter;
|
import com.fasterxml.jackson.databind.ObjectWriter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* JSON解析处理
|
* JSON解析处理
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class JSON
|
public class JSON
|
||||||
{
|
{
|
||||||
public static final String DEFAULT_FAIL = "\"Parse failed\"";
|
public static final String DEFAULT_FAIL = "\"Parse failed\"";
|
||||||
private static final ObjectMapper objectMapper = new ObjectMapper();
|
private static final ObjectMapper objectMapper = new ObjectMapper();
|
||||||
private static final ObjectWriter objectWriter = objectMapper.writerWithDefaultPrettyPrinter();
|
private static final ObjectWriter objectWriter = objectMapper.writerWithDefaultPrettyPrinter();
|
||||||
|
|
||||||
public static void marshal(File file, Object value) throws Exception
|
public static void marshal(File file, Object value) throws Exception
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
objectWriter.writeValue(file, value);
|
objectWriter.writeValue(file, value);
|
||||||
}
|
}
|
||||||
catch (JsonGenerationException e)
|
catch (JsonGenerationException e)
|
||||||
{
|
{
|
||||||
throw new Exception(e);
|
throw new Exception(e);
|
||||||
}
|
}
|
||||||
catch (JsonMappingException e)
|
catch (JsonMappingException e)
|
||||||
{
|
{
|
||||||
throw new Exception(e);
|
throw new Exception(e);
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
throw new Exception(e);
|
throw new Exception(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void marshal(OutputStream os, Object value) throws Exception
|
public static void marshal(OutputStream os, Object value) throws Exception
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
objectWriter.writeValue(os, value);
|
objectWriter.writeValue(os, value);
|
||||||
}
|
}
|
||||||
catch (JsonGenerationException e)
|
catch (JsonGenerationException e)
|
||||||
{
|
{
|
||||||
throw new Exception(e);
|
throw new Exception(e);
|
||||||
}
|
}
|
||||||
catch (JsonMappingException e)
|
catch (JsonMappingException e)
|
||||||
{
|
{
|
||||||
throw new Exception(e);
|
throw new Exception(e);
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
throw new Exception(e);
|
throw new Exception(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String marshal(Object value) throws Exception
|
public static String marshal(Object value) throws Exception
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return objectWriter.writeValueAsString(value);
|
return objectWriter.writeValueAsString(value);
|
||||||
}
|
}
|
||||||
catch (JsonGenerationException e)
|
catch (JsonGenerationException e)
|
||||||
{
|
{
|
||||||
throw new Exception(e);
|
throw new Exception(e);
|
||||||
}
|
}
|
||||||
catch (JsonMappingException e)
|
catch (JsonMappingException e)
|
||||||
{
|
{
|
||||||
throw new Exception(e);
|
throw new Exception(e);
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
throw new Exception(e);
|
throw new Exception(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] marshalBytes(Object value) throws Exception
|
public static byte[] marshalBytes(Object value) throws Exception
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return objectWriter.writeValueAsBytes(value);
|
return objectWriter.writeValueAsBytes(value);
|
||||||
}
|
}
|
||||||
catch (JsonGenerationException e)
|
catch (JsonGenerationException e)
|
||||||
{
|
{
|
||||||
throw new Exception(e);
|
throw new Exception(e);
|
||||||
}
|
}
|
||||||
catch (JsonMappingException e)
|
catch (JsonMappingException e)
|
||||||
{
|
{
|
||||||
throw new Exception(e);
|
throw new Exception(e);
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
throw new Exception(e);
|
throw new Exception(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> T unmarshal(File file, Class<T> valueType) throws Exception
|
public static <T> T unmarshal(File file, Class<T> valueType) throws Exception
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return objectMapper.readValue(file, valueType);
|
return objectMapper.readValue(file, valueType);
|
||||||
}
|
}
|
||||||
catch (JsonParseException e)
|
catch (JsonParseException e)
|
||||||
{
|
{
|
||||||
throw new Exception(e);
|
throw new Exception(e);
|
||||||
}
|
}
|
||||||
catch (JsonMappingException e)
|
catch (JsonMappingException e)
|
||||||
{
|
{
|
||||||
throw new Exception(e);
|
throw new Exception(e);
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
throw new Exception(e);
|
throw new Exception(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> T unmarshal(InputStream is, Class<T> valueType) throws Exception
|
public static <T> T unmarshal(InputStream is, Class<T> valueType) throws Exception
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return objectMapper.readValue(is, valueType);
|
return objectMapper.readValue(is, valueType);
|
||||||
}
|
}
|
||||||
catch (JsonParseException e)
|
catch (JsonParseException e)
|
||||||
{
|
{
|
||||||
throw new Exception(e);
|
throw new Exception(e);
|
||||||
}
|
}
|
||||||
catch (JsonMappingException e)
|
catch (JsonMappingException e)
|
||||||
{
|
{
|
||||||
throw new Exception(e);
|
throw new Exception(e);
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
throw new Exception(e);
|
throw new Exception(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> T unmarshal(String str, Class<T> valueType) throws Exception
|
public static <T> T unmarshal(String str, Class<T> valueType) throws Exception
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return objectMapper.readValue(str, valueType);
|
return objectMapper.readValue(str, valueType);
|
||||||
}
|
}
|
||||||
catch (JsonParseException e)
|
catch (JsonParseException e)
|
||||||
{
|
{
|
||||||
throw new Exception(e);
|
throw new Exception(e);
|
||||||
}
|
}
|
||||||
catch (JsonMappingException e)
|
catch (JsonMappingException e)
|
||||||
{
|
{
|
||||||
throw new Exception(e);
|
throw new Exception(e);
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
throw new Exception(e);
|
throw new Exception(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> T unmarshal(byte[] bytes, Class<T> valueType) throws Exception
|
public static <T> T unmarshal(byte[] bytes, Class<T> valueType) throws Exception
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (bytes == null)
|
if (bytes == null)
|
||||||
{
|
{
|
||||||
bytes = new byte[0];
|
bytes = new byte[0];
|
||||||
}
|
}
|
||||||
return objectMapper.readValue(bytes, 0, bytes.length, valueType);
|
return objectMapper.readValue(bytes, 0, bytes.length, valueType);
|
||||||
}
|
}
|
||||||
catch (JsonParseException e)
|
catch (JsonParseException e)
|
||||||
{
|
{
|
||||||
throw new Exception(e);
|
throw new Exception(e);
|
||||||
}
|
}
|
||||||
catch (JsonMappingException e)
|
catch (JsonMappingException e)
|
||||||
{
|
{
|
||||||
throw new Exception(e);
|
throw new Exception(e);
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
throw new Exception(e);
|
throw new Exception(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,55 +1,55 @@
|
||||||
package com.ruoyi.common.utils;
|
package com.ruoyi.common.utils;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.ruoyi.common.config.Global;
|
import com.ruoyi.common.config.Global;
|
||||||
import com.ruoyi.common.constant.Constants;
|
import com.ruoyi.common.constant.Constants;
|
||||||
import com.ruoyi.common.utils.http.HttpUtils;
|
import com.ruoyi.common.utils.http.HttpUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取地址类
|
* 获取地址类
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class AddressUtils
|
public class AddressUtils
|
||||||
{
|
{
|
||||||
private static final Logger log = LoggerFactory.getLogger(AddressUtils.class);
|
private static final Logger log = LoggerFactory.getLogger(AddressUtils.class);
|
||||||
|
|
||||||
// IP地址查询
|
// IP地址查询
|
||||||
public static final String IP_URL = "http://whois.pconline.com.cn/ipJson.jsp";
|
public static final String IP_URL = "http://whois.pconline.com.cn/ipJson.jsp";
|
||||||
|
|
||||||
// 未知地址
|
// 未知地址
|
||||||
public static final String UNKNOWN = "XX XX";
|
public static final String UNKNOWN = "XX XX";
|
||||||
|
|
||||||
public static String getRealAddressByIP(String ip)
|
public static String getRealAddressByIP(String ip)
|
||||||
{
|
{
|
||||||
String address = UNKNOWN;
|
String address = UNKNOWN;
|
||||||
// 内网不查询
|
// 内网不查询
|
||||||
if (IpUtils.internalIp(ip))
|
if (IpUtils.internalIp(ip))
|
||||||
{
|
{
|
||||||
return "内网IP";
|
return "内网IP";
|
||||||
}
|
}
|
||||||
if (Global.isAddressEnabled())
|
if (Global.isAddressEnabled())
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
String rspStr = HttpUtils.sendGet(IP_URL, "ip=" + ip + "&json=true", Constants.GBK);
|
String rspStr = HttpUtils.sendGet(IP_URL, "ip=" + ip + "&json=true", Constants.GBK);
|
||||||
if (StringUtils.isEmpty(rspStr))
|
if (StringUtils.isEmpty(rspStr))
|
||||||
{
|
{
|
||||||
log.error("获取地理位置异常 {}", ip);
|
log.error("获取地理位置异常 {}", ip);
|
||||||
return UNKNOWN;
|
return UNKNOWN;
|
||||||
}
|
}
|
||||||
JSONObject obj = JSONObject.parseObject(rspStr);
|
JSONObject obj = JSONObject.parseObject(rspStr);
|
||||||
String region = obj.getString("pro");
|
String region = obj.getString("pro");
|
||||||
String city = obj.getString("city");
|
String city = obj.getString("city");
|
||||||
return String.format("%s %s", region, city);
|
return String.format("%s %s", region, city);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
log.error("获取地理位置异常 {}", e);
|
log.error("获取地理位置异常 {}", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return address;
|
return address;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,114 +1,114 @@
|
||||||
package com.ruoyi.common.utils;
|
package com.ruoyi.common.utils;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 精确的浮点数运算
|
* 精确的浮点数运算
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class Arith
|
public class Arith
|
||||||
{
|
{
|
||||||
|
|
||||||
/** 默认除法运算精度 */
|
/** 默认除法运算精度 */
|
||||||
private static final int DEF_DIV_SCALE = 10;
|
private static final int DEF_DIV_SCALE = 10;
|
||||||
|
|
||||||
/** 这个类不能实例化 */
|
/** 这个类不能实例化 */
|
||||||
private Arith()
|
private Arith()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 提供精确的加法运算。
|
* 提供精确的加法运算。
|
||||||
* @param v1 被加数
|
* @param v1 被加数
|
||||||
* @param v2 加数
|
* @param v2 加数
|
||||||
* @return 两个参数的和
|
* @return 两个参数的和
|
||||||
*/
|
*/
|
||||||
public static double add(double v1, double v2)
|
public static double add(double v1, double v2)
|
||||||
{
|
{
|
||||||
BigDecimal b1 = new BigDecimal(Double.toString(v1));
|
BigDecimal b1 = new BigDecimal(Double.toString(v1));
|
||||||
BigDecimal b2 = new BigDecimal(Double.toString(v2));
|
BigDecimal b2 = new BigDecimal(Double.toString(v2));
|
||||||
return b1.add(b2).doubleValue();
|
return b1.add(b2).doubleValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 提供精确的减法运算。
|
* 提供精确的减法运算。
|
||||||
* @param v1 被减数
|
* @param v1 被减数
|
||||||
* @param v2 减数
|
* @param v2 减数
|
||||||
* @return 两个参数的差
|
* @return 两个参数的差
|
||||||
*/
|
*/
|
||||||
public static double sub(double v1, double v2)
|
public static double sub(double v1, double v2)
|
||||||
{
|
{
|
||||||
BigDecimal b1 = new BigDecimal(Double.toString(v1));
|
BigDecimal b1 = new BigDecimal(Double.toString(v1));
|
||||||
BigDecimal b2 = new BigDecimal(Double.toString(v2));
|
BigDecimal b2 = new BigDecimal(Double.toString(v2));
|
||||||
return b1.subtract(b2).doubleValue();
|
return b1.subtract(b2).doubleValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 提供精确的乘法运算。
|
* 提供精确的乘法运算。
|
||||||
* @param v1 被乘数
|
* @param v1 被乘数
|
||||||
* @param v2 乘数
|
* @param v2 乘数
|
||||||
* @return 两个参数的积
|
* @return 两个参数的积
|
||||||
*/
|
*/
|
||||||
public static double mul(double v1, double v2)
|
public static double mul(double v1, double v2)
|
||||||
{
|
{
|
||||||
BigDecimal b1 = new BigDecimal(Double.toString(v1));
|
BigDecimal b1 = new BigDecimal(Double.toString(v1));
|
||||||
BigDecimal b2 = new BigDecimal(Double.toString(v2));
|
BigDecimal b2 = new BigDecimal(Double.toString(v2));
|
||||||
return b1.multiply(b2).doubleValue();
|
return b1.multiply(b2).doubleValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 提供(相对)精确的除法运算,当发生除不尽的情况时,精确到
|
* 提供(相对)精确的除法运算,当发生除不尽的情况时,精确到
|
||||||
* 小数点以后10位,以后的数字四舍五入。
|
* 小数点以后10位,以后的数字四舍五入。
|
||||||
* @param v1 被除数
|
* @param v1 被除数
|
||||||
* @param v2 除数
|
* @param v2 除数
|
||||||
* @return 两个参数的商
|
* @return 两个参数的商
|
||||||
*/
|
*/
|
||||||
public static double div(double v1, double v2)
|
public static double div(double v1, double v2)
|
||||||
{
|
{
|
||||||
return div(v1, v2, DEF_DIV_SCALE);
|
return div(v1, v2, DEF_DIV_SCALE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 提供(相对)精确的除法运算。当发生除不尽的情况时,由scale参数指
|
* 提供(相对)精确的除法运算。当发生除不尽的情况时,由scale参数指
|
||||||
* 定精度,以后的数字四舍五入。
|
* 定精度,以后的数字四舍五入。
|
||||||
* @param v1 被除数
|
* @param v1 被除数
|
||||||
* @param v2 除数
|
* @param v2 除数
|
||||||
* @param scale 表示表示需要精确到小数点以后几位。
|
* @param scale 表示表示需要精确到小数点以后几位。
|
||||||
* @return 两个参数的商
|
* @return 两个参数的商
|
||||||
*/
|
*/
|
||||||
public static double div(double v1, double v2, int scale)
|
public static double div(double v1, double v2, int scale)
|
||||||
{
|
{
|
||||||
if (scale < 0)
|
if (scale < 0)
|
||||||
{
|
{
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"The scale must be a positive integer or zero");
|
"The scale must be a positive integer or zero");
|
||||||
}
|
}
|
||||||
BigDecimal b1 = new BigDecimal(Double.toString(v1));
|
BigDecimal b1 = new BigDecimal(Double.toString(v1));
|
||||||
BigDecimal b2 = new BigDecimal(Double.toString(v2));
|
BigDecimal b2 = new BigDecimal(Double.toString(v2));
|
||||||
if (b1.compareTo(BigDecimal.ZERO) == 0)
|
if (b1.compareTo(BigDecimal.ZERO) == 0)
|
||||||
{
|
{
|
||||||
return BigDecimal.ZERO.doubleValue();
|
return BigDecimal.ZERO.doubleValue();
|
||||||
}
|
}
|
||||||
return b1.divide(b2, scale, RoundingMode.HALF_UP).doubleValue();
|
return b1.divide(b2, scale, RoundingMode.HALF_UP).doubleValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 提供精确的小数位四舍五入处理。
|
* 提供精确的小数位四舍五入处理。
|
||||||
* @param v 需要四舍五入的数字
|
* @param v 需要四舍五入的数字
|
||||||
* @param scale 小数点后保留几位
|
* @param scale 小数点后保留几位
|
||||||
* @return 四舍五入后的结果
|
* @return 四舍五入后的结果
|
||||||
*/
|
*/
|
||||||
public static double round(double v, int scale)
|
public static double round(double v, int scale)
|
||||||
{
|
{
|
||||||
if (scale < 0)
|
if (scale < 0)
|
||||||
{
|
{
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"The scale must be a positive integer or zero");
|
"The scale must be a positive integer or zero");
|
||||||
}
|
}
|
||||||
BigDecimal b = new BigDecimal(Double.toString(v));
|
BigDecimal b = new BigDecimal(Double.toString(v));
|
||||||
BigDecimal one = new BigDecimal("1");
|
BigDecimal one = new BigDecimal("1");
|
||||||
return b.divide(one, scale, RoundingMode.HALF_UP).doubleValue();
|
return b.divide(one, scale, RoundingMode.HALF_UP).doubleValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,155 +1,155 @@
|
||||||
package com.ruoyi.common.utils;
|
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.util.Date;
|
import java.util.Date;
|
||||||
import org.apache.commons.lang3.time.DateFormatUtils;
|
import org.apache.commons.lang3.time.DateFormatUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 时间工具类
|
* 时间工具类
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class DateUtils extends org.apache.commons.lang3.time.DateUtils
|
public class DateUtils extends org.apache.commons.lang3.time.DateUtils
|
||||||
{
|
{
|
||||||
public static String YYYY = "yyyy";
|
public static String YYYY = "yyyy";
|
||||||
|
|
||||||
public static String YYYY_MM = "yyyy-MM";
|
public static String YYYY_MM = "yyyy-MM";
|
||||||
|
|
||||||
public static String YYYY_MM_DD = "yyyy-MM-dd";
|
public static String YYYY_MM_DD = "yyyy-MM-dd";
|
||||||
|
|
||||||
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",
|
||||||
"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"};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取当前Date型日期
|
* 获取当前Date型日期
|
||||||
*
|
*
|
||||||
* @return Date() 当前日期
|
* @return Date() 当前日期
|
||||||
*/
|
*/
|
||||||
public static Date getNowDate()
|
public static Date getNowDate()
|
||||||
{
|
{
|
||||||
return new Date();
|
return new Date();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取当前日期, 默认格式为yyyy-MM-dd
|
* 获取当前日期, 默认格式为yyyy-MM-dd
|
||||||
*
|
*
|
||||||
* @return String
|
* @return String
|
||||||
*/
|
*/
|
||||||
public static String getDate()
|
public static String getDate()
|
||||||
{
|
{
|
||||||
return dateTimeNow(YYYY_MM_DD);
|
return dateTimeNow(YYYY_MM_DD);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final String getTime()
|
public static final String getTime()
|
||||||
{
|
{
|
||||||
return dateTimeNow(YYYY_MM_DD_HH_MM_SS);
|
return dateTimeNow(YYYY_MM_DD_HH_MM_SS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final String dateTimeNow()
|
public static final String dateTimeNow()
|
||||||
{
|
{
|
||||||
return dateTimeNow(YYYYMMDDHHMMSS);
|
return dateTimeNow(YYYYMMDDHHMMSS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final String dateTimeNow(final String format)
|
public static final String dateTimeNow(final String format)
|
||||||
{
|
{
|
||||||
return parseDateToStr(format, new Date());
|
return parseDateToStr(format, new Date());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final String dateTime(final Date date)
|
public static final String dateTime(final Date date)
|
||||||
{
|
{
|
||||||
return parseDateToStr(YYYY_MM_DD, date);
|
return parseDateToStr(YYYY_MM_DD, date);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final String parseDateToStr(final String format, final Date date)
|
public static final String parseDateToStr(final String format, final Date date)
|
||||||
{
|
{
|
||||||
return new SimpleDateFormat(format).format(date);
|
return new SimpleDateFormat(format).format(date);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final Date dateTime(final String format, final String ts)
|
public static final Date dateTime(final String format, final String ts)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return new SimpleDateFormat(format).parse(ts);
|
return new SimpleDateFormat(format).parse(ts);
|
||||||
}
|
}
|
||||||
catch (ParseException e)
|
catch (ParseException e)
|
||||||
{
|
{
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 日期路径 即年/月/日 如2018/08/08
|
* 日期路径 即年/月/日 如2018/08/08
|
||||||
*/
|
*/
|
||||||
public static final String datePath()
|
public static final String datePath()
|
||||||
{
|
{
|
||||||
Date now = new Date();
|
Date now = new Date();
|
||||||
return DateFormatUtils.format(now, "yyyy/MM/dd");
|
return DateFormatUtils.format(now, "yyyy/MM/dd");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 日期路径 即年/月/日 如20180808
|
* 日期路径 即年/月/日 如20180808
|
||||||
*/
|
*/
|
||||||
public static final String dateTime()
|
public static final String dateTime()
|
||||||
{
|
{
|
||||||
Date now = new Date();
|
Date now = new Date();
|
||||||
return DateFormatUtils.format(now, "yyyyMMdd");
|
return DateFormatUtils.format(now, "yyyyMMdd");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 日期型字符串转化为日期 格式
|
* 日期型字符串转化为日期 格式
|
||||||
*/
|
*/
|
||||||
public static Date parseDate(Object str)
|
public static Date parseDate(Object str)
|
||||||
{
|
{
|
||||||
if (str == null)
|
if (str == null)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return parseDate(str.toString(), parsePatterns);
|
return parseDate(str.toString(), parsePatterns);
|
||||||
}
|
}
|
||||||
catch (ParseException e)
|
catch (ParseException e)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取服务器启动时间
|
* 获取服务器启动时间
|
||||||
*/
|
*/
|
||||||
public static Date getServerStartDate()
|
public static Date getServerStartDate()
|
||||||
{
|
{
|
||||||
long time = ManagementFactory.getRuntimeMXBean().getStartTime();
|
long time = ManagementFactory.getRuntimeMXBean().getStartTime();
|
||||||
return new Date(time);
|
return new Date(time);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 计算两个时间差
|
* 计算两个时间差
|
||||||
*/
|
*/
|
||||||
public static String getDatePoor(Date endDate, Date nowDate)
|
public static String getDatePoor(Date endDate, Date nowDate)
|
||||||
{
|
{
|
||||||
long nd = 1000 * 24 * 60 * 60;
|
long nd = 1000 * 24 * 60 * 60;
|
||||||
long nh = 1000 * 60 * 60;
|
long nh = 1000 * 60 * 60;
|
||||||
long nm = 1000 * 60;
|
long nm = 1000 * 60;
|
||||||
// long ns = 1000;
|
// long ns = 1000;
|
||||||
// 获得两个时间的毫秒时间差异
|
// 获得两个时间的毫秒时间差异
|
||||||
long diff = endDate.getTime() - nowDate.getTime();
|
long diff = endDate.getTime() - nowDate.getTime();
|
||||||
// 计算差多少天
|
// 计算差多少天
|
||||||
long day = diff / nd;
|
long day = diff / nd;
|
||||||
// 计算差多少小时
|
// 计算差多少小时
|
||||||
long hour = diff % nd / nh;
|
long hour = diff % nd / nh;
|
||||||
// 计算差多少分钟
|
// 计算差多少分钟
|
||||||
long min = diff % nd % nh / nm;
|
long min = diff % nd % nh / nm;
|
||||||
// 计算差多少秒//输出结果
|
// 计算差多少秒//输出结果
|
||||||
// long sec = diff % nd % nh % nm / ns;
|
// long sec = diff % nd % nh % nm / ns;
|
||||||
return day + "天" + hour + "小时" + min + "分钟";
|
return day + "天" + hour + "小时" + min + "分钟";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,40 +1,40 @@
|
||||||
package com.ruoyi.common.utils;
|
package com.ruoyi.common.utils;
|
||||||
|
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 错误信息处理类。
|
* 错误信息处理类。
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class ExceptionUtil
|
public class ExceptionUtil
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* 获取exception的详细错误信息。
|
* 获取exception的详细错误信息。
|
||||||
*/
|
*/
|
||||||
public static String getExceptionMessage(Throwable e)
|
public static String getExceptionMessage(Throwable e)
|
||||||
{
|
{
|
||||||
StringWriter sw = new StringWriter();
|
StringWriter sw = new StringWriter();
|
||||||
e.printStackTrace(new PrintWriter(sw, true));
|
e.printStackTrace(new PrintWriter(sw, true));
|
||||||
String str = sw.toString();
|
String str = sw.toString();
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getRootErrorMseeage(Exception e)
|
public static String getRootErrorMseeage(Exception e)
|
||||||
{
|
{
|
||||||
Throwable root = ExceptionUtils.getRootCause(e);
|
Throwable root = ExceptionUtils.getRootCause(e);
|
||||||
root = (root == null ? e : root);
|
root = (root == null ? e : root);
|
||||||
if (root == null)
|
if (root == null)
|
||||||
{
|
{
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
String msg = root.getMessage();
|
String msg = root.getMessage();
|
||||||
if (msg == null)
|
if (msg == null)
|
||||||
{
|
{
|
||||||
return "null";
|
return "null";
|
||||||
}
|
}
|
||||||
return StringUtils.defaultString(msg);
|
return StringUtils.defaultString(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,194 +1,194 @@
|
||||||
package com.ruoyi.common.utils;
|
package com.ruoyi.common.utils;
|
||||||
|
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取IP方法
|
* 获取IP方法
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class IpUtils
|
public class IpUtils
|
||||||
{
|
{
|
||||||
public static String getIpAddr(HttpServletRequest request)
|
public static String getIpAddr(HttpServletRequest request)
|
||||||
{
|
{
|
||||||
if (request == null)
|
if (request == null)
|
||||||
{
|
{
|
||||||
return "unknown";
|
return "unknown";
|
||||||
}
|
}
|
||||||
String ip = request.getHeader("x-forwarded-for");
|
String ip = request.getHeader("x-forwarded-for");
|
||||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip))
|
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip))
|
||||||
{
|
{
|
||||||
ip = request.getHeader("Proxy-Client-IP");
|
ip = request.getHeader("Proxy-Client-IP");
|
||||||
}
|
}
|
||||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip))
|
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip))
|
||||||
{
|
{
|
||||||
ip = request.getHeader("X-Forwarded-For");
|
ip = request.getHeader("X-Forwarded-For");
|
||||||
}
|
}
|
||||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip))
|
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip))
|
||||||
{
|
{
|
||||||
ip = request.getHeader("WL-Proxy-Client-IP");
|
ip = request.getHeader("WL-Proxy-Client-IP");
|
||||||
}
|
}
|
||||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip))
|
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip))
|
||||||
{
|
{
|
||||||
ip = request.getHeader("X-Real-IP");
|
ip = request.getHeader("X-Real-IP");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip))
|
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip))
|
||||||
{
|
{
|
||||||
ip = request.getRemoteAddr();
|
ip = request.getRemoteAddr();
|
||||||
}
|
}
|
||||||
|
|
||||||
return "0:0:0:0:0:0:0:1".equals(ip) ? "127.0.0.1" : ip;
|
return "0:0:0:0:0:0:0:1".equals(ip) ? "127.0.0.1" : ip;
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
final byte b0 = addr[0];
|
final byte b0 = addr[0];
|
||||||
final byte b1 = addr[1];
|
final byte b1 = addr[1];
|
||||||
// 10.x.x.x/8
|
// 10.x.x.x/8
|
||||||
final byte SECTION_1 = 0x0A;
|
final byte SECTION_1 = 0x0A;
|
||||||
// 172.16.x.x/12
|
// 172.16.x.x/12
|
||||||
final byte SECTION_2 = (byte) 0xAC;
|
final byte SECTION_2 = (byte) 0xAC;
|
||||||
final byte SECTION_3 = (byte) 0x10;
|
final byte SECTION_3 = (byte) 0x10;
|
||||||
final byte SECTION_4 = (byte) 0x1F;
|
final byte SECTION_4 = (byte) 0x1F;
|
||||||
// 192.168.x.x/16
|
// 192.168.x.x/16
|
||||||
final byte SECTION_5 = (byte) 0xC0;
|
final byte SECTION_5 = (byte) 0xC0;
|
||||||
final byte SECTION_6 = (byte) 0xA8;
|
final byte SECTION_6 = (byte) 0xA8;
|
||||||
switch (b0)
|
switch (b0)
|
||||||
{
|
{
|
||||||
case SECTION_1:
|
case SECTION_1:
|
||||||
return true;
|
return true;
|
||||||
case SECTION_2:
|
case SECTION_2:
|
||||||
if (b1 >= SECTION_3 && b1 <= SECTION_4)
|
if (b1 >= SECTION_3 && b1 <= SECTION_4)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case SECTION_5:
|
case SECTION_5:
|
||||||
switch (b1)
|
switch (b1)
|
||||||
{
|
{
|
||||||
case SECTION_6:
|
case SECTION_6:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 将IPv4地址转换成字节
|
* 将IPv4地址转换成字节
|
||||||
*
|
*
|
||||||
* @param text IPv4地址
|
* @param text IPv4地址
|
||||||
* @return byte 字节
|
* @return byte 字节
|
||||||
*/
|
*/
|
||||||
public static byte[] textToNumericFormatV4(String text)
|
public static byte[] textToNumericFormatV4(String text)
|
||||||
{
|
{
|
||||||
if (text.length() == 0)
|
if (text.length() == 0)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
byte[] bytes = new byte[4];
|
byte[] bytes = new byte[4];
|
||||||
String[] elements = text.split("\\.", -1);
|
String[] elements = text.split("\\.", -1);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
long l;
|
long l;
|
||||||
int i;
|
int i;
|
||||||
switch (elements.length)
|
switch (elements.length)
|
||||||
{
|
{
|
||||||
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);
|
||||||
bytes[1] = (byte) (int) ((l & 0xFFFFFF) >> 16 & 0xFF);
|
bytes[1] = (byte) (int) ((l & 0xFFFFFF) >> 16 & 0xFF);
|
||||||
bytes[2] = (byte) (int) ((l & 0xFFFF) >> 8 & 0xFF);
|
bytes[2] = (byte) (int) ((l & 0xFFFF) >> 8 & 0xFF);
|
||||||
bytes[3] = (byte) (int) (l & 0xFF);
|
bytes[3] = (byte) (int) (l & 0xFF);
|
||||||
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);
|
||||||
bytes[2] = (byte) (int) ((l & 0xFFFF) >> 8 & 0xFF);
|
bytes[2] = (byte) (int) ((l & 0xFFFF) >> 8 & 0xFF);
|
||||||
bytes[3] = (byte) (int) (l & 0xFF);
|
bytes[3] = (byte) (int) (l & 0xFF);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
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);
|
||||||
bytes[3] = (byte) (int) (l & 0xFF);
|
bytes[3] = (byte) (int) (l & 0xFF);
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
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);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (NumberFormatException e)
|
catch (NumberFormatException e)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return bytes;
|
return bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getHostIp()
|
public static String getHostIp()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return InetAddress.getLocalHost().getHostAddress();
|
return InetAddress.getLocalHost().getHostAddress();
|
||||||
}
|
}
|
||||||
catch (UnknownHostException e)
|
catch (UnknownHostException e)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
return "127.0.0.1";
|
return "127.0.0.1";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getHostName()
|
public static String getHostName()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return InetAddress.getLocalHost().getHostName();
|
return InetAddress.getLocalHost().getHostName();
|
||||||
}
|
}
|
||||||
catch (UnknownHostException e)
|
catch (UnknownHostException e)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
return "未知";
|
return "未知";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,50 +1,50 @@
|
||||||
package com.ruoyi.common.utils;
|
package com.ruoyi.common.utils;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Map通用处理方法
|
* Map通用处理方法
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class MapDataUtil
|
public class MapDataUtil
|
||||||
{
|
{
|
||||||
public static Map<String, Object> convertDataMap(HttpServletRequest request)
|
public static Map<String, Object> convertDataMap(HttpServletRequest request)
|
||||||
{
|
{
|
||||||
Map<String, String[]> properties = request.getParameterMap();
|
Map<String, String[]> properties = request.getParameterMap();
|
||||||
Map<String, Object> returnMap = new HashMap<String, Object>();
|
Map<String, Object> returnMap = new HashMap<String, Object>();
|
||||||
Iterator<?> entries = properties.entrySet().iterator();
|
Iterator<?> entries = properties.entrySet().iterator();
|
||||||
Map.Entry<?, ?> entry;
|
Map.Entry<?, ?> entry;
|
||||||
String name = "";
|
String name = "";
|
||||||
String value = "";
|
String value = "";
|
||||||
while (entries.hasNext())
|
while (entries.hasNext())
|
||||||
{
|
{
|
||||||
entry = (Entry<?, ?>) entries.next();
|
entry = (Entry<?, ?>) entries.next();
|
||||||
name = (String) entry.getKey();
|
name = (String) entry.getKey();
|
||||||
Object valueObj = entry.getValue();
|
Object valueObj = entry.getValue();
|
||||||
if (null == valueObj)
|
if (null == valueObj)
|
||||||
{
|
{
|
||||||
value = "";
|
value = "";
|
||||||
}
|
}
|
||||||
else if (valueObj instanceof String[])
|
else if (valueObj instanceof String[])
|
||||||
{
|
{
|
||||||
String[] values = (String[]) valueObj;
|
String[] values = (String[]) valueObj;
|
||||||
for (int i = 0; i < values.length; i++)
|
for (int i = 0; i < values.length; i++)
|
||||||
{
|
{
|
||||||
value = values[i] + ",";
|
value = values[i] + ",";
|
||||||
}
|
}
|
||||||
value = value.substring(0, value.length() - 1);
|
value = value.substring(0, value.length() - 1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
value = valueObj.toString();
|
value = valueObj.toString();
|
||||||
}
|
}
|
||||||
returnMap.put(name, value);
|
returnMap.put(name, value);
|
||||||
}
|
}
|
||||||
return returnMap;
|
return returnMap;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,26 +1,26 @@
|
||||||
package com.ruoyi.common.utils;
|
package com.ruoyi.common.utils;
|
||||||
|
|
||||||
import org.springframework.context.MessageSource;
|
import org.springframework.context.MessageSource;
|
||||||
import org.springframework.context.i18n.LocaleContextHolder;
|
import org.springframework.context.i18n.LocaleContextHolder;
|
||||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取i18n资源文件
|
* 获取i18n资源文件
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class MessageUtils
|
public class MessageUtils
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* 根据消息键和参数 获取消息 委托给spring messageSource
|
* 根据消息键和参数 获取消息 委托给spring messageSource
|
||||||
*
|
*
|
||||||
* @param code 消息键
|
* @param code 消息键
|
||||||
* @param args 参数
|
* @param args 参数
|
||||||
* @return 获取国际化翻译值
|
* @return 获取国际化翻译值
|
||||||
*/
|
*/
|
||||||
public static String message(String code, Object... args)
|
public static String message(String code, Object... args)
|
||||||
{
|
{
|
||||||
MessageSource messageSource = SpringUtils.getBean(MessageSource.class);
|
MessageSource messageSource = SpringUtils.getBean(MessageSource.class);
|
||||||
return messageSource.getMessage(code, args, LocaleContextHolder.getLocale());
|
return messageSource.getMessage(code, args, LocaleContextHolder.getLocale());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,135 +1,135 @@
|
||||||
package com.ruoyi.common.utils;
|
package com.ruoyi.common.utils;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import javax.servlet.http.HttpSession;
|
import javax.servlet.http.HttpSession;
|
||||||
import org.springframework.web.context.request.RequestAttributes;
|
import org.springframework.web.context.request.RequestAttributes;
|
||||||
import org.springframework.web.context.request.RequestContextHolder;
|
import org.springframework.web.context.request.RequestContextHolder;
|
||||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||||
import com.ruoyi.common.core.text.Convert;
|
import com.ruoyi.common.core.text.Convert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 客户端工具类
|
* 客户端工具类
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class ServletUtils
|
public class ServletUtils
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* 获取String参数
|
* 获取String参数
|
||||||
*/
|
*/
|
||||||
public static String getParameter(String name)
|
public static String getParameter(String name)
|
||||||
{
|
{
|
||||||
return getRequest().getParameter(name);
|
return getRequest().getParameter(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取String参数
|
* 获取String参数
|
||||||
*/
|
*/
|
||||||
public static String getParameter(String name, String defaultValue)
|
public static String getParameter(String name, String defaultValue)
|
||||||
{
|
{
|
||||||
return Convert.toStr(getRequest().getParameter(name), defaultValue);
|
return Convert.toStr(getRequest().getParameter(name), defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取Integer参数
|
* 获取Integer参数
|
||||||
*/
|
*/
|
||||||
public static Integer getParameterToInt(String name)
|
public static Integer getParameterToInt(String name)
|
||||||
{
|
{
|
||||||
return Convert.toInt(getRequest().getParameter(name));
|
return Convert.toInt(getRequest().getParameter(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取Integer参数
|
* 获取Integer参数
|
||||||
*/
|
*/
|
||||||
public static Integer getParameterToInt(String name, Integer defaultValue)
|
public static Integer getParameterToInt(String name, Integer defaultValue)
|
||||||
{
|
{
|
||||||
return Convert.toInt(getRequest().getParameter(name), defaultValue);
|
return Convert.toInt(getRequest().getParameter(name), defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取request
|
* 获取request
|
||||||
*/
|
*/
|
||||||
public static HttpServletRequest getRequest()
|
public static HttpServletRequest getRequest()
|
||||||
{
|
{
|
||||||
return getRequestAttributes().getRequest();
|
return getRequestAttributes().getRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取response
|
* 获取response
|
||||||
*/
|
*/
|
||||||
public static HttpServletResponse getResponse()
|
public static HttpServletResponse getResponse()
|
||||||
{
|
{
|
||||||
return getRequestAttributes().getResponse();
|
return getRequestAttributes().getResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取session
|
* 获取session
|
||||||
*/
|
*/
|
||||||
public static HttpSession getSession()
|
public static HttpSession getSession()
|
||||||
{
|
{
|
||||||
return getRequest().getSession();
|
return getRequest().getSession();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ServletRequestAttributes getRequestAttributes()
|
public static ServletRequestAttributes getRequestAttributes()
|
||||||
{
|
{
|
||||||
RequestAttributes attributes = RequestContextHolder.getRequestAttributes();
|
RequestAttributes attributes = RequestContextHolder.getRequestAttributes();
|
||||||
return (ServletRequestAttributes) attributes;
|
return (ServletRequestAttributes) attributes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 将字符串渲染到客户端
|
* 将字符串渲染到客户端
|
||||||
*
|
*
|
||||||
* @param response 渲染对象
|
* @param response 渲染对象
|
||||||
* @param string 待渲染的字符串
|
* @param string 待渲染的字符串
|
||||||
* @return null
|
* @return null
|
||||||
*/
|
*/
|
||||||
public static String renderString(HttpServletResponse response, String string)
|
public static String renderString(HttpServletResponse response, String string)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
response.setContentType("application/json");
|
response.setContentType("application/json");
|
||||||
response.setCharacterEncoding("utf-8");
|
response.setCharacterEncoding("utf-8");
|
||||||
response.getWriter().print(string);
|
response.getWriter().print(string);
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否是Ajax异步请求
|
* 是否是Ajax异步请求
|
||||||
*
|
*
|
||||||
* @param request
|
* @param request
|
||||||
*/
|
*/
|
||||||
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.indexOf("application/json") != -1)
|
||||||
{
|
{
|
||||||
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.indexOf("XMLHttpRequest") != -1)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
String uri = request.getRequestURI();
|
String uri = request.getRequestURI();
|
||||||
if (StringUtils.inStringIgnoreCase(uri, ".json", ".xml"))
|
if (StringUtils.inStringIgnoreCase(uri, ".json", ".xml"))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
String ajax = request.getParameter("__ajax");
|
String ajax = request.getParameter("__ajax");
|
||||||
if (StringUtils.inStringIgnoreCase(ajax, "json", "xml"))
|
if (StringUtils.inStringIgnoreCase(ajax, "json", "xml"))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,404 +1,404 @@
|
||||||
package com.ruoyi.common.utils;
|
package com.ruoyi.common.utils;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import com.ruoyi.common.core.text.StrFormatter;
|
import com.ruoyi.common.core.text.StrFormatter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字符串工具类
|
* 字符串工具类
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class StringUtils extends org.apache.commons.lang3.StringUtils
|
public class StringUtils extends org.apache.commons.lang3.StringUtils
|
||||||
{
|
{
|
||||||
/** 空字符串 */
|
/** 空字符串 */
|
||||||
private static final String NULLSTR = "";
|
private static final String NULLSTR = "";
|
||||||
|
|
||||||
/** 下划线 */
|
/** 下划线 */
|
||||||
private static final char SEPARATOR = '_';
|
private static final char SEPARATOR = '_';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取参数不为空值
|
* 获取参数不为空值
|
||||||
*
|
*
|
||||||
* @param value defaultValue 要判断的value
|
* @param value defaultValue 要判断的value
|
||||||
* @return value 返回值
|
* @return value 返回值
|
||||||
*/
|
*/
|
||||||
public static <T> T nvl(T value, T defaultValue)
|
public static <T> T nvl(T value, T defaultValue)
|
||||||
{
|
{
|
||||||
return value != null ? value : defaultValue;
|
return value != null ? value : defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* * 判断一个Collection是否为空, 包含List,Set,Queue
|
* * 判断一个Collection是否为空, 包含List,Set,Queue
|
||||||
*
|
*
|
||||||
* @param coll 要判断的Collection
|
* @param coll 要判断的Collection
|
||||||
* @return true:为空 false:非空
|
* @return true:为空 false:非空
|
||||||
*/
|
*/
|
||||||
public static boolean isEmpty(Collection<?> coll)
|
public static boolean isEmpty(Collection<?> coll)
|
||||||
{
|
{
|
||||||
return isNull(coll) || coll.isEmpty();
|
return isNull(coll) || coll.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* * 判断一个Collection是否非空,包含List,Set,Queue
|
* * 判断一个Collection是否非空,包含List,Set,Queue
|
||||||
*
|
*
|
||||||
* @param coll 要判断的Collection
|
* @param coll 要判断的Collection
|
||||||
* @return true:非空 false:空
|
* @return true:非空 false:空
|
||||||
*/
|
*/
|
||||||
public static boolean isNotEmpty(Collection<?> coll)
|
public static boolean isNotEmpty(Collection<?> coll)
|
||||||
{
|
{
|
||||||
return !isEmpty(coll);
|
return !isEmpty(coll);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* * 判断一个对象数组是否为空
|
* * 判断一个对象数组是否为空
|
||||||
*
|
*
|
||||||
* @param objects 要判断的对象数组
|
* @param objects 要判断的对象数组
|
||||||
** @return true:为空 false:非空
|
** @return true:为空 false:非空
|
||||||
*/
|
*/
|
||||||
public static boolean isEmpty(Object[] objects)
|
public static boolean isEmpty(Object[] objects)
|
||||||
{
|
{
|
||||||
return isNull(objects) || (objects.length == 0);
|
return isNull(objects) || (objects.length == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* * 判断一个对象数组是否非空
|
* * 判断一个对象数组是否非空
|
||||||
*
|
*
|
||||||
* @param objects 要判断的对象数组
|
* @param objects 要判断的对象数组
|
||||||
* @return true:非空 false:空
|
* @return true:非空 false:空
|
||||||
*/
|
*/
|
||||||
public static boolean isNotEmpty(Object[] objects)
|
public static boolean isNotEmpty(Object[] objects)
|
||||||
{
|
{
|
||||||
return !isEmpty(objects);
|
return !isEmpty(objects);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* * 判断一个Map是否为空
|
* * 判断一个Map是否为空
|
||||||
*
|
*
|
||||||
* @param map 要判断的Map
|
* @param map 要判断的Map
|
||||||
* @return true:为空 false:非空
|
* @return true:为空 false:非空
|
||||||
*/
|
*/
|
||||||
public static boolean isEmpty(Map<?, ?> map)
|
public static boolean isEmpty(Map<?, ?> map)
|
||||||
{
|
{
|
||||||
return isNull(map) || map.isEmpty();
|
return isNull(map) || map.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* * 判断一个Map是否为空
|
* * 判断一个Map是否为空
|
||||||
*
|
*
|
||||||
* @param map 要判断的Map
|
* @param map 要判断的Map
|
||||||
* @return true:非空 false:空
|
* @return true:非空 false:空
|
||||||
*/
|
*/
|
||||||
public static boolean isNotEmpty(Map<?, ?> map)
|
public static boolean isNotEmpty(Map<?, ?> map)
|
||||||
{
|
{
|
||||||
return !isEmpty(map);
|
return !isEmpty(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* * 判断一个字符串是否为空串
|
* * 判断一个字符串是否为空串
|
||||||
*
|
*
|
||||||
* @param str String
|
* @param str String
|
||||||
* @return true:为空 false:非空
|
* @return true:为空 false:非空
|
||||||
*/
|
*/
|
||||||
public static boolean isEmpty(String str)
|
public static boolean isEmpty(String str)
|
||||||
{
|
{
|
||||||
return isNull(str) || NULLSTR.equals(str.trim());
|
return isNull(str) || NULLSTR.equals(str.trim());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* * 判断一个字符串是否为非空串
|
* * 判断一个字符串是否为非空串
|
||||||
*
|
*
|
||||||
* @param str String
|
* @param str String
|
||||||
* @return true:非空串 false:空串
|
* @return true:非空串 false:空串
|
||||||
*/
|
*/
|
||||||
public static boolean isNotEmpty(String str)
|
public static boolean isNotEmpty(String str)
|
||||||
{
|
{
|
||||||
return !isEmpty(str);
|
return !isEmpty(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* * 判断一个对象是否为空
|
* * 判断一个对象是否为空
|
||||||
*
|
*
|
||||||
* @param object Object
|
* @param object Object
|
||||||
* @return true:为空 false:非空
|
* @return true:为空 false:非空
|
||||||
*/
|
*/
|
||||||
public static boolean isNull(Object object)
|
public static boolean isNull(Object object)
|
||||||
{
|
{
|
||||||
return object == null;
|
return object == null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* * 判断一个对象是否非空
|
* * 判断一个对象是否非空
|
||||||
*
|
*
|
||||||
* @param object Object
|
* @param object Object
|
||||||
* @return true:非空 false:空
|
* @return true:非空 false:空
|
||||||
*/
|
*/
|
||||||
public static boolean isNotNull(Object object)
|
public static boolean isNotNull(Object object)
|
||||||
{
|
{
|
||||||
return !isNull(object);
|
return !isNull(object);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* * 判断一个对象是否是数组类型(Java基本型别的数组)
|
* * 判断一个对象是否是数组类型(Java基本型别的数组)
|
||||||
*
|
*
|
||||||
* @param object 对象
|
* @param object 对象
|
||||||
* @return true:是数组 false:不是数组
|
* @return true:是数组 false:不是数组
|
||||||
*/
|
*/
|
||||||
public static boolean isArray(Object object)
|
public static boolean isArray(Object object)
|
||||||
{
|
{
|
||||||
return isNotNull(object) && object.getClass().isArray();
|
return isNotNull(object) && object.getClass().isArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 去空格
|
* 去空格
|
||||||
*/
|
*/
|
||||||
public static String trim(String str)
|
public static String trim(String str)
|
||||||
{
|
{
|
||||||
return (str == null ? "" : str.trim());
|
return (str == null ? "" : str.trim());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 截取字符串
|
* 截取字符串
|
||||||
*
|
*
|
||||||
* @param str 字符串
|
* @param str 字符串
|
||||||
* @param start 开始
|
* @param start 开始
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public static String substring(final String str, int start)
|
public static String substring(final String str, int start)
|
||||||
{
|
{
|
||||||
if (str == null)
|
if (str == null)
|
||||||
{
|
{
|
||||||
return NULLSTR;
|
return NULLSTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (start < 0)
|
if (start < 0)
|
||||||
{
|
{
|
||||||
start = str.length() + start;
|
start = str.length() + start;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (start < 0)
|
if (start < 0)
|
||||||
{
|
{
|
||||||
start = 0;
|
start = 0;
|
||||||
}
|
}
|
||||||
if (start > str.length())
|
if (start > str.length())
|
||||||
{
|
{
|
||||||
return NULLSTR;
|
return NULLSTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
return str.substring(start);
|
return str.substring(start);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 截取字符串
|
* 截取字符串
|
||||||
*
|
*
|
||||||
* @param str 字符串
|
* @param str 字符串
|
||||||
* @param start 开始
|
* @param start 开始
|
||||||
* @param end 结束
|
* @param end 结束
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public static String substring(final String str, int start, int end)
|
public static String substring(final String str, int start, int end)
|
||||||
{
|
{
|
||||||
if (str == null)
|
if (str == null)
|
||||||
{
|
{
|
||||||
return NULLSTR;
|
return NULLSTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (end < 0)
|
if (end < 0)
|
||||||
{
|
{
|
||||||
end = str.length() + end;
|
end = str.length() + end;
|
||||||
}
|
}
|
||||||
if (start < 0)
|
if (start < 0)
|
||||||
{
|
{
|
||||||
start = str.length() + start;
|
start = str.length() + start;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (end > str.length())
|
if (end > str.length())
|
||||||
{
|
{
|
||||||
end = str.length();
|
end = str.length();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (start > end)
|
if (start > end)
|
||||||
{
|
{
|
||||||
return NULLSTR;
|
return NULLSTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (start < 0)
|
if (start < 0)
|
||||||
{
|
{
|
||||||
start = 0;
|
start = 0;
|
||||||
}
|
}
|
||||||
if (end < 0)
|
if (end < 0)
|
||||||
{
|
{
|
||||||
end = 0;
|
end = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return str.substring(start, end);
|
return str.substring(start, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 格式化文本, {} 表示占位符<br>
|
* 格式化文本, {} 表示占位符<br>
|
||||||
* 此方法只是简单将占位符 {} 按照顺序替换为参数<br>
|
* 此方法只是简单将占位符 {} 按照顺序替换为参数<br>
|
||||||
* 如果想输出 {} 使用 \\转义 { 即可,如果想输出 {} 之前的 \ 使用双转义符 \\\\ 即可<br>
|
* 如果想输出 {} 使用 \\转义 { 即可,如果想输出 {} 之前的 \ 使用双转义符 \\\\ 即可<br>
|
||||||
* 例:<br>
|
* 例:<br>
|
||||||
* 通常使用:format("this is {} for {}", "a", "b") -> this is a for b<br>
|
* 通常使用:format("this is {} for {}", "a", "b") -> this is a for b<br>
|
||||||
* 转义{}: format("this is \\{} for {}", "a", "b") -> this is \{} for a<br>
|
* 转义{}: format("this is \\{} for {}", "a", "b") -> this is \{} for a<br>
|
||||||
* 转义\: format("this is \\\\{} for {}", "a", "b") -> this is \a for b<br>
|
* 转义\: format("this is \\\\{} for {}", "a", "b") -> this is \a for b<br>
|
||||||
*
|
*
|
||||||
* @param template 文本模板,被替换的部分用 {} 表示
|
* @param template 文本模板,被替换的部分用 {} 表示
|
||||||
* @param params 参数值
|
* @param params 参数值
|
||||||
* @return 格式化后的文本
|
* @return 格式化后的文本
|
||||||
*/
|
*/
|
||||||
public static String format(String template, Object... params)
|
public static String format(String template, Object... params)
|
||||||
{
|
{
|
||||||
if (isEmpty(params) || isEmpty(template))
|
if (isEmpty(params) || isEmpty(template))
|
||||||
{
|
{
|
||||||
return template;
|
return template;
|
||||||
}
|
}
|
||||||
return StrFormatter.format(template, params);
|
return StrFormatter.format(template, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 下划线转驼峰命名
|
* 下划线转驼峰命名
|
||||||
*/
|
*/
|
||||||
public static String toUnderScoreCase(String str)
|
public static String toUnderScoreCase(String str)
|
||||||
{
|
{
|
||||||
if (str == null)
|
if (str == null)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
// 前置字符是否大写
|
// 前置字符是否大写
|
||||||
boolean preCharIsUpperCase = true;
|
boolean preCharIsUpperCase = true;
|
||||||
// 当前字符是否大写
|
// 当前字符是否大写
|
||||||
boolean curreCharIsUpperCase = true;
|
boolean curreCharIsUpperCase = true;
|
||||||
// 下一字符是否大写
|
// 下一字符是否大写
|
||||||
boolean nexteCharIsUpperCase = true;
|
boolean nexteCharIsUpperCase = true;
|
||||||
for (int i = 0; i < str.length(); i++)
|
for (int i = 0; i < str.length(); i++)
|
||||||
{
|
{
|
||||||
char c = str.charAt(i);
|
char c = str.charAt(i);
|
||||||
if (i > 0)
|
if (i > 0)
|
||||||
{
|
{
|
||||||
preCharIsUpperCase = Character.isUpperCase(str.charAt(i - 1));
|
preCharIsUpperCase = Character.isUpperCase(str.charAt(i - 1));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
preCharIsUpperCase = false;
|
preCharIsUpperCase = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
curreCharIsUpperCase = Character.isUpperCase(c);
|
curreCharIsUpperCase = Character.isUpperCase(c);
|
||||||
|
|
||||||
if (i < (str.length() - 1))
|
if (i < (str.length() - 1))
|
||||||
{
|
{
|
||||||
nexteCharIsUpperCase = Character.isUpperCase(str.charAt(i + 1));
|
nexteCharIsUpperCase = Character.isUpperCase(str.charAt(i + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (preCharIsUpperCase && curreCharIsUpperCase && !nexteCharIsUpperCase)
|
if (preCharIsUpperCase && curreCharIsUpperCase && !nexteCharIsUpperCase)
|
||||||
{
|
{
|
||||||
sb.append(SEPARATOR);
|
sb.append(SEPARATOR);
|
||||||
}
|
}
|
||||||
else if ((i != 0 && !preCharIsUpperCase) && curreCharIsUpperCase)
|
else if ((i != 0 && !preCharIsUpperCase) && curreCharIsUpperCase)
|
||||||
{
|
{
|
||||||
sb.append(SEPARATOR);
|
sb.append(SEPARATOR);
|
||||||
}
|
}
|
||||||
sb.append(Character.toLowerCase(c));
|
sb.append(Character.toLowerCase(c));
|
||||||
}
|
}
|
||||||
|
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否包含字符串
|
* 是否包含字符串
|
||||||
*
|
*
|
||||||
* @param str 验证字符串
|
* @param str 验证字符串
|
||||||
* @param strs 字符串组
|
* @param strs 字符串组
|
||||||
* @return 包含返回true
|
* @return 包含返回true
|
||||||
*/
|
*/
|
||||||
public static boolean inStringIgnoreCase(String str, String... strs)
|
public static boolean inStringIgnoreCase(String str, String... strs)
|
||||||
{
|
{
|
||||||
if (str != null && strs != null)
|
if (str != null && strs != null)
|
||||||
{
|
{
|
||||||
for (String s : strs)
|
for (String s : strs)
|
||||||
{
|
{
|
||||||
if (str.equalsIgnoreCase(trim(s)))
|
if (str.equalsIgnoreCase(trim(s)))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 将下划线大写方式命名的字符串转换为驼峰式。如果转换前的下划线大写方式命名的字符串为空,则返回空字符串。 例如:HELLO_WORLD->HelloWorld
|
* 将下划线大写方式命名的字符串转换为驼峰式。如果转换前的下划线大写方式命名的字符串为空,则返回空字符串。 例如:HELLO_WORLD->HelloWorld
|
||||||
*
|
*
|
||||||
* @param name 转换前的下划线大写方式命名的字符串
|
* @param name 转换前的下划线大写方式命名的字符串
|
||||||
* @return 转换后的驼峰式命名的字符串
|
* @return 转换后的驼峰式命名的字符串
|
||||||
*/
|
*/
|
||||||
public static String convertToCamelCase(String name)
|
public static String convertToCamelCase(String name)
|
||||||
{
|
{
|
||||||
StringBuilder result = new StringBuilder();
|
StringBuilder result = new StringBuilder();
|
||||||
// 快速检查
|
// 快速检查
|
||||||
if (name == null || name.isEmpty())
|
if (name == null || name.isEmpty())
|
||||||
{
|
{
|
||||||
// 没必要转换
|
// 没必要转换
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
else if (!name.contains("_"))
|
else if (!name.contains("_"))
|
||||||
{
|
{
|
||||||
// 不含下划线,仅将首字母大写
|
// 不含下划线,仅将首字母大写
|
||||||
return name.substring(0, 1).toUpperCase() + name.substring(1);
|
return name.substring(0, 1).toUpperCase() + name.substring(1);
|
||||||
}
|
}
|
||||||
// 用下划线将原始字符串分割
|
// 用下划线将原始字符串分割
|
||||||
String[] camels = name.split("_");
|
String[] camels = name.split("_");
|
||||||
for (String camel : camels)
|
for (String camel : camels)
|
||||||
{
|
{
|
||||||
// 跳过原始字符串中开头、结尾的下换线或双重下划线
|
// 跳过原始字符串中开头、结尾的下换线或双重下划线
|
||||||
if (camel.isEmpty())
|
if (camel.isEmpty())
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// 首字母大写
|
// 首字母大写
|
||||||
result.append(camel.substring(0, 1).toUpperCase());
|
result.append(camel.substring(0, 1).toUpperCase());
|
||||||
result.append(camel.substring(1).toLowerCase());
|
result.append(camel.substring(1).toLowerCase());
|
||||||
}
|
}
|
||||||
return result.toString();
|
return result.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 驼峰式命名法 例如:user_name->userName
|
* 驼峰式命名法 例如:user_name->userName
|
||||||
*/
|
*/
|
||||||
public static String toCamelCase(String s)
|
public static String toCamelCase(String s)
|
||||||
{
|
{
|
||||||
if (s == null)
|
if (s == null)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
s = s.toLowerCase();
|
s = s.toLowerCase();
|
||||||
StringBuilder sb = new StringBuilder(s.length());
|
StringBuilder sb = new StringBuilder(s.length());
|
||||||
boolean upperCase = false;
|
boolean upperCase = false;
|
||||||
for (int i = 0; i < s.length(); i++)
|
for (int i = 0; i < s.length(); i++)
|
||||||
{
|
{
|
||||||
char c = s.charAt(i);
|
char c = s.charAt(i);
|
||||||
|
|
||||||
if (c == SEPARATOR)
|
if (c == SEPARATOR)
|
||||||
{
|
{
|
||||||
upperCase = true;
|
upperCase = true;
|
||||||
}
|
}
|
||||||
else if (upperCase)
|
else if (upperCase)
|
||||||
{
|
{
|
||||||
sb.append(Character.toUpperCase(c));
|
sb.append(Character.toUpperCase(c));
|
||||||
upperCase = false;
|
upperCase = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sb.append(c);
|
sb.append(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static <T> T cast(Object obj)
|
public static <T> T cast(Object obj)
|
||||||
{
|
{
|
||||||
return (T) obj;
|
return (T) obj;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,87 +1,87 @@
|
||||||
package com.ruoyi.common.utils;
|
package com.ruoyi.common.utils;
|
||||||
|
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import org.yaml.snakeyaml.DumperOptions;
|
import org.yaml.snakeyaml.DumperOptions;
|
||||||
import org.yaml.snakeyaml.Yaml;
|
import org.yaml.snakeyaml.Yaml;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 配置处理工具类
|
* 配置处理工具类
|
||||||
*
|
*
|
||||||
* @author yml
|
* @author yml
|
||||||
*/
|
*/
|
||||||
public class YamlUtil
|
public class YamlUtil
|
||||||
{
|
{
|
||||||
public static Map<?, ?> loadYaml(String fileName) throws FileNotFoundException
|
public static Map<?, ?> loadYaml(String fileName) throws FileNotFoundException
|
||||||
{
|
{
|
||||||
InputStream in = YamlUtil.class.getClassLoader().getResourceAsStream(fileName);
|
InputStream in = YamlUtil.class.getClassLoader().getResourceAsStream(fileName);
|
||||||
return StringUtils.isNotEmpty(fileName) ? (LinkedHashMap<?, ?>) new Yaml().load(in) : null;
|
return StringUtils.isNotEmpty(fileName) ? (LinkedHashMap<?, ?>) new Yaml().load(in) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void dumpYaml(String fileName, Map<?, ?> map) throws IOException
|
public static void dumpYaml(String fileName, Map<?, ?> map) throws IOException
|
||||||
{
|
{
|
||||||
if (StringUtils.isNotEmpty(fileName))
|
if (StringUtils.isNotEmpty(fileName))
|
||||||
{
|
{
|
||||||
FileWriter fileWriter = new FileWriter(YamlUtil.class.getResource(fileName).getFile());
|
FileWriter fileWriter = new FileWriter(YamlUtil.class.getResource(fileName).getFile());
|
||||||
DumperOptions options = new DumperOptions();
|
DumperOptions options = new DumperOptions();
|
||||||
options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
|
options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
|
||||||
Yaml yaml = new Yaml(options);
|
Yaml yaml = new Yaml(options);
|
||||||
yaml.dump(map, fileWriter);
|
yaml.dump(map, fileWriter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Object getProperty(Map<?, ?> map, Object qualifiedKey)
|
public static Object getProperty(Map<?, ?> map, Object qualifiedKey)
|
||||||
{
|
{
|
||||||
if (map != null && !map.isEmpty() && qualifiedKey != null)
|
if (map != null && !map.isEmpty() && qualifiedKey != null)
|
||||||
{
|
{
|
||||||
String input = String.valueOf(qualifiedKey);
|
String input = String.valueOf(qualifiedKey);
|
||||||
if (!"".equals(input))
|
if (!"".equals(input))
|
||||||
{
|
{
|
||||||
if (input.contains("."))
|
if (input.contains("."))
|
||||||
{
|
{
|
||||||
int index = input.indexOf(".");
|
int index = input.indexOf(".");
|
||||||
String left = input.substring(0, index);
|
String left = input.substring(0, index);
|
||||||
String right = input.substring(index + 1, input.length());
|
String right = input.substring(index + 1, input.length());
|
||||||
return getProperty((Map<?, ?>) map.get(left), right);
|
return getProperty((Map<?, ?>) map.get(left), right);
|
||||||
}
|
}
|
||||||
else if (map.containsKey(input))
|
else if (map.containsKey(input))
|
||||||
{
|
{
|
||||||
return map.get(input);
|
return map.get(input);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static void setProperty(Map<?, ?> map, Object qualifiedKey, Object value)
|
public static void setProperty(Map<?, ?> map, Object qualifiedKey, Object value)
|
||||||
{
|
{
|
||||||
if (map != null && !map.isEmpty() && qualifiedKey != null)
|
if (map != null && !map.isEmpty() && qualifiedKey != null)
|
||||||
{
|
{
|
||||||
String input = String.valueOf(qualifiedKey);
|
String input = String.valueOf(qualifiedKey);
|
||||||
if (!input.equals(""))
|
if (!input.equals(""))
|
||||||
{
|
{
|
||||||
if (input.contains("."))
|
if (input.contains("."))
|
||||||
{
|
{
|
||||||
int index = input.indexOf(".");
|
int index = input.indexOf(".");
|
||||||
String left = input.substring(0, index);
|
String left = input.substring(0, index);
|
||||||
String right = input.substring(index + 1, input.length());
|
String right = input.substring(index + 1, input.length());
|
||||||
setProperty((Map<?, ?>) map.get(left), right, value);
|
setProperty((Map<?, ?>) map.get(left), right, value);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
((Map<Object, Object>) map).put(qualifiedKey, value);
|
((Map<Object, Object>) map).put(qualifiedKey, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,110 +1,110 @@
|
||||||
package com.ruoyi.common.utils.bean;
|
package com.ruoyi.common.utils.bean;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bean 工具类
|
* Bean 工具类
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class BeanUtils extends org.springframework.beans.BeanUtils
|
public class BeanUtils extends org.springframework.beans.BeanUtils
|
||||||
{
|
{
|
||||||
/** Bean方法名中属性名开始的下标 */
|
/** Bean方法名中属性名开始的下标 */
|
||||||
private static final int BEAN_METHOD_PROP_INDEX = 3;
|
private static final int BEAN_METHOD_PROP_INDEX = 3;
|
||||||
|
|
||||||
/** * 匹配getter方法的正则表达式 */
|
/** * 匹配getter方法的正则表达式 */
|
||||||
private static final Pattern GET_PATTERN = Pattern.compile("get(\\p{javaUpperCase}\\w*)");
|
private static final Pattern GET_PATTERN = Pattern.compile("get(\\p{javaUpperCase}\\w*)");
|
||||||
|
|
||||||
/** * 匹配setter方法的正则表达式 */
|
/** * 匹配setter方法的正则表达式 */
|
||||||
private static final Pattern SET_PATTERN = Pattern.compile("set(\\p{javaUpperCase}\\w*)");
|
private static final Pattern SET_PATTERN = Pattern.compile("set(\\p{javaUpperCase}\\w*)");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bean属性复制工具方法。
|
* Bean属性复制工具方法。
|
||||||
*
|
*
|
||||||
* @param dest 目标对象
|
* @param dest 目标对象
|
||||||
* @param src 源对象
|
* @param src 源对象
|
||||||
*/
|
*/
|
||||||
public static void copyBeanProp(Object dest, Object src)
|
public static void copyBeanProp(Object dest, Object src)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
copyProperties(src, dest);
|
copyProperties(src, dest);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取对象的setter方法。
|
* 获取对象的setter方法。
|
||||||
*
|
*
|
||||||
* @param obj 对象
|
* @param obj 对象
|
||||||
* @return 对象的setter方法列表
|
* @return 对象的setter方法列表
|
||||||
*/
|
*/
|
||||||
public static List<Method> getSetterMethods(Object obj)
|
public static List<Method> getSetterMethods(Object obj)
|
||||||
{
|
{
|
||||||
// setter方法列表
|
// setter方法列表
|
||||||
List<Method> setterMethods = new ArrayList<Method>();
|
List<Method> setterMethods = new ArrayList<Method>();
|
||||||
|
|
||||||
// 获取所有方法
|
// 获取所有方法
|
||||||
Method[] methods = obj.getClass().getMethods();
|
Method[] methods = obj.getClass().getMethods();
|
||||||
|
|
||||||
// 查找setter方法
|
// 查找setter方法
|
||||||
|
|
||||||
for (Method method : methods)
|
for (Method method : methods)
|
||||||
{
|
{
|
||||||
Matcher m = SET_PATTERN.matcher(method.getName());
|
Matcher m = SET_PATTERN.matcher(method.getName());
|
||||||
if (m.matches() && (method.getParameterTypes().length == 1))
|
if (m.matches() && (method.getParameterTypes().length == 1))
|
||||||
{
|
{
|
||||||
setterMethods.add(method);
|
setterMethods.add(method);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 返回setter方法列表
|
// 返回setter方法列表
|
||||||
return setterMethods;
|
return setterMethods;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取对象的getter方法。
|
* 获取对象的getter方法。
|
||||||
*
|
*
|
||||||
* @param obj 对象
|
* @param obj 对象
|
||||||
* @return 对象的getter方法列表
|
* @return 对象的getter方法列表
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public static List<Method> getGetterMethods(Object obj)
|
public static List<Method> getGetterMethods(Object obj)
|
||||||
{
|
{
|
||||||
// getter方法列表
|
// getter方法列表
|
||||||
List<Method> getterMethods = new ArrayList<Method>();
|
List<Method> getterMethods = new ArrayList<Method>();
|
||||||
// 获取所有方法
|
// 获取所有方法
|
||||||
Method[] methods = obj.getClass().getMethods();
|
Method[] methods = obj.getClass().getMethods();
|
||||||
// 查找getter方法
|
// 查找getter方法
|
||||||
for (Method method : methods)
|
for (Method method : methods)
|
||||||
{
|
{
|
||||||
Matcher m = GET_PATTERN.matcher(method.getName());
|
Matcher m = GET_PATTERN.matcher(method.getName());
|
||||||
if (m.matches() && (method.getParameterTypes().length == 0))
|
if (m.matches() && (method.getParameterTypes().length == 0))
|
||||||
{
|
{
|
||||||
getterMethods.add(method);
|
getterMethods.add(method);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 返回getter方法列表
|
// 返回getter方法列表
|
||||||
return getterMethods;
|
return getterMethods;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查Bean方法名中的属性名是否相等。<br>
|
* 检查Bean方法名中的属性名是否相等。<br>
|
||||||
* 如getName()和setName()属性名一样,getName()和setAge()属性名不一样。
|
* 如getName()和setName()属性名一样,getName()和setAge()属性名不一样。
|
||||||
*
|
*
|
||||||
* @param m1 方法名1
|
* @param m1 方法名1
|
||||||
* @param m2 方法名2
|
* @param m2 方法名2
|
||||||
* @return 属性名一样返回true,否则返回false
|
* @return 属性名一样返回true,否则返回false
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public static boolean isMethodPropEquals(String m1, String m2)
|
public static boolean isMethodPropEquals(String m1, String m2)
|
||||||
{
|
{
|
||||||
return m1.substring(BEAN_METHOD_PROP_INDEX).equals(m2.substring(BEAN_METHOD_PROP_INDEX));
|
return m1.substring(BEAN_METHOD_PROP_INDEX).equals(m2.substring(BEAN_METHOD_PROP_INDEX));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,243 +1,243 @@
|
||||||
package com.ruoyi.common.utils.file;
|
package com.ruoyi.common.utils.file;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
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.Global;
|
import com.ruoyi.common.config.Global;
|
||||||
import com.ruoyi.common.constant.Constants;
|
import com.ruoyi.common.constant.Constants;
|
||||||
import com.ruoyi.common.exception.file.FileNameLengthLimitExceededException;
|
import com.ruoyi.common.exception.file.FileNameLengthLimitExceededException;
|
||||||
import com.ruoyi.common.exception.file.FileSizeLimitExceededException;
|
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.security.Md5Utils;
|
import com.ruoyi.common.utils.security.Md5Utils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文件上传工具类
|
* 文件上传工具类
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class FileUploadUtils
|
public class FileUploadUtils
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* 默认大小 50M
|
* 默认大小 50M
|
||||||
*/
|
*/
|
||||||
public static final long DEFAULT_MAX_SIZE = 50 * 1024 * 1024;
|
public static final long DEFAULT_MAX_SIZE = 50 * 1024 * 1024;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 默认的文件名最大长度 100
|
* 默认的文件名最大长度 100
|
||||||
*/
|
*/
|
||||||
public static final int DEFAULT_FILE_NAME_LENGTH = 100;
|
public static final int DEFAULT_FILE_NAME_LENGTH = 100;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 默认上传的地址
|
* 默认上传的地址
|
||||||
*/
|
*/
|
||||||
private static String defaultBaseDir = Global.getProfile();
|
private static String defaultBaseDir = Global.getProfile();
|
||||||
|
|
||||||
private static int counter = 0;
|
private static int counter = 0;
|
||||||
|
|
||||||
public static void setDefaultBaseDir(String defaultBaseDir)
|
public static void setDefaultBaseDir(String defaultBaseDir)
|
||||||
{
|
{
|
||||||
FileUploadUtils.defaultBaseDir = defaultBaseDir;
|
FileUploadUtils.defaultBaseDir = defaultBaseDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getDefaultBaseDir()
|
public static String getDefaultBaseDir()
|
||||||
{
|
{
|
||||||
return defaultBaseDir;
|
return defaultBaseDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 以默认配置进行文件上传
|
* 以默认配置进行文件上传
|
||||||
*
|
*
|
||||||
* @param file 上传的文件
|
* @param file 上传的文件
|
||||||
* @return 文件名称
|
* @return 文件名称
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public static final String upload(MultipartFile file) throws IOException
|
public static final String upload(MultipartFile file) throws IOException
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return upload(getDefaultBaseDir(), file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION);
|
return upload(getDefaultBaseDir(), file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
throw new IOException(e.getMessage(), e);
|
throw new IOException(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据文件路径上传
|
* 根据文件路径上传
|
||||||
*
|
*
|
||||||
* @param baseDir 相对应用的基目录
|
* @param baseDir 相对应用的基目录
|
||||||
* @param file 上传的文件
|
* @param file 上传的文件
|
||||||
* @return 文件名称
|
* @return 文件名称
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public static final String upload(String baseDir, MultipartFile file) throws IOException
|
public static final String upload(String baseDir, MultipartFile file) throws IOException
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return upload(baseDir, file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION);
|
return upload(baseDir, file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
throw new IOException(e.getMessage(), e);
|
throw new IOException(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文件上传
|
* 文件上传
|
||||||
*
|
*
|
||||||
* @param baseDir 相对应用的基目录
|
* @param baseDir 相对应用的基目录
|
||||||
* @param file 上传的文件
|
* @param file 上传的文件
|
||||||
* @param allowedExtension 上传文件类型
|
* @param allowedExtension 上传文件类型
|
||||||
* @return 返回上传成功的文件名
|
* @return 返回上传成功的文件名
|
||||||
* @throws FileSizeLimitExceededException 如果超出最大大小
|
* @throws FileSizeLimitExceededException 如果超出最大大小
|
||||||
* @throws FileNameLengthLimitExceededException 文件名太长
|
* @throws FileNameLengthLimitExceededException 文件名太长
|
||||||
* @throws IOException 比如读写文件出错时
|
* @throws IOException 比如读写文件出错时
|
||||||
* @throws InvalidExtensionException 文件校验异常
|
* @throws InvalidExtensionException 文件校验异常
|
||||||
*/
|
*/
|
||||||
public static final String upload(String baseDir, MultipartFile file, String[] allowedExtension)
|
public static final String upload(String baseDir, MultipartFile file, String[] allowedExtension)
|
||||||
throws FileSizeLimitExceededException, IOException, FileNameLengthLimitExceededException,
|
throws FileSizeLimitExceededException, IOException, FileNameLengthLimitExceededException,
|
||||||
InvalidExtensionException
|
InvalidExtensionException
|
||||||
{
|
{
|
||||||
int fileNamelength = file.getOriginalFilename().length();
|
int fileNamelength = 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
assertAllowed(file, allowedExtension);
|
assertAllowed(file, allowedExtension);
|
||||||
|
|
||||||
String fileName = extractFilename(file);
|
String fileName = extractFilename(file);
|
||||||
|
|
||||||
File desc = getAbsoluteFile(baseDir, fileName);
|
File desc = getAbsoluteFile(baseDir, fileName);
|
||||||
file.transferTo(desc);
|
file.transferTo(desc);
|
||||||
String pathFileName = getPathFileName(baseDir, fileName);
|
String pathFileName = getPathFileName(baseDir, fileName);
|
||||||
return pathFileName;
|
return pathFileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 编码文件名
|
* 编码文件名
|
||||||
*/
|
*/
|
||||||
public static final String extractFilename(MultipartFile file)
|
public static final String extractFilename(MultipartFile file)
|
||||||
{
|
{
|
||||||
String fileName = file.getOriginalFilename();
|
String fileName = file.getOriginalFilename();
|
||||||
String extension = getExtension(file);
|
String extension = getExtension(file);
|
||||||
fileName = DateUtils.datePath() + "/" + encodingFilename(fileName) + "." + extension;
|
fileName = DateUtils.datePath() + "/" + encodingFilename(fileName) + "." + extension;
|
||||||
return fileName;
|
return fileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final File getAbsoluteFile(String uploadDir, String fileName) throws IOException
|
private static final File getAbsoluteFile(String uploadDir, String fileName) throws IOException
|
||||||
{
|
{
|
||||||
File desc = new File(uploadDir + File.separator + fileName);
|
File desc = new File(uploadDir + File.separator + fileName);
|
||||||
|
|
||||||
if (!desc.getParentFile().exists())
|
if (!desc.getParentFile().exists())
|
||||||
{
|
{
|
||||||
desc.getParentFile().mkdirs();
|
desc.getParentFile().mkdirs();
|
||||||
}
|
}
|
||||||
if (!desc.exists())
|
if (!desc.exists())
|
||||||
{
|
{
|
||||||
desc.createNewFile();
|
desc.createNewFile();
|
||||||
}
|
}
|
||||||
return desc;
|
return desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String getPathFileName(String uploadDir, String fileName) throws IOException
|
private static final String getPathFileName(String uploadDir, String fileName) throws IOException
|
||||||
{
|
{
|
||||||
int dirLastIndex = Global.getProfile().length() + 1;
|
int dirLastIndex = Global.getProfile().length() + 1;
|
||||||
String currentDir = StringUtils.substring(uploadDir, dirLastIndex);
|
String currentDir = StringUtils.substring(uploadDir, dirLastIndex);
|
||||||
String pathFileName = Constants.RESOURCE_PREFIX + "/" + currentDir + "/" + fileName;
|
String pathFileName = Constants.RESOURCE_PREFIX + "/" + currentDir + "/" + fileName;
|
||||||
return pathFileName;
|
return pathFileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 编码文件名
|
* 编码文件名
|
||||||
*/
|
*/
|
||||||
private static final String encodingFilename(String fileName)
|
private static final String encodingFilename(String fileName)
|
||||||
{
|
{
|
||||||
fileName = fileName.replace("_", " ");
|
fileName = fileName.replace("_", " ");
|
||||||
fileName = Md5Utils.hash(fileName + System.nanoTime() + counter++);
|
fileName = Md5Utils.hash(fileName + System.nanoTime() + counter++);
|
||||||
return fileName;
|
return fileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文件大小校验
|
* 文件大小校验
|
||||||
*
|
*
|
||||||
* @param file 上传的文件
|
* @param file 上传的文件
|
||||||
* @return
|
* @return
|
||||||
* @throws FileSizeLimitExceededException 如果超出最大大小
|
* @throws FileSizeLimitExceededException 如果超出最大大小
|
||||||
* @throws InvalidExtensionException
|
* @throws InvalidExtensionException
|
||||||
*/
|
*/
|
||||||
public static final void assertAllowed(MultipartFile file, String[] allowedExtension)
|
public static final void assertAllowed(MultipartFile file, String[] allowedExtension)
|
||||||
throws FileSizeLimitExceededException, InvalidExtensionException
|
throws FileSizeLimitExceededException, InvalidExtensionException
|
||||||
{
|
{
|
||||||
long size = file.getSize();
|
long size = file.getSize();
|
||||||
if (DEFAULT_MAX_SIZE != -1 && size > DEFAULT_MAX_SIZE)
|
if (DEFAULT_MAX_SIZE != -1 && size > DEFAULT_MAX_SIZE)
|
||||||
{
|
{
|
||||||
throw new FileSizeLimitExceededException(DEFAULT_MAX_SIZE / 1024 / 1024);
|
throw new FileSizeLimitExceededException(DEFAULT_MAX_SIZE / 1024 / 1024);
|
||||||
}
|
}
|
||||||
|
|
||||||
String fileName = file.getOriginalFilename();
|
String fileName = file.getOriginalFilename();
|
||||||
String extension = getExtension(file);
|
String extension = getExtension(file);
|
||||||
if (allowedExtension != null && !isAllowedExtension(extension, allowedExtension))
|
if (allowedExtension != null && !isAllowedExtension(extension, allowedExtension))
|
||||||
{
|
{
|
||||||
if (allowedExtension == MimeTypeUtils.IMAGE_EXTENSION)
|
if (allowedExtension == MimeTypeUtils.IMAGE_EXTENSION)
|
||||||
{
|
{
|
||||||
throw new InvalidExtensionException.InvalidImageExtensionException(allowedExtension, extension,
|
throw new InvalidExtensionException.InvalidImageExtensionException(allowedExtension, extension,
|
||||||
fileName);
|
fileName);
|
||||||
}
|
}
|
||||||
else if (allowedExtension == MimeTypeUtils.FLASH_EXTENSION)
|
else if (allowedExtension == MimeTypeUtils.FLASH_EXTENSION)
|
||||||
{
|
{
|
||||||
throw new InvalidExtensionException.InvalidFlashExtensionException(allowedExtension, extension,
|
throw new InvalidExtensionException.InvalidFlashExtensionException(allowedExtension, extension,
|
||||||
fileName);
|
fileName);
|
||||||
}
|
}
|
||||||
else if (allowedExtension == MimeTypeUtils.MEDIA_EXTENSION)
|
else if (allowedExtension == MimeTypeUtils.MEDIA_EXTENSION)
|
||||||
{
|
{
|
||||||
throw new InvalidExtensionException.InvalidMediaExtensionException(allowedExtension, extension,
|
throw new InvalidExtensionException.InvalidMediaExtensionException(allowedExtension, extension,
|
||||||
fileName);
|
fileName);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new InvalidExtensionException(allowedExtension, extension, fileName);
|
throw new InvalidExtensionException(allowedExtension, extension, fileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 判断MIME类型是否是允许的MIME类型
|
* 判断MIME类型是否是允许的MIME类型
|
||||||
*
|
*
|
||||||
* @param extension
|
* @param extension
|
||||||
* @param allowedExtension
|
* @param allowedExtension
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static final boolean isAllowedExtension(String extension, String[] allowedExtension)
|
public static final boolean isAllowedExtension(String extension, String[] allowedExtension)
|
||||||
{
|
{
|
||||||
for (String str : allowedExtension)
|
for (String str : allowedExtension)
|
||||||
{
|
{
|
||||||
if (str.equalsIgnoreCase(extension))
|
if (str.equalsIgnoreCase(extension))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取文件名的后缀
|
* 获取文件名的后缀
|
||||||
*
|
*
|
||||||
* @param file 表单文件
|
* @param file 表单文件
|
||||||
* @return 后缀名
|
* @return 后缀名
|
||||||
*/
|
*/
|
||||||
public static final String getExtension(MultipartFile file)
|
public static final String getExtension(MultipartFile file)
|
||||||
{
|
{
|
||||||
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(file.getContentType());
|
||||||
}
|
}
|
||||||
return extension;
|
return extension;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,142 +1,142 @@
|
||||||
package com.ruoyi.common.utils.file;
|
package com.ruoyi.common.utils.file;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文件处理工具类
|
* 文件处理工具类
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class FileUtils
|
public class FileUtils
|
||||||
{
|
{
|
||||||
public static String FILENAME_PATTERN = "[a-zA-Z0-9_\\-\\|\\.\\u4e00-\\u9fa5]+";
|
public static String FILENAME_PATTERN = "[a-zA-Z0-9_\\-\\|\\.\\u4e00-\\u9fa5]+";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 输出指定文件的byte数组
|
* 输出指定文件的byte数组
|
||||||
*
|
*
|
||||||
* @param filePath 文件路径
|
* @param filePath 文件路径
|
||||||
* @param os 输出流
|
* @param os 输出流
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static void writeBytes(String filePath, OutputStream os) throws IOException
|
public static void writeBytes(String filePath, OutputStream os) throws IOException
|
||||||
{
|
{
|
||||||
FileInputStream fis = null;
|
FileInputStream fis = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
File file = new File(filePath);
|
File file = new File(filePath);
|
||||||
if (!file.exists())
|
if (!file.exists())
|
||||||
{
|
{
|
||||||
throw new FileNotFoundException(filePath);
|
throw new FileNotFoundException(filePath);
|
||||||
}
|
}
|
||||||
fis = new FileInputStream(file);
|
fis = new FileInputStream(file);
|
||||||
byte[] b = new byte[1024];
|
byte[] b = new byte[1024];
|
||||||
int length;
|
int length;
|
||||||
while ((length = fis.read(b)) > 0)
|
while ((length = fis.read(b)) > 0)
|
||||||
{
|
{
|
||||||
os.write(b, 0, length);
|
os.write(b, 0, length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
if (os != null)
|
if (os != null)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
os.close();
|
os.close();
|
||||||
}
|
}
|
||||||
catch (IOException e1)
|
catch (IOException e1)
|
||||||
{
|
{
|
||||||
e1.printStackTrace();
|
e1.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (fis != null)
|
if (fis != null)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
fis.close();
|
fis.close();
|
||||||
}
|
}
|
||||||
catch (IOException e1)
|
catch (IOException e1)
|
||||||
{
|
{
|
||||||
e1.printStackTrace();
|
e1.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除文件
|
* 删除文件
|
||||||
*
|
*
|
||||||
* @param filePath 文件
|
* @param filePath 文件
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static boolean deleteFile(String filePath)
|
public static boolean deleteFile(String filePath)
|
||||||
{
|
{
|
||||||
boolean flag = false;
|
boolean flag = false;
|
||||||
File file = new File(filePath);
|
File file = new File(filePath);
|
||||||
// 路径为文件且不为空则进行删除
|
// 路径为文件且不为空则进行删除
|
||||||
if (file.isFile() && file.exists())
|
if (file.isFile() && file.exists())
|
||||||
{
|
{
|
||||||
file.delete();
|
file.delete();
|
||||||
flag = true;
|
flag = true;
|
||||||
}
|
}
|
||||||
return flag;
|
return flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文件名称验证
|
* 文件名称验证
|
||||||
*
|
*
|
||||||
* @param filename 文件名称
|
* @param filename 文件名称
|
||||||
* @return true 正常 false 非法
|
* @return true 正常 false 非法
|
||||||
*/
|
*/
|
||||||
public static boolean isValidFilename(String filename)
|
public static boolean isValidFilename(String filename)
|
||||||
{
|
{
|
||||||
return filename.matches(FILENAME_PATTERN);
|
return filename.matches(FILENAME_PATTERN);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 下载文件名重新编码
|
* 下载文件名重新编码
|
||||||
*
|
*
|
||||||
* @param request 请求对象
|
* @param request 请求对象
|
||||||
* @param fileName 文件名
|
* @param fileName 文件名
|
||||||
* @return 编码后的文件名
|
* @return 编码后的文件名
|
||||||
*/
|
*/
|
||||||
public static String setFileDownloadHeader(HttpServletRequest request, String fileName)
|
public static String setFileDownloadHeader(HttpServletRequest request, String fileName)
|
||||||
throws UnsupportedEncodingException
|
throws UnsupportedEncodingException
|
||||||
{
|
{
|
||||||
final String agent = request.getHeader("USER-AGENT");
|
final String agent = request.getHeader("USER-AGENT");
|
||||||
String filename = fileName;
|
String filename = fileName;
|
||||||
if (agent.contains("MSIE"))
|
if (agent.contains("MSIE"))
|
||||||
{
|
{
|
||||||
// IE浏览器
|
// IE浏览器
|
||||||
filename = URLEncoder.encode(filename, "utf-8");
|
filename = URLEncoder.encode(filename, "utf-8");
|
||||||
filename = filename.replace("+", " ");
|
filename = filename.replace("+", " ");
|
||||||
}
|
}
|
||||||
else if (agent.contains("Firefox"))
|
else if (agent.contains("Firefox"))
|
||||||
{
|
{
|
||||||
// 火狐浏览器
|
// 火狐浏览器
|
||||||
filename = new String(fileName.getBytes(), "ISO8859-1");
|
filename = new String(fileName.getBytes(), "ISO8859-1");
|
||||||
}
|
}
|
||||||
else if (agent.contains("Chrome"))
|
else if (agent.contains("Chrome"))
|
||||||
{
|
{
|
||||||
// google浏览器
|
// google浏览器
|
||||||
filename = URLEncoder.encode(filename, "utf-8");
|
filename = URLEncoder.encode(filename, "utf-8");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// 其它浏览器
|
// 其它浏览器
|
||||||
filename = URLEncoder.encode(filename, "utf-8");
|
filename = URLEncoder.encode(filename, "utf-8");
|
||||||
}
|
}
|
||||||
return filename;
|
return filename;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,262 +1,262 @@
|
||||||
package com.ruoyi.common.utils.http;
|
package com.ruoyi.common.utils.http;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
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.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.net.ConnectException;
|
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.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;
|
||||||
import javax.net.ssl.SSLContext;
|
import javax.net.ssl.SSLContext;
|
||||||
import javax.net.ssl.SSLSession;
|
import javax.net.ssl.SSLSession;
|
||||||
import javax.net.ssl.TrustManager;
|
import javax.net.ssl.TrustManager;
|
||||||
import javax.net.ssl.X509TrustManager;
|
import javax.net.ssl.X509TrustManager;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import com.ruoyi.common.constant.Constants;
|
import com.ruoyi.common.constant.Constants;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通用http发送方法
|
* 通用http发送方法
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class HttpUtils
|
public class HttpUtils
|
||||||
{
|
{
|
||||||
private static final Logger log = LoggerFactory.getLogger(HttpUtils.class);
|
private static final Logger log = LoggerFactory.getLogger(HttpUtils.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 向指定 URL 发送GET方法的请求
|
* 向指定 URL 发送GET方法的请求
|
||||||
*
|
*
|
||||||
* @param url 发送请求的 URL
|
* @param url 发送请求的 URL
|
||||||
* @param param 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。
|
* @param param 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。
|
||||||
* @return 所代表远程资源的响应结果
|
* @return 所代表远程资源的响应结果
|
||||||
*/
|
*/
|
||||||
public static String sendGet(String url, String param)
|
public static String sendGet(String url, String param)
|
||||||
{
|
{
|
||||||
return sendGet(url, param, Constants.UTF8);
|
return sendGet(url, param, Constants.UTF8);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 向指定 URL 发送GET方法的请求
|
* 向指定 URL 发送GET方法的请求
|
||||||
*
|
*
|
||||||
* @param url 发送请求的 URL
|
* @param url 发送请求的 URL
|
||||||
* @param param 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。
|
* @param param 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。
|
||||||
* @param contentType 编码类型
|
* @param contentType 编码类型
|
||||||
* @return 所代表远程资源的响应结果
|
* @return 所代表远程资源的响应结果
|
||||||
*/
|
*/
|
||||||
public static String sendGet(String url, String param, String contentType)
|
public static String sendGet(String url, String param, String contentType)
|
||||||
{
|
{
|
||||||
StringBuilder result = new StringBuilder();
|
StringBuilder result = new StringBuilder();
|
||||||
BufferedReader in = null;
|
BufferedReader in = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
String urlNameString = url + "?" + param;
|
String urlNameString = url + "?" + param;
|
||||||
log.info("sendGet - {}", urlNameString);
|
log.info("sendGet - {}", urlNameString);
|
||||||
URL realUrl = new URL(urlNameString);
|
URL realUrl = new URL(urlNameString);
|
||||||
URLConnection connection = realUrl.openConnection();
|
URLConnection connection = realUrl.openConnection();
|
||||||
connection.setRequestProperty("accept", "*/*");
|
connection.setRequestProperty("accept", "*/*");
|
||||||
connection.setRequestProperty("connection", "Keep-Alive");
|
connection.setRequestProperty("connection", "Keep-Alive");
|
||||||
connection.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
|
connection.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
|
||||||
connection.connect();
|
connection.connect();
|
||||||
in = new BufferedReader(new InputStreamReader(connection.getInputStream(), contentType));
|
in = new BufferedReader(new InputStreamReader(connection.getInputStream(), contentType));
|
||||||
String line;
|
String line;
|
||||||
while ((line = in.readLine()) != null)
|
while ((line = in.readLine()) != null)
|
||||||
{
|
{
|
||||||
result.append(line);
|
result.append(line);
|
||||||
}
|
}
|
||||||
log.info("recv - {}", result);
|
log.info("recv - {}", result);
|
||||||
}
|
}
|
||||||
catch (ConnectException e)
|
catch (ConnectException e)
|
||||||
{
|
{
|
||||||
log.error("调用HttpUtils.sendGet ConnectException, url=" + url + ",param=" + param, e);
|
log.error("调用HttpUtils.sendGet ConnectException, url=" + url + ",param=" + param, e);
|
||||||
}
|
}
|
||||||
catch (SocketTimeoutException e)
|
catch (SocketTimeoutException e)
|
||||||
{
|
{
|
||||||
log.error("调用HttpUtils.sendGet SocketTimeoutException, url=" + url + ",param=" + param, e);
|
log.error("调用HttpUtils.sendGet SocketTimeoutException, url=" + url + ",param=" + param, e);
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
log.error("调用HttpUtils.sendGet IOException, url=" + url + ",param=" + param, e);
|
log.error("调用HttpUtils.sendGet IOException, url=" + url + ",param=" + param, e);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
log.error("调用HttpsUtil.sendGet Exception, url=" + url + ",param=" + param, e);
|
log.error("调用HttpsUtil.sendGet Exception, url=" + url + ",param=" + param, e);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (in != null)
|
if (in != null)
|
||||||
{
|
{
|
||||||
in.close();
|
in.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
log.error("调用in.close Exception, url=" + url + ",param=" + param, ex);
|
log.error("调用in.close Exception, url=" + url + ",param=" + param, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result.toString();
|
return result.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 向指定 URL 发送POST方法的请求
|
* 向指定 URL 发送POST方法的请求
|
||||||
*
|
*
|
||||||
* @param url 发送请求的 URL
|
* @param url 发送请求的 URL
|
||||||
* @param param 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。
|
* @param param 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。
|
||||||
* @return 所代表远程资源的响应结果
|
* @return 所代表远程资源的响应结果
|
||||||
*/
|
*/
|
||||||
public static String sendPost(String url, String param)
|
public static String sendPost(String url, String param)
|
||||||
{
|
{
|
||||||
PrintWriter out = null;
|
PrintWriter out = null;
|
||||||
BufferedReader in = null;
|
BufferedReader in = null;
|
||||||
StringBuilder result = new StringBuilder();
|
StringBuilder result = new StringBuilder();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
String urlNameString = url;
|
String urlNameString = url;
|
||||||
log.info("sendPost - {}", urlNameString);
|
log.info("sendPost - {}", urlNameString);
|
||||||
URL realUrl = new URL(urlNameString);
|
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");
|
||||||
conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
|
conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
|
||||||
conn.setRequestProperty("Accept-Charset", "utf-8");
|
conn.setRequestProperty("Accept-Charset", "utf-8");
|
||||||
conn.setRequestProperty("contentType", "utf-8");
|
conn.setRequestProperty("contentType", "utf-8");
|
||||||
conn.setDoOutput(true);
|
conn.setDoOutput(true);
|
||||||
conn.setDoInput(true);
|
conn.setDoInput(true);
|
||||||
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(), "utf-8"));
|
||||||
String line;
|
String line;
|
||||||
while ((line = in.readLine()) != null)
|
while ((line = in.readLine()) != null)
|
||||||
{
|
{
|
||||||
result.append(line);
|
result.append(line);
|
||||||
}
|
}
|
||||||
log.info("recv - {}", result);
|
log.info("recv - {}", result);
|
||||||
}
|
}
|
||||||
catch (ConnectException e)
|
catch (ConnectException e)
|
||||||
{
|
{
|
||||||
log.error("调用HttpUtils.sendPost ConnectException, url=" + url + ",param=" + param, e);
|
log.error("调用HttpUtils.sendPost ConnectException, url=" + url + ",param=" + param, e);
|
||||||
}
|
}
|
||||||
catch (SocketTimeoutException e)
|
catch (SocketTimeoutException e)
|
||||||
{
|
{
|
||||||
log.error("调用HttpUtils.sendPost SocketTimeoutException, url=" + url + ",param=" + param, e);
|
log.error("调用HttpUtils.sendPost SocketTimeoutException, url=" + url + ",param=" + param, e);
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
log.error("调用HttpUtils.sendPost IOException, url=" + url + ",param=" + param, e);
|
log.error("调用HttpUtils.sendPost IOException, url=" + url + ",param=" + param, e);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
log.error("调用HttpsUtil.sendPost Exception, url=" + url + ",param=" + param, e);
|
log.error("调用HttpsUtil.sendPost Exception, url=" + url + ",param=" + param, e);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (out != null)
|
if (out != null)
|
||||||
{
|
{
|
||||||
out.close();
|
out.close();
|
||||||
}
|
}
|
||||||
if (in != null)
|
if (in != null)
|
||||||
{
|
{
|
||||||
in.close();
|
in.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (IOException ex)
|
catch (IOException ex)
|
||||||
{
|
{
|
||||||
log.error("调用in.close Exception, url=" + url + ",param=" + param, ex);
|
log.error("调用in.close Exception, url=" + url + ",param=" + param, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result.toString();
|
return result.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String sendSSLPost(String url, String param)
|
public static String sendSSLPost(String url, String param)
|
||||||
{
|
{
|
||||||
StringBuilder result = new StringBuilder();
|
StringBuilder result = new StringBuilder();
|
||||||
String urlNameString = url + "?" + param;
|
String urlNameString = url + "?" + param;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
log.info("sendSSLPost - {}", urlNameString);
|
log.info("sendSSLPost - {}", urlNameString);
|
||||||
SSLContext sc = SSLContext.getInstance("SSL");
|
SSLContext sc = SSLContext.getInstance("SSL");
|
||||||
sc.init(null, new TrustManager[] { new TrustAnyTrustManager() }, new java.security.SecureRandom());
|
sc.init(null, new TrustManager[] { new TrustAnyTrustManager() }, new java.security.SecureRandom());
|
||||||
URL console = new URL(urlNameString);
|
URL console = new URL(urlNameString);
|
||||||
HttpsURLConnection conn = (HttpsURLConnection) console.openConnection();
|
HttpsURLConnection conn = (HttpsURLConnection) console.openConnection();
|
||||||
conn.setRequestProperty("accept", "*/*");
|
conn.setRequestProperty("accept", "*/*");
|
||||||
conn.setRequestProperty("connection", "Keep-Alive");
|
conn.setRequestProperty("connection", "Keep-Alive");
|
||||||
conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
|
conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
|
||||||
conn.setRequestProperty("Accept-Charset", "utf-8");
|
conn.setRequestProperty("Accept-Charset", "utf-8");
|
||||||
conn.setRequestProperty("contentType", "utf-8");
|
conn.setRequestProperty("contentType", "utf-8");
|
||||||
conn.setDoOutput(true);
|
conn.setDoOutput(true);
|
||||||
conn.setDoInput(true);
|
conn.setDoInput(true);
|
||||||
|
|
||||||
conn.setSSLSocketFactory(sc.getSocketFactory());
|
conn.setSSLSocketFactory(sc.getSocketFactory());
|
||||||
conn.setHostnameVerifier(new TrustAnyHostnameVerifier());
|
conn.setHostnameVerifier(new TrustAnyHostnameVerifier());
|
||||||
conn.connect();
|
conn.connect();
|
||||||
InputStream is = conn.getInputStream();
|
InputStream is = conn.getInputStream();
|
||||||
BufferedReader br = new BufferedReader(new InputStreamReader(is));
|
BufferedReader br = new BufferedReader(new InputStreamReader(is));
|
||||||
String ret = "";
|
String ret = "";
|
||||||
while ((ret = br.readLine()) != null)
|
while ((ret = br.readLine()) != null)
|
||||||
{
|
{
|
||||||
if (ret != null && !ret.trim().equals(""))
|
if (ret != null && !ret.trim().equals(""))
|
||||||
{
|
{
|
||||||
result.append(new String(ret.getBytes("ISO-8859-1"), "utf-8"));
|
result.append(new String(ret.getBytes("ISO-8859-1"), "utf-8"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log.info("recv - {}", result);
|
log.info("recv - {}", result);
|
||||||
conn.disconnect();
|
conn.disconnect();
|
||||||
br.close();
|
br.close();
|
||||||
}
|
}
|
||||||
catch (ConnectException e)
|
catch (ConnectException e)
|
||||||
{
|
{
|
||||||
log.error("调用HttpUtils.sendSSLPost ConnectException, url=" + url + ",param=" + param, e);
|
log.error("调用HttpUtils.sendSSLPost ConnectException, url=" + url + ",param=" + param, e);
|
||||||
}
|
}
|
||||||
catch (SocketTimeoutException e)
|
catch (SocketTimeoutException e)
|
||||||
{
|
{
|
||||||
log.error("调用HttpUtils.sendSSLPost SocketTimeoutException, url=" + url + ",param=" + param, e);
|
log.error("调用HttpUtils.sendSSLPost SocketTimeoutException, url=" + url + ",param=" + param, e);
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
log.error("调用HttpUtils.sendSSLPost IOException, url=" + url + ",param=" + param, e);
|
log.error("调用HttpUtils.sendSSLPost IOException, url=" + url + ",param=" + param, e);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
log.error("调用HttpsUtil.sendSSLPost Exception, url=" + url + ",param=" + param, e);
|
log.error("调用HttpsUtil.sendSSLPost Exception, url=" + url + ",param=" + param, e);
|
||||||
}
|
}
|
||||||
return result.toString();
|
return result.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class TrustAnyTrustManager implements X509TrustManager
|
private static class TrustAnyTrustManager implements X509TrustManager
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void checkClientTrusted(X509Certificate[] chain, String authType)
|
public void checkClientTrusted(X509Certificate[] chain, String authType)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void checkServerTrusted(X509Certificate[] chain, String authType)
|
public void checkServerTrusted(X509Certificate[] chain, String authType)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public X509Certificate[] getAcceptedIssuers()
|
public X509Certificate[] getAcceptedIssuers()
|
||||||
{
|
{
|
||||||
return new X509Certificate[] {};
|
return new X509Certificate[] {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class TrustAnyHostnameVerifier implements HostnameVerifier
|
private static class TrustAnyHostnameVerifier implements HostnameVerifier
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public boolean verify(String hostname, SSLSession session)
|
public boolean verify(String hostname, SSLSession session)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,66 +1,66 @@
|
||||||
package com.ruoyi.common.utils.security;
|
package com.ruoyi.common.utils.security;
|
||||||
|
|
||||||
import java.security.MessageDigest;
|
import java.security.MessageDigest;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Md5加密方法
|
* Md5加密方法
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class Md5Utils
|
public class Md5Utils
|
||||||
{
|
{
|
||||||
private static final Logger log = LoggerFactory.getLogger(Md5Utils.class);
|
private static final Logger log = LoggerFactory.getLogger(Md5Utils.class);
|
||||||
|
|
||||||
private static byte[] md5(String s)
|
private static byte[] md5(String s)
|
||||||
{
|
{
|
||||||
MessageDigest algorithm;
|
MessageDigest algorithm;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
algorithm = MessageDigest.getInstance("MD5");
|
algorithm = MessageDigest.getInstance("MD5");
|
||||||
algorithm.reset();
|
algorithm.reset();
|
||||||
algorithm.update(s.getBytes("UTF-8"));
|
algorithm.update(s.getBytes("UTF-8"));
|
||||||
byte[] messageDigest = algorithm.digest();
|
byte[] messageDigest = algorithm.digest();
|
||||||
return messageDigest;
|
return messageDigest;
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
log.error("MD5 Error...", e);
|
log.error("MD5 Error...", e);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String toHex(byte hash[])
|
private static final String toHex(byte hash[])
|
||||||
{
|
{
|
||||||
if (hash == null)
|
if (hash == null)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
StringBuffer buf = new StringBuffer(hash.length * 2);
|
StringBuffer buf = new StringBuffer(hash.length * 2);
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < hash.length; i++)
|
for (i = 0; i < hash.length; i++)
|
||||||
{
|
{
|
||||||
if ((hash[i] & 0xff) < 0x10)
|
if ((hash[i] & 0xff) < 0x10)
|
||||||
{
|
{
|
||||||
buf.append("0");
|
buf.append("0");
|
||||||
}
|
}
|
||||||
buf.append(Long.toString(hash[i] & 0xff, 16));
|
buf.append(Long.toString(hash[i] & 0xff, 16));
|
||||||
}
|
}
|
||||||
return buf.toString();
|
return buf.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String hash(String s)
|
public static String hash(String s)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return new String(toHex(md5(s)).getBytes("UTF-8"), "UTF-8");
|
return new String(toHex(md5(s)).getBytes("UTF-8"), "UTF-8");
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
log.error("not supported charset...{}", e);
|
log.error("not supported charset...{}", e);
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,118 +1,118 @@
|
||||||
package com.ruoyi.common.utils.security;
|
package com.ruoyi.common.utils.security;
|
||||||
|
|
||||||
import java.beans.BeanInfo;
|
import java.beans.BeanInfo;
|
||||||
import java.beans.Introspector;
|
import java.beans.Introspector;
|
||||||
import java.beans.PropertyDescriptor;
|
import java.beans.PropertyDescriptor;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.shiro.SecurityUtils;
|
import org.apache.shiro.SecurityUtils;
|
||||||
import org.apache.shiro.subject.Subject;
|
import org.apache.shiro.subject.Subject;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import com.ruoyi.common.constant.PermissionConstants;
|
import com.ruoyi.common.constant.PermissionConstants;
|
||||||
import com.ruoyi.common.utils.MessageUtils;
|
import com.ruoyi.common.utils.MessageUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* permission 工具类
|
* permission 工具类
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class PermissionUtils
|
public class PermissionUtils
|
||||||
{
|
{
|
||||||
private static final Logger log = LoggerFactory.getLogger(PermissionUtils.class);
|
private static final Logger log = LoggerFactory.getLogger(PermissionUtils.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查看数据的权限
|
* 查看数据的权限
|
||||||
*/
|
*/
|
||||||
public static final String VIEW_PERMISSION = "no.view.permission";
|
public static final String VIEW_PERMISSION = "no.view.permission";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建数据的权限
|
* 创建数据的权限
|
||||||
*/
|
*/
|
||||||
public static final String CREATE_PERMISSION = "no.create.permission";
|
public static final String CREATE_PERMISSION = "no.create.permission";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改数据的权限
|
* 修改数据的权限
|
||||||
*/
|
*/
|
||||||
public static final String UPDATE_PERMISSION = "no.update.permission";
|
public static final String UPDATE_PERMISSION = "no.update.permission";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除数据的权限
|
* 删除数据的权限
|
||||||
*/
|
*/
|
||||||
public static final String DELETE_PERMISSION = "no.delete.permission";
|
public static final String DELETE_PERMISSION = "no.delete.permission";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出数据的权限
|
* 导出数据的权限
|
||||||
*/
|
*/
|
||||||
public static final String EXPORT_PERMISSION = "no.export.permission";
|
public static final String EXPORT_PERMISSION = "no.export.permission";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 其他数据的权限
|
* 其他数据的权限
|
||||||
*/
|
*/
|
||||||
public static final String PERMISSION = "no.permission";
|
public static final String PERMISSION = "no.permission";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 权限错误消息提醒
|
* 权限错误消息提醒
|
||||||
*
|
*
|
||||||
* @param permissionsStr 错误信息
|
* @param permissionsStr 错误信息
|
||||||
* @return 提示信息
|
* @return 提示信息
|
||||||
*/
|
*/
|
||||||
public static String getMsg(String permissionsStr)
|
public static String getMsg(String permissionsStr)
|
||||||
{
|
{
|
||||||
String permission = StringUtils.substringBetween(permissionsStr, "[", "]");
|
String permission = StringUtils.substringBetween(permissionsStr, "[", "]");
|
||||||
String msg = MessageUtils.message(PERMISSION, permission);
|
String msg = MessageUtils.message(PERMISSION, permission);
|
||||||
if (StringUtils.endsWithIgnoreCase(permission, PermissionConstants.ADD_PERMISSION))
|
if (StringUtils.endsWithIgnoreCase(permission, PermissionConstants.ADD_PERMISSION))
|
||||||
{
|
{
|
||||||
msg = MessageUtils.message(CREATE_PERMISSION, permission);
|
msg = MessageUtils.message(CREATE_PERMISSION, permission);
|
||||||
}
|
}
|
||||||
else if (StringUtils.endsWithIgnoreCase(permission, PermissionConstants.EDIT_PERMISSION))
|
else if (StringUtils.endsWithIgnoreCase(permission, PermissionConstants.EDIT_PERMISSION))
|
||||||
{
|
{
|
||||||
msg = MessageUtils.message(UPDATE_PERMISSION, permission);
|
msg = MessageUtils.message(UPDATE_PERMISSION, permission);
|
||||||
}
|
}
|
||||||
else if (StringUtils.endsWithIgnoreCase(permission, PermissionConstants.REMOVE_PERMISSION))
|
else if (StringUtils.endsWithIgnoreCase(permission, PermissionConstants.REMOVE_PERMISSION))
|
||||||
{
|
{
|
||||||
msg = MessageUtils.message(DELETE_PERMISSION, permission);
|
msg = MessageUtils.message(DELETE_PERMISSION, permission);
|
||||||
}
|
}
|
||||||
else if (StringUtils.endsWithIgnoreCase(permission, PermissionConstants.EXPORT_PERMISSION))
|
else if (StringUtils.endsWithIgnoreCase(permission, PermissionConstants.EXPORT_PERMISSION))
|
||||||
{
|
{
|
||||||
msg = MessageUtils.message(EXPORT_PERMISSION, permission);
|
msg = MessageUtils.message(EXPORT_PERMISSION, permission);
|
||||||
}
|
}
|
||||||
else if (StringUtils.endsWithAny(permission,
|
else if (StringUtils.endsWithAny(permission,
|
||||||
new String[] { PermissionConstants.VIEW_PERMISSION, PermissionConstants.LIST_PERMISSION }))
|
new String[] { PermissionConstants.VIEW_PERMISSION, PermissionConstants.LIST_PERMISSION }))
|
||||||
{
|
{
|
||||||
msg = MessageUtils.message(VIEW_PERMISSION, permission);
|
msg = MessageUtils.message(VIEW_PERMISSION, permission);
|
||||||
}
|
}
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 返回用户属性值
|
* 返回用户属性值
|
||||||
*
|
*
|
||||||
* @param property 属性名称
|
* @param property 属性名称
|
||||||
* @return 用户属性值
|
* @return 用户属性值
|
||||||
*/
|
*/
|
||||||
public static Object getPrincipalProperty(String property)
|
public static Object getPrincipalProperty(String property)
|
||||||
{
|
{
|
||||||
Subject subject = SecurityUtils.getSubject();
|
Subject subject = SecurityUtils.getSubject();
|
||||||
if (subject != null)
|
if (subject != null)
|
||||||
{
|
{
|
||||||
Object principal = subject.getPrincipal();
|
Object principal = subject.getPrincipal();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
BeanInfo bi = Introspector.getBeanInfo(principal.getClass());
|
BeanInfo bi = Introspector.getBeanInfo(principal.getClass());
|
||||||
for (PropertyDescriptor pd : bi.getPropertyDescriptors())
|
for (PropertyDescriptor pd : bi.getPropertyDescriptors())
|
||||||
{
|
{
|
||||||
if (pd.getName().equals(property) == true)
|
if (pd.getName().equals(property) == true)
|
||||||
{
|
{
|
||||||
return pd.getReadMethod().invoke(principal, (Object[]) null);
|
return pd.getReadMethod().invoke(principal, (Object[]) null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
log.error("Error reading property [{}] from principal of type [{}]", property,
|
log.error("Error reading property [{}] from principal of type [{}]", property,
|
||||||
principal.getClass().getName());
|
principal.getClass().getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue