班级表增删改查 全局格式化代码

master
liuyunhu 2024-04-22 21:08:06 +08:00
parent 8f4cc5e9f3
commit 2cb1520b9e
280 changed files with 5754 additions and 5305 deletions

View File

@ -18,23 +18,29 @@
* 权限认证使用Jwt支持多终端认证系统。 * 权限认证使用Jwt支持多终端认证系统。
* 支持加载动态权限菜单,多方式轻松权限控制。 * 支持加载动态权限菜单,多方式轻松权限控制。
* 高效率开发,使用代码生成器可以一键生成前后端代码。 * 高效率开发,使用代码生成器可以一键生成前后端代码。
* 提供了技术栈([Vue3](https://v3.cn.vuejs.org) [Element Plus](https://element-plus.org/zh-CN) [Vite](https://cn.vitejs.dev))版本[RuoYi-Vue3](https://github.com/yangzongzhuan/RuoYi-Vue3),保持同步更新。 *
* 提供了单应用版本[RuoYi-Vue-fast](https://github.com/yangzongzhuan/RuoYi-Vue-fast)Oracle版本[RuoYi-Vue-Oracle](https://github.com/yangzongzhuan/RuoYi-Vue-Oracle),保持同步更新。 提供了技术栈([Vue3](https://v3.cn.vuejs.org) [Element Plus](https://element-plus.org/zh-CN) [Vite](https://cn.vitejs.dev)
* 不分离版本,请移步[RuoYi](https://gitee.com/y_project/RuoYi),微服务版本,请移步[RuoYi-Cloud](https://gitee.com/y_project/RuoYi-Cloud) )版本[RuoYi-Vue3](https://github.com/yangzongzhuan/RuoYi-Vue3),保持同步更新。
* 提供了单应用版本[RuoYi-Vue-fast](https://github.com/yangzongzhuan/RuoYi-Vue-fast)
Oracle版本[RuoYi-Vue-Oracle](https://github.com/yangzongzhuan/RuoYi-Vue-Oracle),保持同步更新。
* 不分离版本,请移步[RuoYi](https://gitee.com/y_project/RuoYi)
,微服务版本,请移步[RuoYi-Cloud](https://gitee.com/y_project/RuoYi-Cloud)
* 阿里云折扣场:[点我进入](http://aly.ruoyi.vip),腾讯云秒杀场:[点我进入](http://txy.ruoyi.vip)   * 阿里云折扣场:[点我进入](http://aly.ruoyi.vip),腾讯云秒杀场:[点我进入](http://txy.ruoyi.vip)  
* 阿里云优惠券:[点我领取](https://www.aliyun.com/minisite/goods?userCode=brki8iof&share_source=copy_link),腾讯云优惠券:[点我领取](https://cloud.tencent.com/redirect.php?redirect=1025&cps_key=198c8df2ed259157187173bc7f4f32fd&from=console)   * 阿里云优惠券:[点我领取](https://www.aliyun.com/minisite/goods?userCode=brki8iof&share_source=copy_link)
,腾讯云优惠券:[点我领取](https://cloud.tencent.com/redirect.php?redirect=1025&cps_key=198c8df2ed259157187173bc7f4f32fd&from=console)
  
## 内置功能 ## 内置功能
1. 用户管理:用户是系统操作者,该功能主要完成系统用户配置。 1. 用户管理:用户是系统操作者,该功能主要完成系统用户配置。
2. 部门管理:配置系统组织机构(公司、部门、小组),树结构展现支持数据权限。 2. 部门管理:配置系统组织机构(公司、部门、小组),树结构展现支持数据权限。
3. 岗位管理:配置系统用户所属担任职务。 3. 岗位管理:配置系统用户所属担任职务。
4. 菜单管理:配置系统菜单,操作权限,按钮权限标识等。 4. 菜单管理:配置系统菜单,操作权限,按钮权限标识等。
5. 角色管理:角色菜单权限分配、设置角色按机构进行数据范围权限划分。 5. 角色管理:角色菜单权限分配、设置角色按机构进行数据范围权限划分。
6. 字典管理:对系统中经常使用的一些较为固定的数据进行维护。 6. 字典管理:对系统中经常使用的一些较为固定的数据进行维护。
7. 参数管理:对系统动态配置常用参数。 7. 参数管理:对系统动态配置常用参数。
8. 通知公告:系统通知公告信息发布维护。 8. 通知公告:系统通知公告信息发布维护。
9. 操作日志:系统正常操作日志记录和查询;系统异常信息日志记录和查询。 9. 操作日志:系统正常操作日志记录和查询;系统异常信息日志记录和查询。
10. 登录日志:系统登录日志记录查询包含登录异常。 10. 登录日志:系统登录日志记录查询包含登录异常。
11. 在线用户:当前系统中活跃用户状态监控。 11. 在线用户:当前系统中活跃用户状态监控。
12. 定时任务:在线(添加、修改、删除)任务调度包含执行结果日志。 12. 定时任务:在线(添加、修改、删除)任务调度包含执行结果日志。
@ -47,7 +53,7 @@
## 在线体验 ## 在线体验
- admin/admin123 - admin/admin123
- 陆陆续续收到一些打赏,为了更好的体验已用于演示服务器升级。谢谢各位小伙伴。 - 陆陆续续收到一些打赏,为了更好的体验已用于演示服务器升级。谢谢各位小伙伴。
演示地址http://vue.ruoyi.vip 演示地址http://vue.ruoyi.vip
@ -90,7 +96,7 @@
</tr> </tr>
</table> </table>
## 若依前后端分离交流群 ## 若依前后端分离交流群
QQ群 [![加入QQ群](https://img.shields.io/badge/已满-937441-blue.svg)](https://jq.qq.com/?_wv=1027&k=5bVB1og) [![加入QQ群](https://img.shields.io/badge/已满-887144332-blue.svg)](https://jq.qq.com/?_wv=1027&k=5eiA4DH) [![加入QQ群](https://img.shields.io/badge/已满-180251782-blue.svg)](https://jq.qq.com/?_wv=1027&k=5AxMKlC) [![加入QQ群](https://img.shields.io/badge/已满-104180207-blue.svg)](https://jq.qq.com/?_wv=1027&k=51G72yr) [![加入QQ群](https://img.shields.io/badge/已满-186866453-blue.svg)](https://jq.qq.com/?_wv=1027&k=VvjN2nvu) [![加入QQ群](https://img.shields.io/badge/已满-201396349-blue.svg)](https://jq.qq.com/?_wv=1027&k=5vYAqA05) [![加入QQ群](https://img.shields.io/badge/已满-101456076-blue.svg)](https://jq.qq.com/?_wv=1027&k=kOIINEb5) [![加入QQ群](https://img.shields.io/badge/已满-101539465-blue.svg)](https://jq.qq.com/?_wv=1027&k=UKtX5jhs) [![加入QQ群](https://img.shields.io/badge/已满-264312783-blue.svg)](https://jq.qq.com/?_wv=1027&k=EI9an8lJ) [![加入QQ群](https://img.shields.io/badge/已满-167385320-blue.svg)](https://jq.qq.com/?_wv=1027&k=SWCtLnMz) [![加入QQ群](https://img.shields.io/badge/已满-104748341-blue.svg)](https://jq.qq.com/?_wv=1027&k=96Dkdq0k) [![加入QQ群](https://img.shields.io/badge/已满-160110482-blue.svg)](https://jq.qq.com/?_wv=1027&k=0fsNiYZt) [![加入QQ群](https://img.shields.io/badge/已满-170801498-blue.svg)](https://jq.qq.com/?_wv=1027&k=7xw4xUG1) [![加入QQ群](https://img.shields.io/badge/已满-108482800-blue.svg)](https://jq.qq.com/?_wv=1027&k=eCx8eyoJ) [![加入QQ群](https://img.shields.io/badge/已满-101046199-blue.svg)](https://jq.qq.com/?_wv=1027&k=SpyH2875) [![加入QQ群](https://img.shields.io/badge/已满-136919097-blue.svg)](https://jq.qq.com/?_wv=1027&k=tKEt51dz) [![加入QQ群](https://img.shields.io/badge/143961921-blue.svg)](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=0vBbSb0ztbBgVtn3kJS-Q4HUNYwip89G&authKey=8irq5PhutrZmWIvsUsklBxhj57l%2F1nOZqjzigkXZVoZE451GG4JHPOqW7AW6cf0T&noverify=0&group_code=143961921) 点击按钮入群。 QQ群 [![加入QQ群](https://img.shields.io/badge/已满-937441-blue.svg)](https://jq.qq.com/?_wv=1027&k=5bVB1og) [![加入QQ群](https://img.shields.io/badge/已满-887144332-blue.svg)](https://jq.qq.com/?_wv=1027&k=5eiA4DH) [![加入QQ群](https://img.shields.io/badge/已满-180251782-blue.svg)](https://jq.qq.com/?_wv=1027&k=5AxMKlC) [![加入QQ群](https://img.shields.io/badge/已满-104180207-blue.svg)](https://jq.qq.com/?_wv=1027&k=51G72yr) [![加入QQ群](https://img.shields.io/badge/已满-186866453-blue.svg)](https://jq.qq.com/?_wv=1027&k=VvjN2nvu) [![加入QQ群](https://img.shields.io/badge/已满-201396349-blue.svg)](https://jq.qq.com/?_wv=1027&k=5vYAqA05) [![加入QQ群](https://img.shields.io/badge/已满-101456076-blue.svg)](https://jq.qq.com/?_wv=1027&k=kOIINEb5) [![加入QQ群](https://img.shields.io/badge/已满-101539465-blue.svg)](https://jq.qq.com/?_wv=1027&k=UKtX5jhs) [![加入QQ群](https://img.shields.io/badge/已满-264312783-blue.svg)](https://jq.qq.com/?_wv=1027&k=EI9an8lJ) [![加入QQ群](https://img.shields.io/badge/已满-167385320-blue.svg)](https://jq.qq.com/?_wv=1027&k=SWCtLnMz) [![加入QQ群](https://img.shields.io/badge/已满-104748341-blue.svg)](https://jq.qq.com/?_wv=1027&k=96Dkdq0k) [![加入QQ群](https://img.shields.io/badge/已满-160110482-blue.svg)](https://jq.qq.com/?_wv=1027&k=0fsNiYZt) [![加入QQ群](https://img.shields.io/badge/已满-170801498-blue.svg)](https://jq.qq.com/?_wv=1027&k=7xw4xUG1) [![加入QQ群](https://img.shields.io/badge/已满-108482800-blue.svg)](https://jq.qq.com/?_wv=1027&k=eCx8eyoJ) [![加入QQ群](https://img.shields.io/badge/已满-101046199-blue.svg)](https://jq.qq.com/?_wv=1027&k=SpyH2875) [![加入QQ群](https://img.shields.io/badge/已满-136919097-blue.svg)](https://jq.qq.com/?_wv=1027&k=tKEt51dz) [![加入QQ群](https://img.shields.io/badge/143961921-blue.svg)](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=0vBbSb0ztbBgVtn3kJS-Q4HUNYwip89G&authKey=8irq5PhutrZmWIvsUsklBxhj57l%2F1nOZqjzigkXZVoZE451GG4JHPOqW7AW6cf0T&noverify=0&group_code=143961921)
点击按钮入群。

View File

@ -2,7 +2,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" <project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>com.muyu</groupId> <groupId>com.muyu</groupId>
<artifactId>ruoyi</artifactId> <artifactId>ruoyi</artifactId>
@ -177,13 +177,18 @@
<version>${ruoyi.version}</version> <version>${ruoyi.version}</version>
</dependency> </dependency>
<!-- 自定义项目-->
<dependency>
<groupId>com.muyu</groupId>
<artifactId>ruoyi-custom</artifactId>
<version>${ruoyi.version}</version>
</dependency>
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>
<modules> <modules>
<module>ruoyi-application</module> <module>ruoyi-application</module>
<module>ruoyi-basic</module> <module>ruoyi-basic</module>
<module>ruoyi-custom</module>
</modules> </modules>
<packaging>pom</packaging> <packaging>pom</packaging>

View File

@ -11,8 +11,9 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
* @author ruoyi * @author ruoyi
*/ */
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}) @SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
@MapperScan("com.ruoyi.*.mapper")
public class RuoYiApplication { public class RuoYiApplication {
public static void main (String[] args) { public static void main(String[] args) {
SpringApplication.run(RuoYiApplication.class, args); SpringApplication.run(RuoYiApplication.class, args);
System.out.println("(♥◠‿◠)ノ゙ 若依启动成功 ლ(´ڡ`ლ)゙"); System.out.println("(♥◠‿◠)ノ゙ 若依启动成功 ლ(´ڡ`ლ)゙");
} }

View File

@ -10,7 +10,7 @@ import org.springframework.boot.web.servlet.support.SpringBootServletInitializer
*/ */
public class RuoYiServletInitializer extends SpringBootServletInitializer { public class RuoYiServletInitializer extends SpringBootServletInitializer {
@Override @Override
protected SpringApplicationBuilder configure (SpringApplicationBuilder application) { protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(RuoYiApplication.class); return application.sources(RuoYiApplication.class);
} }
} }

View File

@ -45,7 +45,7 @@ public class CaptchaController {
* *
*/ */
@GetMapping("/captchaImage") @GetMapping("/captchaImage")
public Result<CaptchaModel> getCode (HttpServletResponse response) throws IOException { public Result<CaptchaModel> getCode(HttpServletResponse response) throws IOException {
Result<CaptchaModel> ajax = Result.success(); Result<CaptchaModel> ajax = Result.success();
boolean captchaEnabled = configService.selectCaptchaEnabled(); boolean captchaEnabled = configService.selectCaptchaEnabled();
CaptchaModel.CaptchaModelBuilder builder CaptchaModel.CaptchaModelBuilder builder

View File

@ -43,7 +43,7 @@ public class CommonController {
* @param delete * @param delete
*/ */
@GetMapping("/download") @GetMapping("/download")
public void fileDownload (String fileName, Boolean delete, HttpServletResponse response, HttpServletRequest request) { public void fileDownload(String fileName, Boolean delete, HttpServletResponse response, HttpServletRequest request) {
try { try {
if (!FileUtils.checkAllowDownload(fileName)) { if (!FileUtils.checkAllowDownload(fileName)) {
throw new Exception(StringUtils.format("文件名称({})非法,不允许下载。 ", fileName)); throw new Exception(StringUtils.format("文件名称({})非法,不允许下载。 ", fileName));
@ -66,7 +66,7 @@ public class CommonController {
* *
*/ */
@PostMapping("/upload") @PostMapping("/upload")
public Result<UploadFileModel> uploadFile (MultipartFile file) throws Exception { public Result<UploadFileModel> uploadFile(MultipartFile file) throws Exception {
try { try {
// 上传文件路径 // 上传文件路径
String filePath = RuoYiConfig.getUploadPath(); String filePath = RuoYiConfig.getUploadPath();
@ -89,7 +89,7 @@ public class CommonController {
* *
*/ */
@PostMapping("/uploads") @PostMapping("/uploads")
public Result<List<UploadFileModel>> uploadFiles (List<MultipartFile> files) throws Exception { public Result<List<UploadFileModel>> uploadFiles(List<MultipartFile> files) throws Exception {
try { try {
// 上传文件路径 // 上传文件路径
String filePath = RuoYiConfig.getUploadPath(); String filePath = RuoYiConfig.getUploadPath();
@ -116,7 +116,7 @@ public class CommonController {
* *
*/ */
@GetMapping("/download/resource") @GetMapping("/download/resource")
public void resourceDownload (String resource, HttpServletRequest request, HttpServletResponse response) public void resourceDownload(String resource, HttpServletRequest request, HttpServletResponse response)
throws Exception { throws Exception {
try { try {
if (!FileUtils.checkAllowDownload(resource)) { if (!FileUtils.checkAllowDownload(resource)) {

View File

@ -0,0 +1,106 @@
package com.ruoyi.web.controller.custom;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.Result;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.custom.domain.SysClass;
import com.ruoyi.custom.domain.req.SysClassEditReq;
import com.ruoyi.custom.domain.req.SysClassQueryReq;
import com.ruoyi.custom.domain.req.SysClassSaveReq;
import com.ruoyi.custom.service.SysClassService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* Controller
*
* @author ruoyi
* @date 2024-04-22
*/
@Api(tags = "班级管理")
@RestController
@RequestMapping("/custom/class")
public class SysClassController extends BaseController {
@Autowired
private SysClassService sysClassService;
/**
*
*/
@ApiOperation("获取班级管理列表")
@PreAuthorize("@ss.hasPermi('custom:class:list')")
@GetMapping("/list")
public Result<TableDataInfo<SysClass>> list(SysClassQueryReq sysClassQueryReq) {
startPage();
List<SysClass> list = sysClassService.list(SysClass.queryBuild(sysClassQueryReq));
return getDataTable(list);
}
/**
*
*/
@ApiOperation("导出班级管理列表")
@PreAuthorize("@ss.hasPermi('custom:class:export')")
@Log(title = "班级管理", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, SysClass sysClass) {
List<SysClass> list = sysClassService.list(sysClass);
ExcelUtil<SysClass> util = new ExcelUtil<SysClass>(SysClass.class);
util.exportExcel(response, list, "班级管理数据");
}
/**
*
*/
@ApiOperation("获取班级管理详细信息")
@PreAuthorize("@ss.hasPermi('custom:class:query')")
@GetMapping(value = "/{classId}")
@ApiImplicitParam(name = "classId", value = "classId", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class)
public Result<SysClass> getInfo(@PathVariable("classId") Long classId) {
return Result.success(sysClassService.getById(classId));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('custom:class:add')")
@Log(title = "班级管理", businessType = BusinessType.INSERT)
@PostMapping
@ApiOperation("新增班级管理")
public Result<String> add(@RequestBody SysClassSaveReq sysClassSaveReq) {
return toAjax(sysClassService.save(SysClass.saveBuild(sysClassSaveReq)));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('custom:class:edit')")
@Log(title = "班级管理", businessType = BusinessType.UPDATE)
@PutMapping("/{classId}")
@ApiOperation("修改班级管理")
public Result<String> edit(@PathVariable Long classId, @RequestBody SysClassEditReq sysClassEditReq) {
return toAjax(sysClassService.updateById(SysClass.editBuild(classId, sysClassEditReq)));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('custom:class:remove')")
@Log(title = "班级管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{classIds}")
@ApiOperation("删除班级管理")
@ApiImplicitParam(name = "classId", value = "classId", required = true, dataType = "Long", paramType = "path", dataTypeClass = String.class, example = "1,2,3,4")
public Result<String> remove(@PathVariable List<Long> classIds) {
return toAjax(sysClassService.removeBatchByIds(classIds));
}
}

View File

@ -36,7 +36,7 @@ public class CacheController {
@PreAuthorize("@ss.hasPermi('monitor:cache:list')") @PreAuthorize("@ss.hasPermi('monitor:cache:list')")
@GetMapping() @GetMapping()
public Result<Map<String, Object>> getInfo () throws Exception { public Result<Map<String, Object>> getInfo() throws Exception {
Properties info = (Properties) redisTemplate.execute((RedisCallback<Object>) connection -> connection.info()); Properties info = (Properties) redisTemplate.execute((RedisCallback<Object>) connection -> connection.info());
Properties commandStats = (Properties) redisTemplate.execute((RedisCallback<Object>) connection -> connection.info("commandstats")); Properties commandStats = (Properties) redisTemplate.execute((RedisCallback<Object>) connection -> connection.info("commandstats"));
Object dbSize = redisTemplate.execute((RedisCallback<Object>) connection -> connection.dbSize()); Object dbSize = redisTemplate.execute((RedisCallback<Object>) connection -> connection.dbSize());
@ -59,20 +59,20 @@ public class CacheController {
@PreAuthorize("@ss.hasPermi('monitor:cache:list')") @PreAuthorize("@ss.hasPermi('monitor:cache:list')")
@GetMapping("/getNames") @GetMapping("/getNames")
public Result<List<SysCache>> cache () { public Result<List<SysCache>> cache() {
return Result.success(caches); return Result.success(caches);
} }
@PreAuthorize("@ss.hasPermi('monitor:cache:list')") @PreAuthorize("@ss.hasPermi('monitor:cache:list')")
@GetMapping("/getKeys/{cacheName}") @GetMapping("/getKeys/{cacheName}")
public Result<Set<String>> getCacheKeys (@PathVariable String cacheName) { public Result<Set<String>> getCacheKeys(@PathVariable String cacheName) {
Set<String> cacheKeys = redisTemplate.keys(cacheName + "*"); Set<String> cacheKeys = redisTemplate.keys(cacheName + "*");
return Result.success(cacheKeys); return Result.success(cacheKeys);
} }
@PreAuthorize("@ss.hasPermi('monitor:cache:list')") @PreAuthorize("@ss.hasPermi('monitor:cache:list')")
@GetMapping("/getValue/{cacheName}/{cacheKey}") @GetMapping("/getValue/{cacheName}/{cacheKey}")
public Result<SysCache> getCacheValue (@PathVariable String cacheName, @PathVariable String cacheKey) { public Result<SysCache> getCacheValue(@PathVariable String cacheName, @PathVariable String cacheKey) {
String cacheValue = redisTemplate.opsForValue().get(cacheKey); String cacheValue = redisTemplate.opsForValue().get(cacheKey);
SysCache sysCache = new SysCache(cacheName, cacheKey, cacheValue); SysCache sysCache = new SysCache(cacheName, cacheKey, cacheValue);
return Result.success(sysCache); return Result.success(sysCache);
@ -80,7 +80,7 @@ public class CacheController {
@PreAuthorize("@ss.hasPermi('monitor:cache:list')") @PreAuthorize("@ss.hasPermi('monitor:cache:list')")
@DeleteMapping("/clearCacheName/{cacheName}") @DeleteMapping("/clearCacheName/{cacheName}")
public Result<String> clearCacheName (@PathVariable String cacheName) { public Result<String> clearCacheName(@PathVariable String cacheName) {
Collection<String> cacheKeys = redisTemplate.keys(cacheName + "*"); Collection<String> cacheKeys = redisTemplate.keys(cacheName + "*");
if (cacheKeys != null) { if (cacheKeys != null) {
redisTemplate.delete(cacheKeys); redisTemplate.delete(cacheKeys);
@ -90,14 +90,14 @@ public class CacheController {
@PreAuthorize("@ss.hasPermi('monitor:cache:list')") @PreAuthorize("@ss.hasPermi('monitor:cache:list')")
@DeleteMapping("/clearCacheKey/{cacheKey}") @DeleteMapping("/clearCacheKey/{cacheKey}")
public Result<String> clearCacheKey (@PathVariable String cacheKey) { public Result<String> clearCacheKey(@PathVariable String cacheKey) {
redisTemplate.delete(cacheKey); redisTemplate.delete(cacheKey);
return Result.success(); return Result.success();
} }
@PreAuthorize("@ss.hasPermi('monitor:cache:list')") @PreAuthorize("@ss.hasPermi('monitor:cache:list')")
@DeleteMapping("/clearCacheAll") @DeleteMapping("/clearCacheAll")
public Result<String> clearCacheAll () { public Result<String> clearCacheAll() {
Collection<String> cacheKeys = redisTemplate.keys("*"); Collection<String> cacheKeys = redisTemplate.keys("*");
if (cacheKeys != null) { if (cacheKeys != null) {
redisTemplate.delete(cacheKeys); redisTemplate.delete(cacheKeys);

View File

@ -17,7 +17,7 @@ import org.springframework.web.bind.annotation.RestController;
public class ServerController { public class ServerController {
@PreAuthorize("@ss.hasPermi('monitor:server:list')") @PreAuthorize("@ss.hasPermi('monitor:server:list')")
@GetMapping() @GetMapping()
public Result<Server> getInfo () throws Exception { public Result<Server> getInfo() throws Exception {
Server server = new Server(); Server server = new Server();
server.copyTo(); server.copyTo();
return Result.success(server); return Result.success(server);

View File

@ -32,7 +32,7 @@ public class SysLogininforController extends BaseController {
@PreAuthorize("@ss.hasPermi('monitor:logininfor:list')") @PreAuthorize("@ss.hasPermi('monitor:logininfor:list')")
@GetMapping("/list") @GetMapping("/list")
public Result<TableDataInfo<SysLogininfor>> list (SysLogininfor logininfor) { public Result<TableDataInfo<SysLogininfor>> list(SysLogininfor logininfor) {
startPage(); startPage();
List<SysLogininfor> list = logininforService.selectLogininforList(logininfor); List<SysLogininfor> list = logininforService.selectLogininforList(logininfor);
return getDataTable(list); return getDataTable(list);
@ -41,7 +41,7 @@ public class SysLogininforController extends BaseController {
@Log(title = "登录日志", businessType = BusinessType.EXPORT) @Log(title = "登录日志", businessType = BusinessType.EXPORT)
@PreAuthorize("@ss.hasPermi('monitor:logininfor:export')") @PreAuthorize("@ss.hasPermi('monitor:logininfor:export')")
@PostMapping("/export") @PostMapping("/export")
public void export (HttpServletResponse response, SysLogininfor logininfor) { public void export(HttpServletResponse response, SysLogininfor logininfor) {
List<SysLogininfor> list = logininforService.selectLogininforList(logininfor); List<SysLogininfor> list = logininforService.selectLogininforList(logininfor);
ExcelUtil<SysLogininfor> util = new ExcelUtil<SysLogininfor>(SysLogininfor.class); ExcelUtil<SysLogininfor> util = new ExcelUtil<SysLogininfor>(SysLogininfor.class);
util.exportExcel(response, list, "登录日志"); util.exportExcel(response, list, "登录日志");
@ -50,14 +50,14 @@ public class SysLogininforController extends BaseController {
@PreAuthorize("@ss.hasPermi('monitor:logininfor:remove')") @PreAuthorize("@ss.hasPermi('monitor:logininfor:remove')")
@Log(title = "登录日志", businessType = BusinessType.DELETE) @Log(title = "登录日志", businessType = BusinessType.DELETE)
@DeleteMapping("/{infoIds}") @DeleteMapping("/{infoIds}")
public Result<String> remove (@PathVariable Long[] infoIds) { public Result<String> remove(@PathVariable Long[] infoIds) {
return toAjax(logininforService.deleteLogininforByIds(infoIds)); return toAjax(logininforService.deleteLogininforByIds(infoIds));
} }
@PreAuthorize("@ss.hasPermi('monitor:logininfor:remove')") @PreAuthorize("@ss.hasPermi('monitor:logininfor:remove')")
@Log(title = "登录日志", businessType = BusinessType.CLEAN) @Log(title = "登录日志", businessType = BusinessType.CLEAN)
@DeleteMapping("/clean") @DeleteMapping("/clean")
public Result<String> clean () { public Result<String> clean() {
logininforService.cleanLogininfor(); logininforService.cleanLogininfor();
return Result.success(); return Result.success();
} }
@ -65,7 +65,7 @@ public class SysLogininforController extends BaseController {
@PreAuthorize("@ss.hasPermi('monitor:logininfor:unlock')") @PreAuthorize("@ss.hasPermi('monitor:logininfor:unlock')")
@Log(title = "账户解锁", businessType = BusinessType.OTHER) @Log(title = "账户解锁", businessType = BusinessType.OTHER)
@GetMapping("/unlock/{userName}") @GetMapping("/unlock/{userName}")
public Result<String> unlock (@PathVariable("userName") String userName) { public Result<String> unlock(@PathVariable("userName") String userName) {
passwordService.clearLoginRecordCache(userName); passwordService.clearLoginRecordCache(userName);
return Result.success(); return Result.success();
} }

View File

@ -28,7 +28,7 @@ public class SysOperlogController extends BaseController {
@PreAuthorize("@ss.hasPermi('monitor:operlog:list')") @PreAuthorize("@ss.hasPermi('monitor:operlog:list')")
@GetMapping("/list") @GetMapping("/list")
public Result<TableDataInfo<SysOperLog>> list (SysOperLog operLog) { public Result<TableDataInfo<SysOperLog>> list(SysOperLog operLog) {
startPage(); startPage();
List<SysOperLog> list = operLogService.selectOperLogList(operLog); List<SysOperLog> list = operLogService.selectOperLogList(operLog);
return getDataTable(list); return getDataTable(list);
@ -37,7 +37,7 @@ public class SysOperlogController extends BaseController {
@Log(title = "操作日志", businessType = BusinessType.EXPORT) @Log(title = "操作日志", businessType = BusinessType.EXPORT)
@PreAuthorize("@ss.hasPermi('monitor:operlog:export')") @PreAuthorize("@ss.hasPermi('monitor:operlog:export')")
@PostMapping("/export") @PostMapping("/export")
public void export (HttpServletResponse response, SysOperLog operLog) { public void export(HttpServletResponse response, SysOperLog operLog) {
List<SysOperLog> list = operLogService.selectOperLogList(operLog); List<SysOperLog> list = operLogService.selectOperLogList(operLog);
ExcelUtil<SysOperLog> util = new ExcelUtil<SysOperLog>(SysOperLog.class); ExcelUtil<SysOperLog> util = new ExcelUtil<SysOperLog>(SysOperLog.class);
util.exportExcel(response, list, "操作日志"); util.exportExcel(response, list, "操作日志");
@ -46,14 +46,14 @@ public class SysOperlogController extends BaseController {
@Log(title = "操作日志", businessType = BusinessType.DELETE) @Log(title = "操作日志", businessType = BusinessType.DELETE)
@PreAuthorize("@ss.hasPermi('monitor:operlog:remove')") @PreAuthorize("@ss.hasPermi('monitor:operlog:remove')")
@DeleteMapping("/{operIds}") @DeleteMapping("/{operIds}")
public Result<String> remove (@PathVariable Long[] operIds) { public Result<String> remove(@PathVariable Long[] operIds) {
return toAjax(operLogService.deleteOperLogByIds(operIds)); return toAjax(operLogService.deleteOperLogByIds(operIds));
} }
@Log(title = "操作日志", businessType = BusinessType.CLEAN) @Log(title = "操作日志", businessType = BusinessType.CLEAN)
@PreAuthorize("@ss.hasPermi('monitor:operlog:remove')") @PreAuthorize("@ss.hasPermi('monitor:operlog:remove')")
@DeleteMapping("/clean") @DeleteMapping("/clean")
public Result<String> clean () { public Result<String> clean() {
operLogService.cleanOperLog(); operLogService.cleanOperLog();
return Result.success(); return Result.success();
} }

View File

@ -36,7 +36,7 @@ public class SysUserOnlineController extends BaseController {
@PreAuthorize("@ss.hasPermi('monitor:online:list')") @PreAuthorize("@ss.hasPermi('monitor:online:list')")
@GetMapping("/list") @GetMapping("/list")
public Result<TableDataInfo<SysUserOnline>> list (String ipaddr, String userName) { public Result<TableDataInfo<SysUserOnline>> list(String ipaddr, String userName) {
Collection<String> keys = redisCache.keys(CacheConstants.LOGIN_TOKEN_KEY + "*"); Collection<String> keys = redisCache.keys(CacheConstants.LOGIN_TOKEN_KEY + "*");
List<SysUserOnline> userOnlineList = new ArrayList<SysUserOnline>(); List<SysUserOnline> userOnlineList = new ArrayList<SysUserOnline>();
for (String key : keys) { for (String key : keys) {
@ -62,7 +62,7 @@ public class SysUserOnlineController extends BaseController {
@PreAuthorize("@ss.hasPermi('monitor:online:forceLogout')") @PreAuthorize("@ss.hasPermi('monitor:online:forceLogout')")
@Log(title = "在线用户", businessType = BusinessType.FORCE) @Log(title = "在线用户", businessType = BusinessType.FORCE)
@DeleteMapping("/{tokenId}") @DeleteMapping("/{tokenId}")
public Result<String> forceLogout (@PathVariable String tokenId) { public Result<String> forceLogout(@PathVariable String tokenId) {
redisCache.deleteObject(CacheConstants.LOGIN_TOKEN_KEY + tokenId); redisCache.deleteObject(CacheConstants.LOGIN_TOKEN_KEY + tokenId);
return Result.success(); return Result.success();
} }

View File

@ -32,7 +32,7 @@ public class SysConfigController extends BaseController {
*/ */
@PreAuthorize("@ss.hasPermi('system:config:list')") @PreAuthorize("@ss.hasPermi('system:config:list')")
@GetMapping("/list") @GetMapping("/list")
public Result<TableDataInfo<SysConfig>> list (SysConfig config) { public Result<TableDataInfo<SysConfig>> list(SysConfig config) {
startPage(); startPage();
List<SysConfig> list = configService.selectConfigList(config); List<SysConfig> list = configService.selectConfigList(config);
return getDataTable(list); return getDataTable(list);
@ -41,7 +41,7 @@ public class SysConfigController extends BaseController {
@Log(title = "参数管理", businessType = BusinessType.EXPORT) @Log(title = "参数管理", businessType = BusinessType.EXPORT)
@PreAuthorize("@ss.hasPermi('system:config:export')") @PreAuthorize("@ss.hasPermi('system:config:export')")
@PostMapping("/export") @PostMapping("/export")
public void export (HttpServletResponse response, SysConfig config) { public void export(HttpServletResponse response, SysConfig config) {
List<SysConfig> list = configService.selectConfigList(config); List<SysConfig> list = configService.selectConfigList(config);
ExcelUtil<SysConfig> util = new ExcelUtil<SysConfig>(SysConfig.class); ExcelUtil<SysConfig> util = new ExcelUtil<SysConfig>(SysConfig.class);
util.exportExcel(response, list, "参数数据"); util.exportExcel(response, list, "参数数据");
@ -52,7 +52,7 @@ public class SysConfigController extends BaseController {
*/ */
@PreAuthorize("@ss.hasPermi('system:config:query')") @PreAuthorize("@ss.hasPermi('system:config:query')")
@GetMapping(value = "/{configId}") @GetMapping(value = "/{configId}")
public Result<SysConfig> getInfo (@PathVariable Long configId) { public Result<SysConfig> getInfo(@PathVariable Long configId) {
return Result.success(configService.selectConfigById(configId)); return Result.success(configService.selectConfigById(configId));
} }
@ -60,7 +60,7 @@ public class SysConfigController extends BaseController {
* *
*/ */
@GetMapping(value = "/configKey/{configKey}") @GetMapping(value = "/configKey/{configKey}")
public Result<String> getConfigKey (@PathVariable String configKey) { public Result<String> getConfigKey(@PathVariable String configKey) {
return Result.success(configService.selectConfigByKey(configKey)); return Result.success(configService.selectConfigByKey(configKey));
} }
@ -70,7 +70,7 @@ public class SysConfigController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:config:add')") @PreAuthorize("@ss.hasPermi('system:config:add')")
@Log(title = "参数管理", businessType = BusinessType.INSERT) @Log(title = "参数管理", businessType = BusinessType.INSERT)
@PostMapping @PostMapping
public Result<String> add (@Validated @RequestBody SysConfig config) { public Result<String> add(@Validated @RequestBody SysConfig config) {
if (!configService.checkConfigKeyUnique(config)) { if (!configService.checkConfigKeyUnique(config)) {
return error("新增参数'" + config.getConfigName() + "'失败,参数键名已存在"); return error("新增参数'" + config.getConfigName() + "'失败,参数键名已存在");
} }
@ -84,7 +84,7 @@ public class SysConfigController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:config:edit')") @PreAuthorize("@ss.hasPermi('system:config:edit')")
@Log(title = "参数管理", businessType = BusinessType.UPDATE) @Log(title = "参数管理", businessType = BusinessType.UPDATE)
@PutMapping @PutMapping
public Result<String> edit (@Validated @RequestBody SysConfig config) { public Result<String> edit(@Validated @RequestBody SysConfig config) {
if (!configService.checkConfigKeyUnique(config)) { if (!configService.checkConfigKeyUnique(config)) {
return error("修改参数'" + config.getConfigName() + "'失败,参数键名已存在"); return error("修改参数'" + config.getConfigName() + "'失败,参数键名已存在");
} }
@ -98,7 +98,7 @@ public class SysConfigController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:config:remove')") @PreAuthorize("@ss.hasPermi('system:config:remove')")
@Log(title = "参数管理", businessType = BusinessType.DELETE) @Log(title = "参数管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{configIds}") @DeleteMapping("/{configIds}")
public Result<String> remove (@PathVariable Long[] configIds) { public Result<String> remove(@PathVariable Long[] configIds) {
configService.deleteConfigByIds(configIds); configService.deleteConfigByIds(configIds);
return Result.success(); return Result.success();
} }
@ -109,7 +109,7 @@ public class SysConfigController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:config:remove')") @PreAuthorize("@ss.hasPermi('system:config:remove')")
@Log(title = "参数管理", businessType = BusinessType.CLEAN) @Log(title = "参数管理", businessType = BusinessType.CLEAN)
@DeleteMapping("/refreshCache") @DeleteMapping("/refreshCache")
public Result<String> refreshCache () { public Result<String> refreshCache() {
configService.resetConfigCache(); configService.resetConfigCache();
return Result.success(); return Result.success();
} }

View File

@ -32,7 +32,7 @@ public class SysDeptController extends BaseController {
*/ */
@PreAuthorize("@ss.hasPermi('system:dept:list')") @PreAuthorize("@ss.hasPermi('system:dept:list')")
@GetMapping("/list") @GetMapping("/list")
public Result<List<SysDept>> list (SysDept dept) { public Result<List<SysDept>> list(SysDept dept) {
List<SysDept> depts = deptService.selectDeptList(dept); List<SysDept> depts = deptService.selectDeptList(dept);
return Result.success(depts); return Result.success(depts);
} }
@ -42,7 +42,7 @@ public class SysDeptController extends BaseController {
*/ */
@PreAuthorize("@ss.hasPermi('system:dept:list')") @PreAuthorize("@ss.hasPermi('system:dept:list')")
@GetMapping("/list/exclude/{deptId}") @GetMapping("/list/exclude/{deptId}")
public Result<List<SysDept>> excludeChild (@PathVariable(value = "deptId", required = false) Long deptId) { public Result<List<SysDept>> excludeChild(@PathVariable(value = "deptId", required = false) Long deptId) {
List<SysDept> depts = deptService.selectDeptList(new SysDept()); List<SysDept> depts = deptService.selectDeptList(new SysDept());
depts.removeIf(d -> d.getDeptId().intValue() == deptId || ArrayUtils.contains(StringUtils.split(d.getAncestors(), ","), deptId + "")); depts.removeIf(d -> d.getDeptId().intValue() == deptId || ArrayUtils.contains(StringUtils.split(d.getAncestors(), ","), deptId + ""));
return Result.success(depts); return Result.success(depts);
@ -53,7 +53,7 @@ public class SysDeptController extends BaseController {
*/ */
@PreAuthorize("@ss.hasPermi('system:dept:query')") @PreAuthorize("@ss.hasPermi('system:dept:query')")
@GetMapping(value = "/{deptId}") @GetMapping(value = "/{deptId}")
public Result<SysDept> getInfo (@PathVariable Long deptId) { public Result<SysDept> getInfo(@PathVariable Long deptId) {
deptService.checkDeptDataScope(deptId); deptService.checkDeptDataScope(deptId);
return Result.success(deptService.selectDeptById(deptId)); return Result.success(deptService.selectDeptById(deptId));
} }
@ -64,7 +64,7 @@ public class SysDeptController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:dept:add')") @PreAuthorize("@ss.hasPermi('system:dept:add')")
@Log(title = "部门管理", businessType = BusinessType.INSERT) @Log(title = "部门管理", businessType = BusinessType.INSERT)
@PostMapping @PostMapping
public Result<String> add (@Validated @RequestBody SysDept dept) { public Result<String> add(@Validated @RequestBody SysDept dept) {
if (!deptService.checkDeptNameUnique(dept)) { if (!deptService.checkDeptNameUnique(dept)) {
return error("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在"); return error("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在");
} }
@ -78,7 +78,7 @@ public class SysDeptController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:dept:edit')") @PreAuthorize("@ss.hasPermi('system:dept:edit')")
@Log(title = "部门管理", businessType = BusinessType.UPDATE) @Log(title = "部门管理", businessType = BusinessType.UPDATE)
@PutMapping @PutMapping
public Result<String> edit (@Validated @RequestBody SysDept dept) { public Result<String> edit(@Validated @RequestBody SysDept dept) {
Long deptId = dept.getDeptId(); Long deptId = dept.getDeptId();
deptService.checkDeptDataScope(deptId); deptService.checkDeptDataScope(deptId);
if (!deptService.checkDeptNameUnique(dept)) { if (!deptService.checkDeptNameUnique(dept)) {
@ -98,7 +98,7 @@ public class SysDeptController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:dept:remove')") @PreAuthorize("@ss.hasPermi('system:dept:remove')")
@Log(title = "部门管理", businessType = BusinessType.DELETE) @Log(title = "部门管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{deptId}") @DeleteMapping("/{deptId}")
public Result<String> remove (@PathVariable Long deptId) { public Result<String> remove(@PathVariable Long deptId) {
if (deptService.hasChildByDeptId(deptId)) { if (deptService.hasChildByDeptId(deptId)) {
return warn("存在下级部门,不允许删除"); return warn("存在下级部门,不允许删除");
} }

View File

@ -35,7 +35,7 @@ public class SysDictDataController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:dict:list')") @PreAuthorize("@ss.hasPermi('system:dict:list')")
@GetMapping("/list") @GetMapping("/list")
public Result<TableDataInfo<SysDictData>> list (SysDictData dictData) { public Result<TableDataInfo<SysDictData>> list(SysDictData dictData) {
startPage(); startPage();
List<SysDictData> list = dictDataService.selectDictDataList(dictData); List<SysDictData> list = dictDataService.selectDictDataList(dictData);
return getDataTable(list); return getDataTable(list);
@ -44,7 +44,7 @@ public class SysDictDataController extends BaseController {
@Log(title = "字典数据", businessType = BusinessType.EXPORT) @Log(title = "字典数据", businessType = BusinessType.EXPORT)
@PreAuthorize("@ss.hasPermi('system:dict:export')") @PreAuthorize("@ss.hasPermi('system:dict:export')")
@PostMapping("/export") @PostMapping("/export")
public void export (HttpServletResponse response, SysDictData dictData) { public void export(HttpServletResponse response, SysDictData dictData) {
List<SysDictData> list = dictDataService.selectDictDataList(dictData); List<SysDictData> list = dictDataService.selectDictDataList(dictData);
ExcelUtil<SysDictData> util = new ExcelUtil<SysDictData>(SysDictData.class); ExcelUtil<SysDictData> util = new ExcelUtil<SysDictData>(SysDictData.class);
util.exportExcel(response, list, "字典数据"); util.exportExcel(response, list, "字典数据");
@ -55,7 +55,7 @@ public class SysDictDataController extends BaseController {
*/ */
@PreAuthorize("@ss.hasPermi('system:dict:query')") @PreAuthorize("@ss.hasPermi('system:dict:query')")
@GetMapping(value = "/{dictCode}") @GetMapping(value = "/{dictCode}")
public Result<SysDictData> getInfo (@PathVariable Long dictCode) { public Result<SysDictData> getInfo(@PathVariable Long dictCode) {
return Result.success(dictDataService.selectDictDataById(dictCode)); return Result.success(dictDataService.selectDictDataById(dictCode));
} }
@ -63,7 +63,7 @@ public class SysDictDataController extends BaseController {
* *
*/ */
@GetMapping(value = "/type/{dictType}") @GetMapping(value = "/type/{dictType}")
public Result<List<SysDictData>> dictType (@PathVariable String dictType) { public Result<List<SysDictData>> dictType(@PathVariable String dictType) {
List<SysDictData> data = dictTypeService.selectDictDataByType(dictType); List<SysDictData> data = dictTypeService.selectDictDataByType(dictType);
if (StringUtils.isNull(data)) { if (StringUtils.isNull(data)) {
data = new ArrayList<SysDictData>(); data = new ArrayList<SysDictData>();
@ -77,7 +77,7 @@ public class SysDictDataController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:dict:add')") @PreAuthorize("@ss.hasPermi('system:dict:add')")
@Log(title = "字典数据", businessType = BusinessType.INSERT) @Log(title = "字典数据", businessType = BusinessType.INSERT)
@PostMapping @PostMapping
public Result<String> add (@Validated @RequestBody SysDictData dict) { public Result<String> add(@Validated @RequestBody SysDictData dict) {
dict.setCreateBy(getUserId()); dict.setCreateBy(getUserId());
return toAjax(dictDataService.insertDictData(dict)); return toAjax(dictDataService.insertDictData(dict));
} }
@ -88,7 +88,7 @@ public class SysDictDataController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:dict:edit')") @PreAuthorize("@ss.hasPermi('system:dict:edit')")
@Log(title = "字典数据", businessType = BusinessType.UPDATE) @Log(title = "字典数据", businessType = BusinessType.UPDATE)
@PutMapping @PutMapping
public Result<String> edit (@Validated @RequestBody SysDictData dict) { public Result<String> edit(@Validated @RequestBody SysDictData dict) {
dict.setUpdateBy(getUserId()); dict.setUpdateBy(getUserId());
return toAjax(dictDataService.updateDictData(dict)); return toAjax(dictDataService.updateDictData(dict));
} }
@ -99,7 +99,7 @@ public class SysDictDataController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:dict:remove')") @PreAuthorize("@ss.hasPermi('system:dict:remove')")
@Log(title = "字典类型", businessType = BusinessType.DELETE) @Log(title = "字典类型", businessType = BusinessType.DELETE)
@DeleteMapping("/{dictCodes}") @DeleteMapping("/{dictCodes}")
public Result<String> remove (@PathVariable Long[] dictCodes) { public Result<String> remove(@PathVariable Long[] dictCodes) {
dictDataService.deleteDictDataByIds(dictCodes); dictDataService.deleteDictDataByIds(dictCodes);
return Result.success(); return Result.success();
} }

View File

@ -29,7 +29,7 @@ public class SysDictTypeController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:dict:list')") @PreAuthorize("@ss.hasPermi('system:dict:list')")
@GetMapping("/list") @GetMapping("/list")
public Result<TableDataInfo<SysDictType>> list (SysDictType dictType) { public Result<TableDataInfo<SysDictType>> list(SysDictType dictType) {
startPage(); startPage();
List<SysDictType> list = dictTypeService.selectDictTypeList(dictType); List<SysDictType> list = dictTypeService.selectDictTypeList(dictType);
return getDataTable(list); return getDataTable(list);
@ -38,7 +38,7 @@ public class SysDictTypeController extends BaseController {
@Log(title = "字典类型", businessType = BusinessType.EXPORT) @Log(title = "字典类型", businessType = BusinessType.EXPORT)
@PreAuthorize("@ss.hasPermi('system:dict:export')") @PreAuthorize("@ss.hasPermi('system:dict:export')")
@PostMapping("/export") @PostMapping("/export")
public void export (HttpServletResponse response, SysDictType dictType) { public void export(HttpServletResponse response, SysDictType dictType) {
List<SysDictType> list = dictTypeService.selectDictTypeList(dictType); List<SysDictType> list = dictTypeService.selectDictTypeList(dictType);
ExcelUtil<SysDictType> util = new ExcelUtil<SysDictType>(SysDictType.class); ExcelUtil<SysDictType> util = new ExcelUtil<SysDictType>(SysDictType.class);
util.exportExcel(response, list, "字典类型"); util.exportExcel(response, list, "字典类型");
@ -49,7 +49,7 @@ public class SysDictTypeController extends BaseController {
*/ */
@PreAuthorize("@ss.hasPermi('system:dict:query')") @PreAuthorize("@ss.hasPermi('system:dict:query')")
@GetMapping(value = "/{dictId}") @GetMapping(value = "/{dictId}")
public Result<SysDictType> getInfo (@PathVariable Long dictId) { public Result<SysDictType> getInfo(@PathVariable Long dictId) {
return Result.success(dictTypeService.selectDictTypeById(dictId)); return Result.success(dictTypeService.selectDictTypeById(dictId));
} }
@ -59,7 +59,7 @@ public class SysDictTypeController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:dict:add')") @PreAuthorize("@ss.hasPermi('system:dict:add')")
@Log(title = "字典类型", businessType = BusinessType.INSERT) @Log(title = "字典类型", businessType = BusinessType.INSERT)
@PostMapping @PostMapping
public Result<String> add (@Validated @RequestBody SysDictType dict) { public Result<String> add(@Validated @RequestBody SysDictType dict) {
if (!dictTypeService.checkDictTypeUnique(dict)) { if (!dictTypeService.checkDictTypeUnique(dict)) {
return error("新增字典'" + dict.getDictName() + "'失败,字典类型已存在"); return error("新增字典'" + dict.getDictName() + "'失败,字典类型已存在");
} }
@ -73,7 +73,7 @@ public class SysDictTypeController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:dict:edit')") @PreAuthorize("@ss.hasPermi('system:dict:edit')")
@Log(title = "字典类型", businessType = BusinessType.UPDATE) @Log(title = "字典类型", businessType = BusinessType.UPDATE)
@PutMapping @PutMapping
public Result<String> edit (@Validated @RequestBody SysDictType dict) { public Result<String> edit(@Validated @RequestBody SysDictType dict) {
if (!dictTypeService.checkDictTypeUnique(dict)) { if (!dictTypeService.checkDictTypeUnique(dict)) {
return error("修改字典'" + dict.getDictName() + "'失败,字典类型已存在"); return error("修改字典'" + dict.getDictName() + "'失败,字典类型已存在");
} }
@ -87,7 +87,7 @@ public class SysDictTypeController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:dict:remove')") @PreAuthorize("@ss.hasPermi('system:dict:remove')")
@Log(title = "字典类型", businessType = BusinessType.DELETE) @Log(title = "字典类型", businessType = BusinessType.DELETE)
@DeleteMapping("/{dictIds}") @DeleteMapping("/{dictIds}")
public Result<String> remove (@PathVariable Long[] dictIds) { public Result<String> remove(@PathVariable Long[] dictIds) {
dictTypeService.deleteDictTypeByIds(dictIds); dictTypeService.deleteDictTypeByIds(dictIds);
return Result.success(); return Result.success();
} }
@ -98,7 +98,7 @@ public class SysDictTypeController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:dict:remove')") @PreAuthorize("@ss.hasPermi('system:dict:remove')")
@Log(title = "字典类型", businessType = BusinessType.CLEAN) @Log(title = "字典类型", businessType = BusinessType.CLEAN)
@DeleteMapping("/refreshCache") @DeleteMapping("/refreshCache")
public Result<String> refreshCache () { public Result<String> refreshCache() {
dictTypeService.resetDictCache(); dictTypeService.resetDictCache();
return Result.success(); return Result.success();
} }
@ -107,7 +107,7 @@ public class SysDictTypeController extends BaseController {
* *
*/ */
@GetMapping("/optionselect") @GetMapping("/optionselect")
public Result<List<SysDictType>> optionselect () { public Result<List<SysDictType>> optionselect() {
List<SysDictType> dictTypes = dictTypeService.selectDictTypeAll(); List<SysDictType> dictTypes = dictTypeService.selectDictTypeAll();
return Result.success(dictTypes); return Result.success(dictTypes);
} }

View File

@ -23,7 +23,7 @@ public class SysIndexController {
* 访 * 访
*/ */
@RequestMapping("/") @RequestMapping("/")
public String index () { public String index() {
return StringUtils.format("欢迎使用{}后台管理框架当前版本v{},请通过前端地址访问。", ruoyiConfig.getName(), ruoyiConfig.getVersion()); return StringUtils.format("欢迎使用{}后台管理框架当前版本v{},请通过前端地址访问。", ruoyiConfig.getName(), ruoyiConfig.getVersion());
} }
} }

View File

@ -39,11 +39,10 @@ public class SysLoginController {
* *
* *
* @param loginBody * @param loginBody
*
* @return * @return
*/ */
@PostMapping("/login") @PostMapping("/login")
public Result<String> login (@RequestBody LoginBody loginBody) { public Result<String> login(@RequestBody LoginBody loginBody) {
// 生成令牌 // 生成令牌
String token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(), String token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(),
loginBody.getUuid()); loginBody.getUuid());
@ -56,7 +55,7 @@ public class SysLoginController {
* @return * @return
*/ */
@GetMapping("getInfo") @GetMapping("getInfo")
public Result<UserInfoResp> getInfo () { public Result<UserInfoResp> getInfo() {
SysUser user = SecurityUtils.getLoginUser().getUser(); SysUser user = SecurityUtils.getLoginUser().getUser();
// 角色集合 // 角色集合
Set<String> roles = permissionService.getRolePermission(user); Set<String> roles = permissionService.getRolePermission(user);
@ -77,7 +76,7 @@ public class SysLoginController {
* @return * @return
*/ */
@GetMapping("getRouters") @GetMapping("getRouters")
public Result<List<RouterVo>> getRouters () { public Result<List<RouterVo>> getRouters() {
Long userId = SecurityUtils.getUserId(); Long userId = SecurityUtils.getUserId();
List<SysMenu> menus = menuService.selectMenuTreeByUserId(userId); List<SysMenu> menus = menuService.selectMenuTreeByUserId(userId);
return Result.success(menuService.buildMenus(menus)); return Result.success(menuService.buildMenus(menus));

View File

@ -33,7 +33,7 @@ public class SysMenuController extends BaseController {
*/ */
@PreAuthorize("@ss.hasPermi('system:menu:list')") @PreAuthorize("@ss.hasPermi('system:menu:list')")
@GetMapping("/list") @GetMapping("/list")
public Result<List<SysMenu>> list (SysMenu menu) { public Result<List<SysMenu>> list(SysMenu menu) {
List<SysMenu> menus = menuService.selectMenuList(menu, getUserId()); List<SysMenu> menus = menuService.selectMenuList(menu, getUserId());
return Result.success(menus); return Result.success(menus);
} }
@ -43,7 +43,7 @@ public class SysMenuController extends BaseController {
*/ */
@PreAuthorize("@ss.hasPermi('system:menu:query')") @PreAuthorize("@ss.hasPermi('system:menu:query')")
@GetMapping(value = "/{menuId}") @GetMapping(value = "/{menuId}")
public Result<SysMenu> getInfo (@PathVariable Long menuId) { public Result<SysMenu> getInfo(@PathVariable Long menuId) {
return Result.success(menuService.selectMenuById(menuId)); return Result.success(menuService.selectMenuById(menuId));
} }
@ -51,7 +51,7 @@ public class SysMenuController extends BaseController {
* *
*/ */
@GetMapping("/treeselect") @GetMapping("/treeselect")
public Result<List<TreeSelect>> treeselect (SysMenu menu) { public Result<List<TreeSelect>> treeselect(SysMenu menu) {
List<SysMenu> menus = menuService.selectMenuList(menu, getUserId()); List<SysMenu> menus = menuService.selectMenuList(menu, getUserId());
return Result.success(menuService.buildMenuTreeSelect(menus)); return Result.success(menuService.buildMenuTreeSelect(menus));
} }
@ -60,7 +60,7 @@ public class SysMenuController extends BaseController {
* *
*/ */
@GetMapping(value = "/roleMenuTreeselect/{roleId}") @GetMapping(value = "/roleMenuTreeselect/{roleId}")
public Result<RoleMenuTreeResp> roleMenuTreeselect (@PathVariable("roleId") Long roleId) { public Result<RoleMenuTreeResp> roleMenuTreeselect(@PathVariable("roleId") Long roleId) {
List<SysMenu> menus = menuService.selectMenuList(getUserId()); List<SysMenu> menus = menuService.selectMenuList(getUserId());
return Result.success( return Result.success(
RoleMenuTreeResp.builder() RoleMenuTreeResp.builder()
@ -76,7 +76,7 @@ public class SysMenuController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:menu:add')") @PreAuthorize("@ss.hasPermi('system:menu:add')")
@Log(title = "菜单管理", businessType = BusinessType.INSERT) @Log(title = "菜单管理", businessType = BusinessType.INSERT)
@PostMapping @PostMapping
public Result<String> add (@Validated @RequestBody SysMenu menu) { public Result<String> add(@Validated @RequestBody SysMenu menu) {
if (!menuService.checkMenuNameUnique(menu)) { if (!menuService.checkMenuNameUnique(menu)) {
return error("新增菜单'" + menu.getMenuName() + "'失败,菜单名称已存在"); return error("新增菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
} else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) && !StringUtils.ishttp(menu.getPath())) { } else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) && !StringUtils.ishttp(menu.getPath())) {
@ -92,7 +92,7 @@ public class SysMenuController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:menu:edit')") @PreAuthorize("@ss.hasPermi('system:menu:edit')")
@Log(title = "菜单管理", businessType = BusinessType.UPDATE) @Log(title = "菜单管理", businessType = BusinessType.UPDATE)
@PutMapping @PutMapping
public Result<String> edit (@Validated @RequestBody SysMenu menu) { public Result<String> edit(@Validated @RequestBody SysMenu menu) {
if (!menuService.checkMenuNameUnique(menu)) { if (!menuService.checkMenuNameUnique(menu)) {
return error("修改菜单'" + menu.getMenuName() + "'失败,菜单名称已存在"); return error("修改菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
} else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) && !StringUtils.ishttp(menu.getPath())) { } else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) && !StringUtils.ishttp(menu.getPath())) {
@ -110,7 +110,7 @@ public class SysMenuController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:menu:remove')") @PreAuthorize("@ss.hasPermi('system:menu:remove')")
@Log(title = "菜单管理", businessType = BusinessType.DELETE) @Log(title = "菜单管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{menuId}") @DeleteMapping("/{menuId}")
public Result<String> remove (@PathVariable("menuId") Long menuId) { public Result<String> remove(@PathVariable("menuId") Long menuId) {
if (menuService.hasChildByMenuId(menuId)) { if (menuService.hasChildByMenuId(menuId)) {
return warn("存在子菜单,不允许删除"); return warn("存在子菜单,不允许删除");
} }

View File

@ -30,7 +30,7 @@ public class SysNoticeController extends BaseController {
*/ */
@PreAuthorize("@ss.hasPermi('system:notice:list')") @PreAuthorize("@ss.hasPermi('system:notice:list')")
@GetMapping("/list") @GetMapping("/list")
public Result<TableDataInfo<SysNotice>> list (SysNotice notice) { public Result<TableDataInfo<SysNotice>> list(SysNotice notice) {
startPage(); startPage();
List<SysNotice> list = noticeService.selectNoticeList(notice); List<SysNotice> list = noticeService.selectNoticeList(notice);
return getDataTable(list); return getDataTable(list);
@ -41,7 +41,7 @@ public class SysNoticeController extends BaseController {
*/ */
@PreAuthorize("@ss.hasPermi('system:notice:query')") @PreAuthorize("@ss.hasPermi('system:notice:query')")
@GetMapping(value = "/{noticeId}") @GetMapping(value = "/{noticeId}")
public Result<SysNotice> getInfo (@PathVariable Long noticeId) { public Result<SysNotice> getInfo(@PathVariable Long noticeId) {
return Result.success(noticeService.selectNoticeById(noticeId)); return Result.success(noticeService.selectNoticeById(noticeId));
} }
@ -51,7 +51,7 @@ public class SysNoticeController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:notice:add')") @PreAuthorize("@ss.hasPermi('system:notice:add')")
@Log(title = "通知公告", businessType = BusinessType.INSERT) @Log(title = "通知公告", businessType = BusinessType.INSERT)
@PostMapping @PostMapping
public Result<String> add (@Validated @RequestBody SysNotice notice) { public Result<String> add(@Validated @RequestBody SysNotice notice) {
notice.setCreateBy(getUserId()); notice.setCreateBy(getUserId());
return toAjax(noticeService.insertNotice(notice)); return toAjax(noticeService.insertNotice(notice));
} }
@ -62,7 +62,7 @@ public class SysNoticeController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:notice:edit')") @PreAuthorize("@ss.hasPermi('system:notice:edit')")
@Log(title = "通知公告", businessType = BusinessType.UPDATE) @Log(title = "通知公告", businessType = BusinessType.UPDATE)
@PutMapping @PutMapping
public Result<String> edit (@Validated @RequestBody SysNotice notice) { public Result<String> edit(@Validated @RequestBody SysNotice notice) {
notice.setUpdateBy(getUserId()); notice.setUpdateBy(getUserId());
return toAjax(noticeService.updateNotice(notice)); return toAjax(noticeService.updateNotice(notice));
} }
@ -73,7 +73,7 @@ public class SysNoticeController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:notice:remove')") @PreAuthorize("@ss.hasPermi('system:notice:remove')")
@Log(title = "通知公告", businessType = BusinessType.DELETE) @Log(title = "通知公告", businessType = BusinessType.DELETE)
@DeleteMapping("/{noticeIds}") @DeleteMapping("/{noticeIds}")
public Result<String> remove (@PathVariable Long[] noticeIds) { public Result<String> remove(@PathVariable Long[] noticeIds) {
return toAjax(noticeService.deleteNoticeByIds(noticeIds)); return toAjax(noticeService.deleteNoticeByIds(noticeIds));
} }
} }

View File

@ -32,7 +32,7 @@ public class SysPostController extends BaseController {
*/ */
@PreAuthorize("@ss.hasPermi('system:post:list')") @PreAuthorize("@ss.hasPermi('system:post:list')")
@GetMapping("/list") @GetMapping("/list")
public Result<TableDataInfo<SysPost>> list (SysPost post) { public Result<TableDataInfo<SysPost>> list(SysPost post) {
startPage(); startPage();
List<SysPost> list = postService.selectPostList(post); List<SysPost> list = postService.selectPostList(post);
return getDataTable(list); return getDataTable(list);
@ -41,7 +41,7 @@ public class SysPostController extends BaseController {
@Log(title = "岗位管理", businessType = BusinessType.EXPORT) @Log(title = "岗位管理", businessType = BusinessType.EXPORT)
@PreAuthorize("@ss.hasPermi('system:post:export')") @PreAuthorize("@ss.hasPermi('system:post:export')")
@PostMapping("/export") @PostMapping("/export")
public void export (HttpServletResponse response, SysPost post) { public void export(HttpServletResponse response, SysPost post) {
List<SysPost> list = postService.selectPostList(post); List<SysPost> list = postService.selectPostList(post);
ExcelUtil<SysPost> util = new ExcelUtil<SysPost>(SysPost.class); ExcelUtil<SysPost> util = new ExcelUtil<SysPost>(SysPost.class);
util.exportExcel(response, list, "岗位数据"); util.exportExcel(response, list, "岗位数据");
@ -52,7 +52,7 @@ public class SysPostController extends BaseController {
*/ */
@PreAuthorize("@ss.hasPermi('system:post:query')") @PreAuthorize("@ss.hasPermi('system:post:query')")
@GetMapping(value = "/{postId}") @GetMapping(value = "/{postId}")
public Result<SysPost> getInfo (@PathVariable Long postId) { public Result<SysPost> getInfo(@PathVariable Long postId) {
return Result.success(postService.selectPostById(postId)); return Result.success(postService.selectPostById(postId));
} }
@ -62,7 +62,7 @@ public class SysPostController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:post:add')") @PreAuthorize("@ss.hasPermi('system:post:add')")
@Log(title = "岗位管理", businessType = BusinessType.INSERT) @Log(title = "岗位管理", businessType = BusinessType.INSERT)
@PostMapping @PostMapping
public Result<String> add (@Validated @RequestBody SysPost post) { public Result<String> add(@Validated @RequestBody SysPost post) {
if (!postService.checkPostNameUnique(post)) { if (!postService.checkPostNameUnique(post)) {
return error("新增岗位'" + post.getPostName() + "'失败,岗位名称已存在"); return error("新增岗位'" + post.getPostName() + "'失败,岗位名称已存在");
} else if (!postService.checkPostCodeUnique(post)) { } else if (!postService.checkPostCodeUnique(post)) {
@ -78,7 +78,7 @@ public class SysPostController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:post:edit')") @PreAuthorize("@ss.hasPermi('system:post:edit')")
@Log(title = "岗位管理", businessType = BusinessType.UPDATE) @Log(title = "岗位管理", businessType = BusinessType.UPDATE)
@PutMapping @PutMapping
public Result<String> edit (@Validated @RequestBody SysPost post) { public Result<String> edit(@Validated @RequestBody SysPost post) {
if (!postService.checkPostNameUnique(post)) { if (!postService.checkPostNameUnique(post)) {
return error("修改岗位'" + post.getPostName() + "'失败,岗位名称已存在"); return error("修改岗位'" + post.getPostName() + "'失败,岗位名称已存在");
} else if (!postService.checkPostCodeUnique(post)) { } else if (!postService.checkPostCodeUnique(post)) {
@ -94,7 +94,7 @@ public class SysPostController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:post:remove')") @PreAuthorize("@ss.hasPermi('system:post:remove')")
@Log(title = "岗位管理", businessType = BusinessType.DELETE) @Log(title = "岗位管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{postIds}") @DeleteMapping("/{postIds}")
public Result<String> remove (@PathVariable Long[] postIds) { public Result<String> remove(@PathVariable Long[] postIds) {
return toAjax(postService.deletePostByIds(postIds)); return toAjax(postService.deletePostByIds(postIds));
} }
@ -102,7 +102,7 @@ public class SysPostController extends BaseController {
* *
*/ */
@GetMapping("/optionselect") @GetMapping("/optionselect")
public Result<List<SysPost>> optionselect () { public Result<List<SysPost>> optionselect() {
List<SysPost> posts = postService.selectPostAll(); List<SysPost> posts = postService.selectPostAll();
return Result.success(posts); return Result.success(posts);
} }

View File

@ -36,7 +36,7 @@ public class SysProfileController extends BaseController {
* *
*/ */
@GetMapping @GetMapping
public Result<ProfileResp> profile () { public Result<ProfileResp> profile() {
LoginUser loginUser = getLoginUser(); LoginUser loginUser = getLoginUser();
SysUser user = loginUser.getUser(); SysUser user = loginUser.getUser();
return Result.success( return Result.success(
@ -53,7 +53,7 @@ public class SysProfileController extends BaseController {
*/ */
@Log(title = "个人信息", businessType = BusinessType.UPDATE) @Log(title = "个人信息", businessType = BusinessType.UPDATE)
@PutMapping @PutMapping
public Result<String> updateProfile (@RequestBody SysUser user) { public Result<String> updateProfile(@RequestBody SysUser user) {
LoginUser loginUser = getLoginUser(); LoginUser loginUser = getLoginUser();
SysUser currentUser = loginUser.getUser(); SysUser currentUser = loginUser.getUser();
currentUser.setNickName(user.getNickName()); currentUser.setNickName(user.getNickName());
@ -79,7 +79,7 @@ public class SysProfileController extends BaseController {
*/ */
@Log(title = "个人信息", businessType = BusinessType.UPDATE) @Log(title = "个人信息", businessType = BusinessType.UPDATE)
@PutMapping("/updatePwd") @PutMapping("/updatePwd")
public Result<String> updatePwd (String oldPassword, String newPassword) { public Result<String> updatePwd(String oldPassword, String newPassword) {
LoginUser loginUser = getLoginUser(); LoginUser loginUser = getLoginUser();
String userName = loginUser.getUsername(); String userName = loginUser.getUsername();
String password = loginUser.getPassword(); String password = loginUser.getPassword();
@ -103,7 +103,7 @@ public class SysProfileController extends BaseController {
*/ */
@Log(title = "用户头像", businessType = BusinessType.UPDATE) @Log(title = "用户头像", businessType = BusinessType.UPDATE)
@PostMapping("/avatar") @PostMapping("/avatar")
public Result<String> avatar (@RequestParam("avatarfile") MultipartFile file) throws Exception { public Result<String> avatar(@RequestParam("avatarfile") MultipartFile file) throws Exception {
if (!file.isEmpty()) { if (!file.isEmpty()) {
LoginUser loginUser = getLoginUser(); LoginUser loginUser = getLoginUser();
String avatar = FileUploadUtils.upload(RuoYiConfig.getAvatarPath(), file, MimeTypeUtils.IMAGE_EXTENSION); String avatar = FileUploadUtils.upload(RuoYiConfig.getAvatarPath(), file, MimeTypeUtils.IMAGE_EXTENSION);

View File

@ -25,7 +25,7 @@ public class SysRegisterController extends BaseController {
private SysConfigServic configService; private SysConfigServic configService;
@PostMapping("/register") @PostMapping("/register")
public Result<String> register (@RequestBody RegisterBody user) { public Result<String> register(@RequestBody RegisterBody user) {
if (!("true".equals(configService.selectConfigByKey("sys.account.registerUser")))) { if (!("true".equals(configService.selectConfigByKey("sys.account.registerUser")))) {
return error("当前系统没有开启注册功能!"); return error("当前系统没有开启注册功能!");
} }

View File

@ -51,7 +51,7 @@ public class SysRoleController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:role:list')") @PreAuthorize("@ss.hasPermi('system:role:list')")
@GetMapping("/list") @GetMapping("/list")
public Result<TableDataInfo<SysRole>> list (SysRole role) { public Result<TableDataInfo<SysRole>> list(SysRole role) {
startPage(); startPage();
List<SysRole> list = roleService.selectRoleList(role); List<SysRole> list = roleService.selectRoleList(role);
return getDataTable(list); return getDataTable(list);
@ -60,7 +60,7 @@ public class SysRoleController extends BaseController {
@Log(title = "角色管理", businessType = BusinessType.EXPORT) @Log(title = "角色管理", businessType = BusinessType.EXPORT)
@PreAuthorize("@ss.hasPermi('system:role:export')") @PreAuthorize("@ss.hasPermi('system:role:export')")
@PostMapping("/export") @PostMapping("/export")
public void export (HttpServletResponse response, SysRole role) { public void export(HttpServletResponse response, SysRole role) {
List<SysRole> list = roleService.selectRoleList(role); List<SysRole> list = roleService.selectRoleList(role);
ExcelUtil<SysRole> util = new ExcelUtil<SysRole>(SysRole.class); ExcelUtil<SysRole> util = new ExcelUtil<SysRole>(SysRole.class);
util.exportExcel(response, list, "角色数据"); util.exportExcel(response, list, "角色数据");
@ -71,7 +71,7 @@ public class SysRoleController extends BaseController {
*/ */
@PreAuthorize("@ss.hasPermi('system:role:query')") @PreAuthorize("@ss.hasPermi('system:role:query')")
@GetMapping(value = "/{roleId}") @GetMapping(value = "/{roleId}")
public Result<SysRole> getInfo (@PathVariable Long roleId) { public Result<SysRole> getInfo(@PathVariable Long roleId) {
roleService.checkRoleDataScope(roleId); roleService.checkRoleDataScope(roleId);
return Result.success(roleService.selectRoleById(roleId)); return Result.success(roleService.selectRoleById(roleId));
} }
@ -82,7 +82,7 @@ public class SysRoleController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:role:add')") @PreAuthorize("@ss.hasPermi('system:role:add')")
@Log(title = "角色管理", businessType = BusinessType.INSERT) @Log(title = "角色管理", businessType = BusinessType.INSERT)
@PostMapping @PostMapping
public Result<String> add (@Validated @RequestBody SysRole role) { public Result<String> add(@Validated @RequestBody SysRole role) {
if (!roleService.checkRoleNameUnique(role)) { if (!roleService.checkRoleNameUnique(role)) {
return error("新增角色'" + role.getRoleName() + "'失败,角色名称已存在"); return error("新增角色'" + role.getRoleName() + "'失败,角色名称已存在");
} else if (!roleService.checkRoleKeyUnique(role)) { } else if (!roleService.checkRoleKeyUnique(role)) {
@ -99,7 +99,7 @@ public class SysRoleController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:role:edit')") @PreAuthorize("@ss.hasPermi('system:role:edit')")
@Log(title = "角色管理", businessType = BusinessType.UPDATE) @Log(title = "角色管理", businessType = BusinessType.UPDATE)
@PutMapping @PutMapping
public Result<String> edit (@Validated @RequestBody SysRole role) { public Result<String> edit(@Validated @RequestBody SysRole role) {
roleService.checkRoleAllowed(role); roleService.checkRoleAllowed(role);
roleService.checkRoleDataScope(role.getRoleId()); roleService.checkRoleDataScope(role.getRoleId());
if (!roleService.checkRoleNameUnique(role)) { if (!roleService.checkRoleNameUnique(role)) {
@ -128,7 +128,7 @@ public class SysRoleController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:role:edit')") @PreAuthorize("@ss.hasPermi('system:role:edit')")
@Log(title = "角色管理", businessType = BusinessType.UPDATE) @Log(title = "角色管理", businessType = BusinessType.UPDATE)
@PutMapping("/dataScope") @PutMapping("/dataScope")
public Result<String> dataScope (@RequestBody SysRole role) { public Result<String> dataScope(@RequestBody SysRole role) {
roleService.checkRoleAllowed(role); roleService.checkRoleAllowed(role);
roleService.checkRoleDataScope(role.getRoleId()); roleService.checkRoleDataScope(role.getRoleId());
return toAjax(roleService.authDataScope(role)); return toAjax(roleService.authDataScope(role));
@ -140,7 +140,7 @@ public class SysRoleController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:role:edit')") @PreAuthorize("@ss.hasPermi('system:role:edit')")
@Log(title = "角色管理", businessType = BusinessType.UPDATE) @Log(title = "角色管理", businessType = BusinessType.UPDATE)
@PutMapping("/changeStatus") @PutMapping("/changeStatus")
public Result<String> changeStatus (@RequestBody SysRole role) { public Result<String> changeStatus(@RequestBody SysRole role) {
roleService.checkRoleAllowed(role); roleService.checkRoleAllowed(role);
roleService.checkRoleDataScope(role.getRoleId()); roleService.checkRoleDataScope(role.getRoleId());
role.setUpdateBy(getUserId()); role.setUpdateBy(getUserId());
@ -153,7 +153,7 @@ public class SysRoleController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:role:remove')") @PreAuthorize("@ss.hasPermi('system:role:remove')")
@Log(title = "角色管理", businessType = BusinessType.DELETE) @Log(title = "角色管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{roleIds}") @DeleteMapping("/{roleIds}")
public Result<String> remove (@PathVariable Long[] roleIds) { public Result<String> remove(@PathVariable Long[] roleIds) {
return toAjax(roleService.deleteRoleByIds(roleIds)); return toAjax(roleService.deleteRoleByIds(roleIds));
} }
@ -162,7 +162,7 @@ public class SysRoleController extends BaseController {
*/ */
@PreAuthorize("@ss.hasPermi('system:role:query')") @PreAuthorize("@ss.hasPermi('system:role:query')")
@GetMapping("/optionselect") @GetMapping("/optionselect")
public Result<List<SysRole>> optionselect () { public Result<List<SysRole>> optionselect() {
return Result.success(roleService.selectRoleAll()); return Result.success(roleService.selectRoleAll());
} }
@ -171,7 +171,7 @@ public class SysRoleController extends BaseController {
*/ */
@PreAuthorize("@ss.hasPermi('system:role:list')") @PreAuthorize("@ss.hasPermi('system:role:list')")
@GetMapping("/authUser/allocatedList") @GetMapping("/authUser/allocatedList")
public Result<TableDataInfo<SysUser>> allocatedList (SysUser user) { public Result<TableDataInfo<SysUser>> allocatedList(SysUser user) {
startPage(); startPage();
List<SysUser> list = userService.selectAllocatedList(user); List<SysUser> list = userService.selectAllocatedList(user);
return getDataTable(list); return getDataTable(list);
@ -182,7 +182,7 @@ public class SysRoleController extends BaseController {
*/ */
@PreAuthorize("@ss.hasPermi('system:role:list')") @PreAuthorize("@ss.hasPermi('system:role:list')")
@GetMapping("/authUser/unallocatedList") @GetMapping("/authUser/unallocatedList")
public Result<TableDataInfo<SysUser>> unallocatedList (SysUser user) { public Result<TableDataInfo<SysUser>> unallocatedList(SysUser user) {
startPage(); startPage();
List<SysUser> list = userService.selectUnallocatedList(user); List<SysUser> list = userService.selectUnallocatedList(user);
return getDataTable(list); return getDataTable(list);
@ -194,7 +194,7 @@ public class SysRoleController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:role:edit')") @PreAuthorize("@ss.hasPermi('system:role:edit')")
@Log(title = "角色管理", businessType = BusinessType.GRANT) @Log(title = "角色管理", businessType = BusinessType.GRANT)
@PutMapping("/authUser/cancel") @PutMapping("/authUser/cancel")
public Result<String> cancelAuthUser (@RequestBody SysUserRole userRole) { public Result<String> cancelAuthUser(@RequestBody SysUserRole userRole) {
return toAjax(roleService.deleteAuthUser(userRole)); return toAjax(roleService.deleteAuthUser(userRole));
} }
@ -204,7 +204,7 @@ public class SysRoleController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:role:edit')") @PreAuthorize("@ss.hasPermi('system:role:edit')")
@Log(title = "角色管理", businessType = BusinessType.GRANT) @Log(title = "角色管理", businessType = BusinessType.GRANT)
@PutMapping("/authUser/cancelAll") @PutMapping("/authUser/cancelAll")
public Result<String> cancelAuthUserAll (Long roleId, Long[] userIds) { public Result<String> cancelAuthUserAll(Long roleId, Long[] userIds) {
return toAjax(roleService.deleteAuthUsers(roleId, userIds)); return toAjax(roleService.deleteAuthUsers(roleId, userIds));
} }
@ -214,7 +214,7 @@ public class SysRoleController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:role:edit')") @PreAuthorize("@ss.hasPermi('system:role:edit')")
@Log(title = "角色管理", businessType = BusinessType.GRANT) @Log(title = "角色管理", businessType = BusinessType.GRANT)
@PutMapping("/authUser/selectAll") @PutMapping("/authUser/selectAll")
public Result<String> selectAuthUserAll (Long roleId, Long[] userIds) { public Result<String> selectAuthUserAll(Long roleId, Long[] userIds) {
roleService.checkRoleDataScope(roleId); roleService.checkRoleDataScope(roleId);
return toAjax(roleService.insertAuthUsers(roleId, userIds)); return toAjax(roleService.insertAuthUsers(roleId, userIds));
} }
@ -224,7 +224,7 @@ public class SysRoleController extends BaseController {
*/ */
@PreAuthorize("@ss.hasPermi('system:role:query')") @PreAuthorize("@ss.hasPermi('system:role:query')")
@GetMapping(value = "/deptTree/{roleId}") @GetMapping(value = "/deptTree/{roleId}")
public Result<DeptTreeResp> deptTree (@PathVariable("roleId") Long roleId) { public Result<DeptTreeResp> deptTree(@PathVariable("roleId") Long roleId) {
return Result.success( return Result.success(
DeptTreeResp.builder() DeptTreeResp.builder()
.checkedKeys(deptService.selectDeptListByRoleId(roleId)) .checkedKeys(deptService.selectDeptListByRoleId(roleId))

View File

@ -55,7 +55,7 @@ public class SysUserController extends BaseController {
*/ */
@PreAuthorize("@ss.hasPermi('system:user:list')") @PreAuthorize("@ss.hasPermi('system:user:list')")
@GetMapping("/list") @GetMapping("/list")
public Result<TableDataInfo<SysUser>> list (SysUser user) { public Result<TableDataInfo<SysUser>> list(SysUser user) {
startPage(); startPage();
List<SysUser> list = userService.selectUserList(user); List<SysUser> list = userService.selectUserList(user);
return getDataTable(list); return getDataTable(list);
@ -64,7 +64,7 @@ public class SysUserController extends BaseController {
@Log(title = "用户管理", businessType = BusinessType.EXPORT) @Log(title = "用户管理", businessType = BusinessType.EXPORT)
@PreAuthorize("@ss.hasPermi('system:user:export')") @PreAuthorize("@ss.hasPermi('system:user:export')")
@PostMapping("/export") @PostMapping("/export")
public void export (HttpServletResponse response, SysUser user) { public void export(HttpServletResponse response, SysUser user) {
List<SysUser> list = userService.selectUserList(user); List<SysUser> list = userService.selectUserList(user);
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class); ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
util.exportExcel(response, list, "用户数据"); util.exportExcel(response, list, "用户数据");
@ -73,7 +73,7 @@ public class SysUserController extends BaseController {
@Log(title = "用户管理", businessType = BusinessType.IMPORT) @Log(title = "用户管理", businessType = BusinessType.IMPORT)
@PreAuthorize("@ss.hasPermi('system:user:import')") @PreAuthorize("@ss.hasPermi('system:user:import')")
@PostMapping("/importData") @PostMapping("/importData")
public Result<String> importData (MultipartFile file, boolean updateSupport) throws Exception { public Result<String> importData(MultipartFile file, boolean updateSupport) throws Exception {
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class); ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
List<SysUser> userList = util.importExcel(file.getInputStream()); List<SysUser> userList = util.importExcel(file.getInputStream());
Long userId = getUserId(); Long userId = getUserId();
@ -82,7 +82,7 @@ public class SysUserController extends BaseController {
} }
@PostMapping("/importTemplate") @PostMapping("/importTemplate")
public void importTemplate (HttpServletResponse response) { public void importTemplate(HttpServletResponse response) {
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class); ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
util.importTemplateExcel(response, "用户数据"); util.importTemplateExcel(response, "用户数据");
} }
@ -92,7 +92,7 @@ public class SysUserController extends BaseController {
*/ */
@PreAuthorize("@ss.hasPermi('system:user:query')") @PreAuthorize("@ss.hasPermi('system:user:query')")
@GetMapping(value = {"/", "/{userId}"}) @GetMapping(value = {"/", "/{userId}"})
public Result<UserDetailInfoResp> getInfo (@PathVariable(value = "userId", required = false) Long userId) { public Result<UserDetailInfoResp> getInfo(@PathVariable(value = "userId", required = false) Long userId) {
userService.checkUserDataScope(userId); userService.checkUserDataScope(userId);
List<SysRole> roles = roleService.selectRoleAll(); List<SysRole> roles = roleService.selectRoleAll();
UserDetailInfoRespBuilder builder = UserDetailInfoResp.builder() UserDetailInfoRespBuilder builder = UserDetailInfoResp.builder()
@ -115,7 +115,7 @@ public class SysUserController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:user:add')") @PreAuthorize("@ss.hasPermi('system:user:add')")
@Log(title = "用户管理", businessType = BusinessType.INSERT) @Log(title = "用户管理", businessType = BusinessType.INSERT)
@PostMapping @PostMapping
public Result<String> add (@Validated @RequestBody SysUser user) { public Result<String> add(@Validated @RequestBody SysUser user) {
if (!userService.checkUserNameUnique(user)) { if (!userService.checkUserNameUnique(user)) {
return error("新增用户'" + user.getUserName() + "'失败,登录账号已存在"); return error("新增用户'" + user.getUserName() + "'失败,登录账号已存在");
} else if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user)) { } else if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user)) {
@ -134,7 +134,7 @@ public class SysUserController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:user:edit')") @PreAuthorize("@ss.hasPermi('system:user:edit')")
@Log(title = "用户管理", businessType = BusinessType.UPDATE) @Log(title = "用户管理", businessType = BusinessType.UPDATE)
@PutMapping @PutMapping
public Result<String> edit (@Validated @RequestBody SysUser user) { public Result<String> edit(@Validated @RequestBody SysUser user) {
userService.checkUserAllowed(user); userService.checkUserAllowed(user);
userService.checkUserDataScope(user.getUserId()); userService.checkUserDataScope(user.getUserId());
if (!userService.checkUserNameUnique(user)) { if (!userService.checkUserNameUnique(user)) {
@ -154,7 +154,7 @@ public class SysUserController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:user:remove')") @PreAuthorize("@ss.hasPermi('system:user:remove')")
@Log(title = "用户管理", businessType = BusinessType.DELETE) @Log(title = "用户管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{userIds}") @DeleteMapping("/{userIds}")
public Result<String> remove (@PathVariable Long[] userIds) { public Result<String> remove(@PathVariable Long[] userIds) {
if (ArrayUtils.contains(userIds, getUserId())) { if (ArrayUtils.contains(userIds, getUserId())) {
return error("当前用户不能删除"); return error("当前用户不能删除");
} }
@ -167,7 +167,7 @@ public class SysUserController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:user:resetPwd')") @PreAuthorize("@ss.hasPermi('system:user:resetPwd')")
@Log(title = "用户管理", businessType = BusinessType.UPDATE) @Log(title = "用户管理", businessType = BusinessType.UPDATE)
@PutMapping("/resetPwd") @PutMapping("/resetPwd")
public Result<String> resetPwd (@RequestBody SysUser user) { public Result<String> resetPwd(@RequestBody SysUser user) {
userService.checkUserAllowed(user); userService.checkUserAllowed(user);
userService.checkUserDataScope(user.getUserId()); userService.checkUserDataScope(user.getUserId());
user.setPassword(SecurityUtils.encryptPassword(user.getPassword())); user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
@ -181,7 +181,7 @@ public class SysUserController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:user:edit')") @PreAuthorize("@ss.hasPermi('system:user:edit')")
@Log(title = "用户管理", businessType = BusinessType.UPDATE) @Log(title = "用户管理", businessType = BusinessType.UPDATE)
@PutMapping("/changeStatus") @PutMapping("/changeStatus")
public Result<String> changeStatus (@RequestBody SysUser user) { public Result<String> changeStatus(@RequestBody SysUser user) {
userService.checkUserAllowed(user); userService.checkUserAllowed(user);
userService.checkUserDataScope(user.getUserId()); userService.checkUserDataScope(user.getUserId());
user.setUpdateBy(getUserId()); user.setUpdateBy(getUserId());
@ -193,7 +193,7 @@ public class SysUserController extends BaseController {
*/ */
@PreAuthorize("@ss.hasPermi('system:user:query')") @PreAuthorize("@ss.hasPermi('system:user:query')")
@GetMapping("/authRole/{userId}") @GetMapping("/authRole/{userId}")
public Result<AuthRoleResp> authRole (@PathVariable("userId") Long userId) { public Result<AuthRoleResp> authRole(@PathVariable("userId") Long userId) {
SysUser user = userService.selectUserById(userId); SysUser user = userService.selectUserById(userId);
List<SysRole> roles = roleService.selectRolesByUserId(userId); List<SysRole> roles = roleService.selectRolesByUserId(userId);
return Result.success( return Result.success(
@ -210,7 +210,7 @@ public class SysUserController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:user:edit')") @PreAuthorize("@ss.hasPermi('system:user:edit')")
@Log(title = "用户管理", businessType = BusinessType.GRANT) @Log(title = "用户管理", businessType = BusinessType.GRANT)
@PutMapping("/authRole") @PutMapping("/authRole")
public Result<String> insertAuthRole (Long userId, Long[] roleIds) { public Result<String> insertAuthRole(Long userId, Long[] roleIds) {
userService.checkUserDataScope(userId); userService.checkUserDataScope(userId);
userService.insertUserAuth(userId, roleIds); userService.insertUserAuth(userId, roleIds);
return Result.success(); return Result.success();
@ -221,7 +221,7 @@ public class SysUserController extends BaseController {
*/ */
@PreAuthorize("@ss.hasPermi('system:user:list')") @PreAuthorize("@ss.hasPermi('system:user:list')")
@GetMapping("/deptTree") @GetMapping("/deptTree")
public Result<List<TreeSelect>> deptTree (SysDept dept) { public Result<List<TreeSelect>> deptTree(SysDept dept) {
return Result.success(deptService.selectDeptTreeList(dept)); return Result.success(deptService.selectDeptTreeList(dept));
} }
} }

View File

@ -29,7 +29,7 @@ public class TestController extends BaseController {
@ApiOperation("获取用户列表") @ApiOperation("获取用户列表")
@GetMapping("/list") @GetMapping("/list")
public Result<List<UserEntity>> userList () { public Result<List<UserEntity>> userList() {
List<UserEntity> userList = new ArrayList<UserEntity>(users.values()); List<UserEntity> userList = new ArrayList<UserEntity>(users.values());
return Result.success(userList); return Result.success(userList);
} }
@ -37,7 +37,7 @@ public class TestController extends BaseController {
@ApiOperation("获取用户详细") @ApiOperation("获取用户详细")
@ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path", dataTypeClass = Integer.class) @ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path", dataTypeClass = Integer.class)
@GetMapping("/{userId}") @GetMapping("/{userId}")
public Result<UserEntity> getUser (@PathVariable Integer userId) { public Result<UserEntity> getUser(@PathVariable Integer userId) {
if (!users.isEmpty() && users.containsKey(userId)) { if (!users.isEmpty() && users.containsKey(userId)) {
return Result.success(users.get(userId)); return Result.success(users.get(userId));
} else { } else {
@ -53,7 +53,7 @@ public class TestController extends BaseController {
@ApiImplicitParam(name = "mobile", value = "用户手机", dataType = "String", dataTypeClass = String.class) @ApiImplicitParam(name = "mobile", value = "用户手机", dataType = "String", dataTypeClass = String.class)
}) })
@PostMapping("/save") @PostMapping("/save")
public Result<String> save (UserEntity user) { public Result<String> save(UserEntity user) {
if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId())) { if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId())) {
return Result.error("用户ID不能为空"); return Result.error("用户ID不能为空");
} }
@ -63,7 +63,7 @@ public class TestController extends BaseController {
@ApiOperation("更新用户") @ApiOperation("更新用户")
@PutMapping("/update") @PutMapping("/update")
public Result<String> update (@RequestBody UserEntity user) { public Result<String> update(@RequestBody UserEntity user) {
if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId())) { if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId())) {
return Result.error("用户ID不能为空"); return Result.error("用户ID不能为空");
} }
@ -78,7 +78,7 @@ public class TestController extends BaseController {
@ApiOperation("删除用户信息") @ApiOperation("删除用户信息")
@ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path", dataTypeClass = Integer.class) @ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path", dataTypeClass = Integer.class)
@DeleteMapping("/{userId}") @DeleteMapping("/{userId}")
public Result<String> delete (@PathVariable Integer userId) { public Result<String> delete(@PathVariable Integer userId) {
if (!users.isEmpty() && users.containsKey(userId)) { if (!users.isEmpty() && users.containsKey(userId)) {
users.remove(userId); users.remove(userId);
return Result.success(); return Result.success();
@ -102,46 +102,46 @@ class UserEntity {
@ApiModelProperty("用户手机") @ApiModelProperty("用户手机")
private String mobile; private String mobile;
public UserEntity () { public UserEntity() {
} }
public UserEntity (Integer userId, String username, String password, String mobile) { public UserEntity(Integer userId, String username, String password, String mobile) {
this.userId = userId; this.userId = userId;
this.username = username; this.username = username;
this.password = password; this.password = password;
this.mobile = mobile; this.mobile = mobile;
} }
public Integer getUserId () { public Integer getUserId() {
return userId; return userId;
} }
public void setUserId (Integer userId) { public void setUserId(Integer userId) {
this.userId = userId; this.userId = userId;
} }
public String getUsername () { public String getUsername() {
return username; return username;
} }
public void setUsername (String username) { public void setUsername(String username) {
this.username = username; this.username = username;
} }
public String getPassword () { public String getPassword() {
return password; return password;
} }
public void setPassword (String password) { public void setPassword(String password) {
this.password = password; this.password = password;
} }
public String getMobile () { public String getMobile() {
return mobile; return mobile;
} }
public void setMobile (String mobile) { public void setMobile(String mobile) {
this.mobile = mobile; this.mobile = mobile;
} }
} }

View File

@ -47,7 +47,7 @@ public class SwaggerConfig {
* API * API
*/ */
@Bean @Bean
public Docket createRestApi () { public Docket createRestApi() {
return new Docket(DocumentationType.OAS_30) return new Docket(DocumentationType.OAS_30)
// 是否启用Swagger // 是否启用Swagger
.enable(enabled) .enable(enabled)
@ -71,7 +71,7 @@ public class SwaggerConfig {
/** /**
* tokenAuthorization * tokenAuthorization
*/ */
private List<SecurityScheme> securitySchemes () { private List<SecurityScheme> securitySchemes() {
List<SecurityScheme> apiKeyList = new ArrayList<SecurityScheme>(); List<SecurityScheme> apiKeyList = new ArrayList<SecurityScheme>();
apiKeyList.add(new ApiKey("Authorization", "Authorization", In.HEADER.toValue())); apiKeyList.add(new ApiKey("Authorization", "Authorization", In.HEADER.toValue()));
return apiKeyList; return apiKeyList;
@ -80,7 +80,7 @@ public class SwaggerConfig {
/** /**
* *
*/ */
private List<SecurityContext> securityContexts () { private List<SecurityContext> securityContexts() {
List<SecurityContext> securityContexts = new ArrayList<>(); List<SecurityContext> securityContexts = new ArrayList<>();
securityContexts.add( securityContexts.add(
SecurityContext.builder() SecurityContext.builder()
@ -93,7 +93,7 @@ public class SwaggerConfig {
/** /**
* *
*/ */
private List<SecurityReference> defaultAuth () { private List<SecurityReference> defaultAuth() {
AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything"); AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything");
AuthorizationScope[] authorizationScopes = new AuthorizationScope[1]; AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
authorizationScopes[0] = authorizationScope; authorizationScopes[0] = authorizationScope;
@ -105,7 +105,7 @@ public class SwaggerConfig {
/** /**
* *
*/ */
private ApiInfo apiInfo () { private ApiInfo apiInfo() {
// 用ApiInfoBuilder进行定制 // 用ApiInfoBuilder进行定制
return new ApiInfoBuilder() return new ApiInfoBuilder()
// 设置标题 // 设置标题

View File

@ -16,6 +16,7 @@
<module>ruoyi-framework</module> <module>ruoyi-framework</module>
<module>ruoyi-system</module> <module>ruoyi-system</module>
<module>ruoyi-common</module> <module>ruoyi-common</module>
<module>ruoyi-custom</module>
</modules> </modules>
<properties> <properties>

View File

@ -14,15 +14,15 @@ public @interface DataScope {
/** /**
* *
*/ */
public String deptAlias () default ""; public String deptAlias() default "";
/** /**
* *
*/ */
public String userAlias () default ""; public String userAlias() default "";
/** /**
* @ss * @ss
*/ */
public String permission () default ""; public String permission() default "";
} }

View File

@ -19,5 +19,5 @@ public @interface DataSource {
/** /**
* *
*/ */
public DataSourceType value () default DataSourceType.MASTER; public DataSourceType value() default DataSourceType.MASTER;
} }

View File

@ -21,137 +21,137 @@ public @interface Excel {
/** /**
* excel * excel
*/ */
public int sort () default Integer.MAX_VALUE; public int sort() default Integer.MAX_VALUE;
/** /**
* Excel. * Excel.
*/ */
public String name () default ""; public String name() default "";
/** /**
* , : yyyy-MM-dd * , : yyyy-MM-dd
*/ */
public String dateFormat () default ""; public String dateFormat() default "";
/** /**
* type (: sys_user_sex) * type (: sys_user_sex)
*/ */
public String dictType () default ""; public String dictType() default "";
/** /**
* (: 0=,1=,2=) * (: 0=,1=,2=)
*/ */
public String readConverterExp () default ""; public String readConverterExp() default "";
/** /**
* *
*/ */
public String separator () default ","; public String separator() default ",";
/** /**
* BigDecimal :-1(BigDecimal) * BigDecimal :-1(BigDecimal)
*/ */
public int scale () default -1; public int scale() default -1;
/** /**
* BigDecimal :BigDecimal.ROUND_HALF_EVEN * BigDecimal :BigDecimal.ROUND_HALF_EVEN
*/ */
public int roundingMode () default BigDecimal.ROUND_HALF_EVEN; public int roundingMode() default BigDecimal.ROUND_HALF_EVEN;
/** /**
* excel * excel
*/ */
public double height () default 14; public double height() default 14;
/** /**
* excel * excel
*/ */
public double width () default 16; public double width() default 16;
/** /**
* ,% 90 90% * ,% 90 90%
*/ */
public String suffix () default ""; public String suffix() default "";
/** /**
* , * ,
*/ */
public String defaultValue () default ""; public String defaultValue() default "";
/** /**
* *
*/ */
public String prompt () default ""; public String prompt() default "";
/** /**
* . * .
*/ */
public String[] combo () default {}; public String[] combo() default {};
/** /**
* ,:list) * ,:list)
*/ */
public boolean needMerge () default false; public boolean needMerge() default false;
/** /**
* ,:,. * ,:,.
*/ */
public boolean isExport () default true; public boolean isExport() default true;
/** /**
* ,, * ,,
*/ */
public String targetAttr () default ""; public String targetAttr() default "";
/** /**
* , * ,
*/ */
public boolean isStatistics () default false; public boolean isStatistics() default false;
/** /**
* 0 1 2 * 0 1 2
*/ */
public ColumnType cellType () default ColumnType.STRING; public ColumnType cellType() default ColumnType.STRING;
/** /**
* *
*/ */
public IndexedColors headerBackgroundColor () default IndexedColors.GREY_50_PERCENT; public IndexedColors headerBackgroundColor() default IndexedColors.GREY_50_PERCENT;
/** /**
* *
*/ */
public IndexedColors headerColor () default IndexedColors.WHITE; public IndexedColors headerColor() default IndexedColors.WHITE;
/** /**
* *
*/ */
public IndexedColors backgroundColor () default IndexedColors.WHITE; public IndexedColors backgroundColor() default IndexedColors.WHITE;
/** /**
* *
*/ */
public IndexedColors color () default IndexedColors.BLACK; public IndexedColors color() default IndexedColors.BLACK;
/** /**
* *
*/ */
public HorizontalAlignment align () default HorizontalAlignment.CENTER; public HorizontalAlignment align() default HorizontalAlignment.CENTER;
/** /**
* *
*/ */
public Class<?> handler () default ExcelHandlerAdapter.class; public Class<?> handler() default ExcelHandlerAdapter.class;
/** /**
* *
*/ */
public String[] args () default {}; public String[] args() default {};
/** /**
* 012 * 012
*/ */
Type type () default Type.ALL; Type type() default Type.ALL;
public enum Type { public enum Type {
/** /**
@ -168,11 +168,11 @@ public @interface Excel {
IMPORT(2); IMPORT(2);
private final int value; private final int value;
Type (int value) { Type(int value) {
this.value = value; this.value = value;
} }
public int value () { public int value() {
return this.value; return this.value;
} }
} }
@ -199,17 +199,19 @@ public @interface Excel {
/** /**
* *
*
* @param value * @param value
*/ */
ColumnType (int value) { ColumnType(int value) {
this.value = value; this.value = value;
} }
/** /**
* *
*
* @return * @return
*/ */
public int value () { public int value() {
return this.value; return this.value;
} }
} }

View File

@ -13,5 +13,5 @@ import java.lang.annotation.Target;
@Target(ElementType.FIELD) @Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
public @interface Excels { public @interface Excels {
public Excel[] value (); public Excel[] value();
} }

View File

@ -17,30 +17,30 @@ public @interface Log {
/** /**
* *
*/ */
public String title () default ""; public String title() default "";
/** /**
* *
*/ */
public BusinessType businessType () default BusinessType.OTHER; public BusinessType businessType() default BusinessType.OTHER;
/** /**
* *
*/ */
public OperatorType operatorType () default OperatorType.MANAGE; public OperatorType operatorType() default OperatorType.MANAGE;
/** /**
* *
*/ */
public boolean isSaveRequestData () default true; public boolean isSaveRequestData() default true;
/** /**
* *
*/ */
public boolean isSaveResponseData () default true; public boolean isSaveResponseData() default true;
/** /**
* *
*/ */
public String[] excludeParamNames () default {}; public String[] excludeParamNames() default {};
} }

View File

@ -17,20 +17,20 @@ public @interface RateLimiter {
/** /**
* key * key
*/ */
public String key () default CacheConstants.RATE_LIMIT_KEY; public String key() default CacheConstants.RATE_LIMIT_KEY;
/** /**
* , * ,
*/ */
public int time () default 60; public int time() default 60;
/** /**
* *
*/ */
public int count () default 100; public int count() default 100;
/** /**
* *
*/ */
public LimitType limitType () default LimitType.DEFAULT; public LimitType limitType() default LimitType.DEFAULT;
} }

View File

@ -15,10 +15,10 @@ public @interface RepeatSubmit {
/** /**
* (ms) * (ms)
*/ */
public int interval () default 5000; public int interval() default 5000;
/** /**
* *
*/ */
public String message () default "不允许重复提交,请稍候再试"; public String message() default "不允许重复提交,请稍候再试";
} }

View File

@ -40,87 +40,87 @@ public class RuoYiConfig {
*/ */
private boolean demoEnabled; private boolean demoEnabled;
public static String getProfile () { public static String getProfile() {
return profile; return profile;
} }
public void setProfile (String profile) { public void setProfile(String profile) {
RuoYiConfig.profile = profile; RuoYiConfig.profile = profile;
} }
public static boolean isAddressEnabled () { public static boolean isAddressEnabled() {
return addressEnabled; return addressEnabled;
} }
public void setAddressEnabled (boolean addressEnabled) { public void setAddressEnabled(boolean addressEnabled) {
RuoYiConfig.addressEnabled = addressEnabled; RuoYiConfig.addressEnabled = addressEnabled;
} }
public static String getCaptchaType () { public static String getCaptchaType() {
return captchaType; return captchaType;
} }
public void setCaptchaType (String captchaType) { public void setCaptchaType(String captchaType) {
RuoYiConfig.captchaType = captchaType; RuoYiConfig.captchaType = captchaType;
} }
/** /**
* *
*/ */
public static String getImportPath () { public static String getImportPath() {
return getProfile() + "/import"; return getProfile() + "/import";
} }
/** /**
* *
*/ */
public static String getAvatarPath () { public static String getAvatarPath() {
return getProfile() + "/avatar"; return getProfile() + "/avatar";
} }
/** /**
* *
*/ */
public static String getDownloadPath () { public static String getDownloadPath() {
return getProfile() + "/download/"; return getProfile() + "/download/";
} }
/** /**
* *
*/ */
public static String getUploadPath () { public static String getUploadPath() {
return getProfile() + "/upload"; return getProfile() + "/upload";
} }
public String getName () { public String getName() {
return name; return name;
} }
public void setName (String name) { public void setName(String name) {
this.name = name; this.name = name;
} }
public String getVersion () { public String getVersion() {
return version; return version;
} }
public void setVersion (String version) { public void setVersion(String version) {
this.version = version; this.version = version;
} }
public String getCopyrightYear () { public String getCopyrightYear() {
return copyrightYear; return copyrightYear;
} }
public void setCopyrightYear (String copyrightYear) { public void setCopyrightYear(String copyrightYear) {
this.copyrightYear = copyrightYear; this.copyrightYear = copyrightYear;
} }
public boolean isDemoEnabled () { public boolean isDemoEnabled() {
return demoEnabled; return demoEnabled;
} }
public void setDemoEnabled (boolean demoEnabled) { public void setDemoEnabled(boolean demoEnabled) {
this.demoEnabled = demoEnabled; this.demoEnabled = demoEnabled;
} }
} }

View File

@ -45,11 +45,11 @@ public class ScheduleConstants {
private String value; private String value;
private Status (String value) { private Status(String value) {
this.value = value; this.value = value;
} }
public String getValue () { public String getValue() {
return value; return value;
} }
} }

View File

@ -12,7 +12,6 @@ import com.ruoyi.common.utils.PageUtils;
import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.sql.SqlUtil; import com.ruoyi.common.utils.sql.SqlUtil;
import org.apache.poi.ss.formula.functions.T;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.web.bind.WebDataBinder; import org.springframework.web.bind.WebDataBinder;
@ -34,11 +33,11 @@ public class BaseController {
* Date * Date
*/ */
@InitBinder @InitBinder
public void initBinder (WebDataBinder binder) { public void initBinder(WebDataBinder binder) {
// Date 类型转换 // Date 类型转换
binder.registerCustomEditor(Date.class, new PropertyEditorSupport() { binder.registerCustomEditor(Date.class, new PropertyEditorSupport() {
@Override @Override
public void setAsText (String text) { public void setAsText(String text) {
setValue(DateUtils.parseDate(text)); setValue(DateUtils.parseDate(text));
} }
}); });
@ -47,14 +46,14 @@ public class BaseController {
/** /**
* *
*/ */
protected void startPage () { protected void startPage() {
PageUtils.startPage(); PageUtils.startPage();
} }
/** /**
* *
*/ */
protected void startOrderBy () { protected void startOrderBy() {
PageDomain pageDomain = TableSupport.buildPageRequest(); PageDomain pageDomain = TableSupport.buildPageRequest();
if (StringUtils.isNotEmpty(pageDomain.getOrderBy())) { if (StringUtils.isNotEmpty(pageDomain.getOrderBy())) {
String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy()); String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy());
@ -65,7 +64,7 @@ public class BaseController {
/** /**
* 线 * 线
*/ */
protected void clearPage () { protected void clearPage() {
PageUtils.clearPage(); PageUtils.clearPage();
} }
@ -73,7 +72,7 @@ public class BaseController {
* *
*/ */
@SuppressWarnings({"rawtypes", "unchecked"}) @SuppressWarnings({"rawtypes", "unchecked"})
protected <T> Result<TableDataInfo<T>> getDataTable (List<T> list) { protected <T> Result<TableDataInfo<T>> getDataTable(List<T> list) {
return Result.success( return Result.success(
TableDataInfo.<T>builder() TableDataInfo.<T>builder()
.total(new PageInfo(list).getTotal()) .total(new PageInfo(list).getTotal())
@ -85,14 +84,14 @@ public class BaseController {
/** /**
* *
*/ */
public Result<String> success () { public Result<String> success() {
return Result.success(); return Result.success();
} }
/** /**
* *
*/ */
public Result<String> error () { public Result<String> error() {
return Result.error(); return Result.error();
} }
@ -100,14 +99,14 @@ public class BaseController {
/** /**
* *
*/ */
public Result<String> error (String message) { public Result<String> error(String message) {
return Result.error(message); return Result.error(message);
} }
/** /**
* *
*/ */
public Result<String> warn (String message) { public Result<String> warn(String message) {
return Result.warn(message); return Result.warn(message);
} }
@ -115,10 +114,9 @@ public class BaseController {
* *
* *
* @param rows * @param rows
*
* @return * @return
*/ */
protected Result<String> toAjax (int rows) { protected Result<String> toAjax(int rows) {
return rows > 0 ? Result.success() : Result.error(); return rows > 0 ? Result.success() : Result.error();
} }
@ -126,45 +124,44 @@ public class BaseController {
* *
* *
* @param result * @param result
*
* @return * @return
*/ */
protected Result<String> toAjax (boolean result) { protected Result<String> toAjax(boolean result) {
return result ? success() : error(); return result ? success() : error();
} }
/** /**
* *
*/ */
public String redirect (String url) { public String redirect(String url) {
return StringUtils.format("redirect:{}", url); return StringUtils.format("redirect:{}", url);
} }
/** /**
* *
*/ */
public LoginUser getLoginUser () { public LoginUser getLoginUser() {
return SecurityUtils.getLoginUser(); return SecurityUtils.getLoginUser();
} }
/** /**
* id * id
*/ */
public Long getUserId () { public Long getUserId() {
return getLoginUser().getUserId(); return getLoginUser().getUserId();
} }
/** /**
* id * id
*/ */
public Long getDeptId () { public Long getDeptId() {
return getLoginUser().getDeptId(); return getLoginUser().getDeptId();
} }
/** /**
* *
*/ */
public String getUsername () { public String getUsername() {
return getLoginUser().getUsername(); return getLoginUser().getUsername();
} }
} }

View File

@ -40,31 +40,31 @@ public class BaseEntity implements Serializable {
/** /**
* *
*/ */
@TableField(value = "create_by" , fill = FieldFill.INSERT) @TableField(value = "create_by", fill = FieldFill.INSERT)
@ApiModelProperty(hidden=true) @ApiModelProperty(hidden = true)
private Long createBy; private Long createBy;
/** /**
* *
*/ */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@TableField(value = "create_time" , fill = FieldFill.INSERT) @TableField(value = "create_time", fill = FieldFill.INSERT)
@ApiModelProperty(hidden=true) @ApiModelProperty(hidden = true)
private Date createTime; private Date createTime;
/** /**
* *
*/ */
@TableField(value = "update_by" , fill = FieldFill.UPDATE) @TableField(value = "update_by", fill = FieldFill.UPDATE)
@ApiModelProperty(hidden=true) @ApiModelProperty(hidden = true)
private Long updateBy; private Long updateBy;
/** /**
* *
*/ */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@TableField(value = "update_time" , fill = FieldFill.UPDATE) @TableField(value = "update_time", fill = FieldFill.UPDATE)
@ApiModelProperty(hidden=true) @ApiModelProperty(hidden = true)
private Date updateTime; private Date updateTime;
/** /**
@ -72,26 +72,27 @@ public class BaseEntity implements Serializable {
*/ */
@JsonInclude(JsonInclude.Include.NON_EMPTY) @JsonInclude(JsonInclude.Include.NON_EMPTY)
@TableField(exist = false) @TableField(exist = false)
@ApiModelProperty(hidden=true) @ApiModelProperty(hidden = true)
private Map<String, Object> params; private Map<String, Object> params;
public Map<String, Object> getParams () { public Map<String, Object> getParams() {
if (params == null) { if (params == null) {
params = new HashMap<>(); params = new HashMap<>();
} }
return params; return params;
} }
public void setParams (Map<String, Object> params) { public void setParams(Map<String, Object> params) {
this.params = params; this.params = params;
} }
/** /**
* *
*
* @param key * @param key
* @return * @return
*/ */
public Object getBeginParam(String key){ public Object getBeginParam(String key) {
return getParams().get( return getParams().get(
StringUtils.format(ReqDomain.BEGIN_REF, key) StringUtils.format(ReqDomain.BEGIN_REF, key)
); );
@ -99,10 +100,11 @@ public class BaseEntity implements Serializable {
/** /**
* *
*
* @param key * @param key
* @return * @return
*/ */
public Object getEndParam(String key){ public Object getEndParam(String key) {
return getParams().get( return getParams().get(
StringUtils.format(ReqDomain.END_REF, key) StringUtils.format(ReqDomain.END_REF, key)
); );
@ -110,10 +112,11 @@ public class BaseEntity implements Serializable {
/** /**
* *
*
* @param key * @param key
* @return * @return
*/ */
public Object[] getBetween(String key){ public Object[] getBetween(String key) {
return new Object[]{getBeginParam(key), getEndParam(key)}; return new Object[]{getBeginParam(key), getEndParam(key)};
} }
} }

View File

@ -32,59 +32,59 @@ public class Result<T> implements Serializable {
private T data; private T data;
public static <T> Result<T> success () { public static <T> Result<T> success() {
return restResult(null, SUCCESS, "操作成功"); return restResult(null, SUCCESS, "操作成功");
} }
public static <T> Result<T> success (T data) { public static <T> Result<T> success(T data) {
return restResult(data, SUCCESS, "操作成功"); return restResult(data, SUCCESS, "操作成功");
} }
public static <T> Result<T> success (T data, String msg) { public static <T> Result<T> success(T data, String msg) {
return restResult(data, SUCCESS, msg); return restResult(data, SUCCESS, msg);
} }
public static <T> Result<T> error () { public static <T> Result<T> error() {
return restResult(null, FAIL, "操作失败"); return restResult(null, FAIL, "操作失败");
} }
public static <T> Result<T> error (String msg) { public static <T> Result<T> error(String msg) {
return restResult(null, FAIL, msg); return restResult(null, FAIL, msg);
} }
public static <T> Result<T> error (T data) { public static <T> Result<T> error(T data) {
return restResult(data, FAIL, "操作失败"); return restResult(data, FAIL, "操作失败");
} }
public static <T> Result<T> error (T data, String msg) { public static <T> Result<T> error(T data, String msg) {
return restResult(data, FAIL, msg); return restResult(data, FAIL, msg);
} }
public static <T> Result<T> error (int code, String msg) { public static <T> Result<T> error(int code, String msg) {
return restResult(null, code, msg); return restResult(null, code, msg);
} }
public static <T> Result<T> warn () { public static <T> Result<T> warn() {
return restResult(null, WARN, "操作失败"); return restResult(null, WARN, "操作失败");
} }
public static <T> Result<T> warn (String msg) { public static <T> Result<T> warn(String msg) {
return restResult(null, WARN, msg); return restResult(null, WARN, msg);
} }
public static <T> Result<T> warn (T data) { public static <T> Result<T> warn(T data) {
return restResult(data, WARN, "操作失败"); return restResult(data, WARN, "操作失败");
} }
public static <T> Result<T> warn (T data, String msg) { public static <T> Result<T> warn(T data, String msg) {
return restResult(data, WARN, msg); return restResult(data, WARN, msg);
} }
public static <T> Result<T> warn (int code, String msg) { public static <T> Result<T> warn(int code, String msg) {
return restResult(null, code, msg); return restResult(null, code, msg);
} }
private static <T> Result<T> restResult (T data, int code, String msg) { private static <T> Result<T> restResult(T data, int code, String msg) {
Result<T> apiResult = new Result<>(); Result<T> apiResult = new Result<>();
apiResult.setCode(code); apiResult.setCode(code);
apiResult.setData(data); apiResult.setData(data);
@ -92,11 +92,11 @@ public class Result<T> implements Serializable {
return apiResult; return apiResult;
} }
public static <T> Boolean isError (Result<T> ret) { public static <T> Boolean isError(Result<T> ret) {
return !isSuccess(ret); return !isSuccess(ret);
} }
public static <T> Boolean isSuccess (Result<T> ret) { public static <T> Boolean isSuccess(Result<T> ret) {
return Result.SUCCESS == ret.getCode(); return Result.SUCCESS == ret.getCode();
} }
} }

View File

@ -36,43 +36,43 @@ public class TreeEntity extends BaseEntity {
*/ */
private List<?> children = new ArrayList<>(); private List<?> children = new ArrayList<>();
public String getParentName () { public String getParentName() {
return parentName; return parentName;
} }
public void setParentName (String parentName) { public void setParentName(String parentName) {
this.parentName = parentName; this.parentName = parentName;
} }
public Long getParentId () { public Long getParentId() {
return parentId; return parentId;
} }
public void setParentId (Long parentId) { public void setParentId(Long parentId) {
this.parentId = parentId; this.parentId = parentId;
} }
public Integer getOrderNum () { public Integer getOrderNum() {
return orderNum; return orderNum;
} }
public void setOrderNum (Integer orderNum) { public void setOrderNum(Integer orderNum) {
this.orderNum = orderNum; this.orderNum = orderNum;
} }
public String getAncestors () { public String getAncestors() {
return ancestors; return ancestors;
} }
public void setAncestors (String ancestors) { public void setAncestors(String ancestors) {
this.ancestors = ancestors; this.ancestors = ancestors;
} }
public List<?> getChildren () { public List<?> getChildren() {
return children; return children;
} }
public void setChildren (List<?> children) { public void setChildren(List<?> children) {
this.children = children; this.children = children;
} }
} }

View File

@ -32,43 +32,43 @@ public class TreeSelect implements Serializable {
@JsonInclude(JsonInclude.Include.NON_EMPTY) @JsonInclude(JsonInclude.Include.NON_EMPTY)
private List<TreeSelect> children; private List<TreeSelect> children;
public TreeSelect () { public TreeSelect() {
} }
public TreeSelect (SysDept dept) { public TreeSelect(SysDept dept) {
this.id = dept.getDeptId(); this.id = dept.getDeptId();
this.label = dept.getDeptName(); this.label = dept.getDeptName();
this.children = dept.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList()); this.children = dept.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
} }
public TreeSelect (SysMenu menu) { public TreeSelect(SysMenu menu) {
this.id = menu.getMenuId(); this.id = menu.getMenuId();
this.label = menu.getMenuName(); this.label = menu.getMenuName();
this.children = menu.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList()); this.children = menu.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
} }
public Long getId () { public Long getId() {
return id; return id;
} }
public void setId (Long id) { public void setId(Long id) {
this.id = id; this.id = id;
} }
public String getLabel () { public String getLabel() {
return label; return label;
} }
public void setLabel (String label) { public void setLabel(String label) {
this.label = label; this.label = label;
} }
public List<TreeSelect> getChildren () { public List<TreeSelect> getChildren() {
return children; return children;
} }
public void setChildren (List<TreeSelect> children) { public void setChildren(List<TreeSelect> children) {
this.children = children; this.children = children;
} }
} }

View File

@ -79,110 +79,110 @@ public class SysDept extends BaseEntity {
*/ */
private List<SysDept> children = new ArrayList<SysDept>(); private List<SysDept> children = new ArrayList<SysDept>();
public Long getDeptId () { public Long getDeptId() {
return deptId; return deptId;
} }
public void setDeptId (Long deptId) { public void setDeptId(Long deptId) {
this.deptId = deptId; this.deptId = deptId;
} }
public Long getParentId () { public Long getParentId() {
return parentId; return parentId;
} }
public void setParentId (Long parentId) { public void setParentId(Long parentId) {
this.parentId = parentId; this.parentId = parentId;
} }
public String getAncestors () { public String getAncestors() {
return ancestors; return ancestors;
} }
public void setAncestors (String ancestors) { public void setAncestors(String ancestors) {
this.ancestors = ancestors; this.ancestors = ancestors;
} }
@NotBlank(message = "部门名称不能为空") @NotBlank(message = "部门名称不能为空")
@Size(min = 0, max = 30, message = "部门名称长度不能超过30个字符") @Size(min = 0, max = 30, message = "部门名称长度不能超过30个字符")
public String getDeptName () { public String getDeptName() {
return deptName; return deptName;
} }
public void setDeptName (String deptName) { public void setDeptName(String deptName) {
this.deptName = deptName; this.deptName = deptName;
} }
@NotNull(message = "显示顺序不能为空") @NotNull(message = "显示顺序不能为空")
public Integer getOrderNum () { public Integer getOrderNum() {
return orderNum; return orderNum;
} }
public void setOrderNum (Integer orderNum) { public void setOrderNum(Integer orderNum) {
this.orderNum = orderNum; this.orderNum = orderNum;
} }
public String getLeader () { public String getLeader() {
return leader; return leader;
} }
public void setLeader (String leader) { public void setLeader(String leader) {
this.leader = leader; this.leader = leader;
} }
@Size(min = 0, max = 11, message = "联系电话长度不能超过11个字符") @Size(min = 0, max = 11, message = "联系电话长度不能超过11个字符")
public String getPhone () { public String getPhone() {
return phone; return phone;
} }
public void setPhone (String phone) { public void setPhone(String phone) {
this.phone = phone; this.phone = phone;
} }
@Email(message = "邮箱格式不正确") @Email(message = "邮箱格式不正确")
@Size(min = 0, max = 50, message = "邮箱长度不能超过50个字符") @Size(min = 0, max = 50, message = "邮箱长度不能超过50个字符")
public String getEmail () { public String getEmail() {
return email; return email;
} }
public void setEmail (String email) { public void setEmail(String email) {
this.email = email; this.email = email;
} }
public String getStatus () { public String getStatus() {
return status; return status;
} }
public void setStatus (String status) { public void setStatus(String status) {
this.status = status; this.status = status;
} }
public String getDelFlag () { public String getDelFlag() {
return delFlag; return delFlag;
} }
public void setDelFlag (String delFlag) { public void setDelFlag(String delFlag) {
this.delFlag = delFlag; this.delFlag = delFlag;
} }
public String getParentName () { public String getParentName() {
return parentName; return parentName;
} }
public void setParentName (String parentName) { public void setParentName(String parentName) {
this.parentName = parentName; this.parentName = parentName;
} }
public List<SysDept> getChildren () { public List<SysDept> getChildren() {
return children; return children;
} }
public void setChildren (List<SysDept> children) { public void setChildren(List<SysDept> children) {
this.children = children; this.children = children;
} }
@Override @Override
public String toString () { public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("deptId", getDeptId()) .append("deptId", getDeptId())
.append("parentId", getParentId()) .append("parentId", getParentId())

View File

@ -2,7 +2,6 @@ package com.ruoyi.common.core.domain.entity;
import com.ruoyi.common.annotation.Excel; import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.annotation.Excel.ColumnType; import com.ruoyi.common.annotation.Excel.ColumnType;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.domain.BaseEntity; import com.ruoyi.common.core.domain.BaseEntity;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
@ -87,29 +86,29 @@ public class SysDictData extends BaseEntity {
@NotBlank(message = "字典标签不能为空") @NotBlank(message = "字典标签不能为空")
@Size(min = 0, max = 100, message = "字典标签长度不能超过100个字符") @Size(min = 0, max = 100, message = "字典标签长度不能超过100个字符")
public String getDictLabel () { public String getDictLabel() {
return dictLabel; return dictLabel;
} }
@NotBlank(message = "字典键值不能为空") @NotBlank(message = "字典键值不能为空")
@Size(min = 0, max = 100, message = "字典键值长度不能超过100个字符") @Size(min = 0, max = 100, message = "字典键值长度不能超过100个字符")
public String getDictValue () { public String getDictValue() {
return dictValue; return dictValue;
} }
@NotBlank(message = "字典类型不能为空") @NotBlank(message = "字典类型不能为空")
@Size(min = 0, max = 100, message = "字典类型长度不能超过100个字符") @Size(min = 0, max = 100, message = "字典类型长度不能超过100个字符")
public String getDictType () { public String getDictType() {
return dictType; return dictType;
} }
@Size(min = 0, max = 100, message = "样式属性长度不能超过100个字符") @Size(min = 0, max = 100, message = "样式属性长度不能超过100个字符")
public String getCssClass () { public String getCssClass() {
return cssClass; return cssClass;
} }
@Override @Override
public String toString () { public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("dictCode", getDictCode()) .append("dictCode", getDictCode())
.append("dictSort", getDictSort()) .append("dictSort", getDictSort())

View File

@ -60,19 +60,19 @@ public class SysDictType extends BaseEntity {
@NotBlank(message = "字典名称不能为空") @NotBlank(message = "字典名称不能为空")
@Size(min = 0, max = 100, message = "字典类型名称长度不能超过100个字符") @Size(min = 0, max = 100, message = "字典类型名称长度不能超过100个字符")
public String getDictName () { public String getDictName() {
return dictName; return dictName;
} }
@NotBlank(message = "字典类型不能为空") @NotBlank(message = "字典类型不能为空")
@Size(min = 0, max = 100, message = "字典类型类型长度不能超过100个字符") @Size(min = 0, max = 100, message = "字典类型类型长度不能超过100个字符")
@Pattern(regexp = "^[a-z][a-z0-9_]*$", message = "字典类型必须以字母开头,且只能为(小写字母,数字,下滑线)") @Pattern(regexp = "^[a-z][a-z0-9_]*$", message = "字典类型必须以字母开头,且只能为(小写字母,数字,下滑线)")
public String getDictType () { public String getDictType() {
return dictType; return dictType;
} }
@Override @Override
public String toString () { public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("dictId", getDictId()) .append("dictId", getDictId())
.append("dictName", getDictName()) .append("dictName", getDictName())

View File

@ -116,38 +116,38 @@ public class SysMenu extends BaseEntity {
@NotBlank(message = "菜单名称不能为空") @NotBlank(message = "菜单名称不能为空")
@Size(min = 0, max = 50, message = "菜单名称长度不能超过50个字符") @Size(min = 0, max = 50, message = "菜单名称长度不能超过50个字符")
public String getMenuName () { public String getMenuName() {
return menuName; return menuName;
} }
@NotNull(message = "显示顺序不能为空") @NotNull(message = "显示顺序不能为空")
public Integer getOrderNum () { public Integer getOrderNum() {
return orderNum; return orderNum;
} }
@Size(min = 0, max = 200, message = "路由地址不能超过200个字符") @Size(min = 0, max = 200, message = "路由地址不能超过200个字符")
public String getPath () { public String getPath() {
return path; return path;
} }
@Size(min = 0, max = 200, message = "组件路径不能超过255个字符") @Size(min = 0, max = 200, message = "组件路径不能超过255个字符")
public String getComponent () { public String getComponent() {
return component; return component;
} }
@NotBlank(message = "菜单类型不能为空") @NotBlank(message = "菜单类型不能为空")
public String getMenuType () { public String getMenuType() {
return menuType; return menuType;
} }
@Size(min = 0, max = 100, message = "权限标识长度不能超过100个字符") @Size(min = 0, max = 100, message = "权限标识长度不能超过100个字符")
public String getPerms () { public String getPerms() {
return perms; return perms;
} }
@Override @Override
public String toString () { public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("menuId", getMenuId()) .append("menuId", getMenuId())
.append("menuName", getMenuName()) .append("menuName", getMenuName())

View File

@ -6,7 +6,6 @@ import com.ruoyi.common.core.domain.BaseEntity;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder; import lombok.experimental.SuperBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle; import org.apache.commons.lang3.builder.ToStringStyle;
@ -105,48 +104,49 @@ public class SysRole extends BaseEntity {
private String remark; private String remark;
public SysRole () { public SysRole() {
} }
public SysRole (Long roleId) { public SysRole(Long roleId) {
this.roleId = roleId; this.roleId = roleId;
} }
public static boolean isAdmin (Long roleId) { public static boolean isAdmin(Long roleId) {
return roleId != null && 1L == roleId; return roleId != null && 1L == roleId;
} }
public boolean isAdmin () { public boolean isAdmin() {
return isAdmin(this.roleId); return isAdmin(this.roleId);
} }
@NotBlank(message = "角色名称不能为空") @NotBlank(message = "角色名称不能为空")
@Size(min = 0, max = 30, message = "角色名称长度不能超过30个字符") @Size(min = 0, max = 30, message = "角色名称长度不能超过30个字符")
public String getRoleName () { public String getRoleName() {
return roleName; return roleName;
} }
@NotBlank(message = "权限字符不能为空") @NotBlank(message = "权限字符不能为空")
@Size(min = 0, max = 100, message = "权限字符长度不能超过100个字符") @Size(min = 0, max = 100, message = "权限字符长度不能超过100个字符")
public String getRoleKey () { public String getRoleKey() {
return roleKey; return roleKey;
} }
@NotNull(message = "显示顺序不能为空") @NotNull(message = "显示顺序不能为空")
public Integer getRoleSort () { public Integer getRoleSort() {
return roleSort; return roleSort;
} }
public boolean isMenuCheckStrictly () { public boolean isMenuCheckStrictly() {
return menuCheckStrictly; return menuCheckStrictly;
} }
public boolean isDeptCheckStrictly () { public boolean isDeptCheckStrictly() {
return deptCheckStrictly; return deptCheckStrictly;
} }
@Override @Override
public String toString () { public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("roleId", getRoleId()) .append("roleId", getRoleId())
.append("roleName", getRoleName()) .append("roleName", getRoleName())

View File

@ -9,7 +9,6 @@ import com.ruoyi.common.xss.Xss;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder; import lombok.experimental.SuperBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle; import org.apache.commons.lang3.builder.ToStringStyle;
@ -141,47 +140,48 @@ public class SysUser extends BaseEntity {
*/ */
private String remark; private String remark;
public SysUser () { public SysUser() {
} }
public SysUser (Long userId) { public SysUser(Long userId) {
this.userId = userId; this.userId = userId;
} }
public static boolean isAdmin (Long userId) { public static boolean isAdmin(Long userId) {
return userId != null && 1L == userId; return userId != null && 1L == userId;
} }
public boolean isAdmin () { public boolean isAdmin() {
return isAdmin(this.userId); return isAdmin(this.userId);
} }
@Xss(message = "用户昵称不能包含脚本字符") @Xss(message = "用户昵称不能包含脚本字符")
@Size(min = 0, max = 30, message = "用户昵称长度不能超过30个字符") @Size(min = 0, max = 30, message = "用户昵称长度不能超过30个字符")
public String getNickName () { public String getNickName() {
return nickName; return nickName;
} }
@Xss(message = "用户账号不能包含脚本字符") @Xss(message = "用户账号不能包含脚本字符")
@NotBlank(message = "用户账号不能为空") @NotBlank(message = "用户账号不能为空")
@Size(min = 0, max = 30, message = "用户账号长度不能超过30个字符") @Size(min = 0, max = 30, message = "用户账号长度不能超过30个字符")
public String getUserName () { public String getUserName() {
return userName; return userName;
} }
@Email(message = "邮箱格式不正确") @Email(message = "邮箱格式不正确")
@Size(min = 0, max = 50, message = "邮箱长度不能超过50个字符") @Size(min = 0, max = 50, message = "邮箱长度不能超过50个字符")
public String getEmail () { public String getEmail() {
return email; return email;
} }
@Size(min = 0, max = 11, message = "手机号码长度不能超过11个字符") @Size(min = 0, max = 11, message = "手机号码长度不能超过11个字符")
public String getPhonenumber () { public String getPhonenumber() {
return phonenumber; return phonenumber;
} }
@Override @Override
public String toString () { public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("userId", getUserId()) .append("userId", getUserId())
.append("deptId", getDeptId()) .append("deptId", getDeptId())

View File

@ -26,35 +26,35 @@ public class LoginBody {
*/ */
private String uuid; private String uuid;
public String getUsername () { public String getUsername() {
return username; return username;
} }
public void setUsername (String username) { public void setUsername(String username) {
this.username = username; this.username = username;
} }
public String getPassword () { public String getPassword() {
return password; return password;
} }
public void setPassword (String password) { public void setPassword(String password) {
this.password = password; this.password = password;
} }
public String getCode () { public String getCode() {
return code; return code;
} }
public void setCode (String code) { public void setCode(String code) {
this.code = code; this.code = code;
} }
public String getUuid () { public String getUuid() {
return uuid; return uuid;
} }
public void setUuid (String uuid) { public void setUuid(String uuid) {
this.uuid = uuid; this.uuid = uuid;
} }
} }

View File

@ -71,53 +71,53 @@ public class LoginUser implements UserDetails {
*/ */
private SysUser user; private SysUser user;
public LoginUser () { public LoginUser() {
} }
public LoginUser (SysUser user, Set<String> permissions) { public LoginUser(SysUser user, Set<String> permissions) {
this.user = user; this.user = user;
this.permissions = permissions; this.permissions = permissions;
} }
public LoginUser (Long userId, Long deptId, SysUser user, Set<String> permissions) { public LoginUser(Long userId, Long deptId, SysUser user, Set<String> permissions) {
this.userId = userId; this.userId = userId;
this.deptId = deptId; this.deptId = deptId;
this.user = user; this.user = user;
this.permissions = permissions; this.permissions = permissions;
} }
public Long getUserId () { public Long getUserId() {
return userId; return userId;
} }
public void setUserId (Long userId) { public void setUserId(Long userId) {
this.userId = userId; this.userId = userId;
} }
public Long getDeptId () { public Long getDeptId() {
return deptId; return deptId;
} }
public void setDeptId (Long deptId) { public void setDeptId(Long deptId) {
this.deptId = deptId; this.deptId = deptId;
} }
public String getToken () { public String getToken() {
return token; return token;
} }
public void setToken (String token) { public void setToken(String token) {
this.token = token; this.token = token;
} }
@JSONField(serialize = false) @JSONField(serialize = false)
@Override @Override
public String getPassword () { public String getPassword() {
return user.getPassword(); return user.getPassword();
} }
@Override @Override
public String getUsername () { public String getUsername() {
return user.getUserName(); return user.getUserName();
} }
@ -126,7 +126,7 @@ public class LoginUser implements UserDetails {
*/ */
@JSONField(serialize = false) @JSONField(serialize = false)
@Override @Override
public boolean isAccountNonExpired () { public boolean isAccountNonExpired() {
return true; return true;
} }
@ -137,7 +137,7 @@ public class LoginUser implements UserDetails {
*/ */
@JSONField(serialize = false) @JSONField(serialize = false)
@Override @Override
public boolean isAccountNonLocked () { public boolean isAccountNonLocked() {
return true; return true;
} }
@ -148,7 +148,7 @@ public class LoginUser implements UserDetails {
*/ */
@JSONField(serialize = false) @JSONField(serialize = false)
@Override @Override
public boolean isCredentialsNonExpired () { public boolean isCredentialsNonExpired() {
return true; return true;
} }
@ -159,76 +159,76 @@ public class LoginUser implements UserDetails {
*/ */
@JSONField(serialize = false) @JSONField(serialize = false)
@Override @Override
public boolean isEnabled () { public boolean isEnabled() {
return true; return true;
} }
public Long getLoginTime () { public Long getLoginTime() {
return loginTime; return loginTime;
} }
public void setLoginTime (Long loginTime) { public void setLoginTime(Long loginTime) {
this.loginTime = loginTime; this.loginTime = loginTime;
} }
public String getIpaddr () { public String getIpaddr() {
return ipaddr; return ipaddr;
} }
public void setIpaddr (String ipaddr) { public void setIpaddr(String ipaddr) {
this.ipaddr = ipaddr; this.ipaddr = ipaddr;
} }
public String getLoginLocation () { public String getLoginLocation() {
return loginLocation; return loginLocation;
} }
public void setLoginLocation (String loginLocation) { public void setLoginLocation(String loginLocation) {
this.loginLocation = loginLocation; this.loginLocation = loginLocation;
} }
public String getBrowser () { public String getBrowser() {
return browser; return browser;
} }
public void setBrowser (String browser) { public void setBrowser(String browser) {
this.browser = browser; this.browser = browser;
} }
public String getOs () { public String getOs() {
return os; return os;
} }
public void setOs (String os) { public void setOs(String os) {
this.os = os; this.os = os;
} }
public Long getExpireTime () { public Long getExpireTime() {
return expireTime; return expireTime;
} }
public void setExpireTime (Long expireTime) { public void setExpireTime(Long expireTime) {
this.expireTime = expireTime; this.expireTime = expireTime;
} }
public Set<String> getPermissions () { public Set<String> getPermissions() {
return permissions; return permissions;
} }
public void setPermissions (Set<String> permissions) { public void setPermissions(Set<String> permissions) {
this.permissions = permissions; this.permissions = permissions;
} }
public SysUser getUser () { public SysUser getUser() {
return user; return user;
} }
public void setUser (SysUser user) { public void setUser(SysUser user) {
this.user = user; this.user = user;
} }
@Override @Override
public Collection<? extends GrantedAuthority> getAuthorities () { public Collection<? extends GrantedAuthority> getAuthorities() {
return null; return null;
} }
} }

View File

@ -33,42 +33,42 @@ public class PageDomain {
*/ */
private Boolean reasonable = true; private Boolean reasonable = true;
public String getOrderBy () { public String getOrderBy() {
if (StringUtils.isEmpty(orderByColumn)) { if (StringUtils.isEmpty(orderByColumn)) {
return ""; return "";
} }
return StringUtils.toUnderScoreCase(orderByColumn) + " " + isAsc; return StringUtils.toUnderScoreCase(orderByColumn) + " " + isAsc;
} }
public Integer getPageNum () { public Integer getPageNum() {
return pageNum; return pageNum;
} }
public void setPageNum (Integer pageNum) { public void setPageNum(Integer pageNum) {
this.pageNum = pageNum; this.pageNum = pageNum;
} }
public Integer getPageSize () { public Integer getPageSize() {
return pageSize; return pageSize;
} }
public void setPageSize (Integer pageSize) { public void setPageSize(Integer pageSize) {
this.pageSize = pageSize; this.pageSize = pageSize;
} }
public String getOrderByColumn () { public String getOrderByColumn() {
return orderByColumn; return orderByColumn;
} }
public void setOrderByColumn (String orderByColumn) { public void setOrderByColumn(String orderByColumn) {
this.orderByColumn = orderByColumn; this.orderByColumn = orderByColumn;
} }
public String getIsAsc () { public String getIsAsc() {
return isAsc; return isAsc;
} }
public void setIsAsc (String isAsc) { public void setIsAsc(String isAsc) {
if (StringUtils.isNotEmpty(isAsc)) { if (StringUtils.isNotEmpty(isAsc)) {
// 兼容前端排序类型 // 兼容前端排序类型
if ("ascending".equals(isAsc)) { if ("ascending".equals(isAsc)) {
@ -80,14 +80,14 @@ public class PageDomain {
} }
} }
public Boolean getReasonable () { public Boolean getReasonable() {
if (StringUtils.isNull(reasonable)) { if (StringUtils.isNull(reasonable)) {
return Boolean.TRUE; return Boolean.TRUE;
} }
return reasonable; return reasonable;
} }
public void setReasonable (Boolean reasonable) { public void setReasonable(Boolean reasonable) {
this.reasonable = reasonable; this.reasonable = reasonable;
} }
} }

View File

@ -37,7 +37,7 @@ public class TableSupport {
/** /**
* *
*/ */
public static PageDomain getPageDomain () { public static PageDomain getPageDomain() {
PageDomain pageDomain = new PageDomain(); PageDomain pageDomain = new PageDomain();
pageDomain.setPageNum(Convert.toInt(ServletUtils.getParameter(PAGE_NUM), 1)); pageDomain.setPageNum(Convert.toInt(ServletUtils.getParameter(PAGE_NUM), 1));
pageDomain.setPageSize(Convert.toInt(ServletUtils.getParameter(PAGE_SIZE), 10)); pageDomain.setPageSize(Convert.toInt(ServletUtils.getParameter(PAGE_SIZE), 10));
@ -47,7 +47,7 @@ public class TableSupport {
return pageDomain; return pageDomain;
} }
public static PageDomain buildPageRequest () { public static PageDomain buildPageRequest() {
return getPageDomain(); return getPageDomain();
} }
} }

View File

@ -7,7 +7,10 @@ import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations; import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.*; import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
/** /**
@ -27,7 +30,7 @@ public class RedisCache {
* @param key * @param key
* @param value * @param value
*/ */
public <T> void setCacheObject (final String key, final T value) { public <T> void setCacheObject(final String key, final T value) {
redisTemplate.opsForValue().set(key, value); redisTemplate.opsForValue().set(key, value);
} }
@ -39,7 +42,7 @@ public class RedisCache {
* @param timeout * @param timeout
* @param timeUnit * @param timeUnit
*/ */
public <T> void setCacheObject (final String key, final T value, final Integer timeout, final TimeUnit timeUnit) { public <T> void setCacheObject(final String key, final T value, final Integer timeout, final TimeUnit timeUnit) {
redisTemplate.opsForValue().set(key, value, timeout, timeUnit); redisTemplate.opsForValue().set(key, value, timeout, timeUnit);
} }
@ -48,10 +51,9 @@ public class RedisCache {
* *
* @param key Redis * @param key Redis
* @param timeout * @param timeout
*
* @return true=false= * @return true=false=
*/ */
public boolean expire (final String key, final long timeout) { public boolean expire(final String key, final long timeout) {
return expire(key, timeout, TimeUnit.SECONDS); return expire(key, timeout, TimeUnit.SECONDS);
} }
@ -61,10 +63,9 @@ public class RedisCache {
* @param key Redis * @param key Redis
* @param timeout * @param timeout
* @param unit * @param unit
*
* @return true=false= * @return true=false=
*/ */
public boolean expire (final String key, final long timeout, final TimeUnit unit) { public boolean expire(final String key, final long timeout, final TimeUnit unit) {
return Boolean.TRUE.equals(redisTemplate.expire(key, timeout, unit)); return Boolean.TRUE.equals(redisTemplate.expire(key, timeout, unit));
} }
@ -72,10 +73,9 @@ public class RedisCache {
* *
* *
* @param key Redis * @param key Redis
*
* @return * @return
*/ */
public long getExpire (final String key) { public long getExpire(final String key) {
return redisTemplate.getExpire(key); return redisTemplate.getExpire(key);
} }
@ -83,10 +83,9 @@ public class RedisCache {
* key * key
* *
* @param key * @param key
*
* @return true false * @return true false
*/ */
public Boolean hasKey (String key) { public Boolean hasKey(String key) {
return redisTemplate.hasKey(key); return redisTemplate.hasKey(key);
} }
@ -94,10 +93,9 @@ public class RedisCache {
* *
* *
* @param key * @param key
*
* @return * @return
*/ */
public <T> T getCacheObject (final String key) { public <T> T getCacheObject(final String key) {
ValueOperations<String, T> operation = redisTemplate.opsForValue(); ValueOperations<String, T> operation = redisTemplate.opsForValue();
return operation.get(key); return operation.get(key);
} }
@ -107,7 +105,7 @@ public class RedisCache {
* *
* @param key * @param key
*/ */
public boolean deleteObject (final String key) { public boolean deleteObject(final String key) {
return redisTemplate.delete(key); return redisTemplate.delete(key);
} }
@ -115,10 +113,9 @@ public class RedisCache {
* *
* *
* @param collection * @param collection
*
* @return * @return
*/ */
public boolean deleteObject (final Collection collection) { public boolean deleteObject(final Collection collection) {
return redisTemplate.delete(collection) > 0; return redisTemplate.delete(collection) > 0;
} }
@ -127,10 +124,9 @@ public class RedisCache {
* *
* @param key * @param key
* @param dataList List * @param dataList List
*
* @return * @return
*/ */
public <T> long setCacheList (final String key, final List<T> dataList) { public <T> long setCacheList(final String key, final List<T> dataList) {
Long count = redisTemplate.opsForList().rightPushAll(key, dataList); Long count = redisTemplate.opsForList().rightPushAll(key, dataList);
return count == null ? 0 : count; return count == null ? 0 : count;
} }
@ -139,10 +135,9 @@ public class RedisCache {
* list * list
* *
* @param key * @param key
*
* @return * @return
*/ */
public <T> List<T> getCacheList (final String key) { public <T> List<T> getCacheList(final String key) {
return redisTemplate.opsForList().range(key, 0, -1); return redisTemplate.opsForList().range(key, 0, -1);
} }
@ -151,10 +146,9 @@ public class RedisCache {
* *
* @param key * @param key
* @param dataSet * @param dataSet
*
* @return * @return
*/ */
public <T> BoundSetOperations<String, T> setCacheSet (final String key, final Set<T> dataSet) { public <T> BoundSetOperations<String, T> setCacheSet(final String key, final Set<T> dataSet) {
BoundSetOperations<String, T> setOperation = redisTemplate.boundSetOps(key); BoundSetOperations<String, T> setOperation = redisTemplate.boundSetOps(key);
for (T t : dataSet) { for (T t : dataSet) {
setOperation.add(t); setOperation.add(t);
@ -166,10 +160,9 @@ public class RedisCache {
* set * set
* *
* @param key * @param key
*
* @return * @return
*/ */
public <T> Set<T> getCacheSet (final String key) { public <T> Set<T> getCacheSet(final String key) {
return redisTemplate.opsForSet().members(key); return redisTemplate.opsForSet().members(key);
} }
@ -179,7 +172,7 @@ public class RedisCache {
* @param key * @param key
* @param dataMap * @param dataMap
*/ */
public <T> void setCacheMap (final String key, final Map<String, T> dataMap) { public <T> void setCacheMap(final String key, final Map<String, T> dataMap) {
if (dataMap != null) { if (dataMap != null) {
redisTemplate.opsForHash().putAll(key, dataMap); redisTemplate.opsForHash().putAll(key, dataMap);
} }
@ -189,10 +182,9 @@ public class RedisCache {
* Map * Map
* *
* @param key * @param key
*
* @return * @return
*/ */
public <T> Map<String, T> getCacheMap (final String key) { public <T> Map<String, T> getCacheMap(final String key) {
return redisTemplate.opsForHash().entries(key); return redisTemplate.opsForHash().entries(key);
} }
@ -203,7 +195,7 @@ public class RedisCache {
* @param hKey Hash * @param hKey Hash
* @param value * @param value
*/ */
public <T> void setCacheMapValue (final String key, final String hKey, final T value) { public <T> void setCacheMapValue(final String key, final String hKey, final T value) {
redisTemplate.opsForHash().put(key, hKey, value); redisTemplate.opsForHash().put(key, hKey, value);
} }
@ -212,10 +204,9 @@ public class RedisCache {
* *
* @param key Redis * @param key Redis
* @param hKey Hash * @param hKey Hash
*
* @return Hash * @return Hash
*/ */
public <T> T getCacheMapValue (final String key, final String hKey) { public <T> T getCacheMapValue(final String key, final String hKey) {
HashOperations<String, String, T> opsForHash = redisTemplate.opsForHash(); HashOperations<String, String, T> opsForHash = redisTemplate.opsForHash();
return opsForHash.get(key, hKey); return opsForHash.get(key, hKey);
} }
@ -225,10 +216,9 @@ public class RedisCache {
* *
* @param key Redis * @param key Redis
* @param hKeys Hash * @param hKeys Hash
*
* @return Hash * @return Hash
*/ */
public <T> List<T> getMultiCacheMapValue (final String key, final Collection<Object> hKeys) { public <T> List<T> getMultiCacheMapValue(final String key, final Collection<Object> hKeys) {
return redisTemplate.opsForHash().multiGet(key, hKeys); return redisTemplate.opsForHash().multiGet(key, hKeys);
} }
@ -237,10 +227,9 @@ public class RedisCache {
* *
* @param key Redis * @param key Redis
* @param hKey Hash * @param hKey Hash
*
* @return * @return
*/ */
public boolean deleteCacheMapValue (final String key, final String hKey) { public boolean deleteCacheMapValue(final String key, final String hKey) {
return redisTemplate.opsForHash().delete(key, hKey) > 0; return redisTemplate.opsForHash().delete(key, hKey) > 0;
} }
@ -248,10 +237,9 @@ public class RedisCache {
* *
* *
* @param pattern * @param pattern
*
* @return * @return
*/ */
public Collection<String> keys (final String pattern) { public Collection<String> keys(final String pattern) {
return redisTemplate.keys(pattern); return redisTemplate.keys(pattern);
} }
} }

View File

@ -41,10 +41,9 @@ public class CharsetKit {
* Charset * Charset
* *
* @param charset * @param charset
*
* @return Charset * @return Charset
*/ */
public static Charset charset (String charset) { public static Charset charset(String charset) {
return StringUtils.isEmpty(charset) ? Charset.defaultCharset() : Charset.forName(charset); return StringUtils.isEmpty(charset) ? Charset.defaultCharset() : Charset.forName(charset);
} }
@ -54,10 +53,9 @@ public class CharsetKit {
* @param source * @param source
* @param srcCharset ISO-8859-1 * @param srcCharset ISO-8859-1
* @param destCharset UTF-8 * @param destCharset UTF-8
*
* @return * @return
*/ */
public static String convert (String source, String srcCharset, String destCharset) { public static String convert(String source, String srcCharset, String destCharset) {
return convert(source, Charset.forName(srcCharset), Charset.forName(destCharset)); return convert(source, Charset.forName(srcCharset), Charset.forName(destCharset));
} }
@ -67,10 +65,9 @@ public class CharsetKit {
* @param source * @param source
* @param srcCharset ISO-8859-1 * @param srcCharset ISO-8859-1
* @param destCharset UTF-8 * @param destCharset UTF-8
*
* @return * @return
*/ */
public static String convert (String source, Charset srcCharset, Charset destCharset) { public static String convert(String source, Charset srcCharset, Charset destCharset) {
if (null == srcCharset) { if (null == srcCharset) {
srcCharset = StandardCharsets.ISO_8859_1; srcCharset = StandardCharsets.ISO_8859_1;
} }
@ -88,7 +85,7 @@ public class CharsetKit {
/** /**
* @return * @return
*/ */
public static String systemCharset () { public static String systemCharset() {
return Charset.defaultCharset().name(); return Charset.defaultCharset().name();
} }
} }

View File

@ -23,10 +23,9 @@ public class Convert {
* *
* @param value * @param value
* @param defaultValue * @param defaultValue
*
* @return * @return
*/ */
public static String toStr (Object value, String defaultValue) { public static String toStr(Object value, String defaultValue) {
if (null == value) { if (null == value) {
return defaultValue; return defaultValue;
} }
@ -42,10 +41,9 @@ public class Convert {
* *
* *
* @param value * @param value
*
* @return * @return
*/ */
public static String toStr (Object value) { public static String toStr(Object value) {
return toStr(value, null); return toStr(value, null);
} }
@ -56,10 +54,9 @@ public class Convert {
* *
* @param value * @param value
* @param defaultValue * @param defaultValue
*
* @return * @return
*/ */
public static Character toChar (Object value, Character defaultValue) { public static Character toChar(Object value, Character defaultValue) {
if (null == value) { if (null == value) {
return defaultValue; return defaultValue;
} }
@ -77,10 +74,9 @@ public class Convert {
* *
* *
* @param value * @param value
*
* @return * @return
*/ */
public static Character toChar (Object value) { public static Character toChar(Object value) {
return toChar(value, null); return toChar(value, null);
} }
@ -91,10 +87,9 @@ public class Convert {
* *
* @param value * @param value
* @param defaultValue * @param defaultValue
*
* @return * @return
*/ */
public static Byte toByte (Object value, Byte defaultValue) { public static Byte toByte(Object value, Byte defaultValue) {
if (value == null) { if (value == null) {
return defaultValue; return defaultValue;
} }
@ -121,10 +116,9 @@ public class Convert {
* *
* *
* @param value * @param value
*
* @return * @return
*/ */
public static Byte toByte (Object value) { public static Byte toByte(Object value) {
return toByte(value, null); return toByte(value, null);
} }
@ -135,10 +129,9 @@ public class Convert {
* *
* @param value * @param value
* @param defaultValue * @param defaultValue
*
* @return * @return
*/ */
public static Short toShort (Object value, Short defaultValue) { public static Short toShort(Object value, Short defaultValue) {
if (value == null) { if (value == null) {
return defaultValue; return defaultValue;
} }
@ -165,10 +158,9 @@ public class Convert {
* *
* *
* @param value * @param value
*
* @return * @return
*/ */
public static Short toShort (Object value) { public static Short toShort(Object value) {
return toShort(value, null); return toShort(value, null);
} }
@ -179,10 +171,9 @@ public class Convert {
* *
* @param value * @param value
* @param defaultValue * @param defaultValue
*
* @return * @return
*/ */
public static Number toNumber (Object value, Number defaultValue) { public static Number toNumber(Object value, Number defaultValue) {
if (value == null) { if (value == null) {
return defaultValue; return defaultValue;
} }
@ -206,10 +197,9 @@ public class Convert {
* *
* *
* @param value * @param value
*
* @return * @return
*/ */
public static Number toNumber (Object value) { public static Number toNumber(Object value) {
return toNumber(value, null); return toNumber(value, null);
} }
@ -220,10 +210,9 @@ public class Convert {
* *
* @param value * @param value
* @param defaultValue * @param defaultValue
*
* @return * @return
*/ */
public static Integer toInt (Object value, Integer defaultValue) { public static Integer toInt(Object value, Integer defaultValue) {
if (value == null) { if (value == null) {
return defaultValue; return defaultValue;
} }
@ -250,10 +239,9 @@ public class Convert {
* *
* *
* @param value * @param value
*
* @return * @return
*/ */
public static Integer toInt (Object value) { public static Integer toInt(Object value) {
return toInt(value, null); return toInt(value, null);
} }
@ -261,10 +249,9 @@ public class Convert {
* Integer<br> * Integer<br>
* *
* @param str * @param str
*
* @return * @return
*/ */
public static Integer[] toIntArray (String str) { public static Integer[] toIntArray(String str) {
return toIntArray(",", str); return toIntArray(",", str);
} }
@ -272,10 +259,9 @@ public class Convert {
* Long<br> * Long<br>
* *
* @param str * @param str
*
* @return * @return
*/ */
public static Long[] toLongArray (String str) { public static Long[] toLongArray(String str) {
return toLongArray(",", str); return toLongArray(",", str);
} }
@ -284,16 +270,15 @@ public class Convert {
* *
* @param split * @param split
* @param split * @param split
*
* @return * @return
*/ */
public static Integer[] toIntArray (String split, String str) { public static Integer[] toIntArray(String split, String str) {
if (StringUtils.isEmpty(str)) { if (StringUtils.isEmpty(str)) {
return new Integer[]{}; return new Integer[]{};
} }
String[] arr = str.split(split); String[] arr = str.split(split);
final Integer[] ints = new Integer[arr.length]; 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); final Integer v = toInt(arr[i], 0);
ints[i] = v; ints[i] = v;
} }
@ -305,16 +290,15 @@ public class Convert {
* *
* @param split * @param split
* @param str * @param str
*
* @return * @return
*/ */
public static Long[] toLongArray (String split, String str) { public static Long[] toLongArray(String split, String str) {
if (StringUtils.isEmpty(str)) { if (StringUtils.isEmpty(str)) {
return new Long[]{}; return new Long[]{};
} }
String[] arr = str.split(split); String[] arr = str.split(split);
final Long[] longs = new Long[arr.length]; 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); final Long v = toLong(arr[i], null);
longs[i] = v; longs[i] = v;
} }
@ -325,10 +309,9 @@ public class Convert {
* String<br> * String<br>
* *
* @param str * @param str
*
* @return * @return
*/ */
public static String[] toStrArray (String str) { public static String[] toStrArray(String str) {
return toStrArray(",", str); return toStrArray(",", str);
} }
@ -337,10 +320,9 @@ public class Convert {
* *
* @param split * @param split
* @param split * @param split
*
* @return * @return
*/ */
public static String[] toStrArray (String split, String str) { public static String[] toStrArray(String split, String str) {
return str.split(split); return str.split(split);
} }
@ -351,10 +333,9 @@ public class Convert {
* *
* @param value * @param value
* @param defaultValue * @param defaultValue
*
* @return * @return
*/ */
public static Long toLong (Object value, Long defaultValue) { public static Long toLong(Object value, Long defaultValue) {
if (value == null) { if (value == null) {
return defaultValue; return defaultValue;
} }
@ -382,10 +363,9 @@ public class Convert {
* *
* *
* @param value * @param value
*
* @return * @return
*/ */
public static Long toLong (Object value) { public static Long toLong(Object value) {
return toLong(value, null); return toLong(value, null);
} }
@ -396,10 +376,9 @@ public class Convert {
* *
* @param value * @param value
* @param defaultValue * @param defaultValue
*
* @return * @return
*/ */
public static Double toDouble (Object value, Double defaultValue) { public static Double toDouble(Object value, Double defaultValue) {
if (value == null) { if (value == null) {
return defaultValue; return defaultValue;
} }
@ -427,10 +406,9 @@ public class Convert {
* *
* *
* @param value * @param value
*
* @return * @return
*/ */
public static Double toDouble (Object value) { public static Double toDouble(Object value) {
return toDouble(value, null); return toDouble(value, null);
} }
@ -441,10 +419,9 @@ public class Convert {
* *
* @param value * @param value
* @param defaultValue * @param defaultValue
*
* @return * @return
*/ */
public static Float toFloat (Object value, Float defaultValue) { public static Float toFloat(Object value, Float defaultValue) {
if (value == null) { if (value == null) {
return defaultValue; return defaultValue;
} }
@ -471,10 +448,9 @@ public class Convert {
* *
* *
* @param value * @param value
*
* @return * @return
*/ */
public static Float toFloat (Object value) { public static Float toFloat(Object value) {
return toFloat(value, null); return toFloat(value, null);
} }
@ -485,10 +461,9 @@ public class Convert {
* *
* @param value * @param value
* @param defaultValue * @param defaultValue
*
* @return * @return
*/ */
public static Boolean toBool (Object value, Boolean defaultValue) { public static Boolean toBool(Object value, Boolean defaultValue) {
if (value == null) { if (value == null) {
return defaultValue; return defaultValue;
} }
@ -521,10 +496,9 @@ public class Convert {
* *
* *
* @param value * @param value
*
* @return * @return
*/ */
public static Boolean toBool (Object value) { public static Boolean toBool(Object value) {
return toBool(value, null); return toBool(value, null);
} }
@ -535,10 +509,9 @@ public class Convert {
* @param clazz EnumClass * @param clazz EnumClass
* @param value * @param value
* @param defaultValue * @param defaultValue
*
* @return Enum * @return Enum
*/ */
public static <E extends Enum<E>> E toEnum (Class<E> clazz, Object value, E defaultValue) { public static <E extends Enum<E>> E toEnum(Class<E> clazz, Object value, E defaultValue) {
if (value == null) { if (value == null) {
return defaultValue; return defaultValue;
} }
@ -564,10 +537,9 @@ public class Convert {
* *
* @param clazz EnumClass * @param clazz EnumClass
* @param value * @param value
*
* @return Enum * @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); return toEnum(clazz, value, null);
} }
@ -578,10 +550,9 @@ public class Convert {
* *
* @param value * @param value
* @param defaultValue * @param defaultValue
*
* @return * @return
*/ */
public static BigInteger toBigInteger (Object value, BigInteger defaultValue) { public static BigInteger toBigInteger(Object value, BigInteger defaultValue) {
if (value == null) { if (value == null) {
return defaultValue; return defaultValue;
} }
@ -608,10 +579,9 @@ public class Convert {
* *
* *
* @param value * @param value
*
* @return * @return
*/ */
public static BigInteger toBigInteger (Object value) { public static BigInteger toBigInteger(Object value) {
return toBigInteger(value, null); return toBigInteger(value, null);
} }
@ -622,10 +592,9 @@ public class Convert {
* *
* @param value * @param value
* @param defaultValue * @param defaultValue
*
* @return * @return
*/ */
public static BigDecimal toBigDecimal (Object value, BigDecimal defaultValue) { public static BigDecimal toBigDecimal(Object value, BigDecimal defaultValue) {
if (value == null) { if (value == null) {
return defaultValue; return defaultValue;
} }
@ -658,10 +627,9 @@ public class Convert {
* *
* *
* @param value * @param value
*
* @return * @return
*/ */
public static BigDecimal toBigDecimal (Object value) { public static BigDecimal toBigDecimal(Object value) {
return toBigDecimal(value, null); return toBigDecimal(value, null);
} }
@ -670,10 +638,9 @@ public class Convert {
* 1ByteByteBuffer 2Arrays.toString * 1ByteByteBuffer 2Arrays.toString
* *
* @param obj * @param obj
*
* @return * @return
*/ */
public static String utf8Str (Object obj) { public static String utf8Str(Object obj) {
return str(obj, CharsetKit.CHARSET_UTF_8); return str(obj, CharsetKit.CHARSET_UTF_8);
} }
@ -683,10 +650,9 @@ public class Convert {
* *
* @param obj * @param obj
* @param charsetName * @param charsetName
*
* @return * @return
*/ */
public static String str (Object obj, String charsetName) { public static String str(Object obj, String charsetName) {
return str(obj, Charset.forName(charsetName)); return str(obj, Charset.forName(charsetName));
} }
@ -696,10 +662,9 @@ public class Convert {
* *
* @param obj * @param obj
* @param charset * @param charset
*
* @return * @return
*/ */
public static String str (Object obj, Charset charset) { public static String str(Object obj, Charset charset) {
if (null == obj) { if (null == obj) {
return null; return null;
} }
@ -722,10 +687,9 @@ public class Convert {
* *
* @param bytes byte * @param bytes byte
* @param charset * @param charset
*
* @return * @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)); return str(bytes, StringUtils.isEmpty(charset) ? Charset.defaultCharset() : Charset.forName(charset));
} }
@ -734,10 +698,9 @@ public class Convert {
* *
* @param data * @param data
* @param charset * @param charset
*
* @return * @return
*/ */
public static String str (byte[] data, Charset charset) { public static String str(byte[] data, Charset charset) {
if (data == null) { if (data == null) {
return null; return null;
} }
@ -753,10 +716,9 @@ public class Convert {
* *
* @param data * @param data
* @param charset 使 * @param charset 使
*
* @return * @return
*/ */
public static String str (ByteBuffer data, String charset) { public static String str(ByteBuffer data, String charset) {
if (data == null) { if (data == null) {
return null; return null;
} }
@ -769,10 +731,9 @@ public class Convert {
* *
* @param data * @param data
* @param charset 使 * @param charset 使
*
* @return * @return
*/ */
public static String str (ByteBuffer data, Charset charset) { public static String str(ByteBuffer data, Charset charset) {
if (null == charset) { if (null == charset) {
charset = Charset.defaultCharset(); charset = Charset.defaultCharset();
} }
@ -785,10 +746,9 @@ public class Convert {
* *
* *
* @param input String. * @param input String.
*
* @return . * @return .
*/ */
public static String toSBC (String input) { public static String toSBC(String input) {
return toSBC(input, null); return toSBC(input, null);
} }
@ -797,12 +757,11 @@ public class Convert {
* *
* @param input String * @param input String
* @param notConvertSet * @param notConvertSet
*
* @return . * @return .
*/ */
public static String toSBC (String input, Set<Character> notConvertSet) { public static String toSBC(String input, Set<Character> notConvertSet) {
char[] c = input.toCharArray(); char[] c = input.toCharArray();
for (int i = 0 ; i < c.length ; i++) { for (int i = 0; i < c.length; i++) {
if (null != notConvertSet && notConvertSet.contains(c[i])) { if (null != notConvertSet && notConvertSet.contains(c[i])) {
// 跳过不替换的字符 // 跳过不替换的字符
continue; continue;
@ -822,10 +781,9 @@ public class Convert {
* *
* *
* @param input String. * @param input String.
*
* @return * @return
*/ */
public static String toDBC (String input) { public static String toDBC(String input) {
return toDBC(input, null); return toDBC(input, null);
} }
@ -834,12 +792,11 @@ public class Convert {
* *
* @param text * @param text
* @param notConvertSet * @param notConvertSet
*
* @return * @return
*/ */
public static String toDBC (String text, Set<Character> notConvertSet) { public static String toDBC(String text, Set<Character> notConvertSet) {
char[] c = text.toCharArray(); char[] c = text.toCharArray();
for (int i = 0 ; i < c.length ; i++) { for (int i = 0; i < c.length; i++) {
if (null != notConvertSet && notConvertSet.contains(c[i])) { if (null != notConvertSet && notConvertSet.contains(c[i])) {
// 跳过不替换的字符 // 跳过不替换的字符
continue; continue;
@ -860,10 +817,9 @@ public class Convert {
* *
* *
* @param n * @param n
*
* @return * @return
*/ */
public static String digitUppercase (double n) { public static String digitUppercase(double n) {
String[] fraction = {"角", "分"}; String[] fraction = {"角", "分"};
String[] digit = {"零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖"}; String[] digit = {"零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖"};
String[][] unit = {{"元", "万", "亿"}, {"", "拾", "佰", "仟"}}; String[][] unit = {{"元", "万", "亿"}, {"", "拾", "佰", "仟"}};
@ -872,7 +828,7 @@ public class Convert {
n = Math.abs(n); n = Math.abs(n);
String s = ""; 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("(零.)+", ""); s += (digit[(int) (Math.floor(n * 10 * Math.pow(10, i)) % 10)] + fraction[i]).replaceAll("(零.)+", "");
} }
if (s.length() < 1) { if (s.length() < 1) {
@ -880,9 +836,9 @@ public class Convert {
} }
int integerPart = (int) Math.floor(n); 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 = ""; 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; p = digit[integerPart % 10] + unit[1][j] + p;
integerPart = integerPart / 10; integerPart = integerPart / 10;
} }

View File

@ -24,10 +24,9 @@ public class StrFormatter {
* *
* @param strPattern * @param strPattern
* @param argArray * @param argArray
*
* @return * @return
*/ */
public static String format (final String strPattern, final Object... argArray) { public static String format(final String strPattern, final Object... argArray) {
if (StringUtils.isEmpty(strPattern) || StringUtils.isEmpty(argArray)) { if (StringUtils.isEmpty(strPattern) || StringUtils.isEmpty(argArray)) {
return strPattern; return strPattern;
} }
@ -38,7 +37,7 @@ public class StrFormatter {
int handledPosition = 0; int handledPosition = 0;
int delimIndex;// 占位符所在位置 int delimIndex;// 占位符所在位置
for (int argIndex = 0 ; argIndex < argArray.length ; argIndex++) { for (int argIndex = 0; argIndex < argArray.length; argIndex++) {
delimIndex = strPattern.indexOf(EMPTY_JSON, handledPosition); delimIndex = strPattern.indexOf(EMPTY_JSON, handledPosition);
if (delimIndex == -1) { if (delimIndex == -1) {
if (handledPosition == 0) { if (handledPosition == 0) {

View File

@ -22,11 +22,11 @@ public enum HttpMethod {
} }
@Nullable @Nullable
public static HttpMethod resolve (@Nullable String method) { public static HttpMethod resolve(@Nullable String method) {
return (method != null ? mappings.get(method) : null); return (method != null ? mappings.get(method) : null);
} }
public boolean matches (String method) { public boolean matches(String method) {
return (this == resolve(method)); return (this == resolve(method));
} }
} }

View File

@ -11,16 +11,16 @@ public enum UserStatus {
private final String code; private final String code;
private final String info; private final String info;
UserStatus (String code, String info) { UserStatus(String code, String info) {
this.code = code; this.code = code;
this.info = info; this.info = info;
} }
public String getCode () { public String getCode() {
return code; return code;
} }
public String getInfo () { public String getInfo() {
return info; return info;
} }
} }

View File

@ -8,6 +8,6 @@ package com.ruoyi.common.exception;
public class DemoModeException extends RuntimeException { public class DemoModeException extends RuntimeException {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public DemoModeException () { public DemoModeException() {
} }
} }

View File

@ -23,28 +23,28 @@ public class GlobalException extends RuntimeException {
/** /**
* *
*/ */
public GlobalException () { public GlobalException() {
} }
public GlobalException (String message) { public GlobalException(String message) {
this.message = message; this.message = message;
} }
public String getDetailMessage () { public String getDetailMessage() {
return detailMessage; return detailMessage;
} }
public GlobalException setDetailMessage (String detailMessage) { public GlobalException setDetailMessage(String detailMessage) {
this.detailMessage = detailMessage; this.detailMessage = detailMessage;
return this; return this;
} }
@Override @Override
public String getMessage () { public String getMessage() {
return message; return message;
} }
public GlobalException setMessage (String message) { public GlobalException setMessage(String message) {
this.message = message; this.message = message;
return this; return this;
} }

View File

@ -28,38 +28,38 @@ public final class ServiceException extends RuntimeException {
/** /**
* *
*/ */
public ServiceException () { public ServiceException() {
} }
public ServiceException (String message) { public ServiceException(String message) {
this.message = message; this.message = message;
} }
public ServiceException (String message, Integer code) { public ServiceException(String message, Integer code) {
this.message = message; this.message = message;
this.code = code; this.code = code;
} }
public String getDetailMessage () { public String getDetailMessage() {
return detailMessage; return detailMessage;
} }
public ServiceException setDetailMessage (String detailMessage) { public ServiceException setDetailMessage(String detailMessage) {
this.detailMessage = detailMessage; this.detailMessage = detailMessage;
return this; return this;
} }
@Override @Override
public String getMessage () { public String getMessage() {
return message; return message;
} }
public ServiceException setMessage (String message) { public ServiceException setMessage(String message) {
this.message = message; this.message = message;
return this; return this;
} }
public Integer getCode () { public Integer getCode() {
return code; return code;
} }
} }

View File

@ -8,15 +8,15 @@ package com.ruoyi.common.exception;
public class UtilException extends RuntimeException { public class UtilException extends RuntimeException {
private static final long serialVersionUID = 8247610319171014183L; private static final long serialVersionUID = 8247610319171014183L;
public UtilException (Throwable e) { public UtilException(Throwable e) {
super(e.getMessage(), e); super(e.getMessage(), e);
} }
public UtilException (String message) { public UtilException(String message) {
super(message); super(message);
} }
public UtilException (String message, Throwable throwable) { public UtilException(String message, Throwable throwable) {
super(message, throwable); super(message, throwable);
} }
} }

View File

@ -31,31 +31,31 @@ public class BaseException extends RuntimeException {
*/ */
private String defaultMessage; private String defaultMessage;
public BaseException (String module, String code, Object[] args, String defaultMessage) { public BaseException(String module, String code, Object[] args, String defaultMessage) {
this.module = module; this.module = module;
this.code = code; this.code = code;
this.args = args; this.args = args;
this.defaultMessage = defaultMessage; this.defaultMessage = defaultMessage;
} }
public BaseException (String module, String code, Object[] args) { public BaseException(String module, String code, Object[] args) {
this(module, code, args, null); this(module, code, args, null);
} }
public BaseException (String module, String defaultMessage) { public BaseException(String module, String defaultMessage) {
this(module, null, null, defaultMessage); this(module, null, null, defaultMessage);
} }
public BaseException (String code, Object[] args) { public BaseException(String code, Object[] args) {
this(null, code, args, null); this(null, code, args, null);
} }
public BaseException (String defaultMessage) { public BaseException(String defaultMessage) {
this(null, null, null, defaultMessage); this(null, null, null, defaultMessage);
} }
@Override @Override
public String getMessage () { public String getMessage() {
String message = null; String message = null;
if (!StringUtils.isEmpty(code)) { if (!StringUtils.isEmpty(code)) {
message = MessageUtils.message(code, args); message = MessageUtils.message(code, args);
@ -66,19 +66,19 @@ public class BaseException extends RuntimeException {
return message; return message;
} }
public String getModule () { public String getModule() {
return module; return module;
} }
public String getCode () { public String getCode() {
return code; return code;
} }
public Object[] getArgs () { public Object[] getArgs() {
return args; return args;
} }
public String getDefaultMessage () { public String getDefaultMessage() {
return defaultMessage; return defaultMessage;
} }
} }

View File

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

View File

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

View File

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

View File

@ -14,21 +14,21 @@ public class FileUploadException extends Exception {
private final Throwable cause; private final Throwable cause;
public FileUploadException () { public FileUploadException() {
this(null, null); this(null, null);
} }
public FileUploadException (final String msg) { public FileUploadException(final String msg) {
this(msg, null); this(msg, null);
} }
public FileUploadException (String msg, Throwable cause) { public FileUploadException(String msg, Throwable cause) {
super(msg); super(msg);
this.cause = cause; this.cause = cause;
} }
@Override @Override
public void printStackTrace (PrintStream stream) { public void printStackTrace(PrintStream stream) {
super.printStackTrace(stream); super.printStackTrace(stream);
if (cause != null) { if (cause != null) {
stream.println("Caused by:"); stream.println("Caused by:");
@ -37,7 +37,7 @@ public class FileUploadException extends Exception {
} }
@Override @Override
public void printStackTrace (PrintWriter writer) { public void printStackTrace(PrintWriter writer) {
super.printStackTrace(writer); super.printStackTrace(writer);
if (cause != null) { if (cause != null) {
writer.println("Caused by:"); writer.println("Caused by:");
@ -46,7 +46,7 @@ public class FileUploadException extends Exception {
} }
@Override @Override
public Throwable getCause () { public Throwable getCause() {
return cause; return cause;
} }
} }

View File

@ -14,29 +14,29 @@ public class InvalidExtensionException extends FileUploadException {
private String extension; private String extension;
private String filename; private String filename;
public InvalidExtensionException (String[] allowedExtension, String extension, String filename) { public InvalidExtensionException(String[] allowedExtension, String extension, String filename) {
super("文件[" + filename + "]后缀[" + extension + "]不正确,请上传" + Arrays.toString(allowedExtension) + "格式"); super("文件[" + filename + "]后缀[" + extension + "]不正确,请上传" + Arrays.toString(allowedExtension) + "格式");
this.allowedExtension = allowedExtension; this.allowedExtension = allowedExtension;
this.extension = extension; this.extension = extension;
this.filename = filename; this.filename = filename;
} }
public String[] getAllowedExtension () { public String[] getAllowedExtension() {
return allowedExtension; return allowedExtension;
} }
public String getExtension () { public String getExtension() {
return extension; return extension;
} }
public String getFilename () { public String getFilename() {
return filename; return filename;
} }
public static class InvalidImageExtensionException extends InvalidExtensionException { public static class InvalidImageExtensionException extends InvalidExtensionException {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public InvalidImageExtensionException (String[] allowedExtension, String extension, String filename) { public InvalidImageExtensionException(String[] allowedExtension, String extension, String filename) {
super(allowedExtension, extension, filename); super(allowedExtension, extension, filename);
} }
} }
@ -44,7 +44,7 @@ public class InvalidExtensionException extends FileUploadException {
public static class InvalidFlashExtensionException extends InvalidExtensionException { public static class InvalidFlashExtensionException extends InvalidExtensionException {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public InvalidFlashExtensionException (String[] allowedExtension, String extension, String filename) { public InvalidFlashExtensionException(String[] allowedExtension, String extension, String filename) {
super(allowedExtension, extension, filename); super(allowedExtension, extension, filename);
} }
} }
@ -52,7 +52,7 @@ public class InvalidExtensionException extends FileUploadException {
public static class InvalidMediaExtensionException extends InvalidExtensionException { public static class InvalidMediaExtensionException extends InvalidExtensionException {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public InvalidMediaExtensionException (String[] allowedExtension, String extension, String filename) { public InvalidMediaExtensionException(String[] allowedExtension, String extension, String filename) {
super(allowedExtension, extension, filename); super(allowedExtension, extension, filename);
} }
} }
@ -60,7 +60,7 @@ public class InvalidExtensionException extends FileUploadException {
public static class InvalidVideoExtensionException extends InvalidExtensionException { public static class InvalidVideoExtensionException extends InvalidExtensionException {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public InvalidVideoExtensionException (String[] allowedExtension, String extension, String filename) { public InvalidVideoExtensionException(String[] allowedExtension, String extension, String filename) {
super(allowedExtension, extension, filename); super(allowedExtension, extension, filename);
} }
} }

View File

@ -10,16 +10,16 @@ public class TaskException extends Exception {
private Code code; private Code code;
public TaskException (String msg, Code code) { public TaskException(String msg, Code code) {
this(msg, code, null); this(msg, code, null);
} }
public TaskException (String msg, Code code, Exception nestedEx) { public TaskException(String msg, Code code, Exception nestedEx) {
super(msg, nestedEx); super(msg, nestedEx);
this.code = code; this.code = code;
} }
public Code getCode () { public Code getCode() {
return code; return code;
} }

View File

@ -8,7 +8,7 @@ package com.ruoyi.common.exception.user;
public class BlackListException extends UserException { public class BlackListException extends UserException {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public BlackListException () { public BlackListException() {
super("login.blocked", null); super("login.blocked", null);
} }
} }

View File

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

View File

@ -8,7 +8,7 @@ package com.ruoyi.common.exception.user;
public class CaptchaExpireException extends UserException { public class CaptchaExpireException extends UserException {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public CaptchaExpireException () { public CaptchaExpireException() {
super("user.jcaptcha.expire", null); super("user.jcaptcha.expire", null);
} }
} }

View File

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

View File

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

View File

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

View File

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

View File

@ -8,11 +8,11 @@ import com.alibaba.fastjson2.filter.SimplePropertyPreFilter;
* @author ruoyi * @author ruoyi
*/ */
public class PropertyPreExcludeFilter extends SimplePropertyPreFilter { public class PropertyPreExcludeFilter extends SimplePropertyPreFilter {
public PropertyPreExcludeFilter () { public PropertyPreExcludeFilter() {
} }
public PropertyPreExcludeFilter addExcludes (String... filters) { public PropertyPreExcludeFilter addExcludes(String... filters) {
for (int i = 0 ; i < filters.length ; i++) { for (int i = 0; i < filters.length; i++) {
this.getExcludes().add(filters[i]); this.getExcludes().add(filters[i]);
} }
return this; return this;

View File

@ -14,12 +14,12 @@ import java.io.IOException;
*/ */
public class RepeatableFilter implements Filter { public class RepeatableFilter implements Filter {
@Override @Override
public void init (FilterConfig filterConfig) throws ServletException { public void init(FilterConfig filterConfig) throws ServletException {
} }
@Override @Override
public void doFilter (ServletRequest request, ServletResponse response, FilterChain chain) public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException { throws IOException, ServletException {
ServletRequest requestWrapper = null; ServletRequest requestWrapper = null;
if (request instanceof HttpServletRequest if (request instanceof HttpServletRequest
@ -34,7 +34,7 @@ public class RepeatableFilter implements Filter {
} }
@Override @Override
public void destroy () { public void destroy() {
} }
} }

View File

@ -21,7 +21,7 @@ import java.io.InputStreamReader;
public class RepeatedlyRequestWrapper extends HttpServletRequestWrapper { public class RepeatedlyRequestWrapper extends HttpServletRequestWrapper {
private final byte[] body; private final byte[] body;
public RepeatedlyRequestWrapper (HttpServletRequest request, ServletResponse response) throws IOException { public RepeatedlyRequestWrapper(HttpServletRequest request, ServletResponse response) throws IOException {
super(request); super(request);
request.setCharacterEncoding(Constants.UTF8); request.setCharacterEncoding(Constants.UTF8);
response.setCharacterEncoding(Constants.UTF8); response.setCharacterEncoding(Constants.UTF8);
@ -30,36 +30,36 @@ public class RepeatedlyRequestWrapper extends HttpServletRequestWrapper {
} }
@Override @Override
public BufferedReader getReader () throws IOException { public BufferedReader getReader() throws IOException {
return new BufferedReader(new InputStreamReader(getInputStream())); return new BufferedReader(new InputStreamReader(getInputStream()));
} }
@Override @Override
public ServletInputStream getInputStream () throws IOException { public ServletInputStream getInputStream() throws IOException {
final ByteArrayInputStream bais = new ByteArrayInputStream(body); final ByteArrayInputStream bais = new ByteArrayInputStream(body);
return new ServletInputStream() { return new ServletInputStream() {
@Override @Override
public int read () throws IOException { public int read() throws IOException {
return bais.read(); return bais.read();
} }
@Override @Override
public int available () throws IOException { public int available() throws IOException {
return body.length; return body.length;
} }
@Override @Override
public boolean isFinished () { public boolean isFinished() {
return false; return false;
} }
@Override @Override
public boolean isReady () { public boolean isReady() {
return false; return false;
} }
@Override @Override
public void setReadListener (ReadListener readListener) { public void setReadListener(ReadListener readListener) {
} }
}; };

View File

@ -22,18 +22,18 @@ public class XssFilter implements Filter {
public List<String> excludes = new ArrayList<>(); public List<String> excludes = new ArrayList<>();
@Override @Override
public void init (FilterConfig filterConfig) throws ServletException { public void init(FilterConfig filterConfig) throws ServletException {
String tempExcludes = filterConfig.getInitParameter("excludes"); String tempExcludes = filterConfig.getInitParameter("excludes");
if (StringUtils.isNotEmpty(tempExcludes)) { if (StringUtils.isNotEmpty(tempExcludes)) {
String[] url = tempExcludes.split(","); String[] url = tempExcludes.split(",");
for (int i = 0 ; url != null && i < url.length ; i++) { for (int i = 0; url != null && i < url.length; i++) {
excludes.add(url[i]); excludes.add(url[i]);
} }
} }
} }
@Override @Override
public void doFilter (ServletRequest request, ServletResponse response, FilterChain chain) public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException { throws IOException, ServletException {
HttpServletRequest req = (HttpServletRequest) request; HttpServletRequest req = (HttpServletRequest) request;
HttpServletResponse resp = (HttpServletResponse) response; HttpServletResponse resp = (HttpServletResponse) response;
@ -45,7 +45,7 @@ public class XssFilter implements Filter {
chain.doFilter(xssRequest, response); chain.doFilter(xssRequest, response);
} }
private boolean handleExcludeURL (HttpServletRequest request, HttpServletResponse response) { private boolean handleExcludeURL(HttpServletRequest request, HttpServletResponse response) {
String url = request.getServletPath(); String url = request.getServletPath();
String method = request.getMethod(); String method = request.getMethod();
// GET DELETE 不过滤 // GET DELETE 不过滤
@ -56,7 +56,7 @@ public class XssFilter implements Filter {
} }
@Override @Override
public void destroy () { public void destroy() {
} }
} }

View File

@ -22,17 +22,17 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper {
/** /**
* @param request * @param request
*/ */
public XssHttpServletRequestWrapper (HttpServletRequest request) { public XssHttpServletRequestWrapper(HttpServletRequest request) {
super(request); super(request);
} }
@Override @Override
public String[] getParameterValues (String name) { public String[] getParameterValues(String name) {
String[] values = super.getParameterValues(name); String[] values = super.getParameterValues(name);
if (values != null) { if (values != null) {
int length = values.length; int length = values.length;
String[] escapesValues = new String[length]; String[] escapesValues = new String[length];
for (int i = 0 ; i < length ; i++) { for (int i = 0; i < length; i++) {
// 防xss攻击和过滤前后空格 // 防xss攻击和过滤前后空格
escapesValues[i] = EscapeUtil.clean(values[i]).trim(); escapesValues[i] = EscapeUtil.clean(values[i]).trim();
} }
@ -42,7 +42,7 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper {
} }
@Override @Override
public ServletInputStream getInputStream () throws IOException { public ServletInputStream getInputStream() throws IOException {
// 非json类型直接返回 // 非json类型直接返回
if (!isJsonRequest()) { if (!isJsonRequest()) {
return super.getInputStream(); return super.getInputStream();
@ -60,26 +60,26 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper {
final ByteArrayInputStream bis = new ByteArrayInputStream(jsonBytes); final ByteArrayInputStream bis = new ByteArrayInputStream(jsonBytes);
return new ServletInputStream() { return new ServletInputStream() {
@Override @Override
public boolean isFinished () { public boolean isFinished() {
return true; return true;
} }
@Override @Override
public boolean isReady () { public boolean isReady() {
return true; return true;
} }
@Override @Override
public int available () throws IOException { public int available() throws IOException {
return jsonBytes.length; return jsonBytes.length;
} }
@Override @Override
public void setReadListener (ReadListener readListener) { public void setReadListener(ReadListener readListener) {
} }
@Override @Override
public int read () throws IOException { public int read() throws IOException {
return bis.read(); return bis.read();
} }
}; };
@ -90,7 +90,7 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper {
* *
* @param request * @param request
*/ */
public boolean isJsonRequest () { public boolean isJsonRequest() {
String header = super.getHeader(HttpHeaders.CONTENT_TYPE); String header = super.getHeader(HttpHeaders.CONTENT_TYPE);
return StringUtils.startsWithIgnoreCase(header, MediaType.APPLICATION_JSON_VALUE); return StringUtils.startsWithIgnoreCase(header, MediaType.APPLICATION_JSON_VALUE);
} }

View File

@ -18,7 +18,7 @@ public class Arith {
/** /**
* *
*/ */
private Arith () { private Arith() {
} }
/** /**
@ -26,10 +26,9 @@ public class Arith {
* *
* @param v1 * @param v1
* @param v2 * @param v2
*
* @return * @return
*/ */
public static double add (double v1, double v2) { public static double add(double v1, double v2) {
BigDecimal b1 = new BigDecimal(Double.toString(v1)); BigDecimal b1 = new BigDecimal(Double.toString(v1));
BigDecimal b2 = new BigDecimal(Double.toString(v2)); BigDecimal b2 = new BigDecimal(Double.toString(v2));
return b1.add(b2).doubleValue(); return b1.add(b2).doubleValue();
@ -40,10 +39,9 @@ public class Arith {
* *
* @param v1 * @param v1
* @param v2 * @param v2
*
* @return * @return
*/ */
public static double sub (double v1, double v2) { public static double sub(double v1, double v2) {
BigDecimal b1 = new BigDecimal(Double.toString(v1)); BigDecimal b1 = new BigDecimal(Double.toString(v1));
BigDecimal b2 = new BigDecimal(Double.toString(v2)); BigDecimal b2 = new BigDecimal(Double.toString(v2));
return b1.subtract(b2).doubleValue(); return b1.subtract(b2).doubleValue();
@ -54,10 +52,9 @@ public class Arith {
* *
* @param v1 * @param v1
* @param v2 * @param v2
*
* @return * @return
*/ */
public static double mul (double v1, double v2) { public static double mul(double v1, double v2) {
BigDecimal b1 = new BigDecimal(Double.toString(v1)); BigDecimal b1 = new BigDecimal(Double.toString(v1));
BigDecimal b2 = new BigDecimal(Double.toString(v2)); BigDecimal b2 = new BigDecimal(Double.toString(v2));
return b1.multiply(b2).doubleValue(); return b1.multiply(b2).doubleValue();
@ -69,10 +66,9 @@ public class Arith {
* *
* @param v1 * @param v1
* @param v2 * @param v2
*
* @return * @return
*/ */
public static double div (double v1, double v2) { public static double div(double v1, double v2) {
return div(v1, v2, DEF_DIV_SCALE); return div(v1, v2, DEF_DIV_SCALE);
} }
@ -83,10 +79,9 @@ public class Arith {
* @param v1 * @param v1
* @param v2 * @param v2
* @param scale * @param scale
*
* @return * @return
*/ */
public static double div (double v1, double v2, int scale) { public static double div(double v1, double v2, int scale) {
if (scale < 0) { if (scale < 0) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"The scale must be a positive integer or zero"); "The scale must be a positive integer or zero");
@ -104,10 +99,9 @@ public class Arith {
* *
* @param v * @param v
* @param scale * @param scale
*
* @return * @return
*/ */
public static double round (double v, int scale) { public static double round(double v, int scale) {
if (scale < 0) { if (scale < 0) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"The scale must be a positive integer or zero"); "The scale must be a positive integer or zero");

View File

@ -34,7 +34,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
* *
* @return Date() * @return Date()
*/ */
public static Date getNowDate () { public static Date getNowDate() {
return new Date(); return new Date();
} }
@ -43,31 +43,31 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
* *
* @return String * @return String
*/ */
public static String getDate () { public static String getDate() {
return dateTimeNow(YYYY_MM_DD); return dateTimeNow(YYYY_MM_DD);
} }
public static final String getTime () { public static final String getTime() {
return dateTimeNow(YYYY_MM_DD_HH_MM_SS); return dateTimeNow(YYYY_MM_DD_HH_MM_SS);
} }
public static final String dateTimeNow () { public static final String dateTimeNow() {
return dateTimeNow(YYYYMMDDHHMMSS); return dateTimeNow(YYYYMMDDHHMMSS);
} }
public static final String dateTimeNow (final String format) { public static final String dateTimeNow(final String format) {
return parseDateToStr(format, new Date()); return parseDateToStr(format, new Date());
} }
public static final String dateTime (final Date date) { public static final String dateTime(final Date date) {
return parseDateToStr(YYYY_MM_DD, date); return parseDateToStr(YYYY_MM_DD, date);
} }
public static final String parseDateToStr (final String format, final Date date) { public static final String parseDateToStr(final String format, final Date date) {
return new SimpleDateFormat(format).format(date); return new SimpleDateFormat(format).format(date);
} }
public static final Date dateTime (final String format, final String ts) { public static final Date dateTime(final String format, final String ts) {
try { try {
return new SimpleDateFormat(format).parse(ts); return new SimpleDateFormat(format).parse(ts);
} catch (ParseException e) { } catch (ParseException e) {
@ -78,7 +78,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
/** /**
* // 2018/08/08 * // 2018/08/08
*/ */
public static final String datePath () { public static final String datePath() {
Date now = new Date(); Date now = new Date();
return DateFormatUtils.format(now, "yyyy/MM/dd"); return DateFormatUtils.format(now, "yyyy/MM/dd");
} }
@ -86,7 +86,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
/** /**
* // 20180808 * // 20180808
*/ */
public static final String dateTime () { public static final String dateTime() {
Date now = new Date(); Date now = new Date();
return DateFormatUtils.format(now, "yyyyMMdd"); return DateFormatUtils.format(now, "yyyyMMdd");
} }
@ -94,7 +94,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
/** /**
* *
*/ */
public static Date parseDate (Object str) { public static Date parseDate(Object str) {
if (str == null) { if (str == null) {
return null; return null;
} }
@ -108,7 +108,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
/** /**
* *
*/ */
public static Date getServerStartDate () { public static Date getServerStartDate() {
long time = ManagementFactory.getRuntimeMXBean().getStartTime(); long time = ManagementFactory.getRuntimeMXBean().getStartTime();
return new Date(time); return new Date(time);
} }
@ -116,7 +116,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
/** /**
* *
*/ */
public static int differentDaysByMillisecond (Date date1, Date date2) { public static int differentDaysByMillisecond(Date date1, Date date2) {
return Math.abs((int) ((date2.getTime() - date1.getTime()) / (1000 * 3600 * 24))); return Math.abs((int) ((date2.getTime() - date1.getTime()) / (1000 * 3600 * 24)));
} }
@ -125,10 +125,9 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
* *
* @param endDate * @param endDate
* @param startTime * @param startTime
*
* @return // * @return //
*/ */
public static String timeDistance (Date endDate, Date startTime) { public static String timeDistance(Date endDate, Date startTime) {
long nd = 1000 * 24 * 60 * 60; long nd = 1000 * 24 * 60 * 60;
long nh = 1000 * 60 * 60; long nh = 1000 * 60 * 60;
long nm = 1000 * 60; long nm = 1000 * 60;
@ -149,7 +148,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
/** /**
* LocalDateTime ==> Date * LocalDateTime ==> Date
*/ */
public static Date toDate (LocalDateTime temporalAccessor) { public static Date toDate(LocalDateTime temporalAccessor) {
ZonedDateTime zdt = temporalAccessor.atZone(ZoneId.systemDefault()); ZonedDateTime zdt = temporalAccessor.atZone(ZoneId.systemDefault());
return Date.from(zdt.toInstant()); return Date.from(zdt.toInstant());
} }
@ -157,7 +156,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
/** /**
* LocalDate ==> Date * LocalDate ==> Date
*/ */
public static Date toDate (LocalDate temporalAccessor) { public static Date toDate(LocalDate temporalAccessor) {
LocalDateTime localDateTime = LocalDateTime.of(temporalAccessor, LocalTime.of(0, 0, 0)); LocalDateTime localDateTime = LocalDateTime.of(temporalAccessor, LocalTime.of(0, 0, 0));
ZonedDateTime zdt = localDateTime.atZone(ZoneId.systemDefault()); ZonedDateTime zdt = localDateTime.atZone(ZoneId.systemDefault());
return Date.from(zdt.toInstant()); return Date.from(zdt.toInstant());

View File

@ -26,7 +26,7 @@ public class DictUtils {
* @param key * @param key
* @param dictDatas * @param dictDatas
*/ */
public static void setDictCache (String key, List<SysDictData> dictDatas) { public static void setDictCache(String key, List<SysDictData> dictDatas) {
SpringUtils.getBean(RedisCache.class).setCacheObject(getCacheKey(key), dictDatas); SpringUtils.getBean(RedisCache.class).setCacheObject(getCacheKey(key), dictDatas);
} }
@ -34,10 +34,9 @@ public class DictUtils {
* *
* *
* @param key * @param key
*
* @return dictDatas * @return dictDatas
*/ */
public static List<SysDictData> getDictCache (String key) { public static List<SysDictData> getDictCache(String key) {
JSONArray arrayCache = SpringUtils.getBean(RedisCache.class).getCacheObject(getCacheKey(key)); JSONArray arrayCache = SpringUtils.getBean(RedisCache.class).getCacheObject(getCacheKey(key));
if (StringUtils.isNotNull(arrayCache)) { if (StringUtils.isNotNull(arrayCache)) {
return arrayCache.toList(SysDictData.class); return arrayCache.toList(SysDictData.class);
@ -50,10 +49,9 @@ public class DictUtils {
* *
* @param dictType * @param dictType
* @param dictValue * @param dictValue
*
* @return * @return
*/ */
public static String getDictLabel (String dictType, String dictValue) { public static String getDictLabel(String dictType, String dictValue) {
return getDictLabel(dictType, dictValue, SEPARATOR); return getDictLabel(dictType, dictValue, SEPARATOR);
} }
@ -62,10 +60,9 @@ public class DictUtils {
* *
* @param dictType * @param dictType
* @param dictLabel * @param dictLabel
*
* @return * @return
*/ */
public static String getDictValue (String dictType, String dictLabel) { public static String getDictValue(String dictType, String dictLabel) {
return getDictValue(dictType, dictLabel, SEPARATOR); return getDictValue(dictType, dictLabel, SEPARATOR);
} }
@ -75,10 +72,9 @@ public class DictUtils {
* @param dictType * @param dictType
* @param dictValue * @param dictValue
* @param separator * @param separator
*
* @return * @return
*/ */
public static String getDictLabel (String dictType, String dictValue, String separator) { public static String getDictLabel(String dictType, String dictValue, String separator) {
StringBuilder propertyString = new StringBuilder(); StringBuilder propertyString = new StringBuilder();
List<SysDictData> datas = getDictCache(dictType); List<SysDictData> datas = getDictCache(dictType);
@ -109,10 +105,9 @@ public class DictUtils {
* @param dictType * @param dictType
* @param dictLabel * @param dictLabel
* @param separator * @param separator
*
* @return * @return
*/ */
public static String getDictValue (String dictType, String dictLabel, String separator) { public static String getDictValue(String dictType, String dictLabel, String separator) {
StringBuilder propertyString = new StringBuilder(); StringBuilder propertyString = new StringBuilder();
List<SysDictData> datas = getDictCache(dictType); List<SysDictData> datas = getDictCache(dictType);
@ -140,14 +135,14 @@ public class DictUtils {
* *
* @param key * @param key
*/ */
public static void removeDictCache (String key) { public static void removeDictCache(String key) {
SpringUtils.getBean(RedisCache.class).deleteObject(getCacheKey(key)); SpringUtils.getBean(RedisCache.class).deleteObject(getCacheKey(key));
} }
/** /**
* *
*/ */
public static void clearDictCache () { public static void clearDictCache() {
Collection<String> keys = SpringUtils.getBean(RedisCache.class).keys(CacheConstants.SYS_DICT_KEY + "*"); Collection<String> keys = SpringUtils.getBean(RedisCache.class).keys(CacheConstants.SYS_DICT_KEY + "*");
SpringUtils.getBean(RedisCache.class).deleteObject(keys); SpringUtils.getBean(RedisCache.class).deleteObject(keys);
} }
@ -156,10 +151,9 @@ public class DictUtils {
* cache key * cache key
* *
* @param configKey * @param configKey
*
* @return key * @return key
*/ */
public static String getCacheKey (String configKey) { public static String getCacheKey(String configKey) {
return CacheConstants.SYS_DICT_KEY + configKey; return CacheConstants.SYS_DICT_KEY + configKey;
} }
} }

View File

@ -14,13 +14,13 @@ public class ExceptionUtil {
/** /**
* exception * exception
*/ */
public static String getExceptionMessage (Throwable e) { public static String getExceptionMessage(Throwable e) {
StringWriter sw = new StringWriter(); StringWriter sw = new StringWriter();
e.printStackTrace(new PrintWriter(sw, true)); e.printStackTrace(new PrintWriter(sw, true));
return sw.toString(); return sw.toString();
} }
public static String getRootErrorMessage (Exception e) { public static String getRootErrorMessage(Exception e) {
Throwable root = ExceptionUtils.getRootCause(e); Throwable root = ExceptionUtils.getRootCause(e);
root = (root == null ? e : root); root = (root == null ? e : root);
if (root == null) { if (root == null) {

View File

@ -6,7 +6,7 @@ package com.ruoyi.common.utils;
* @author ruoyi * @author ruoyi
*/ */
public class LogUtils { public class LogUtils {
public static String getBlock (Object msg) { public static String getBlock(Object msg) {
if (msg == null) { if (msg == null) {
msg = ""; msg = "";
} }

View File

@ -15,10 +15,9 @@ public class MessageUtils {
* *
* @param code * @param code
* @param args * @param args
*
* @return * @return
*/ */
public static String message (String code, Object... args) { public static String message(String code, Object... args) {
MessageSource messageSource = SpringUtils.getBean(MessageSource.class); MessageSource messageSource = SpringUtils.getBean(MessageSource.class);
return messageSource.getMessage(code, args, LocaleContextHolder.getLocale()); return messageSource.getMessage(code, args, LocaleContextHolder.getLocale());
} }

View File

@ -17,49 +17,56 @@ public class ObjUtils {
* Array: * Array:
* Collection: * Collection:
* Map: * Map:
*
* @param o * @param o
* @return nulltruefalse * @return nulltruefalse
*/ */
public static boolean notNull(Object o){ public static boolean notNull(Object o) {
return ObjectUtils.isNotEmpty(o); return ObjectUtils.isNotEmpty(o);
} }
/** /**
* long0 * long0
*
* @param val * @param val
* @return 0 * @return 0
*/ */
public static boolean notNull(Long val){ public static boolean notNull(Long val) {
return ObjectUtils.isNotEmpty(val) && val != 0; return ObjectUtils.isNotEmpty(val) && val != 0;
} }
/** /**
* Integer0 * Integer0
*
* @param val * @param val
* @return 0 * @return 0
*/ */
public static boolean notNull(Integer val){ public static boolean notNull(Integer val) {
return ObjectUtils.isNotEmpty(val) && val != 0; return ObjectUtils.isNotEmpty(val) && val != 0;
} }
/** /**
* BigDecimal0 * BigDecimal0
*
* @param val * @param val
* @return 0 * @return 0
*/ */
public static boolean notNull(BigDecimal val){ public static boolean notNull(BigDecimal val) {
return ObjectUtils.isNotEmpty(val) && val.doubleValue() == 0.00; return ObjectUtils.isNotEmpty(val) && val.doubleValue() == 0.00;
} }
/** /**
* BigDecimal0 * BigDecimal0
*
* @param val * @param val
* @return 0 * @return 0
*/ */
public static boolean notChildNull(Object[] val){ public static boolean notChildNull(Object[] val) {
for (Object o : val) { for (Object o : val) {
if (!notNull(o)){ if (!notNull(o)) {
return false; return false;
} }
} }
return true; return true;
} }
} }

View File

@ -14,7 +14,7 @@ public class PageUtils extends PageHelper {
/** /**
* *
*/ */
public static void startPage () { public static void startPage() {
PageDomain pageDomain = TableSupport.buildPageRequest(); PageDomain pageDomain = TableSupport.buildPageRequest();
Integer pageNum = pageDomain.getPageNum(); Integer pageNum = pageDomain.getPageNum();
Integer pageSize = pageDomain.getPageSize(); Integer pageSize = pageDomain.getPageSize();
@ -26,7 +26,7 @@ public class PageUtils extends PageHelper {
/** /**
* 线 * 线
*/ */
public static void clearPage () { public static void clearPage() {
PageHelper.clearPage(); PageHelper.clearPage();
} }
} }

View File

@ -16,7 +16,7 @@ public class SecurityUtils {
/** /**
* ID * ID
**/ **/
public static Long getUserId () { public static Long getUserId() {
try { try {
return getLoginUser().getUserId(); return getLoginUser().getUserId();
} catch (Exception e) { } catch (Exception e) {
@ -27,7 +27,7 @@ public class SecurityUtils {
/** /**
* ID * ID
**/ **/
public static Long getDeptId () { public static Long getDeptId() {
try { try {
return getLoginUser().getDeptId(); return getLoginUser().getDeptId();
} catch (Exception e) { } catch (Exception e) {
@ -38,7 +38,7 @@ public class SecurityUtils {
/** /**
* *
**/ **/
public static String getUsername () { public static String getUsername() {
try { try {
return getLoginUser().getUsername(); return getLoginUser().getUsername();
} catch (Exception e) { } catch (Exception e) {
@ -49,7 +49,7 @@ public class SecurityUtils {
/** /**
* *
**/ **/
public static LoginUser getLoginUser () { public static LoginUser getLoginUser() {
try { try {
return (LoginUser) getAuthentication().getPrincipal(); return (LoginUser) getAuthentication().getPrincipal();
} catch (Exception e) { } catch (Exception e) {
@ -60,7 +60,7 @@ public class SecurityUtils {
/** /**
* Authentication * Authentication
*/ */
public static Authentication getAuthentication () { public static Authentication getAuthentication() {
return SecurityContextHolder.getContext().getAuthentication(); return SecurityContextHolder.getContext().getAuthentication();
} }
@ -68,10 +68,9 @@ public class SecurityUtils {
* BCryptPasswordEncoder * BCryptPasswordEncoder
* *
* @param password * @param password
*
* @return * @return
*/ */
public static String encryptPassword (String password) { public static String encryptPassword(String password) {
BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder(); BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
return passwordEncoder.encode(password); return passwordEncoder.encode(password);
} }
@ -81,10 +80,9 @@ public class SecurityUtils {
* *
* @param rawPassword * @param rawPassword
* @param encodedPassword * @param encodedPassword
*
* @return * @return
*/ */
public static boolean matchesPassword (String rawPassword, String encodedPassword) { public static boolean matchesPassword(String rawPassword, String encodedPassword) {
BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder(); BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
return passwordEncoder.matches(rawPassword, encodedPassword); return passwordEncoder.matches(rawPassword, encodedPassword);
} }
@ -93,10 +91,9 @@ public class SecurityUtils {
* *
* *
* @param userId ID * @param userId ID
*
* @return * @return
*/ */
public static boolean isAdmin (Long userId) { public static boolean isAdmin(Long userId) {
return userId != null && 1L == userId; return userId != null && 1L == userId;
} }
} }

View File

@ -27,42 +27,42 @@ public class ServletUtils {
/** /**
* String * String
*/ */
public static String getParameter (String name) { public static String getParameter(String name) {
return getRequest().getParameter(name); return getRequest().getParameter(name);
} }
/** /**
* String * String
*/ */
public static String getParameter (String name, String defaultValue) { public static String getParameter(String name, String defaultValue) {
return Convert.toStr(getRequest().getParameter(name), defaultValue); return Convert.toStr(getRequest().getParameter(name), defaultValue);
} }
/** /**
* Integer * Integer
*/ */
public static Integer getParameterToInt (String name) { public static Integer getParameterToInt(String name) {
return Convert.toInt(getRequest().getParameter(name)); return Convert.toInt(getRequest().getParameter(name));
} }
/** /**
* Integer * Integer
*/ */
public static Integer getParameterToInt (String name, Integer defaultValue) { public static Integer getParameterToInt(String name, Integer defaultValue) {
return Convert.toInt(getRequest().getParameter(name), defaultValue); return Convert.toInt(getRequest().getParameter(name), defaultValue);
} }
/** /**
* Boolean * Boolean
*/ */
public static Boolean getParameterToBool (String name) { public static Boolean getParameterToBool(String name) {
return Convert.toBool(getRequest().getParameter(name)); return Convert.toBool(getRequest().getParameter(name));
} }
/** /**
* Boolean * Boolean
*/ */
public static Boolean getParameterToBool (String name, Boolean defaultValue) { public static Boolean getParameterToBool(String name, Boolean defaultValue) {
return Convert.toBool(getRequest().getParameter(name), defaultValue); return Convert.toBool(getRequest().getParameter(name), defaultValue);
} }
@ -70,10 +70,9 @@ public class ServletUtils {
* *
* *
* @param request {@link ServletRequest} * @param request {@link ServletRequest}
*
* @return Map * @return Map
*/ */
public static Map<String, String[]> getParams (ServletRequest request) { public static Map<String, String[]> getParams(ServletRequest request) {
final Map<String, String[]> map = request.getParameterMap(); final Map<String, String[]> map = request.getParameterMap();
return Collections.unmodifiableMap(map); return Collections.unmodifiableMap(map);
} }
@ -82,10 +81,9 @@ public class ServletUtils {
* *
* *
* @param request {@link ServletRequest} * @param request {@link ServletRequest}
*
* @return Map * @return Map
*/ */
public static Map<String, String> getParamMap (ServletRequest request) { public static Map<String, String> getParamMap(ServletRequest request) {
Map<String, String> params = new HashMap<>(); Map<String, String> params = new HashMap<>();
for (Map.Entry<String, String[]> entry : getParams(request).entrySet()) { for (Map.Entry<String, String[]> entry : getParams(request).entrySet()) {
params.put(entry.getKey(), StringUtils.join(entry.getValue(), ",")); params.put(entry.getKey(), StringUtils.join(entry.getValue(), ","));
@ -96,25 +94,25 @@ public class ServletUtils {
/** /**
* request * request
*/ */
public static HttpServletRequest getRequest () { public static HttpServletRequest getRequest() {
return getRequestAttributes().getRequest(); return getRequestAttributes().getRequest();
} }
/** /**
* response * response
*/ */
public static HttpServletResponse getResponse () { public static HttpServletResponse getResponse() {
return getRequestAttributes().getResponse(); return getRequestAttributes().getResponse();
} }
/** /**
* session * session
*/ */
public static HttpSession getSession () { public static HttpSession getSession() {
return getRequest().getSession(); return getRequest().getSession();
} }
public static ServletRequestAttributes getRequestAttributes () { public static ServletRequestAttributes getRequestAttributes() {
RequestAttributes attributes = RequestContextHolder.getRequestAttributes(); RequestAttributes attributes = RequestContextHolder.getRequestAttributes();
return (ServletRequestAttributes) attributes; return (ServletRequestAttributes) attributes;
} }
@ -125,7 +123,7 @@ public class ServletUtils {
* @param response * @param response
* @param string * @param string
*/ */
public static void renderString (HttpServletResponse response, String string) { public static void renderString(HttpServletResponse response, String string) {
try { try {
response.setStatus(200); response.setStatus(200);
response.setContentType("application/json"); response.setContentType("application/json");
@ -141,7 +139,7 @@ public class ServletUtils {
* *
* @param request * @param request
*/ */
public static boolean isAjaxRequest (HttpServletRequest request) { public static boolean isAjaxRequest(HttpServletRequest request) {
String accept = request.getHeader("accept"); String accept = request.getHeader("accept");
if (accept != null && accept.contains("application/json")) { if (accept != null && accept.contains("application/json")) {
return true; return true;
@ -165,10 +163,9 @@ public class ServletUtils {
* *
* *
* @param str * @param str
*
* @return * @return
*/ */
public static String urlEncode (String str) { public static String urlEncode(String str) {
try { try {
return URLEncoder.encode(str, Constants.UTF8); return URLEncoder.encode(str, Constants.UTF8);
} catch (UnsupportedEncodingException e) { } catch (UnsupportedEncodingException e) {
@ -180,10 +177,9 @@ public class ServletUtils {
* *
* *
* @param str * @param str
*
* @return * @return
*/ */
public static String urlDecode (String str) { public static String urlDecode(String str) {
try { try {
return URLDecoder.decode(str, Constants.UTF8); return URLDecoder.decode(str, Constants.UTF8);
} catch (UnsupportedEncodingException e) { } catch (UnsupportedEncodingException e) {

View File

@ -26,10 +26,9 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
* *
* *
* @param value defaultValue value * @param value defaultValue value
*
* @return value * @return value
*/ */
public static <T> T nvl (T value, T defaultValue) { public static <T> T nvl(T value, T defaultValue) {
return value != null ? value : defaultValue; return value != null ? value : defaultValue;
} }
@ -37,10 +36,9 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
* * Collection ListSetQueue * * Collection ListSetQueue
* *
* @param coll Collection * @param coll Collection
*
* @return true false * @return true false
*/ */
public static boolean isEmpty (Collection<?> coll) { public static boolean isEmpty(Collection<?> coll) {
return isNull(coll) || coll.isEmpty(); return isNull(coll) || coll.isEmpty();
} }
@ -48,10 +46,9 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
* * CollectionListSetQueue * * CollectionListSetQueue
* *
* @param coll Collection * @param coll Collection
*
* @return true false * @return true false
*/ */
public static boolean isNotEmpty (Collection<?> coll) { public static boolean isNotEmpty(Collection<?> coll) {
return !isEmpty(coll); return !isEmpty(coll);
} }
@ -61,7 +58,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
* @param objects * @param objects
* * @return true false * * @return true false
*/ */
public static boolean isEmpty (Object[] objects) { public static boolean isEmpty(Object[] objects) {
return isNull(objects) || (objects.length == 0); return isNull(objects) || (objects.length == 0);
} }
@ -69,10 +66,9 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
* * * *
* *
* @param objects * @param objects
*
* @return true false * @return true false
*/ */
public static boolean isNotEmpty (Object[] objects) { public static boolean isNotEmpty(Object[] objects) {
return !isEmpty(objects); return !isEmpty(objects);
} }
@ -80,10 +76,9 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
* * Map * * Map
* *
* @param map Map * @param map Map
*
* @return true false * @return true false
*/ */
public static boolean isEmpty (Map<?, ?> map) { public static boolean isEmpty(Map<?, ?> map) {
return isNull(map) || map.isEmpty(); return isNull(map) || map.isEmpty();
} }
@ -91,10 +86,9 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
* * Map * * Map
* *
* @param map Map * @param map Map
*
* @return true false * @return true false
*/ */
public static boolean isNotEmpty (Map<?, ?> map) { public static boolean isNotEmpty(Map<?, ?> map) {
return !isEmpty(map); return !isEmpty(map);
} }
@ -102,10 +96,9 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
* * * *
* *
* @param str String * @param str String
*
* @return true false * @return true false
*/ */
public static boolean isEmpty (String str) { public static boolean isEmpty(String str) {
return isNull(str) || NULLSTR.equals(str.trim()); return isNull(str) || NULLSTR.equals(str.trim());
} }
@ -113,10 +106,9 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
* * * *
* *
* @param str String * @param str String
*
* @return true false * @return true false
*/ */
public static boolean isNotEmpty (String str) { public static boolean isNotEmpty(String str) {
return !isEmpty(str); return !isEmpty(str);
} }
@ -124,10 +116,9 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
* * * *
* *
* @param object Object * @param object Object
*
* @return true false * @return true false
*/ */
public static boolean isNull (Object object) { public static boolean isNull(Object object) {
return object == null; return object == null;
} }
@ -135,10 +126,9 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
* * * *
* *
* @param object Object * @param object Object
*
* @return true false * @return true false
*/ */
public static boolean isNotNull (Object object) { public static boolean isNotNull(Object object) {
return !isNull(object); return !isNull(object);
} }
@ -146,17 +136,16 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
* * Java * * Java
* *
* @param object * @param object
*
* @return true false * @return true false
*/ */
public static boolean isArray (Object object) { public static boolean isArray(Object object) {
return isNotNull(object) && object.getClass().isArray(); return isNotNull(object) && object.getClass().isArray();
} }
/** /**
* *
*/ */
public static String trim (String str) { public static String trim(String str) {
return (str == null ? "" : str.trim()); return (str == null ? "" : str.trim());
} }
@ -165,10 +154,9 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
* *
* @param str * @param str
* @param start * @param start
*
* @return * @return
*/ */
public static String substring (final String str, int start) { public static String substring(final String str, int start) {
if (str == null) { if (str == null) {
return NULLSTR; return NULLSTR;
} }
@ -193,10 +181,9 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
* @param str * @param str
* @param start * @param start
* @param end * @param end
*
* @return * @return
*/ */
public static String substring (final String str, int start, int end) { public static String substring(final String str, int start, int end) {
if (str == null) { if (str == null) {
return NULLSTR; return NULLSTR;
} }
@ -237,10 +224,9 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
* *
* @param template {} * @param template {}
* @param params * @param params
*
* @return * @return
*/ */
public static String format (String template, Object... params) { public static String format(String template, Object... params) {
if (isEmpty(params) || isEmpty(template)) { if (isEmpty(params) || isEmpty(template)) {
return template; return template;
} }
@ -251,10 +237,9 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
* http(s)://开头 * http(s)://开头
* *
* @param link * @param link
*
* @return * @return
*/ */
public static boolean ishttp (String link) { public static boolean ishttp(String link) {
return StringUtils.startsWithAny(link, Constants.HTTP, Constants.HTTPS); return StringUtils.startsWithAny(link, Constants.HTTP, Constants.HTTPS);
} }
@ -263,10 +248,9 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
* *
* @param str * @param str
* @param sep * @param sep
*
* @return set * @return set
*/ */
public static final Set<String> str2Set (String str, String sep) { public static final Set<String> str2Set(String str, String sep) {
return new HashSet<String>(str2List(str, sep, true, false)); return new HashSet<String>(str2List(str, sep, true, false));
} }
@ -277,10 +261,9 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
* @param sep * @param sep
* @param filterBlank * @param filterBlank
* @param trim * @param trim
*
* @return list * @return list
*/ */
public static final List<String> str2List (String str, String sep, boolean filterBlank, boolean trim) { public static final List<String> str2List(String str, String sep, boolean filterBlank, boolean trim) {
List<String> list = new ArrayList<String>(); List<String> list = new ArrayList<String>();
if (StringUtils.isEmpty(str)) { if (StringUtils.isEmpty(str)) {
return list; return list;
@ -309,10 +292,9 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
* *
* @param collection * @param collection
* @param array * @param array
*
* @return boolean * @return boolean
*/ */
public static boolean containsAny (Collection<String> collection, String... array) { public static boolean containsAny(Collection<String> collection, String... array) {
if (isEmpty(collection) || isEmpty(array)) { if (isEmpty(collection) || isEmpty(array)) {
return false; return false;
} else { } else {
@ -330,10 +312,9 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
* *
* @param cs * @param cs
* @param searchCharSequences * @param searchCharSequences
*
* @return * @return
*/ */
public static boolean containsAnyIgnoreCase (CharSequence cs, CharSequence... searchCharSequences) { public static boolean containsAnyIgnoreCase(CharSequence cs, CharSequence... searchCharSequences) {
if (isEmpty(cs) || isEmpty(searchCharSequences)) { if (isEmpty(cs) || isEmpty(searchCharSequences)) {
return false; return false;
} }
@ -348,7 +329,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
/** /**
* 线 * 线
*/ */
public static String toUnderScoreCase (String str) { public static String toUnderScoreCase(String str) {
if (str == null) { if (str == null) {
return null; return null;
} }
@ -359,7 +340,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
boolean curreCharIsUpperCase = true; boolean curreCharIsUpperCase = true;
// 下一字符是否大写 // 下一字符是否大写
boolean nexteCharIsUpperCase = true; boolean nexteCharIsUpperCase = true;
for (int i = 0 ; i < str.length() ; i++) { for (int i = 0; i < str.length(); i++) {
char c = str.charAt(i); char c = str.charAt(i);
if (i > 0) { if (i > 0) {
preCharIsUpperCase = Character.isUpperCase(str.charAt(i - 1)); preCharIsUpperCase = Character.isUpperCase(str.charAt(i - 1));
@ -389,10 +370,9 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
* *
* @param str * @param str
* @param strs * @param strs
*
* @return true * @return true
*/ */
public static boolean inStringIgnoreCase (String str, String... strs) { public static boolean inStringIgnoreCase(String str, String... strs) {
if (str != null && strs != null) { if (str != null && strs != null) {
for (String s : strs) { for (String s : strs) {
if (str.equalsIgnoreCase(trim(s))) { if (str.equalsIgnoreCase(trim(s))) {
@ -407,10 +387,9 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
* 线线 HELLO_WORLD->HelloWorld * 线线 HELLO_WORLD->HelloWorld
* *
* @param name 线 * @param name 线
*
* @return * @return
*/ */
public static String convertToCamelCase (String name) { public static String convertToCamelCase(String name) {
StringBuilder result = new StringBuilder(); StringBuilder result = new StringBuilder();
// 快速检查 // 快速检查
if (name == null || name.isEmpty()) { if (name == null || name.isEmpty()) {
@ -438,7 +417,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
* *
* user_name->userName * user_name->userName
*/ */
public static String toCamelCase (String s) { public static String toCamelCase(String s) {
if (s == null) { if (s == null) {
return null; return null;
} }
@ -448,7 +427,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
s = s.toLowerCase(); s = s.toLowerCase();
StringBuilder sb = new StringBuilder(s.length()); StringBuilder sb = new StringBuilder(s.length());
boolean upperCase = false; boolean upperCase = false;
for (int i = 0 ; i < s.length() ; i++) { for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i); char c = s.charAt(i);
if (c == SEPARATOR) { if (c == SEPARATOR) {
@ -468,10 +447,9 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
* *
* @param str * @param str
* @param strs * @param strs
*
* @return * @return
*/ */
public static boolean matches (String str, List<String> strs) { public static boolean matches(String str, List<String> strs) {
if (isEmpty(str) || isEmpty(strs)) { if (isEmpty(str) || isEmpty(strs)) {
return false; return false;
} }
@ -491,16 +469,15 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
* *
* @param pattern * @param pattern
* @param url url * @param url url
*
* @return * @return
*/ */
public static boolean isMatch (String pattern, String url) { public static boolean isMatch(String pattern, String url) {
AntPathMatcher matcher = new AntPathMatcher(); AntPathMatcher matcher = new AntPathMatcher();
return matcher.match(pattern, url); return matcher.match(pattern, url);
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public static <T> T cast (Object obj) { public static <T> T cast(Object obj) {
return (T) obj; return (T) obj;
} }
@ -509,10 +486,9 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
* *
* @param num * @param num
* @param size * @param size
*
* @return * @return
*/ */
public static final String padl (final Number num, final int size) { public static final String padl(final Number num, final int size) {
return padl(num.toString(), size, '0'); return padl(num.toString(), size, '0');
} }
@ -522,15 +498,14 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
* @param s * @param s
* @param size * @param size
* @param c * @param c
*
* @return * @return
*/ */
public static final String padl (final String s, final int size, final char c) { public static final String padl(final String s, final int size, final char c) {
final StringBuilder sb = new StringBuilder(size); final StringBuilder sb = new StringBuilder(size);
if (s != null) { if (s != null) {
final int len = s.length(); final int len = s.length();
if (s.length() <= size) { if (s.length() <= size) {
for (int i = size - len ; i > 0 ; i--) { for (int i = size - len; i > 0; i--) {
sb.append(c); sb.append(c);
} }
sb.append(s); sb.append(s);
@ -538,7 +513,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
return s.substring(len - size, len); return s.substring(len - size, len);
} }
} else { } else {
for (int i = size ; i > 0 ; i--) { for (int i = size; i > 0; i--) {
sb.append(c); sb.append(c);
} }
} }

View File

@ -16,7 +16,7 @@ public class Threads {
/** /**
* sleep, * sleep,
*/ */
public static void sleep (long milliseconds) { public static void sleep(long milliseconds) {
try { try {
Thread.sleep(milliseconds); Thread.sleep(milliseconds);
} catch (InterruptedException e) { } catch (InterruptedException e) {
@ -31,7 +31,7 @@ public class Threads {
* 退. * 退.
* shutdown线. * shutdown线.
*/ */
public static void shutdownAndAwaitTermination (ExecutorService pool) { public static void shutdownAndAwaitTermination(ExecutorService pool) {
if (pool != null && !pool.isShutdown()) { if (pool != null && !pool.isShutdown()) {
pool.shutdown(); pool.shutdown();
try { try {
@ -51,7 +51,7 @@ public class Threads {
/** /**
* 线 * 线
*/ */
public static void printException (Runnable r, Throwable t) { public static void printException(Runnable r, Throwable t) {
if (t == null && r instanceof Future<?>) { if (t == null && r instanceof Future<?>) {
try { try {
Future<?> future = (Future<?>) r; Future<?> future = (Future<?>) r;

View File

@ -33,7 +33,7 @@ public class BeanUtils extends org.springframework.beans.BeanUtils {
* @param dest * @param dest
* @param src * @param src
*/ */
public static void copyBeanProp (Object dest, Object src) { public static void copyBeanProp(Object dest, Object src) {
try { try {
copyProperties(src, dest); copyProperties(src, dest);
} catch (Exception e) { } catch (Exception e) {
@ -45,10 +45,9 @@ public class BeanUtils extends org.springframework.beans.BeanUtils {
* setter * setter
* *
* @param obj * @param obj
*
* @return setter * @return setter
*/ */
public static List<Method> getSetterMethods (Object obj) { public static List<Method> getSetterMethods(Object obj) {
// setter方法列表 // setter方法列表
List<Method> setterMethods = new ArrayList<Method>(); List<Method> setterMethods = new ArrayList<Method>();
@ -71,11 +70,10 @@ public class BeanUtils extends org.springframework.beans.BeanUtils {
* getter * getter
* *
* @param obj * @param obj
*
* @return getter * @return getter
*/ */
public static List<Method> getGetterMethods (Object obj) { public static List<Method> getGetterMethods(Object obj) {
// getter方法列表 // getter方法列表
List<Method> getterMethods = new ArrayList<Method>(); List<Method> getterMethods = new ArrayList<Method>();
// 获取所有方法 // 获取所有方法
@ -97,11 +95,10 @@ public class BeanUtils extends org.springframework.beans.BeanUtils {
* *
* @param m1 1 * @param m1 1
* @param m2 2 * @param m2 2
*
* @return truefalse * @return truefalse
*/ */
public static boolean isMethodPropEquals (String m1, String m2) { public static boolean isMethodPropEquals(String m1, String m2) {
return m1.substring(BEAN_METHOD_PROP_INDEX).equals(m2.substring(BEAN_METHOD_PROP_INDEX)); return m1.substring(BEAN_METHOD_PROP_INDEX).equals(m2.substring(BEAN_METHOD_PROP_INDEX));
} }
} }

View File

@ -11,7 +11,7 @@ import java.util.Set;
* @author ruoyi * @author ruoyi
*/ */
public class BeanValidators { public class BeanValidators {
public static void validateWithException (Validator validator, Object object, Class<?>... groups) public static void validateWithException(Validator validator, Object object, Class<?>... groups)
throws ConstraintViolationException { throws ConstraintViolationException {
Set<ConstraintViolation<Object>> constraintViolations = validator.validate(object, groups); Set<ConstraintViolation<Object>> constraintViolations = validator.validate(object, groups);
if (!constraintViolations.isEmpty()) { if (!constraintViolations.isEmpty()) {

View File

@ -16,10 +16,9 @@ public class FileTypeUtils {
* : ruoyi.txt, : txt * : ruoyi.txt, : txt
* *
* @param file * @param file
*
* @return ".") * @return ".")
*/ */
public static String getFileType (File file) { public static String getFileType(File file) {
if (null == file) { if (null == file) {
return StringUtils.EMPTY; return StringUtils.EMPTY;
} }
@ -32,10 +31,9 @@ public class FileTypeUtils {
* : ruoyi.txt, : txt * : ruoyi.txt, : txt
* *
* @param fileName * @param fileName
*
* @return ".") * @return ".")
*/ */
public static String getFileType (String fileName) { public static String getFileType(String fileName) {
int separatorIndex = fileName.lastIndexOf("."); int separatorIndex = fileName.lastIndexOf(".");
if (separatorIndex < 0) { if (separatorIndex < 0) {
return ""; return "";
@ -47,10 +45,9 @@ public class FileTypeUtils {
* *
* *
* @param photoByte * @param photoByte
*
* @return ".") * @return ".")
*/ */
public static String getFileExtendName (byte[] photoByte) { public static String getFileExtendName(byte[] photoByte) {
String strFileExtendName = "JPG"; String strFileExtendName = "JPG";
if ((photoByte[0] == 71) && (photoByte[1] == 73) && (photoByte[2] == 70) && (photoByte[3] == 56) if ((photoByte[0] == 71) && (photoByte[1] == 73) && (photoByte[2] == 70) && (photoByte[3] == 56)
&& ((photoByte[4] == 55) || (photoByte[4] == 57)) && (photoByte[5] == 97)) { && ((photoByte[4] == 55) || (photoByte[4] == 57)) && (photoByte[5] == 97)) {

View File

@ -37,11 +37,11 @@ public class FileUploadUtils {
*/ */
private static String defaultBaseDir = RuoYiConfig.getProfile(); private static String defaultBaseDir = RuoYiConfig.getProfile();
public static String getDefaultBaseDir () { public static String getDefaultBaseDir() {
return defaultBaseDir; return defaultBaseDir;
} }
public static void setDefaultBaseDir (String defaultBaseDir) { public static void setDefaultBaseDir(String defaultBaseDir) {
FileUploadUtils.defaultBaseDir = defaultBaseDir; FileUploadUtils.defaultBaseDir = defaultBaseDir;
} }
@ -49,12 +49,10 @@ public class FileUploadUtils {
* *
* *
* @param file * @param file
*
* @return * @return
*
* @throws Exception * @throws Exception
*/ */
public static final String upload (MultipartFile file) throws IOException { public static final String upload(MultipartFile file) throws IOException {
try { try {
return upload(getDefaultBaseDir(), file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION); return upload(getDefaultBaseDir(), file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION);
} catch (Exception e) { } catch (Exception e) {
@ -67,12 +65,10 @@ public class FileUploadUtils {
* *
* @param baseDir * @param baseDir
* @param file * @param file
*
* @return * @return
*
* @throws IOException * @throws IOException
*/ */
public static final String upload (String baseDir, MultipartFile file) throws IOException { public static final String upload(String baseDir, MultipartFile file) throws IOException {
try { try {
return upload(baseDir, file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION); return upload(baseDir, file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION);
} catch (Exception e) { } catch (Exception e) {
@ -86,15 +82,13 @@ public class FileUploadUtils {
* @param baseDir * @param baseDir
* @param file * @param file
* @param allowedExtension * @param allowedExtension
*
* @return * @return
*
* @throws FileSizeLimitExceededException * @throws FileSizeLimitExceededException
* @throws FileNameLengthLimitExceededException * @throws FileNameLengthLimitExceededException
* @throws IOException * @throws IOException
* @throws InvalidExtensionException * @throws InvalidExtensionException
*/ */
public static final String upload (String baseDir, MultipartFile file, String[] allowedExtension) public static final String upload(String baseDir, MultipartFile file, String[] allowedExtension)
throws FileSizeLimitExceededException, IOException, FileNameLengthLimitExceededException, throws FileSizeLimitExceededException, IOException, FileNameLengthLimitExceededException,
InvalidExtensionException { InvalidExtensionException {
int fileNamelength = Objects.requireNonNull(file.getOriginalFilename()).length(); int fileNamelength = Objects.requireNonNull(file.getOriginalFilename()).length();
@ -114,12 +108,12 @@ public class FileUploadUtils {
/** /**
* *
*/ */
public static final String extractFilename (MultipartFile file) { public static final String extractFilename(MultipartFile file) {
return StringUtils.format("{}/{}_{}.{}", DateUtils.datePath(), return StringUtils.format("{}/{}_{}.{}", DateUtils.datePath(),
FilenameUtils.getBaseName(file.getOriginalFilename()), Seq.getId(Seq.uploadSeqType), getExtension(file)); FilenameUtils.getBaseName(file.getOriginalFilename()), Seq.getId(Seq.uploadSeqType), getExtension(file));
} }
public static final File getAbsoluteFile (String uploadDir, String fileName) throws IOException { public static final File getAbsoluteFile(String uploadDir, String fileName) throws IOException {
File desc = new File(uploadDir + File.separator + fileName); File desc = new File(uploadDir + File.separator + fileName);
if (!desc.exists()) { if (!desc.exists()) {
@ -130,7 +124,7 @@ public class FileUploadUtils {
return desc; return desc;
} }
public static final String getPathFileName (String uploadDir, String fileName) throws IOException { public static final String getPathFileName(String uploadDir, String fileName) throws IOException {
int dirLastIndex = RuoYiConfig.getProfile().length() + 1; int dirLastIndex = RuoYiConfig.getProfile().length() + 1;
String currentDir = StringUtils.substring(uploadDir, dirLastIndex); String currentDir = StringUtils.substring(uploadDir, dirLastIndex);
return Constants.RESOURCE_PREFIX + "/" + currentDir + "/" + fileName; return Constants.RESOURCE_PREFIX + "/" + currentDir + "/" + fileName;
@ -140,13 +134,11 @@ public class FileUploadUtils {
* *
* *
* @param file * @param file
*
* @return * @return
*
* @throws FileSizeLimitExceededException * @throws FileSizeLimitExceededException
* @throws InvalidExtensionException * @throws InvalidExtensionException
*/ */
public static final void assertAllowed (MultipartFile file, String[] allowedExtension) public static final void assertAllowed(MultipartFile file, String[] allowedExtension)
throws FileSizeLimitExceededException, InvalidExtensionException { throws FileSizeLimitExceededException, InvalidExtensionException {
long size = file.getSize(); long size = file.getSize();
if (size > DEFAULT_MAX_SIZE) { if (size > DEFAULT_MAX_SIZE) {
@ -179,10 +171,9 @@ public class FileUploadUtils {
* *
* @param extension * @param extension
* @param allowedExtension * @param allowedExtension
*
* @return * @return
*/ */
public static final boolean isAllowedExtension (String extension, String[] allowedExtension) { public static final boolean isAllowedExtension(String extension, String[] allowedExtension) {
for (String str : allowedExtension) { for (String str : allowedExtension) {
if (str.equalsIgnoreCase(extension)) { if (str.equalsIgnoreCase(extension)) {
return true; return true;
@ -195,10 +186,9 @@ public class FileUploadUtils {
* *
* *
* @param file * @param file
*
* @return * @return
*/ */
public static final String getExtension (MultipartFile file) { public static final String getExtension(MultipartFile file) {
String extension = FilenameUtils.getExtension(file.getOriginalFilename()); String extension = FilenameUtils.getExtension(file.getOriginalFilename());
if (StringUtils.isEmpty(extension)) { if (StringUtils.isEmpty(extension)) {
extension = MimeTypeUtils.getExtension(Objects.requireNonNull(file.getContentType())); extension = MimeTypeUtils.getExtension(Objects.requireNonNull(file.getContentType()));

View File

@ -27,10 +27,9 @@ public class FileUtils {
* *
* @param filePath * @param filePath
* @param os * @param os
*
* @return * @return
*/ */
public static void writeBytes (String filePath, OutputStream os) throws IOException { public static void writeBytes(String filePath, OutputStream os) throws IOException {
FileInputStream fis = null; FileInputStream fis = null;
try { try {
File file = new File(filePath); File file = new File(filePath);
@ -55,12 +54,10 @@ public class FileUtils {
* *
* *
* @param data * @param data
*
* @return * @return
*
* @throws IOException IO * @throws IOException IO
*/ */
public static String writeImportBytes (byte[] data) throws IOException { public static String writeImportBytes(byte[] data) throws IOException {
return writeBytes(data, RuoYiConfig.getImportPath()); return writeBytes(data, RuoYiConfig.getImportPath());
} }
@ -69,12 +66,10 @@ public class FileUtils {
* *
* @param data * @param data
* @param uploadDir * @param uploadDir
*
* @return * @return
*
* @throws IOException IO * @throws IOException IO
*/ */
public static String writeBytes (byte[] data, String uploadDir) throws IOException { public static String writeBytes(byte[] data, String uploadDir) throws IOException {
FileOutputStream fos = null; FileOutputStream fos = null;
String pathName = ""; String pathName = "";
try { try {
@ -93,10 +88,9 @@ public class FileUtils {
* *
* *
* @param filePath * @param filePath
*
* @return * @return
*/ */
public static boolean deleteFile (String filePath) { public static boolean deleteFile(String filePath) {
boolean flag = false; boolean flag = false;
File file = new File(filePath); File file = new File(filePath);
// 路径为文件且不为空则进行删除 // 路径为文件且不为空则进行删除
@ -110,10 +104,9 @@ public class FileUtils {
* *
* *
* @param filename * @param filename
*
* @return true false * @return true false
*/ */
public static boolean isValidFilename (String filename) { public static boolean isValidFilename(String filename) {
return filename.matches(FILENAME_PATTERN); return filename.matches(FILENAME_PATTERN);
} }
@ -121,10 +114,9 @@ public class FileUtils {
* *
* *
* @param resource * @param resource
*
* @return true false * @return true false
*/ */
public static boolean checkAllowDownload (String resource) { public static boolean checkAllowDownload(String resource) {
// 禁止目录上跳级别 // 禁止目录上跳级别
if (StringUtils.contains(resource, "..")) { if (StringUtils.contains(resource, "..")) {
return false; return false;
@ -144,10 +136,9 @@ public class FileUtils {
* *
* @param request * @param request
* @param fileName * @param fileName
*
* @return * @return
*/ */
public static String setFileDownloadHeader (HttpServletRequest request, String fileName) throws UnsupportedEncodingException { public static String setFileDownloadHeader(HttpServletRequest request, String fileName) throws UnsupportedEncodingException {
final String agent = request.getHeader("USER-AGENT"); final String agent = request.getHeader("USER-AGENT");
String filename = fileName; String filename = fileName;
if (agent.contains("MSIE")) { if (agent.contains("MSIE")) {
@ -173,7 +164,7 @@ public class FileUtils {
* @param response * @param response
* @param realFileName * @param realFileName
*/ */
public static void setAttachmentResponseHeader (HttpServletResponse response, String realFileName) throws UnsupportedEncodingException { public static void setAttachmentResponseHeader(HttpServletResponse response, String realFileName) throws UnsupportedEncodingException {
String percentEncodedFileName = percentEncode(realFileName); String percentEncodedFileName = percentEncode(realFileName);
StringBuilder contentDispositionValue = new StringBuilder(); StringBuilder contentDispositionValue = new StringBuilder();
@ -193,10 +184,9 @@ public class FileUtils {
* *
* *
* @param s * @param s
*
* @return * @return
*/ */
public static String percentEncode (String s) throws UnsupportedEncodingException { public static String percentEncode(String s) throws UnsupportedEncodingException {
String encode = URLEncoder.encode(s, StandardCharsets.UTF_8.toString()); String encode = URLEncoder.encode(s, StandardCharsets.UTF_8.toString());
return encode.replaceAll("\\+", "%20"); return encode.replaceAll("\\+", "%20");
} }
@ -205,10 +195,9 @@ public class FileUtils {
* *
* *
* @param photoByte * @param photoByte
*
* @return * @return
*/ */
public static String getFileExtendName (byte[] photoByte) { public static String getFileExtendName(byte[] photoByte) {
String strFileExtendName = "jpg"; String strFileExtendName = "jpg";
if ((photoByte[0] == 71) && (photoByte[1] == 73) && (photoByte[2] == 70) && (photoByte[3] == 56) if ((photoByte[0] == 71) && (photoByte[1] == 73) && (photoByte[2] == 70) && (photoByte[3] == 56)
&& ((photoByte[4] == 55) || (photoByte[4] == 57)) && (photoByte[5] == 97)) { && ((photoByte[4] == 55) || (photoByte[4] == 57)) && (photoByte[5] == 97)) {
@ -227,10 +216,9 @@ public class FileUtils {
* /profile/upload/2022/04/16/ruoyi.png -- ruoyi.png * /profile/upload/2022/04/16/ruoyi.png -- ruoyi.png
* *
* @param fileName * @param fileName
*
* @return * @return
*/ */
public static String getName (String fileName) { public static String getName(String fileName) {
if (fileName == null) { if (fileName == null) {
return null; return null;
} }
@ -244,10 +232,9 @@ public class FileUtils {
* /profile/upload/2022/04/16/ruoyi.png -- ruoyi * /profile/upload/2022/04/16/ruoyi.png -- ruoyi
* *
* @param fileName * @param fileName
*
* @return * @return
*/ */
public static String getNameNotSuffix (String fileName) { public static String getNameNotSuffix(String fileName) {
if (fileName == null) { if (fileName == null) {
return null; return null;
} }

View File

@ -22,7 +22,7 @@ import java.util.Arrays;
public class ImageUtils { public class ImageUtils {
private static final Logger log = LoggerFactory.getLogger(ImageUtils.class); private static final Logger log = LoggerFactory.getLogger(ImageUtils.class);
public static byte[] getImage (String imagePath) { public static byte[] getImage(String imagePath) {
InputStream is = getFile(imagePath); InputStream is = getFile(imagePath);
try { try {
return IOUtils.toByteArray(is); return IOUtils.toByteArray(is);
@ -34,7 +34,7 @@ public class ImageUtils {
} }
} }
public static InputStream getFile (String imagePath) { public static InputStream getFile(String imagePath) {
try { try {
byte[] result = readFile(imagePath); byte[] result = readFile(imagePath);
result = Arrays.copyOf(result, result.length); result = Arrays.copyOf(result, result.length);
@ -49,10 +49,9 @@ public class ImageUtils {
* *
* *
* @param url * @param url
*
* @return * @return
*/ */
public static byte[] readFile (String url) { public static byte[] readFile(String url) {
InputStream in = null; InputStream in = null;
try { try {
if (url.startsWith("http")) { if (url.startsWith("http")) {

View File

@ -37,7 +37,7 @@ public class MimeTypeUtils {
// pdf // pdf
"pdf"}; "pdf"};
public static String getExtension (String prefix) { public static String getExtension(String prefix) {
switch (prefix) { switch (prefix) {
case IMAGE_PNG: case IMAGE_PNG:
return "png"; return "png";

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