班级表增删改查 全局格式化代码
parent
8f4cc5e9f3
commit
2cb1520b9e
36
README.md
36
README.md
|
@ -18,23 +18,29 @@
|
|||
* 权限认证使用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),保持同步更新。
|
||||
* 不分离版本,请移步[RuoYi](https://gitee.com/y_project/RuoYi),微服务版本,请移步[RuoYi-Cloud](https://gitee.com/y_project/RuoYi-Cloud)
|
||||
*
|
||||
提供了技术栈([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),保持同步更新。
|
||||
* 不分离版本,请移步[RuoYi](https://gitee.com/y_project/RuoYi)
|
||||
,微服务版本,请移步[RuoYi-Cloud](https://gitee.com/y_project/RuoYi-Cloud)
|
||||
* 阿里云折扣场:[点我进入](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. 用户管理:用户是系统操作者,该功能主要完成系统用户配置。
|
||||
2. 部门管理:配置系统组织机构(公司、部门、小组),树结构展现支持数据权限。
|
||||
3. 岗位管理:配置系统用户所属担任职务。
|
||||
4. 菜单管理:配置系统菜单,操作权限,按钮权限标识等。
|
||||
5. 角色管理:角色菜单权限分配、设置角色按机构进行数据范围权限划分。
|
||||
6. 字典管理:对系统中经常使用的一些较为固定的数据进行维护。
|
||||
7. 参数管理:对系统动态配置常用参数。
|
||||
8. 通知公告:系统通知公告信息发布维护。
|
||||
9. 操作日志:系统正常操作日志记录和查询;系统异常信息日志记录和查询。
|
||||
1. 用户管理:用户是系统操作者,该功能主要完成系统用户配置。
|
||||
2. 部门管理:配置系统组织机构(公司、部门、小组),树结构展现支持数据权限。
|
||||
3. 岗位管理:配置系统用户所属担任职务。
|
||||
4. 菜单管理:配置系统菜单,操作权限,按钮权限标识等。
|
||||
5. 角色管理:角色菜单权限分配、设置角色按机构进行数据范围权限划分。
|
||||
6. 字典管理:对系统中经常使用的一些较为固定的数据进行维护。
|
||||
7. 参数管理:对系统动态配置常用参数。
|
||||
8. 通知公告:系统通知公告信息发布维护。
|
||||
9. 操作日志:系统正常操作日志记录和查询;系统异常信息日志记录和查询。
|
||||
10. 登录日志:系统登录日志记录查询包含登录异常。
|
||||
11. 在线用户:当前系统中活跃用户状态监控。
|
||||
12. 定时任务:在线(添加、修改、删除)任务调度包含执行结果日志。
|
||||
|
@ -90,7 +96,7 @@
|
|||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
## 若依前后端分离交流群
|
||||
|
||||
QQ群: [](https://jq.qq.com/?_wv=1027&k=5bVB1og) [](https://jq.qq.com/?_wv=1027&k=5eiA4DH) [](https://jq.qq.com/?_wv=1027&k=5AxMKlC) [](https://jq.qq.com/?_wv=1027&k=51G72yr) [](https://jq.qq.com/?_wv=1027&k=VvjN2nvu) [](https://jq.qq.com/?_wv=1027&k=5vYAqA05) [](https://jq.qq.com/?_wv=1027&k=kOIINEb5) [](https://jq.qq.com/?_wv=1027&k=UKtX5jhs) [](https://jq.qq.com/?_wv=1027&k=EI9an8lJ) [](https://jq.qq.com/?_wv=1027&k=SWCtLnMz) [](https://jq.qq.com/?_wv=1027&k=96Dkdq0k) [](https://jq.qq.com/?_wv=1027&k=0fsNiYZt) [](https://jq.qq.com/?_wv=1027&k=7xw4xUG1) [](https://jq.qq.com/?_wv=1027&k=eCx8eyoJ) [](https://jq.qq.com/?_wv=1027&k=SpyH2875) [](https://jq.qq.com/?_wv=1027&k=tKEt51dz) [](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=0vBbSb0ztbBgVtn3kJS-Q4HUNYwip89G&authKey=8irq5PhutrZmWIvsUsklBxhj57l%2F1nOZqjzigkXZVoZE451GG4JHPOqW7AW6cf0T&noverify=0&group_code=143961921) 点击按钮入群。
|
||||
QQ群: [](https://jq.qq.com/?_wv=1027&k=5bVB1og) [](https://jq.qq.com/?_wv=1027&k=5eiA4DH) [](https://jq.qq.com/?_wv=1027&k=5AxMKlC) [](https://jq.qq.com/?_wv=1027&k=51G72yr) [](https://jq.qq.com/?_wv=1027&k=VvjN2nvu) [](https://jq.qq.com/?_wv=1027&k=5vYAqA05) [](https://jq.qq.com/?_wv=1027&k=kOIINEb5) [](https://jq.qq.com/?_wv=1027&k=UKtX5jhs) [](https://jq.qq.com/?_wv=1027&k=EI9an8lJ) [](https://jq.qq.com/?_wv=1027&k=SWCtLnMz) [](https://jq.qq.com/?_wv=1027&k=96Dkdq0k) [](https://jq.qq.com/?_wv=1027&k=0fsNiYZt) [](https://jq.qq.com/?_wv=1027&k=7xw4xUG1) [](https://jq.qq.com/?_wv=1027&k=eCx8eyoJ) [](https://jq.qq.com/?_wv=1027&k=SpyH2875) [](https://jq.qq.com/?_wv=1027&k=tKEt51dz) [](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=0vBbSb0ztbBgVtn3kJS-Q4HUNYwip89G&authKey=8irq5PhutrZmWIvsUsklBxhj57l%2F1nOZqjzigkXZVoZE451GG4JHPOqW7AW6cf0T&noverify=0&group_code=143961921)
|
||||
点击按钮入群。
|
||||
|
|
9
pom.xml
9
pom.xml
|
@ -2,7 +2,7 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>ruoyi</artifactId>
|
||||
|
@ -177,13 +177,18 @@
|
|||
<version>${ruoyi.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 自定义项目-->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>ruoyi-custom</artifactId>
|
||||
<version>${ruoyi.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<modules>
|
||||
<module>ruoyi-application</module>
|
||||
<module>ruoyi-basic</module>
|
||||
<module>ruoyi-custom</module>
|
||||
</modules>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
|
|
|
@ -11,8 +11,9 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
|||
* @author ruoyi
|
||||
*/
|
||||
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
|
||||
@MapperScan("com.ruoyi.*.mapper")
|
||||
public class RuoYiApplication {
|
||||
public static void main (String[] args) {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(RuoYiApplication.class, args);
|
||||
System.out.println("(♥◠‿◠)ノ゙ 若依启动成功 ლ(´ڡ`ლ)゙");
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import org.springframework.boot.web.servlet.support.SpringBootServletInitializer
|
|||
*/
|
||||
public class RuoYiServletInitializer extends SpringBootServletInitializer {
|
||||
@Override
|
||||
protected SpringApplicationBuilder configure (SpringApplicationBuilder application) {
|
||||
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
|
||||
return application.sources(RuoYiApplication.class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ public class CaptchaController {
|
|||
* 生成验证码
|
||||
*/
|
||||
@GetMapping("/captchaImage")
|
||||
public Result<CaptchaModel> getCode (HttpServletResponse response) throws IOException {
|
||||
public Result<CaptchaModel> getCode(HttpServletResponse response) throws IOException {
|
||||
Result<CaptchaModel> ajax = Result.success();
|
||||
boolean captchaEnabled = configService.selectCaptchaEnabled();
|
||||
CaptchaModel.CaptchaModelBuilder builder
|
||||
|
|
|
@ -43,7 +43,7 @@ public class CommonController {
|
|||
* @param delete 是否删除
|
||||
*/
|
||||
@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 {
|
||||
if (!FileUtils.checkAllowDownload(fileName)) {
|
||||
throw new Exception(StringUtils.format("文件名称({})非法,不允许下载。 ", fileName));
|
||||
|
@ -66,7 +66,7 @@ public class CommonController {
|
|||
* 通用上传请求(单个)
|
||||
*/
|
||||
@PostMapping("/upload")
|
||||
public Result<UploadFileModel> uploadFile (MultipartFile file) throws Exception {
|
||||
public Result<UploadFileModel> uploadFile(MultipartFile file) throws Exception {
|
||||
try {
|
||||
// 上传文件路径
|
||||
String filePath = RuoYiConfig.getUploadPath();
|
||||
|
@ -89,7 +89,7 @@ public class CommonController {
|
|||
* 通用上传请求(多个)
|
||||
*/
|
||||
@PostMapping("/uploads")
|
||||
public Result<List<UploadFileModel>> uploadFiles (List<MultipartFile> files) throws Exception {
|
||||
public Result<List<UploadFileModel>> uploadFiles(List<MultipartFile> files) throws Exception {
|
||||
try {
|
||||
// 上传文件路径
|
||||
String filePath = RuoYiConfig.getUploadPath();
|
||||
|
@ -116,7 +116,7 @@ public class CommonController {
|
|||
* 本地资源通用下载
|
||||
*/
|
||||
@GetMapping("/download/resource")
|
||||
public void resourceDownload (String resource, HttpServletRequest request, HttpServletResponse response)
|
||||
public void resourceDownload(String resource, HttpServletRequest request, HttpServletResponse response)
|
||||
throws Exception {
|
||||
try {
|
||||
if (!FileUtils.checkAllowDownload(resource)) {
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
|
@ -36,7 +36,7 @@ public class CacheController {
|
|||
|
||||
@PreAuthorize("@ss.hasPermi('monitor:cache:list')")
|
||||
@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 commandStats = (Properties) redisTemplate.execute((RedisCallback<Object>) connection -> connection.info("commandstats"));
|
||||
Object dbSize = redisTemplate.execute((RedisCallback<Object>) connection -> connection.dbSize());
|
||||
|
@ -59,20 +59,20 @@ public class CacheController {
|
|||
|
||||
@PreAuthorize("@ss.hasPermi('monitor:cache:list')")
|
||||
@GetMapping("/getNames")
|
||||
public Result<List<SysCache>> cache () {
|
||||
public Result<List<SysCache>> cache() {
|
||||
return Result.success(caches);
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('monitor:cache:list')")
|
||||
@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 + "*");
|
||||
return Result.success(cacheKeys);
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('monitor:cache:list')")
|
||||
@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);
|
||||
SysCache sysCache = new SysCache(cacheName, cacheKey, cacheValue);
|
||||
return Result.success(sysCache);
|
||||
|
@ -80,7 +80,7 @@ public class CacheController {
|
|||
|
||||
@PreAuthorize("@ss.hasPermi('monitor:cache:list')")
|
||||
@DeleteMapping("/clearCacheName/{cacheName}")
|
||||
public Result<String> clearCacheName (@PathVariable String cacheName) {
|
||||
public Result<String> clearCacheName(@PathVariable String cacheName) {
|
||||
Collection<String> cacheKeys = redisTemplate.keys(cacheName + "*");
|
||||
if (cacheKeys != null) {
|
||||
redisTemplate.delete(cacheKeys);
|
||||
|
@ -90,14 +90,14 @@ public class CacheController {
|
|||
|
||||
@PreAuthorize("@ss.hasPermi('monitor:cache:list')")
|
||||
@DeleteMapping("/clearCacheKey/{cacheKey}")
|
||||
public Result<String> clearCacheKey (@PathVariable String cacheKey) {
|
||||
public Result<String> clearCacheKey(@PathVariable String cacheKey) {
|
||||
redisTemplate.delete(cacheKey);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('monitor:cache:list')")
|
||||
@DeleteMapping("/clearCacheAll")
|
||||
public Result<String> clearCacheAll () {
|
||||
public Result<String> clearCacheAll() {
|
||||
Collection<String> cacheKeys = redisTemplate.keys("*");
|
||||
if (cacheKeys != null) {
|
||||
redisTemplate.delete(cacheKeys);
|
||||
|
|
|
@ -17,7 +17,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|||
public class ServerController {
|
||||
@PreAuthorize("@ss.hasPermi('monitor:server:list')")
|
||||
@GetMapping()
|
||||
public Result<Server> getInfo () throws Exception {
|
||||
public Result<Server> getInfo() throws Exception {
|
||||
Server server = new Server();
|
||||
server.copyTo();
|
||||
return Result.success(server);
|
||||
|
|
|
@ -32,7 +32,7 @@ public class SysLogininforController extends BaseController {
|
|||
|
||||
@PreAuthorize("@ss.hasPermi('monitor:logininfor:list')")
|
||||
@GetMapping("/list")
|
||||
public Result<TableDataInfo<SysLogininfor>> list (SysLogininfor logininfor) {
|
||||
public Result<TableDataInfo<SysLogininfor>> list(SysLogininfor logininfor) {
|
||||
startPage();
|
||||
List<SysLogininfor> list = logininforService.selectLogininforList(logininfor);
|
||||
return getDataTable(list);
|
||||
|
@ -41,7 +41,7 @@ public class SysLogininforController extends BaseController {
|
|||
@Log(title = "登录日志", businessType = BusinessType.EXPORT)
|
||||
@PreAuthorize("@ss.hasPermi('monitor:logininfor:export')")
|
||||
@PostMapping("/export")
|
||||
public void export (HttpServletResponse response, SysLogininfor logininfor) {
|
||||
public void export(HttpServletResponse response, SysLogininfor logininfor) {
|
||||
List<SysLogininfor> list = logininforService.selectLogininforList(logininfor);
|
||||
ExcelUtil<SysLogininfor> util = new ExcelUtil<SysLogininfor>(SysLogininfor.class);
|
||||
util.exportExcel(response, list, "登录日志");
|
||||
|
@ -50,14 +50,14 @@ public class SysLogininforController extends BaseController {
|
|||
@PreAuthorize("@ss.hasPermi('monitor:logininfor:remove')")
|
||||
@Log(title = "登录日志", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{infoIds}")
|
||||
public Result<String> remove (@PathVariable Long[] infoIds) {
|
||||
public Result<String> remove(@PathVariable Long[] infoIds) {
|
||||
return toAjax(logininforService.deleteLogininforByIds(infoIds));
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('monitor:logininfor:remove')")
|
||||
@Log(title = "登录日志", businessType = BusinessType.CLEAN)
|
||||
@DeleteMapping("/clean")
|
||||
public Result<String> clean () {
|
||||
public Result<String> clean() {
|
||||
logininforService.cleanLogininfor();
|
||||
return Result.success();
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ public class SysLogininforController extends BaseController {
|
|||
@PreAuthorize("@ss.hasPermi('monitor:logininfor:unlock')")
|
||||
@Log(title = "账户解锁", businessType = BusinessType.OTHER)
|
||||
@GetMapping("/unlock/{userName}")
|
||||
public Result<String> unlock (@PathVariable("userName") String userName) {
|
||||
public Result<String> unlock(@PathVariable("userName") String userName) {
|
||||
passwordService.clearLoginRecordCache(userName);
|
||||
return Result.success();
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ public class SysOperlogController extends BaseController {
|
|||
|
||||
@PreAuthorize("@ss.hasPermi('monitor:operlog:list')")
|
||||
@GetMapping("/list")
|
||||
public Result<TableDataInfo<SysOperLog>> list (SysOperLog operLog) {
|
||||
public Result<TableDataInfo<SysOperLog>> list(SysOperLog operLog) {
|
||||
startPage();
|
||||
List<SysOperLog> list = operLogService.selectOperLogList(operLog);
|
||||
return getDataTable(list);
|
||||
|
@ -37,7 +37,7 @@ public class SysOperlogController extends BaseController {
|
|||
@Log(title = "操作日志", businessType = BusinessType.EXPORT)
|
||||
@PreAuthorize("@ss.hasPermi('monitor:operlog:export')")
|
||||
@PostMapping("/export")
|
||||
public void export (HttpServletResponse response, SysOperLog operLog) {
|
||||
public void export(HttpServletResponse response, SysOperLog operLog) {
|
||||
List<SysOperLog> list = operLogService.selectOperLogList(operLog);
|
||||
ExcelUtil<SysOperLog> util = new ExcelUtil<SysOperLog>(SysOperLog.class);
|
||||
util.exportExcel(response, list, "操作日志");
|
||||
|
@ -46,14 +46,14 @@ public class SysOperlogController extends BaseController {
|
|||
@Log(title = "操作日志", businessType = BusinessType.DELETE)
|
||||
@PreAuthorize("@ss.hasPermi('monitor:operlog:remove')")
|
||||
@DeleteMapping("/{operIds}")
|
||||
public Result<String> remove (@PathVariable Long[] operIds) {
|
||||
public Result<String> remove(@PathVariable Long[] operIds) {
|
||||
return toAjax(operLogService.deleteOperLogByIds(operIds));
|
||||
}
|
||||
|
||||
@Log(title = "操作日志", businessType = BusinessType.CLEAN)
|
||||
@PreAuthorize("@ss.hasPermi('monitor:operlog:remove')")
|
||||
@DeleteMapping("/clean")
|
||||
public Result<String> clean () {
|
||||
public Result<String> clean() {
|
||||
operLogService.cleanOperLog();
|
||||
return Result.success();
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ public class SysUserOnlineController extends BaseController {
|
|||
|
||||
@PreAuthorize("@ss.hasPermi('monitor:online: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 + "*");
|
||||
List<SysUserOnline> userOnlineList = new ArrayList<SysUserOnline>();
|
||||
for (String key : keys) {
|
||||
|
@ -62,7 +62,7 @@ public class SysUserOnlineController extends BaseController {
|
|||
@PreAuthorize("@ss.hasPermi('monitor:online:forceLogout')")
|
||||
@Log(title = "在线用户", businessType = BusinessType.FORCE)
|
||||
@DeleteMapping("/{tokenId}")
|
||||
public Result<String> forceLogout (@PathVariable String tokenId) {
|
||||
public Result<String> forceLogout(@PathVariable String tokenId) {
|
||||
redisCache.deleteObject(CacheConstants.LOGIN_TOKEN_KEY + tokenId);
|
||||
return Result.success();
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ public class SysConfigController extends BaseController {
|
|||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:config:list')")
|
||||
@GetMapping("/list")
|
||||
public Result<TableDataInfo<SysConfig>> list (SysConfig config) {
|
||||
public Result<TableDataInfo<SysConfig>> list(SysConfig config) {
|
||||
startPage();
|
||||
List<SysConfig> list = configService.selectConfigList(config);
|
||||
return getDataTable(list);
|
||||
|
@ -41,7 +41,7 @@ public class SysConfigController extends BaseController {
|
|||
@Log(title = "参数管理", businessType = BusinessType.EXPORT)
|
||||
@PreAuthorize("@ss.hasPermi('system:config:export')")
|
||||
@PostMapping("/export")
|
||||
public void export (HttpServletResponse response, SysConfig config) {
|
||||
public void export(HttpServletResponse response, SysConfig config) {
|
||||
List<SysConfig> list = configService.selectConfigList(config);
|
||||
ExcelUtil<SysConfig> util = new ExcelUtil<SysConfig>(SysConfig.class);
|
||||
util.exportExcel(response, list, "参数数据");
|
||||
|
@ -52,7 +52,7 @@ public class SysConfigController extends BaseController {
|
|||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:config:query')")
|
||||
@GetMapping(value = "/{configId}")
|
||||
public Result<SysConfig> getInfo (@PathVariable Long configId) {
|
||||
public Result<SysConfig> getInfo(@PathVariable Long configId) {
|
||||
return Result.success(configService.selectConfigById(configId));
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ public class SysConfigController extends BaseController {
|
|||
* 根据参数键名查询参数值
|
||||
*/
|
||||
@GetMapping(value = "/configKey/{configKey}")
|
||||
public Result<String> getConfigKey (@PathVariable String configKey) {
|
||||
public Result<String> getConfigKey(@PathVariable String configKey) {
|
||||
return Result.success(configService.selectConfigByKey(configKey));
|
||||
}
|
||||
|
||||
|
@ -70,7 +70,7 @@ public class SysConfigController extends BaseController {
|
|||
@PreAuthorize("@ss.hasPermi('system:config:add')")
|
||||
@Log(title = "参数管理", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public Result<String> add (@Validated @RequestBody SysConfig config) {
|
||||
public Result<String> add(@Validated @RequestBody SysConfig config) {
|
||||
if (!configService.checkConfigKeyUnique(config)) {
|
||||
return error("新增参数'" + config.getConfigName() + "'失败,参数键名已存在");
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ public class SysConfigController extends BaseController {
|
|||
@PreAuthorize("@ss.hasPermi('system:config:edit')")
|
||||
@Log(title = "参数管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public Result<String> edit (@Validated @RequestBody SysConfig config) {
|
||||
public Result<String> edit(@Validated @RequestBody SysConfig config) {
|
||||
if (!configService.checkConfigKeyUnique(config)) {
|
||||
return error("修改参数'" + config.getConfigName() + "'失败,参数键名已存在");
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ public class SysConfigController extends BaseController {
|
|||
@PreAuthorize("@ss.hasPermi('system:config:remove')")
|
||||
@Log(title = "参数管理", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{configIds}")
|
||||
public Result<String> remove (@PathVariable Long[] configIds) {
|
||||
public Result<String> remove(@PathVariable Long[] configIds) {
|
||||
configService.deleteConfigByIds(configIds);
|
||||
return Result.success();
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ public class SysConfigController extends BaseController {
|
|||
@PreAuthorize("@ss.hasPermi('system:config:remove')")
|
||||
@Log(title = "参数管理", businessType = BusinessType.CLEAN)
|
||||
@DeleteMapping("/refreshCache")
|
||||
public Result<String> refreshCache () {
|
||||
public Result<String> refreshCache() {
|
||||
configService.resetConfigCache();
|
||||
return Result.success();
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ public class SysDeptController extends BaseController {
|
|||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:dept:list')")
|
||||
@GetMapping("/list")
|
||||
public Result<List<SysDept>> list (SysDept dept) {
|
||||
public Result<List<SysDept>> list(SysDept dept) {
|
||||
List<SysDept> depts = deptService.selectDeptList(dept);
|
||||
return Result.success(depts);
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ public class SysDeptController extends BaseController {
|
|||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:dept:list')")
|
||||
@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());
|
||||
depts.removeIf(d -> d.getDeptId().intValue() == deptId || ArrayUtils.contains(StringUtils.split(d.getAncestors(), ","), deptId + ""));
|
||||
return Result.success(depts);
|
||||
|
@ -53,7 +53,7 @@ public class SysDeptController extends BaseController {
|
|||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:dept:query')")
|
||||
@GetMapping(value = "/{deptId}")
|
||||
public Result<SysDept> getInfo (@PathVariable Long deptId) {
|
||||
public Result<SysDept> getInfo(@PathVariable Long deptId) {
|
||||
deptService.checkDeptDataScope(deptId);
|
||||
return Result.success(deptService.selectDeptById(deptId));
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ public class SysDeptController extends BaseController {
|
|||
@PreAuthorize("@ss.hasPermi('system:dept:add')")
|
||||
@Log(title = "部门管理", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public Result<String> add (@Validated @RequestBody SysDept dept) {
|
||||
public Result<String> add(@Validated @RequestBody SysDept dept) {
|
||||
if (!deptService.checkDeptNameUnique(dept)) {
|
||||
return error("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在");
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ public class SysDeptController extends BaseController {
|
|||
@PreAuthorize("@ss.hasPermi('system:dept:edit')")
|
||||
@Log(title = "部门管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public Result<String> edit (@Validated @RequestBody SysDept dept) {
|
||||
public Result<String> edit(@Validated @RequestBody SysDept dept) {
|
||||
Long deptId = dept.getDeptId();
|
||||
deptService.checkDeptDataScope(deptId);
|
||||
if (!deptService.checkDeptNameUnique(dept)) {
|
||||
|
@ -98,7 +98,7 @@ public class SysDeptController extends BaseController {
|
|||
@PreAuthorize("@ss.hasPermi('system:dept:remove')")
|
||||
@Log(title = "部门管理", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{deptId}")
|
||||
public Result<String> remove (@PathVariable Long deptId) {
|
||||
public Result<String> remove(@PathVariable Long deptId) {
|
||||
if (deptService.hasChildByDeptId(deptId)) {
|
||||
return warn("存在下级部门,不允许删除");
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ public class SysDictDataController extends BaseController {
|
|||
|
||||
@PreAuthorize("@ss.hasPermi('system:dict:list')")
|
||||
@GetMapping("/list")
|
||||
public Result<TableDataInfo<SysDictData>> list (SysDictData dictData) {
|
||||
public Result<TableDataInfo<SysDictData>> list(SysDictData dictData) {
|
||||
startPage();
|
||||
List<SysDictData> list = dictDataService.selectDictDataList(dictData);
|
||||
return getDataTable(list);
|
||||
|
@ -44,7 +44,7 @@ public class SysDictDataController extends BaseController {
|
|||
@Log(title = "字典数据", businessType = BusinessType.EXPORT)
|
||||
@PreAuthorize("@ss.hasPermi('system:dict:export')")
|
||||
@PostMapping("/export")
|
||||
public void export (HttpServletResponse response, SysDictData dictData) {
|
||||
public void export(HttpServletResponse response, SysDictData dictData) {
|
||||
List<SysDictData> list = dictDataService.selectDictDataList(dictData);
|
||||
ExcelUtil<SysDictData> util = new ExcelUtil<SysDictData>(SysDictData.class);
|
||||
util.exportExcel(response, list, "字典数据");
|
||||
|
@ -55,7 +55,7 @@ public class SysDictDataController extends BaseController {
|
|||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:dict:query')")
|
||||
@GetMapping(value = "/{dictCode}")
|
||||
public Result<SysDictData> getInfo (@PathVariable Long dictCode) {
|
||||
public Result<SysDictData> getInfo(@PathVariable Long dictCode) {
|
||||
return Result.success(dictDataService.selectDictDataById(dictCode));
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,7 @@ public class SysDictDataController extends BaseController {
|
|||
* 根据字典类型查询字典数据信息
|
||||
*/
|
||||
@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);
|
||||
if (StringUtils.isNull(data)) {
|
||||
data = new ArrayList<SysDictData>();
|
||||
|
@ -77,7 +77,7 @@ public class SysDictDataController extends BaseController {
|
|||
@PreAuthorize("@ss.hasPermi('system:dict:add')")
|
||||
@Log(title = "字典数据", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public Result<String> add (@Validated @RequestBody SysDictData dict) {
|
||||
public Result<String> add(@Validated @RequestBody SysDictData dict) {
|
||||
dict.setCreateBy(getUserId());
|
||||
return toAjax(dictDataService.insertDictData(dict));
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ public class SysDictDataController extends BaseController {
|
|||
@PreAuthorize("@ss.hasPermi('system:dict:edit')")
|
||||
@Log(title = "字典数据", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public Result<String> edit (@Validated @RequestBody SysDictData dict) {
|
||||
public Result<String> edit(@Validated @RequestBody SysDictData dict) {
|
||||
dict.setUpdateBy(getUserId());
|
||||
return toAjax(dictDataService.updateDictData(dict));
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ public class SysDictDataController extends BaseController {
|
|||
@PreAuthorize("@ss.hasPermi('system:dict:remove')")
|
||||
@Log(title = "字典类型", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{dictCodes}")
|
||||
public Result<String> remove (@PathVariable Long[] dictCodes) {
|
||||
public Result<String> remove(@PathVariable Long[] dictCodes) {
|
||||
dictDataService.deleteDictDataByIds(dictCodes);
|
||||
return Result.success();
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ public class SysDictTypeController extends BaseController {
|
|||
|
||||
@PreAuthorize("@ss.hasPermi('system:dict:list')")
|
||||
@GetMapping("/list")
|
||||
public Result<TableDataInfo<SysDictType>> list (SysDictType dictType) {
|
||||
public Result<TableDataInfo<SysDictType>> list(SysDictType dictType) {
|
||||
startPage();
|
||||
List<SysDictType> list = dictTypeService.selectDictTypeList(dictType);
|
||||
return getDataTable(list);
|
||||
|
@ -38,7 +38,7 @@ public class SysDictTypeController extends BaseController {
|
|||
@Log(title = "字典类型", businessType = BusinessType.EXPORT)
|
||||
@PreAuthorize("@ss.hasPermi('system:dict:export')")
|
||||
@PostMapping("/export")
|
||||
public void export (HttpServletResponse response, SysDictType dictType) {
|
||||
public void export(HttpServletResponse response, SysDictType dictType) {
|
||||
List<SysDictType> list = dictTypeService.selectDictTypeList(dictType);
|
||||
ExcelUtil<SysDictType> util = new ExcelUtil<SysDictType>(SysDictType.class);
|
||||
util.exportExcel(response, list, "字典类型");
|
||||
|
@ -49,7 +49,7 @@ public class SysDictTypeController extends BaseController {
|
|||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:dict:query')")
|
||||
@GetMapping(value = "/{dictId}")
|
||||
public Result<SysDictType> getInfo (@PathVariable Long dictId) {
|
||||
public Result<SysDictType> getInfo(@PathVariable Long dictId) {
|
||||
return Result.success(dictTypeService.selectDictTypeById(dictId));
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@ public class SysDictTypeController extends BaseController {
|
|||
@PreAuthorize("@ss.hasPermi('system:dict:add')")
|
||||
@Log(title = "字典类型", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public Result<String> add (@Validated @RequestBody SysDictType dict) {
|
||||
public Result<String> add(@Validated @RequestBody SysDictType dict) {
|
||||
if (!dictTypeService.checkDictTypeUnique(dict)) {
|
||||
return error("新增字典'" + dict.getDictName() + "'失败,字典类型已存在");
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ public class SysDictTypeController extends BaseController {
|
|||
@PreAuthorize("@ss.hasPermi('system:dict:edit')")
|
||||
@Log(title = "字典类型", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public Result<String> edit (@Validated @RequestBody SysDictType dict) {
|
||||
public Result<String> edit(@Validated @RequestBody SysDictType dict) {
|
||||
if (!dictTypeService.checkDictTypeUnique(dict)) {
|
||||
return error("修改字典'" + dict.getDictName() + "'失败,字典类型已存在");
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ public class SysDictTypeController extends BaseController {
|
|||
@PreAuthorize("@ss.hasPermi('system:dict:remove')")
|
||||
@Log(title = "字典类型", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{dictIds}")
|
||||
public Result<String> remove (@PathVariable Long[] dictIds) {
|
||||
public Result<String> remove(@PathVariable Long[] dictIds) {
|
||||
dictTypeService.deleteDictTypeByIds(dictIds);
|
||||
return Result.success();
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ public class SysDictTypeController extends BaseController {
|
|||
@PreAuthorize("@ss.hasPermi('system:dict:remove')")
|
||||
@Log(title = "字典类型", businessType = BusinessType.CLEAN)
|
||||
@DeleteMapping("/refreshCache")
|
||||
public Result<String> refreshCache () {
|
||||
public Result<String> refreshCache() {
|
||||
dictTypeService.resetDictCache();
|
||||
return Result.success();
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ public class SysDictTypeController extends BaseController {
|
|||
* 获取字典选择框列表
|
||||
*/
|
||||
@GetMapping("/optionselect")
|
||||
public Result<List<SysDictType>> optionselect () {
|
||||
public Result<List<SysDictType>> optionselect() {
|
||||
List<SysDictType> dictTypes = dictTypeService.selectDictTypeAll();
|
||||
return Result.success(dictTypes);
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ public class SysIndexController {
|
|||
* 访问首页,提示语
|
||||
*/
|
||||
@RequestMapping("/")
|
||||
public String index () {
|
||||
public String index() {
|
||||
return StringUtils.format("欢迎使用{}后台管理框架,当前版本:v{},请通过前端地址访问。", ruoyiConfig.getName(), ruoyiConfig.getVersion());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,11 +39,10 @@ public class SysLoginController {
|
|||
* 登录方法
|
||||
*
|
||||
* @param loginBody 登录信息
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
@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(),
|
||||
loginBody.getUuid());
|
||||
|
@ -56,7 +55,7 @@ public class SysLoginController {
|
|||
* @return 用户信息
|
||||
*/
|
||||
@GetMapping("getInfo")
|
||||
public Result<UserInfoResp> getInfo () {
|
||||
public Result<UserInfoResp> getInfo() {
|
||||
SysUser user = SecurityUtils.getLoginUser().getUser();
|
||||
// 角色集合
|
||||
Set<String> roles = permissionService.getRolePermission(user);
|
||||
|
@ -77,7 +76,7 @@ public class SysLoginController {
|
|||
* @return 路由信息
|
||||
*/
|
||||
@GetMapping("getRouters")
|
||||
public Result<List<RouterVo>> getRouters () {
|
||||
public Result<List<RouterVo>> getRouters() {
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
List<SysMenu> menus = menuService.selectMenuTreeByUserId(userId);
|
||||
return Result.success(menuService.buildMenus(menus));
|
||||
|
|
|
@ -33,7 +33,7 @@ public class SysMenuController extends BaseController {
|
|||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:menu:list')")
|
||||
@GetMapping("/list")
|
||||
public Result<List<SysMenu>> list (SysMenu menu) {
|
||||
public Result<List<SysMenu>> list(SysMenu menu) {
|
||||
List<SysMenu> menus = menuService.selectMenuList(menu, getUserId());
|
||||
return Result.success(menus);
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ public class SysMenuController extends BaseController {
|
|||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:menu:query')")
|
||||
@GetMapping(value = "/{menuId}")
|
||||
public Result<SysMenu> getInfo (@PathVariable Long menuId) {
|
||||
public Result<SysMenu> getInfo(@PathVariable Long menuId) {
|
||||
return Result.success(menuService.selectMenuById(menuId));
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ public class SysMenuController extends BaseController {
|
|||
* 获取菜单下拉树列表
|
||||
*/
|
||||
@GetMapping("/treeselect")
|
||||
public Result<List<TreeSelect>> treeselect (SysMenu menu) {
|
||||
public Result<List<TreeSelect>> treeselect(SysMenu menu) {
|
||||
List<SysMenu> menus = menuService.selectMenuList(menu, getUserId());
|
||||
return Result.success(menuService.buildMenuTreeSelect(menus));
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ public class SysMenuController extends BaseController {
|
|||
* 加载对应角色菜单列表树
|
||||
*/
|
||||
@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());
|
||||
return Result.success(
|
||||
RoleMenuTreeResp.builder()
|
||||
|
@ -76,7 +76,7 @@ public class SysMenuController extends BaseController {
|
|||
@PreAuthorize("@ss.hasPermi('system:menu:add')")
|
||||
@Log(title = "菜单管理", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public Result<String> add (@Validated @RequestBody SysMenu menu) {
|
||||
public Result<String> add(@Validated @RequestBody SysMenu menu) {
|
||||
if (!menuService.checkMenuNameUnique(menu)) {
|
||||
return error("新增菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
|
||||
} 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')")
|
||||
@Log(title = "菜单管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public Result<String> edit (@Validated @RequestBody SysMenu menu) {
|
||||
public Result<String> edit(@Validated @RequestBody SysMenu menu) {
|
||||
if (!menuService.checkMenuNameUnique(menu)) {
|
||||
return error("修改菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
|
||||
} 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')")
|
||||
@Log(title = "菜单管理", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{menuId}")
|
||||
public Result<String> remove (@PathVariable("menuId") Long menuId) {
|
||||
public Result<String> remove(@PathVariable("menuId") Long menuId) {
|
||||
if (menuService.hasChildByMenuId(menuId)) {
|
||||
return warn("存在子菜单,不允许删除");
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ public class SysNoticeController extends BaseController {
|
|||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:notice:list')")
|
||||
@GetMapping("/list")
|
||||
public Result<TableDataInfo<SysNotice>> list (SysNotice notice) {
|
||||
public Result<TableDataInfo<SysNotice>> list(SysNotice notice) {
|
||||
startPage();
|
||||
List<SysNotice> list = noticeService.selectNoticeList(notice);
|
||||
return getDataTable(list);
|
||||
|
@ -41,7 +41,7 @@ public class SysNoticeController extends BaseController {
|
|||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:notice:query')")
|
||||
@GetMapping(value = "/{noticeId}")
|
||||
public Result<SysNotice> getInfo (@PathVariable Long noticeId) {
|
||||
public Result<SysNotice> getInfo(@PathVariable Long noticeId) {
|
||||
return Result.success(noticeService.selectNoticeById(noticeId));
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ public class SysNoticeController extends BaseController {
|
|||
@PreAuthorize("@ss.hasPermi('system:notice:add')")
|
||||
@Log(title = "通知公告", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public Result<String> add (@Validated @RequestBody SysNotice notice) {
|
||||
public Result<String> add(@Validated @RequestBody SysNotice notice) {
|
||||
notice.setCreateBy(getUserId());
|
||||
return toAjax(noticeService.insertNotice(notice));
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ public class SysNoticeController extends BaseController {
|
|||
@PreAuthorize("@ss.hasPermi('system:notice:edit')")
|
||||
@Log(title = "通知公告", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public Result<String> edit (@Validated @RequestBody SysNotice notice) {
|
||||
public Result<String> edit(@Validated @RequestBody SysNotice notice) {
|
||||
notice.setUpdateBy(getUserId());
|
||||
return toAjax(noticeService.updateNotice(notice));
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ public class SysNoticeController extends BaseController {
|
|||
@PreAuthorize("@ss.hasPermi('system:notice:remove')")
|
||||
@Log(title = "通知公告", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{noticeIds}")
|
||||
public Result<String> remove (@PathVariable Long[] noticeIds) {
|
||||
public Result<String> remove(@PathVariable Long[] noticeIds) {
|
||||
return toAjax(noticeService.deleteNoticeByIds(noticeIds));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ public class SysPostController extends BaseController {
|
|||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:post:list')")
|
||||
@GetMapping("/list")
|
||||
public Result<TableDataInfo<SysPost>> list (SysPost post) {
|
||||
public Result<TableDataInfo<SysPost>> list(SysPost post) {
|
||||
startPage();
|
||||
List<SysPost> list = postService.selectPostList(post);
|
||||
return getDataTable(list);
|
||||
|
@ -41,7 +41,7 @@ public class SysPostController extends BaseController {
|
|||
@Log(title = "岗位管理", businessType = BusinessType.EXPORT)
|
||||
@PreAuthorize("@ss.hasPermi('system:post:export')")
|
||||
@PostMapping("/export")
|
||||
public void export (HttpServletResponse response, SysPost post) {
|
||||
public void export(HttpServletResponse response, SysPost post) {
|
||||
List<SysPost> list = postService.selectPostList(post);
|
||||
ExcelUtil<SysPost> util = new ExcelUtil<SysPost>(SysPost.class);
|
||||
util.exportExcel(response, list, "岗位数据");
|
||||
|
@ -52,7 +52,7 @@ public class SysPostController extends BaseController {
|
|||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:post:query')")
|
||||
@GetMapping(value = "/{postId}")
|
||||
public Result<SysPost> getInfo (@PathVariable Long postId) {
|
||||
public Result<SysPost> getInfo(@PathVariable Long postId) {
|
||||
return Result.success(postService.selectPostById(postId));
|
||||
}
|
||||
|
||||
|
@ -62,7 +62,7 @@ public class SysPostController extends BaseController {
|
|||
@PreAuthorize("@ss.hasPermi('system:post:add')")
|
||||
@Log(title = "岗位管理", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public Result<String> add (@Validated @RequestBody SysPost post) {
|
||||
public Result<String> add(@Validated @RequestBody SysPost post) {
|
||||
if (!postService.checkPostNameUnique(post)) {
|
||||
return error("新增岗位'" + post.getPostName() + "'失败,岗位名称已存在");
|
||||
} else if (!postService.checkPostCodeUnique(post)) {
|
||||
|
@ -78,7 +78,7 @@ public class SysPostController extends BaseController {
|
|||
@PreAuthorize("@ss.hasPermi('system:post:edit')")
|
||||
@Log(title = "岗位管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public Result<String> edit (@Validated @RequestBody SysPost post) {
|
||||
public Result<String> edit(@Validated @RequestBody SysPost post) {
|
||||
if (!postService.checkPostNameUnique(post)) {
|
||||
return error("修改岗位'" + post.getPostName() + "'失败,岗位名称已存在");
|
||||
} else if (!postService.checkPostCodeUnique(post)) {
|
||||
|
@ -94,7 +94,7 @@ public class SysPostController extends BaseController {
|
|||
@PreAuthorize("@ss.hasPermi('system:post:remove')")
|
||||
@Log(title = "岗位管理", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{postIds}")
|
||||
public Result<String> remove (@PathVariable Long[] postIds) {
|
||||
public Result<String> remove(@PathVariable Long[] postIds) {
|
||||
return toAjax(postService.deletePostByIds(postIds));
|
||||
}
|
||||
|
||||
|
@ -102,7 +102,7 @@ public class SysPostController extends BaseController {
|
|||
* 获取岗位选择框列表
|
||||
*/
|
||||
@GetMapping("/optionselect")
|
||||
public Result<List<SysPost>> optionselect () {
|
||||
public Result<List<SysPost>> optionselect() {
|
||||
List<SysPost> posts = postService.selectPostAll();
|
||||
return Result.success(posts);
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ public class SysProfileController extends BaseController {
|
|||
* 个人信息
|
||||
*/
|
||||
@GetMapping
|
||||
public Result<ProfileResp> profile () {
|
||||
public Result<ProfileResp> profile() {
|
||||
LoginUser loginUser = getLoginUser();
|
||||
SysUser user = loginUser.getUser();
|
||||
return Result.success(
|
||||
|
@ -53,7 +53,7 @@ public class SysProfileController extends BaseController {
|
|||
*/
|
||||
@Log(title = "个人信息", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public Result<String> updateProfile (@RequestBody SysUser user) {
|
||||
public Result<String> updateProfile(@RequestBody SysUser user) {
|
||||
LoginUser loginUser = getLoginUser();
|
||||
SysUser currentUser = loginUser.getUser();
|
||||
currentUser.setNickName(user.getNickName());
|
||||
|
@ -79,7 +79,7 @@ public class SysProfileController extends BaseController {
|
|||
*/
|
||||
@Log(title = "个人信息", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/updatePwd")
|
||||
public Result<String> updatePwd (String oldPassword, String newPassword) {
|
||||
public Result<String> updatePwd(String oldPassword, String newPassword) {
|
||||
LoginUser loginUser = getLoginUser();
|
||||
String userName = loginUser.getUsername();
|
||||
String password = loginUser.getPassword();
|
||||
|
@ -103,7 +103,7 @@ public class SysProfileController extends BaseController {
|
|||
*/
|
||||
@Log(title = "用户头像", businessType = BusinessType.UPDATE)
|
||||
@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()) {
|
||||
LoginUser loginUser = getLoginUser();
|
||||
String avatar = FileUploadUtils.upload(RuoYiConfig.getAvatarPath(), file, MimeTypeUtils.IMAGE_EXTENSION);
|
||||
|
|
|
@ -25,7 +25,7 @@ public class SysRegisterController extends BaseController {
|
|||
private SysConfigServic configService;
|
||||
|
||||
@PostMapping("/register")
|
||||
public Result<String> register (@RequestBody RegisterBody user) {
|
||||
public Result<String> register(@RequestBody RegisterBody user) {
|
||||
if (!("true".equals(configService.selectConfigByKey("sys.account.registerUser")))) {
|
||||
return error("当前系统没有开启注册功能!");
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ public class SysRoleController extends BaseController {
|
|||
|
||||
@PreAuthorize("@ss.hasPermi('system:role:list')")
|
||||
@GetMapping("/list")
|
||||
public Result<TableDataInfo<SysRole>> list (SysRole role) {
|
||||
public Result<TableDataInfo<SysRole>> list(SysRole role) {
|
||||
startPage();
|
||||
List<SysRole> list = roleService.selectRoleList(role);
|
||||
return getDataTable(list);
|
||||
|
@ -60,7 +60,7 @@ public class SysRoleController extends BaseController {
|
|||
@Log(title = "角色管理", businessType = BusinessType.EXPORT)
|
||||
@PreAuthorize("@ss.hasPermi('system:role:export')")
|
||||
@PostMapping("/export")
|
||||
public void export (HttpServletResponse response, SysRole role) {
|
||||
public void export(HttpServletResponse response, SysRole role) {
|
||||
List<SysRole> list = roleService.selectRoleList(role);
|
||||
ExcelUtil<SysRole> util = new ExcelUtil<SysRole>(SysRole.class);
|
||||
util.exportExcel(response, list, "角色数据");
|
||||
|
@ -71,7 +71,7 @@ public class SysRoleController extends BaseController {
|
|||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:role:query')")
|
||||
@GetMapping(value = "/{roleId}")
|
||||
public Result<SysRole> getInfo (@PathVariable Long roleId) {
|
||||
public Result<SysRole> getInfo(@PathVariable Long roleId) {
|
||||
roleService.checkRoleDataScope(roleId);
|
||||
return Result.success(roleService.selectRoleById(roleId));
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ public class SysRoleController extends BaseController {
|
|||
@PreAuthorize("@ss.hasPermi('system:role:add')")
|
||||
@Log(title = "角色管理", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public Result<String> add (@Validated @RequestBody SysRole role) {
|
||||
public Result<String> add(@Validated @RequestBody SysRole role) {
|
||||
if (!roleService.checkRoleNameUnique(role)) {
|
||||
return error("新增角色'" + role.getRoleName() + "'失败,角色名称已存在");
|
||||
} else if (!roleService.checkRoleKeyUnique(role)) {
|
||||
|
@ -99,7 +99,7 @@ public class SysRoleController extends BaseController {
|
|||
@PreAuthorize("@ss.hasPermi('system:role:edit')")
|
||||
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public Result<String> edit (@Validated @RequestBody SysRole role) {
|
||||
public Result<String> edit(@Validated @RequestBody SysRole role) {
|
||||
roleService.checkRoleAllowed(role);
|
||||
roleService.checkRoleDataScope(role.getRoleId());
|
||||
if (!roleService.checkRoleNameUnique(role)) {
|
||||
|
@ -128,7 +128,7 @@ public class SysRoleController extends BaseController {
|
|||
@PreAuthorize("@ss.hasPermi('system:role:edit')")
|
||||
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/dataScope")
|
||||
public Result<String> dataScope (@RequestBody SysRole role) {
|
||||
public Result<String> dataScope(@RequestBody SysRole role) {
|
||||
roleService.checkRoleAllowed(role);
|
||||
roleService.checkRoleDataScope(role.getRoleId());
|
||||
return toAjax(roleService.authDataScope(role));
|
||||
|
@ -140,7 +140,7 @@ public class SysRoleController extends BaseController {
|
|||
@PreAuthorize("@ss.hasPermi('system:role:edit')")
|
||||
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/changeStatus")
|
||||
public Result<String> changeStatus (@RequestBody SysRole role) {
|
||||
public Result<String> changeStatus(@RequestBody SysRole role) {
|
||||
roleService.checkRoleAllowed(role);
|
||||
roleService.checkRoleDataScope(role.getRoleId());
|
||||
role.setUpdateBy(getUserId());
|
||||
|
@ -153,7 +153,7 @@ public class SysRoleController extends BaseController {
|
|||
@PreAuthorize("@ss.hasPermi('system:role:remove')")
|
||||
@Log(title = "角色管理", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{roleIds}")
|
||||
public Result<String> remove (@PathVariable Long[] roleIds) {
|
||||
public Result<String> remove(@PathVariable Long[] roleIds) {
|
||||
return toAjax(roleService.deleteRoleByIds(roleIds));
|
||||
}
|
||||
|
||||
|
@ -162,7 +162,7 @@ public class SysRoleController extends BaseController {
|
|||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:role:query')")
|
||||
@GetMapping("/optionselect")
|
||||
public Result<List<SysRole>> optionselect () {
|
||||
public Result<List<SysRole>> optionselect() {
|
||||
return Result.success(roleService.selectRoleAll());
|
||||
}
|
||||
|
||||
|
@ -171,7 +171,7 @@ public class SysRoleController extends BaseController {
|
|||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:role:list')")
|
||||
@GetMapping("/authUser/allocatedList")
|
||||
public Result<TableDataInfo<SysUser>> allocatedList (SysUser user) {
|
||||
public Result<TableDataInfo<SysUser>> allocatedList(SysUser user) {
|
||||
startPage();
|
||||
List<SysUser> list = userService.selectAllocatedList(user);
|
||||
return getDataTable(list);
|
||||
|
@ -182,7 +182,7 @@ public class SysRoleController extends BaseController {
|
|||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:role:list')")
|
||||
@GetMapping("/authUser/unallocatedList")
|
||||
public Result<TableDataInfo<SysUser>> unallocatedList (SysUser user) {
|
||||
public Result<TableDataInfo<SysUser>> unallocatedList(SysUser user) {
|
||||
startPage();
|
||||
List<SysUser> list = userService.selectUnallocatedList(user);
|
||||
return getDataTable(list);
|
||||
|
@ -194,7 +194,7 @@ public class SysRoleController extends BaseController {
|
|||
@PreAuthorize("@ss.hasPermi('system:role:edit')")
|
||||
@Log(title = "角色管理", businessType = BusinessType.GRANT)
|
||||
@PutMapping("/authUser/cancel")
|
||||
public Result<String> cancelAuthUser (@RequestBody SysUserRole userRole) {
|
||||
public Result<String> cancelAuthUser(@RequestBody SysUserRole userRole) {
|
||||
return toAjax(roleService.deleteAuthUser(userRole));
|
||||
}
|
||||
|
||||
|
@ -204,7 +204,7 @@ public class SysRoleController extends BaseController {
|
|||
@PreAuthorize("@ss.hasPermi('system:role:edit')")
|
||||
@Log(title = "角色管理", businessType = BusinessType.GRANT)
|
||||
@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));
|
||||
}
|
||||
|
||||
|
@ -214,7 +214,7 @@ public class SysRoleController extends BaseController {
|
|||
@PreAuthorize("@ss.hasPermi('system:role:edit')")
|
||||
@Log(title = "角色管理", businessType = BusinessType.GRANT)
|
||||
@PutMapping("/authUser/selectAll")
|
||||
public Result<String> selectAuthUserAll (Long roleId, Long[] userIds) {
|
||||
public Result<String> selectAuthUserAll(Long roleId, Long[] userIds) {
|
||||
roleService.checkRoleDataScope(roleId);
|
||||
return toAjax(roleService.insertAuthUsers(roleId, userIds));
|
||||
}
|
||||
|
@ -224,7 +224,7 @@ public class SysRoleController extends BaseController {
|
|||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:role:query')")
|
||||
@GetMapping(value = "/deptTree/{roleId}")
|
||||
public Result<DeptTreeResp> deptTree (@PathVariable("roleId") Long roleId) {
|
||||
public Result<DeptTreeResp> deptTree(@PathVariable("roleId") Long roleId) {
|
||||
return Result.success(
|
||||
DeptTreeResp.builder()
|
||||
.checkedKeys(deptService.selectDeptListByRoleId(roleId))
|
||||
|
|
|
@ -55,7 +55,7 @@ public class SysUserController extends BaseController {
|
|||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:user:list')")
|
||||
@GetMapping("/list")
|
||||
public Result<TableDataInfo<SysUser>> list (SysUser user) {
|
||||
public Result<TableDataInfo<SysUser>> list(SysUser user) {
|
||||
startPage();
|
||||
List<SysUser> list = userService.selectUserList(user);
|
||||
return getDataTable(list);
|
||||
|
@ -64,7 +64,7 @@ public class SysUserController extends BaseController {
|
|||
@Log(title = "用户管理", businessType = BusinessType.EXPORT)
|
||||
@PreAuthorize("@ss.hasPermi('system:user:export')")
|
||||
@PostMapping("/export")
|
||||
public void export (HttpServletResponse response, SysUser user) {
|
||||
public void export(HttpServletResponse response, SysUser user) {
|
||||
List<SysUser> list = userService.selectUserList(user);
|
||||
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
|
||||
util.exportExcel(response, list, "用户数据");
|
||||
|
@ -73,7 +73,7 @@ public class SysUserController extends BaseController {
|
|||
@Log(title = "用户管理", businessType = BusinessType.IMPORT)
|
||||
@PreAuthorize("@ss.hasPermi('system:user:import')")
|
||||
@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);
|
||||
List<SysUser> userList = util.importExcel(file.getInputStream());
|
||||
Long userId = getUserId();
|
||||
|
@ -82,7 +82,7 @@ public class SysUserController extends BaseController {
|
|||
}
|
||||
|
||||
@PostMapping("/importTemplate")
|
||||
public void importTemplate (HttpServletResponse response) {
|
||||
public void importTemplate(HttpServletResponse response) {
|
||||
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
|
||||
util.importTemplateExcel(response, "用户数据");
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ public class SysUserController extends BaseController {
|
|||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:user:query')")
|
||||
@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);
|
||||
List<SysRole> roles = roleService.selectRoleAll();
|
||||
UserDetailInfoRespBuilder builder = UserDetailInfoResp.builder()
|
||||
|
@ -115,7 +115,7 @@ public class SysUserController extends BaseController {
|
|||
@PreAuthorize("@ss.hasPermi('system:user:add')")
|
||||
@Log(title = "用户管理", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public Result<String> add (@Validated @RequestBody SysUser user) {
|
||||
public Result<String> add(@Validated @RequestBody SysUser user) {
|
||||
if (!userService.checkUserNameUnique(user)) {
|
||||
return error("新增用户'" + user.getUserName() + "'失败,登录账号已存在");
|
||||
} else if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user)) {
|
||||
|
@ -134,7 +134,7 @@ public class SysUserController extends BaseController {
|
|||
@PreAuthorize("@ss.hasPermi('system:user:edit')")
|
||||
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public Result<String> edit (@Validated @RequestBody SysUser user) {
|
||||
public Result<String> edit(@Validated @RequestBody SysUser user) {
|
||||
userService.checkUserAllowed(user);
|
||||
userService.checkUserDataScope(user.getUserId());
|
||||
if (!userService.checkUserNameUnique(user)) {
|
||||
|
@ -154,7 +154,7 @@ public class SysUserController extends BaseController {
|
|||
@PreAuthorize("@ss.hasPermi('system:user:remove')")
|
||||
@Log(title = "用户管理", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{userIds}")
|
||||
public Result<String> remove (@PathVariable Long[] userIds) {
|
||||
public Result<String> remove(@PathVariable Long[] userIds) {
|
||||
if (ArrayUtils.contains(userIds, getUserId())) {
|
||||
return error("当前用户不能删除");
|
||||
}
|
||||
|
@ -167,7 +167,7 @@ public class SysUserController extends BaseController {
|
|||
@PreAuthorize("@ss.hasPermi('system:user:resetPwd')")
|
||||
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/resetPwd")
|
||||
public Result<String> resetPwd (@RequestBody SysUser user) {
|
||||
public Result<String> resetPwd(@RequestBody SysUser user) {
|
||||
userService.checkUserAllowed(user);
|
||||
userService.checkUserDataScope(user.getUserId());
|
||||
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
|
||||
|
@ -181,7 +181,7 @@ public class SysUserController extends BaseController {
|
|||
@PreAuthorize("@ss.hasPermi('system:user:edit')")
|
||||
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/changeStatus")
|
||||
public Result<String> changeStatus (@RequestBody SysUser user) {
|
||||
public Result<String> changeStatus(@RequestBody SysUser user) {
|
||||
userService.checkUserAllowed(user);
|
||||
userService.checkUserDataScope(user.getUserId());
|
||||
user.setUpdateBy(getUserId());
|
||||
|
@ -193,7 +193,7 @@ public class SysUserController extends BaseController {
|
|||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:user:query')")
|
||||
@GetMapping("/authRole/{userId}")
|
||||
public Result<AuthRoleResp> authRole (@PathVariable("userId") Long userId) {
|
||||
public Result<AuthRoleResp> authRole(@PathVariable("userId") Long userId) {
|
||||
SysUser user = userService.selectUserById(userId);
|
||||
List<SysRole> roles = roleService.selectRolesByUserId(userId);
|
||||
return Result.success(
|
||||
|
@ -210,7 +210,7 @@ public class SysUserController extends BaseController {
|
|||
@PreAuthorize("@ss.hasPermi('system:user:edit')")
|
||||
@Log(title = "用户管理", businessType = BusinessType.GRANT)
|
||||
@PutMapping("/authRole")
|
||||
public Result<String> insertAuthRole (Long userId, Long[] roleIds) {
|
||||
public Result<String> insertAuthRole(Long userId, Long[] roleIds) {
|
||||
userService.checkUserDataScope(userId);
|
||||
userService.insertUserAuth(userId, roleIds);
|
||||
return Result.success();
|
||||
|
@ -221,7 +221,7 @@ public class SysUserController extends BaseController {
|
|||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:user:list')")
|
||||
@GetMapping("/deptTree")
|
||||
public Result<List<TreeSelect>> deptTree (SysDept dept) {
|
||||
public Result<List<TreeSelect>> deptTree(SysDept dept) {
|
||||
return Result.success(deptService.selectDeptTreeList(dept));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ public class TestController extends BaseController {
|
|||
|
||||
@ApiOperation("获取用户列表")
|
||||
@GetMapping("/list")
|
||||
public Result<List<UserEntity>> userList () {
|
||||
public Result<List<UserEntity>> userList() {
|
||||
List<UserEntity> userList = new ArrayList<UserEntity>(users.values());
|
||||
return Result.success(userList);
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ public class TestController extends BaseController {
|
|||
@ApiOperation("获取用户详细")
|
||||
@ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path", dataTypeClass = Integer.class)
|
||||
@GetMapping("/{userId}")
|
||||
public Result<UserEntity> getUser (@PathVariable Integer userId) {
|
||||
public Result<UserEntity> getUser(@PathVariable Integer userId) {
|
||||
if (!users.isEmpty() && users.containsKey(userId)) {
|
||||
return Result.success(users.get(userId));
|
||||
} else {
|
||||
|
@ -53,7 +53,7 @@ public class TestController extends BaseController {
|
|||
@ApiImplicitParam(name = "mobile", value = "用户手机", dataType = "String", dataTypeClass = String.class)
|
||||
})
|
||||
@PostMapping("/save")
|
||||
public Result<String> save (UserEntity user) {
|
||||
public Result<String> save(UserEntity user) {
|
||||
if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId())) {
|
||||
return Result.error("用户ID不能为空");
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ public class TestController extends BaseController {
|
|||
|
||||
@ApiOperation("更新用户")
|
||||
@PutMapping("/update")
|
||||
public Result<String> update (@RequestBody UserEntity user) {
|
||||
public Result<String> update(@RequestBody UserEntity user) {
|
||||
if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId())) {
|
||||
return Result.error("用户ID不能为空");
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ public class TestController extends BaseController {
|
|||
@ApiOperation("删除用户信息")
|
||||
@ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path", dataTypeClass = Integer.class)
|
||||
@DeleteMapping("/{userId}")
|
||||
public Result<String> delete (@PathVariable Integer userId) {
|
||||
public Result<String> delete(@PathVariable Integer userId) {
|
||||
if (!users.isEmpty() && users.containsKey(userId)) {
|
||||
users.remove(userId);
|
||||
return Result.success();
|
||||
|
@ -102,46 +102,46 @@ class UserEntity {
|
|||
@ApiModelProperty("用户手机")
|
||||
private String mobile;
|
||||
|
||||
public UserEntity () {
|
||||
public UserEntity() {
|
||||
|
||||
}
|
||||
|
||||
public UserEntity (Integer userId, String username, String password, String mobile) {
|
||||
public UserEntity(Integer userId, String username, String password, String mobile) {
|
||||
this.userId = userId;
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
this.mobile = mobile;
|
||||
}
|
||||
|
||||
public Integer getUserId () {
|
||||
public Integer getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId (Integer userId) {
|
||||
public void setUserId(Integer userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public String getUsername () {
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername (String username) {
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getPassword () {
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword (String password) {
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getMobile () {
|
||||
public String getMobile() {
|
||||
return mobile;
|
||||
}
|
||||
|
||||
public void setMobile (String mobile) {
|
||||
public void setMobile(String mobile) {
|
||||
this.mobile = mobile;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ public class SwaggerConfig {
|
|||
* 创建API
|
||||
*/
|
||||
@Bean
|
||||
public Docket createRestApi () {
|
||||
public Docket createRestApi() {
|
||||
return new Docket(DocumentationType.OAS_30)
|
||||
// 是否启用Swagger
|
||||
.enable(enabled)
|
||||
|
@ -71,7 +71,7 @@ public class SwaggerConfig {
|
|||
/**
|
||||
* 安全模式,这里指定token通过Authorization头请求头传递
|
||||
*/
|
||||
private List<SecurityScheme> securitySchemes () {
|
||||
private List<SecurityScheme> securitySchemes() {
|
||||
List<SecurityScheme> apiKeyList = new ArrayList<SecurityScheme>();
|
||||
apiKeyList.add(new ApiKey("Authorization", "Authorization", In.HEADER.toValue()));
|
||||
return apiKeyList;
|
||||
|
@ -80,7 +80,7 @@ public class SwaggerConfig {
|
|||
/**
|
||||
* 安全上下文
|
||||
*/
|
||||
private List<SecurityContext> securityContexts () {
|
||||
private List<SecurityContext> securityContexts() {
|
||||
List<SecurityContext> securityContexts = new ArrayList<>();
|
||||
securityContexts.add(
|
||||
SecurityContext.builder()
|
||||
|
@ -93,7 +93,7 @@ public class SwaggerConfig {
|
|||
/**
|
||||
* 默认的安全上引用
|
||||
*/
|
||||
private List<SecurityReference> defaultAuth () {
|
||||
private List<SecurityReference> defaultAuth() {
|
||||
AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything");
|
||||
AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
|
||||
authorizationScopes[0] = authorizationScope;
|
||||
|
@ -105,7 +105,7 @@ public class SwaggerConfig {
|
|||
/**
|
||||
* 添加摘要信息
|
||||
*/
|
||||
private ApiInfo apiInfo () {
|
||||
private ApiInfo apiInfo() {
|
||||
// 用ApiInfoBuilder进行定制
|
||||
return new ApiInfoBuilder()
|
||||
// 设置标题
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
<module>ruoyi-framework</module>
|
||||
<module>ruoyi-system</module>
|
||||
<module>ruoyi-common</module>
|
||||
<module>ruoyi-custom</module>
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
|
|
|
@ -14,15 +14,15 @@ public @interface DataScope {
|
|||
/**
|
||||
* 部门表的别名
|
||||
*/
|
||||
public String deptAlias () default "";
|
||||
public String deptAlias() default "";
|
||||
|
||||
/**
|
||||
* 用户表的别名
|
||||
*/
|
||||
public String userAlias () default "";
|
||||
public String userAlias() default "";
|
||||
|
||||
/**
|
||||
* 权限字符(用于多个角色匹配符合要求的权限)默认根据权限注解@ss获取,多个权限用逗号分隔开来
|
||||
*/
|
||||
public String permission () default "";
|
||||
public String permission() default "";
|
||||
}
|
||||
|
|
|
@ -19,5 +19,5 @@ public @interface DataSource {
|
|||
/**
|
||||
* 切换数据源名称
|
||||
*/
|
||||
public DataSourceType value () default DataSourceType.MASTER;
|
||||
public DataSourceType value() default DataSourceType.MASTER;
|
||||
}
|
||||
|
|
|
@ -21,137 +21,137 @@ public @interface Excel {
|
|||
/**
|
||||
* 导出时在excel中排序
|
||||
*/
|
||||
public int sort () default Integer.MAX_VALUE;
|
||||
public int sort() default Integer.MAX_VALUE;
|
||||
|
||||
/**
|
||||
* 导出到Excel中的名字.
|
||||
*/
|
||||
public String name () default "";
|
||||
public String name() default "";
|
||||
|
||||
/**
|
||||
* 日期格式, 如: yyyy-MM-dd
|
||||
*/
|
||||
public String dateFormat () default "";
|
||||
public String dateFormat() default "";
|
||||
|
||||
/**
|
||||
* 如果是字典类型,请设置字典的type值 (如: sys_user_sex)
|
||||
*/
|
||||
public String dictType () default "";
|
||||
public String dictType() default "";
|
||||
|
||||
/**
|
||||
* 读取内容转表达式 (如: 0=男,1=女,2=未知)
|
||||
*/
|
||||
public String readConverterExp () default "";
|
||||
public String readConverterExp() default "";
|
||||
|
||||
/**
|
||||
* 分隔符,读取字符串组内容
|
||||
*/
|
||||
public String separator () default ",";
|
||||
public String separator() default ",";
|
||||
|
||||
/**
|
||||
* BigDecimal 精度 默认:-1(默认不开启BigDecimal格式化)
|
||||
*/
|
||||
public int scale () default -1;
|
||||
public int scale() default -1;
|
||||
|
||||
/**
|
||||
* BigDecimal 舍入规则 默认:BigDecimal.ROUND_HALF_EVEN
|
||||
*/
|
||||
public int roundingMode () default BigDecimal.ROUND_HALF_EVEN;
|
||||
public int roundingMode() default BigDecimal.ROUND_HALF_EVEN;
|
||||
|
||||
/**
|
||||
* 导出时在excel中每个列的高度
|
||||
*/
|
||||
public double height () default 14;
|
||||
public double height() default 14;
|
||||
|
||||
/**
|
||||
* 导出时在excel中每个列的宽度
|
||||
*/
|
||||
public double width () default 16;
|
||||
public double width() default 16;
|
||||
|
||||
/**
|
||||
* 文字后缀,如% 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集合单元格)
|
||||
*/
|
||||
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图片)
|
||||
*/
|
||||
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 {};
|
||||
|
||||
/**
|
||||
* 字段类型(0:导出导入;1:仅导出;2:仅导入)
|
||||
*/
|
||||
Type type () default Type.ALL;
|
||||
Type type() default Type.ALL;
|
||||
|
||||
public enum Type {
|
||||
/**
|
||||
|
@ -168,11 +168,11 @@ public @interface Excel {
|
|||
IMPORT(2);
|
||||
private final int value;
|
||||
|
||||
Type (int value) {
|
||||
Type(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int value () {
|
||||
public int value() {
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
|
@ -199,17 +199,19 @@ public @interface Excel {
|
|||
|
||||
/**
|
||||
* 类类型枚举构造器
|
||||
*
|
||||
* @param value 枚举类型值
|
||||
*/
|
||||
ColumnType (int value) {
|
||||
ColumnType(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取列枚举类型
|
||||
*
|
||||
* @return 枚举值
|
||||
*/
|
||||
public int value () {
|
||||
public int value() {
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,5 +13,5 @@ import java.lang.annotation.Target;
|
|||
@Target(ElementType.FIELD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Excels {
|
||||
public Excel[] value ();
|
||||
public Excel[] value();
|
||||
}
|
||||
|
|
|
@ -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 {};
|
||||
}
|
||||
|
|
|
@ -17,20 +17,20 @@ public @interface RateLimiter {
|
|||
/**
|
||||
* 限流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;
|
||||
}
|
||||
|
|
|
@ -15,10 +15,10 @@ public @interface RepeatSubmit {
|
|||
/**
|
||||
* 间隔时间(ms),小于此时间视为重复提交
|
||||
*/
|
||||
public int interval () default 5000;
|
||||
public int interval() default 5000;
|
||||
|
||||
/**
|
||||
* 提示消息
|
||||
*/
|
||||
public String message () default "不允许重复提交,请稍候再试";
|
||||
public String message() default "不允许重复提交,请稍候再试";
|
||||
}
|
||||
|
|
|
@ -40,87 +40,87 @@ public class RuoYiConfig {
|
|||
*/
|
||||
private boolean demoEnabled;
|
||||
|
||||
public static String getProfile () {
|
||||
public static String getProfile() {
|
||||
return profile;
|
||||
}
|
||||
|
||||
public void setProfile (String profile) {
|
||||
public void setProfile(String profile) {
|
||||
RuoYiConfig.profile = profile;
|
||||
}
|
||||
|
||||
public static boolean isAddressEnabled () {
|
||||
public static boolean isAddressEnabled() {
|
||||
return addressEnabled;
|
||||
}
|
||||
|
||||
public void setAddressEnabled (boolean addressEnabled) {
|
||||
public void setAddressEnabled(boolean addressEnabled) {
|
||||
RuoYiConfig.addressEnabled = addressEnabled;
|
||||
}
|
||||
|
||||
public static String getCaptchaType () {
|
||||
public static String getCaptchaType() {
|
||||
return captchaType;
|
||||
}
|
||||
|
||||
public void setCaptchaType (String captchaType) {
|
||||
public void setCaptchaType(String captchaType) {
|
||||
RuoYiConfig.captchaType = captchaType;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取导入上传路径
|
||||
*/
|
||||
public static String getImportPath () {
|
||||
public static String getImportPath() {
|
||||
return getProfile() + "/import";
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取头像上传路径
|
||||
*/
|
||||
public static String getAvatarPath () {
|
||||
public static String getAvatarPath() {
|
||||
return getProfile() + "/avatar";
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取下载路径
|
||||
*/
|
||||
public static String getDownloadPath () {
|
||||
public static String getDownloadPath() {
|
||||
return getProfile() + "/download/";
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取上传路径
|
||||
*/
|
||||
public static String getUploadPath () {
|
||||
public static String getUploadPath() {
|
||||
return getProfile() + "/upload";
|
||||
}
|
||||
|
||||
public String getName () {
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName (String name) {
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getVersion () {
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion (String version) {
|
||||
public void setVersion(String version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public String getCopyrightYear () {
|
||||
public String getCopyrightYear() {
|
||||
return copyrightYear;
|
||||
}
|
||||
|
||||
public void setCopyrightYear (String copyrightYear) {
|
||||
public void setCopyrightYear(String copyrightYear) {
|
||||
this.copyrightYear = copyrightYear;
|
||||
}
|
||||
|
||||
public boolean isDemoEnabled () {
|
||||
public boolean isDemoEnabled() {
|
||||
return demoEnabled;
|
||||
}
|
||||
|
||||
public void setDemoEnabled (boolean demoEnabled) {
|
||||
public void setDemoEnabled(boolean demoEnabled) {
|
||||
this.demoEnabled = demoEnabled;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,11 +45,11 @@ public class ScheduleConstants {
|
|||
|
||||
private String value;
|
||||
|
||||
private Status (String value) {
|
||||
private Status(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getValue () {
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@ import com.ruoyi.common.utils.PageUtils;
|
|||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.sql.SqlUtil;
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.bind.WebDataBinder;
|
||||
|
@ -34,11 +33,11 @@ public class BaseController {
|
|||
* 将前台传递过来的日期格式的字符串,自动转化为Date类型
|
||||
*/
|
||||
@InitBinder
|
||||
public void initBinder (WebDataBinder binder) {
|
||||
public void initBinder(WebDataBinder binder) {
|
||||
// Date 类型转换
|
||||
binder.registerCustomEditor(Date.class, new PropertyEditorSupport() {
|
||||
@Override
|
||||
public void setAsText (String text) {
|
||||
public void setAsText(String text) {
|
||||
setValue(DateUtils.parseDate(text));
|
||||
}
|
||||
});
|
||||
|
@ -47,14 +46,14 @@ public class BaseController {
|
|||
/**
|
||||
* 设置请求分页数据
|
||||
*/
|
||||
protected void startPage () {
|
||||
protected void startPage() {
|
||||
PageUtils.startPage();
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置请求排序数据
|
||||
*/
|
||||
protected void startOrderBy () {
|
||||
protected void startOrderBy() {
|
||||
PageDomain pageDomain = TableSupport.buildPageRequest();
|
||||
if (StringUtils.isNotEmpty(pageDomain.getOrderBy())) {
|
||||
String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy());
|
||||
|
@ -65,7 +64,7 @@ public class BaseController {
|
|||
/**
|
||||
* 清理分页的线程变量
|
||||
*/
|
||||
protected void clearPage () {
|
||||
protected void clearPage() {
|
||||
PageUtils.clearPage();
|
||||
}
|
||||
|
||||
|
@ -73,7 +72,7 @@ public class BaseController {
|
|||
* 响应请求分页数据
|
||||
*/
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
protected <T> Result<TableDataInfo<T>> getDataTable (List<T> list) {
|
||||
protected <T> Result<TableDataInfo<T>> getDataTable(List<T> list) {
|
||||
return Result.success(
|
||||
TableDataInfo.<T>builder()
|
||||
.total(new PageInfo(list).getTotal())
|
||||
|
@ -85,14 +84,14 @@ public class BaseController {
|
|||
/**
|
||||
* 返回成功
|
||||
*/
|
||||
public Result<String> success () {
|
||||
public Result<String> success() {
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回失败消息
|
||||
*/
|
||||
public Result<String> error () {
|
||||
public Result<String> 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回警告消息
|
||||
*/
|
||||
public Result<String> warn (String message) {
|
||||
public Result<String> warn(String message) {
|
||||
return Result.warn(message);
|
||||
}
|
||||
|
||||
|
@ -115,10 +114,9 @@ public class BaseController {
|
|||
* 响应返回结果
|
||||
*
|
||||
* @param rows 影响行数
|
||||
*
|
||||
* @return 操作结果
|
||||
*/
|
||||
protected Result<String> toAjax (int rows) {
|
||||
protected Result<String> toAjax(int rows) {
|
||||
return rows > 0 ? Result.success() : Result.error();
|
||||
}
|
||||
|
||||
|
@ -126,45 +124,44 @@ public class BaseController {
|
|||
* 响应返回结果
|
||||
*
|
||||
* @param result 结果
|
||||
*
|
||||
* @return 操作结果
|
||||
*/
|
||||
protected Result<String> toAjax (boolean result) {
|
||||
protected Result<String> toAjax(boolean result) {
|
||||
return result ? success() : error();
|
||||
}
|
||||
|
||||
/**
|
||||
* 页面跳转
|
||||
*/
|
||||
public String redirect (String url) {
|
||||
public String redirect(String url) {
|
||||
return StringUtils.format("redirect:{}", url);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户缓存信息
|
||||
*/
|
||||
public LoginUser getLoginUser () {
|
||||
public LoginUser getLoginUser() {
|
||||
return SecurityUtils.getLoginUser();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取登录用户id
|
||||
*/
|
||||
public Long getUserId () {
|
||||
public Long getUserId() {
|
||||
return getLoginUser().getUserId();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取登录部门id
|
||||
*/
|
||||
public Long getDeptId () {
|
||||
public Long getDeptId() {
|
||||
return getLoginUser().getDeptId();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取登录用户名
|
||||
*/
|
||||
public String getUsername () {
|
||||
public String getUsername() {
|
||||
return getLoginUser().getUsername();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,31 +40,31 @@ public class BaseEntity implements Serializable {
|
|||
/**
|
||||
* 创建者
|
||||
*/
|
||||
@TableField(value = "create_by" , fill = FieldFill.INSERT)
|
||||
@ApiModelProperty(hidden=true)
|
||||
@TableField(value = "create_by", fill = FieldFill.INSERT)
|
||||
@ApiModelProperty(hidden = true)
|
||||
private Long createBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@TableField(value = "create_time" , fill = FieldFill.INSERT)
|
||||
@ApiModelProperty(hidden=true)
|
||||
@TableField(value = "create_time", fill = FieldFill.INSERT)
|
||||
@ApiModelProperty(hidden = true)
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新者
|
||||
*/
|
||||
@TableField(value = "update_by" , fill = FieldFill.UPDATE)
|
||||
@ApiModelProperty(hidden=true)
|
||||
@TableField(value = "update_by", fill = FieldFill.UPDATE)
|
||||
@ApiModelProperty(hidden = true)
|
||||
private Long updateBy;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@TableField(value = "update_time" , fill = FieldFill.UPDATE)
|
||||
@ApiModelProperty(hidden=true)
|
||||
@TableField(value = "update_time", fill = FieldFill.UPDATE)
|
||||
@ApiModelProperty(hidden = true)
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
|
@ -72,26 +72,27 @@ public class BaseEntity implements Serializable {
|
|||
*/
|
||||
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||
@TableField(exist = false)
|
||||
@ApiModelProperty(hidden=true)
|
||||
@ApiModelProperty(hidden = true)
|
||||
private Map<String, Object> params;
|
||||
|
||||
public Map<String, Object> getParams () {
|
||||
public Map<String, Object> getParams() {
|
||||
if (params == null) {
|
||||
params = new HashMap<>();
|
||||
}
|
||||
return params;
|
||||
}
|
||||
|
||||
public void setParams (Map<String, Object> params) {
|
||||
public void setParams(Map<String, Object> params) {
|
||||
this.params = params;
|
||||
}
|
||||
|
||||
/**
|
||||
* 开始时间
|
||||
*
|
||||
* @param key 属性名称
|
||||
* @return 结果数据
|
||||
*/
|
||||
public Object getBeginParam(String key){
|
||||
public Object getBeginParam(String key) {
|
||||
return getParams().get(
|
||||
StringUtils.format(ReqDomain.BEGIN_REF, key)
|
||||
);
|
||||
|
@ -99,10 +100,11 @@ public class BaseEntity implements Serializable {
|
|||
|
||||
/**
|
||||
* 开始时间
|
||||
*
|
||||
* @param key 属性名称
|
||||
* @return 结果数据
|
||||
*/
|
||||
public Object getEndParam(String key){
|
||||
public Object getEndParam(String key) {
|
||||
return getParams().get(
|
||||
StringUtils.format(ReqDomain.END_REF, key)
|
||||
);
|
||||
|
@ -110,10 +112,11 @@ public class BaseEntity implements Serializable {
|
|||
|
||||
/**
|
||||
* 获取区间数据
|
||||
*
|
||||
* @param key 属性名称
|
||||
* @return 结果数据
|
||||
*/
|
||||
public Object[] getBetween(String key){
|
||||
public Object[] getBetween(String key) {
|
||||
return new Object[]{getBeginParam(key), getEndParam(key)};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,59 +32,59 @@ public class Result<T> implements Serializable {
|
|||
|
||||
private T data;
|
||||
|
||||
public static <T> Result<T> success () {
|
||||
public static <T> Result<T> 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, "操作成功");
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public static <T> Result<T> error () {
|
||||
public static <T> Result<T> error() {
|
||||
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);
|
||||
}
|
||||
|
||||
public static <T> Result<T> error (T data) {
|
||||
public static <T> Result<T> error(T data) {
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public static <T> Result<T> warn () {
|
||||
public static <T> Result<T> 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);
|
||||
}
|
||||
|
||||
public static <T> Result<T> warn (T data) {
|
||||
public static <T> Result<T> warn(T data) {
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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<>();
|
||||
apiResult.setCode(code);
|
||||
apiResult.setData(data);
|
||||
|
@ -92,11 +92,11 @@ public class Result<T> implements Serializable {
|
|||
return apiResult;
|
||||
}
|
||||
|
||||
public static <T> Boolean isError (Result<T> ret) {
|
||||
public static <T> Boolean isError(Result<T> 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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,43 +36,43 @@ public class TreeEntity extends BaseEntity {
|
|||
*/
|
||||
private List<?> children = new ArrayList<>();
|
||||
|
||||
public String getParentName () {
|
||||
public String getParentName() {
|
||||
return parentName;
|
||||
}
|
||||
|
||||
public void setParentName (String parentName) {
|
||||
public void setParentName(String parentName) {
|
||||
this.parentName = parentName;
|
||||
}
|
||||
|
||||
public Long getParentId () {
|
||||
public Long getParentId() {
|
||||
return parentId;
|
||||
}
|
||||
|
||||
public void setParentId (Long parentId) {
|
||||
public void setParentId(Long parentId) {
|
||||
this.parentId = parentId;
|
||||
}
|
||||
|
||||
public Integer getOrderNum () {
|
||||
public Integer getOrderNum() {
|
||||
return orderNum;
|
||||
}
|
||||
|
||||
public void setOrderNum (Integer orderNum) {
|
||||
public void setOrderNum(Integer orderNum) {
|
||||
this.orderNum = orderNum;
|
||||
}
|
||||
|
||||
public String getAncestors () {
|
||||
public String getAncestors() {
|
||||
return ancestors;
|
||||
}
|
||||
|
||||
public void setAncestors (String ancestors) {
|
||||
public void setAncestors(String ancestors) {
|
||||
this.ancestors = ancestors;
|
||||
}
|
||||
|
||||
public List<?> getChildren () {
|
||||
public List<?> getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
public void setChildren (List<?> children) {
|
||||
public void setChildren(List<?> children) {
|
||||
this.children = children;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,43 +32,43 @@ public class TreeSelect implements Serializable {
|
|||
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||
private List<TreeSelect> children;
|
||||
|
||||
public TreeSelect () {
|
||||
public TreeSelect() {
|
||||
|
||||
}
|
||||
|
||||
public TreeSelect (SysDept dept) {
|
||||
public TreeSelect(SysDept dept) {
|
||||
this.id = dept.getDeptId();
|
||||
this.label = dept.getDeptName();
|
||||
this.children = dept.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public TreeSelect (SysMenu menu) {
|
||||
public TreeSelect(SysMenu menu) {
|
||||
this.id = menu.getMenuId();
|
||||
this.label = menu.getMenuName();
|
||||
this.children = menu.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public Long getId () {
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId (Long id) {
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getLabel () {
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel (String label) {
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public List<TreeSelect> getChildren () {
|
||||
public List<TreeSelect> getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
public void setChildren (List<TreeSelect> children) {
|
||||
public void setChildren(List<TreeSelect> children) {
|
||||
this.children = children;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -79,110 +79,110 @@ public class SysDept extends BaseEntity {
|
|||
*/
|
||||
private List<SysDept> children = new ArrayList<SysDept>();
|
||||
|
||||
public Long getDeptId () {
|
||||
public Long getDeptId() {
|
||||
return deptId;
|
||||
}
|
||||
|
||||
public void setDeptId (Long deptId) {
|
||||
public void setDeptId(Long deptId) {
|
||||
this.deptId = deptId;
|
||||
}
|
||||
|
||||
public Long getParentId () {
|
||||
public Long getParentId() {
|
||||
return parentId;
|
||||
}
|
||||
|
||||
public void setParentId (Long parentId) {
|
||||
public void setParentId(Long parentId) {
|
||||
this.parentId = parentId;
|
||||
}
|
||||
|
||||
public String getAncestors () {
|
||||
public String getAncestors() {
|
||||
return ancestors;
|
||||
}
|
||||
|
||||
public void setAncestors (String ancestors) {
|
||||
public void setAncestors(String ancestors) {
|
||||
this.ancestors = ancestors;
|
||||
}
|
||||
|
||||
@NotBlank(message = "部门名称不能为空")
|
||||
@Size(min = 0, max = 30, message = "部门名称长度不能超过30个字符")
|
||||
public String getDeptName () {
|
||||
public String getDeptName() {
|
||||
return deptName;
|
||||
}
|
||||
|
||||
public void setDeptName (String deptName) {
|
||||
public void setDeptName(String deptName) {
|
||||
this.deptName = deptName;
|
||||
}
|
||||
|
||||
@NotNull(message = "显示顺序不能为空")
|
||||
public Integer getOrderNum () {
|
||||
public Integer getOrderNum() {
|
||||
return orderNum;
|
||||
}
|
||||
|
||||
public void setOrderNum (Integer orderNum) {
|
||||
public void setOrderNum(Integer orderNum) {
|
||||
this.orderNum = orderNum;
|
||||
}
|
||||
|
||||
public String getLeader () {
|
||||
public String getLeader() {
|
||||
return leader;
|
||||
}
|
||||
|
||||
public void setLeader (String leader) {
|
||||
public void setLeader(String leader) {
|
||||
this.leader = leader;
|
||||
}
|
||||
|
||||
@Size(min = 0, max = 11, message = "联系电话长度不能超过11个字符")
|
||||
public String getPhone () {
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
|
||||
public void setPhone (String phone) {
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
@Email(message = "邮箱格式不正确")
|
||||
@Size(min = 0, max = 50, message = "邮箱长度不能超过50个字符")
|
||||
public String getEmail () {
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail (String email) {
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public String getStatus () {
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus (String status) {
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getDelFlag () {
|
||||
public String getDelFlag() {
|
||||
return delFlag;
|
||||
}
|
||||
|
||||
public void setDelFlag (String delFlag) {
|
||||
public void setDelFlag(String delFlag) {
|
||||
this.delFlag = delFlag;
|
||||
}
|
||||
|
||||
public String getParentName () {
|
||||
public String getParentName() {
|
||||
return parentName;
|
||||
}
|
||||
|
||||
public void setParentName (String parentName) {
|
||||
public void setParentName(String parentName) {
|
||||
this.parentName = parentName;
|
||||
}
|
||||
|
||||
public List<SysDept> getChildren () {
|
||||
public List<SysDept> getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
public void setChildren (List<SysDept> children) {
|
||||
public void setChildren(List<SysDept> children) {
|
||||
this.children = children;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString () {
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("deptId", getDeptId())
|
||||
.append("parentId", getParentId())
|
||||
|
|
|
@ -2,7 +2,6 @@ package com.ruoyi.common.core.domain.entity;
|
|||
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.annotation.Excel.ColumnType;
|
||||
import com.ruoyi.common.constant.UserConstants;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
@ -87,29 +86,29 @@ public class SysDictData extends BaseEntity {
|
|||
|
||||
@NotBlank(message = "字典标签不能为空")
|
||||
@Size(min = 0, max = 100, message = "字典标签长度不能超过100个字符")
|
||||
public String getDictLabel () {
|
||||
public String getDictLabel() {
|
||||
return dictLabel;
|
||||
}
|
||||
|
||||
@NotBlank(message = "字典键值不能为空")
|
||||
@Size(min = 0, max = 100, message = "字典键值长度不能超过100个字符")
|
||||
public String getDictValue () {
|
||||
public String getDictValue() {
|
||||
return dictValue;
|
||||
}
|
||||
|
||||
@NotBlank(message = "字典类型不能为空")
|
||||
@Size(min = 0, max = 100, message = "字典类型长度不能超过100个字符")
|
||||
public String getDictType () {
|
||||
public String getDictType() {
|
||||
return dictType;
|
||||
}
|
||||
|
||||
@Size(min = 0, max = 100, message = "样式属性长度不能超过100个字符")
|
||||
public String getCssClass () {
|
||||
public String getCssClass() {
|
||||
return cssClass;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString () {
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("dictCode", getDictCode())
|
||||
.append("dictSort", getDictSort())
|
||||
|
|
|
@ -60,19 +60,19 @@ public class SysDictType extends BaseEntity {
|
|||
|
||||
@NotBlank(message = "字典名称不能为空")
|
||||
@Size(min = 0, max = 100, message = "字典类型名称长度不能超过100个字符")
|
||||
public String getDictName () {
|
||||
public String getDictName() {
|
||||
return dictName;
|
||||
}
|
||||
|
||||
@NotBlank(message = "字典类型不能为空")
|
||||
@Size(min = 0, max = 100, message = "字典类型类型长度不能超过100个字符")
|
||||
@Pattern(regexp = "^[a-z][a-z0-9_]*$", message = "字典类型必须以字母开头,且只能为(小写字母,数字,下滑线)")
|
||||
public String getDictType () {
|
||||
public String getDictType() {
|
||||
return dictType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString () {
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("dictId", getDictId())
|
||||
.append("dictName", getDictName())
|
||||
|
|
|
@ -116,38 +116,38 @@ public class SysMenu extends BaseEntity {
|
|||
|
||||
@NotBlank(message = "菜单名称不能为空")
|
||||
@Size(min = 0, max = 50, message = "菜单名称长度不能超过50个字符")
|
||||
public String getMenuName () {
|
||||
public String getMenuName() {
|
||||
return menuName;
|
||||
}
|
||||
|
||||
|
||||
@NotNull(message = "显示顺序不能为空")
|
||||
public Integer getOrderNum () {
|
||||
public Integer getOrderNum() {
|
||||
return orderNum;
|
||||
}
|
||||
|
||||
@Size(min = 0, max = 200, message = "路由地址不能超过200个字符")
|
||||
public String getPath () {
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
@Size(min = 0, max = 200, message = "组件路径不能超过255个字符")
|
||||
public String getComponent () {
|
||||
public String getComponent() {
|
||||
return component;
|
||||
}
|
||||
|
||||
@NotBlank(message = "菜单类型不能为空")
|
||||
public String getMenuType () {
|
||||
public String getMenuType() {
|
||||
return menuType;
|
||||
}
|
||||
|
||||
@Size(min = 0, max = 100, message = "权限标识长度不能超过100个字符")
|
||||
public String getPerms () {
|
||||
public String getPerms() {
|
||||
return perms;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString () {
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("menuId", getMenuId())
|
||||
.append("menuName", getMenuName())
|
||||
|
|
|
@ -6,7 +6,6 @@ import com.ruoyi.common.core.domain.BaseEntity;
|
|||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
@ -105,48 +104,49 @@ public class SysRole extends BaseEntity {
|
|||
private String remark;
|
||||
|
||||
|
||||
public SysRole () {
|
||||
public SysRole() {
|
||||
|
||||
}
|
||||
|
||||
public SysRole (Long roleId) {
|
||||
public SysRole(Long roleId) {
|
||||
this.roleId = roleId;
|
||||
}
|
||||
|
||||
public static boolean isAdmin (Long roleId) {
|
||||
public static boolean isAdmin(Long roleId) {
|
||||
return roleId != null && 1L == roleId;
|
||||
}
|
||||
|
||||
public boolean isAdmin () {
|
||||
public boolean isAdmin() {
|
||||
return isAdmin(this.roleId);
|
||||
}
|
||||
|
||||
@NotBlank(message = "角色名称不能为空")
|
||||
@Size(min = 0, max = 30, message = "角色名称长度不能超过30个字符")
|
||||
public String getRoleName () {
|
||||
public String getRoleName() {
|
||||
return roleName;
|
||||
}
|
||||
|
||||
@NotBlank(message = "权限字符不能为空")
|
||||
@Size(min = 0, max = 100, message = "权限字符长度不能超过100个字符")
|
||||
public String getRoleKey () {
|
||||
public String getRoleKey() {
|
||||
return roleKey;
|
||||
}
|
||||
|
||||
@NotNull(message = "显示顺序不能为空")
|
||||
public Integer getRoleSort () {
|
||||
public Integer getRoleSort() {
|
||||
return roleSort;
|
||||
}
|
||||
|
||||
public boolean isMenuCheckStrictly () {
|
||||
public boolean isMenuCheckStrictly() {
|
||||
return menuCheckStrictly;
|
||||
}
|
||||
|
||||
public boolean isDeptCheckStrictly () {
|
||||
public boolean isDeptCheckStrictly() {
|
||||
return deptCheckStrictly;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString () {
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("roleId", getRoleId())
|
||||
.append("roleName", getRoleName())
|
||||
|
|
|
@ -9,7 +9,6 @@ import com.ruoyi.common.xss.Xss;
|
|||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
@ -141,47 +140,48 @@ public class SysUser extends BaseEntity {
|
|||
*/
|
||||
private String remark;
|
||||
|
||||
public SysUser () {
|
||||
public SysUser() {
|
||||
|
||||
}
|
||||
|
||||
public SysUser (Long userId) {
|
||||
public SysUser(Long userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public static boolean isAdmin (Long userId) {
|
||||
public static boolean isAdmin(Long userId) {
|
||||
return userId != null && 1L == userId;
|
||||
}
|
||||
|
||||
public boolean isAdmin () {
|
||||
public boolean isAdmin() {
|
||||
return isAdmin(this.userId);
|
||||
}
|
||||
|
||||
@Xss(message = "用户昵称不能包含脚本字符")
|
||||
@Size(min = 0, max = 30, message = "用户昵称长度不能超过30个字符")
|
||||
public String getNickName () {
|
||||
public String getNickName() {
|
||||
return nickName;
|
||||
}
|
||||
|
||||
@Xss(message = "用户账号不能包含脚本字符")
|
||||
@NotBlank(message = "用户账号不能为空")
|
||||
@Size(min = 0, max = 30, message = "用户账号长度不能超过30个字符")
|
||||
public String getUserName () {
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
@Email(message = "邮箱格式不正确")
|
||||
@Size(min = 0, max = 50, message = "邮箱长度不能超过50个字符")
|
||||
public String getEmail () {
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
@Size(min = 0, max = 11, message = "手机号码长度不能超过11个字符")
|
||||
public String getPhonenumber () {
|
||||
public String getPhonenumber() {
|
||||
return phonenumber;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString () {
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("userId", getUserId())
|
||||
.append("deptId", getDeptId())
|
||||
|
|
|
@ -26,35 +26,35 @@ public class LoginBody {
|
|||
*/
|
||||
private String uuid;
|
||||
|
||||
public String getUsername () {
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername (String username) {
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getPassword () {
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword (String password) {
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getCode () {
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode (String code) {
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getUuid () {
|
||||
public String getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public void setUuid (String uuid) {
|
||||
public void setUuid(String uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,53 +71,53 @@ public class LoginUser implements UserDetails {
|
|||
*/
|
||||
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.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.deptId = deptId;
|
||||
this.user = user;
|
||||
this.permissions = permissions;
|
||||
}
|
||||
|
||||
public Long getUserId () {
|
||||
public Long getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId (Long userId) {
|
||||
public void setUserId(Long userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public Long getDeptId () {
|
||||
public Long getDeptId() {
|
||||
return deptId;
|
||||
}
|
||||
|
||||
public void setDeptId (Long deptId) {
|
||||
public void setDeptId(Long deptId) {
|
||||
this.deptId = deptId;
|
||||
}
|
||||
|
||||
public String getToken () {
|
||||
public String getToken() {
|
||||
return token;
|
||||
}
|
||||
|
||||
public void setToken (String token) {
|
||||
public void setToken(String token) {
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
@JSONField(serialize = false)
|
||||
@Override
|
||||
public String getPassword () {
|
||||
public String getPassword() {
|
||||
return user.getPassword();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUsername () {
|
||||
public String getUsername() {
|
||||
return user.getUserName();
|
||||
}
|
||||
|
||||
|
@ -126,7 +126,7 @@ public class LoginUser implements UserDetails {
|
|||
*/
|
||||
@JSONField(serialize = false)
|
||||
@Override
|
||||
public boolean isAccountNonExpired () {
|
||||
public boolean isAccountNonExpired() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -137,7 +137,7 @@ public class LoginUser implements UserDetails {
|
|||
*/
|
||||
@JSONField(serialize = false)
|
||||
@Override
|
||||
public boolean isAccountNonLocked () {
|
||||
public boolean isAccountNonLocked() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -148,7 +148,7 @@ public class LoginUser implements UserDetails {
|
|||
*/
|
||||
@JSONField(serialize = false)
|
||||
@Override
|
||||
public boolean isCredentialsNonExpired () {
|
||||
public boolean isCredentialsNonExpired() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -159,76 +159,76 @@ public class LoginUser implements UserDetails {
|
|||
*/
|
||||
@JSONField(serialize = false)
|
||||
@Override
|
||||
public boolean isEnabled () {
|
||||
public boolean isEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public Long getLoginTime () {
|
||||
public Long getLoginTime() {
|
||||
return loginTime;
|
||||
}
|
||||
|
||||
public void setLoginTime (Long loginTime) {
|
||||
public void setLoginTime(Long loginTime) {
|
||||
this.loginTime = loginTime;
|
||||
}
|
||||
|
||||
public String getIpaddr () {
|
||||
public String getIpaddr() {
|
||||
return ipaddr;
|
||||
}
|
||||
|
||||
public void setIpaddr (String ipaddr) {
|
||||
public void setIpaddr(String ipaddr) {
|
||||
this.ipaddr = ipaddr;
|
||||
}
|
||||
|
||||
public String getLoginLocation () {
|
||||
public String getLoginLocation() {
|
||||
return loginLocation;
|
||||
}
|
||||
|
||||
public void setLoginLocation (String loginLocation) {
|
||||
public void setLoginLocation(String loginLocation) {
|
||||
this.loginLocation = loginLocation;
|
||||
}
|
||||
|
||||
public String getBrowser () {
|
||||
public String getBrowser() {
|
||||
return browser;
|
||||
}
|
||||
|
||||
public void setBrowser (String browser) {
|
||||
public void setBrowser(String browser) {
|
||||
this.browser = browser;
|
||||
}
|
||||
|
||||
public String getOs () {
|
||||
public String getOs() {
|
||||
return os;
|
||||
}
|
||||
|
||||
public void setOs (String os) {
|
||||
public void setOs(String os) {
|
||||
this.os = os;
|
||||
}
|
||||
|
||||
public Long getExpireTime () {
|
||||
public Long getExpireTime() {
|
||||
return expireTime;
|
||||
}
|
||||
|
||||
public void setExpireTime (Long expireTime) {
|
||||
public void setExpireTime(Long expireTime) {
|
||||
this.expireTime = expireTime;
|
||||
}
|
||||
|
||||
public Set<String> getPermissions () {
|
||||
public Set<String> getPermissions() {
|
||||
return permissions;
|
||||
}
|
||||
|
||||
public void setPermissions (Set<String> permissions) {
|
||||
public void setPermissions(Set<String> permissions) {
|
||||
this.permissions = permissions;
|
||||
}
|
||||
|
||||
public SysUser getUser () {
|
||||
public SysUser getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUser (SysUser user) {
|
||||
public void setUser(SysUser user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<? extends GrantedAuthority> getAuthorities () {
|
||||
public Collection<? extends GrantedAuthority> getAuthorities() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,42 +33,42 @@ public class PageDomain {
|
|||
*/
|
||||
private Boolean reasonable = true;
|
||||
|
||||
public String getOrderBy () {
|
||||
public String getOrderBy() {
|
||||
if (StringUtils.isEmpty(orderByColumn)) {
|
||||
return "";
|
||||
}
|
||||
return StringUtils.toUnderScoreCase(orderByColumn) + " " + isAsc;
|
||||
}
|
||||
|
||||
public Integer getPageNum () {
|
||||
public Integer getPageNum() {
|
||||
return pageNum;
|
||||
}
|
||||
|
||||
public void setPageNum (Integer pageNum) {
|
||||
public void setPageNum(Integer pageNum) {
|
||||
this.pageNum = pageNum;
|
||||
}
|
||||
|
||||
public Integer getPageSize () {
|
||||
public Integer getPageSize() {
|
||||
return pageSize;
|
||||
}
|
||||
|
||||
public void setPageSize (Integer pageSize) {
|
||||
public void setPageSize(Integer pageSize) {
|
||||
this.pageSize = pageSize;
|
||||
}
|
||||
|
||||
public String getOrderByColumn () {
|
||||
public String getOrderByColumn() {
|
||||
return orderByColumn;
|
||||
}
|
||||
|
||||
public void setOrderByColumn (String orderByColumn) {
|
||||
public void setOrderByColumn(String orderByColumn) {
|
||||
this.orderByColumn = orderByColumn;
|
||||
}
|
||||
|
||||
public String getIsAsc () {
|
||||
public String getIsAsc() {
|
||||
return isAsc;
|
||||
}
|
||||
|
||||
public void setIsAsc (String isAsc) {
|
||||
public void setIsAsc(String isAsc) {
|
||||
if (StringUtils.isNotEmpty(isAsc)) {
|
||||
// 兼容前端排序类型
|
||||
if ("ascending".equals(isAsc)) {
|
||||
|
@ -80,14 +80,14 @@ public class PageDomain {
|
|||
}
|
||||
}
|
||||
|
||||
public Boolean getReasonable () {
|
||||
public Boolean getReasonable() {
|
||||
if (StringUtils.isNull(reasonable)) {
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
return reasonable;
|
||||
}
|
||||
|
||||
public void setReasonable (Boolean reasonable) {
|
||||
public void setReasonable(Boolean reasonable) {
|
||||
this.reasonable = reasonable;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ public class TableSupport {
|
|||
/**
|
||||
* 封装分页对象
|
||||
*/
|
||||
public static PageDomain getPageDomain () {
|
||||
public static PageDomain getPageDomain() {
|
||||
PageDomain pageDomain = new PageDomain();
|
||||
pageDomain.setPageNum(Convert.toInt(ServletUtils.getParameter(PAGE_NUM), 1));
|
||||
pageDomain.setPageSize(Convert.toInt(ServletUtils.getParameter(PAGE_SIZE), 10));
|
||||
|
@ -47,7 +47,7 @@ public class TableSupport {
|
|||
return pageDomain;
|
||||
}
|
||||
|
||||
public static PageDomain buildPageRequest () {
|
||||
public static PageDomain buildPageRequest() {
|
||||
return getPageDomain();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,10 @@ import org.springframework.data.redis.core.RedisTemplate;
|
|||
import org.springframework.data.redis.core.ValueOperations;
|
||||
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;
|
||||
|
||||
/**
|
||||
|
@ -27,7 +30,7 @@ public class RedisCache {
|
|||
* @param key 缓存的键值
|
||||
* @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);
|
||||
}
|
||||
|
||||
|
@ -39,7 +42,7 @@ public class RedisCache {
|
|||
* @param timeout 时间
|
||||
* @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);
|
||||
}
|
||||
|
||||
|
@ -48,10 +51,9 @@ public class RedisCache {
|
|||
*
|
||||
* @param key Redis键
|
||||
* @param timeout 超时时间
|
||||
*
|
||||
* @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);
|
||||
}
|
||||
|
||||
|
@ -61,10 +63,9 @@ public class RedisCache {
|
|||
* @param key Redis键
|
||||
* @param timeout 超时时间
|
||||
* @param unit 时间单位
|
||||
*
|
||||
* @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));
|
||||
}
|
||||
|
||||
|
@ -72,10 +73,9 @@ public class RedisCache {
|
|||
* 获取有效时间
|
||||
*
|
||||
* @param key Redis键
|
||||
*
|
||||
* @return 有效时间
|
||||
*/
|
||||
public long getExpire (final String key) {
|
||||
public long getExpire(final String key) {
|
||||
return redisTemplate.getExpire(key);
|
||||
}
|
||||
|
||||
|
@ -83,10 +83,9 @@ public class RedisCache {
|
|||
* 判断 key是否存在
|
||||
*
|
||||
* @param key 键
|
||||
*
|
||||
* @return true 存在 false不存在
|
||||
*/
|
||||
public Boolean hasKey (String key) {
|
||||
public Boolean hasKey(String key) {
|
||||
return redisTemplate.hasKey(key);
|
||||
}
|
||||
|
||||
|
@ -94,10 +93,9 @@ public class RedisCache {
|
|||
* 获得缓存的基本对象。
|
||||
*
|
||||
* @param key 缓存键值
|
||||
*
|
||||
* @return 缓存键值对应的数据
|
||||
*/
|
||||
public <T> T getCacheObject (final String key) {
|
||||
public <T> T getCacheObject(final String key) {
|
||||
ValueOperations<String, T> operation = redisTemplate.opsForValue();
|
||||
return operation.get(key);
|
||||
}
|
||||
|
@ -107,7 +105,7 @@ public class RedisCache {
|
|||
*
|
||||
* @param key
|
||||
*/
|
||||
public boolean deleteObject (final String key) {
|
||||
public boolean deleteObject(final String key) {
|
||||
return redisTemplate.delete(key);
|
||||
}
|
||||
|
||||
|
@ -115,10 +113,9 @@ public class RedisCache {
|
|||
* 删除集合对象
|
||||
*
|
||||
* @param collection 多个对象
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean deleteObject (final Collection collection) {
|
||||
public boolean deleteObject(final Collection collection) {
|
||||
return redisTemplate.delete(collection) > 0;
|
||||
}
|
||||
|
||||
|
@ -127,10 +124,9 @@ public class RedisCache {
|
|||
*
|
||||
* @param key 缓存的键值
|
||||
* @param dataList 待缓存的List数据
|
||||
*
|
||||
* @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);
|
||||
return count == null ? 0 : count;
|
||||
}
|
||||
|
@ -139,10 +135,9 @@ public class RedisCache {
|
|||
* 获得缓存的list对象
|
||||
*
|
||||
* @param key 缓存的键值
|
||||
*
|
||||
* @return 缓存键值对应的数据
|
||||
*/
|
||||
public <T> List<T> getCacheList (final String key) {
|
||||
public <T> List<T> getCacheList(final String key) {
|
||||
return redisTemplate.opsForList().range(key, 0, -1);
|
||||
}
|
||||
|
||||
|
@ -151,10 +146,9 @@ public class RedisCache {
|
|||
*
|
||||
* @param key 缓存键值
|
||||
* @param dataSet 缓存的数据
|
||||
*
|
||||
* @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);
|
||||
for (T t : dataSet) {
|
||||
setOperation.add(t);
|
||||
|
@ -166,10 +160,9 @@ public class RedisCache {
|
|||
* 获得缓存的set
|
||||
*
|
||||
* @param key
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public <T> Set<T> getCacheSet (final String key) {
|
||||
public <T> Set<T> getCacheSet(final String key) {
|
||||
return redisTemplate.opsForSet().members(key);
|
||||
}
|
||||
|
||||
|
@ -179,7 +172,7 @@ public class RedisCache {
|
|||
* @param key
|
||||
* @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) {
|
||||
redisTemplate.opsForHash().putAll(key, dataMap);
|
||||
}
|
||||
|
@ -189,10 +182,9 @@ public class RedisCache {
|
|||
* 获得缓存的Map
|
||||
*
|
||||
* @param key
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public <T> Map<String, T> getCacheMap (final String key) {
|
||||
public <T> Map<String, T> getCacheMap(final String key) {
|
||||
return redisTemplate.opsForHash().entries(key);
|
||||
}
|
||||
|
||||
|
@ -203,7 +195,7 @@ public class RedisCache {
|
|||
* @param hKey Hash键
|
||||
* @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);
|
||||
}
|
||||
|
||||
|
@ -212,10 +204,9 @@ public class RedisCache {
|
|||
*
|
||||
* @param key Redis键
|
||||
* @param hKey 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();
|
||||
return opsForHash.get(key, hKey);
|
||||
}
|
||||
|
@ -225,10 +216,9 @@ public class RedisCache {
|
|||
*
|
||||
* @param key Redis键
|
||||
* @param hKeys 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);
|
||||
}
|
||||
|
||||
|
@ -237,10 +227,9 @@ public class RedisCache {
|
|||
*
|
||||
* @param key Redis键
|
||||
* @param hKey Hash键
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
|
@ -248,10 +237,9 @@ public class RedisCache {
|
|||
* 获得缓存的基本对象列表
|
||||
*
|
||||
* @param pattern 字符串前缀
|
||||
*
|
||||
* @return 对象列表
|
||||
*/
|
||||
public Collection<String> keys (final String pattern) {
|
||||
public Collection<String> keys(final String pattern) {
|
||||
return redisTemplate.keys(pattern);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,10 +41,9 @@ public class CharsetKit {
|
|||
* 转换为Charset对象
|
||||
*
|
||||
* @param charset 字符集,为空则返回默认字符集
|
||||
*
|
||||
* @return Charset
|
||||
*/
|
||||
public static Charset charset (String charset) {
|
||||
public static Charset charset(String charset) {
|
||||
return StringUtils.isEmpty(charset) ? Charset.defaultCharset() : Charset.forName(charset);
|
||||
}
|
||||
|
||||
|
@ -54,10 +53,9 @@ public class CharsetKit {
|
|||
* @param source 字符串
|
||||
* @param srcCharset 源字符集,默认ISO-8859-1
|
||||
* @param destCharset 目标字符集,默认UTF-8
|
||||
*
|
||||
* @return 转换后的字符集
|
||||
*/
|
||||
public static String convert (String source, String srcCharset, String destCharset) {
|
||||
public static String convert(String source, String srcCharset, String destCharset) {
|
||||
return convert(source, Charset.forName(srcCharset), Charset.forName(destCharset));
|
||||
}
|
||||
|
||||
|
@ -67,10 +65,9 @@ public class CharsetKit {
|
|||
* @param source 字符串
|
||||
* @param srcCharset 源字符集,默认ISO-8859-1
|
||||
* @param destCharset 目标字符集,默认UTF-8
|
||||
*
|
||||
* @return 转换后的字符集
|
||||
*/
|
||||
public static String convert (String source, Charset srcCharset, Charset destCharset) {
|
||||
public static String convert(String source, Charset srcCharset, Charset destCharset) {
|
||||
if (null == srcCharset) {
|
||||
srcCharset = StandardCharsets.ISO_8859_1;
|
||||
}
|
||||
|
@ -88,7 +85,7 @@ public class CharsetKit {
|
|||
/**
|
||||
* @return 系统字符集编码
|
||||
*/
|
||||
public static String systemCharset () {
|
||||
public static String systemCharset() {
|
||||
return Charset.defaultCharset().name();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,10 +23,9 @@ public class Convert {
|
|||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
public static String toStr (Object value, String defaultValue) {
|
||||
public static String toStr(Object value, String defaultValue) {
|
||||
if (null == value) {
|
||||
return defaultValue;
|
||||
}
|
||||
|
@ -42,10 +41,9 @@ public class Convert {
|
|||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
public static String toStr (Object value) {
|
||||
public static String toStr(Object value) {
|
||||
return toStr(value, null);
|
||||
}
|
||||
|
||||
|
@ -56,10 +54,9 @@ public class Convert {
|
|||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
public static Character toChar (Object value, Character defaultValue) {
|
||||
public static Character toChar(Object value, Character defaultValue) {
|
||||
if (null == value) {
|
||||
return defaultValue;
|
||||
}
|
||||
|
@ -77,10 +74,9 @@ public class Convert {
|
|||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
public static Character toChar (Object value) {
|
||||
public static Character toChar(Object value) {
|
||||
return toChar(value, null);
|
||||
}
|
||||
|
||||
|
@ -91,10 +87,9 @@ public class Convert {
|
|||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
public static Byte toByte (Object value, Byte defaultValue) {
|
||||
public static Byte toByte(Object value, Byte defaultValue) {
|
||||
if (value == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
|
@ -121,10 +116,9 @@ public class Convert {
|
|||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
public static Byte toByte (Object value) {
|
||||
public static Byte toByte(Object value) {
|
||||
return toByte(value, null);
|
||||
}
|
||||
|
||||
|
@ -135,10 +129,9 @@ public class Convert {
|
|||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
public static Short toShort (Object value, Short defaultValue) {
|
||||
public static Short toShort(Object value, Short defaultValue) {
|
||||
if (value == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
|
@ -165,10 +158,9 @@ public class Convert {
|
|||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
public static Short toShort (Object value) {
|
||||
public static Short toShort(Object value) {
|
||||
return toShort(value, null);
|
||||
}
|
||||
|
||||
|
@ -179,10 +171,9 @@ public class Convert {
|
|||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
public static Number toNumber (Object value, Number defaultValue) {
|
||||
public static Number toNumber(Object value, Number defaultValue) {
|
||||
if (value == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
|
@ -206,10 +197,9 @@ public class Convert {
|
|||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
public static Number toNumber (Object value) {
|
||||
public static Number toNumber(Object value) {
|
||||
return toNumber(value, null);
|
||||
}
|
||||
|
||||
|
@ -220,10 +210,9 @@ public class Convert {
|
|||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
public static Integer toInt (Object value, Integer defaultValue) {
|
||||
public static Integer toInt(Object value, Integer defaultValue) {
|
||||
if (value == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
|
@ -250,10 +239,9 @@ public class Convert {
|
|||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
public static Integer toInt (Object value) {
|
||||
public static Integer toInt(Object value) {
|
||||
return toInt(value, null);
|
||||
}
|
||||
|
||||
|
@ -261,10 +249,9 @@ public class Convert {
|
|||
* 转换为Integer数组<br>
|
||||
*
|
||||
* @param str 被转换的值
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
public static Integer[] toIntArray (String str) {
|
||||
public static Integer[] toIntArray(String str) {
|
||||
return toIntArray(",", str);
|
||||
}
|
||||
|
||||
|
@ -272,10 +259,9 @@ public class Convert {
|
|||
* 转换为Long数组<br>
|
||||
*
|
||||
* @param str 被转换的值
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
public static Long[] toLongArray (String str) {
|
||||
public static Long[] toLongArray(String str) {
|
||||
return toLongArray(",", str);
|
||||
}
|
||||
|
||||
|
@ -284,16 +270,15 @@ public class Convert {
|
|||
*
|
||||
* @param split 分隔符
|
||||
* @param split 被转换的值
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
public static Integer[] toIntArray (String split, String str) {
|
||||
public static Integer[] toIntArray(String split, String str) {
|
||||
if (StringUtils.isEmpty(str)) {
|
||||
return new Integer[]{};
|
||||
}
|
||||
String[] arr = str.split(split);
|
||||
final Integer[] ints = new Integer[arr.length];
|
||||
for (int i = 0 ; i < arr.length ; i++) {
|
||||
for (int i = 0; i < arr.length; i++) {
|
||||
final Integer v = toInt(arr[i], 0);
|
||||
ints[i] = v;
|
||||
}
|
||||
|
@ -305,16 +290,15 @@ public class Convert {
|
|||
*
|
||||
* @param split 分隔符
|
||||
* @param str 被转换的值
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
public static Long[] toLongArray (String split, String str) {
|
||||
public static Long[] toLongArray(String split, String str) {
|
||||
if (StringUtils.isEmpty(str)) {
|
||||
return new Long[]{};
|
||||
}
|
||||
String[] arr = str.split(split);
|
||||
final Long[] longs = new Long[arr.length];
|
||||
for (int i = 0 ; i < arr.length ; i++) {
|
||||
for (int i = 0; i < arr.length; i++) {
|
||||
final Long v = toLong(arr[i], null);
|
||||
longs[i] = v;
|
||||
}
|
||||
|
@ -325,10 +309,9 @@ public class Convert {
|
|||
* 转换为String数组<br>
|
||||
*
|
||||
* @param str 被转换的值
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
public static String[] toStrArray (String str) {
|
||||
public static String[] toStrArray(String str) {
|
||||
return toStrArray(",", str);
|
||||
}
|
||||
|
||||
|
@ -337,10 +320,9 @@ public class Convert {
|
|||
*
|
||||
* @param split 分隔符
|
||||
* @param split 被转换的值
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
public static String[] toStrArray (String split, String str) {
|
||||
public static String[] toStrArray(String split, String str) {
|
||||
return str.split(split);
|
||||
}
|
||||
|
||||
|
@ -351,10 +333,9 @@ public class Convert {
|
|||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
public static Long toLong (Object value, Long defaultValue) {
|
||||
public static Long toLong(Object value, Long defaultValue) {
|
||||
if (value == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
|
@ -382,10 +363,9 @@ public class Convert {
|
|||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
public static Long toLong (Object value) {
|
||||
public static Long toLong(Object value) {
|
||||
return toLong(value, null);
|
||||
}
|
||||
|
||||
|
@ -396,10 +376,9 @@ public class Convert {
|
|||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
public static Double toDouble (Object value, Double defaultValue) {
|
||||
public static Double toDouble(Object value, Double defaultValue) {
|
||||
if (value == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
|
@ -427,10 +406,9 @@ public class Convert {
|
|||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
public static Double toDouble (Object value) {
|
||||
public static Double toDouble(Object value) {
|
||||
return toDouble(value, null);
|
||||
}
|
||||
|
||||
|
@ -441,10 +419,9 @@ public class Convert {
|
|||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
public static Float toFloat (Object value, Float defaultValue) {
|
||||
public static Float toFloat(Object value, Float defaultValue) {
|
||||
if (value == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
|
@ -471,10 +448,9 @@ public class Convert {
|
|||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
public static Float toFloat (Object value) {
|
||||
public static Float toFloat(Object value) {
|
||||
return toFloat(value, null);
|
||||
}
|
||||
|
||||
|
@ -485,10 +461,9 @@ public class Convert {
|
|||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
public static Boolean toBool (Object value, Boolean defaultValue) {
|
||||
public static Boolean toBool(Object value, Boolean defaultValue) {
|
||||
if (value == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
|
@ -521,10 +496,9 @@ public class Convert {
|
|||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
public static Boolean toBool (Object value) {
|
||||
public static Boolean toBool(Object value) {
|
||||
return toBool(value, null);
|
||||
}
|
||||
|
||||
|
@ -535,10 +509,9 @@ public class Convert {
|
|||
* @param clazz Enum的Class
|
||||
* @param value 值
|
||||
* @param defaultValue 默认值
|
||||
*
|
||||
* @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) {
|
||||
return defaultValue;
|
||||
}
|
||||
|
@ -564,10 +537,9 @@ public class Convert {
|
|||
*
|
||||
* @param clazz Enum的Class
|
||||
* @param value 值
|
||||
*
|
||||
* @return Enum
|
||||
*/
|
||||
public static <E extends Enum<E>> E toEnum (Class<E> clazz, Object value) {
|
||||
public static <E extends Enum<E>> E toEnum(Class<E> clazz, Object value) {
|
||||
return toEnum(clazz, value, null);
|
||||
}
|
||||
|
||||
|
@ -578,10 +550,9 @@ public class Convert {
|
|||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
public static BigInteger toBigInteger (Object value, BigInteger defaultValue) {
|
||||
public static BigInteger toBigInteger(Object value, BigInteger defaultValue) {
|
||||
if (value == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
|
@ -608,10 +579,9 @@ public class Convert {
|
|||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
public static BigInteger toBigInteger (Object value) {
|
||||
public static BigInteger toBigInteger(Object value) {
|
||||
return toBigInteger(value, null);
|
||||
}
|
||||
|
||||
|
@ -622,10 +592,9 @@ public class Convert {
|
|||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
public static BigDecimal toBigDecimal (Object value, BigDecimal defaultValue) {
|
||||
public static BigDecimal toBigDecimal(Object value, BigDecimal defaultValue) {
|
||||
if (value == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
|
@ -658,10 +627,9 @@ public class Convert {
|
|||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
public static BigDecimal toBigDecimal (Object value) {
|
||||
public static BigDecimal toBigDecimal(Object value) {
|
||||
return toBigDecimal(value, null);
|
||||
}
|
||||
|
||||
|
@ -670,10 +638,9 @@ public class Convert {
|
|||
* 1、Byte数组和ByteBuffer会被转换为对应字符串的数组 2、对象数组会调用Arrays.toString方法
|
||||
*
|
||||
* @param obj 对象
|
||||
*
|
||||
* @return 字符串
|
||||
*/
|
||||
public static String utf8Str (Object obj) {
|
||||
public static String utf8Str(Object obj) {
|
||||
return str(obj, CharsetKit.CHARSET_UTF_8);
|
||||
}
|
||||
|
||||
|
@ -683,10 +650,9 @@ public class Convert {
|
|||
*
|
||||
* @param obj 对象
|
||||
* @param charsetName 字符集
|
||||
*
|
||||
* @return 字符串
|
||||
*/
|
||||
public static String str (Object obj, String charsetName) {
|
||||
public static String str(Object obj, String charsetName) {
|
||||
return str(obj, Charset.forName(charsetName));
|
||||
}
|
||||
|
||||
|
@ -696,10 +662,9 @@ public class Convert {
|
|||
*
|
||||
* @param obj 对象
|
||||
* @param charset 字符集
|
||||
*
|
||||
* @return 字符串
|
||||
*/
|
||||
public static String str (Object obj, Charset charset) {
|
||||
public static String str(Object obj, Charset charset) {
|
||||
if (null == obj) {
|
||||
return null;
|
||||
}
|
||||
|
@ -722,10 +687,9 @@ public class Convert {
|
|||
*
|
||||
* @param bytes byte数组
|
||||
* @param charset 字符集
|
||||
*
|
||||
* @return 字符串
|
||||
*/
|
||||
public static String str (byte[] bytes, String charset) {
|
||||
public static String str(byte[] bytes, String charset) {
|
||||
return str(bytes, StringUtils.isEmpty(charset) ? Charset.defaultCharset() : Charset.forName(charset));
|
||||
}
|
||||
|
||||
|
@ -734,10 +698,9 @@ public class Convert {
|
|||
*
|
||||
* @param data 字符串
|
||||
* @param charset 字符集,如果此字段为空,则解码的结果取决于平台
|
||||
*
|
||||
* @return 解码后的字符串
|
||||
*/
|
||||
public static String str (byte[] data, Charset charset) {
|
||||
public static String str(byte[] data, Charset charset) {
|
||||
if (data == null) {
|
||||
return null;
|
||||
}
|
||||
|
@ -753,10 +716,9 @@ public class Convert {
|
|||
*
|
||||
* @param data 数据
|
||||
* @param charset 字符集,如果为空使用当前系统字符集
|
||||
*
|
||||
* @return 字符串
|
||||
*/
|
||||
public static String str (ByteBuffer data, String charset) {
|
||||
public static String str(ByteBuffer data, String charset) {
|
||||
if (data == null) {
|
||||
return null;
|
||||
}
|
||||
|
@ -769,10 +731,9 @@ public class Convert {
|
|||
*
|
||||
* @param data 数据
|
||||
* @param charset 字符集,如果为空使用当前系统字符集
|
||||
*
|
||||
* @return 字符串
|
||||
*/
|
||||
public static String str (ByteBuffer data, Charset charset) {
|
||||
public static String str(ByteBuffer data, Charset charset) {
|
||||
if (null == charset) {
|
||||
charset = Charset.defaultCharset();
|
||||
}
|
||||
|
@ -785,10 +746,9 @@ public class Convert {
|
|||
* 半角转全角
|
||||
*
|
||||
* @param input String.
|
||||
*
|
||||
* @return 全角字符串.
|
||||
*/
|
||||
public static String toSBC (String input) {
|
||||
public static String toSBC(String input) {
|
||||
return toSBC(input, null);
|
||||
}
|
||||
|
||||
|
@ -797,12 +757,11 @@ public class Convert {
|
|||
*
|
||||
* @param input String
|
||||
* @param notConvertSet 不替换的字符集合
|
||||
*
|
||||
* @return 全角字符串.
|
||||
*/
|
||||
public static String toSBC (String input, Set<Character> notConvertSet) {
|
||||
public static String toSBC(String input, Set<Character> notConvertSet) {
|
||||
char[] c = input.toCharArray();
|
||||
for (int i = 0 ; i < c.length ; i++) {
|
||||
for (int i = 0; i < c.length; i++) {
|
||||
if (null != notConvertSet && notConvertSet.contains(c[i])) {
|
||||
// 跳过不替换的字符
|
||||
continue;
|
||||
|
@ -822,10 +781,9 @@ public class Convert {
|
|||
* 全角转半角
|
||||
*
|
||||
* @param input String.
|
||||
*
|
||||
* @return 半角字符串
|
||||
*/
|
||||
public static String toDBC (String input) {
|
||||
public static String toDBC(String input) {
|
||||
return toDBC(input, null);
|
||||
}
|
||||
|
||||
|
@ -834,12 +792,11 @@ public class Convert {
|
|||
*
|
||||
* @param text 文本
|
||||
* @param notConvertSet 不替换的字符集合
|
||||
*
|
||||
* @return 替换后的字符
|
||||
*/
|
||||
public static String toDBC (String text, Set<Character> notConvertSet) {
|
||||
public static String toDBC(String text, Set<Character> notConvertSet) {
|
||||
char[] c = text.toCharArray();
|
||||
for (int i = 0 ; i < c.length ; i++) {
|
||||
for (int i = 0; i < c.length; i++) {
|
||||
if (null != notConvertSet && notConvertSet.contains(c[i])) {
|
||||
// 跳过不替换的字符
|
||||
continue;
|
||||
|
@ -860,10 +817,9 @@ public class Convert {
|
|||
* 数字金额大写转换 先写个完整的然后将如零拾替换成零
|
||||
*
|
||||
* @param n 数字
|
||||
*
|
||||
* @return 中文大写数字
|
||||
*/
|
||||
public static String digitUppercase (double n) {
|
||||
public static String digitUppercase(double n) {
|
||||
String[] fraction = {"角", "分"};
|
||||
String[] digit = {"零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖"};
|
||||
String[][] unit = {{"元", "万", "亿"}, {"", "拾", "佰", "仟"}};
|
||||
|
@ -872,7 +828,7 @@ public class Convert {
|
|||
n = Math.abs(n);
|
||||
|
||||
String s = "";
|
||||
for (int i = 0 ; i < fraction.length ; i++) {
|
||||
for (int i = 0; i < fraction.length; i++) {
|
||||
s += (digit[(int) (Math.floor(n * 10 * Math.pow(10, i)) % 10)] + fraction[i]).replaceAll("(零.)+", "");
|
||||
}
|
||||
if (s.length() < 1) {
|
||||
|
@ -880,9 +836,9 @@ public class Convert {
|
|||
}
|
||||
int integerPart = (int) Math.floor(n);
|
||||
|
||||
for (int i = 0 ; i < unit[0].length && integerPart > 0 ; i++) {
|
||||
for (int i = 0; i < unit[0].length && integerPart > 0; i++) {
|
||||
String p = "";
|
||||
for (int j = 0 ; j < unit[1].length && n > 0 ; j++) {
|
||||
for (int j = 0; j < unit[1].length && n > 0; j++) {
|
||||
p = digit[integerPart % 10] + unit[1][j] + p;
|
||||
integerPart = integerPart / 10;
|
||||
}
|
||||
|
|
|
@ -24,10 +24,9 @@ public class StrFormatter {
|
|||
*
|
||||
* @param strPattern 字符串模板
|
||||
* @param argArray 参数列表
|
||||
*
|
||||
* @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)) {
|
||||
return strPattern;
|
||||
}
|
||||
|
@ -38,7 +37,7 @@ public class StrFormatter {
|
|||
|
||||
int handledPosition = 0;
|
||||
int delimIndex;// 占位符所在位置
|
||||
for (int argIndex = 0 ; argIndex < argArray.length ; argIndex++) {
|
||||
for (int argIndex = 0; argIndex < argArray.length; argIndex++) {
|
||||
delimIndex = strPattern.indexOf(EMPTY_JSON, handledPosition);
|
||||
if (delimIndex == -1) {
|
||||
if (handledPosition == 0) {
|
||||
|
|
|
@ -22,11 +22,11 @@ public enum HttpMethod {
|
|||
}
|
||||
|
||||
@Nullable
|
||||
public static HttpMethod resolve (@Nullable String method) {
|
||||
public static HttpMethod resolve(@Nullable String method) {
|
||||
return (method != null ? mappings.get(method) : null);
|
||||
}
|
||||
|
||||
public boolean matches (String method) {
|
||||
public boolean matches(String method) {
|
||||
return (this == resolve(method));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,16 +11,16 @@ public enum UserStatus {
|
|||
private final String code;
|
||||
private final String info;
|
||||
|
||||
UserStatus (String code, String info) {
|
||||
UserStatus(String code, String info) {
|
||||
this.code = code;
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
public String getCode () {
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getInfo () {
|
||||
public String getInfo() {
|
||||
return info;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,6 @@ package com.ruoyi.common.exception;
|
|||
public class DemoModeException extends RuntimeException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public DemoModeException () {
|
||||
public DemoModeException() {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,28 +23,28 @@ public class GlobalException extends RuntimeException {
|
|||
/**
|
||||
* 空构造方法,避免反序列化问题
|
||||
*/
|
||||
public GlobalException () {
|
||||
public GlobalException() {
|
||||
}
|
||||
|
||||
public GlobalException (String message) {
|
||||
public GlobalException(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public String getDetailMessage () {
|
||||
public String getDetailMessage() {
|
||||
return detailMessage;
|
||||
}
|
||||
|
||||
public GlobalException setDetailMessage (String detailMessage) {
|
||||
public GlobalException setDetailMessage(String detailMessage) {
|
||||
this.detailMessage = detailMessage;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage () {
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public GlobalException setMessage (String message) {
|
||||
public GlobalException setMessage(String message) {
|
||||
this.message = message;
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
public ServiceException (String message, Integer code) {
|
||||
public ServiceException(String message, Integer code) {
|
||||
this.message = message;
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getDetailMessage () {
|
||||
public String getDetailMessage() {
|
||||
return detailMessage;
|
||||
}
|
||||
|
||||
public ServiceException setDetailMessage (String detailMessage) {
|
||||
public ServiceException setDetailMessage(String detailMessage) {
|
||||
this.detailMessage = detailMessage;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage () {
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public ServiceException setMessage (String message) {
|
||||
public ServiceException setMessage(String message) {
|
||||
this.message = message;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getCode () {
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,15 +8,15 @@ package com.ruoyi.common.exception;
|
|||
public class UtilException extends RuntimeException {
|
||||
private static final long serialVersionUID = 8247610319171014183L;
|
||||
|
||||
public UtilException (Throwable e) {
|
||||
public UtilException(Throwable e) {
|
||||
super(e.getMessage(), e);
|
||||
}
|
||||
|
||||
public UtilException (String message) {
|
||||
public UtilException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public UtilException (String message, Throwable throwable) {
|
||||
public UtilException(String message, Throwable throwable) {
|
||||
super(message, throwable);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,31 +31,31 @@ public class BaseException extends RuntimeException {
|
|||
*/
|
||||
private String defaultMessage;
|
||||
|
||||
public BaseException (String module, String code, Object[] args, String defaultMessage) {
|
||||
public BaseException(String module, String code, Object[] args, String defaultMessage) {
|
||||
this.module = module;
|
||||
this.code = code;
|
||||
this.args = args;
|
||||
this.defaultMessage = defaultMessage;
|
||||
}
|
||||
|
||||
public BaseException (String module, String code, Object[] args) {
|
||||
public BaseException(String module, String code, Object[] args) {
|
||||
this(module, code, args, null);
|
||||
}
|
||||
|
||||
public BaseException (String module, String defaultMessage) {
|
||||
public BaseException(String module, String defaultMessage) {
|
||||
this(module, null, null, defaultMessage);
|
||||
}
|
||||
|
||||
public BaseException (String code, Object[] args) {
|
||||
public BaseException(String code, Object[] args) {
|
||||
this(null, code, args, null);
|
||||
}
|
||||
|
||||
public BaseException (String defaultMessage) {
|
||||
public BaseException(String defaultMessage) {
|
||||
this(null, null, null, defaultMessage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage () {
|
||||
public String getMessage() {
|
||||
String message = null;
|
||||
if (!StringUtils.isEmpty(code)) {
|
||||
message = MessageUtils.message(code, args);
|
||||
|
@ -66,19 +66,19 @@ public class BaseException extends RuntimeException {
|
|||
return message;
|
||||
}
|
||||
|
||||
public String getModule () {
|
||||
public String getModule() {
|
||||
return module;
|
||||
}
|
||||
|
||||
public String getCode () {
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public Object[] getArgs () {
|
||||
public Object[] getArgs() {
|
||||
return args;
|
||||
}
|
||||
|
||||
public String getDefaultMessage () {
|
||||
public String getDefaultMessage() {
|
||||
return defaultMessage;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import com.ruoyi.common.exception.base.BaseException;
|
|||
public class FileException extends BaseException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public FileException (String code, Object[] args) {
|
||||
public FileException(String code, Object[] args) {
|
||||
super("file", code, args, null);
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ package com.ruoyi.common.exception.file;
|
|||
public class FileNameLengthLimitExceededException extends FileException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public FileNameLengthLimitExceededException (int defaultFileNameLength) {
|
||||
public FileNameLengthLimitExceededException(int defaultFileNameLength) {
|
||||
super("upload.filename.exceed.length", new Object[]{defaultFileNameLength});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ package com.ruoyi.common.exception.file;
|
|||
public class FileSizeLimitExceededException extends FileException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public FileSizeLimitExceededException (long defaultMaxSize) {
|
||||
public FileSizeLimitExceededException(long defaultMaxSize) {
|
||||
super("upload.exceed.maxSize", new Object[]{defaultMaxSize});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,21 +14,21 @@ public class FileUploadException extends Exception {
|
|||
|
||||
private final Throwable cause;
|
||||
|
||||
public FileUploadException () {
|
||||
public FileUploadException() {
|
||||
this(null, null);
|
||||
}
|
||||
|
||||
public FileUploadException (final String msg) {
|
||||
public FileUploadException(final String msg) {
|
||||
this(msg, null);
|
||||
}
|
||||
|
||||
public FileUploadException (String msg, Throwable cause) {
|
||||
public FileUploadException(String msg, Throwable cause) {
|
||||
super(msg);
|
||||
this.cause = cause;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printStackTrace (PrintStream stream) {
|
||||
public void printStackTrace(PrintStream stream) {
|
||||
super.printStackTrace(stream);
|
||||
if (cause != null) {
|
||||
stream.println("Caused by:");
|
||||
|
@ -37,7 +37,7 @@ public class FileUploadException extends Exception {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void printStackTrace (PrintWriter writer) {
|
||||
public void printStackTrace(PrintWriter writer) {
|
||||
super.printStackTrace(writer);
|
||||
if (cause != null) {
|
||||
writer.println("Caused by:");
|
||||
|
@ -46,7 +46,7 @@ public class FileUploadException extends Exception {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Throwable getCause () {
|
||||
public Throwable getCause() {
|
||||
return cause;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,29 +14,29 @@ public class InvalidExtensionException extends FileUploadException {
|
|||
private String extension;
|
||||
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) + "格式");
|
||||
this.allowedExtension = allowedExtension;
|
||||
this.extension = extension;
|
||||
this.filename = filename;
|
||||
}
|
||||
|
||||
public String[] getAllowedExtension () {
|
||||
public String[] getAllowedExtension() {
|
||||
return allowedExtension;
|
||||
}
|
||||
|
||||
public String getExtension () {
|
||||
public String getExtension() {
|
||||
return extension;
|
||||
}
|
||||
|
||||
public String getFilename () {
|
||||
public String getFilename() {
|
||||
return filename;
|
||||
}
|
||||
|
||||
public static class InvalidImageExtensionException extends InvalidExtensionException {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ public class InvalidExtensionException extends FileUploadException {
|
|||
public static class InvalidFlashExtensionException extends InvalidExtensionException {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ public class InvalidExtensionException extends FileUploadException {
|
|||
public static class InvalidMediaExtensionException extends InvalidExtensionException {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ public class InvalidExtensionException extends FileUploadException {
|
|||
public static class InvalidVideoExtensionException extends InvalidExtensionException {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,16 +10,16 @@ public class TaskException extends Exception {
|
|||
|
||||
private Code code;
|
||||
|
||||
public TaskException (String msg, Code code) {
|
||||
public TaskException(String msg, Code code) {
|
||||
this(msg, code, null);
|
||||
}
|
||||
|
||||
public TaskException (String msg, Code code, Exception nestedEx) {
|
||||
public TaskException(String msg, Code code, Exception nestedEx) {
|
||||
super(msg, nestedEx);
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public Code getCode () {
|
||||
public Code getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ package com.ruoyi.common.exception.user;
|
|||
public class BlackListException extends UserException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public BlackListException () {
|
||||
public BlackListException() {
|
||||
super("login.blocked", null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ package com.ruoyi.common.exception.user;
|
|||
public class CaptchaException extends UserException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public CaptchaException () {
|
||||
public CaptchaException() {
|
||||
super("user.jcaptcha.error", null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ package com.ruoyi.common.exception.user;
|
|||
public class CaptchaExpireException extends UserException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public CaptchaExpireException () {
|
||||
public CaptchaExpireException() {
|
||||
super("user.jcaptcha.expire", null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import com.ruoyi.common.exception.base.BaseException;
|
|||
public class UserException extends BaseException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public UserException (String code, Object[] args) {
|
||||
public UserException(String code, Object[] args) {
|
||||
super("user", code, args, null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ package com.ruoyi.common.exception.user;
|
|||
public class UserNotExistsException extends UserException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public UserNotExistsException () {
|
||||
public UserNotExistsException() {
|
||||
super("user.not.exists", null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ package com.ruoyi.common.exception.user;
|
|||
public class UserPasswordNotMatchException extends UserException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public UserPasswordNotMatchException () {
|
||||
public UserPasswordNotMatchException() {
|
||||
super("user.password.not.match", null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ package com.ruoyi.common.exception.user;
|
|||
public class UserPasswordRetryLimitExceedException extends UserException {
|
||||
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});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,11 +8,11 @@ import com.alibaba.fastjson2.filter.SimplePropertyPreFilter;
|
|||
* @author ruoyi
|
||||
*/
|
||||
public class PropertyPreExcludeFilter extends SimplePropertyPreFilter {
|
||||
public PropertyPreExcludeFilter () {
|
||||
public PropertyPreExcludeFilter() {
|
||||
}
|
||||
|
||||
public PropertyPreExcludeFilter addExcludes (String... filters) {
|
||||
for (int i = 0 ; i < filters.length ; i++) {
|
||||
public PropertyPreExcludeFilter addExcludes(String... filters) {
|
||||
for (int i = 0; i < filters.length; i++) {
|
||||
this.getExcludes().add(filters[i]);
|
||||
}
|
||||
return this;
|
||||
|
|
|
@ -14,12 +14,12 @@ import java.io.IOException;
|
|||
*/
|
||||
public class RepeatableFilter implements Filter {
|
||||
@Override
|
||||
public void init (FilterConfig filterConfig) throws ServletException {
|
||||
public void init(FilterConfig filterConfig) throws ServletException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doFilter (ServletRequest request, ServletResponse response, FilterChain chain)
|
||||
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
|
||||
throws IOException, ServletException {
|
||||
ServletRequest requestWrapper = null;
|
||||
if (request instanceof HttpServletRequest
|
||||
|
@ -34,7 +34,7 @@ public class RepeatableFilter implements Filter {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void destroy () {
|
||||
public void destroy() {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ import java.io.InputStreamReader;
|
|||
public class RepeatedlyRequestWrapper extends HttpServletRequestWrapper {
|
||||
private final byte[] body;
|
||||
|
||||
public RepeatedlyRequestWrapper (HttpServletRequest request, ServletResponse response) throws IOException {
|
||||
public RepeatedlyRequestWrapper(HttpServletRequest request, ServletResponse response) throws IOException {
|
||||
super(request);
|
||||
request.setCharacterEncoding(Constants.UTF8);
|
||||
response.setCharacterEncoding(Constants.UTF8);
|
||||
|
@ -30,36 +30,36 @@ public class RepeatedlyRequestWrapper extends HttpServletRequestWrapper {
|
|||
}
|
||||
|
||||
@Override
|
||||
public BufferedReader getReader () throws IOException {
|
||||
public BufferedReader getReader() throws IOException {
|
||||
return new BufferedReader(new InputStreamReader(getInputStream()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServletInputStream getInputStream () throws IOException {
|
||||
public ServletInputStream getInputStream() throws IOException {
|
||||
final ByteArrayInputStream bais = new ByteArrayInputStream(body);
|
||||
return new ServletInputStream() {
|
||||
@Override
|
||||
public int read () throws IOException {
|
||||
public int read() throws IOException {
|
||||
return bais.read();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int available () throws IOException {
|
||||
public int available() throws IOException {
|
||||
return body.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFinished () {
|
||||
public boolean isFinished() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReady () {
|
||||
public boolean isReady() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReadListener (ReadListener readListener) {
|
||||
public void setReadListener(ReadListener readListener) {
|
||||
|
||||
}
|
||||
};
|
||||
|
|
|
@ -22,18 +22,18 @@ public class XssFilter implements Filter {
|
|||
public List<String> excludes = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void init (FilterConfig filterConfig) throws ServletException {
|
||||
public void init(FilterConfig filterConfig) throws ServletException {
|
||||
String tempExcludes = filterConfig.getInitParameter("excludes");
|
||||
if (StringUtils.isNotEmpty(tempExcludes)) {
|
||||
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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doFilter (ServletRequest request, ServletResponse response, FilterChain chain)
|
||||
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
|
||||
throws IOException, ServletException {
|
||||
HttpServletRequest req = (HttpServletRequest) request;
|
||||
HttpServletResponse resp = (HttpServletResponse) response;
|
||||
|
@ -45,7 +45,7 @@ public class XssFilter implements Filter {
|
|||
chain.doFilter(xssRequest, response);
|
||||
}
|
||||
|
||||
private boolean handleExcludeURL (HttpServletRequest request, HttpServletResponse response) {
|
||||
private boolean handleExcludeURL(HttpServletRequest request, HttpServletResponse response) {
|
||||
String url = request.getServletPath();
|
||||
String method = request.getMethod();
|
||||
// GET DELETE 不过滤
|
||||
|
@ -56,7 +56,7 @@ public class XssFilter implements Filter {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void destroy () {
|
||||
public void destroy() {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,17 +22,17 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper {
|
|||
/**
|
||||
* @param request
|
||||
*/
|
||||
public XssHttpServletRequestWrapper (HttpServletRequest request) {
|
||||
public XssHttpServletRequestWrapper(HttpServletRequest request) {
|
||||
super(request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getParameterValues (String name) {
|
||||
public String[] getParameterValues(String name) {
|
||||
String[] values = super.getParameterValues(name);
|
||||
if (values != null) {
|
||||
int length = values.length;
|
||||
String[] escapesValues = new String[length];
|
||||
for (int i = 0 ; i < length ; i++) {
|
||||
for (int i = 0; i < length; i++) {
|
||||
// 防xss攻击和过滤前后空格
|
||||
escapesValues[i] = EscapeUtil.clean(values[i]).trim();
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ServletInputStream getInputStream () throws IOException {
|
||||
public ServletInputStream getInputStream() throws IOException {
|
||||
// 非json类型,直接返回
|
||||
if (!isJsonRequest()) {
|
||||
return super.getInputStream();
|
||||
|
@ -60,26 +60,26 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper {
|
|||
final ByteArrayInputStream bis = new ByteArrayInputStream(jsonBytes);
|
||||
return new ServletInputStream() {
|
||||
@Override
|
||||
public boolean isFinished () {
|
||||
public boolean isFinished() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReady () {
|
||||
public boolean isReady() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int available () throws IOException {
|
||||
public int available() throws IOException {
|
||||
return jsonBytes.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReadListener (ReadListener readListener) {
|
||||
public void setReadListener(ReadListener readListener) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read () throws IOException {
|
||||
public int read() throws IOException {
|
||||
return bis.read();
|
||||
}
|
||||
};
|
||||
|
@ -90,7 +90,7 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper {
|
|||
*
|
||||
* @param request
|
||||
*/
|
||||
public boolean isJsonRequest () {
|
||||
public boolean isJsonRequest() {
|
||||
String header = super.getHeader(HttpHeaders.CONTENT_TYPE);
|
||||
return StringUtils.startsWithIgnoreCase(header, MediaType.APPLICATION_JSON_VALUE);
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ public class Arith {
|
|||
/**
|
||||
* 这个类不能实例化
|
||||
*/
|
||||
private Arith () {
|
||||
private Arith() {
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -26,10 +26,9 @@ public class Arith {
|
|||
*
|
||||
* @param v1 被加数
|
||||
* @param v2 加数
|
||||
*
|
||||
* @return 两个参数的和
|
||||
*/
|
||||
public static double add (double v1, double v2) {
|
||||
public static double add(double v1, double v2) {
|
||||
BigDecimal b1 = new BigDecimal(Double.toString(v1));
|
||||
BigDecimal b2 = new BigDecimal(Double.toString(v2));
|
||||
return b1.add(b2).doubleValue();
|
||||
|
@ -40,10 +39,9 @@ public class Arith {
|
|||
*
|
||||
* @param v1 被减数
|
||||
* @param v2 减数
|
||||
*
|
||||
* @return 两个参数的差
|
||||
*/
|
||||
public static double sub (double v1, double v2) {
|
||||
public static double sub(double v1, double v2) {
|
||||
BigDecimal b1 = new BigDecimal(Double.toString(v1));
|
||||
BigDecimal b2 = new BigDecimal(Double.toString(v2));
|
||||
return b1.subtract(b2).doubleValue();
|
||||
|
@ -54,10 +52,9 @@ public class Arith {
|
|||
*
|
||||
* @param v1 被乘数
|
||||
* @param v2 乘数
|
||||
*
|
||||
* @return 两个参数的积
|
||||
*/
|
||||
public static double mul (double v1, double v2) {
|
||||
public static double mul(double v1, double v2) {
|
||||
BigDecimal b1 = new BigDecimal(Double.toString(v1));
|
||||
BigDecimal b2 = new BigDecimal(Double.toString(v2));
|
||||
return b1.multiply(b2).doubleValue();
|
||||
|
@ -69,10 +66,9 @@ public class Arith {
|
|||
*
|
||||
* @param v1 被除数
|
||||
* @param v2 除数
|
||||
*
|
||||
* @return 两个参数的商
|
||||
*/
|
||||
public static double div (double v1, double v2) {
|
||||
public static double div(double v1, double v2) {
|
||||
return div(v1, v2, DEF_DIV_SCALE);
|
||||
}
|
||||
|
||||
|
@ -83,10 +79,9 @@ public class Arith {
|
|||
* @param v1 被除数
|
||||
* @param v2 除数
|
||||
* @param scale 表示表示需要精确到小数点以后几位。
|
||||
*
|
||||
* @return 两个参数的商
|
||||
*/
|
||||
public static double div (double v1, double v2, int scale) {
|
||||
public static double div(double v1, double v2, int scale) {
|
||||
if (scale < 0) {
|
||||
throw new IllegalArgumentException(
|
||||
"The scale must be a positive integer or zero");
|
||||
|
@ -104,10 +99,9 @@ public class Arith {
|
|||
*
|
||||
* @param v 需要四舍五入的数字
|
||||
* @param scale 小数点后保留几位
|
||||
*
|
||||
* @return 四舍五入后的结果
|
||||
*/
|
||||
public static double round (double v, int scale) {
|
||||
public static double round(double v, int scale) {
|
||||
if (scale < 0) {
|
||||
throw new IllegalArgumentException(
|
||||
"The scale must be a positive integer or zero");
|
||||
|
|
|
@ -34,7 +34,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
|
|||
*
|
||||
* @return Date() 当前日期
|
||||
*/
|
||||
public static Date getNowDate () {
|
||||
public static Date getNowDate() {
|
||||
return new Date();
|
||||
}
|
||||
|
||||
|
@ -43,31 +43,31 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
|
|||
*
|
||||
* @return String
|
||||
*/
|
||||
public static String getDate () {
|
||||
public static String getDate() {
|
||||
return dateTimeNow(YYYY_MM_DD);
|
||||
}
|
||||
|
||||
public static final String getTime () {
|
||||
public static final String getTime() {
|
||||
return dateTimeNow(YYYY_MM_DD_HH_MM_SS);
|
||||
}
|
||||
|
||||
public static final String dateTimeNow () {
|
||||
public static final String dateTimeNow() {
|
||||
return dateTimeNow(YYYYMMDDHHMMSS);
|
||||
}
|
||||
|
||||
public static final String dateTimeNow (final String format) {
|
||||
public static final String dateTimeNow(final String format) {
|
||||
return parseDateToStr(format, new Date());
|
||||
}
|
||||
|
||||
public static final String dateTime (final Date date) {
|
||||
public static final String dateTime(final Date date) {
|
||||
return parseDateToStr(YYYY_MM_DD, date);
|
||||
}
|
||||
|
||||
public static final String parseDateToStr (final String format, final Date date) {
|
||||
public static final String parseDateToStr(final String format, final Date date) {
|
||||
return new SimpleDateFormat(format).format(date);
|
||||
}
|
||||
|
||||
public static final Date dateTime (final String format, final String ts) {
|
||||
public static final Date dateTime(final String format, final String ts) {
|
||||
try {
|
||||
return new SimpleDateFormat(format).parse(ts);
|
||||
} catch (ParseException e) {
|
||||
|
@ -78,7 +78,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
|
|||
/**
|
||||
* 日期路径 即年/月/日 如2018/08/08
|
||||
*/
|
||||
public static final String datePath () {
|
||||
public static final String datePath() {
|
||||
Date now = new Date();
|
||||
return DateFormatUtils.format(now, "yyyy/MM/dd");
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
|
|||
/**
|
||||
* 日期路径 即年/月/日 如20180808
|
||||
*/
|
||||
public static final String dateTime () {
|
||||
public static final String dateTime() {
|
||||
Date now = new Date();
|
||||
return DateFormatUtils.format(now, "yyyyMMdd");
|
||||
}
|
||||
|
@ -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) {
|
||||
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();
|
||||
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)));
|
||||
}
|
||||
|
||||
|
@ -125,10 +125,9 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
|
|||
*
|
||||
* @param endDate 最后时间
|
||||
* @param startTime 开始时间
|
||||
*
|
||||
* @return 时间差(天/小时/分钟)
|
||||
*/
|
||||
public static String timeDistance (Date endDate, Date startTime) {
|
||||
public static String timeDistance(Date endDate, Date startTime) {
|
||||
long nd = 1000 * 24 * 60 * 60;
|
||||
long nh = 1000 * 60 * 60;
|
||||
long nm = 1000 * 60;
|
||||
|
@ -149,7 +148,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
|
|||
/**
|
||||
* 增加 LocalDateTime ==> Date
|
||||
*/
|
||||
public static Date toDate (LocalDateTime temporalAccessor) {
|
||||
public static Date toDate(LocalDateTime temporalAccessor) {
|
||||
ZonedDateTime zdt = temporalAccessor.atZone(ZoneId.systemDefault());
|
||||
return Date.from(zdt.toInstant());
|
||||
}
|
||||
|
@ -157,7 +156,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
|
|||
/**
|
||||
* 增加 LocalDate ==> Date
|
||||
*/
|
||||
public static Date toDate (LocalDate temporalAccessor) {
|
||||
public static Date toDate(LocalDate temporalAccessor) {
|
||||
LocalDateTime localDateTime = LocalDateTime.of(temporalAccessor, LocalTime.of(0, 0, 0));
|
||||
ZonedDateTime zdt = localDateTime.atZone(ZoneId.systemDefault());
|
||||
return Date.from(zdt.toInstant());
|
||||
|
|
|
@ -26,7 +26,7 @@ public class DictUtils {
|
|||
* @param key 参数键
|
||||
* @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);
|
||||
}
|
||||
|
||||
|
@ -34,10 +34,9 @@ public class DictUtils {
|
|||
* 获取字典缓存
|
||||
*
|
||||
* @param key 参数键
|
||||
*
|
||||
* @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));
|
||||
if (StringUtils.isNotNull(arrayCache)) {
|
||||
return arrayCache.toList(SysDictData.class);
|
||||
|
@ -50,10 +49,9 @@ public class DictUtils {
|
|||
*
|
||||
* @param dictType 字典类型
|
||||
* @param dictValue 字典值
|
||||
*
|
||||
* @return 字典标签
|
||||
*/
|
||||
public static String getDictLabel (String dictType, String dictValue) {
|
||||
public static String getDictLabel(String dictType, String dictValue) {
|
||||
return getDictLabel(dictType, dictValue, SEPARATOR);
|
||||
}
|
||||
|
||||
|
@ -62,10 +60,9 @@ public class DictUtils {
|
|||
*
|
||||
* @param dictType 字典类型
|
||||
* @param dictLabel 字典标签
|
||||
*
|
||||
* @return 字典值
|
||||
*/
|
||||
public static String getDictValue (String dictType, String dictLabel) {
|
||||
public static String getDictValue(String dictType, String dictLabel) {
|
||||
return getDictValue(dictType, dictLabel, SEPARATOR);
|
||||
}
|
||||
|
||||
|
@ -75,10 +72,9 @@ public class DictUtils {
|
|||
* @param dictType 字典类型
|
||||
* @param dictValue 字典值
|
||||
* @param separator 分隔符
|
||||
*
|
||||
* @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();
|
||||
List<SysDictData> datas = getDictCache(dictType);
|
||||
|
||||
|
@ -109,10 +105,9 @@ public class DictUtils {
|
|||
* @param dictType 字典类型
|
||||
* @param dictLabel 字典标签
|
||||
* @param separator 分隔符
|
||||
*
|
||||
* @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();
|
||||
List<SysDictData> datas = getDictCache(dictType);
|
||||
|
||||
|
@ -140,14 +135,14 @@ public class DictUtils {
|
|||
*
|
||||
* @param key 字典键
|
||||
*/
|
||||
public static void removeDictCache (String key) {
|
||||
public static void removeDictCache(String 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 + "*");
|
||||
SpringUtils.getBean(RedisCache.class).deleteObject(keys);
|
||||
}
|
||||
|
@ -156,10 +151,9 @@ public class DictUtils {
|
|||
* 设置cache key
|
||||
*
|
||||
* @param configKey 参数键
|
||||
*
|
||||
* @return 缓存键key
|
||||
*/
|
||||
public static String getCacheKey (String configKey) {
|
||||
public static String getCacheKey(String configKey) {
|
||||
return CacheConstants.SYS_DICT_KEY + configKey;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,13 +14,13 @@ public class ExceptionUtil {
|
|||
/**
|
||||
* 获取exception的详细错误信息。
|
||||
*/
|
||||
public static String getExceptionMessage (Throwable e) {
|
||||
public static String getExceptionMessage(Throwable e) {
|
||||
StringWriter sw = new StringWriter();
|
||||
e.printStackTrace(new PrintWriter(sw, true));
|
||||
return sw.toString();
|
||||
}
|
||||
|
||||
public static String getRootErrorMessage (Exception e) {
|
||||
public static String getRootErrorMessage(Exception e) {
|
||||
Throwable root = ExceptionUtils.getRootCause(e);
|
||||
root = (root == null ? e : root);
|
||||
if (root == null) {
|
||||
|
|
|
@ -6,7 +6,7 @@ package com.ruoyi.common.utils;
|
|||
* @author ruoyi
|
||||
*/
|
||||
public class LogUtils {
|
||||
public static String getBlock (Object msg) {
|
||||
public static String getBlock(Object msg) {
|
||||
if (msg == null) {
|
||||
msg = "";
|
||||
}
|
||||
|
|
|
@ -15,10 +15,9 @@ public class MessageUtils {
|
|||
*
|
||||
* @param code 消息键
|
||||
* @param args 参数
|
||||
*
|
||||
* @return 获取国际化翻译值
|
||||
*/
|
||||
public static String message (String code, Object... args) {
|
||||
public static String message(String code, Object... args) {
|
||||
MessageSource messageSource = SpringUtils.getBean(MessageSource.class);
|
||||
return messageSource.getMessage(code, args, LocaleContextHolder.getLocale());
|
||||
}
|
||||
|
|
|
@ -17,49 +17,56 @@ public class ObjUtils {
|
|||
* Array: 如果长度为零,则认为为空。
|
||||
* Collection: 如果元素为零,则认为为空。
|
||||
* Map: 如果键值映射为零,则认为为空。
|
||||
*
|
||||
* @param o 对象
|
||||
* @return 如果对象具有受支持的类型并且为空或null,则为true,否则为false
|
||||
*/
|
||||
public static boolean notNull(Object o){
|
||||
public static boolean notNull(Object o) {
|
||||
return ObjectUtils.isNotEmpty(o);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断long类型不为0
|
||||
*
|
||||
* @param val 值
|
||||
* @return 返回值不为0
|
||||
*/
|
||||
public static boolean notNull(Long val){
|
||||
return ObjectUtils.isNotEmpty(val) && val != 0;
|
||||
public static boolean notNull(Long val) {
|
||||
return ObjectUtils.isNotEmpty(val) && val != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断Integer类型不为0
|
||||
*
|
||||
* @param val 值
|
||||
* @return 返回值不为0
|
||||
*/
|
||||
public static boolean notNull(Integer val){
|
||||
return ObjectUtils.isNotEmpty(val) && val != 0;
|
||||
public static boolean notNull(Integer val) {
|
||||
return ObjectUtils.isNotEmpty(val) && val != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断BigDecimal类型不为0
|
||||
*
|
||||
* @param val 值
|
||||
* @return 返回值不为0
|
||||
*/
|
||||
public static boolean notNull(BigDecimal val){
|
||||
return ObjectUtils.isNotEmpty(val) && val.doubleValue() == 0.00;
|
||||
public static boolean notNull(BigDecimal val) {
|
||||
return ObjectUtils.isNotEmpty(val) && val.doubleValue() == 0.00;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断BigDecimal类型不为0
|
||||
*
|
||||
* @param val 值
|
||||
* @return 返回值不为0
|
||||
*/
|
||||
public static boolean notChildNull(Object[] val){
|
||||
public static boolean notChildNull(Object[] val) {
|
||||
for (Object o : val) {
|
||||
if (!notNull(o)){
|
||||
if (!notNull(o)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ public class PageUtils extends PageHelper {
|
|||
/**
|
||||
* 设置请求分页数据
|
||||
*/
|
||||
public static void startPage () {
|
||||
public static void startPage() {
|
||||
PageDomain pageDomain = TableSupport.buildPageRequest();
|
||||
Integer pageNum = pageDomain.getPageNum();
|
||||
Integer pageSize = pageDomain.getPageSize();
|
||||
|
@ -26,7 +26,7 @@ public class PageUtils extends PageHelper {
|
|||
/**
|
||||
* 清理分页的线程变量
|
||||
*/
|
||||
public static void clearPage () {
|
||||
public static void clearPage() {
|
||||
PageHelper.clearPage();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ public class SecurityUtils {
|
|||
/**
|
||||
* 用户ID
|
||||
**/
|
||||
public static Long getUserId () {
|
||||
public static Long getUserId() {
|
||||
try {
|
||||
return getLoginUser().getUserId();
|
||||
} catch (Exception e) {
|
||||
|
@ -27,7 +27,7 @@ public class SecurityUtils {
|
|||
/**
|
||||
* 获取部门ID
|
||||
**/
|
||||
public static Long getDeptId () {
|
||||
public static Long getDeptId() {
|
||||
try {
|
||||
return getLoginUser().getDeptId();
|
||||
} catch (Exception e) {
|
||||
|
@ -38,7 +38,7 @@ public class SecurityUtils {
|
|||
/**
|
||||
* 获取用户账户
|
||||
**/
|
||||
public static String getUsername () {
|
||||
public static String getUsername() {
|
||||
try {
|
||||
return getLoginUser().getUsername();
|
||||
} catch (Exception e) {
|
||||
|
@ -49,7 +49,7 @@ public class SecurityUtils {
|
|||
/**
|
||||
* 获取用户
|
||||
**/
|
||||
public static LoginUser getLoginUser () {
|
||||
public static LoginUser getLoginUser() {
|
||||
try {
|
||||
return (LoginUser) getAuthentication().getPrincipal();
|
||||
} catch (Exception e) {
|
||||
|
@ -60,7 +60,7 @@ public class SecurityUtils {
|
|||
/**
|
||||
* 获取Authentication
|
||||
*/
|
||||
public static Authentication getAuthentication () {
|
||||
public static Authentication getAuthentication() {
|
||||
return SecurityContextHolder.getContext().getAuthentication();
|
||||
}
|
||||
|
||||
|
@ -68,10 +68,9 @@ public class SecurityUtils {
|
|||
* 生成BCryptPasswordEncoder密码
|
||||
*
|
||||
* @param password 密码
|
||||
*
|
||||
* @return 加密字符串
|
||||
*/
|
||||
public static String encryptPassword (String password) {
|
||||
public static String encryptPassword(String password) {
|
||||
BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
|
||||
return passwordEncoder.encode(password);
|
||||
}
|
||||
|
@ -81,10 +80,9 @@ public class SecurityUtils {
|
|||
*
|
||||
* @param rawPassword 真实密码
|
||||
* @param encodedPassword 加密后字符
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
public static boolean matchesPassword (String rawPassword, String encodedPassword) {
|
||||
public static boolean matchesPassword(String rawPassword, String encodedPassword) {
|
||||
BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
|
||||
return passwordEncoder.matches(rawPassword, encodedPassword);
|
||||
}
|
||||
|
@ -93,10 +91,9 @@ public class SecurityUtils {
|
|||
* 是否为管理员
|
||||
*
|
||||
* @param userId 用户ID
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
public static boolean isAdmin (Long userId) {
|
||||
public static boolean isAdmin(Long userId) {
|
||||
return userId != null && 1L == userId;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,42 +27,42 @@ public class ServletUtils {
|
|||
/**
|
||||
* 获取String参数
|
||||
*/
|
||||
public static String getParameter (String name) {
|
||||
public static String getParameter(String name) {
|
||||
return getRequest().getParameter(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取String参数
|
||||
*/
|
||||
public static String getParameter (String name, String defaultValue) {
|
||||
public static String getParameter(String name, String defaultValue) {
|
||||
return Convert.toStr(getRequest().getParameter(name), defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Integer参数
|
||||
*/
|
||||
public static Integer getParameterToInt (String name) {
|
||||
public static Integer getParameterToInt(String name) {
|
||||
return Convert.toInt(getRequest().getParameter(name));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Integer参数
|
||||
*/
|
||||
public static Integer getParameterToInt (String name, Integer defaultValue) {
|
||||
public static Integer getParameterToInt(String name, Integer defaultValue) {
|
||||
return Convert.toInt(getRequest().getParameter(name), defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Boolean参数
|
||||
*/
|
||||
public static Boolean getParameterToBool (String name) {
|
||||
public static Boolean getParameterToBool(String name) {
|
||||
return Convert.toBool(getRequest().getParameter(name));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Boolean参数
|
||||
*/
|
||||
public static Boolean getParameterToBool (String name, Boolean defaultValue) {
|
||||
public static Boolean getParameterToBool(String name, Boolean defaultValue) {
|
||||
return Convert.toBool(getRequest().getParameter(name), defaultValue);
|
||||
}
|
||||
|
||||
|
@ -70,10 +70,9 @@ public class ServletUtils {
|
|||
* 获得所有请求参数
|
||||
*
|
||||
* @param request 请求对象{@link ServletRequest}
|
||||
*
|
||||
* @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();
|
||||
return Collections.unmodifiableMap(map);
|
||||
}
|
||||
|
@ -82,10 +81,9 @@ public class ServletUtils {
|
|||
* 获得所有请求参数
|
||||
*
|
||||
* @param request 请求对象{@link ServletRequest}
|
||||
*
|
||||
* @return Map
|
||||
*/
|
||||
public static Map<String, String> getParamMap (ServletRequest request) {
|
||||
public static Map<String, String> getParamMap(ServletRequest request) {
|
||||
Map<String, String> params = new HashMap<>();
|
||||
for (Map.Entry<String, String[]> entry : getParams(request).entrySet()) {
|
||||
params.put(entry.getKey(), StringUtils.join(entry.getValue(), ","));
|
||||
|
@ -96,25 +94,25 @@ public class ServletUtils {
|
|||
/**
|
||||
* 获取request
|
||||
*/
|
||||
public static HttpServletRequest getRequest () {
|
||||
public static HttpServletRequest getRequest() {
|
||||
return getRequestAttributes().getRequest();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取response
|
||||
*/
|
||||
public static HttpServletResponse getResponse () {
|
||||
public static HttpServletResponse getResponse() {
|
||||
return getRequestAttributes().getResponse();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取session
|
||||
*/
|
||||
public static HttpSession getSession () {
|
||||
public static HttpSession getSession() {
|
||||
return getRequest().getSession();
|
||||
}
|
||||
|
||||
public static ServletRequestAttributes getRequestAttributes () {
|
||||
public static ServletRequestAttributes getRequestAttributes() {
|
||||
RequestAttributes attributes = RequestContextHolder.getRequestAttributes();
|
||||
return (ServletRequestAttributes) attributes;
|
||||
}
|
||||
|
@ -125,7 +123,7 @@ public class ServletUtils {
|
|||
* @param response 渲染对象
|
||||
* @param string 待渲染的字符串
|
||||
*/
|
||||
public static void renderString (HttpServletResponse response, String string) {
|
||||
public static void renderString(HttpServletResponse response, String string) {
|
||||
try {
|
||||
response.setStatus(200);
|
||||
response.setContentType("application/json");
|
||||
|
@ -141,7 +139,7 @@ public class ServletUtils {
|
|||
*
|
||||
* @param request
|
||||
*/
|
||||
public static boolean isAjaxRequest (HttpServletRequest request) {
|
||||
public static boolean isAjaxRequest(HttpServletRequest request) {
|
||||
String accept = request.getHeader("accept");
|
||||
if (accept != null && accept.contains("application/json")) {
|
||||
return true;
|
||||
|
@ -165,10 +163,9 @@ public class ServletUtils {
|
|||
* 内容编码
|
||||
*
|
||||
* @param str 内容
|
||||
*
|
||||
* @return 编码后的内容
|
||||
*/
|
||||
public static String urlEncode (String str) {
|
||||
public static String urlEncode(String str) {
|
||||
try {
|
||||
return URLEncoder.encode(str, Constants.UTF8);
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
|
@ -180,10 +177,9 @@ public class ServletUtils {
|
|||
* 内容解码
|
||||
*
|
||||
* @param str 内容
|
||||
*
|
||||
* @return 解码后的内容
|
||||
*/
|
||||
public static String urlDecode (String str) {
|
||||
public static String urlDecode(String str) {
|
||||
try {
|
||||
return URLDecoder.decode(str, Constants.UTF8);
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
|
|
|
@ -26,10 +26,9 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
|||
* 获取参数不为空值
|
||||
*
|
||||
* @param value defaultValue 要判断的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;
|
||||
}
|
||||
|
||||
|
@ -37,10 +36,9 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
|||
* * 判断一个Collection是否为空, 包含List,Set,Queue
|
||||
*
|
||||
* @param coll 要判断的Collection
|
||||
*
|
||||
* @return true:为空 false:非空
|
||||
*/
|
||||
public static boolean isEmpty (Collection<?> coll) {
|
||||
public static boolean isEmpty(Collection<?> coll) {
|
||||
return isNull(coll) || coll.isEmpty();
|
||||
}
|
||||
|
||||
|
@ -48,10 +46,9 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
|||
* * 判断一个Collection是否非空,包含List,Set,Queue
|
||||
*
|
||||
* @param coll 要判断的Collection
|
||||
*
|
||||
* @return true:非空 false:空
|
||||
*/
|
||||
public static boolean isNotEmpty (Collection<?> coll) {
|
||||
public static boolean isNotEmpty(Collection<?> coll) {
|
||||
return !isEmpty(coll);
|
||||
}
|
||||
|
||||
|
@ -61,7 +58,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
|||
* @param objects 要判断的对象数组
|
||||
* * @return true:为空 false:非空
|
||||
*/
|
||||
public static boolean isEmpty (Object[] objects) {
|
||||
public static boolean isEmpty(Object[] objects) {
|
||||
return isNull(objects) || (objects.length == 0);
|
||||
}
|
||||
|
||||
|
@ -69,10 +66,9 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
|||
* * 判断一个对象数组是否非空
|
||||
*
|
||||
* @param objects 要判断的对象数组
|
||||
*
|
||||
* @return true:非空 false:空
|
||||
*/
|
||||
public static boolean isNotEmpty (Object[] objects) {
|
||||
public static boolean isNotEmpty(Object[] objects) {
|
||||
return !isEmpty(objects);
|
||||
}
|
||||
|
||||
|
@ -80,10 +76,9 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
|||
* * 判断一个Map是否为空
|
||||
*
|
||||
* @param map 要判断的Map
|
||||
*
|
||||
* @return true:为空 false:非空
|
||||
*/
|
||||
public static boolean isEmpty (Map<?, ?> map) {
|
||||
public static boolean isEmpty(Map<?, ?> map) {
|
||||
return isNull(map) || map.isEmpty();
|
||||
}
|
||||
|
||||
|
@ -91,10 +86,9 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
|||
* * 判断一个Map是否为空
|
||||
*
|
||||
* @param map 要判断的Map
|
||||
*
|
||||
* @return true:非空 false:空
|
||||
*/
|
||||
public static boolean isNotEmpty (Map<?, ?> map) {
|
||||
public static boolean isNotEmpty(Map<?, ?> map) {
|
||||
return !isEmpty(map);
|
||||
}
|
||||
|
||||
|
@ -102,10 +96,9 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
|||
* * 判断一个字符串是否为空串
|
||||
*
|
||||
* @param str String
|
||||
*
|
||||
* @return true:为空 false:非空
|
||||
*/
|
||||
public static boolean isEmpty (String str) {
|
||||
public static boolean isEmpty(String str) {
|
||||
return isNull(str) || NULLSTR.equals(str.trim());
|
||||
}
|
||||
|
||||
|
@ -113,10 +106,9 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
|||
* * 判断一个字符串是否为非空串
|
||||
*
|
||||
* @param str String
|
||||
*
|
||||
* @return true:非空串 false:空串
|
||||
*/
|
||||
public static boolean isNotEmpty (String str) {
|
||||
public static boolean isNotEmpty(String str) {
|
||||
return !isEmpty(str);
|
||||
}
|
||||
|
||||
|
@ -124,10 +116,9 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
|||
* * 判断一个对象是否为空
|
||||
*
|
||||
* @param object Object
|
||||
*
|
||||
* @return true:为空 false:非空
|
||||
*/
|
||||
public static boolean isNull (Object object) {
|
||||
public static boolean isNull(Object object) {
|
||||
return object == null;
|
||||
}
|
||||
|
||||
|
@ -135,10 +126,9 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
|||
* * 判断一个对象是否非空
|
||||
*
|
||||
* @param object Object
|
||||
*
|
||||
* @return true:非空 false:空
|
||||
*/
|
||||
public static boolean isNotNull (Object object) {
|
||||
public static boolean isNotNull(Object object) {
|
||||
return !isNull(object);
|
||||
}
|
||||
|
||||
|
@ -146,17 +136,16 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
|||
* * 判断一个对象是否是数组类型(Java基本型别的数组)
|
||||
*
|
||||
* @param object 对象
|
||||
*
|
||||
* @return true:是数组 false:不是数组
|
||||
*/
|
||||
public static boolean isArray (Object object) {
|
||||
public static boolean isArray(Object object) {
|
||||
return isNotNull(object) && object.getClass().isArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* 去空格
|
||||
*/
|
||||
public static String trim (String str) {
|
||||
public static String trim(String str) {
|
||||
return (str == null ? "" : str.trim());
|
||||
}
|
||||
|
||||
|
@ -165,10 +154,9 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
|||
*
|
||||
* @param str 字符串
|
||||
* @param start 开始
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
public static String substring (final String str, int start) {
|
||||
public static String substring(final String str, int start) {
|
||||
if (str == null) {
|
||||
return NULLSTR;
|
||||
}
|
||||
|
@ -193,10 +181,9 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
|||
* @param str 字符串
|
||||
* @param start 开始
|
||||
* @param end 结束
|
||||
*
|
||||
* @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) {
|
||||
return NULLSTR;
|
||||
}
|
||||
|
@ -237,10 +224,9 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
|||
*
|
||||
* @param template 文本模板,被替换的部分用 {} 表示
|
||||
* @param params 参数值
|
||||
*
|
||||
* @return 格式化后的文本
|
||||
*/
|
||||
public static String format (String template, Object... params) {
|
||||
public static String format(String template, Object... params) {
|
||||
if (isEmpty(params) || isEmpty(template)) {
|
||||
return template;
|
||||
}
|
||||
|
@ -251,10 +237,9 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
|||
* 是否为http(s)://开头
|
||||
*
|
||||
* @param link 链接
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
public static boolean ishttp (String link) {
|
||||
public static boolean ishttp(String link) {
|
||||
return StringUtils.startsWithAny(link, Constants.HTTP, Constants.HTTPS);
|
||||
}
|
||||
|
||||
|
@ -263,10 +248,9 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
|||
*
|
||||
* @param str 字符串
|
||||
* @param sep 分隔符
|
||||
*
|
||||
* @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));
|
||||
}
|
||||
|
||||
|
@ -277,10 +261,9 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
|||
* @param sep 分隔符
|
||||
* @param filterBlank 过滤纯空白
|
||||
* @param trim 去掉首尾空白
|
||||
*
|
||||
* @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>();
|
||||
if (StringUtils.isEmpty(str)) {
|
||||
return list;
|
||||
|
@ -309,10 +292,9 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
|||
*
|
||||
* @param collection 给定的集合
|
||||
* @param array 给定的数组
|
||||
*
|
||||
* @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)) {
|
||||
return false;
|
||||
} else {
|
||||
|
@ -330,10 +312,9 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
|||
*
|
||||
* @param cs 指定字符串
|
||||
* @param searchCharSequences 需要检查的字符串数组
|
||||
*
|
||||
* @return 是否包含任意一个字符串
|
||||
*/
|
||||
public static boolean containsAnyIgnoreCase (CharSequence cs, CharSequence... searchCharSequences) {
|
||||
public static boolean containsAnyIgnoreCase(CharSequence cs, CharSequence... searchCharSequences) {
|
||||
if (isEmpty(cs) || isEmpty(searchCharSequences)) {
|
||||
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) {
|
||||
return null;
|
||||
}
|
||||
|
@ -359,7 +340,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
|||
boolean curreCharIsUpperCase = 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);
|
||||
if (i > 0) {
|
||||
preCharIsUpperCase = Character.isUpperCase(str.charAt(i - 1));
|
||||
|
@ -389,10 +370,9 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
|||
*
|
||||
* @param str 验证字符串
|
||||
* @param strs 字符串组
|
||||
*
|
||||
* @return 包含返回true
|
||||
*/
|
||||
public static boolean inStringIgnoreCase (String str, String... strs) {
|
||||
public static boolean inStringIgnoreCase(String str, String... strs) {
|
||||
if (str != null && strs != null) {
|
||||
for (String s : strs) {
|
||||
if (str.equalsIgnoreCase(trim(s))) {
|
||||
|
@ -407,10 +387,9 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
|||
* 将下划线大写方式命名的字符串转换为驼峰式。如果转换前的下划线大写方式命名的字符串为空,则返回空字符串。 例如:HELLO_WORLD->HelloWorld
|
||||
*
|
||||
* @param name 转换前的下划线大写方式命名的字符串
|
||||
*
|
||||
* @return 转换后的驼峰式命名的字符串
|
||||
*/
|
||||
public static String convertToCamelCase (String name) {
|
||||
public static String convertToCamelCase(String name) {
|
||||
StringBuilder result = new StringBuilder();
|
||||
// 快速检查
|
||||
if (name == null || name.isEmpty()) {
|
||||
|
@ -438,7 +417,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
|||
* 驼峰式命名法
|
||||
* 例如:user_name->userName
|
||||
*/
|
||||
public static String toCamelCase (String s) {
|
||||
public static String toCamelCase(String s) {
|
||||
if (s == null) {
|
||||
return null;
|
||||
}
|
||||
|
@ -448,7 +427,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
|||
s = s.toLowerCase();
|
||||
StringBuilder sb = new StringBuilder(s.length());
|
||||
boolean upperCase = false;
|
||||
for (int i = 0 ; i < s.length() ; i++) {
|
||||
for (int i = 0; i < s.length(); i++) {
|
||||
char c = s.charAt(i);
|
||||
|
||||
if (c == SEPARATOR) {
|
||||
|
@ -468,10 +447,9 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
|||
*
|
||||
* @param str 指定字符串
|
||||
* @param strs 需要检查的字符串数组
|
||||
*
|
||||
* @return 是否匹配
|
||||
*/
|
||||
public static boolean matches (String str, List<String> strs) {
|
||||
public static boolean matches(String str, List<String> strs) {
|
||||
if (isEmpty(str) || isEmpty(strs)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -491,16 +469,15 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
|||
*
|
||||
* @param pattern 匹配规则
|
||||
* @param url 需要匹配的url
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static boolean isMatch (String pattern, String url) {
|
||||
public static boolean isMatch(String pattern, String url) {
|
||||
AntPathMatcher matcher = new AntPathMatcher();
|
||||
return matcher.match(pattern, url);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> T cast (Object obj) {
|
||||
public static <T> T cast(Object obj) {
|
||||
return (T) obj;
|
||||
}
|
||||
|
||||
|
@ -509,10 +486,9 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
|||
*
|
||||
* @param num 数字对象
|
||||
* @param size 字符串指定长度
|
||||
*
|
||||
* @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');
|
||||
}
|
||||
|
||||
|
@ -522,15 +498,14 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
|||
* @param s 原始字符串
|
||||
* @param size 字符串指定长度
|
||||
* @param c 用于补齐的字符
|
||||
*
|
||||
* @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);
|
||||
if (s != null) {
|
||||
final int len = s.length();
|
||||
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(s);
|
||||
|
@ -538,7 +513,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
|||
return s.substring(len - size, len);
|
||||
}
|
||||
} else {
|
||||
for (int i = size ; i > 0 ; i--) {
|
||||
for (int i = size; i > 0; i--) {
|
||||
sb.append(c);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ public class Threads {
|
|||
/**
|
||||
* sleep等待,单位为毫秒
|
||||
*/
|
||||
public static void sleep (long milliseconds) {
|
||||
public static void sleep(long milliseconds) {
|
||||
try {
|
||||
Thread.sleep(milliseconds);
|
||||
} catch (InterruptedException e) {
|
||||
|
@ -31,7 +31,7 @@ public class Threads {
|
|||
* 如果仍然超時,則強制退出.
|
||||
* 另对在shutdown时线程本身被调用中断做了处理.
|
||||
*/
|
||||
public static void shutdownAndAwaitTermination (ExecutorService pool) {
|
||||
public static void shutdownAndAwaitTermination(ExecutorService pool) {
|
||||
if (pool != null && !pool.isShutdown()) {
|
||||
pool.shutdown();
|
||||
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<?>) {
|
||||
try {
|
||||
Future<?> future = (Future<?>) r;
|
||||
|
|
|
@ -33,7 +33,7 @@ public class BeanUtils extends org.springframework.beans.BeanUtils {
|
|||
* @param dest 目标对象
|
||||
* @param src 源对象
|
||||
*/
|
||||
public static void copyBeanProp (Object dest, Object src) {
|
||||
public static void copyBeanProp(Object dest, Object src) {
|
||||
try {
|
||||
copyProperties(src, dest);
|
||||
} catch (Exception e) {
|
||||
|
@ -45,10 +45,9 @@ public class BeanUtils extends org.springframework.beans.BeanUtils {
|
|||
* 获取对象的setter方法。
|
||||
*
|
||||
* @param obj 对象
|
||||
*
|
||||
* @return 对象的setter方法列表
|
||||
*/
|
||||
public static List<Method> getSetterMethods (Object obj) {
|
||||
public static List<Method> getSetterMethods(Object obj) {
|
||||
// setter方法列表
|
||||
List<Method> setterMethods = new ArrayList<Method>();
|
||||
|
||||
|
@ -71,11 +70,10 @@ public class BeanUtils extends org.springframework.beans.BeanUtils {
|
|||
* 获取对象的getter方法。
|
||||
*
|
||||
* @param obj 对象
|
||||
*
|
||||
* @return 对象的getter方法列表
|
||||
*/
|
||||
|
||||
public static List<Method> getGetterMethods (Object obj) {
|
||||
public static List<Method> getGetterMethods(Object obj) {
|
||||
// getter方法列表
|
||||
List<Method> getterMethods = new ArrayList<Method>();
|
||||
// 获取所有方法
|
||||
|
@ -97,11 +95,10 @@ public class BeanUtils extends org.springframework.beans.BeanUtils {
|
|||
*
|
||||
* @param m1 方法名1
|
||||
* @param m2 方法名2
|
||||
*
|
||||
* @return 属性名一样返回true,否则返回false
|
||||
*/
|
||||
|
||||
public static boolean isMethodPropEquals (String m1, String m2) {
|
||||
public static boolean isMethodPropEquals(String m1, String m2) {
|
||||
return m1.substring(BEAN_METHOD_PROP_INDEX).equals(m2.substring(BEAN_METHOD_PROP_INDEX));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ import java.util.Set;
|
|||
* @author ruoyi
|
||||
*/
|
||||
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 {
|
||||
Set<ConstraintViolation<Object>> constraintViolations = validator.validate(object, groups);
|
||||
if (!constraintViolations.isEmpty()) {
|
||||
|
|
|
@ -16,10 +16,9 @@ public class FileTypeUtils {
|
|||
* 例如: ruoyi.txt, 返回: txt
|
||||
*
|
||||
* @param file 文件名
|
||||
*
|
||||
* @return 后缀(不含".")
|
||||
*/
|
||||
public static String getFileType (File file) {
|
||||
public static String getFileType(File file) {
|
||||
if (null == file) {
|
||||
return StringUtils.EMPTY;
|
||||
}
|
||||
|
@ -32,10 +31,9 @@ public class FileTypeUtils {
|
|||
* 例如: ruoyi.txt, 返回: txt
|
||||
*
|
||||
* @param fileName 文件名
|
||||
*
|
||||
* @return 后缀(不含".")
|
||||
*/
|
||||
public static String getFileType (String fileName) {
|
||||
public static String getFileType(String fileName) {
|
||||
int separatorIndex = fileName.lastIndexOf(".");
|
||||
if (separatorIndex < 0) {
|
||||
return "";
|
||||
|
@ -47,10 +45,9 @@ public class FileTypeUtils {
|
|||
* 获取文件类型
|
||||
*
|
||||
* @param photoByte 文件字节码
|
||||
*
|
||||
* @return 后缀(不含".")
|
||||
*/
|
||||
public static String getFileExtendName (byte[] photoByte) {
|
||||
public static String getFileExtendName(byte[] photoByte) {
|
||||
String strFileExtendName = "JPG";
|
||||
if ((photoByte[0] == 71) && (photoByte[1] == 73) && (photoByte[2] == 70) && (photoByte[3] == 56)
|
||||
&& ((photoByte[4] == 55) || (photoByte[4] == 57)) && (photoByte[5] == 97)) {
|
||||
|
|
|
@ -37,11 +37,11 @@ public class FileUploadUtils {
|
|||
*/
|
||||
private static String defaultBaseDir = RuoYiConfig.getProfile();
|
||||
|
||||
public static String getDefaultBaseDir () {
|
||||
public static String getDefaultBaseDir() {
|
||||
return defaultBaseDir;
|
||||
}
|
||||
|
||||
public static void setDefaultBaseDir (String defaultBaseDir) {
|
||||
public static void setDefaultBaseDir(String defaultBaseDir) {
|
||||
FileUploadUtils.defaultBaseDir = defaultBaseDir;
|
||||
}
|
||||
|
||||
|
@ -49,12 +49,10 @@ public class FileUploadUtils {
|
|||
* 以默认配置进行文件上传
|
||||
*
|
||||
* @param file 上传的文件
|
||||
*
|
||||
* @return 文件名称
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public static final String upload (MultipartFile file) throws IOException {
|
||||
public static final String upload(MultipartFile file) throws IOException {
|
||||
try {
|
||||
return upload(getDefaultBaseDir(), file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION);
|
||||
} catch (Exception e) {
|
||||
|
@ -67,12 +65,10 @@ public class FileUploadUtils {
|
|||
*
|
||||
* @param baseDir 相对应用的基目录
|
||||
* @param file 上传的文件
|
||||
*
|
||||
* @return 文件名称
|
||||
*
|
||||
* @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 {
|
||||
return upload(baseDir, file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION);
|
||||
} catch (Exception e) {
|
||||
|
@ -86,15 +82,13 @@ public class FileUploadUtils {
|
|||
* @param baseDir 相对应用的基目录
|
||||
* @param file 上传的文件
|
||||
* @param allowedExtension 上传文件类型
|
||||
*
|
||||
* @return 返回上传成功的文件名
|
||||
*
|
||||
* @throws FileSizeLimitExceededException 如果超出最大大小
|
||||
* @throws FileNameLengthLimitExceededException 文件名太长
|
||||
* @throws IOException 比如读写文件出错时
|
||||
* @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,
|
||||
InvalidExtensionException {
|
||||
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(),
|
||||
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);
|
||||
|
||||
if (!desc.exists()) {
|
||||
|
@ -130,7 +124,7 @@ public class FileUploadUtils {
|
|||
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;
|
||||
String currentDir = StringUtils.substring(uploadDir, dirLastIndex);
|
||||
return Constants.RESOURCE_PREFIX + "/" + currentDir + "/" + fileName;
|
||||
|
@ -140,13 +134,11 @@ public class FileUploadUtils {
|
|||
* 文件大小校验
|
||||
*
|
||||
* @param file 上传的文件
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @throws FileSizeLimitExceededException 如果超出最大大小
|
||||
* @throws InvalidExtensionException
|
||||
*/
|
||||
public static final void assertAllowed (MultipartFile file, String[] allowedExtension)
|
||||
public static final void assertAllowed(MultipartFile file, String[] allowedExtension)
|
||||
throws FileSizeLimitExceededException, InvalidExtensionException {
|
||||
long size = file.getSize();
|
||||
if (size > DEFAULT_MAX_SIZE) {
|
||||
|
@ -179,10 +171,9 @@ public class FileUploadUtils {
|
|||
*
|
||||
* @param extension
|
||||
* @param allowedExtension
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static final boolean isAllowedExtension (String extension, String[] allowedExtension) {
|
||||
public static final boolean isAllowedExtension(String extension, String[] allowedExtension) {
|
||||
for (String str : allowedExtension) {
|
||||
if (str.equalsIgnoreCase(extension)) {
|
||||
return true;
|
||||
|
@ -195,10 +186,9 @@ public class FileUploadUtils {
|
|||
* 获取文件名的后缀
|
||||
*
|
||||
* @param file 表单文件
|
||||
*
|
||||
* @return 后缀名
|
||||
*/
|
||||
public static final String getExtension (MultipartFile file) {
|
||||
public static final String getExtension(MultipartFile file) {
|
||||
String extension = FilenameUtils.getExtension(file.getOriginalFilename());
|
||||
if (StringUtils.isEmpty(extension)) {
|
||||
extension = MimeTypeUtils.getExtension(Objects.requireNonNull(file.getContentType()));
|
||||
|
|
|
@ -27,10 +27,9 @@ public class FileUtils {
|
|||
*
|
||||
* @param filePath 文件路径
|
||||
* @param os 输出流
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static void writeBytes (String filePath, OutputStream os) throws IOException {
|
||||
public static void writeBytes(String filePath, OutputStream os) throws IOException {
|
||||
FileInputStream fis = null;
|
||||
try {
|
||||
File file = new File(filePath);
|
||||
|
@ -55,12 +54,10 @@ public class FileUtils {
|
|||
* 写数据到文件中
|
||||
*
|
||||
* @param data 数据
|
||||
*
|
||||
* @return 目标文件
|
||||
*
|
||||
* @throws IOException IO异常
|
||||
*/
|
||||
public static String writeImportBytes (byte[] data) throws IOException {
|
||||
public static String writeImportBytes(byte[] data) throws IOException {
|
||||
return writeBytes(data, RuoYiConfig.getImportPath());
|
||||
}
|
||||
|
||||
|
@ -69,12 +66,10 @@ public class FileUtils {
|
|||
*
|
||||
* @param data 数据
|
||||
* @param uploadDir 目标文件
|
||||
*
|
||||
* @return 目标文件
|
||||
*
|
||||
* @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;
|
||||
String pathName = "";
|
||||
try {
|
||||
|
@ -93,10 +88,9 @@ public class FileUtils {
|
|||
* 删除文件
|
||||
*
|
||||
* @param filePath 文件
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static boolean deleteFile (String filePath) {
|
||||
public static boolean deleteFile(String filePath) {
|
||||
boolean flag = false;
|
||||
File file = new File(filePath);
|
||||
// 路径为文件且不为空则进行删除
|
||||
|
@ -110,10 +104,9 @@ public class FileUtils {
|
|||
* 文件名称验证
|
||||
*
|
||||
* @param filename 文件名称
|
||||
*
|
||||
* @return true 正常 false 非法
|
||||
*/
|
||||
public static boolean isValidFilename (String filename) {
|
||||
public static boolean isValidFilename(String filename) {
|
||||
return filename.matches(FILENAME_PATTERN);
|
||||
}
|
||||
|
||||
|
@ -121,10 +114,9 @@ public class FileUtils {
|
|||
* 检查文件是否可下载
|
||||
*
|
||||
* @param resource 需要下载的文件
|
||||
*
|
||||
* @return true 正常 false 非法
|
||||
*/
|
||||
public static boolean checkAllowDownload (String resource) {
|
||||
public static boolean checkAllowDownload(String resource) {
|
||||
// 禁止目录上跳级别
|
||||
if (StringUtils.contains(resource, "..")) {
|
||||
return false;
|
||||
|
@ -144,10 +136,9 @@ public class FileUtils {
|
|||
*
|
||||
* @param request 请求对象
|
||||
* @param fileName 文件名
|
||||
*
|
||||
* @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");
|
||||
String filename = fileName;
|
||||
if (agent.contains("MSIE")) {
|
||||
|
@ -173,7 +164,7 @@ public class FileUtils {
|
|||
* @param response 响应对象
|
||||
* @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);
|
||||
|
||||
StringBuilder contentDispositionValue = new StringBuilder();
|
||||
|
@ -193,10 +184,9 @@ public class FileUtils {
|
|||
* 百分号编码工具方法
|
||||
*
|
||||
* @param s 需要百分号编码的字符串
|
||||
*
|
||||
* @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());
|
||||
return encode.replaceAll("\\+", "%20");
|
||||
}
|
||||
|
@ -205,10 +195,9 @@ public class FileUtils {
|
|||
* 获取图像后缀
|
||||
*
|
||||
* @param photoByte 图像数据
|
||||
*
|
||||
* @return 后缀名
|
||||
*/
|
||||
public static String getFileExtendName (byte[] photoByte) {
|
||||
public static String getFileExtendName(byte[] photoByte) {
|
||||
String strFileExtendName = "jpg";
|
||||
if ((photoByte[0] == 71) && (photoByte[1] == 73) && (photoByte[2] == 70) && (photoByte[3] == 56)
|
||||
&& ((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
|
||||
*
|
||||
* @param fileName 路径名称
|
||||
*
|
||||
* @return 没有文件路径的名称
|
||||
*/
|
||||
public static String getName (String fileName) {
|
||||
public static String getName(String fileName) {
|
||||
if (fileName == null) {
|
||||
return null;
|
||||
}
|
||||
|
@ -244,10 +232,9 @@ public class FileUtils {
|
|||
* 获取不带后缀文件名称 /profile/upload/2022/04/16/ruoyi.png -- ruoyi
|
||||
*
|
||||
* @param fileName 路径名称
|
||||
*
|
||||
* @return 没有文件路径和后缀的名称
|
||||
*/
|
||||
public static String getNameNotSuffix (String fileName) {
|
||||
public static String getNameNotSuffix(String fileName) {
|
||||
if (fileName == null) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ import java.util.Arrays;
|
|||
public class ImageUtils {
|
||||
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);
|
||||
try {
|
||||
return IOUtils.toByteArray(is);
|
||||
|
@ -34,7 +34,7 @@ public class ImageUtils {
|
|||
}
|
||||
}
|
||||
|
||||
public static InputStream getFile (String imagePath) {
|
||||
public static InputStream getFile(String imagePath) {
|
||||
try {
|
||||
byte[] result = readFile(imagePath);
|
||||
result = Arrays.copyOf(result, result.length);
|
||||
|
@ -49,10 +49,9 @@ public class ImageUtils {
|
|||
* 读取文件为字节数据
|
||||
*
|
||||
* @param url 地址
|
||||
*
|
||||
* @return 字节数据
|
||||
*/
|
||||
public static byte[] readFile (String url) {
|
||||
public static byte[] readFile(String url) {
|
||||
InputStream in = null;
|
||||
try {
|
||||
if (url.startsWith("http")) {
|
||||
|
|
|
@ -37,7 +37,7 @@ public class MimeTypeUtils {
|
|||
// pdf
|
||||
"pdf"};
|
||||
|
||||
public static String getExtension (String prefix) {
|
||||
public static String getExtension(String prefix) {
|
||||
switch (prefix) {
|
||||
case IMAGE_PNG:
|
||||
return "png";
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue