Pre Merge pull request !147 from Quieter/master

This commit is contained in:
Quieter 2020-09-14 21:41:44 +08:00 committed by Gitee
commit 36802706d2
319 changed files with 32022 additions and 32560 deletions

36
pom.xml
View File

@ -18,7 +18,6 @@
<java.version>1.8</java.version>
<shiro.version>1.6.0</shiro.version>
<thymeleaf.extras.shiro.version>2.0.0</thymeleaf.extras.shiro.version>
<mybatis.boot.version>1.3.2</mybatis.boot.version>
<druid.version>1.1.22</druid.version>
<bitwalker.version>1.19</bitwalker.version>
<kaptcha.version>2.3.2</kaptcha.version>
@ -30,6 +29,7 @@
<commons.fileupload.version>1.3.3</commons.fileupload.version>
<poi.version>3.17</poi.version>
<velocity.version>1.7</velocity.version>
<querydsl.version>4.2.1</querydsl.version>
</properties>
<!-- 依赖声明 -->
@ -202,6 +202,12 @@
<version>${ruoyi.version}</version>
</dependency>
<dependency>
<groupId>com.querydsl</groupId>
<artifactId>querydsl-jpa</artifactId>
<version>${querydsl.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
@ -215,13 +221,31 @@
</modules>
<packaging>pom</packaging>
<dependencies>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.mysema.maven</groupId>
<artifactId>apt-maven-plugin</artifactId>
<version>1.1.3</version>
<executions>
<execution>
<goals>
<goal>process</goal>
</goals>
<configuration>
<outputDirectory>target/generated-sources/java</outputDirectory>
<processor>com.querydsl.apt.jpa.JPAAnnotationProcessor</processor>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.querydsl</groupId>
<artifactId>querydsl-apt</artifactId>
<version>${querydsl.version}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>

View File

@ -79,6 +79,17 @@
<artifactId>ruoyi-generator</artifactId>
</dependency>
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.datatype/jackson-datatype-hibernate5 -->
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-hibernate5</artifactId>
<version>2.10.1</version>
</dependency>
</dependencies>
<build>

View File

@ -1,8 +1,12 @@
package com.ruoyi;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
/**
* 启动程序
@ -10,12 +14,22 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
* @author ruoyi
*/
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
public class RuoYiApplication
{
public static void main(String[] args)
{
public class RuoYiApplication extends SpringBootServletInitializer {
public static void main(String[] args) {
// System.setProperty("spring.devtools.restart.enabled", "false");
SpringApplication.run(RuoYiApplication.class, args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(RuoYiApplication.class);
}
@Bean
public CommandLineRunner startupCommandLineRunner() {
return new CommandLineRunner() {
@Override
public void run(String... args) throws Exception {
System.out.println("(♥◠‿◠)ノ゙ 若依启动成功 ლ(´ڡ`ლ)゙ \n" +
" .-------. ____ __ \n" +
" | _ _ \\ \\ \\ / / \n" +
@ -27,4 +41,6 @@ public class RuoYiApplication
" | | \\ / \\ / \n" +
" ''-' `'-' `-..-' ");
}
};
}
}

View File

@ -1,18 +0,0 @@
package com.ruoyi;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
/**
* web容器中进行部署
*
* @author ruoyi
*/
public class RuoYiServletInitializer extends SpringBootServletInitializer
{
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application)
{
return application.sources(RuoYiApplication.class);
}
}

View File

@ -2,6 +2,7 @@ package com.ruoyi.web.controller.common;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -25,8 +26,7 @@ import com.ruoyi.common.utils.file.FileUtils;
* @author ruoyi
*/
@Controller
public class CommonController
{
public class CommonController {
private static final Logger log = LoggerFactory.getLogger(CommonController.class);
@Autowired
@ -39,12 +39,9 @@ public class CommonController
* @param delete 是否删除
*/
@GetMapping("common/download")
public void fileDownload(String fileName, Boolean delete, HttpServletResponse response, HttpServletRequest request)
{
try
{
if (!FileUtils.isValidFilename(fileName))
{
public void fileDownload(String fileName, Boolean delete, HttpServletResponse response, HttpServletRequest request) {
try {
if (!FileUtils.isValidFilename(fileName)) {
throw new Exception(StringUtils.format("文件名称({})非法,不允许下载。 ", fileName));
}
String realFileName = System.currentTimeMillis() + fileName.substring(fileName.indexOf("_") + 1);
@ -54,13 +51,10 @@ public class CommonController
FileUtils.setAttachmentResponseHeader(response, realFileName);
FileUtils.writeBytes(filePath, response.getOutputStream());
if (delete)
{
if (delete) {
FileUtils.deleteFile(filePath);
}
}
catch (Exception e)
{
} catch (Exception e) {
log.error("下载文件失败", e);
}
}
@ -70,10 +64,8 @@ public class CommonController
*/
@PostMapping("/common/upload")
@ResponseBody
public AjaxResult uploadFile(MultipartFile file) throws Exception
{
try
{
public AjaxResult uploadFile(MultipartFile file) throws Exception {
try {
// 上传文件路径
String filePath = Global.getUploadPath();
// 上传并返回新文件名称
@ -83,9 +75,7 @@ public class CommonController
ajax.put("fileName", fileName);
ajax.put("url", url);
return ajax;
}
catch (Exception e)
{
} catch (Exception e) {
return AjaxResult.error(e.getMessage());
}
}
@ -95,8 +85,7 @@ public class CommonController
*/
@GetMapping("/common/download/resource")
public void resourceDownload(String resource, HttpServletRequest request, HttpServletResponse response)
throws Exception
{
throws Exception {
// 本地资源路径
String localPath = Global.getProfile();
// 数据库资源地址

View File

@ -11,16 +11,14 @@ import org.springframework.web.bind.annotation.RequestMapping;
*/
@Controller
@RequestMapping("/demo/modal")
public class DemoDialogController
{
public class DemoDialogController {
private String prefix = "demo/modal";
/**
* 模态窗口
*/
@GetMapping("/dialog")
public String dialog()
{
public String dialog() {
return prefix + "/dialog";
}
@ -28,8 +26,7 @@ public class DemoDialogController
* 弹层组件
*/
@GetMapping("/layer")
public String layer()
{
public String layer() {
return prefix + "/layer";
}
@ -37,8 +34,7 @@ public class DemoDialogController
* 表单
*/
@GetMapping("/form")
public String form()
{
public String form() {
return prefix + "/form";
}
@ -46,8 +42,7 @@ public class DemoDialogController
* 表格
*/
@GetMapping("/table")
public String table()
{
public String table() {
return prefix + "/table";
}
@ -55,8 +50,7 @@ public class DemoDialogController
* 表格check
*/
@GetMapping("/check")
public String check()
{
public String check() {
return prefix + "/table/check";
}
@ -64,8 +58,7 @@ public class DemoDialogController
* 表格radio
*/
@GetMapping("/radio")
public String radio()
{
public String radio() {
return prefix + "/table/radio";
}
@ -73,8 +66,7 @@ public class DemoDialogController
* 表格回传父窗体
*/
@GetMapping("/parent")
public String parent()
{
public String parent() {
return prefix + "/table/parent";
}
}

View File

@ -11,16 +11,14 @@ import org.springframework.web.bind.annotation.RequestMapping;
*/
@Controller
@RequestMapping("/demo/icon")
public class DemoIconController
{
public class DemoIconController {
private String prefix = "demo/icon";
/**
* FontAwesome图标
*/
@GetMapping("/fontawesome")
public String fontAwesome()
{
public String fontAwesome() {
return prefix + "/fontawesome";
}
@ -28,8 +26,7 @@ public class DemoIconController
* Glyphicons图标
*/
@GetMapping("/glyphicons")
public String glyphicons()
{
public String glyphicons() {
return prefix + "/glyphicons";
}
}

View File

@ -11,16 +11,14 @@ import org.springframework.web.bind.annotation.RequestMapping;
*/
@Controller
@RequestMapping("/demo/report")
public class DemoReportController
{
public class DemoReportController {
private String prefix = "demo/report";
/**
* 百度ECharts
*/
@GetMapping("/echarts")
public String echarts()
{
public String echarts() {
return prefix + "/echarts";
}
@ -28,8 +26,7 @@ public class DemoReportController
* 图表插件
*/
@GetMapping("/peity")
public String peity()
{
public String peity() {
return prefix + "/peity";
}
@ -37,8 +34,7 @@ public class DemoReportController
* 线状图插件
*/
@GetMapping("/sparkline")
public String sparkline()
{
public String sparkline() {
return prefix + "/sparkline";
}
@ -46,8 +42,7 @@ public class DemoReportController
* 图表组合
*/
@GetMapping("/metrics")
public String metrics()
{
public String metrics() {
return prefix + "/metrics";
}
}

View File

@ -13,14 +13,12 @@ import com.ruoyi.common.core.controller.BaseController;
*/
@Controller
@RequestMapping("/monitor/data")
public class DruidController extends BaseController
{
public class DruidController extends BaseController {
private String prefix = "/druid";
@RequiresPermissions("monitor:data:view")
@GetMapping()
public String index()
{
public String index() {
return redirect(prefix + "/index");
}
}

View File

@ -15,14 +15,12 @@ import com.ruoyi.framework.web.domain.Server;
*/
@Controller
@RequestMapping("/monitor/server")
public class ServerController extends BaseController
{
public class ServerController extends BaseController {
private String prefix = "monitor/server";
@RequiresPermissions("monitor:server:view")
@GetMapping()
public String server(ModelMap mmap) throws Exception
{
public String server(ModelMap mmap) throws Exception {
Server server = new Server();
server.copyTo();
mmap.put("server", server);

View File

@ -1,22 +1,24 @@
package com.ruoyi.web.controller.monitor;
import java.util.List;
import com.ruoyi.framework.shiro.service.SysPasswordService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.shiro.service.SysPasswordService;
import com.ruoyi.system.domain.SysLogininfor;
import com.ruoyi.system.service.ISysLogininforService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
/**
* 系统访问记录
@ -25,8 +27,7 @@ import com.ruoyi.system.service.ISysLogininforService;
*/
@Controller
@RequestMapping("/monitor/logininfor")
public class SysLogininforController extends BaseController
{
public class SysLogininforController extends BaseController {
private String prefix = "monitor/logininfor";
@Autowired
@ -37,28 +38,23 @@ public class SysLogininforController extends BaseController
@RequiresPermissions("monitor:logininfor:view")
@GetMapping()
public String logininfor()
{
public String logininfor() {
return prefix + "/logininfor";
}
@RequiresPermissions("monitor:logininfor:list")
@PostMapping("/list")
@ResponseBody
public TableDataInfo list(SysLogininfor logininfor)
{
startPage();
List<SysLogininfor> list = logininforService.selectLogininforList(logininfor);
return getDataTable(list);
public TableDataInfo list(SysLogininfor logininfor) {
return getDataTable(logininforService.selectLogininforList(logininfor, getPageRequest()));
}
@Log(title = "登陆日志", businessType = BusinessType.EXPORT)
@RequiresPermissions("monitor:logininfor:export")
@PostMapping("/export")
@ResponseBody
public AjaxResult export(SysLogininfor logininfor)
{
List<SysLogininfor> list = logininforService.selectLogininforList(logininfor);
public AjaxResult export(SysLogininfor logininfor) {
List<SysLogininfor> list = logininforService.selectLogininforList(logininfor, Pageable.unpaged()).getContent();
ExcelUtil<SysLogininfor> util = new ExcelUtil<SysLogininfor>(SysLogininfor.class);
return util.exportExcel(list, "登陆日志");
}
@ -67,8 +63,7 @@ public class SysLogininforController extends BaseController
@Log(title = "登陆日志", businessType = BusinessType.DELETE)
@PostMapping("/remove")
@ResponseBody
public AjaxResult remove(String ids)
{
public AjaxResult remove(String ids) {
return toAjax(logininforService.deleteLogininforByIds(ids));
}
@ -76,8 +71,7 @@ public class SysLogininforController extends BaseController
@Log(title = "登陆日志", businessType = BusinessType.CLEAN)
@PostMapping("/clean")
@ResponseBody
public AjaxResult clean()
{
public AjaxResult clean() {
logininforService.cleanLogininfor();
return success();
}
@ -86,8 +80,7 @@ public class SysLogininforController extends BaseController
@Log(title = "账户解锁", businessType = BusinessType.OTHER)
@PostMapping("/unlock")
@ResponseBody
public AjaxResult unlock(String loginName)
{
public AjaxResult unlock(String loginName) {
passwordService.unlock(loginName);
return success();
}

View File

@ -1,15 +1,5 @@
package com.ruoyi.web.controller.monitor;
import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
@ -18,6 +8,14 @@ import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.SysOperLog;
import com.ruoyi.system.service.ISysOperLogService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 操作日志记录
@ -26,8 +24,7 @@ import com.ruoyi.system.service.ISysOperLogService;
*/
@Controller
@RequestMapping("/monitor/operlog")
public class SysOperlogController extends BaseController
{
public class SysOperlogController extends BaseController {
private String prefix = "monitor/operlog";
@Autowired
@ -35,28 +32,23 @@ public class SysOperlogController extends BaseController
@RequiresPermissions("monitor:operlog:view")
@GetMapping()
public String operlog()
{
public String operlog() {
return prefix + "/operlog";
}
@RequiresPermissions("monitor:operlog:list")
@PostMapping("/list")
@ResponseBody
public TableDataInfo list(SysOperLog operLog)
{
startPage();
List<SysOperLog> list = operLogService.selectOperLogList(operLog);
return getDataTable(list);
public TableDataInfo list(SysOperLog operLog) {
return getDataTable(operLogService.selectOperLogList(operLog, getPageRequest()));
}
@Log(title = "操作日志", businessType = BusinessType.EXPORT)
@RequiresPermissions("monitor:operlog:export")
@PostMapping("/export")
@ResponseBody
public AjaxResult export(SysOperLog operLog)
{
List<SysOperLog> list = operLogService.selectOperLogList(operLog);
public AjaxResult export(SysOperLog operLog) {
List<SysOperLog> list = operLogService.selectOperLogList(operLog, Pageable.unpaged()).getContent();
ExcelUtil<SysOperLog> util = new ExcelUtil<SysOperLog>(SysOperLog.class);
return util.exportExcel(list, "操作日志");
}
@ -64,15 +56,13 @@ public class SysOperlogController extends BaseController
@RequiresPermissions("monitor:operlog:remove")
@PostMapping("/remove")
@ResponseBody
public AjaxResult remove(String ids)
{
public AjaxResult remove(String ids) {
return toAjax(operLogService.deleteOperLogByIds(ids));
}
@RequiresPermissions("monitor:operlog:detail")
@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));
return prefix + "/detail";
}
@ -81,8 +71,7 @@ public class SysOperlogController extends BaseController
@RequiresPermissions("monitor:operlog:remove")
@PostMapping("/clean")
@ResponseBody
public AjaxResult clean()
{
public AjaxResult clean() {
operLogService.cleanOperLog();
return success();
}

View File

@ -49,11 +49,8 @@ public class SysUserOnlineController extends BaseController
@RequiresPermissions("monitor:online:list")
@PostMapping("/list")
@ResponseBody
public TableDataInfo list(SysUserOnline userOnline)
{
startPage();
List<SysUserOnline> list = userOnlineService.selectUserOnlineList(userOnline);
return getDataTable(list);
public TableDataInfo list(SysUserOnline userOnline) {
return getDataTable(userOnlineService.selectUserOnlineList(userOnline, getPageRequest()));
}
@RequiresPermissions(value = { "monitor:online:batchForceLogout", "monitor:online:forceLogout" }, logical = Logical.OR)

View File

@ -8,6 +8,7 @@ import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
@ -23,8 +24,7 @@ import com.ruoyi.common.core.controller.BaseController;
*/
@Controller
@RequestMapping("/captcha")
public class SysCaptchaController extends BaseController
{
public class SysCaptchaController extends BaseController {
@Resource(name = "captchaProducer")
private Producer captchaProducer;
@ -35,11 +35,9 @@ public class SysCaptchaController extends BaseController
* 验证码生成
*/
@GetMapping(value = "/captchaImage")
public ModelAndView getKaptchaImage(HttpServletRequest request, HttpServletResponse response)
{
public ModelAndView getKaptchaImage(HttpServletRequest request, HttpServletResponse response) {
ServletOutputStream out = null;
try
{
try {
HttpSession session = request.getSession();
response.setDateHeader("Expires", 0);
response.setHeader("Cache-Control", "no-store, no-cache, must-revalidate");
@ -51,15 +49,12 @@ public class SysCaptchaController extends BaseController
String capStr = null;
String code = null;
BufferedImage bi = null;
if ("math".equals(type))
{
if ("math".equals(type)) {
String capText = captchaProducerMath.createText();
capStr = capText.substring(0, capText.lastIndexOf("@"));
code = capText.substring(capText.lastIndexOf("@") + 1);
bi = captchaProducerMath.createImage(capStr);
}
else if ("char".equals(type))
{
} else if ("char".equals(type)) {
capStr = code = captchaProducer.createText();
bi = captchaProducer.createImage(capStr);
}
@ -68,22 +63,14 @@ public class SysCaptchaController extends BaseController
ImageIO.write(bi, "jpg", out);
out.flush();
}
catch (Exception e)
{
} catch (Exception e) {
e.printStackTrace();
}
finally
{
try
{
if (out != null)
{
} finally {
try {
if (out != null) {
out.close();
}
}
catch (IOException e)
{
} catch (IOException e) {
e.printStackTrace();
}
}

View File

@ -1,16 +1,5 @@
package com.ruoyi.web.controller.system;
import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
@ -20,6 +9,15 @@ import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.util.ShiroUtils;
import com.ruoyi.system.domain.SysDictData;
import com.ruoyi.system.service.ISysDictDataService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 数据字典信息
@ -28,8 +26,7 @@ import com.ruoyi.system.service.ISysDictDataService;
*/
@Controller
@RequestMapping("/system/dict/data")
public class SysDictDataController extends BaseController
{
public class SysDictDataController extends BaseController {
private String prefix = "system/dict/data";
@Autowired
@ -37,28 +34,23 @@ public class SysDictDataController extends BaseController
@RequiresPermissions("system:dict:view")
@GetMapping()
public String dictData()
{
public String dictData() {
return prefix + "/data";
}
@PostMapping("/list")
@RequiresPermissions("system:dict:list")
@ResponseBody
public TableDataInfo list(SysDictData dictData)
{
startPage();
List<SysDictData> list = dictDataService.selectDictDataList(dictData);
return getDataTable(list);
public TableDataInfo list(SysDictData dictData) {
return getDataTable(dictDataService.selectDictDataList(dictData, getPageRequest()));
}
@Log(title = "字典数据", businessType = BusinessType.EXPORT)
@RequiresPermissions("system:dict:export")
@PostMapping("/export")
@ResponseBody
public AjaxResult export(SysDictData dictData)
{
List<SysDictData> list = dictDataService.selectDictDataList(dictData);
public AjaxResult export(SysDictData dictData) {
List<SysDictData> list = dictDataService.selectDictDataList(dictData, Pageable.unpaged()).getContent();
ExcelUtil<SysDictData> util = new ExcelUtil<SysDictData>(SysDictData.class);
return util.exportExcel(list, "字典数据");
}
@ -67,8 +59,7 @@ public class SysDictDataController extends BaseController
* 新增字典类型
*/
@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);
return prefix + "/add";
}
@ -80,8 +71,7 @@ public class SysDictDataController extends BaseController
@RequiresPermissions("system:dict:add")
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(@Validated SysDictData dict)
{
public AjaxResult addSave(@Validated SysDictData dict) {
dict.setCreateBy(ShiroUtils.getLoginName());
return toAjax(dictDataService.insertDictData(dict));
}
@ -90,8 +80,7 @@ public class SysDictDataController extends BaseController
* 修改字典类型
*/
@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));
return prefix + "/edit";
}
@ -103,8 +92,7 @@ public class SysDictDataController extends BaseController
@RequiresPermissions("system:dict:edit")
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(@Validated SysDictData dict)
{
public AjaxResult editSave(@Validated SysDictData dict) {
dict.setUpdateBy(ShiroUtils.getLoginName());
return toAjax(dictDataService.updateDictData(dict));
}
@ -113,8 +101,7 @@ public class SysDictDataController extends BaseController
@RequiresPermissions("system:dict:remove")
@PostMapping("/remove")
@ResponseBody
public AjaxResult remove(String ids)
{
public AjaxResult remove(String ids) {
return toAjax(dictDataService.deleteDictDataByIds(ids));
}
}

View File

@ -2,6 +2,7 @@ package com.ruoyi.web.controller.system;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.UsernamePasswordToken;
@ -21,14 +22,11 @@ import com.ruoyi.common.utils.StringUtils;
* @author ruoyi
*/
@Controller
public class SysLoginController extends BaseController
{
public class SysLoginController extends BaseController {
@GetMapping("/login")
public String login(HttpServletRequest request, HttpServletResponse response)
{
public String login(HttpServletRequest request, HttpServletResponse response) {
// 如果是Ajax请求返回Json字符串
if (ServletUtils.isAjaxRequest(request))
{
if (ServletUtils.isAjaxRequest(request)) {
return ServletUtils.renderString(response, "{\"code\":\"1\",\"msg\":\"未登录或登录超时。请重新登录\"}");
}
@ -37,20 +35,15 @@ public class SysLoginController extends BaseController
@PostMapping("/login")
@ResponseBody
public AjaxResult ajaxLogin(String username, String password, Boolean rememberMe)
{
public AjaxResult ajaxLogin(String username, String password, Boolean rememberMe) {
UsernamePasswordToken token = new UsernamePasswordToken(username, password, rememberMe);
Subject subject = SecurityUtils.getSubject();
try
{
try {
subject.login(token);
return success();
}
catch (AuthenticationException e)
{
} catch (AuthenticationException e) {
String msg = "用户或密码错误";
if (StringUtils.isNotEmpty(e.getMessage()))
{
if (StringUtils.isNotEmpty(e.getMessage())) {
msg = e.getMessage();
}
return error(msg);
@ -58,8 +51,7 @@ public class SysLoginController extends BaseController
}
@GetMapping("/unauth")
public String unauth()
{
public String unauth() {
return "error/unauth";
}
}

View File

@ -1,6 +1,7 @@
package com.ruoyi.web.controller.system;
import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
@ -29,8 +30,7 @@ import com.ruoyi.system.service.ISysMenuService;
*/
@Controller
@RequestMapping("/system/menu")
public class SysMenuController extends BaseController
{
public class SysMenuController extends BaseController {
private String prefix = "system/menu";
@Autowired
@ -38,16 +38,14 @@ public class SysMenuController extends BaseController
@RequiresPermissions("system:menu:view")
@GetMapping()
public String menu()
{
public String menu() {
return prefix + "/menu";
}
@RequiresPermissions("system:menu:list")
@PostMapping("/list")
@ResponseBody
public List<SysMenu> list(SysMenu menu)
{
public List<SysMenu> list(SysMenu menu) {
Long userId = ShiroUtils.getUserId();
List<SysMenu> menuList = menuService.selectMenuList(menu, userId);
return menuList;
@ -60,14 +58,11 @@ public class SysMenuController extends BaseController
@RequiresPermissions("system:menu:remove")
@GetMapping("/remove/{menuId}")
@ResponseBody
public AjaxResult remove(@PathVariable("menuId") Long menuId)
{
if (menuService.selectCountMenuByParentId(menuId) > 0)
{
public AjaxResult remove(@PathVariable("menuId") Long menuId) {
if (menuService.selectCountMenuByParentId(menuId) > 0) {
return AjaxResult.warn("存在子菜单,不允许删除");
}
if (menuService.selectCountRoleMenuByMenuId(menuId) > 0)
{
if (menuService.selectCountRoleMenuByMenuId(menuId) > 0) {
return AjaxResult.warn("菜单已分配,不允许删除");
}
ShiroUtils.clearCachedAuthorizationInfo();
@ -78,15 +73,11 @@ public class SysMenuController extends BaseController
* 新增
*/
@GetMapping("/add/{parentId}")
public String add(@PathVariable("parentId") Long parentId, ModelMap mmap)
{
public String add(@PathVariable("parentId") Long parentId, ModelMap mmap) {
SysMenu menu = null;
if (0L != parentId)
{
if (0L != parentId) {
menu = menuService.selectMenuById(parentId);
}
else
{
} else {
menu = new SysMenu();
menu.setMenuId(0L);
menu.setMenuName("主目录");
@ -102,23 +93,21 @@ public class SysMenuController extends BaseController
@RequiresPermissions("system:menu:add")
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(@Validated SysMenu menu)
{
if (UserConstants.MENU_NAME_NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu)))
{
public AjaxResult addSave(@Validated SysMenu menu) {
if (UserConstants.MENU_NAME_NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu))) {
return error("新增菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
}
menu.setCreateBy(ShiroUtils.getLoginName());
ShiroUtils.clearCachedAuthorizationInfo();
return toAjax(menuService.insertMenu(menu));
menuService.insertMenu(menu);
return success();
}
/**
* 修改菜单
*/
@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));
return prefix + "/edit";
}
@ -130,23 +119,21 @@ public class SysMenuController extends BaseController
@RequiresPermissions("system:menu:edit")
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(@Validated SysMenu menu)
{
if (UserConstants.MENU_NAME_NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu)))
{
public AjaxResult editSave(@Validated SysMenu menu) {
if (UserConstants.MENU_NAME_NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu))) {
return error("修改菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
}
menu.setUpdateBy(ShiroUtils.getLoginName());
ShiroUtils.clearCachedAuthorizationInfo();
return toAjax(menuService.updateMenu(menu));
menuService.updateMenu(menu);
return success();
}
/**
* 选择菜单图标
*/
@GetMapping("/icon")
public String icon()
{
public String icon() {
return prefix + "/icon";
}
@ -155,8 +142,7 @@ public class SysMenuController extends BaseController
*/
@PostMapping("/checkMenuNameUnique")
@ResponseBody
public String checkMenuNameUnique(SysMenu menu)
{
public String checkMenuNameUnique(SysMenu menu) {
return menuService.checkMenuNameUnique(menu);
}
@ -165,8 +151,7 @@ public class SysMenuController extends BaseController
*/
@GetMapping("/roleMenuTreeData")
@ResponseBody
public List<Ztree> roleMenuTreeData(SysRole role)
{
public List<Ztree> roleMenuTreeData(SysRole role) {
Long userId = ShiroUtils.getUserId();
List<Ztree> ztrees = menuService.roleMenuTreeData(role, userId);
return ztrees;
@ -177,8 +162,7 @@ public class SysMenuController extends BaseController
*/
@GetMapping("/menuTreeData")
@ResponseBody
public List<Ztree> menuTreeData()
{
public List<Ztree> menuTreeData() {
Long userId = ShiroUtils.getUserId();
List<Ztree> ztrees = menuService.menuTreeData(userId);
return ztrees;
@ -188,8 +172,7 @@ public class SysMenuController extends BaseController
* 选择菜单树
*/
@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));
return prefix + "/tree";
}

View File

@ -1,6 +1,7 @@
package com.ruoyi.web.controller.system;
import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
@ -26,8 +27,7 @@ import com.ruoyi.system.service.ISysNoticeService;
*/
@Controller
@RequestMapping("/system/notice")
public class SysNoticeController extends BaseController
{
public class SysNoticeController extends BaseController {
private String prefix = "system/notice";
@Autowired
@ -35,8 +35,7 @@ public class SysNoticeController extends BaseController
@RequiresPermissions("system:notice:view")
@GetMapping()
public String notice()
{
public String notice() {
return prefix + "/notice";
}
@ -46,19 +45,15 @@ public class SysNoticeController extends BaseController
@RequiresPermissions("system:notice:list")
@PostMapping("/list")
@ResponseBody
public TableDataInfo list(SysNotice notice)
{
startPage();
List<SysNotice> list = noticeService.selectNoticeList(notice);
return getDataTable(list);
public TableDataInfo list(SysNotice notice) {
return getDataTable(noticeService.selectNoticeList(notice, getPageRequest()));
}
/**
* 新增公告
*/
@GetMapping("/add")
public String add()
{
public String add() {
return prefix + "/add";
}
@ -69,8 +64,7 @@ public class SysNoticeController extends BaseController
@Log(title = "通知公告", businessType = BusinessType.INSERT)
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(SysNotice notice)
{
public AjaxResult addSave(SysNotice notice) {
notice.setCreateBy(ShiroUtils.getLoginName());
return toAjax(noticeService.insertNotice(notice));
}
@ -79,8 +73,7 @@ public class SysNoticeController extends BaseController
* 修改公告
*/
@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));
return prefix + "/edit";
}
@ -92,8 +85,7 @@ public class SysNoticeController extends BaseController
@Log(title = "通知公告", businessType = BusinessType.UPDATE)
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(SysNotice notice)
{
public AjaxResult editSave(SysNotice notice) {
notice.setUpdateBy(ShiroUtils.getLoginName());
return toAjax(noticeService.updateNotice(notice));
}
@ -105,8 +97,7 @@ public class SysNoticeController extends BaseController
@Log(title = "通知公告", businessType = BusinessType.DELETE)
@PostMapping("/remove")
@ResponseBody
public AjaxResult remove(String ids)
{
public AjaxResult remove(String ids) {
return toAjax(noticeService.deleteNoticeByIds(ids));
}
}

View File

@ -1,16 +1,5 @@
package com.ruoyi.web.controller.system;
import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.controller.BaseController;
@ -21,6 +10,14 @@ import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.util.ShiroUtils;
import com.ruoyi.system.domain.SysPost;
import com.ruoyi.system.service.ISysPostService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
/**
* 岗位信息操作处理
@ -29,8 +26,7 @@ import com.ruoyi.system.service.ISysPostService;
*/
@Controller
@RequestMapping("/system/post")
public class SysPostController extends BaseController
{
public class SysPostController extends BaseController {
private String prefix = "system/post";
@Autowired
@ -38,44 +34,35 @@ public class SysPostController extends BaseController
@RequiresPermissions("system:post:view")
@GetMapping()
public String operlog()
{
public String operlog() {
return prefix + "/post";
}
@RequiresPermissions("system:post:list")
@PostMapping("/list")
@ResponseBody
public TableDataInfo list(SysPost post)
{
startPage();
List<SysPost> list = postService.selectPostList(post);
return getDataTable(list);
public TableDataInfo list(SysPost post) {
return getDataTable(postService.selectPostList(post, getPageRequest()));
}
@Log(title = "岗位管理", businessType = BusinessType.EXPORT)
@RequiresPermissions("system:post:export")
@PostMapping("/export")
@ResponseBody
public AjaxResult export(SysPost post)
{
List<SysPost> list = postService.selectPostList(post);
public AjaxResult export(SysPost post) {
Page<SysPost> list = postService.selectPostList(post, Pageable.unpaged());
ExcelUtil<SysPost> util = new ExcelUtil<SysPost>(SysPost.class);
return util.exportExcel(list, "岗位数据");
return util.exportExcel(list.getContent(), "岗位数据");
}
@RequiresPermissions("system:post:remove")
@Log(title = "岗位管理", businessType = BusinessType.DELETE)
@PostMapping("/remove")
@ResponseBody
public AjaxResult remove(String ids)
{
try
{
public AjaxResult remove(String ids) {
try {
return toAjax(postService.deletePostByIds(ids));
}
catch (Exception e)
{
} catch (Exception e) {
return error(e.getMessage());
}
}
@ -84,8 +71,7 @@ public class SysPostController extends BaseController
* 新增岗位
*/
@GetMapping("/add")
public String add()
{
public String add() {
return prefix + "/add";
}
@ -96,26 +82,21 @@ public class SysPostController extends BaseController
@Log(title = "岗位管理", businessType = BusinessType.INSERT)
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(@Validated SysPost post)
{
if (UserConstants.POST_NAME_NOT_UNIQUE.equals(postService.checkPostNameUnique(post)))
{
public AjaxResult addSave(@Validated SysPost post) {
if (UserConstants.POST_NAME_NOT_UNIQUE.equals(postService.checkPostNameUnique(post))) {
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() + "'失败,岗位编码已存在");
}
post.setCreateBy(ShiroUtils.getLoginName());
return toAjax(postService.insertPost(post));
return success(postService.insertPost(post));
}
/**
* 修改岗位
*/
@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));
return prefix + "/edit";
}
@ -127,18 +108,14 @@ public class SysPostController extends BaseController
@Log(title = "岗位管理", businessType = BusinessType.UPDATE)
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(@Validated SysPost post)
{
if (UserConstants.POST_NAME_NOT_UNIQUE.equals(postService.checkPostNameUnique(post)))
{
public AjaxResult editSave(@Validated SysPost post) {
if (UserConstants.POST_NAME_NOT_UNIQUE.equals(postService.checkPostNameUnique(post))) {
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() + "'失败,岗位编码已存在");
}
post.setUpdateBy(ShiroUtils.getLoginName());
return toAjax(postService.updatePost(post));
return success(postService.updatePost(post));
}
/**
@ -146,8 +123,7 @@ public class SysPostController extends BaseController
*/
@PostMapping("/checkPostNameUnique")
@ResponseBody
public String checkPostNameUnique(SysPost post)
{
public String checkPostNameUnique(SysPost post) {
return postService.checkPostNameUnique(post);
}
@ -156,8 +132,7 @@ public class SysPostController extends BaseController
*/
@PostMapping("/checkPostCodeUnique")
@ResponseBody
public String checkPostCodeUnique(SysPost post)
{
public String checkPostCodeUnique(SysPost post) {
return postService.checkPostCodeUnique(post);
}
}

View File

@ -1,16 +1,5 @@
package com.ruoyi.web.controller.system;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.config.Global;
import com.ruoyi.common.core.controller.BaseController;
@ -20,8 +9,16 @@ import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.file.FileUploadUtils;
import com.ruoyi.framework.shiro.service.SysPasswordService;
import com.ruoyi.framework.util.ShiroUtils;
import com.ruoyi.system.domain.SysPost;
import com.ruoyi.system.domain.SysUser;
import com.ruoyi.system.service.ISysUserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
/**
* 个人信息 业务处理
@ -30,8 +27,7 @@ import com.ruoyi.system.service.ISysUserService;
*/
@Controller
@RequestMapping("/system/user/profile")
public class SysProfileController extends BaseController
{
public class SysProfileController extends BaseController {
private static final Logger log = LoggerFactory.getLogger(SysProfileController.class);
private String prefix = "system/user/profile";
@ -46,30 +42,36 @@ public class SysProfileController extends BaseController
* 个人信息
*/
@GetMapping()
public String profile(ModelMap mmap)
{
SysUser user = ShiroUtils.getSysUser();
public String profile(ModelMap mmap) {
SysUser user = userService.selectUserWithRolesAndPostsById(ShiroUtils.getUserId());
mmap.put("user", user);
mmap.put("roleGroup", userService.selectUserRoleGroup(user.getUserId()));
mmap.put("postGroup", userService.selectUserPostGroup(user.getUserId()));
mmap.put("postGroup", concat(user));
return prefix + "/profile";
}
private String concat(SysUser user){
StringBuffer idsStr = new StringBuffer();
for (SysPost post : user.getPosts()) {
idsStr.append(post.getPostName()).append(",");
}
if (StringUtils.isNotEmpty(idsStr.toString())) {
return idsStr.substring(0, idsStr.length() - 1);
}
return idsStr.toString();
}
@GetMapping("/checkPassword")
@ResponseBody
public boolean checkPassword(String password)
{
public boolean checkPassword(String password) {
SysUser user = ShiroUtils.getSysUser();
if (passwordService.matches(user, password))
{
if (passwordService.matches(user, password)) {
return true;
}
return false;
}
@GetMapping("/resetPwd")
public String resetPwd(ModelMap mmap)
{
public String resetPwd(ModelMap mmap) {
SysUser user = ShiroUtils.getSysUser();
mmap.put("user", userService.selectUserById(user.getUserId()));
return prefix + "/resetPwd";
@ -78,22 +80,15 @@ public class SysProfileController extends BaseController
@Log(title = "重置密码", businessType = BusinessType.UPDATE)
@PostMapping("/resetPwd")
@ResponseBody
public AjaxResult resetPwd(String oldPassword, String newPassword)
{
public AjaxResult resetPwd(String oldPassword, String newPassword) {
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.setPassword(passwordService.encryptPassword(user.getLoginName(), newPassword, user.getSalt()));
if (userService.resetUserPwd(user) > 0)
{
ShiroUtils.setSysUser(userService.selectUserById(user.getUserId()));
user = userService.resetUserPwd(user);
ShiroUtils.setSysUser(user);
return success();
}
return error();
}
else
{
} else {
return error("修改密码失败,旧密码错误");
}
}
@ -102,8 +97,7 @@ public class SysProfileController extends BaseController
* 修改用户
*/
@GetMapping("/edit")
public String edit(ModelMap mmap)
{
public String edit(ModelMap mmap) {
SysUser user = ShiroUtils.getSysUser();
mmap.put("user", userService.selectUserById(user.getUserId()));
return prefix + "/edit";
@ -113,8 +107,7 @@ public class SysProfileController extends BaseController
* 修改头像
*/
@GetMapping("/avatar")
public String avatar(ModelMap mmap)
{
public String avatar(ModelMap mmap) {
SysUser user = ShiroUtils.getSysUser();
mmap.put("user", userService.selectUserById(user.getUserId()));
return prefix + "/avatar";
@ -126,20 +119,16 @@ public class SysProfileController extends BaseController
@Log(title = "个人信息", businessType = BusinessType.UPDATE)
@PostMapping("/update")
@ResponseBody
public AjaxResult update(SysUser user)
{
public AjaxResult update(SysUser user) {
SysUser currentUser = ShiroUtils.getSysUser();
currentUser.setUserName(user.getUserName());
currentUser.setEmail(user.getEmail());
currentUser.setPhonenumber(user.getPhonenumber());
currentUser.setSex(user.getSex());
if (userService.updateUserInfo(currentUser) > 0)
{
ShiroUtils.setSysUser(userService.selectUserById(currentUser.getUserId()));
userService.updateUserInfo(currentUser);
ShiroUtils.setSysUser(currentUser);
return success();
}
return error();
}
/**
* 保存头像
@ -147,25 +136,18 @@ public class SysProfileController extends BaseController
@Log(title = "个人信息", businessType = BusinessType.UPDATE)
@PostMapping("/updateAvatar")
@ResponseBody
public AjaxResult updateAvatar(@RequestParam("avatarfile") MultipartFile file)
{
public AjaxResult updateAvatar(@RequestParam("avatarfile") MultipartFile file) {
SysUser currentUser = ShiroUtils.getSysUser();
try
{
if (!file.isEmpty())
{
try {
if (!file.isEmpty()) {
String avatar = FileUploadUtils.upload(Global.getAvatarPath(), file);
currentUser.setAvatar(avatar);
if (userService.updateUserInfo(currentUser) > 0)
{
ShiroUtils.setSysUser(userService.selectUserById(currentUser.getUserId()));
userService.updateUserInfo(currentUser);
ShiroUtils.setSysUser(currentUser);
return success();
}
}
return error();
}
catch (Exception e)
{
} catch (Exception e) {
log.error("修改头像失败!", e);
return error(e.getMessage());
}

View File

@ -1,19 +1,7 @@
package com.ruoyi.web.controller.system;
import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
@ -24,6 +12,16 @@ import com.ruoyi.system.domain.SysUser;
import com.ruoyi.system.domain.SysUserRole;
import com.ruoyi.system.service.ISysRoleService;
import com.ruoyi.system.service.ISysUserService;
import com.ruoyi.web.controller.system.base.WebController;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 角色信息
@ -32,8 +30,7 @@ import com.ruoyi.system.service.ISysUserService;
*/
@Controller
@RequestMapping("/system/role")
public class SysRoleController extends BaseController
{
public class SysRoleController extends WebController {
private String prefix = "system/role";
@Autowired
@ -44,28 +41,23 @@ public class SysRoleController extends BaseController
@RequiresPermissions("system:role:view")
@GetMapping()
public String role()
{
public String role() {
return prefix + "/role";
}
@RequiresPermissions("system:role:list")
@PostMapping("/list")
@ResponseBody
public TableDataInfo list(SysRole role)
{
startPage();
List<SysRole> list = roleService.selectRoleList(role);
return getDataTable(list);
public TableDataInfo list(SysRole role) {
return getDataTable(roleService.selectRoleList(role, getPageRequest(), getUser()));
}
@Log(title = "角色管理", businessType = BusinessType.EXPORT)
@RequiresPermissions("system:role:export")
@PostMapping("/export")
@ResponseBody
public AjaxResult export(SysRole role)
{
List<SysRole> list = roleService.selectRoleList(role);
public AjaxResult export(SysRole role) {
List<SysRole> list = roleService.selectRoleList(role, Pageable.unpaged(), getUser()).getContent();
ExcelUtil<SysRole> util = new ExcelUtil<SysRole>(SysRole.class);
return util.exportExcel(list, "角色数据");
}
@ -74,8 +66,7 @@ public class SysRoleController extends BaseController
* 新增角色
*/
@GetMapping("/add")
public String add()
{
public String add() {
return prefix + "/add";
}
@ -86,19 +77,16 @@ public class SysRoleController extends BaseController
@Log(title = "角色管理", businessType = BusinessType.INSERT)
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(@Validated SysRole role)
{
if (UserConstants.ROLE_NAME_NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role)))
{
public AjaxResult addSave(@Validated SysRole role) {
if (UserConstants.ROLE_NAME_NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role))) {
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() + "'失败,角色权限已存在");
}
role.setCreateBy(ShiroUtils.getLoginName());
ShiroUtils.clearCachedAuthorizationInfo();
return toAjax(roleService.insertRole(role));
roleService.insertRole(role);
return success();
}
@ -106,8 +94,7 @@ public class SysRoleController extends BaseController
* 修改角色
*/
@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));
return prefix + "/edit";
}
@ -119,28 +106,24 @@ public class SysRoleController extends BaseController
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(@Validated SysRole role)
{
public AjaxResult editSave(@Validated SysRole 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() + "'失败,角色名称已存在");
}
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() + "'失败,角色权限已存在");
}
role.setUpdateBy(ShiroUtils.getLoginName());
ShiroUtils.clearCachedAuthorizationInfo();
return toAjax(roleService.updateRole(role));
roleService.updateRole(role);
return success();
}
/**
* 角色分配数据权限
*/
@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));
return prefix + "/dataScope";
}
@ -152,12 +135,10 @@ public class SysRoleController extends BaseController
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
@PostMapping("/authDataScope")
@ResponseBody
public AjaxResult authDataScopeSave(SysRole role)
{
public AjaxResult authDataScopeSave(SysRole role) {
roleService.checkRoleAllowed(role);
role.setUpdateBy(ShiroUtils.getLoginName());
if (roleService.authDataScope(role) > 0)
{
if (roleService.authDataScope(role) > 0) {
ShiroUtils.setSysUser(userService.selectUserById(ShiroUtils.getSysUser().getUserId()));
return success();
}
@ -168,14 +149,10 @@ public class SysRoleController extends BaseController
@Log(title = "角色管理", businessType = BusinessType.DELETE)
@PostMapping("/remove")
@ResponseBody
public AjaxResult remove(String ids)
{
try
{
public AjaxResult remove(String ids) {
try {
return toAjax(roleService.deleteRoleByIds(ids));
}
catch (Exception e)
{
} catch (Exception e) {
return error(e.getMessage());
}
}
@ -185,8 +162,7 @@ public class SysRoleController extends BaseController
*/
@PostMapping("/checkRoleNameUnique")
@ResponseBody
public String checkRoleNameUnique(SysRole role)
{
public String checkRoleNameUnique(SysRole role) {
return roleService.checkRoleNameUnique(role);
}
@ -195,8 +171,7 @@ public class SysRoleController extends BaseController
*/
@PostMapping("/checkRoleKeyUnique")
@ResponseBody
public String checkRoleKeyUnique(SysRole role)
{
public String checkRoleKeyUnique(SysRole role) {
return roleService.checkRoleKeyUnique(role);
}
@ -204,8 +179,7 @@ public class SysRoleController extends BaseController
* 选择菜单树
*/
@GetMapping("/selectMenuTree")
public String selectMenuTree()
{
public String selectMenuTree() {
return prefix + "/tree";
}
@ -216,8 +190,7 @@ public class SysRoleController extends BaseController
@RequiresPermissions("system:role:edit")
@PostMapping("/changeStatus")
@ResponseBody
public AjaxResult changeStatus(SysRole role)
{
public AjaxResult changeStatus(SysRole role) {
roleService.checkRoleAllowed(role);
return toAjax(roleService.changeStatus(role));
}
@ -227,8 +200,7 @@ public class SysRoleController extends BaseController
*/
@RequiresPermissions("system:role:edit")
@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));
return prefix + "/authUser";
}
@ -239,11 +211,8 @@ public class SysRoleController extends BaseController
@RequiresPermissions("system:role:list")
@PostMapping("/authUser/allocatedList")
@ResponseBody
public TableDataInfo allocatedList(SysUser user)
{
startPage();
List<SysUser> list = userService.selectAllocatedList(user);
return getDataTable(list);
public TableDataInfo allocatedList(SysUser user) {
return getDataTable(userService.selectAllocatedList(user, getPageRequest()));
}
/**
@ -252,8 +221,7 @@ public class SysRoleController extends BaseController
@Log(title = "角色管理", businessType = BusinessType.GRANT)
@PostMapping("/authUser/cancel")
@ResponseBody
public AjaxResult cancelAuthUser(SysUserRole userRole)
{
public AjaxResult cancelAuthUser(SysUserRole userRole) {
return toAjax(roleService.deleteAuthUser(userRole));
}
@ -263,8 +231,7 @@ public class SysRoleController extends BaseController
@Log(title = "角色管理", businessType = BusinessType.GRANT)
@PostMapping("/authUser/cancelAll")
@ResponseBody
public AjaxResult cancelAuthUserAll(Long roleId, String userIds)
{
public AjaxResult cancelAuthUserAll(Long roleId, String userIds) {
return toAjax(roleService.deleteAuthUsers(roleId, userIds));
}
@ -272,8 +239,7 @@ public class SysRoleController extends BaseController
* 选择用户
*/
@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));
return prefix + "/selectUser";
}
@ -284,11 +250,8 @@ public class SysRoleController extends BaseController
@RequiresPermissions("system:role:list")
@PostMapping("/authUser/unallocatedList")
@ResponseBody
public TableDataInfo unallocatedList(SysUser user)
{
startPage();
List<SysUser> list = userService.selectUnallocatedList(user);
return getDataTable(list);
public TableDataInfo unallocatedList(SysUser user) {
return getDataTable(userService.selectUnallocatedList(user, getPageRequest()));
}
/**
@ -297,8 +260,7 @@ public class SysRoleController extends BaseController
@Log(title = "角色管理", businessType = BusinessType.GRANT)
@PostMapping("/authUser/selectAll")
@ResponseBody
public AjaxResult selectAuthUserAll(Long roleId, String userIds)
{
public AjaxResult selectAuthUserAll(Long roleId, String userIds) {
return toAjax(roleService.insertAuthUsers(roleId, userIds));
}
}

View File

@ -0,0 +1,12 @@
package com.ruoyi.web.controller.system.base;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.framework.util.ShiroUtils;
import com.ruoyi.system.domain.SysUser;
public class WebController extends BaseController {
protected SysUser getUser(){
return ShiroUtils.getSysUser();
}
}

View File

@ -13,14 +13,12 @@ import com.ruoyi.common.core.controller.BaseController;
*/
@Controller
@RequestMapping("/tool/build")
public class BuildController extends BaseController
{
public class BuildController extends BaseController {
private String prefix = "tool/build";
@RequiresPermissions("tool:build:view")
@GetMapping()
public String build()
{
public String build() {
return prefix + "/build";
}
}

View File

@ -13,12 +13,10 @@ import com.ruoyi.common.core.controller.BaseController;
*/
@Controller
@RequestMapping("/tool/swagger")
public class SwaggerController extends BaseController
{
public class SwaggerController extends BaseController {
@RequiresPermissions("tool:swagger:view")
@GetMapping()
public String index()
{
public String index() {
return redirect("/swagger-ui.html");
}
}

View File

@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
@ -28,9 +29,9 @@ import io.swagger.annotations.ApiOperation;
@Api("用户信息管理")
@RestController
@RequestMapping("/test/user")
public class TestController extends BaseController
{
public class TestController extends BaseController {
private final static Map<Integer, UserEntity> users = new LinkedHashMap<Integer, UserEntity>();
{
users.put(1, new UserEntity(1, "admin", "admin123", "15888888888"));
users.put(2, new UserEntity(2, "ry", "admin123", "15666666666"));
@ -38,8 +39,7 @@ public class TestController extends BaseController
@ApiOperation("获取用户列表")
@GetMapping("/list")
public AjaxResult userList()
{
public AjaxResult userList() {
List<UserEntity> userList = new ArrayList<UserEntity>(users.values());
return AjaxResult.success(userList);
}
@ -47,14 +47,10 @@ public class TestController extends BaseController
@ApiOperation("获取用户详细")
@ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path")
@GetMapping("/{userId}")
public AjaxResult getUser(@PathVariable Integer userId)
{
if (!users.isEmpty() && users.containsKey(userId))
{
public AjaxResult getUser(@PathVariable Integer userId) {
if (!users.isEmpty() && users.containsKey(userId)) {
return AjaxResult.success(users.get(userId));
}
else
{
} else {
return error("用户不存在");
}
}
@ -62,10 +58,8 @@ public class TestController extends BaseController
@ApiOperation("新增用户")
@ApiImplicitParam(name = "userEntity", value = "新增用户信息", dataType = "UserEntity")
@PostMapping("/save")
public AjaxResult save(UserEntity user)
{
if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId()))
{
public AjaxResult save(UserEntity user) {
if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId())) {
return error("用户ID不能为空");
}
return AjaxResult.success(users.put(user.getUserId(), user));
@ -74,14 +68,11 @@ public class TestController extends BaseController
@ApiOperation("更新用户")
@ApiImplicitParam(name = "userEntity", value = "新增用户信息", dataType = "UserEntity")
@PutMapping("/update")
public AjaxResult update(UserEntity user)
{
if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId()))
{
public AjaxResult update(UserEntity user) {
if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId())) {
return error("用户ID不能为空");
}
if (users.isEmpty() || !users.containsKey(user.getUserId()))
{
if (users.isEmpty() || !users.containsKey(user.getUserId())) {
return error("用户不存在");
}
users.remove(user.getUserId());
@ -91,23 +82,18 @@ public class TestController extends BaseController
@ApiOperation("删除用户信息")
@ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path")
@DeleteMapping("/{userId}")
public AjaxResult delete(@PathVariable Integer userId)
{
if (!users.isEmpty() && users.containsKey(userId))
{
public AjaxResult delete(@PathVariable Integer userId) {
if (!users.isEmpty() && users.containsKey(userId)) {
users.remove(userId);
return success();
}
else
{
} else {
return error("用户不存在");
}
}
}
@ApiModel("用户实体")
class UserEntity
{
class UserEntity {
@ApiModelProperty("用户ID")
private Integer userId;
@ -120,56 +106,46 @@ class UserEntity
@ApiModelProperty("用户手机")
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.username = username;
this.password = password;
this.mobile = mobile;
}
public Integer getUserId()
{
public Integer getUserId() {
return userId;
}
public void setUserId(Integer userId)
{
public void setUserId(Integer userId) {
this.userId = userId;
}
public String getUsername()
{
public String getUsername() {
return username;
}
public void setUsername(String username)
{
public void setUsername(String username) {
this.username = username;
}
public String getPassword()
{
public String getPassword() {
return password;
}
public void setPassword(String password)
{
public void setPassword(String password) {
this.password = password;
}
public String getMobile()
{
public String getMobile() {
return mobile;
}
public void setMobile(String mobile)
{
public void setMobile(String mobile) {
this.mobile = mobile;
}
}

View File

@ -0,0 +1,37 @@
package com.ruoyi.web.core.config;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.hibernate5.Hibernate5Module;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import java.util.List;
@Configuration
public class WebmvcConfig implements WebMvcConfigurer {
@Override
public void extendMessageConverters(List<HttpMessageConverter<?>> converters) {
for ( HttpMessageConverter<?> converter : converters ) {
if ( converter instanceof MappingJackson2HttpMessageConverter) {
MappingJackson2HttpMessageConverter jacksonConverter = (MappingJackson2HttpMessageConverter) converter;
ObjectMapper objectMapper = jacksonConverter.getObjectMapper();
//--- register hibernateModule in MappingJackson2HttpMessageConverter.objectMapper
Hibernate5Module hibernate5Module = new Hibernate5Module();
hibernate5Module.disable(Hibernate5Module.Feature.FORCE_LAZY_LOADING);
hibernate5Module.enable(Hibernate5Module.Feature.WRITE_MISSING_ENTITIES_AS_NULL);
hibernate5Module.disable(Hibernate5Module.Feature.USE_TRANSIENT_ANNOTATION);
objectMapper.registerModule(hibernate5Module);
//--- other configurations
jacksonConverter.setPrettyPrint( true );
objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
objectMapper.enable(SerializationFeature.INDENT_OUTPUT);
}
}
}
}

View File

@ -1,3 +1,10 @@
#flyway会自动建立该数据库
db:
# mysql, oracle, sqlserver
type: mysql
name: framework
username: root
password: root
# 数据源配置
spring:
datasource:
@ -6,9 +13,9 @@ spring:
druid:
# 主库数据源
master:
url: jdbc:mysql://localhost:3306/ry?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root
password: password
url: jdbc:mysql://localhost:3306/${db.name}?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: ${db.username}
password: ${db.password}
# 从库数据源
slave:
# 从数据源开关/默认关闭
@ -55,3 +62,19 @@ spring:
wall:
config:
multi-statement-allow: true
flyway:
enabled: true
url: jdbc:mysql://localhost:3306/mysql?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
user: ${db.username}
password: ${db.password}
#目标数据库已经存在,不自动升级
baseline-on-migrate: false
encoding: utf-8
clean-on-validation-error: false
clean-disabled: true
#数据库自动迁移的位置
locations: classpath:db/migration/${db.type}
# 需要管理的数据库
schemas: ${db.name}
sql-migration-prefix: v

View File

@ -31,8 +31,10 @@ server:
# 日志配置
logging:
level:
root: warn
com.ruoyi: debug
org.springframework: warn
com.ruoyi.quartz.mapper: warn
com.ruoyi.system.mapper: warn
# 用户配置
user:
@ -68,7 +70,21 @@ spring:
devtools:
restart:
# 热部署开关
enabled: true
enabled: false
jpa:
hibernate:
ddl-auto: update
use-new-id-generator-mappings: true
show-sql: true
database-platform: org.hibernate.dialect.MySQL55Dialect
open-in-view: false
properties:
hibernate:
format_sql: false
cache:
type: jcache
jcache:
provider: org.ehcache.jsr107.EhcacheCachingProvider
# MyBatis
mybatis:

View File

@ -0,0 +1,706 @@
-- ----------------------------
-- 1、部门表
-- ----------------------------
drop table if exists sys_dept;
create table sys_dept (
dept_id bigint(20) not null auto_increment comment '部门id',
parent_id bigint(20) default 0 comment '父部门id',
ancestors varchar(50) default '' comment '祖级列表',
dept_name varchar(30) default '' comment '部门名称',
order_num int(4) default 0 comment '显示顺序',
leader varchar(20) default null comment '负责人',
phone varchar(11) default null comment '联系电话',
email varchar(50) default null comment '邮箱',
status char(1) default '0' comment '部门状态0正常 1停用',
del_flag char(1) default '0' comment '删除标志0代表存在 2代表删除',
create_by varchar(64) default '' comment '创建者',
create_time datetime comment '创建时间',
update_by varchar(64) default '' comment '更新者',
update_time datetime comment '更新时间',
primary key (dept_id)
) engine=innodb auto_increment=200 comment = '部门表';
-- ----------------------------
-- 初始化-部门表数据
-- ----------------------------
insert into sys_dept values(100, 0, '0', '若依科技', 0, '若依', '15888888888', 'ry@qq.com', '0', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00');
insert into sys_dept values(101, 100, '0,100', '深圳总公司', 1, '若依', '15888888888', 'ry@qq.com', '0', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00');
insert into sys_dept values(102, 100, '0,100', '长沙分公司', 2, '若依', '15888888888', 'ry@qq.com', '0', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00');
insert into sys_dept values(103, 101, '0,100,101', '研发部门', 1, '若依', '15888888888', 'ry@qq.com', '0', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00');
insert into sys_dept values(104, 101, '0,100,101', '市场部门', 2, '若依', '15888888888', 'ry@qq.com', '0', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00');
insert into sys_dept values(105, 101, '0,100,101', '测试部门', 3, '若依', '15888888888', 'ry@qq.com', '0', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00');
insert into sys_dept values(106, 101, '0,100,101', '财务部门', 4, '若依', '15888888888', 'ry@qq.com', '0', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00');
insert into sys_dept values(107, 101, '0,100,101', '运维部门', 5, '若依', '15888888888', 'ry@qq.com', '0', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00');
insert into sys_dept values(108, 102, '0,100,102', '市场部门', 1, '若依', '15888888888', 'ry@qq.com', '0', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00');
insert into sys_dept values(109, 102, '0,100,102', '财务部门', 2, '若依', '15888888888', 'ry@qq.com', '0', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00');
-- ----------------------------
-- 2、用户信息表
-- ----------------------------
drop table if exists sys_user;
create table sys_user (
user_id bigint(20) not null auto_increment comment '用户ID',
dept_id bigint(20) default null comment '部门ID',
login_name varchar(30) not null comment '登录账号',
user_name varchar(30) default '' comment '用户昵称',
user_type varchar(2) default '00' comment '用户类型00系统用户 01注册用户',
email varchar(50) default '' comment '用户邮箱',
phonenumber varchar(11) default '' comment '手机号码',
sex char(1) default '0' comment '用户性别0男 1女 2未知',
avatar varchar(100) default '' comment '头像路径',
password varchar(50) default '' comment '密码',
salt varchar(20) default '' comment '盐加密',
status char(1) default '0' comment '帐号状态0正常 1停用',
del_flag char(1) default '0' comment '删除标志0代表存在 2代表删除',
login_ip varchar(50) default '' comment '最后登陆IP',
login_date datetime comment '最后登陆时间',
create_by varchar(64) default '' comment '创建者',
create_time datetime comment '创建时间',
update_by varchar(64) default '' comment '更新者',
update_time datetime comment '更新时间',
remark varchar(500) default null comment '备注',
primary key (user_id)
) engine=innodb auto_increment=100 comment = '用户信息表';
-- ----------------------------
-- 初始化-用户信息表数据
-- ----------------------------
insert into sys_user values(1, 103, 'admin', '若依', '00', 'ry@163.com', '15888888888', '1', '', '29c67a30398638269fe600f73a054934', '111111', '0', '0', '127.0.0.1', '2018-03-16 11-33-00', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '管理员');
insert into sys_user values(2, 105, 'ry', '若依', '00', 'ry@qq.com', '15666666666', '1', '', '8e6d98b90472783cc73c17047ddccf36', '222222', '0', '0', '127.0.0.1', '2018-03-16 11-33-00', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '测试员');
-- ----------------------------
-- 3、岗位信息表
-- ----------------------------
drop table if exists sys_post;
create table sys_post
(
post_id bigint(20) not null auto_increment comment '岗位ID',
post_code varchar(64) not null comment '岗位编码',
post_name varchar(50) not null comment '岗位名称',
post_sort int(4) not null comment '显示顺序',
status char(1) not null comment '状态0正常 1停用',
create_by varchar(64) default '' comment '创建者',
create_time datetime comment '创建时间',
update_by varchar(64) default '' comment '更新者',
update_time datetime comment '更新时间',
remark varchar(500) default null comment '备注',
primary key (post_id)
) engine=innodb comment = '岗位信息表';
-- ----------------------------
-- 初始化-岗位信息表数据
-- ----------------------------
insert into sys_post values(1, 'ceo', '董事长', 1, '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_post values(2, 'se', '项目经理', 2, '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_post values(3, 'hr', '人力资源', 3, '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_post values(4, 'user', '普通员工', 4, '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
-- ----------------------------
-- 4、角色信息表
-- ----------------------------
drop table if exists sys_role;
create table sys_role (
role_id bigint(20) not null auto_increment comment '角色ID',
role_name varchar(30) not null comment '角色名称',
role_key varchar(100) not null comment '角色权限字符串',
role_sort int(4) not null comment '显示顺序',
data_scope char(1) default '1' comment '数据范围1全部数据权限 2自定数据权限 3本部门数据权限 4本部门及以下数据权限',
status char(1) not null comment '角色状态0正常 1停用',
del_flag char(1) default '0' comment '删除标志0代表存在 2代表删除',
create_by varchar(64) default '' comment '创建者',
create_time datetime comment '创建时间',
update_by varchar(64) default '' comment '更新者',
update_time datetime comment '更新时间',
remark varchar(500) default null comment '备注',
primary key (role_id)
) engine=innodb auto_increment=100 comment = '角色信息表';
-- ----------------------------
-- 初始化-角色信息表数据
-- ----------------------------
insert into sys_role values('1', '超级管理员', 'admin', 1, 1, '0', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '超级管理员');
insert into sys_role values('2', '普通角色', 'common', 2, 2, '0', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '普通角色');
-- ----------------------------
-- 5、菜单权限表
-- ----------------------------
drop table if exists sys_menu;
create table sys_menu (
menu_id bigint(20) not null auto_increment comment '菜单ID',
menu_name varchar(50) not null comment '菜单名称',
parent_id bigint(20) default 0 comment '父菜单ID',
order_num int(4) default 0 comment '显示顺序',
url varchar(200) default '#' comment '请求地址',
target varchar(20) default '' comment '打开方式menuItem页签 menuBlank新窗口',
menu_type char(1) default '' comment '菜单类型M目录 C菜单 F按钮',
visible char(1) default 0 comment '菜单状态0显示 1隐藏',
perms varchar(100) default null comment '权限标识',
icon varchar(100) default '#' comment '菜单图标',
create_by varchar(64) default '' comment '创建者',
create_time datetime comment '创建时间',
update_by varchar(64) default '' comment '更新者',
update_time datetime comment '更新时间',
remark varchar(500) default '' comment '备注',
primary key (menu_id)
) engine=innodb auto_increment=2000 comment = '菜单权限表';
-- ----------------------------
-- 初始化-菜单信息表数据
-- ----------------------------
-- 一级菜单
insert into sys_menu values('1', '系统管理', '0', '1', '#', '', 'M', '0', '', 'fa fa-gear', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '系统管理目录');
insert into sys_menu values('2', '系统监控', '0', '2', '#', '', 'M', '0', '', 'fa fa-video-camera', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '系统监控目录');
insert into sys_menu values('3', '系统工具', '0', '3', '#', '', 'M', '0', '', 'fa fa-bars', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '系统工具目录');
insert into sys_menu values('4', '若依官网', '0', '4', 'http://ruoyi.vip', 'menuBlank', 'C', '0', '', 'fa fa-location-arrow', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '若依官网地址');
-- 二级菜单
insert into sys_menu values('100', '用户管理', '1', '1', '/system/user', '', 'C', '0', 'system:user:view', 'fa fa-user-o', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '用户管理菜单');
insert into sys_menu values('101', '角色管理', '1', '2', '/system/role', '', 'C', '0', 'system:role:view', 'fa fa-user-secret', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '角色管理菜单');
insert into sys_menu values('102', '菜单管理', '1', '3', '/system/menu', '', 'C', '0', 'system:menu:view', 'fa fa-th-list', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '菜单管理菜单');
insert into sys_menu values('103', '部门管理', '1', '4', '/system/dept', '', 'C', '0', 'system:dept:view', 'fa fa-outdent', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '部门管理菜单');
insert into sys_menu values('104', '岗位管理', '1', '5', '/system/post', '', 'C', '0', 'system:post:view', 'fa fa-address-card-o', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '岗位管理菜单');
insert into sys_menu values('105', '字典管理', '1', '6', '/system/dict', '', 'C', '0', 'system:dict:view', 'fa fa-bookmark-o', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '字典管理菜单');
insert into sys_menu values('106', '参数设置', '1', '7', '/system/config', '', 'C', '0', 'system:config:view', 'fa fa-sun-o', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '参数设置菜单');
insert into sys_menu values('107', '通知公告', '1', '8', '/system/notice', '', 'C', '0', 'system:notice:view', 'fa fa-bullhorn', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '通知公告菜单');
insert into sys_menu values('108', '日志管理', '1', '9', '#', '', 'M', '0', '', 'fa fa-pencil-square-o', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '日志管理菜单');
insert into sys_menu values('109', '在线用户', '2', '1', '/monitor/online', '', 'C', '0', 'monitor:online:view', 'fa fa-user-circle', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '在线用户菜单');
insert into sys_menu values('110', '定时任务', '2', '2', '/monitor/job', '', 'C', '0', 'monitor:job:view', 'fa fa-tasks', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '定时任务菜单');
insert into sys_menu values('111', '数据监控', '2', '3', '/monitor/data', '', 'C', '0', 'monitor:data:view', 'fa fa-bug', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '数据监控菜单');
insert into sys_menu values('112', '服务监控', '2', '3', '/monitor/server', '', 'C', '0', 'monitor:server:view', 'fa fa-server', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '服务监控菜单');
insert into sys_menu values('113', '表单构建', '3', '1', '/tool/build', '', 'C', '0', 'tool:build:view', 'fa fa-wpforms', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '表单构建菜单');
insert into sys_menu values('114', '代码生成', '3', '2', '/tool/gen', '', 'C', '0', 'tool:gen:view', 'fa fa-code', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '代码生成菜单');
insert into sys_menu values('115', '系统接口', '3', '3', '/tool/swagger', '', 'C', '0', 'tool:swagger:view', 'fa fa-gg', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '系统接口菜单');
-- 三级菜单
insert into sys_menu values('500', '操作日志', '108', '1', '/monitor/operlog', '', 'C', '0', 'monitor:operlog:view', 'fa fa-address-book', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '操作日志菜单');
insert into sys_menu values('501', '登录日志', '108', '2', '/monitor/logininfor', '', 'C', '0', 'monitor:logininfor:view', 'fa fa-file-image-o', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '登录日志菜单');
-- 用户管理按钮
insert into sys_menu values('1000', '用户查询', '100', '1', '#', '', 'F', '0', 'system:user:list', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1001', '用户新增', '100', '2', '#', '', 'F', '0', 'system:user:add', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1002', '用户修改', '100', '3', '#', '', 'F', '0', 'system:user:edit', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1003', '用户删除', '100', '4', '#', '', 'F', '0', 'system:user:remove', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1004', '用户导出', '100', '5', '#', '', 'F', '0', 'system:user:export', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1005', '用户导入', '100', '6', '#', '', 'F', '0', 'system:user:import', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1006', '重置密码', '100', '7', '#', '', 'F', '0', 'system:user:resetPwd', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
-- 角色管理按钮
insert into sys_menu values('1007', '角色查询', '101', '1', '#', '', 'F', '0', 'system:role:list', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1008', '角色新增', '101', '2', '#', '', 'F', '0', 'system:role:add', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1009', '角色修改', '101', '3', '#', '', 'F', '0', 'system:role:edit', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1010', '角色删除', '101', '4', '#', '', 'F', '0', 'system:role:remove', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1011', '角色导出', '101', '5', '#', '', 'F', '0', 'system:role:export', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
-- 菜单管理按钮
insert into sys_menu values('1012', '菜单查询', '102', '1', '#', '', 'F', '0', 'system:menu:list', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1013', '菜单新增', '102', '2', '#', '', 'F', '0', 'system:menu:add', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1014', '菜单修改', '102', '3', '#', '', 'F', '0', 'system:menu:edit', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1015', '菜单删除', '102', '4', '#', '', 'F', '0', 'system:menu:remove', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
-- 部门管理按钮
insert into sys_menu values('1016', '部门查询', '103', '1', '#', '', 'F', '0', 'system:dept:list', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1017', '部门新增', '103', '2', '#', '', 'F', '0', 'system:dept:add', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1018', '部门修改', '103', '3', '#', '', 'F', '0', 'system:dept:edit', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1019', '部门删除', '103', '4', '#', '', 'F', '0', 'system:dept:remove', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
-- 岗位管理按钮
insert into sys_menu values('1020', '岗位查询', '104', '1', '#', '', 'F', '0', 'system:post:list', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1021', '岗位新增', '104', '2', '#', '', 'F', '0', 'system:post:add', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1022', '岗位修改', '104', '3', '#', '', 'F', '0', 'system:post:edit', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1023', '岗位删除', '104', '4', '#', '', 'F', '0', 'system:post:remove', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1024', '岗位导出', '104', '5', '#', '', 'F', '0', 'system:post:export', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
-- 字典管理按钮
insert into sys_menu values('1025', '字典查询', '105', '1', '#', '', 'F', '0', 'system:dict:list', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1026', '字典新增', '105', '2', '#', '', 'F', '0', 'system:dict:add', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1027', '字典修改', '105', '3', '#', '', 'F', '0', 'system:dict:edit', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1028', '字典删除', '105', '4', '#', '', 'F', '0', 'system:dict:remove', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1029', '字典导出', '105', '5', '#', '', 'F', '0', 'system:dict:export', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
-- 参数设置按钮
insert into sys_menu values('1030', '参数查询', '106', '1', '#', '', 'F', '0', 'system:config:list', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1031', '参数新增', '106', '2', '#', '', 'F', '0', 'system:config:add', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1032', '参数修改', '106', '3', '#', '', 'F', '0', 'system:config:edit', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1033', '参数删除', '106', '4', '#', '', 'F', '0', 'system:config:remove', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1034', '参数导出', '106', '5', '#', '', 'F', '0', 'system:config:export', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
-- 通知公告按钮
insert into sys_menu values('1035', '公告查询', '107', '1', '#', '', 'F', '0', 'system:notice:list', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1036', '公告新增', '107', '2', '#', '', 'F', '0', 'system:notice:add', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1037', '公告修改', '107', '3', '#', '', 'F', '0', 'system:notice:edit', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1038', '公告删除', '107', '4', '#', '', 'F', '0', 'system:notice:remove', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
-- 操作日志按钮
insert into sys_menu values('1039', '操作查询', '500', '1', '#', '', 'F', '0', 'monitor:operlog:list', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1040', '操作删除', '500', '2', '#', '', 'F', '0', 'monitor:operlog:remove', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1041', '详细信息', '500', '3', '#', '', 'F', '0', 'monitor:operlog:detail', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1042', '日志导出', '500', '4', '#', '', 'F', '0', 'monitor:operlog:export', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
-- 登录日志按钮
insert into sys_menu values('1043', '登录查询', '501', '1', '#', '', 'F', '0', 'monitor:logininfor:list', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1044', '登录删除', '501', '2', '#', '', 'F', '0', 'monitor:logininfor:remove', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1045', '日志导出', '501', '3', '#', '', 'F', '0', 'monitor:logininfor:export', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1046', '账户解锁', '501', '4', '#', '', 'F', '0', 'monitor:logininfor:unlock', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
-- 在线用户按钮
insert into sys_menu values('1047', '在线查询', '109', '1', '#', '', 'F', '0', 'monitor:online:list', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1048', '批量强退', '109', '2', '#', '', 'F', '0', 'monitor:online:batchForceLogout', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1049', '单条强退', '109', '3', '#', '', 'F', '0', 'monitor:online:forceLogout', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
-- 定时任务按钮
insert into sys_menu values('1050', '任务查询', '110', '1', '#', '', 'F', '0', 'monitor:job:list', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1051', '任务新增', '110', '2', '#', '', 'F', '0', 'monitor:job:add', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1052', '任务修改', '110', '3', '#', '', 'F', '0', 'monitor:job:edit', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1053', '任务删除', '110', '4', '#', '', 'F', '0', 'monitor:job:remove', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1054', '状态修改', '110', '5', '#', '', 'F', '0', 'monitor:job:changeStatus', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1055', '任务详细', '110', '6', '#', '', 'F', '0', 'monitor:job:detail', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1056', '任务导出', '110', '7', '#', '', 'F', '0', 'monitor:job:export', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
-- 代码生成按钮
insert into sys_menu values('1057', '生成查询', '114', '1', '#', '', 'F', '0', 'tool:gen:list', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1058', '生成修改', '114', '2', '#', '', 'F', '0', 'tool:gen:edit', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1059', '生成删除', '114', '3', '#', '', 'F', '0', 'tool:gen:remove', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1060', '预览代码', '114', '4', '#', '', 'F', '0', 'tool:gen:preview', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1061', '生成代码', '114', '5', '#', '', 'F', '0', 'tool:gen:code', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
-- ----------------------------
-- 6、用户和角色关联表 用户N-1角色
-- ----------------------------
drop table if exists sys_user_role;
create table sys_user_role (
user_id bigint(20) not null comment '用户ID',
role_id bigint(20) not null comment '角色ID',
primary key(user_id, role_id)
) engine=innodb comment = '用户和角色关联表';
-- ----------------------------
-- 初始化-用户和角色关联表数据
-- ----------------------------
insert into sys_user_role values ('1', '1');
insert into sys_user_role values ('2', '2');
-- ----------------------------
-- 7、角色和菜单关联表 角色1-N菜单
-- ----------------------------
drop table if exists sys_role_menu;
create table sys_role_menu (
role_id bigint(20) not null comment '角色ID',
menu_id bigint(20) not null comment '菜单ID',
primary key(role_id, menu_id)
) engine=innodb comment = '角色和菜单关联表';
-- ----------------------------
-- 初始化-角色和菜单关联表数据
-- ----------------------------
insert into sys_role_menu values ('2', '1');
insert into sys_role_menu values ('2', '2');
insert into sys_role_menu values ('2', '3');
insert into sys_role_menu values ('2', '4');
insert into sys_role_menu values ('2', '100');
insert into sys_role_menu values ('2', '101');
insert into sys_role_menu values ('2', '102');
insert into sys_role_menu values ('2', '103');
insert into sys_role_menu values ('2', '104');
insert into sys_role_menu values ('2', '105');
insert into sys_role_menu values ('2', '106');
insert into sys_role_menu values ('2', '107');
insert into sys_role_menu values ('2', '108');
insert into sys_role_menu values ('2', '109');
insert into sys_role_menu values ('2', '110');
insert into sys_role_menu values ('2', '111');
insert into sys_role_menu values ('2', '112');
insert into sys_role_menu values ('2', '113');
insert into sys_role_menu values ('2', '114');
insert into sys_role_menu values ('2', '115');
insert into sys_role_menu values ('2', '500');
insert into sys_role_menu values ('2', '501');
insert into sys_role_menu values ('2', '1000');
insert into sys_role_menu values ('2', '1001');
insert into sys_role_menu values ('2', '1002');
insert into sys_role_menu values ('2', '1003');
insert into sys_role_menu values ('2', '1004');
insert into sys_role_menu values ('2', '1005');
insert into sys_role_menu values ('2', '1006');
insert into sys_role_menu values ('2', '1007');
insert into sys_role_menu values ('2', '1008');
insert into sys_role_menu values ('2', '1009');
insert into sys_role_menu values ('2', '1010');
insert into sys_role_menu values ('2', '1011');
insert into sys_role_menu values ('2', '1012');
insert into sys_role_menu values ('2', '1013');
insert into sys_role_menu values ('2', '1014');
insert into sys_role_menu values ('2', '1015');
insert into sys_role_menu values ('2', '1016');
insert into sys_role_menu values ('2', '1017');
insert into sys_role_menu values ('2', '1018');
insert into sys_role_menu values ('2', '1019');
insert into sys_role_menu values ('2', '1020');
insert into sys_role_menu values ('2', '1021');
insert into sys_role_menu values ('2', '1022');
insert into sys_role_menu values ('2', '1023');
insert into sys_role_menu values ('2', '1024');
insert into sys_role_menu values ('2', '1025');
insert into sys_role_menu values ('2', '1026');
insert into sys_role_menu values ('2', '1027');
insert into sys_role_menu values ('2', '1028');
insert into sys_role_menu values ('2', '1029');
insert into sys_role_menu values ('2', '1030');
insert into sys_role_menu values ('2', '1031');
insert into sys_role_menu values ('2', '1032');
insert into sys_role_menu values ('2', '1033');
insert into sys_role_menu values ('2', '1034');
insert into sys_role_menu values ('2', '1035');
insert into sys_role_menu values ('2', '1036');
insert into sys_role_menu values ('2', '1037');
insert into sys_role_menu values ('2', '1038');
insert into sys_role_menu values ('2', '1039');
insert into sys_role_menu values ('2', '1040');
insert into sys_role_menu values ('2', '1041');
insert into sys_role_menu values ('2', '1042');
insert into sys_role_menu values ('2', '1043');
insert into sys_role_menu values ('2', '1044');
insert into sys_role_menu values ('2', '1045');
insert into sys_role_menu values ('2', '1046');
insert into sys_role_menu values ('2', '1047');
insert into sys_role_menu values ('2', '1048');
insert into sys_role_menu values ('2', '1049');
insert into sys_role_menu values ('2', '1050');
insert into sys_role_menu values ('2', '1051');
insert into sys_role_menu values ('2', '1052');
insert into sys_role_menu values ('2', '1053');
insert into sys_role_menu values ('2', '1054');
insert into sys_role_menu values ('2', '1055');
insert into sys_role_menu values ('2', '1056');
insert into sys_role_menu values ('2', '1057');
insert into sys_role_menu values ('2', '1058');
insert into sys_role_menu values ('2', '1059');
insert into sys_role_menu values ('2', '1060');
insert into sys_role_menu values ('2', '1061');
-- ----------------------------
-- 8、角色和部门关联表 角色1-N部门
-- ----------------------------
drop table if exists sys_role_dept;
create table sys_role_dept (
role_id bigint(20) not null comment '角色ID',
dept_id bigint(20) not null comment '部门ID',
primary key(role_id, dept_id)
) engine=innodb comment = '角色和部门关联表';
-- ----------------------------
-- 初始化-角色和部门关联表数据
-- ----------------------------
insert into sys_role_dept values ('2', '100');
insert into sys_role_dept values ('2', '101');
insert into sys_role_dept values ('2', '105');
-- ----------------------------
-- 9、用户与岗位关联表 用户1-N岗位
-- ----------------------------
drop table if exists sys_user_post;
create table sys_user_post
(
user_id bigint(20) not null comment '用户ID',
post_id bigint(20) not null comment '岗位ID',
primary key (user_id, post_id)
) engine=innodb comment = '用户与岗位关联表';
-- ----------------------------
-- 初始化-用户与岗位关联表数据
-- ----------------------------
insert into sys_user_post values ('1', '1');
insert into sys_user_post values ('2', '2');
-- ----------------------------
-- 10、操作日志记录
-- ----------------------------
drop table if exists sys_oper_log;
create table sys_oper_log (
oper_id bigint(20) not null auto_increment comment '日志主键',
title varchar(50) default '' comment '模块标题',
business_type int(2) default 0 comment '业务类型0其它 1新增 2修改 3删除',
method varchar(100) default '' comment '方法名称',
request_method varchar(10) default '' comment '请求方式',
operator_type int(1) default 0 comment '操作类别0其它 1后台用户 2手机端用户',
oper_name varchar(50) default '' comment '操作人员',
dept_name varchar(50) default '' comment '部门名称',
oper_url varchar(255) default '' comment '请求URL',
oper_ip varchar(50) default '' comment '主机地址',
oper_location varchar(255) default '' comment '操作地点',
oper_param varchar(2000) default '' comment '请求参数',
json_result varchar(2000) default '' comment '返回参数',
status int(1) default 0 comment '操作状态0正常 1异常',
error_msg varchar(2000) default '' comment '错误消息',
oper_time datetime comment '操作时间',
primary key (oper_id)
) engine=innodb auto_increment=100 comment = '操作日志记录';
-- ----------------------------
-- 11、字典类型表
-- ----------------------------
drop table if exists sys_dict_type;
create table sys_dict_type
(
dict_id bigint(20) not null auto_increment comment '字典主键',
dict_name varchar(100) default '' comment '字典名称',
dict_type varchar(100) default '' comment '字典类型',
status char(1) default '0' comment '状态0正常 1停用',
create_by varchar(64) default '' comment '创建者',
create_time datetime comment '创建时间',
update_by varchar(64) default '' comment '更新者',
update_time datetime comment '更新时间',
remark varchar(500) default null comment '备注',
primary key (dict_id),
unique (dict_type)
) engine=innodb auto_increment=100 comment = '字典类型表';
insert into sys_dict_type values(1, '用户性别', 'sys_user_sex', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '用户性别列表');
insert into sys_dict_type values(2, '菜单状态', 'sys_show_hide', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '菜单状态列表');
insert into sys_dict_type values(3, '系统开关', 'sys_normal_disable', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '系统开关列表');
insert into sys_dict_type values(4, '任务状态', 'sys_job_status', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '任务状态列表');
insert into sys_dict_type values(5, '任务分组', 'sys_job_group', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '任务分组列表');
insert into sys_dict_type values(6, '系统是否', 'sys_yes_no', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '系统是否列表');
insert into sys_dict_type values(7, '通知类型', 'sys_notice_type', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '通知类型列表');
insert into sys_dict_type values(8, '通知状态', 'sys_notice_status', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '通知状态列表');
insert into sys_dict_type values(9, '操作类型', 'sys_oper_type', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '操作类型列表');
insert into sys_dict_type values(10, '系统状态', 'sys_common_status', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '登录状态列表');
-- ----------------------------
-- 12、字典数据表
-- ----------------------------
drop table if exists sys_dict_data;
create table sys_dict_data
(
dict_code bigint(20) not null auto_increment comment '字典编码',
dict_sort int(4) default 0 comment '字典排序',
dict_label varchar(100) default '' comment '字典标签',
dict_value varchar(100) default '' comment '字典键值',
dict_type varchar(100) default '' comment '字典类型',
css_class varchar(100) default null comment '样式属性(其他样式扩展)',
list_class varchar(100) default null comment '表格回显样式',
is_default char(1) default 'N' comment '是否默认Y是 N否',
status char(1) default '0' comment '状态0正常 1停用',
create_by varchar(64) default '' comment '创建者',
create_time datetime comment '创建时间',
update_by varchar(64) default '' comment '更新者',
update_time datetime comment '更新时间',
remark varchar(500) default null comment '备注',
primary key (dict_code)
) engine=innodb auto_increment=100 comment = '字典数据表';
insert into sys_dict_data values(1, 1, '', '0', 'sys_user_sex', '', '', 'Y', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '性别男');
insert into sys_dict_data values(2, 2, '', '1', 'sys_user_sex', '', '', 'N', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '性别女');
insert into sys_dict_data values(3, 3, '未知', '2', 'sys_user_sex', '', '', 'N', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '性别未知');
insert into sys_dict_data values(4, 1, '显示', '0', 'sys_show_hide', '', 'primary', 'Y', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '显示菜单');
insert into sys_dict_data values(5, 2, '隐藏', '1', 'sys_show_hide', '', 'danger', 'N', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '隐藏菜单');
insert into sys_dict_data values(6, 1, '正常', '0', 'sys_normal_disable', '', 'primary', 'Y', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '正常状态');
insert into sys_dict_data values(7, 2, '停用', '1', 'sys_normal_disable', '', 'danger', 'N', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '停用状态');
insert into sys_dict_data values(8, 1, '正常', '0', 'sys_job_status', '', 'primary', 'Y', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '正常状态');
insert into sys_dict_data values(9, 2, '暂停', '1', 'sys_job_status', '', 'danger', 'N', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '停用状态');
insert into sys_dict_data values(10, 1, '默认', 'DEFAULT', 'sys_job_group', '', '', 'Y', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '默认分组');
insert into sys_dict_data values(11, 2, '系统', 'SYSTEM', 'sys_job_group', '', '', 'N', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '系统分组');
insert into sys_dict_data values(12, 1, '', 'Y', 'sys_yes_no', '', 'primary', 'Y', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '系统默认是');
insert into sys_dict_data values(13, 2, '', 'N', 'sys_yes_no', '', 'danger', 'N', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '系统默认否');
insert into sys_dict_data values(14, 1, '通知', '1', 'sys_notice_type', '', 'warning', 'Y', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '通知');
insert into sys_dict_data values(15, 2, '公告', '2', 'sys_notice_type', '', 'success', 'N', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '公告');
insert into sys_dict_data values(16, 1, '正常', '0', 'sys_notice_status', '', 'primary', 'Y', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '正常状态');
insert into sys_dict_data values(17, 2, '关闭', '1', 'sys_notice_status', '', 'danger', 'N', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '关闭状态');
insert into sys_dict_data values(18, 99, '其他', '0', 'sys_oper_type', '', 'info', 'N', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '其他操作');
insert into sys_dict_data values(19, 1, '新增', '1', 'sys_oper_type', '', 'info', 'N', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '新增操作');
insert into sys_dict_data values(20, 2, '修改', '2', 'sys_oper_type', '', 'info', 'N', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '修改操作');
insert into sys_dict_data values(21, 3, '删除', '3', 'sys_oper_type', '', 'danger', 'N', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '删除操作');
insert into sys_dict_data values(22, 4, '授权', '4', 'sys_oper_type', '', 'primary', 'N', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '授权操作');
insert into sys_dict_data values(23, 5, '导出', '5', 'sys_oper_type', '', 'warning', 'N', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '导出操作');
insert into sys_dict_data values(24, 6, '导入', '6', 'sys_oper_type', '', 'warning', 'N', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '导入操作');
insert into sys_dict_data values(25, 7, '强退', '7', 'sys_oper_type', '', 'danger', 'N', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '强退操作');
insert into sys_dict_data values(26, 8, '生成代码', '8', 'sys_oper_type', '', 'warning', 'N', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '生成操作');
insert into sys_dict_data values(27, 9, '清空数据', '9', 'sys_oper_type', '', 'danger', 'N', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '清空操作');
insert into sys_dict_data values(28, 1, '成功', '0', 'sys_common_status', '', 'primary', 'N', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '正常状态');
insert into sys_dict_data values(29, 2, '失败', '1', 'sys_common_status', '', 'danger', 'N', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '停用状态');
-- ----------------------------
-- 13、参数配置表
-- ----------------------------
drop table if exists sys_config;
create table sys_config (
config_id int(5) not null auto_increment comment '参数主键',
config_name varchar(100) default '' comment '参数名称',
config_key varchar(100) default '' comment '参数键名',
config_value varchar(500) default '' comment '参数键值',
config_type char(1) default 'N' comment '系统内置Y是 N否',
create_by varchar(64) default '' comment '创建者',
create_time datetime comment '创建时间',
update_by varchar(64) default '' comment '更新者',
update_time datetime comment '更新时间',
remark varchar(500) default null comment '备注',
primary key (config_id)
) engine=innodb auto_increment=100 comment = '参数配置表';
insert into sys_config values(1, '主框架页-默认皮肤样式名称', 'sys.index.skinName', 'skin-blue', 'Y', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '蓝色 skin-blue、绿色 skin-green、紫色 skin-purple、红色 skin-red、黄色 skin-yellow');
insert into sys_config values(2, '用户管理-账号初始密码', 'sys.user.initPassword', '123456', 'Y', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '初始化密码 123456');
insert into sys_config values(3, '主框架页-侧边栏主题', 'sys.index.sideTheme', 'theme-dark', 'Y', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '深黑主题theme-dark浅色主题theme-light深蓝主题theme-blue');
insert into sys_config values(4, '账号自助-是否开启用户注册功能', 'sys.account.registerUser', 'false', 'Y', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '是否开启注册用户功能true开启false关闭');
insert into sys_config values(5, '用户管理-密码字符范围', 'sys.account.chrtype', '0', 'Y', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '默认任意字符范围0任意密码可以输入任意字符1数字密码只能为0-9数字2英文字母密码只能为a-z和A-Z字母3字母和数字密码必须包含字母数字,4字母数组和特殊字符密码必须包含字母数字特殊字符-_');
insert into sys_config values(6, '主框架页-菜单导航显示风格', 'sys.index.menuStyle', 'default', 'Y', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '菜单导航显示风格default为左侧导航菜单topnav为顶部导航菜单');
insert into sys_config values(7, '主框架页-是否开启页脚', 'sys.index.ignoreFooter', 'true', 'Y', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '是否开启底部页脚显示true显示false隐藏');
-- ----------------------------
-- 14、系统访问记录
-- ----------------------------
drop table if exists sys_logininfor;
create table sys_logininfor (
info_id bigint(20) not null auto_increment comment '访问ID',
login_name varchar(50) default '' comment '登录账号',
ipaddr varchar(50) default '' comment '登录IP地址',
login_location varchar(255) default '' comment '登录地点',
browser varchar(50) default '' comment '浏览器类型',
os varchar(50) default '' comment '操作系统',
status char(1) default '0' comment '登录状态0成功 1失败',
msg varchar(255) default '' comment '提示消息',
login_time datetime comment '访问时间',
primary key (info_id)
) engine=innodb auto_increment=100 comment = '系统访问记录';
-- ----------------------------
-- 15、在线用户记录
-- ----------------------------
drop table if exists sys_user_online;
create table sys_user_online (
sessionId varchar(50) default '' comment '用户会话id',
login_name varchar(50) default '' comment '登录账号',
dept_name varchar(50) default '' comment '部门名称',
ipaddr varchar(50) default '' comment '登录IP地址',
login_location varchar(255) default '' comment '登录地点',
browser varchar(50) default '' comment '浏览器类型',
os varchar(50) default '' comment '操作系统',
status varchar(10) default '' comment '在线状态on_line在线off_line离线',
start_timestamp datetime comment 'session创建时间',
last_access_time datetime comment 'session最后访问时间',
expire_time int(5) default 0 comment '超时时间,单位为分钟',
primary key (sessionId)
) engine=innodb comment = '在线用户记录';
-- ----------------------------
-- 16、定时任务调度表
-- ----------------------------
drop table if exists sys_job;
create table sys_job (
job_id bigint(20) not null auto_increment comment '任务ID',
job_name varchar(64) default '' comment '任务名称',
job_group varchar(64) default 'DEFAULT' comment '任务组名',
invoke_target varchar(500) not null comment '调用目标字符串',
cron_expression varchar(255) default '' comment 'cron执行表达式',
misfire_policy varchar(20) default '3' comment '计划执行错误策略1立即执行 2执行一次 3放弃执行',
concurrent char(1) default '1' comment '是否并发执行0允许 1禁止',
status char(1) default '0' comment '状态0正常 1暂停',
create_by varchar(64) default '' comment '创建者',
create_time datetime comment '创建时间',
update_by varchar(64) default '' comment '更新者',
update_time datetime comment '更新时间',
remark varchar(500) default '' comment '备注信息',
primary key (job_id, job_name, job_group)
) engine=innodb auto_increment=100 comment = '定时任务调度表';
insert into sys_job values(1, '系统默认(无参)', 'DEFAULT', 'ryTask.ryNoParams', '0/10 * * * * ?', '3', '1', '1', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_job values(2, '系统默认(有参)', 'DEFAULT', 'ryTask.ryParams(\'ry\')', '0/15 * * * * ?', '3', '1', '1', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_job values(3, '系统默认(多参)', 'DEFAULT', 'ryTask.ryMultipleParams(\'ry\', true, 2000L, 316.50D, 100)', '0/20 * * * * ?', '3', '1', '1', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
-- ----------------------------
-- 17、定时任务调度日志表
-- ----------------------------
drop table if exists sys_job_log;
create table sys_job_log (
job_log_id bigint(20) not null auto_increment comment '任务日志ID',
job_name varchar(64) not null comment '任务名称',
job_group varchar(64) not null comment '任务组名',
invoke_target varchar(500) not null comment '调用目标字符串',
job_message varchar(500) comment '日志信息',
status char(1) default '0' comment '执行状态0正常 1失败',
exception_info varchar(2000) default '' comment '异常信息',
create_time datetime comment '创建时间',
primary key (job_log_id)
) engine=innodb comment = '定时任务调度日志表';
-- ----------------------------
-- 18、通知公告表
-- ----------------------------
drop table if exists sys_notice;
create table sys_notice (
notice_id int(4) not null auto_increment comment '公告ID',
notice_title varchar(50) not null comment '公告标题',
notice_type char(1) not null comment '公告类型1通知 2公告',
notice_content varchar(2000) default null comment '公告内容',
status char(1) default '0' comment '公告状态0正常 1关闭',
create_by varchar(64) default '' comment '创建者',
create_time datetime comment '创建时间',
update_by varchar(64) default '' comment '更新者',
update_time datetime comment '更新时间',
remark varchar(255) default null comment '备注',
primary key (notice_id)
) engine=innodb auto_increment=10 comment = '通知公告表';
-- ----------------------------
-- 初始化-公告信息表数据
-- ----------------------------
insert into sys_notice values('1', '温馨提醒2018-07-01 若依新版本发布啦', '2', '新版本内容', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '管理员');
insert into sys_notice values('2', '维护通知2018-07-01 若依系统凌晨维护', '1', '维护内容', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '管理员');
-- ----------------------------
-- 19、代码生成业务表
-- ----------------------------
drop table if exists gen_table;
create table gen_table (
table_id bigint(20) not null auto_increment comment '编号',
table_name varchar(200) default '' comment '表名称',
table_comment varchar(500) default '' comment '表描述',
sub_table_name varchar(64) default null comment '关联子表的表名',
sub_table_fk_name varchar(64) default null comment '子表关联的外键名',
class_name varchar(100) default '' comment '实体类名称',
tpl_category varchar(200) default 'crud' comment '使用的模板crud单表操作 tree树表操作 sub主子表操作',
package_name varchar(100) comment '生成包路径',
module_name varchar(30) comment '生成模块名',
business_name varchar(30) comment '生成业务名',
function_name varchar(50) comment '生成功能名',
function_author varchar(50) comment '生成功能作者',
gen_type char(1) default '0' comment '生成代码方式0zip压缩包 1自定义路径',
gen_path varchar(200) default '/' comment '生成路径(不填默认项目路径)',
options varchar(1000) comment '其它生成选项',
create_by varchar(64) default '' comment '创建者',
create_time datetime comment '创建时间',
update_by varchar(64) default '' comment '更新者',
update_time datetime comment '更新时间',
remark varchar(500) default null comment '备注',
primary key (table_id)
) engine=innodb auto_increment=1 comment = '代码生成业务表';
-- ----------------------------
-- 20、代码生成业务表字段
-- ----------------------------
drop table if exists gen_table_column;
create table gen_table_column (
column_id bigint(20) not null auto_increment comment '编号',
table_id varchar(64) comment '归属表编号',
column_name varchar(200) comment '列名称',
column_comment varchar(500) comment '列描述',
column_type varchar(100) comment '列类型',
java_type varchar(500) comment 'JAVA类型',
java_field varchar(200) comment 'JAVA字段名',
is_pk char(1) comment '是否主键1是',
is_increment char(1) comment '是否自增1是',
is_required char(1) comment '是否必填1是',
is_insert char(1) comment '是否为插入字段1是',
is_edit char(1) comment '是否编辑字段1是',
is_list char(1) comment '是否列表字段1是',
is_query char(1) comment '是否查询字段1是',
query_type varchar(200) default 'EQ' comment '查询方式(等于、不等于、大于、小于、范围)',
html_type varchar(200) comment '显示类型(文本框、文本域、下拉框、复选框、单选框、日期控件)',
dict_type varchar(200) default '' comment '字典类型',
sort int comment '排序',
create_by varchar(64) default '' comment '创建者',
create_time datetime comment '创建时间',
update_by varchar(64) default '' comment '更新者',
update_time datetime comment '更新时间',
primary key (column_id)
) engine=innodb auto_increment=1 comment = '代码生成业务表字段';

View File

@ -0,0 +1 @@
UPDATE sys_menu SET parent_id = NULL WHERE parent_id = 0;

View File

@ -0,0 +1,5 @@
hibernate.cache.use_second_level_cache=true
hibernate.cache.region.factory_class=com.ruoyi.framework.ehcache.MyJCacheRegionFactory
hibernate.cache.use_query_cache=true
hibernate.generate_statistics=true
hibernate.javax.cache.uri=hibernate_2level_ehcache.xml

View File

@ -0,0 +1,23 @@
<config xmlns="http://www.ehcache.org/v3"
xmlns:jsr107="http://www.ehcache.org/v3/jsr107">
<service>
<jsr107:defaults enable-management="true" enable-statistics="false"/>
</service>
<!--指定缓存目录-->
<persistence directory="${java.io.tmpdir}/hibernate-ehcache"/>
<!--缓存模板-->
<cache-template name="default">
<expiry>
<tti>600</tti>
</expiry>
<resources>
<heap>500</heap>
</resources>
</cache-template>
<cache alias="com.ruoyi.system.domain.SysDept" uses-template="default"/>
</config>

View File

@ -6,7 +6,7 @@
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-dept-add">
<input id="treeId" name="parentId" type="hidden" th:value="${dept.deptId}" />
<input id="treeId" name="parent" type="hidden" th:value="${dept.deptId}" />
<div class="form-group">
<label class="col-sm-3 control-label">上级部门:</label>
<div class="col-sm-8">

View File

@ -29,7 +29,7 @@
</div>
<div class="btn-group-sm" id="toolbar" role="group">
<a class="btn btn-success" onclick="$.operate.add(100)" shiro:hasPermission="system:dept:add">
<a class="btn btn-success" onclick="$.operate.add(1)" shiro:hasPermission="system:dept:add">
<i class="fa fa-plus"></i> 新增
</a>
<a class="btn btn-primary" onclick="$.operate.edit()" shiro:hasPermission="system:dept:edit">
@ -50,13 +50,13 @@
var editFlag = [[${@permission.hasPermi('system:dept:edit')}]];
var removeFlag = [[${@permission.hasPermi('system:dept:remove')}]];
var datas = [[${@dict.getType('sys_normal_disable')}]];
var prefix = ctx + "system/dept"
var prefix = ctx + "system/dept";
$(function() {
var options = {
code: "deptId",
parentCode: "parentId",
uniqueId: "deptId",
rootIdValue: null,
url: prefix + "/list",
createUrl: prefix + "/add/{id}",
updateUrl: prefix + "/edit/{id}",

View File

@ -7,12 +7,12 @@
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-dept-edit" th:object="${dept}">
<input name="deptId" type="hidden" th:field="*{deptId}" />
<input id="treeId" name="parentId" type="hidden" th:field="*{parentId}" />
<input id="treeId" name="parent" type="hidden" th:field="*{parent.deptId}" />
<div class="form-group">
<label class="col-sm-3 control-label">上级部门:</label>
<div class="col-sm-8">
<div class="input-group">
<input class="form-control" type="text" id="treeName" onclick="selectDeptTree()" readonly="true" th:field="*{parentName}">
<input class="form-control" type="text" id="treeName" onclick="selectDeptTree()" readonly="true" th:field="*{parent.deptName}">
<span class="input-group-addon"><i class="fa fa-search"></i></span>
</div>
</div>

View File

@ -137,7 +137,7 @@
"roleSort": roleSort,
"status": status,
"remark": remark,
"menuIds": menuIds
"menus": menuIds
},
async : false,
error : function(request) {

View File

@ -101,7 +101,7 @@
function queryParams(params) {
var search = $.table.queryParams(params);
search.roleId = $("#roleId").val();
search.roles = $("#roleId").val();
return search;
}

View File

@ -8,7 +8,7 @@
<div class="main-content">
<form class="form-horizontal" id="form-user-edit" th:object="${user}">
<input name="userId" type="hidden" th:field="*{userId}" />
<input name="deptId" type="hidden" th:field="*{deptId}" id="treeId"/>
<input name="dept.deptId" type="hidden" th:field="*{dept.deptId}" id="treeId"/>
<h4 class="form-header h4">基本信息</h4>
<div class="row">
<div class="col-sm-6">
@ -58,7 +58,7 @@
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<label class="col-sm-4 control-label is-required">登录账号:</label>
<label class="col-sm-4 control-label"><span style="color: red; ">*</span>登录账号:</label>
<div class="col-sm-8">
<input class="form-control" type="text" readonly="true" th:field="*{loginName}"/>
</div>
@ -82,7 +82,7 @@
<label class="col-sm-4 control-label">岗位:</label>
<div class="col-sm-8">
<select id="post" class="form-control select2-multiple" multiple>
<option th:each="post:${posts}" th:value="${post.postId}" th:text="${post.postName}" th:selected="${post.flag}" th:disabled="${post.status == '1'}"></option>
<option th:each="post:${posts}" th:value="${post.postId}" th:text="${post.postName}" th:selected="${post.flag}" th:disabled="${post.status == '1'}" th:field="*{posts}"></option>
</select>
</div>
</div>
@ -104,7 +104,7 @@
<label class="col-xs-2 control-label">角色:</label>
<div class="col-xs-10">
<label th:each="role:${roles}" class="check-box">
<input name="role" type="checkbox" th:value="${role.roleId}" th:text="${role.roleName}" th:checked="${role.flag}" th:disabled="${role.status == '1'}">
<input name="role" type="checkbox" th:value="${role.roleId}" th:text="${role.roleName}" th:checked="${role.flag}" th:disabled="${role.status == '1'}" th:field="*{roles}">
</label>
</div>
</div>
@ -194,8 +194,8 @@
var roleIds = $.form.selectCheckeds("role");
var postIds = $.form.selectSelects("post");
data.push({"name": "status", "value": status});
data.push({"name": "roleIds", "value": roleIds});
data.push({"name": "postIds", "value": postIds});
data.push({"name": "roles", "value": roleIds});
data.push({"name": "posts", "value": postIds});
$.operate.saveTab(prefix + "/edit", data);
}
}

View File

@ -101,6 +101,23 @@
<artifactId>javax.servlet-api</artifactId>
</dependency>
<!-- spring.data.jpa -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>com.querydsl</groupId>
<artifactId>querydsl-jpa</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -11,18 +11,13 @@ import java.lang.annotation.Target;
*
* @author ruoyi
*/
@Target(ElementType.METHOD)
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface DataScope
{
public @interface DataScope {
/**
* 部门表的别名
* 业务表的所属用户的字段名称过滤仅本人的数据权限,
* 该字段的类型为{@link com.ruoyi.system.domain.SysUser}
*/
public String deptAlias() default "";
/**
* 用户表的别名
*/
public String userAlias() default "";
String userFieldName() default "";
}

View File

@ -0,0 +1,25 @@
package com.ruoyi.common.annotation;
public enum DataScopes implements Comparable<DataScopes>{
/**
* 全部数据权限
*/
DATA_SCOPE_ALL,
/**
* 自定数据权限
*/
DATA_SCOPE_CUSTOM,
/**
* 部门数据权限
*/
DATA_SCOPE_DEPT,
/**
* 部门及以下数据权限
*/
DATA_SCOPE_DEPT_AND_CHILD,
/**
* 仅本人数据权限
*/
DATA_SCOPE_SELF,
;
}

View File

@ -6,21 +6,19 @@ import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import com.ruoyi.common.enums.DataSourceType;
/**
* 自定义多数据源切换注解
*
* 优先级先方法后类如果方法覆盖了类上的数据源类型以方法的为准否则以类上的为准
*
* @author ruoyi
*/
@Target({ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
public @interface DataSource
{
public @interface DataSource {
/**
* 切换数据源名称
*/

View File

@ -12,7 +12,6 @@ import java.lang.annotation.Target;
*/
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
public @interface Excels
{
public @interface Excels {
Excel[] value();
}

View File

@ -5,6 +5,7 @@ import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.enums.OperatorType;
@ -16,8 +17,7 @@ import com.ruoyi.common.enums.OperatorType;
@Target({ElementType.PARAMETER, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface Log
{
public @interface Log {
/**
* 模块
*/

View File

@ -10,12 +10,10 @@ import java.lang.annotation.Target;
* 自定义注解防止表单重复提交
*
* @author ruoyi
*
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface RepeatSubmit
{
public @interface RepeatSubmit {
}

View File

@ -0,0 +1,15 @@
package com.ruoyi.common.base;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.querydsl.QuerydslPredicateExecutor;
import org.springframework.data.repository.NoRepositoryBean;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.Predicate;
@NoRepositoryBean
public interface BaseRepository<T, ID> extends JpaRepository<T, ID>,
JpaSpecificationExecutor<T>,
QuerydslPredicateExecutor<T> {
}

View File

@ -0,0 +1,35 @@
package com.ruoyi.common.base;
import com.querydsl.core.types.dsl.*;
import com.ruoyi.common.utils.querydsl.ExpressionUtils;
public class BaseService {
protected BooleanExpression buildLike(StringPath path, String value){
return ExpressionUtils.buildLike(path, value);
}
protected <T extends Comparable<T>> BooleanExpression buildEqual(ComparableExpressionBase<T> path, T value){
return ExpressionUtils.buildEqual(path, value);
}
protected <T extends Number & Comparable<T>> BooleanExpression buildEqual(NumberPath<T> path, T value){
return ExpressionUtils.buildEqual(path, value);
}
protected <T extends Comparable<T>> BooleanExpression buildGreaterThanOrEqualTo(ComparableExpression<T> path, T value){
return ExpressionUtils.buildGreaterThanOrEqualTo(path, value);
}
protected <T extends Comparable<T>> BooleanExpression buildLessThanOrEqualTo(ComparableExpression<T> path, T value){
return ExpressionUtils.buildLessThanOrEqualTo(path, value);
}
protected BooleanExpression notLike(StringPath path, String value){
return ExpressionUtils.notLike(path, value);
}
protected BooleanExpression notStartWith(StringPath path, String value){
return ExpressionUtils.notStartWith(path, value);
}
}

View File

@ -10,107 +10,103 @@ import org.springframework.stereotype.Component;
*/
@Component
@ConfigurationProperties(prefix = "ruoyi")
public class Global
{
/** 项目名称 */
public class Global {
/**
* 项目名称
*/
private static String name;
/** 版本 */
/**
* 版本
*/
private static String version;
/** 版权年份 */
/**
* 版权年份
*/
private static String copyrightYear;
/** 实例演示开关 */
/**
* 实例演示开关
*/
private static boolean demoEnabled;
/** 上传路径 */
/**
* 上传路径
*/
private static String profile;
/** 获取地址开关 */
/**
* 获取地址开关
*/
private static boolean addressEnabled;
public static String getName()
{
public static String getName() {
return name;
}
public void setName(String name)
{
public void setName(String name) {
Global.name = name;
}
public static String getVersion()
{
public static String getVersion() {
return version;
}
public void setVersion(String version)
{
public void setVersion(String version) {
Global.version = version;
}
public static String getCopyrightYear()
{
public static String getCopyrightYear() {
return copyrightYear;
}
public void setCopyrightYear(String copyrightYear)
{
public void setCopyrightYear(String copyrightYear) {
Global.copyrightYear = copyrightYear;
}
public static boolean isDemoEnabled()
{
public static boolean isDemoEnabled() {
return demoEnabled;
}
public void setDemoEnabled(boolean demoEnabled)
{
public void setDemoEnabled(boolean demoEnabled) {
Global.demoEnabled = demoEnabled;
}
public static String getProfile()
{
public static String getProfile() {
return profile;
}
public void setProfile(String profile)
{
public void setProfile(String profile) {
Global.profile = profile;
}
public static boolean isAddressEnabled()
{
public static boolean isAddressEnabled() {
return addressEnabled;
}
public void setAddressEnabled(boolean addressEnabled)
{
public void setAddressEnabled(boolean addressEnabled) {
Global.addressEnabled = addressEnabled;
}
/**
* 获取头像上传路径
*/
public static String getAvatarPath()
{
public static String getAvatarPath() {
return getProfile() + "/avatar";
}
/**
* 获取下载路径
*/
public static String getDownloadPath()
{
public static String getDownloadPath() {
return getProfile() + "/download/";
}
/**
* 获取上传路径
*/
public static String getUploadPath()
{
public static String getUploadPath() {
return getProfile() + "/upload";
}
}

View File

@ -1,6 +1,7 @@
package com.ruoyi.common.config;
import javax.servlet.http.HttpServletRequest;
import org.springframework.stereotype.Component;
import com.ruoyi.common.utils.ServletUtils;
@ -8,24 +9,20 @@ import com.ruoyi.common.utils.ServletUtils;
* 服务相关配置
*
* @author ruoyi
*
*/
@Component
public class ServerConfig
{
public class ServerConfig {
/**
* 获取完整的请求路径包括域名端口上下文访问路径
*
* @return 服务地址
*/
public String getUrl()
{
public String getUrl() {
HttpServletRequest request = ServletUtils.getRequest();
return getDomain(request);
}
public static String getDomain(HttpServletRequest request)
{
public static String getDomain(HttpServletRequest request) {
StringBuffer url = request.getRequestURL();
String contextPath = request.getServletContext().getContextPath();
return url.delete(url.length() - request.getRequestURI().length(), url.length()).append(contextPath).toString();

View File

@ -8,8 +8,7 @@ import org.slf4j.LoggerFactory;
*
* @author ruoyi
*/
public class DynamicDataSourceContextHolder
{
public class DynamicDataSourceContextHolder {
public static final Logger log = LoggerFactory.getLogger(DynamicDataSourceContextHolder.class);
/**
@ -21,8 +20,7 @@ public class DynamicDataSourceContextHolder
/**
* 设置数据源的变量
*/
public static void setDataSourceType(String dsType)
{
public static void setDataSourceType(String dsType) {
log.info("切换到{}数据源", dsType);
CONTEXT_HOLDER.set(dsType);
}
@ -30,16 +28,14 @@ public class DynamicDataSourceContextHolder
/**
* 获得数据源的变量
*/
public static String getDataSourceType()
{
public static String getDataSourceType() {
return CONTEXT_HOLDER.get();
}
/**
* 清空数据源变量
*/
public static void clearDataSourceType()
{
public static void clearDataSourceType() {
CONTEXT_HOLDER.remove();
}
}

View File

@ -3,6 +3,7 @@ package com.ruoyi.common.config.thread;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.ThreadPoolExecutor;
import org.apache.commons.lang3.concurrent.BasicThreadFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@ -15,8 +16,7 @@ import com.ruoyi.common.utils.Threads;
* @author ruoyi
**/
@Configuration
public class ThreadPoolConfig
{
public class ThreadPoolConfig {
// 核心线程池大小
private int corePoolSize = 50;
@ -30,8 +30,7 @@ public class ThreadPoolConfig
private int keepAliveSeconds = 300;
@Bean(name = "threadPoolTaskExecutor")
public ThreadPoolTaskExecutor threadPoolTaskExecutor()
{
public ThreadPoolTaskExecutor threadPoolTaskExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setMaxPoolSize(maxPoolSize);
executor.setCorePoolSize(corePoolSize);
@ -46,14 +45,11 @@ public class ThreadPoolConfig
* 执行周期性或定时任务
*/
@Bean(name = "scheduledExecutorService")
protected ScheduledExecutorService scheduledExecutorService()
{
protected ScheduledExecutorService scheduledExecutorService() {
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
protected void afterExecute(Runnable r, Throwable t)
{
protected void afterExecute(Runnable r, Throwable t) {
super.afterExecute(r, t);
Threads.printException(r, t);
}

View File

@ -5,8 +5,7 @@ package com.ruoyi.common.constant;
*
* @author ruoyi
*/
public class Constants
{
public class Constants {
/**
* UTF-8 字符集
*/
@ -47,6 +46,11 @@ public class Constants
*/
public static final String LOGIN_FAIL = "Error";
/**
* 自动去除表前缀
*/
public static final String AUTO_REOMVE_PRE = "true";
/**
* 当前记录起始索引
*/

View File

@ -5,23 +5,34 @@ package com.ruoyi.common.constant;
*
* @author ruoyi
*/
public class PermissionConstants
{
/** 新增权限 */
public class PermissionConstants {
/**
* 新增权限
*/
public static final String ADD_PERMISSION = "add";
/** 修改权限 */
/**
* 修改权限
*/
public static final String EDIT_PERMISSION = "edit";
/** 删除权限 */
/**
* 删除权限
*/
public static final String REMOVE_PERMISSION = "remove";
/** 导出权限 */
/**
* 导出权限
*/
public static final String EXPORT_PERMISSION = "export";
/** 显示权限 */
/**
* 显示权限
*/
public static final String VIEW_PERMISSION = "view";
/** 查询权限 */
/**
* 查询权限
*/
public static final String LIST_PERMISSION = "list";
}

View File

@ -1,17 +1,5 @@
package com.ruoyi.common.core.controller;
import java.beans.PropertyEditorSupport;
import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.AjaxResult.Type;
import com.ruoyi.common.core.page.PageDomain;
@ -21,95 +9,98 @@ import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.ServletUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.sql.SqlUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.beans.PropertyEditorSupport;
import java.util.Date;
import java.util.List;
/**
* web层通用数据处理
*
* @author ruoyi
*/
public class BaseController
{
public class BaseController {
protected final Logger logger = LoggerFactory.getLogger(BaseController.class);
/**
* 将前台传递过来的日期格式的字符串自动转化为Date类型
*/
@InitBinder
public void initBinder(WebDataBinder binder)
{
public void initBinder(WebDataBinder binder) {
// Date 类型转换
binder.registerCustomEditor(Date.class, new PropertyEditorSupport()
{
binder.registerCustomEditor(Date.class, new PropertyEditorSupport() {
@Override
public void setAsText(String text)
{
public void setAsText(String text) {
setValue(DateUtils.parseDate(text));
}
});
}
/**
* 设置请求分页数据
*/
protected void startPage()
{
PageDomain pageDomain = TableSupport.buildPageRequest();
Integer pageNum = pageDomain.getPageNum();
Integer pageSize = pageDomain.getPageSize();
if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize))
{
String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy());
PageHelper.startPage(pageNum, pageSize, orderBy);
}
}
/**
* 设置请求排序数据
*/
protected void startOrderBy()
{
PageDomain pageDomain = TableSupport.buildPageRequest();
if (StringUtils.isNotEmpty(pageDomain.getOrderBy()))
{
String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy());
PageHelper.orderBy(orderBy);
}
}
/**
* 获取request
*/
public HttpServletRequest getRequest()
{
public HttpServletRequest getRequest() {
return ServletUtils.getRequest();
}
/**
* 获取response
*/
public HttpServletResponse getResponse()
{
public HttpServletResponse getResponse() {
return ServletUtils.getResponse();
}
/**
* 获取session
*/
public HttpSession getSession()
{
public HttpSession getSession() {
return getRequest().getSession();
}
/**
* 设置请求分页数据
*/
protected Pageable getPageRequest() {
PageDomain pageDomain = TableSupport.buildPageRequest();
Integer pageNum = pageDomain.getPageNum();
Integer pageSize = pageDomain.getPageSize();
if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize)) {
String attribute = pageDomain.getOrderByColumn();
if(StringUtils.isNotEmpty(attribute)){
Sort.Order order = null;
if("desc".equals(pageDomain.getIsAsc())){
order = Sort.Order.desc(attribute);
}else{
order = Sort.Order.asc(attribute);
}
return PageRequest.of(pageNum-1, pageSize, Sort.by(order));
}else{
return PageRequest.of(pageNum-1, pageSize);
}
}else{
return PageRequest.of(0,10);
}
}
/**
* 响应请求分页数据
*/
@SuppressWarnings({"rawtypes", "unchecked"})
protected TableDataInfo getDataTable(List<?> list)
{
protected TableDataInfo getDataTable(org.springframework.data.domain.Page<?> page) {
TableDataInfo rspData = new TableDataInfo();
rspData.setCode(0);
rspData.setRows(list);
rspData.setTotal(new PageInfo(list).getTotal());
rspData.setRows(page.getContent());
rspData.setTotal(page.getTotalElements());
return rspData;
}
@ -119,8 +110,7 @@ public class BaseController
* @param rows 影响行数
* @return 操作结果
*/
protected AjaxResult toAjax(int rows)
{
protected AjaxResult toAjax(int rows) {
return rows > 0 ? success() : error();
}
@ -130,56 +120,56 @@ public class BaseController
* @param result 结果
* @return 操作结果
*/
protected AjaxResult toAjax(boolean result)
{
protected AjaxResult toAjax(boolean result) {
return result ? success() : error();
}
/**
* 返回成功
*/
public AjaxResult success()
{
public AjaxResult success() {
return AjaxResult.success();
}
public <T> AjaxResult success(T data) {
AjaxResult result = AjaxResult.success();
result.put("data", data);
return result;
}
/**
* 返回失败消息
*/
public AjaxResult error()
{
public AjaxResult error() {
return AjaxResult.error();
}
/**
* 返回成功消息
*/
public AjaxResult success(String message)
{
public AjaxResult success(String message) {
return AjaxResult.success(message);
}
/**
* 返回失败消息
*/
public AjaxResult error(String message)
{
public AjaxResult error(String message) {
return AjaxResult.error(message);
}
/**
* 返回错误码消息
*/
public AjaxResult error(Type type, String message)
{
public AjaxResult error(Type type, String message) {
return new AjaxResult(type, message);
}
/**
* 页面跳转
*/
public String redirect(String url)
{
public String redirect(String url) {
return StringUtils.format("redirect:{}", url);
}
}

View File

@ -1,6 +1,7 @@
package com.ruoyi.common.core.domain;
import java.util.HashMap;
import com.ruoyi.common.utils.StringUtils;
/**
@ -8,39 +9,47 @@ import com.ruoyi.common.utils.StringUtils;
*
* @author ruoyi
*/
public class AjaxResult extends HashMap<String, Object>
{
public class AjaxResult extends HashMap<String, Object> {
private static final long serialVersionUID = 1L;
/** 状态码 */
/**
* 状态码
*/
public static final String CODE_TAG = "code";
/** 返回内容 */
/**
* 返回内容
*/
public static final String MSG_TAG = "msg";
/** 数据对象 */
/**
* 数据对象
*/
public static final String DATA_TAG = "data";
/**
* 状态类型
*/
public enum Type
{
/** 成功 */
public enum Type {
/**
* 成功
*/
SUCCESS(0),
/** 警告 */
/**
* 警告
*/
WARN(301),
/** 错误 */
/**
* 错误
*/
ERROR(500);
private final int value;
Type(int value)
{
Type(int value) {
this.value = value;
}
public int value()
{
public int value() {
return this.value;
}
}
@ -48,8 +57,7 @@ public class AjaxResult extends HashMap<String, Object>
/**
* 初始化一个新创建的 AjaxResult 对象使其表示一个空消息
*/
public AjaxResult()
{
public AjaxResult() {
}
/**
@ -58,8 +66,7 @@ public class AjaxResult extends HashMap<String, Object>
* @param type 状态类型
* @param msg 返回内容
*/
public AjaxResult(Type type, String msg)
{
public AjaxResult(Type type, String msg) {
super.put(CODE_TAG, type.value);
super.put(MSG_TAG, msg);
}
@ -71,12 +78,10 @@ public class AjaxResult extends HashMap<String, Object>
* @param msg 返回内容
* @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(MSG_TAG, msg);
if (StringUtils.isNotNull(data))
{
if (StringUtils.isNotNull(data)) {
super.put(DATA_TAG, data);
}
}
@ -86,8 +91,7 @@ public class AjaxResult extends HashMap<String, Object>
*
* @return 成功消息
*/
public static AjaxResult success()
{
public static AjaxResult success() {
return AjaxResult.success("操作成功");
}
@ -96,8 +100,7 @@ public class AjaxResult extends HashMap<String, Object>
*
* @return 成功消息
*/
public static AjaxResult success(Object data)
{
public static AjaxResult success(Object data) {
return AjaxResult.success("操作成功", data);
}
@ -107,8 +110,7 @@ public class AjaxResult extends HashMap<String, Object>
* @param msg 返回内容
* @return 成功消息
*/
public static AjaxResult success(String msg)
{
public static AjaxResult success(String msg) {
return AjaxResult.success(msg, null);
}
@ -119,8 +121,7 @@ public class AjaxResult extends HashMap<String, Object>
* @param data 数据对象
* @return 成功消息
*/
public static AjaxResult success(String msg, Object data)
{
public static AjaxResult success(String msg, Object data) {
return new AjaxResult(Type.SUCCESS, msg, data);
}
@ -130,8 +131,7 @@ public class AjaxResult extends HashMap<String, Object>
* @param msg 返回内容
* @return 警告消息
*/
public static AjaxResult warn(String msg)
{
public static AjaxResult warn(String msg) {
return AjaxResult.warn(msg, null);
}
@ -142,8 +142,7 @@ public class AjaxResult extends HashMap<String, Object>
* @param data 数据对象
* @return 警告消息
*/
public static AjaxResult warn(String msg, Object data)
{
public static AjaxResult warn(String msg, Object data) {
return new AjaxResult(Type.WARN, msg, data);
}
@ -152,8 +151,7 @@ public class AjaxResult extends HashMap<String, Object>
*
* @return
*/
public static AjaxResult error()
{
public static AjaxResult error() {
return AjaxResult.error("操作失败");
}
@ -163,8 +161,7 @@ public class AjaxResult extends HashMap<String, Object>
* @param msg 返回内容
* @return 警告消息
*/
public static AjaxResult error(String msg)
{
public static AjaxResult error(String msg) {
return AjaxResult.error(msg, null);
}
@ -175,8 +172,7 @@ public class AjaxResult extends HashMap<String, Object>
* @param data 数据对象
* @return 警告消息
*/
public static AjaxResult error(String msg, Object data)
{
public static AjaxResult error(String msg, Object data) {
return new AjaxResult(Type.ERROR, msg, data);
}
}

View File

@ -0,0 +1,123 @@
package com.ruoyi.common.core.domain;
import com.ruoyi.common.core.domain.enums.ActiveState;
import com.ruoyi.common.core.domain.enums.DeleteState;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
@MappedSuperclass
@EntityListeners(AuditingEntityListener.class)
public class BaseDatabaseEntity implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@CreatedDate
@Column(updatable = false)
private Date createDate;
@CreatedBy
@Column(updatable = false)
private Long createBy;
@LastModifiedDate
private Date updateDate;
@LastModifiedBy
private Long updateBy;
/**
* 删除状态
*/
private DeleteState deleteState = DeleteState.NOT_DELETED;
/**
* 启用状态
*/
private ActiveState activeState = ActiveState.enabled;
@Version
private Integer version;
private String remark;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Date getCreateDate() {
return createDate;
}
public void setCreateDate(Date createDate) {
this.createDate = createDate;
}
public Long getCreateBy() {
return createBy;
}
public void setCreateBy(Long createBy) {
this.createBy = createBy;
}
public Date getUpdateDate() {
return updateDate;
}
public void setUpdateDate(Date updateDate) {
this.updateDate = updateDate;
}
public Long getUpdateBy() {
return updateBy;
}
public void setUpdateBy(Long updateBy) {
this.updateBy = updateBy;
}
public DeleteState getDeleteState() {
return deleteState;
}
public void setDeleteState(DeleteState deleteState) {
this.deleteState = deleteState;
}
public Integer getVersion() {
return version;
}
public void setVersion(Integer version) {
this.version = version;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public ActiveState getActiveState() {
return activeState;
}
public void setActiveState(ActiveState activeState) {
this.activeState = activeState;
}
}

View File

@ -1,114 +1,162 @@
package com.ruoyi.common.core.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.Column;
import javax.persistence.EntityListeners;
import javax.persistence.MappedSuperclass;
import javax.persistence.Transient;
import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import com.fasterxml.jackson.annotation.JsonFormat;
/**
* Entity基类
*
* @author ruoyi
*/
public class BaseEntity implements Serializable
{
@MappedSuperclass
@EntityListeners(AuditingEntityListener.class)
@SelectBeforeUpdate
@DynamicUpdate
public class BaseEntity implements Serializable {
public static final String NOT_DELETED = "0";
public static final String DELETED = "1";
private static final long serialVersionUID = 1L;
/** 搜索值 */
/**
* 搜索值
*/
@Transient
private String searchValue;
/** 创建者 */
/**
* 创建者
*/
@CreatedBy
@Column(updatable = false)
private String createBy;
/** 创建时间 */
/**
* 创建时间
*/
@CreatedDate
@Column(updatable = false)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
/** 更新者 */
/**
* 更新者
*/
@LastModifiedBy
private String updateBy;
/** 更新时间 */
/**
* 更新时间
*/
@LastModifiedDate
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date updateTime;
/** 备注 */
/**
* 备注
*/
private String remark;
/** 请求参数 */
/**
* 请求参数
*/
@Transient
private Map<String, Object> params;
public String getSearchValue()
{
@Transient
private Date startTime;
@Transient
private Date endTime;
public String getSearchValue() {
return searchValue;
}
public void setSearchValue(String searchValue)
{
public void setSearchValue(String searchValue) {
this.searchValue = searchValue;
}
public String getCreateBy()
{
public String getCreateBy() {
return createBy;
}
public void setCreateBy(String createBy)
{
public void setCreateBy(String createBy) {
this.createBy = createBy;
}
public Date getCreateTime()
{
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime)
{
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public String getUpdateBy()
{
public String getUpdateBy() {
return updateBy;
}
public void setUpdateBy(String updateBy)
{
public void setUpdateBy(String updateBy) {
this.updateBy = updateBy;
}
public Date getUpdateTime()
{
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime)
{
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public String getRemark()
{
public String getRemark() {
return remark;
}
public void setRemark(String remark)
{
public void setRemark(String remark) {
this.remark = remark;
}
public Map<String, Object> getParams()
{
if (params == null)
{
public Map<String, Object> getParams() {
if (params == null) {
params = new HashMap<>();
}
return params;
}
public void setParams(Map<String, Object> params)
{
public void setParams(Map<String, Object> params) {
this.params = params;
}
public Date getStartTime() {
return startTime;
}
public void setStartTime(Date startTime) {
this.startTime = startTime;
}
public Date getEndTime() {
return endTime;
}
public void setEndTime(Date endTime) {
this.endTime = endTime;
}
}

View File

@ -5,59 +5,58 @@ package com.ruoyi.common.core.domain;
*
* @author ruoyi
*/
public class TreeEntity extends BaseEntity
{
public class TreeEntity extends BaseEntity {
private static final long serialVersionUID = 1L;
/** 父菜单名称 */
/**
* 父菜单名称
*/
private String parentName;
/** 父菜单ID */
/**
* 父菜单ID
*/
private Long parentId;
/** 显示顺序 */
/**
* 显示顺序
*/
private Integer orderNum;
/** 祖级列表 */
/**
* 祖级列表
*/
private String ancestors;
public String getParentName()
{
public String getParentName() {
return parentName;
}
public void setParentName(String parentName)
{
public void setParentName(String parentName) {
this.parentName = parentName;
}
public Long getParentId()
{
public Long getParentId() {
return parentId;
}
public void setParentId(Long parentId)
{
public void setParentId(Long parentId) {
this.parentId = parentId;
}
public Integer getOrderNum()
{
public Integer getOrderNum() {
return orderNum;
}
public void setOrderNum(Integer orderNum)
{
public void setOrderNum(Integer orderNum) {
this.orderNum = orderNum;
}
public String getAncestors()
{
public String getAncestors() {
return ancestors;
}
public void setAncestors(String ancestors)
{
public void setAncestors(String ancestors) {
this.ancestors = ancestors;
}
}

View File

@ -7,98 +7,97 @@ import java.io.Serializable;
*
* @author ruoyi
*/
public class Ztree implements Serializable
{
public class Ztree implements Serializable {
private static final long serialVersionUID = 1L;
/** 节点ID */
/**
* 节点ID
*/
private Long id;
/** 节点父ID */
/**
* 节点父ID
*/
private Long pId;
/** 节点名称 */
/**
* 节点名称
*/
private String name;
/** 节点标题 */
/**
* 节点标题
*/
private String title;
/** 是否勾选 */
/**
* 是否勾选
*/
private boolean checked = false;
/** 是否展开 */
/**
* 是否展开
*/
private boolean open = false;
/** 是否能勾选 */
/**
* 是否能勾选
*/
private boolean nocheck = false;
public Long getId()
{
public Long getId() {
return id;
}
public void setId(Long id)
{
public void setId(Long id) {
this.id = id;
}
public Long getpId()
{
public Long getpId() {
return pId;
}
public void setpId(Long pId)
{
public void setpId(Long pId) {
this.pId = pId;
}
public String getName()
{
public String getName() {
return name;
}
public void setName(String name)
{
public void setName(String name) {
this.name = name;
}
public String getTitle()
{
public String getTitle() {
return title;
}
public void setTitle(String title)
{
public void setTitle(String title) {
this.title = title;
}
public boolean isChecked()
{
public boolean isChecked() {
return checked;
}
public void setChecked(boolean checked)
{
public void setChecked(boolean checked) {
this.checked = checked;
}
public boolean isOpen()
{
public boolean isOpen() {
return open;
}
public void setOpen(boolean open)
{
public void setOpen(boolean open) {
this.open = open;
}
public boolean isNocheck()
{
public boolean isNocheck() {
return nocheck;
}
public void setNocheck(boolean nocheck)
{
public void setNocheck(boolean nocheck) {
this.nocheck = nocheck;
}
}

View File

@ -0,0 +1,54 @@
package com.ruoyi.common.core.domain.enums;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.util.Arrays;
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
public enum ActiveState implements BaseEnum{
enabled(1,"活跃"),
disabled(2,"不活跃"),
;
private Integer state;
private String desc;
ActiveState(Integer state, String desc) {
this.state = state;
this.desc = desc;
}
public Integer getState() {
return state;
}
public void setState(Integer state) {
this.state = state;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
@Override
public String en() {
return null;
}
@Override
public String zh() {
return null;
}
public static ActiveState of(Integer value){
return Arrays.stream(ActiveState.values())
.filter(activeState -> activeState.getState().equals(value))
.findFirst()
.orElseThrow(IllegalArgumentException::new);
}
}

View File

@ -0,0 +1,16 @@
package com.ruoyi.common.core.domain.enums;
public interface BaseEnum {
/**
* 英文显示
* @return
*/
String en();
/**
* 汉语显示
* @return
*/
String zh();
}

View File

@ -0,0 +1,62 @@
package com.ruoyi.common.core.domain.enums;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.util.Arrays;
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
public enum DeleteState implements BaseEnum {
NOT_DELETED(0, "未删除","Not Deleted"),
DELETED(1, "已删除", "Deleted"),
;
private Integer state;
private String desc;
private String en;
public Integer getState() {
return state;
}
public void setState(Integer state) {
this.state = state;
}
DeleteState(Integer state, String desc, String en) {
this.state = state;
this.desc = desc;
this.en = en;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
public static DeleteState of(Integer state){
return Arrays.stream(DeleteState.values())
.filter(deleteState -> deleteState.getState().equals(state))
.findFirst()
.orElseThrow(IllegalArgumentException::new);
}
public String getEn() {
return en;
}
public void setEn(String en) {
this.en = en;
}
@Override
public String en() {
return en;
}
@Override
public String zh() {
return desc;
}
}

View File

@ -0,0 +1,19 @@
package com.ruoyi.common.core.domain.enums.converter;
import com.ruoyi.common.core.domain.enums.ActiveState;
import javax.persistence.AttributeConverter;
import javax.persistence.Converter;
@Converter(autoApply = true)
public class ActiveStateConverter implements AttributeConverter<ActiveState, Integer> {
@Override
public Integer convertToDatabaseColumn(ActiveState activeState) {
return null;
}
@Override
public ActiveState convertToEntityAttribute(Integer integer) {
return null;
}
}

View File

@ -0,0 +1,19 @@
package com.ruoyi.common.core.domain.enums.converter;
import com.ruoyi.common.core.domain.enums.DeleteState;
import javax.persistence.AttributeConverter;
import javax.persistence.Converter;
@Converter(autoApply = true)
public class DeleteStateConverter implements AttributeConverter<DeleteState, Integer> {
@Override
public Integer convertToDatabaseColumn(DeleteState attribute) {
return null == attribute ? null : attribute.getState();
}
@Override
public DeleteState convertToEntityAttribute(Integer dbData) {
return DeleteState.of(dbData);
}
}

View File

@ -0,0 +1,18 @@
package com.ruoyi.common.core.domain.enums.propertyeditor;
import com.ruoyi.common.core.domain.enums.ActiveState;
import java.beans.PropertyEditorSupport;
public class ActiveStatePropertyEditor extends PropertyEditorSupport {
@Override
public void setAsText(String text) throws IllegalArgumentException {
try{
Integer enumValue = Integer.parseInt(text);
setValue(ActiveState.of(enumValue));
}catch (NumberFormatException e){
e.printStackTrace();
}
}
}

View File

@ -0,0 +1,18 @@
package com.ruoyi.common.core.domain.enums.propertyeditor;
import com.ruoyi.common.core.domain.enums.DeleteState;
import java.beans.PropertyEditorSupport;
public class DeleteStatePropertyEditor extends PropertyEditorSupport {
@Override
public void setAsText(String text) throws IllegalArgumentException {
try{
Integer enumValue = Integer.parseInt(text);
setValue(DeleteState.of(enumValue));
}catch (NumberFormatException e){
e.printStackTrace();
}
}
}

View File

@ -8,13 +8,11 @@ import com.ruoyi.common.utils.ServletUtils;
*
* @author ruoyi
*/
public class TableSupport
{
public class TableSupport {
/**
* 封装分页对象
*/
public static PageDomain getPageDomain()
{
public static PageDomain getPageDomain() {
PageDomain pageDomain = new PageDomain();
pageDomain.setPageNum(ServletUtils.getParameterToInt(Constants.PAGE_NUM));
pageDomain.setPageSize(ServletUtils.getParameterToInt(Constants.PAGE_SIZE));
@ -23,8 +21,7 @@ public class TableSupport
return pageDomain;
}
public static PageDomain buildPageRequest()
{
public static PageDomain buildPageRequest() {
return getPageDomain();
}
}

View File

@ -2,6 +2,7 @@ package com.ruoyi.common.core.text;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import com.ruoyi.common.utils.StringUtils;
/**
@ -9,20 +10,31 @@ import com.ruoyi.common.utils.StringUtils;
*
* @author ruoyi
*/
public class CharsetKit
{
/** ISO-8859-1 */
public class CharsetKit {
/**
* 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";
/** 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);
/** UTF-8 */
/**
* UTF-8
*/
public static final Charset CHARSET_UTF_8 = Charset.forName(UTF_8);
/** GBK */
/**
* GBK
*/
public static final Charset CHARSET_GBK = Charset.forName(GBK);
/**
@ -31,8 +43,7 @@ public class CharsetKit
* @param charset 字符集为空则返回默认字符集
* @return Charset
*/
public static Charset charset(String charset)
{
public static Charset charset(String charset) {
return StringUtils.isEmpty(charset) ? Charset.defaultCharset() : Charset.forName(charset);
}
@ -44,8 +55,7 @@ public class CharsetKit
* @param destCharset 目标字符集默认UTF-8
* @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));
}
@ -57,20 +67,16 @@ public class CharsetKit
* @param destCharset 目标字符集默认UTF-8
* @return 转换后的字符集
*/
public static String convert(String source, Charset srcCharset, Charset destCharset)
{
if (null == srcCharset)
{
public static String convert(String source, Charset srcCharset, Charset destCharset) {
if (null == srcCharset) {
srcCharset = StandardCharsets.ISO_8859_1;
}
if (null == destCharset)
{
if (null == destCharset) {
srcCharset = StandardCharsets.UTF_8;
}
if (StringUtils.isEmpty(source) || srcCharset.equals(destCharset))
{
if (StringUtils.isEmpty(source) || srcCharset.equals(destCharset)) {
return source;
}
return new String(source.getBytes(srcCharset), destCharset);
@ -79,8 +85,7 @@ public class CharsetKit
/**
* @return 系统字符集编码
*/
public static String systemCharset()
{
public static String systemCharset() {
return Charset.defaultCharset().name();
}
}

View File

@ -6,6 +6,7 @@ import java.nio.ByteBuffer;
import java.nio.charset.Charset;
import java.text.NumberFormat;
import java.util.Set;
import com.ruoyi.common.utils.StringUtils;
/**
@ -13,8 +14,7 @@ import com.ruoyi.common.utils.StringUtils;
*
* @author ruoyi
*/
public class Convert
{
public class Convert {
/**
* 转换为字符串<br>
* 如果给定的值为null或者转换失败返回默认值<br>
@ -24,14 +24,11 @@ public class Convert
* @param defaultValue 转换错误时的默认值
* @return 结果
*/
public static String toStr(Object value, String defaultValue)
{
if (null == value)
{
public static String toStr(Object value, String defaultValue) {
if (null == value) {
return defaultValue;
}
if (value instanceof String)
{
if (value instanceof String) {
return (String) value;
}
return value.toString();
@ -45,8 +42,7 @@ public class Convert
* @param value 被转换的值
* @return 结果
*/
public static String toStr(Object value)
{
public static String toStr(Object value) {
return toStr(value, null);
}
@ -59,14 +55,11 @@ public class Convert
* @param defaultValue 转换错误时的默认值
* @return 结果
*/
public static Character toChar(Object value, Character defaultValue)
{
if (null == value)
{
public static Character toChar(Object value, Character defaultValue) {
if (null == value) {
return defaultValue;
}
if (value instanceof Character)
{
if (value instanceof Character) {
return (Character) value;
}
@ -82,8 +75,7 @@ public class Convert
* @param value 被转换的值
* @return 结果
*/
public static Character toChar(Object value)
{
public static Character toChar(Object value) {
return toChar(value, null);
}
@ -96,31 +88,23 @@ public class Convert
* @param defaultValue 转换错误时的默认值
* @return 结果
*/
public static Byte toByte(Object value, Byte defaultValue)
{
if (value == null)
{
public static Byte toByte(Object value, Byte defaultValue) {
if (value == null) {
return defaultValue;
}
if (value instanceof Byte)
{
if (value instanceof Byte) {
return (Byte) value;
}
if (value instanceof Number)
{
if (value instanceof Number) {
return ((Number) value).byteValue();
}
final String valueStr = toStr(value, null);
if (StringUtils.isEmpty(valueStr))
{
if (StringUtils.isEmpty(valueStr)) {
return defaultValue;
}
try
{
try {
return Byte.parseByte(valueStr);
}
catch (Exception e)
{
} catch (Exception e) {
return defaultValue;
}
}
@ -133,8 +117,7 @@ public class Convert
* @param value 被转换的值
* @return 结果
*/
public static Byte toByte(Object value)
{
public static Byte toByte(Object value) {
return toByte(value, null);
}
@ -147,31 +130,23 @@ public class Convert
* @param defaultValue 转换错误时的默认值
* @return 结果
*/
public static Short toShort(Object value, Short defaultValue)
{
if (value == null)
{
public static Short toShort(Object value, Short defaultValue) {
if (value == null) {
return defaultValue;
}
if (value instanceof Short)
{
if (value instanceof Short) {
return (Short) value;
}
if (value instanceof Number)
{
if (value instanceof Number) {
return ((Number) value).shortValue();
}
final String valueStr = toStr(value, null);
if (StringUtils.isEmpty(valueStr))
{
if (StringUtils.isEmpty(valueStr)) {
return defaultValue;
}
try
{
try {
return Short.parseShort(valueStr.trim());
}
catch (Exception e)
{
} catch (Exception e) {
return defaultValue;
}
}
@ -184,8 +159,7 @@ public class Convert
* @param value 被转换的值
* @return 结果
*/
public static Short toShort(Object value)
{
public static Short toShort(Object value) {
return toShort(value, null);
}
@ -198,27 +172,20 @@ public class Convert
* @param defaultValue 转换错误时的默认值
* @return 结果
*/
public static Number toNumber(Object value, Number defaultValue)
{
if (value == null)
{
public static Number toNumber(Object value, Number defaultValue) {
if (value == null) {
return defaultValue;
}
if (value instanceof Number)
{
if (value instanceof Number) {
return (Number) value;
}
final String valueStr = toStr(value, null);
if (StringUtils.isEmpty(valueStr))
{
if (StringUtils.isEmpty(valueStr)) {
return defaultValue;
}
try
{
try {
return NumberFormat.getInstance().parse(valueStr);
}
catch (Exception e)
{
} catch (Exception e) {
return defaultValue;
}
}
@ -231,8 +198,7 @@ public class Convert
* @param value 被转换的值
* @return 结果
*/
public static Number toNumber(Object value)
{
public static Number toNumber(Object value) {
return toNumber(value, null);
}
@ -245,31 +211,23 @@ public class Convert
* @param defaultValue 转换错误时的默认值
* @return 结果
*/
public static Integer toInt(Object value, Integer defaultValue)
{
if (value == null)
{
public static Integer toInt(Object value, Integer defaultValue) {
if (value == null) {
return defaultValue;
}
if (value instanceof Integer)
{
if (value instanceof Integer) {
return (Integer) value;
}
if (value instanceof Number)
{
if (value instanceof Number) {
return ((Number) value).intValue();
}
final String valueStr = toStr(value, null);
if (StringUtils.isEmpty(valueStr))
{
if (StringUtils.isEmpty(valueStr)) {
return defaultValue;
}
try
{
try {
return Integer.parseInt(valueStr.trim());
}
catch (Exception e)
{
} catch (Exception e) {
return defaultValue;
}
}
@ -282,8 +240,7 @@ public class Convert
* @param value 被转换的值
* @return 结果
*/
public static Integer toInt(Object value)
{
public static Integer toInt(Object value) {
return toInt(value, null);
}
@ -293,8 +250,7 @@ public class Convert
* @param str 被转换的值
* @return 结果
*/
public static Integer[] toIntArray(String str)
{
public static Integer[] toIntArray(String str) {
return toIntArray(",", str);
}
@ -304,8 +260,7 @@ public class Convert
* @param str 被转换的值
* @return 结果
*/
public static Long[] toLongArray(String str)
{
public static Long[] toLongArray(String str) {
return toLongArray(",", str);
}
@ -316,16 +271,13 @@ public class Convert
* @param split 被转换的值
* @return 结果
*/
public static Integer[] toIntArray(String split, String str)
{
if (StringUtils.isEmpty(str))
{
public static Integer[] toIntArray(String split, String str) {
if (StringUtils.isEmpty(str)) {
return new Integer[]{};
}
String[] arr = str.split(split);
final Integer[] ints = new Integer[arr.length];
for (int i = 0; i < arr.length; i++)
{
for (int i = 0; i < arr.length; i++) {
final Integer v = toInt(arr[i], 0);
ints[i] = v;
}
@ -339,16 +291,13 @@ public class Convert
* @param str 被转换的值
* @return 结果
*/
public static Long[] toLongArray(String split, String str)
{
if (StringUtils.isEmpty(str))
{
public static Long[] toLongArray(String split, String str) {
if (StringUtils.isEmpty(str)) {
return new Long[]{};
}
String[] arr = str.split(split);
final Long[] longs = new Long[arr.length];
for (int i = 0; i < arr.length; i++)
{
for (int i = 0; i < arr.length; i++) {
final Long v = toLong(arr[i], null);
longs[i] = v;
}
@ -361,8 +310,7 @@ public class Convert
* @param str 被转换的值
* @return 结果
*/
public static String[] toStrArray(String str)
{
public static String[] toStrArray(String str) {
return toStrArray(",", str);
}
@ -373,8 +321,7 @@ public class Convert
* @param split 被转换的值
* @return 结果
*/
public static String[] toStrArray(String split, String str)
{
public static String[] toStrArray(String split, String str) {
return str.split(split);
}
@ -387,32 +334,24 @@ public class Convert
* @param defaultValue 转换错误时的默认值
* @return 结果
*/
public static Long toLong(Object value, Long defaultValue)
{
if (value == null)
{
public static Long toLong(Object value, Long defaultValue) {
if (value == null) {
return defaultValue;
}
if (value instanceof Long)
{
if (value instanceof Long) {
return (Long) value;
}
if (value instanceof Number)
{
if (value instanceof Number) {
return ((Number) value).longValue();
}
final String valueStr = toStr(value, null);
if (StringUtils.isEmpty(valueStr))
{
if (StringUtils.isEmpty(valueStr)) {
return defaultValue;
}
try
{
try {
// 支持科学计数法
return new BigDecimal(valueStr.trim()).longValue();
}
catch (Exception e)
{
} catch (Exception e) {
return defaultValue;
}
}
@ -425,8 +364,7 @@ public class Convert
* @param value 被转换的值
* @return 结果
*/
public static Long toLong(Object value)
{
public static Long toLong(Object value) {
return toLong(value, null);
}
@ -439,32 +377,24 @@ public class Convert
* @param defaultValue 转换错误时的默认值
* @return 结果
*/
public static Double toDouble(Object value, Double defaultValue)
{
if (value == null)
{
public static Double toDouble(Object value, Double defaultValue) {
if (value == null) {
return defaultValue;
}
if (value instanceof Double)
{
if (value instanceof Double) {
return (Double) value;
}
if (value instanceof Number)
{
if (value instanceof Number) {
return ((Number) value).doubleValue();
}
final String valueStr = toStr(value, null);
if (StringUtils.isEmpty(valueStr))
{
if (StringUtils.isEmpty(valueStr)) {
return defaultValue;
}
try
{
try {
// 支持科学计数法
return new BigDecimal(valueStr.trim()).doubleValue();
}
catch (Exception e)
{
} catch (Exception e) {
return defaultValue;
}
}
@ -477,8 +407,7 @@ public class Convert
* @param value 被转换的值
* @return 结果
*/
public static Double toDouble(Object value)
{
public static Double toDouble(Object value) {
return toDouble(value, null);
}
@ -491,31 +420,23 @@ public class Convert
* @param defaultValue 转换错误时的默认值
* @return 结果
*/
public static Float toFloat(Object value, Float defaultValue)
{
if (value == null)
{
public static Float toFloat(Object value, Float defaultValue) {
if (value == null) {
return defaultValue;
}
if (value instanceof Float)
{
if (value instanceof Float) {
return (Float) value;
}
if (value instanceof Number)
{
if (value instanceof Number) {
return ((Number) value).floatValue();
}
final String valueStr = toStr(value, null);
if (StringUtils.isEmpty(valueStr))
{
if (StringUtils.isEmpty(valueStr)) {
return defaultValue;
}
try
{
try {
return Float.parseFloat(valueStr.trim());
}
catch (Exception e)
{
} catch (Exception e) {
return defaultValue;
}
}
@ -528,8 +449,7 @@ public class Convert
* @param value 被转换的值
* @return 结果
*/
public static Float toFloat(Object value)
{
public static Float toFloat(Object value) {
return toFloat(value, null);
}
@ -542,24 +462,19 @@ public class Convert
* @param defaultValue 转换错误时的默认值
* @return 结果
*/
public static Boolean toBool(Object value, Boolean defaultValue)
{
if (value == null)
{
public static Boolean toBool(Object value, Boolean defaultValue) {
if (value == null) {
return defaultValue;
}
if (value instanceof Boolean)
{
if (value instanceof Boolean) {
return (Boolean) value;
}
String valueStr = toStr(value, null);
if (StringUtils.isEmpty(valueStr))
{
if (StringUtils.isEmpty(valueStr)) {
return defaultValue;
}
valueStr = valueStr.trim().toLowerCase();
switch (valueStr)
{
switch (valueStr) {
case "true":
return true;
case "false":
@ -587,8 +502,7 @@ public class Convert
* @param value 被转换的值
* @return 结果
*/
public static Boolean toBool(Object value)
{
public static Boolean toBool(Object value) {
return toBool(value, null);
}
@ -601,29 +515,22 @@ public class Convert
* @param defaultValue 默认值
* @return Enum
*/
public static <E extends Enum<E>> E toEnum(Class<E> clazz, Object value, E defaultValue)
{
if (value == null)
{
public static <E extends Enum<E>> E toEnum(Class<E> clazz, Object value, E defaultValue) {
if (value == null) {
return defaultValue;
}
if (clazz.isAssignableFrom(value.getClass()))
{
if (clazz.isAssignableFrom(value.getClass())) {
@SuppressWarnings("unchecked")
E myE = (E) value;
return myE;
}
final String valueStr = toStr(value, null);
if (StringUtils.isEmpty(valueStr))
{
if (StringUtils.isEmpty(valueStr)) {
return defaultValue;
}
try
{
try {
return Enum.valueOf(clazz, valueStr);
}
catch (Exception e)
{
} catch (Exception e) {
return defaultValue;
}
}
@ -636,8 +543,7 @@ public class Convert
* @param value
* @return Enum
*/
public static <E extends Enum<E>> E toEnum(Class<E> clazz, Object value)
{
public static <E extends Enum<E>> E toEnum(Class<E> clazz, Object value) {
return toEnum(clazz, value, null);
}
@ -650,31 +556,23 @@ public class Convert
* @param defaultValue 转换错误时的默认值
* @return 结果
*/
public static BigInteger toBigInteger(Object value, BigInteger defaultValue)
{
if (value == null)
{
public static BigInteger toBigInteger(Object value, BigInteger defaultValue) {
if (value == null) {
return defaultValue;
}
if (value instanceof BigInteger)
{
if (value instanceof BigInteger) {
return (BigInteger) value;
}
if (value instanceof Long)
{
if (value instanceof Long) {
return BigInteger.valueOf((Long) value);
}
final String valueStr = toStr(value, null);
if (StringUtils.isEmpty(valueStr))
{
if (StringUtils.isEmpty(valueStr)) {
return defaultValue;
}
try
{
try {
return new BigInteger(valueStr);
}
catch (Exception e)
{
} catch (Exception e) {
return defaultValue;
}
}
@ -687,8 +585,7 @@ public class Convert
* @param value 被转换的值
* @return 结果
*/
public static BigInteger toBigInteger(Object value)
{
public static BigInteger toBigInteger(Object value) {
return toBigInteger(value, null);
}
@ -701,39 +598,29 @@ public class Convert
* @param defaultValue 转换错误时的默认值
* @return 结果
*/
public static BigDecimal toBigDecimal(Object value, BigDecimal defaultValue)
{
if (value == null)
{
public static BigDecimal toBigDecimal(Object value, BigDecimal defaultValue) {
if (value == null) {
return defaultValue;
}
if (value instanceof BigDecimal)
{
if (value instanceof BigDecimal) {
return (BigDecimal) value;
}
if (value instanceof Long)
{
if (value instanceof Long) {
return new BigDecimal((Long) value);
}
if (value instanceof Double)
{
if (value instanceof Double) {
return new BigDecimal((Double) value);
}
if (value instanceof Integer)
{
if (value instanceof Integer) {
return new BigDecimal((Integer) value);
}
final String valueStr = toStr(value, null);
if (StringUtils.isEmpty(valueStr))
{
if (StringUtils.isEmpty(valueStr)) {
return defaultValue;
}
try
{
try {
return new BigDecimal(valueStr);
}
catch (Exception e)
{
} catch (Exception e) {
return defaultValue;
}
}
@ -746,8 +633,7 @@ public class Convert
* @param value 被转换的值
* @return 结果
*/
public static BigDecimal toBigDecimal(Object value)
{
public static BigDecimal toBigDecimal(Object value) {
return toBigDecimal(value, null);
}
@ -758,8 +644,7 @@ public class Convert
* @param obj 对象
* @return 字符串
*/
public static String utf8Str(Object obj)
{
public static String utf8Str(Object obj) {
return str(obj, CharsetKit.CHARSET_UTF_8);
}
@ -771,8 +656,7 @@ public class Convert
* @param charsetName 字符集
* @return 字符串
*/
public static String str(Object obj, String charsetName)
{
public static String str(Object obj, String charsetName) {
return str(obj, Charset.forName(charsetName));
}
@ -784,23 +668,16 @@ public class Convert
* @param charset 字符集
* @return 字符串
*/
public static String str(Object obj, Charset charset)
{
if (null == obj)
{
public static String str(Object obj, Charset charset) {
if (null == obj) {
return null;
}
if (obj instanceof String)
{
if (obj instanceof String) {
return (String) obj;
}
else if (obj instanceof byte[] || obj instanceof Byte[])
{
} else if (obj instanceof byte[] || obj instanceof Byte[]) {
return str((Byte[]) obj, charset);
}
else if (obj instanceof ByteBuffer)
{
} else if (obj instanceof ByteBuffer) {
return str((ByteBuffer) obj, charset);
}
return obj.toString();
@ -813,8 +690,7 @@ public class Convert
* @param charset 字符集
* @return 字符串
*/
public static String str(byte[] bytes, String charset)
{
public static String str(byte[] bytes, String charset) {
return str(bytes, StringUtils.isEmpty(charset) ? Charset.defaultCharset() : Charset.forName(charset));
}
@ -825,15 +701,12 @@ public class Convert
* @param charset 字符集如果此字段为空则解码的结果取决于平台
* @return 解码后的字符串
*/
public static String str(byte[] data, Charset charset)
{
if (data == null)
{
public static String str(byte[] data, Charset charset) {
if (data == null) {
return null;
}
if (null == charset)
{
if (null == charset) {
return new String(data);
}
return new String(data, charset);
@ -846,10 +719,8 @@ public class Convert
* @param charset 字符集如果为空使用当前系统字符集
* @return 字符串
*/
public static String str(ByteBuffer data, String charset)
{
if (data == null)
{
public static String str(ByteBuffer data, String charset) {
if (data == null) {
return null;
}
@ -863,24 +734,22 @@ public class Convert
* @param charset 字符集如果为空使用当前系统字符集
* @return 字符串
*/
public static String str(ByteBuffer data, Charset charset)
{
if (null == charset)
{
public static String str(ByteBuffer data, Charset charset) {
if (null == charset) {
charset = Charset.defaultCharset();
}
return charset.decode(data).toString();
}
// ----------------------------------------------------------------------- 全角半角转换
/**
* 半角转全角
*
* @param input String.
* @return 全角字符串.
*/
public static String toSBC(String input)
{
public static String toSBC(String input) {
return toSBC(input, null);
}
@ -891,23 +760,17 @@ public class Convert
* @param notConvertSet 不替换的字符集合
* @return 全角字符串.
*/
public static String toSBC(String input, Set<Character> notConvertSet)
{
public static String toSBC(String input, Set<Character> notConvertSet) {
char c[] = input.toCharArray();
for (int i = 0; i < c.length; i++)
{
if (null != notConvertSet && notConvertSet.contains(c[i]))
{
for (int i = 0; i < c.length; i++) {
if (null != notConvertSet && notConvertSet.contains(c[i])) {
// 跳过不替换的字符
continue;
}
if (c[i] == ' ')
{
if (c[i] == ' ') {
c[i] = '\u3000';
}
else if (c[i] < '\177')
{
} else if (c[i] < '\177') {
c[i] = (char) (c[i] + 65248);
}
@ -921,8 +784,7 @@ public class Convert
* @param input String.
* @return 半角字符串
*/
public static String toDBC(String input)
{
public static String toDBC(String input) {
return toDBC(input, null);
}
@ -933,23 +795,17 @@ public class Convert
* @param notConvertSet 不替换的字符集合
* @return 替换后的字符
*/
public static String toDBC(String text, Set<Character> notConvertSet)
{
public static String toDBC(String text, Set<Character> notConvertSet) {
char c[] = text.toCharArray();
for (int i = 0; i < c.length; i++)
{
if (null != notConvertSet && notConvertSet.contains(c[i]))
{
for (int i = 0; i < c.length; i++) {
if (null != notConvertSet && notConvertSet.contains(c[i])) {
// 跳过不替换的字符
continue;
}
if (c[i] == '\u3000')
{
if (c[i] == '\u3000') {
c[i] = ' ';
}
else if (c[i] > '\uFF00' && c[i] < '\uFF5F')
{
} else if (c[i] > '\uFF00' && c[i] < '\uFF5F') {
c[i] = (char) (c[i] - 65248);
}
}
@ -964,8 +820,7 @@ public class Convert
* @param n 数字
* @return 中文大写数字
*/
public static String digitUppercase(double n)
{
public static String digitUppercase(double n) {
String[] fraction = {"", ""};
String[] digit = {"", "", "", "", "", "", "", "", "", ""};
String[][] unit = {{"", "", "亿"}, {"", "", "", ""}};
@ -974,21 +829,17 @@ public class Convert
n = Math.abs(n);
String s = "";
for (int i = 0; i < fraction.length; i++)
{
for (int i = 0; i < fraction.length; i++) {
s += (digit[(int) (Math.floor(n * 10 * Math.pow(10, i)) % 10)] + fraction[i]).replaceAll("(零.)+", "");
}
if (s.length() < 1)
{
if (s.length() < 1) {
s = "";
}
int integerPart = (int) Math.floor(n);
for (int i = 0; i < unit[0].length && integerPart > 0; i++)
{
for (int i = 0; i < unit[0].length && integerPart > 0; i++) {
String p = "";
for (int j = 0; j < unit[1].length && n > 0; j++)
{
for (int j = 0; j < unit[1].length && n > 0; j++) {
p = digit[integerPart % 10] + unit[1][j] + p;
integerPart = integerPart / 10;
}

View File

@ -7,8 +7,7 @@ import com.ruoyi.common.utils.StringUtils;
*
* @author ruoyi
*/
public class StrFormatter
{
public class StrFormatter {
public static final String EMPTY_JSON = "{}";
public static final char C_BACKSLASH = '\\';
public static final char C_DELIM_START = '{';
@ -27,10 +26,8 @@ public class StrFormatter
* @param argArray 参数列表
* @return 结果
*/
public static String format(final String strPattern, final Object... argArray)
{
if (StringUtils.isEmpty(strPattern) || StringUtils.isEmpty(argArray))
{
public static String format(final String strPattern, final Object... argArray) {
if (StringUtils.isEmpty(strPattern) || StringUtils.isEmpty(argArray)) {
return strPattern;
}
final int strPatternLength = strPattern.length();
@ -40,43 +37,30 @@ public class StrFormatter
int handledPosition = 0;
int delimIndex;// 占位符所在位置
for (int argIndex = 0; argIndex < argArray.length; argIndex++)
{
for (int argIndex = 0; argIndex < argArray.length; argIndex++) {
delimIndex = strPattern.indexOf(EMPTY_JSON, handledPosition);
if (delimIndex == -1)
{
if (handledPosition == 0)
{
if (delimIndex == -1) {
if (handledPosition == 0) {
return strPattern;
}
else
{ // 字符串模板剩余部分不再包含占位符加入剩余部分后返回结果
} else { // 字符串模板剩余部分不再包含占位符加入剩余部分后返回结果
sbuf.append(strPattern, handledPosition, strPatternLength);
return sbuf.toString();
}
}
else
{
if (delimIndex > 0 && strPattern.charAt(delimIndex - 1) == C_BACKSLASH)
{
if (delimIndex > 1 && strPattern.charAt(delimIndex - 2) == C_BACKSLASH)
{
} else {
if (delimIndex > 0 && strPattern.charAt(delimIndex - 1) == C_BACKSLASH) {
if (delimIndex > 1 && strPattern.charAt(delimIndex - 2) == C_BACKSLASH) {
// 转义符之前还有一个转义符占位符依旧有效
sbuf.append(strPattern, handledPosition, delimIndex - 1);
sbuf.append(Convert.utf8Str(argArray[argIndex]));
handledPosition = delimIndex + 2;
}
else
{
} else {
// 占位符被转义
argIndex--;
sbuf.append(strPattern, handledPosition, delimIndex - 1);
sbuf.append(C_DELIM_START);
handledPosition = delimIndex + 1;
}
}
else
{
} else {
// 正常占位符
sbuf.append(strPattern, handledPosition, delimIndex);
sbuf.append(Convert.utf8Str(argArray[argIndex]));

View File

@ -5,8 +5,7 @@ package com.ruoyi.common.enums;
*
* @author ruoyi
*/
public enum BusinessStatus
{
public enum BusinessStatus {
/**
* 成功
*/

View File

@ -5,8 +5,7 @@ package com.ruoyi.common.enums;
*
* @author ruoyi
*/
public enum BusinessType
{
public enum BusinessType {
/**
* 其它
*/

View File

@ -5,8 +5,7 @@ package com.ruoyi.common.enums;
*
* @author ruoyi
*/
public enum DataSourceType
{
public enum DataSourceType {
/**
* 主库
*/

View File

@ -5,20 +5,19 @@ package com.ruoyi.common.enums;
*
* @author ruoyi
*/
public enum OnlineStatus
{
/** 用户状态 */
public enum OnlineStatus {
/**
* 用户状态
*/
on_line("在线"), off_line("离线");
private final String info;
private OnlineStatus(String info)
{
private OnlineStatus(String info) {
this.info = info;
}
public String getInfo()
{
public String getInfo() {
return info;
}
}

View File

@ -5,8 +5,7 @@ package com.ruoyi.common.enums;
*
* @author ruoyi
*/
public enum OperatorType
{
public enum OperatorType {
/**
* 其它
*/

View File

@ -5,26 +5,22 @@ package com.ruoyi.common.enums;
*
* @author ruoyi
*/
public enum UserStatus
{
public enum UserStatus {
OK("0", "正常"), DISABLE("1", "停用"), DELETED("2", "删除");
private final String code;
private final String info;
UserStatus(String code, String info)
{
UserStatus(String code, String info) {
this.code = code;
this.info = info;
}
public String getCode()
{
public String getCode() {
return code;
}
public String getInfo()
{
public String getInfo() {
return info;
}
}

View File

@ -0,0 +1,19 @@
package com.ruoyi.common.enums.converter;
import com.ruoyi.common.enums.OnlineStatus;
import javax.persistence.AttributeConverter;
import javax.persistence.Converter;
@Converter(autoApply = true)
public class OnlineStatusConverter implements AttributeConverter<OnlineStatus, String> {
@Override
public String convertToDatabaseColumn(OnlineStatus attribute) {
return attribute == null ? null : attribute.name();
}
@Override
public OnlineStatus convertToEntityAttribute(String dbData) {
return OnlineStatus.valueOf(dbData);
}
}

View File

@ -5,26 +5,22 @@ package com.ruoyi.common.exception;
*
* @author ruoyi
*/
public class BusinessException extends RuntimeException
{
public class BusinessException extends RuntimeException {
private static final long serialVersionUID = 1L;
protected final String message;
public BusinessException(String message)
{
public BusinessException(String message) {
this.message = message;
}
public BusinessException(String message, Throwable e)
{
public BusinessException(String message, Throwable e) {
super(message, e);
this.message = message;
}
@Override
public String getMessage()
{
public String getMessage() {
return message;
}
}

View File

@ -5,11 +5,9 @@ package com.ruoyi.common.exception;
*
* @author ruoyi
*/
public class DemoModeException extends RuntimeException
{
public class DemoModeException extends RuntimeException {
private static final long serialVersionUID = 1L;
public DemoModeException()
{
public DemoModeException() {
}
}

View File

@ -8,8 +8,7 @@ import com.ruoyi.common.utils.StringUtils;
*
* @author ruoyi
*/
public class BaseException extends RuntimeException
{
public class BaseException extends RuntimeException {
private static final long serialVersionUID = 1L;
/**
@ -32,66 +31,54 @@ public class BaseException extends RuntimeException
*/
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.code = code;
this.args = args;
this.defaultMessage = defaultMessage;
}
public BaseException(String module, String code, Object[] args)
{
public BaseException(String module, String code, Object[] args) {
this(module, code, args, null);
}
public BaseException(String module, String defaultMessage)
{
public BaseException(String module, String defaultMessage) {
this(module, null, null, defaultMessage);
}
public BaseException(String code, Object[] args)
{
public BaseException(String code, Object[] args) {
this(null, code, args, null);
}
public BaseException(String defaultMessage)
{
public BaseException(String defaultMessage) {
this(null, null, null, defaultMessage);
}
@Override
public String getMessage()
{
public String getMessage() {
String message = null;
if (!StringUtils.isEmpty(code))
{
if (!StringUtils.isEmpty(code)) {
message = MessageUtils.message(code, args);
}
if (message == null)
{
if (message == null) {
message = defaultMessage;
}
return message;
}
public String getModule()
{
public String getModule() {
return module;
}
public String getCode()
{
public String getCode() {
return code;
}
public Object[] getArgs()
{
public Object[] getArgs() {
return args;
}
public String getDefaultMessage()
{
public String getDefaultMessage() {
return defaultMessage;
}
}

View File

@ -7,12 +7,10 @@ import com.ruoyi.common.exception.base.BaseException;
*
* @author ruoyi
*/
public class FileException extends BaseException
{
public class FileException extends BaseException {
private static final long serialVersionUID = 1L;
public FileException(String code, Object[] args)
{
public FileException(String code, Object[] args) {
super("file", code, args, null);
}

View File

@ -5,12 +5,10 @@ package com.ruoyi.common.exception.file;
*
* @author ruoyi
*/
public class FileNameLengthLimitExceededException extends FileException
{
public class FileNameLengthLimitExceededException extends FileException {
private static final long serialVersionUID = 1L;
public FileNameLengthLimitExceededException(int defaultFileNameLength)
{
public FileNameLengthLimitExceededException(int defaultFileNameLength) {
super("upload.filename.exceed.length", new Object[]{defaultFileNameLength});
}
}

View File

@ -5,12 +5,10 @@ package com.ruoyi.common.exception.file;
*
* @author ruoyi
*/
public class FileSizeLimitExceededException extends FileException
{
public class FileSizeLimitExceededException extends FileException {
private static final long serialVersionUID = 1L;
public FileSizeLimitExceededException(long defaultMaxSize)
{
public FileSizeLimitExceededException(long defaultMaxSize) {
super("upload.exceed.maxSize", new Object[]{defaultMaxSize});
}
}

View File

@ -5,30 +5,25 @@ package com.ruoyi.common.exception.job;
*
* @author ruoyi
*/
public class TaskException extends Exception
{
public class TaskException extends Exception {
private static final long serialVersionUID = 1L;
private Code code;
public TaskException(String msg, Code code)
{
public TaskException(String msg, Code code) {
this(msg, code, null);
}
public TaskException(String msg, Code code, Exception nestedEx)
{
public TaskException(String msg, Code code, Exception nestedEx) {
super(msg, nestedEx);
this.code = code;
}
public Code getCode()
{
public Code getCode() {
return code;
}
public enum Code
{
public enum Code {
TASK_EXISTS, NO_TASK_EXISTS, TASK_ALREADY_STARTED, UNKNOWN, CONFIG_ERROR, TASK_NODE_NOT_AVAILABLE
}
}

View File

@ -5,12 +5,10 @@ package com.ruoyi.common.exception.user;
*
* @author ruoyi
*/
public class CaptchaException extends UserException
{
public class CaptchaException extends UserException {
private static final long serialVersionUID = 1L;
public CaptchaException()
{
public CaptchaException() {
super("user.jcaptcha.error", null);
}
}

View File

@ -5,12 +5,10 @@ package com.ruoyi.common.exception.user;
*
* @author ruoyi
*/
public class RoleBlockedException extends UserException
{
public class RoleBlockedException extends UserException {
private static final long serialVersionUID = 1L;
public RoleBlockedException()
{
public RoleBlockedException() {
super("role.blocked", null);
}
}

View File

@ -5,12 +5,10 @@ package com.ruoyi.common.exception.user;
*
* @author ruoyi
*/
public class UserBlockedException extends UserException
{
public class UserBlockedException extends UserException {
private static final long serialVersionUID = 1L;
public UserBlockedException()
{
public UserBlockedException() {
super("user.blocked", null);
}
}

View File

@ -5,12 +5,10 @@ package com.ruoyi.common.exception.user;
*
* @author ruoyi
*/
public class UserDeleteException extends UserException
{
public class UserDeleteException extends UserException {
private static final long serialVersionUID = 1L;
public UserDeleteException()
{
public UserDeleteException() {
super("user.password.delete", null);
}
}

View File

@ -7,12 +7,10 @@ import com.ruoyi.common.exception.base.BaseException;
*
* @author ruoyi
*/
public class UserException extends BaseException
{
public class UserException extends BaseException {
private static final long serialVersionUID = 1L;
public UserException(String code, Object[] args)
{
public UserException(String code, Object[] args) {
super("user", code, args, null);
}
}

View File

@ -5,12 +5,10 @@ package com.ruoyi.common.exception.user;
*
* @author ruoyi
*/
public class UserNotExistsException extends UserException
{
public class UserNotExistsException extends UserException {
private static final long serialVersionUID = 1L;
public UserNotExistsException()
{
public UserNotExistsException() {
super("user.not.exists", null);
}
}

View File

@ -5,12 +5,10 @@ package com.ruoyi.common.exception.user;
*
* @author ruoyi
*/
public class UserPasswordNotMatchException extends UserException
{
public class UserPasswordNotMatchException extends UserException {
private static final long serialVersionUID = 1L;
public UserPasswordNotMatchException()
{
public UserPasswordNotMatchException() {
super("user.password.not.match", null);
}
}

View File

@ -5,12 +5,10 @@ package com.ruoyi.common.exception.user;
*
* @author ruoyi
*/
public class UserPasswordRetryLimitCountException extends UserException
{
public class UserPasswordRetryLimitCountException extends UserException {
private static final long serialVersionUID = 1L;
public UserPasswordRetryLimitCountException(int retryLimitCount)
{
public UserPasswordRetryLimitCountException(int retryLimitCount) {
super("user.password.retry.limit.count", new Object[]{retryLimitCount});
}
}

View File

@ -5,12 +5,10 @@ package com.ruoyi.common.exception.user;
*
* @author ruoyi
*/
public class UserPasswordRetryLimitExceedException extends UserException
{
public class UserPasswordRetryLimitExceedException extends UserException {
private static final long serialVersionUID = 1L;
public UserPasswordRetryLimitExceedException(int retryLimitCount)
{
public UserPasswordRetryLimitExceedException(int retryLimitCount) {
super("user.password.retry.limit.exceed", new Object[]{retryLimitCount});
}
}

View File

@ -4,6 +4,7 @@ import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import com.fasterxml.jackson.core.JsonGenerationException;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException;
@ -15,172 +16,106 @@ import com.fasterxml.jackson.databind.ObjectWriter;
*
* @author ruoyi
*/
public class JSON
{
public class JSON {
public static final String DEFAULT_FAIL = "\"Parse failed\"";
private static final ObjectMapper objectMapper = new ObjectMapper();
private static final ObjectWriter objectWriter = objectMapper.writerWithDefaultPrettyPrinter();
public static void marshal(File file, Object value) throws Exception
{
try
{
public static void marshal(File file, Object value) throws Exception {
try {
objectWriter.writeValue(file, value);
}
catch (JsonGenerationException e)
{
} catch (JsonGenerationException e) {
throw new Exception(e);
}
catch (JsonMappingException e)
{
} catch (JsonMappingException e) {
throw new Exception(e);
}
catch (IOException e)
{
} catch (IOException e) {
throw new Exception(e);
}
}
public static void marshal(OutputStream os, Object value) throws Exception
{
try
{
public static void marshal(OutputStream os, Object value) throws Exception {
try {
objectWriter.writeValue(os, value);
}
catch (JsonGenerationException e)
{
} catch (JsonGenerationException e) {
throw new Exception(e);
}
catch (JsonMappingException e)
{
} catch (JsonMappingException e) {
throw new Exception(e);
}
catch (IOException e)
{
} catch (IOException e) {
throw new Exception(e);
}
}
public static String marshal(Object value) throws Exception
{
try
{
public static String marshal(Object value) throws Exception {
try {
return objectWriter.writeValueAsString(value);
}
catch (JsonGenerationException e)
{
} catch (JsonGenerationException e) {
throw new Exception(e);
}
catch (JsonMappingException e)
{
} catch (JsonMappingException e) {
throw new Exception(e);
}
catch (IOException e)
{
} catch (IOException e) {
throw new Exception(e);
}
}
public static byte[] marshalBytes(Object value) throws Exception
{
try
{
public static byte[] marshalBytes(Object value) throws Exception {
try {
return objectWriter.writeValueAsBytes(value);
}
catch (JsonGenerationException e)
{
} catch (JsonGenerationException e) {
throw new Exception(e);
}
catch (JsonMappingException e)
{
} catch (JsonMappingException e) {
throw new Exception(e);
}
catch (IOException e)
{
} catch (IOException e) {
throw new Exception(e);
}
}
public static <T> T unmarshal(File file, Class<T> valueType) throws Exception
{
try
{
public static <T> T unmarshal(File file, Class<T> valueType) throws Exception {
try {
return objectMapper.readValue(file, valueType);
}
catch (JsonParseException e)
{
} catch (JsonParseException e) {
throw new Exception(e);
}
catch (JsonMappingException e)
{
} catch (JsonMappingException e) {
throw new Exception(e);
}
catch (IOException e)
{
} catch (IOException e) {
throw new Exception(e);
}
}
public static <T> T unmarshal(InputStream is, Class<T> valueType) throws Exception
{
try
{
public static <T> T unmarshal(InputStream is, Class<T> valueType) throws Exception {
try {
return objectMapper.readValue(is, valueType);
}
catch (JsonParseException e)
{
} catch (JsonParseException e) {
throw new Exception(e);
}
catch (JsonMappingException e)
{
} catch (JsonMappingException e) {
throw new Exception(e);
}
catch (IOException e)
{
} catch (IOException e) {
throw new Exception(e);
}
}
public static <T> T unmarshal(String str, Class<T> valueType) throws Exception
{
try
{
public static <T> T unmarshal(String str, Class<T> valueType) throws Exception {
try {
return objectMapper.readValue(str, valueType);
}
catch (JsonParseException e)
{
} catch (JsonParseException e) {
throw new Exception(e);
}
catch (JsonMappingException e)
{
} catch (JsonMappingException e) {
throw new Exception(e);
}
catch (IOException e)
{
} catch (IOException e) {
throw new Exception(e);
}
}
public static <T> T unmarshal(byte[] bytes, Class<T> valueType) throws Exception
{
try
{
if (bytes == null)
{
public static <T> T unmarshal(byte[] bytes, Class<T> valueType) throws Exception {
try {
if (bytes == null) {
bytes = new byte[0];
}
return objectMapper.readValue(bytes, 0, bytes.length, valueType);
}
catch (JsonParseException e)
{
} catch (JsonParseException e) {
throw new Exception(e);
}
catch (JsonMappingException e)
{
} catch (JsonMappingException e) {
throw new Exception(e);
}
catch (IOException e)
{
} catch (IOException e) {
throw new Exception(e);
}
}

View File

@ -8,6 +8,7 @@ import java.util.Map;
import java.util.StringTokenizer;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.ruoyi.common.utils.StringUtils;
@ -16,8 +17,7 @@ import com.ruoyi.common.utils.StringUtils;
*
* @author ruoyi
*/
public class JSONObject extends LinkedHashMap<String, Object>
{
public class JSONObject extends LinkedHashMap<String, Object> {
private static final long serialVersionUID = 1L;
private static final Pattern arrayNamePattern = Pattern.compile("(\\w+)((\\[\\d+\\])+)");
private static final ObjectMapper objectMapper = new ObjectMapper();
@ -25,71 +25,55 @@ public class JSONObject extends LinkedHashMap<String, Object>
/**
* 数组结构
*/
public static class JSONArray extends ArrayList<Object>
{
public static class JSONArray extends ArrayList<Object> {
private static final long serialVersionUID = 1L;
public JSONArray()
{
public JSONArray() {
super();
}
public JSONArray(int size)
{
public JSONArray(int size) {
super(size);
}
@Override
public String toString()
{
try
{
public String toString() {
try {
return JSON.marshal(this);
}
catch (Exception e)
{
} catch (Exception e) {
throw new RuntimeException(e);
}
}
@Override
public Object set(int index, Object element)
{
public Object set(int index, Object element) {
return super.set(index, transfer(element));
}
@Override
public boolean add(Object element)
{
public boolean add(Object element) {
return super.add(transfer(element));
}
@Override
public void add(int index, Object element)
{
public void add(int index, Object element) {
super.add(index, transfer(element));
}
}
public JSONObject()
{
public JSONObject() {
super();
}
public JSONObject(final JSONObject other)
{
public JSONObject(final JSONObject other) {
super(other);
}
@Override
public String toString()
{
try
{
public String toString() {
try {
return JSON.marshal(this);
}
catch (Exception e)
{
} catch (Exception e) {
throw new RuntimeException(e);
}
}
@ -99,14 +83,10 @@ public class JSONObject extends LinkedHashMap<String, Object>
*
* @return 返回本对象紧凑格式字符串
*/
public String toCompactString()
{
try
{
public String toCompactString() {
try {
return objectMapper.writeValueAsString(this);
}
catch (Exception e)
{
} catch (Exception e) {
throw new RuntimeException(e);
}
}
@ -117,8 +97,7 @@ public class JSONObject extends LinkedHashMap<String, Object>
* @param name 字段名支持多级
* @return 返回指定的整数值或者null
*/
public Integer intValue(final String name)
{
public Integer intValue(final String name) {
return valueAsInt(value(name));
}
@ -129,8 +108,7 @@ public class JSONObject extends LinkedHashMap<String, Object>
* @param defaultValue 查询失败时返回的值
* @return 返回指定的整数值或者defaultValue
*/
public Integer intValue(final String name, final Integer defaultValue)
{
public Integer intValue(final String name, final Integer defaultValue) {
return StringUtils.nvl(intValue(name), defaultValue);
}
@ -140,8 +118,7 @@ public class JSONObject extends LinkedHashMap<String, Object>
* @param name 字段名支持多级
* @return 返回指定的长整数值或者null
*/
public Long longValue(final String name)
{
public Long longValue(final String name) {
return valueAsLong(value(name));
}
@ -152,8 +129,7 @@ public class JSONObject extends LinkedHashMap<String, Object>
* @param defaultValue 查询失败时返回的值
* @return 返回指定的长整数值或者defaultValue
*/
public Long longValue(final String name, final Long defaultValue)
{
public Long longValue(final String name, final Long defaultValue) {
return StringUtils.nvl(longValue(name), defaultValue);
}
@ -163,8 +139,7 @@ public class JSONObject extends LinkedHashMap<String, Object>
* @param name 字段名支持多级
* @return 返回指定的布尔值或者null
*/
public Boolean boolValue(final String name)
{
public Boolean boolValue(final String name) {
return valueAsBool(value(name));
}
@ -175,8 +150,7 @@ public class JSONObject extends LinkedHashMap<String, Object>
* @param defaultValue 查询失败时返回的值
* @return 返回指定的布尔值或者defaultValue
*/
public Boolean boolValue(final String name, final Boolean defaultValue)
{
public Boolean boolValue(final String name, final Boolean defaultValue) {
return StringUtils.nvl(boolValue(name), defaultValue);
}
@ -186,8 +160,7 @@ public class JSONObject extends LinkedHashMap<String, Object>
* @param name 字段名支持多级
* @return 返回指定的字符串值或者null
*/
public String strValue(final String name)
{
public String strValue(final String name) {
return valueAsStr(value(name));
}
@ -198,8 +171,7 @@ public class JSONObject extends LinkedHashMap<String, Object>
* @param defaultValue 查询失败时返回的值
* @return 返回指定的字符串值或者defaultValue
*/
public String strValue(final String name, final String defaultValue)
{
public String strValue(final String name, final String defaultValue) {
return StringUtils.nvl(strValue(name), defaultValue);
}
@ -209,29 +181,20 @@ public class JSONObject extends LinkedHashMap<String, Object>
* @param name 字段名支持多级支持数组下标
* @return 返回指定字段的值
*/
public Object value(final String name)
{
public Object value(final String name) {
final int indexDot = name.indexOf('.');
if (indexDot >= 0)
{
if (indexDot >= 0) {
return obj(name.substring(0, indexDot)).value(name.substring(indexDot + 1));
}
else
{
} else {
final Matcher matcher = arrayNamePattern.matcher(name);
if (matcher.find())
{
return endArray(matcher.group(1), matcher.group(2), new EndArrayCallback<Object>()
{
if (matcher.find()) {
return endArray(matcher.group(1), matcher.group(2), new EndArrayCallback<Object>() {
@Override
public Object callback(JSONArray arr, int index)
{
public Object callback(JSONArray arr, int index) {
return elementAt(arr, index);
}
});
}
else
{
} else {
return get(name);
}
}
@ -244,30 +207,21 @@ public class JSONObject extends LinkedHashMap<String, Object>
* @param value 字段值
* @return 返回本对象
*/
public JSONObject value(final String name, final Object value)
{
public JSONObject value(final String name, final Object value) {
final int indexDot = name.indexOf('.');
if (indexDot >= 0)
{
if (indexDot >= 0) {
obj(name.substring(0, indexDot)).value(name.substring(indexDot + 1), value);
}
else
{
} else {
final Matcher matcher = arrayNamePattern.matcher(name);
if (matcher.find())
{
endArray(matcher.group(1), matcher.group(2), new EndArrayCallback<Void>()
{
if (matcher.find()) {
endArray(matcher.group(1), matcher.group(2), new EndArrayCallback<Void>() {
@Override
public Void callback(JSONArray arr, int index)
{
public Void callback(JSONArray arr, int index) {
elementAt(arr, index, value);
return null;
}
});
}
else
{
} else {
set(name, value);
}
}
@ -280,25 +234,18 @@ public class JSONObject extends LinkedHashMap<String, Object>
* @param name 字段名不支持多级名字支持数组下标
* @return 返回指定的对象如果对象不存在则为指定的名字创建一个空的MessageObject对象
*/
public JSONObject obj(final String name)
{
public JSONObject obj(final String name) {
final Matcher matcher = arrayNamePattern.matcher(name);
if (matcher.find())
{
return endArray(matcher.group(1), matcher.group(2), new EndArrayCallback<JSONObject>()
{
if (matcher.find()) {
return endArray(matcher.group(1), matcher.group(2), new EndArrayCallback<JSONObject>() {
@Override
public JSONObject callback(JSONArray arr, int index)
{
public JSONObject callback(JSONArray arr, int index) {
return objAt(arr, index);
}
});
}
else
{
} else {
JSONObject obj = getObj(name);
if (obj == null)
{
if (obj == null) {
obj = new JSONObject();
put(name, obj);
}
@ -312,11 +259,9 @@ public class JSONObject extends LinkedHashMap<String, Object>
* @param name 字段名不支持多级名字不支持下标
* @return 返回一个数组List
*/
public JSONArray arr(final String name)
{
public JSONArray arr(final String name) {
JSONArray arr = getArr(name);
if (arr == null)
{
if (arr == null) {
arr = new JSONArray();
put(name, arr);
}
@ -329,8 +274,7 @@ public class JSONObject extends LinkedHashMap<String, Object>
* @param name 字段名
* @return 返回指定的对象字段
*/
public JSONObject getObj(final String name)
{
public JSONObject getObj(final String name) {
return (JSONObject) get(name);
}
@ -340,8 +284,7 @@ public class JSONObject extends LinkedHashMap<String, Object>
* @param name 字段名
* @return 返回数组类型字段
*/
public JSONArray getArr(final String name)
{
public JSONArray getArr(final String name) {
return (JSONArray) get(name);
}
@ -351,8 +294,7 @@ public class JSONObject extends LinkedHashMap<String, Object>
* @param name 字段名
* @return 返回指定字段整数值
*/
public Integer getInt(final String name)
{
public Integer getInt(final String name) {
return valueAsInt(get(name));
}
@ -363,8 +305,7 @@ public class JSONObject extends LinkedHashMap<String, Object>
* @param defaultValue 字段不存在时返回的值
* @return 返回指定字段整数值
*/
public Integer getInt(final String name, Integer defaultValue)
{
public Integer getInt(final String name, Integer defaultValue) {
return StringUtils.nvl(getInt(name), defaultValue);
}
@ -374,8 +315,7 @@ public class JSONObject extends LinkedHashMap<String, Object>
* @param name 字段名
* @return 返回指定字段长整数值
*/
public Long getLong(final String name)
{
public Long getLong(final String name) {
return valueAsLong(get(name));
}
@ -386,8 +326,7 @@ public class JSONObject extends LinkedHashMap<String, Object>
* @param defaultValue 字段不存在时返回的值
* @return 返回指定字段长整数值
*/
public Long getLong(final String name, Long defaultValue)
{
public Long getLong(final String name, Long defaultValue) {
return StringUtils.nvl(getLong(name), defaultValue);
}
@ -397,8 +336,7 @@ public class JSONObject extends LinkedHashMap<String, Object>
* @param name 字段名
* @return 返回指定字段字符串值
*/
public String getStr(final String name)
{
public String getStr(final String name) {
return valueAsStr(get(name));
}
@ -409,8 +347,7 @@ public class JSONObject extends LinkedHashMap<String, Object>
* @param defaultValue 字段不存在时返回的值
* @return 返回指定字段字符串值
*/
public String getStr(final String name, final String defaultValue)
{
public String getStr(final String name, final String defaultValue) {
return StringUtils.nvl(getStr(name), defaultValue);
}
@ -420,8 +357,7 @@ public class JSONObject extends LinkedHashMap<String, Object>
* @param name 字段名
* @return 字段值
*/
public Boolean getBool(final String name)
{
public Boolean getBool(final String name) {
return valueAsBool(get(name));
}
@ -432,8 +368,7 @@ public class JSONObject extends LinkedHashMap<String, Object>
* @param defaultValue 字段不存在时返回的值
* @return 字段值
*/
public Boolean getBool(final String name, final Boolean defaultValue)
{
public Boolean getBool(final String name, final Boolean defaultValue) {
return StringUtils.nvl(getBool(name), defaultValue);
}
@ -445,8 +380,7 @@ public class JSONObject extends LinkedHashMap<String, Object>
* 此时再修改Map中的数据将不会体现到本对象中
* @return 返回本对象
*/
public JSONObject set(final String name, final Object value)
{
public JSONObject set(final String name, final Object value) {
put(name, value);
return this;
}
@ -457,14 +391,10 @@ public class JSONObject extends LinkedHashMap<String, Object>
* @param beanClass Java Bean的类对象
* @return 返回转换后的Java Bean
*/
public <T> T asBean(Class<T> beanClass)
{
try
{
public <T> T asBean(Class<T> beanClass) {
try {
return JSON.unmarshal(JSON.marshal(this), beanClass);
}
catch (Exception e)
{
} catch (Exception e) {
throw new RuntimeException(e);
}
}
@ -474,91 +404,56 @@ public class JSONObject extends LinkedHashMap<String, Object>
* MessageObject 重载此方法的目的是为了使JSON能够正确地解析为MessageObject对象不建议直接调用此方法请使用 set(name, value)方法设置字段值
*/
@Override
public Object put(String key, Object value)
{
public Object put(String key, Object value) {
return super.put(key, transfer(value));
}
public static Integer valueAsInt(Object value)
{
if (value instanceof Integer)
{
public static Integer valueAsInt(Object value) {
if (value instanceof Integer) {
return (Integer) value;
}
else if (value instanceof Number)
{
} else if (value instanceof Number) {
return ((Number) value).intValue();
}
else if (value instanceof String)
{
} else if (value instanceof String) {
return Integer.valueOf((String) value);
}
else if (value instanceof Boolean)
{
} else if (value instanceof Boolean) {
return ((Boolean) value) ? 1 : 0;
}
else
{
} else {
return null;
}
}
public static Long valueAsLong(Object value)
{
if (value instanceof Long)
{
public static Long valueAsLong(Object value) {
if (value instanceof Long) {
return (Long) value;
}
else if (value instanceof Number)
{
} else if (value instanceof Number) {
return ((Number) value).longValue();
}
else if (value instanceof String)
{
} else if (value instanceof String) {
return Long.valueOf((String) value);
}
else if (value instanceof Boolean)
{
} else if (value instanceof Boolean) {
return ((Boolean) value) ? 1L : 0L;
}
else
{
} else {
return null;
}
}
public static String valueAsStr(Object value)
{
if (value instanceof String)
{
public static String valueAsStr(Object value) {
if (value instanceof String) {
return (String) value;
}
else if (value != null)
{
} else if (value != null) {
return value.toString();
}
else
{
} else {
return null;
}
}
public static Boolean valueAsBool(Object value)
{
if (value instanceof Boolean)
{
public static Boolean valueAsBool(Object value) {
if (value instanceof Boolean) {
return (Boolean) value;
}
else if (value instanceof Number)
{
} else if (value instanceof Number) {
return ((Number) value).doubleValue() != 0.0;
}
else if (value instanceof String)
{
} else if (value instanceof String) {
return Boolean.valueOf((String) value);
}
else
{
} else {
return null;
}
}
@ -570,37 +465,27 @@ public class JSONObject extends LinkedHashMap<String, Object>
* @return 返回转换后的值
*/
@SuppressWarnings("unchecked")
private static Object transfer(final Object value)
{
if (!(value instanceof JSONObject) && value instanceof Map)
{
private static Object transfer(final Object value) {
if (!(value instanceof JSONObject) && value instanceof Map) {
return toObj((Map<String, Object>) value);
}
else if (!(value instanceof JSONArray) && value instanceof Collection)
{
} else if (!(value instanceof JSONArray) && value instanceof Collection) {
return toArr((Collection<Object>) value);
}
else
{
} else {
return value;
}
}
private static JSONArray toArr(final Collection<Object> list)
{
private static JSONArray toArr(final Collection<Object> list) {
final JSONArray arr = new JSONArray(list.size());
for (final Object element : list)
{
for (final Object element : list) {
arr.add(element);
}
return arr;
}
private static JSONObject toObj(final Map<String, Object> map)
{
private static JSONObject toObj(final Map<String, Object> map) {
final JSONObject obj = new JSONObject();
for (final Map.Entry<String, Object> ent : map.entrySet())
{
for (final Map.Entry<String, Object> ent : map.entrySet()) {
obj.put(ent.getKey(), transfer(ent.getValue()));
}
return obj;
@ -613,11 +498,9 @@ public class JSONObject extends LinkedHashMap<String, Object>
* @param index 下标
* @return 返回当前数组指定下标的元素该元素应该是一个数组
*/
private static JSONArray arrayAt(JSONArray arr, int index)
{
private static JSONArray arrayAt(JSONArray arr, int index) {
expand(arr, index);
if (arr.get(index) == null)
{
if (arr.get(index) == null) {
arr.set(index, new JSONArray());
}
return (JSONArray) arr.get(index);
@ -630,11 +513,9 @@ public class JSONObject extends LinkedHashMap<String, Object>
* @param index 下标
* @return 返回当前数组指定下标元素该元素是一个结构体
*/
private static JSONObject objAt(final JSONArray arr, int index)
{
private static JSONObject objAt(final JSONArray arr, int index) {
expand(arr, index);
if (arr.get(index) == null)
{
if (arr.get(index) == null) {
arr.set(index, new JSONObject());
}
return (JSONObject) arr.get(index);
@ -647,8 +528,7 @@ public class JSONObject extends LinkedHashMap<String, Object>
* @param index 下标
* @param value
*/
private static void elementAt(final JSONArray arr, final int index, final Object value)
{
private static void elementAt(final JSONArray arr, final int index, final Object value) {
expand(arr, index).set(index, value);
}
@ -659,8 +539,7 @@ public class JSONObject extends LinkedHashMap<String, Object>
* @param index 下标
* @return
*/
private static Object elementAt(final JSONArray arr, final int index)
{
private static Object elementAt(final JSONArray arr, final int index) {
return expand(arr, index).get(index);
}
@ -671,10 +550,8 @@ public class JSONObject extends LinkedHashMap<String, Object>
* @param index 下标
* @return 返回传入的数组
*/
private static JSONArray expand(final JSONArray arr, final int index)
{
while (arr.size() <= index)
{
private static JSONArray expand(final JSONArray arr, final int index) {
while (arr.size() <= index) {
arr.add(null);
}
return arr;
@ -683,12 +560,10 @@ public class JSONObject extends LinkedHashMap<String, Object>
/**
* 最后数组回调
*
* @author Mike
*
* @param <T> 回调返回数据类型
* @author Mike
*/
private interface EndArrayCallback<T>
{
private interface EndArrayCallback<T> {
/**
* 当定位到最后一级数组将调用本方法
*
@ -708,29 +583,24 @@ public class JSONObject extends LinkedHashMap<String, Object>
* @param callback 回调函数
* @return 返回回调函数的返回值
*/
private <T> T endArray(final String name, final String indexesStr, final EndArrayCallback<T> callback)
{
private <T> T endArray(final String name, final String indexesStr, final EndArrayCallback<T> callback) {
JSONArray endArr = arr(name);
final int[] indexes = parseIndexes(indexesStr);
int i = 0;
while (i < indexes.length - 1)
{
while (i < indexes.length - 1) {
endArr = arrayAt(endArr, indexes[i++]);
}
return callback.callback(endArr, indexes[i]);
}
private static int[] parseIndexes(final String s)
{
private static int[] parseIndexes(final String s) {
int[] indexes = null;
List<Integer> list = new ArrayList<Integer>();
final StringTokenizer st = new StringTokenizer(s, "[]");
while (st.hasMoreTokens())
{
while (st.hasMoreTokens()) {
final int index = Integer.valueOf(st.nextToken());
if (index < 0)
{
if (index < 0) {
throw new RuntimeException(String.format("Illegal index %1$d in \"%2$s\"", index, s));
}
@ -739,8 +609,7 @@ public class JSONObject extends LinkedHashMap<String, Object>
indexes = new int[list.size()];
int i = 0;
for (Integer tmp : list.toArray(new Integer[list.size()]))
{
for (Integer tmp : list.toArray(new Integer[list.size()])) {
indexes[i++] = tmp;
}

View File

@ -0,0 +1,230 @@
package com.ruoyi.common.repository;
import com.querydsl.core.types.OrderSpecifier;
import com.querydsl.core.types.Predicate;
import org.springframework.data.domain.Example;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.support.*;
import org.springframework.data.querydsl.QuerydslPredicateExecutor;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import javax.persistence.EntityManager;
import java.io.Serializable;
import java.util.List;
import java.util.Optional;
public class DataScopeRepository<T, ID extends Serializable> implements JpaRepositoryImplementation<T, ID>,
QuerydslPredicateExecutor<T> {
private @Nullable
CrudMethodMetadata metadata;
private SimpleJpaRepository<T, ID> simpleJpaRepository;
private QuerydslPredicateExecutor<T> querydslPredicateExecutor;
public DataScopeRepository(JpaEntityInformation<T, ?> entityInformation, EntityManager entityManager) {
Assert.notNull(entityInformation, "JpaEntityInformation must not be null!");
Assert.notNull(entityManager, "EntityManager must not be null!");
this.simpleJpaRepository = new SimpleJpaRepository<T, ID>(entityInformation, entityManager);
}
public DataScopeRepository(Class<T> domainClass, EntityManager em) {
this.simpleJpaRepository = new SimpleJpaRepository<T, ID>(JpaEntityInformationSupport.getEntityInformation(domainClass, em), em);
}
@Override
public void setRepositoryMethodMetadata(CrudMethodMetadata crudMethodMetadata) {
this.metadata = crudMethodMetadata;
simpleJpaRepository.setRepositoryMethodMetadata(crudMethodMetadata);
}
@Override
public List<T> findAll() {
return simpleJpaRepository.findAll();
}
@Override
public List<T> findAll(Sort sort) {
return null;
}
@Override
public Page<T> findAll(Pageable pageable) {
return null;
}
@Override
public List<T> findAllById(Iterable<ID> ids) {
return null;
}
@Override
public long count() {
return 0;
}
@Override
public void deleteById(ID id) {
}
@Override
public void delete(T entity) {
}
@Override
public void deleteAll(Iterable<? extends T> entities) {
}
@Override
public void deleteAll() {
}
@Override
public <S extends T> S save(S entity) {
return null;
}
@Override
public <S extends T> List<S> saveAll(Iterable<S> entities) {
return null;
}
@Override
public Optional<T> findById(ID id) {
return Optional.empty();
}
@Override
public boolean existsById(ID id) {
return false;
}
@Override
public void flush() {
}
@Override
public <S extends T> S saveAndFlush(S entity) {
return null;
}
@Override
public void deleteInBatch(Iterable<T> entities) {
}
@Override
public void deleteAllInBatch() {
}
@Override
public T getOne(ID id) {
return null;
}
@Override
public <S extends T> Optional<S> findOne(Example<S> example) {
return Optional.empty();
}
@Override
public <S extends T> List<S> findAll(Example<S> example) {
return null;
}
@Override
public <S extends T> List<S> findAll(Example<S> example, Sort sort) {
return null;
}
@Override
public <S extends T> Page<S> findAll(Example<S> example, Pageable pageable) {
return null;
}
@Override
public <S extends T> long count(Example<S> example) {
return 0;
}
@Override
public <S extends T> boolean exists(Example<S> example) {
return false;
}
@Override
public Optional<T> findOne(Specification<T> spec) {
return Optional.empty();
}
@Override
public List<T> findAll(Specification<T> spec) {
return null;
}
@Override
public Page<T> findAll(Specification<T> spec, Pageable pageable) {
return null;
}
@Override
public List<T> findAll(Specification<T> spec, Sort sort) {
return null;
}
@Override
public long count(Specification<T> spec) {
return 0;
}
@Override
public Optional<T> findOne(Predicate predicate) {
return querydslPredicateExecutor.findOne(predicate);
}
@Override
public Iterable<T> findAll(Predicate predicate) {
return querydslPredicateExecutor.findAll(predicate);
}
@Override
public Iterable<T> findAll(Predicate predicate, Sort sort) {
return querydslPredicateExecutor.findAll(predicate, sort);
}
@Override
public Iterable<T> findAll(Predicate predicate, OrderSpecifier<?>... orders) {
return querydslPredicateExecutor.findAll(predicate, orders);
}
@Override
public Iterable<T> findAll(OrderSpecifier<?>... orders) {
return querydslPredicateExecutor.findAll(orders);
}
@Override
public Page<T> findAll(Predicate predicate, Pageable pageable) {
return querydslPredicateExecutor.findAll(predicate, pageable);
}
@Override
public long count(Predicate predicate) {
return querydslPredicateExecutor.count(predicate);
}
@Override
public boolean exists(Predicate predicate) {
return querydslPredicateExecutor.exists(predicate);
}
}

View File

@ -8,25 +8,27 @@ import java.math.RoundingMode;
*
* @author ruoyi
*/
public class Arith
{
public class Arith {
/** 默认除法运算精度 */
/**
* 默认除法运算精度
*/
private static final int DEF_DIV_SCALE = 10;
/** 这个类不能实例化 */
private Arith()
{
/**
* 这个类不能实例化
*/
private Arith() {
}
/**
* 提供精确的加法运算
*
* @param v1 被加数
* @param v2 加数
* @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 b2 = new BigDecimal(Double.toString(v2));
return b1.add(b2).doubleValue();
@ -34,12 +36,12 @@ public class Arith
/**
* 提供精确的减法运算
*
* @param v1 被减数
* @param v2 减数
* @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 b2 = new BigDecimal(Double.toString(v2));
return b1.subtract(b2).doubleValue();
@ -47,12 +49,12 @@ public class Arith
/**
* 提供精确的乘法运算
*
* @param v1 被乘数
* @param v2 乘数
* @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 b2 = new BigDecimal(Double.toString(v2));
return b1.multiply(b2).doubleValue();
@ -61,34 +63,32 @@ public class Arith
/**
* 提供相对精确的除法运算当发生除不尽的情况时精确到
* 小数点以后10位以后的数字四舍五入
*
* @param v1 被除数
* @param v2 除数
* @return 两个参数的商
*/
public static double div(double v1, double v2)
{
public static double div(double v1, double v2) {
return div(v1, v2, DEF_DIV_SCALE);
}
/**
* 提供相对精确的除法运算当发生除不尽的情况时由scale参数指
* 定精度以后的数字四舍五入
*
* @param v1 被除数
* @param v2 除数
* @param scale 表示表示需要精确到小数点以后几位
* @return 两个参数的商
*/
public static double div(double v1, double v2, int scale)
{
if (scale < 0)
{
public static double div(double v1, double v2, int scale) {
if (scale < 0) {
throw new IllegalArgumentException(
"The scale must be a positive integer or zero");
}
BigDecimal b1 = new BigDecimal(Double.toString(v1));
BigDecimal b2 = new BigDecimal(Double.toString(v2));
if (b1.compareTo(BigDecimal.ZERO) == 0)
{
if (b1.compareTo(BigDecimal.ZERO) == 0) {
return BigDecimal.ZERO.doubleValue();
}
return b1.divide(b2, scale, RoundingMode.HALF_UP).doubleValue();
@ -96,14 +96,13 @@ public class Arith
/**
* 提供精确的小数位四舍五入处理
*
* @param v 需要四舍五入的数字
* @param scale 小数点后保留几位
* @return 四舍五入后的结果
*/
public static double round(double v, int scale)
{
if (scale < 0)
{
public static double round(double v, int scale) {
if (scale < 0) {
throw new IllegalArgumentException(
"The scale must be a positive integer or zero");
}

View File

@ -4,6 +4,7 @@ import java.lang.management.ManagementFactory;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.apache.commons.lang3.time.DateFormatUtils;
/**
@ -11,8 +12,7 @@ import org.apache.commons.lang3.time.DateFormatUtils;
*
* @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_MM = "yyyy-MM";
@ -33,8 +33,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
*
* @return Date() 当前日期
*/
public static Date getNowDate()
{
public static Date getNowDate() {
return new Date();
}
@ -43,44 +42,34 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
*
* @return String
*/
public static String getDate()
{
public static String getDate() {
return dateTimeNow(YYYY_MM_DD);
}
public static final String getTime()
{
public static final String getTime() {
return dateTimeNow(YYYY_MM_DD_HH_MM_SS);
}
public static final String dateTimeNow()
{
public static final String dateTimeNow() {
return dateTimeNow(YYYYMMDDHHMMSS);
}
public static final String dateTimeNow(final String format)
{
public static final String dateTimeNow(final String format) {
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);
}
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);
}
public static final Date dateTime(final String format, final String ts)
{
try
{
public static final Date dateTime(final String format, final String ts) {
try {
return new SimpleDateFormat(format).parse(ts);
}
catch (ParseException e)
{
} catch (ParseException e) {
throw new RuntimeException(e);
}
}
@ -88,8 +77,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
/**
* 日期路径 即年// 如2018/08/08
*/
public static final String datePath()
{
public static final String datePath() {
Date now = new Date();
return DateFormatUtils.format(now, "yyyy/MM/dd");
}
@ -97,8 +85,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
/**
* 日期路径 即年// 如20180808
*/
public static final String dateTime()
{
public static final String dateTime() {
Date now = new Date();
return DateFormatUtils.format(now, "yyyyMMdd");
}
@ -106,18 +93,13 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
/**
* 日期型字符串转化为日期 格式
*/
public static Date parseDate(Object str)
{
if (str == null)
{
public static Date parseDate(Object str) {
if (str == null) {
return null;
}
try
{
try {
return parseDate(str.toString(), parsePatterns);
}
catch (ParseException e)
{
} catch (ParseException e) {
return null;
}
}
@ -125,8 +107,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
/**
* 获取服务器启动时间
*/
public static Date getServerStartDate()
{
public static Date getServerStartDate() {
long time = ManagementFactory.getRuntimeMXBean().getStartTime();
return new Date(time);
}
@ -134,8 +115,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
/**
* 计算两个时间差
*/
public static String getDatePoor(Date endDate, Date nowDate)
{
public static String getDatePoor(Date endDate, Date nowDate) {
long nd = 1000 * 24 * 60 * 60;
long nh = 1000 * 60 * 60;
long nm = 1000 * 60;

View File

@ -2,6 +2,7 @@ package com.ruoyi.common.utils;
import java.io.PrintWriter;
import java.io.StringWriter;
import org.apache.commons.lang3.exception.ExceptionUtils;
/**
@ -9,30 +10,25 @@ import org.apache.commons.lang3.exception.ExceptionUtils;
*
* @author ruoyi
*/
public class ExceptionUtil
{
public class ExceptionUtil {
/**
* 获取exception的详细错误信息
*/
public static String getExceptionMessage(Throwable e)
{
public static String getExceptionMessage(Throwable e) {
StringWriter sw = new StringWriter();
e.printStackTrace(new PrintWriter(sw, true));
String str = sw.toString();
return str;
}
public static String getRootErrorMseeage(Exception e)
{
public static String getRootErrorMseeage(Exception e) {
Throwable root = ExceptionUtils.getRootCause(e);
root = (root == null ? e : root);
if (root == null)
{
if (root == null) {
return "";
}
String msg = root.getMessage();
if (msg == null)
{
if (msg == null) {
return "null";
}
return StringUtils.defaultString(msg);

Some files were not shown because too many files have changed in this diff Show More