| | |
| | | import com.ruoyi.common.constant.Constants; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.enums.CaptchaType; |
| | | import com.ruoyi.common.utils.redis.RedisUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.redis.RedisUtils; |
| | | import com.ruoyi.common.utils.reflect.ReflectUtils; |
| | | import com.ruoyi.common.utils.spring.SpringUtils; |
| | | import com.ruoyi.framework.config.properties.CaptchaProperties; |
| | |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | |
| | | * @author Lion Li |
| | | */ |
| | | @Api(value = "验证码操作处理", tags = {"验证码管理"}) |
| | | @RequiredArgsConstructor(onConstructor_ = @Autowired) |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | public class CaptchaController { |
| | | |
| | |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.redis.connection.RedisServerCommands; |
| | | import org.springframework.data.redis.core.RedisCallback; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | |
| | | * @author Lion Li |
| | | */ |
| | | @Api(value = "缓存监控", tags = {"缓存监控管理"}) |
| | | @RequiredArgsConstructor(onConstructor_ = @Autowired) |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/monitor/cache") |
| | | public class CacheController { |
| | |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | |
| | | */ |
| | | @Validated |
| | | @Api(value = "系统访问记录", tags = {"系统访问记录管理"}) |
| | | @RequiredArgsConstructor(onConstructor_ = @Autowired) |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/monitor/logininfor") |
| | | public class SysLogininforController extends BaseController { |
| | |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | |
| | | */ |
| | | @Validated |
| | | @Api(value = "操作日志记录", tags = {"操作日志记录管理"}) |
| | | @RequiredArgsConstructor(onConstructor_ = @Autowired) |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/monitor/operlog") |
| | | public class SysOperlogController extends BaseController { |
| | |
| | | |
| | | import cn.dev33.satoken.annotation.SaCheckPermission; |
| | | import cn.dev33.satoken.exception.NotLoginException; |
| | | import cn.dev33.satoken.stp.StpLogic; |
| | | import cn.dev33.satoken.stp.StpUtil; |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import com.ruoyi.common.annotation.Log; |
| | |
| | | import com.ruoyi.common.core.domain.dto.UserOnlineDTO; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.utils.redis.RedisUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.redis.RedisUtils; |
| | | import com.ruoyi.system.domain.SysUserOnline; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.ArrayList; |
| | |
| | | * @author Lion Li |
| | | */ |
| | | @Api(value = "在线用户监控", tags = {"在线用户监控管理"}) |
| | | @RequiredArgsConstructor(onConstructor_ = @Autowired) |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/monitor/online") |
| | | public class SysUserOnlineController extends BaseController { |
| | |
| | | ).collect(Collectors.toList()); |
| | | } else if (StringUtils.isNotEmpty(ipaddr)) { |
| | | userOnlineDTOList = userOnlineDTOList.stream().filter(userOnline -> |
| | | StringUtils.equals(ipaddr, userOnline.getIpaddr())) |
| | | StringUtils.equals(ipaddr, userOnline.getIpaddr())) |
| | | .collect(Collectors.toList()); |
| | | } else if (StringUtils.isNotEmpty(userName)) { |
| | | userOnlineDTOList = userOnlineDTOList.stream().filter(userOnline -> |
| | |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | |
| | | */ |
| | | @Validated |
| | | @Api(value = "参数配置控制器", tags = {"参数配置管理"}) |
| | | @RequiredArgsConstructor(onConstructor_ = @Autowired) |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/system/config") |
| | | public class SysConfigController extends BaseController { |
| | |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | |
| | | */ |
| | | @Validated |
| | | @Api(value = "部门控制器", tags = {"部门管理"}) |
| | | @RequiredArgsConstructor(onConstructor_ = @Autowired) |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/system/dept") |
| | | public class SysDeptController extends BaseController { |
| | |
| | | public AjaxResult<List<SysDept>> excludeChild(@ApiParam("部门ID") @PathVariable(value = "deptId", required = false) Long deptId) { |
| | | List<SysDept> depts = deptService.selectDeptList(new SysDept()); |
| | | depts.removeIf(d -> d.getDeptId().equals(deptId) |
| | | || ArrayUtil.contains(StringUtils.split(d.getAncestors(), ","), deptId + "")); |
| | | || ArrayUtil.contains(StringUtils.split(d.getAncestors(), ","), deptId + "")); |
| | | return AjaxResult.success(depts); |
| | | } |
| | | |
| | |
| | | } else if (dept.getParentId().equals(dept.getDeptId())) { |
| | | return AjaxResult.error("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己"); |
| | | } else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus()) |
| | | && deptService.selectNormalChildrenDeptById(dept.getDeptId()) > 0) { |
| | | && deptService.selectNormalChildrenDeptById(dept.getDeptId()) > 0) { |
| | | return AjaxResult.error("该部门包含未停用的子部门!"); |
| | | } |
| | | return toAjax(deptService.updateDept(dept)); |
| | |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | |
| | | */ |
| | | @Validated |
| | | @Api(value = "数据字典信息控制器", tags = {"数据字典信息管理"}) |
| | | @RequiredArgsConstructor(onConstructor_ = @Autowired) |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/system/dict/data") |
| | | public class SysDictDataController extends BaseController { |
| | |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | |
| | | */ |
| | | @Validated |
| | | @Api(value = "数据字典信息控制器", tags = {"数据字典信息管理"}) |
| | | @RequiredArgsConstructor(onConstructor_ = @Autowired) |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/system/dict/type") |
| | | public class SysDictTypeController extends BaseController { |
| | |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | |
| | | * @author Lion Li |
| | | */ |
| | | @Api(value = "首页控制器", tags = {"首页管理"}) |
| | | @RequiredArgsConstructor(onConstructor_ = @Autowired) |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | public class SysIndexController { |
| | | |
| | |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | |
| | | */ |
| | | @Validated |
| | | @Api(value = "登录验证控制器", tags = {"登录验证管理"}) |
| | | @RequiredArgsConstructor(onConstructor_ = @Autowired) |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | public class SysLoginController { |
| | | |
| | |
| | | Map<String, Object> ajax = new HashMap<>(); |
| | | // 生成令牌 |
| | | String token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(), |
| | | loginBody.getUuid()); |
| | | loginBody.getUuid()); |
| | | ajax.put(Constants.TOKEN, token); |
| | | return AjaxResult.success(ajax); |
| | | } |
| | | |
| | | @ApiOperation("登出方法") |
| | | @PostMapping("/logout") |
| | | public AjaxResult<Void> logout(){ |
| | | public AjaxResult<Void> logout() { |
| | | try { |
| | | StpUtil.logout(); |
| | | } catch (NotLoginException e) { |
| | |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | |
| | | */ |
| | | @Validated |
| | | @Api(value = "菜单信息控制器", tags = {"菜单信息管理"}) |
| | | @RequiredArgsConstructor(onConstructor_ = @Autowired) |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/system/menu") |
| | | public class SysMenuController extends BaseController { |
| | |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.system.domain.SysNotice; |
| | | import com.ruoyi.system.service.ISysNoticeService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | /** |
| | | * 公告 信息操作处理 |
| | |
| | | */ |
| | | @Validated |
| | | @Api(value = "公告信息控制器", tags = {"公告信息管理"}) |
| | | @RequiredArgsConstructor(onConstructor_ = @Autowired) |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/system/notice") |
| | | public class SysNoticeController extends BaseController { |
| | |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | |
| | | */ |
| | | @Validated |
| | | @Api(value = "对象存储配置控制器", tags = {"对象存储配置管理"}) |
| | | @RequiredArgsConstructor(onConstructor_ = @Autowired) |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/system/oss/config") |
| | | public class SysOssConfigController extends BaseController { |
| | |
| | | import com.ruoyi.system.service.ISysOssService; |
| | | import io.swagger.annotations.*; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | |
| | | */ |
| | | @Validated |
| | | @Api(value = "OSS对象存储控制器", tags = {"OSS对象存储管理"}) |
| | | @RequiredArgsConstructor(onConstructor_ = @Autowired) |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/system/oss") |
| | | public class SysOssController extends BaseController { |
| | |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | |
| | | */ |
| | | @Validated |
| | | @Api(value = "岗位信息控制器", tags = {"岗位信息管理"}) |
| | | @RequiredArgsConstructor(onConstructor_ = @Autowired) |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/system/post") |
| | | public class SysPostController extends BaseController { |
| | |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | |
| | | */ |
| | | @Validated |
| | | @Api(value = "个人信息控制器", tags = {"个人信息管理"}) |
| | | @RequiredArgsConstructor(onConstructor_ = @Autowired) |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/system/user/profile") |
| | | public class SysProfileController extends BaseController { |
| | |
| | | @PutMapping |
| | | public AjaxResult<Void> updateProfile(@RequestBody SysUser user) { |
| | | if (StringUtils.isNotEmpty(user.getPhonenumber()) |
| | | && UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user))) { |
| | | && UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user))) { |
| | | return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,手机号码已存在"); |
| | | } |
| | | if (StringUtils.isNotEmpty(user.getEmail()) |
| | | && UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user))) { |
| | | && UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user))) { |
| | | return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在"); |
| | | } |
| | | user.setUserId(getUserId()); |
| | |
| | | @Log(title = "用户头像", businessType = BusinessType.UPDATE) |
| | | @PostMapping("/avatar") |
| | | public AjaxResult<Map<String, Object>> avatar(@RequestPart("avatarfile") MultipartFile file) { |
| | | Map<String,Object> ajax = new HashMap<>(); |
| | | Map<String, Object> ajax = new HashMap<>(); |
| | | if (!file.isEmpty()) { |
| | | SysOss oss = iSysOssService.upload(file); |
| | | String avatar = oss.getUrl(); |
| | |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | |
| | | */ |
| | | @Validated |
| | | @Api(value = "注册验证控制器", tags = {"注册验证管理"}) |
| | | @RequiredArgsConstructor(onConstructor_ = @Autowired) |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | public class SysRegisterController extends BaseController { |
| | | |
| | |
| | | import com.ruoyi.system.service.SysPermissionService; |
| | | import io.swagger.annotations.*; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | |
| | | */ |
| | | @Validated |
| | | @Api(value = "角色信息控制器", tags = {"角色信息管理"}) |
| | | @RequiredArgsConstructor(onConstructor_ = @Autowired) |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/system/role") |
| | | public class SysRoleController extends BaseController { |
| | |
| | | import com.ruoyi.system.service.ISysUserService; |
| | | import io.swagger.annotations.*; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | |
| | | */ |
| | | @Validated |
| | | @Api(value = "用户信息控制器", tags = {"用户信息管理"}) |
| | | @RequiredArgsConstructor(onConstructor_ = @Autowired) |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/system/user") |
| | | public class SysUserController extends BaseController { |
| | |
| | | |
| | | @ApiOperation("导入用户列表") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "file", value = "导入文件", dataType = "java.io.File", required = true), |
| | | @ApiImplicitParam(name = "file", value = "导入文件", dataType = "java.io.File", required = true), |
| | | }) |
| | | @Log(title = "用户管理", businessType = BusinessType.IMPORT) |
| | | @SaCheckPermission("system:user:import") |
| | |
| | | */ |
| | | @ApiOperation("根据用户编号获取详细信息") |
| | | @SaCheckPermission("system:user:query") |
| | | @GetMapping(value = {"/", "/{userId}" }) |
| | | @GetMapping(value = {"/", "/{userId}"}) |
| | | public AjaxResult<Map<String, Object>> getInfo(@ApiParam("用户ID") @PathVariable(value = "userId", required = false) Long userId) { |
| | | userService.checkUserDataScope(userId); |
| | | Map<String, Object> ajax = new HashMap<>(); |
| | |
| | | if (UserConstants.NOT_UNIQUE.equals(userService.checkUserNameUnique(user.getUserName()))) { |
| | | return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,登录账号已存在"); |
| | | } else if (StringUtils.isNotEmpty(user.getPhonenumber()) |
| | | && UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user))) { |
| | | && UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user))) { |
| | | return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,手机号码已存在"); |
| | | } else if (StringUtils.isNotEmpty(user.getEmail()) |
| | | && UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user))) { |
| | | && UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user))) { |
| | | return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,邮箱账号已存在"); |
| | | } |
| | | user.setPassword(SecurityUtils.encryptPassword(user.getPassword())); |
| | |
| | | public AjaxResult<Void> edit(@Validated @RequestBody SysUser user) { |
| | | userService.checkUserAllowed(user); |
| | | if (StringUtils.isNotEmpty(user.getPhonenumber()) |
| | | && UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user))) { |
| | | && UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user))) { |
| | | return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,手机号码已存在"); |
| | | } else if (StringUtils.isNotEmpty(user.getEmail()) |
| | | && UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user))) { |
| | | && UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user))) { |
| | | return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在"); |
| | | } |
| | | return toAjax(userService.updateUser(user)); |
| | |
| | | |
| | | /** |
| | | * 数据脱敏注解 |
| | | * |
| | | * @author zhujie |
| | | */ |
| | | @Retention(RetentionPolicy.RUNTIME) |
| | |
| | | |
| | | private static final long serialVersionUID = -5514819971774091076L; |
| | | |
| | | private static final String operators = "+-*"; |
| | | private static final String OPERATORS = "+-*"; |
| | | |
| | | /** |
| | | * 参与计算数字最大长度 |
| | |
| | | number1 = StringUtils.rightPad(number1, this.numberLength, CharUtil.SPACE); |
| | | number2 = StringUtils.rightPad(number2, this.numberLength, CharUtil.SPACE); |
| | | |
| | | return number1 + RandomUtil.randomChar(operators) + number2 + '='; |
| | | return number1 + RandomUtil.randomChar(OPERATORS) + number2 + '='; |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | /** |
| | | * 数据权限类型 |
| | | * |
| | | * <p> |
| | | * 语法支持 spel 模板表达式 |
| | | * |
| | | * <p> |
| | | * 内置数据 user 当前用户 内容参考 SysUser |
| | | * 如需扩展数据 可使用 {@link com.ruoyi.common.helper.DataPermissionHelper} 操作 |
| | | * 内置服务 sdss 系统数据权限服务 内容参考 SysDataScopeService |
| | |
| | | /** |
| | | * 仅本人数据权限 |
| | | */ |
| | | SELF("5", " #{#userName} = #{#user.userId} " , " 1 = 0 "); |
| | | SELF("5", " #{#userName} = #{#user.userId} ", " 1 = 0 "); |
| | | |
| | | private final String code; |
| | | |
| | |
| | | |
| | | import com.ruoyi.common.utils.MessageUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import lombok.*; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import lombok.NoArgsConstructor; |
| | | |
| | | /** |
| | | * 基础异常 |
| | |
| | | |
| | | @Override |
| | | public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) |
| | | throws IOException, ServletException { |
| | | throws IOException, ServletException { |
| | | ServletRequest requestWrapper = null; |
| | | if (request instanceof HttpServletRequest |
| | | && StringUtils.startsWithIgnoreCase(request.getContentType(), MediaType.APPLICATION_JSON_VALUE)) { |
| | | && StringUtils.startsWithIgnoreCase(request.getContentType(), MediaType.APPLICATION_JSON_VALUE)) { |
| | | requestWrapper = new RepeatedlyRequestWrapper((HttpServletRequest) request, response); |
| | | } |
| | | if (null == requestWrapper) { |
| | |
| | | |
| | | @Override |
| | | public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) |
| | | throws IOException, ServletException { |
| | | throws IOException, ServletException { |
| | | HttpServletRequest req = (HttpServletRequest) request; |
| | | HttpServletResponse resp = (HttpServletResponse) response; |
| | | if (handleExcludeURL(req, resp)) { |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | public static void setVariable(String key, Object value) { |
| | | Map<String, Object> context = getContext(); |
| | | context.put(key, value); |
| | |
| | | |
| | | /** |
| | | * 数据脱敏json序列化工具 |
| | | * |
| | | * @author Yjoioooo |
| | | */ |
| | | public class SensitiveJsonSerializer extends JsonSerializer<String> implements ContextualSerializer { |
| | |
| | | @Override |
| | | public void serialize(String value, JsonGenerator gen, SerializerProvider serializers) throws IOException { |
| | | SensitiveService sensitiveService = SpringUtils.getBean(SensitiveService.class); |
| | | if (sensitiveService.isSensitive()){ |
| | | if (sensitiveService.isSensitive()) { |
| | | gen.writeString(value); |
| | | } else { |
| | | gen.writeString(strategy.desensitizer().apply(value)); |
| | |
| | | @Override |
| | | public JsonSerializer<?> createContextual(SerializerProvider prov, BeanProperty property) throws JsonMappingException { |
| | | Sensitive annotation = property.getAnnotation(Sensitive.class); |
| | | if (Objects.nonNull(annotation)&&Objects.equals(String.class, property.getType().getRawClass())) { |
| | | if (Objects.nonNull(annotation) && Objects.equals(String.class, property.getType().getRawClass())) { |
| | | this.strategy = annotation.strategy(); |
| | | return this; |
| | | } |
| | |
| | | public static String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss"; |
| | | |
| | | private static String[] parsePatterns = { |
| | | "yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM", |
| | | "yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM", |
| | | "yyyy.MM.dd", "yyyy.MM.dd HH:mm:ss", "yyyy.MM.dd HH:mm", "yyyy.MM"}; |
| | | "yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM", |
| | | "yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM", |
| | | "yyyy.MM.dd", "yyyy.MM.dd HH:mm:ss", "yyyy.MM.dd HH:mm", "yyyy.MM"}; |
| | | |
| | | /** |
| | | * 获取当前Date型日期 |
| | |
| | | import com.ruoyi.common.enums.DeviceType; |
| | | import com.ruoyi.common.enums.UserType; |
| | | import com.ruoyi.common.exception.UtilException; |
| | | import lombok.AccessLevel; |
| | | import lombok.NoArgsConstructor; |
| | | |
| | | /** |
| | | * 登录鉴权工具 |
| | |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @NoArgsConstructor(access = AccessLevel.PRIVATE) |
| | | public class LoginUtils { |
| | | |
| | | private final static String LOGIN_USER_KEY = "loginUser"; |
| | | private static final String LOGIN_USER_KEY = "loginUser"; |
| | | |
| | | /** |
| | | * 登录系统 |
| | | * 针对两套用户体系 |
| | | * |
| | | * @param loginUser 登录用户信息 |
| | | */ |
| | | public static void login(LoginUser loginUser, UserType userType) { |
| | |
| | | /** |
| | | * 登录系统 基于 设备类型 |
| | | * 针对一套用户体系 |
| | | * |
| | | * @param loginUser 登录用户信息 |
| | | */ |
| | | public static void loginByDevice(LoginUser loginUser, UserType userType, DeviceType deviceType) { |
| | |
| | | String replace = ""; |
| | | if (StringUtils.contains(loginId, UserType.SYS_USER.getUserType())) { |
| | | userId = StringUtils.replace(loginId, UserType.SYS_USER.getUserType(), replace); |
| | | } else if (StringUtils.contains(loginId, UserType.APP_USER.getUserType())){ |
| | | } else if (StringUtils.contains(loginId, UserType.APP_USER.getUserType())) { |
| | | userId = StringUtils.replace(loginId, UserType.APP_USER.getUserType(), replace); |
| | | } else { |
| | | throw new UtilException("登录用户: LoginId异常 => " + loginId); |
| | |
| | | public static UserType getUserType(Object loginId) { |
| | | if (StringUtils.contains(loginId.toString(), UserType.SYS_USER.getUserType())) { |
| | | return UserType.SYS_USER; |
| | | } else if (StringUtils.contains(loginId.toString(), UserType.APP_USER.getUserType())){ |
| | | } else if (StringUtils.contains(loginId.toString(), UserType.APP_USER.getUserType())) { |
| | | return UserType.APP_USER; |
| | | } else { |
| | | throw new UtilException("登录用户: LoginId异常 => " + loginId); |
| | |
| | | |
| | | StringBuilder contentDispositionValue = new StringBuilder(); |
| | | contentDispositionValue.append("attachment; filename=") |
| | | .append(percentEncodedFileName) |
| | | .append(";") |
| | | .append("filename*=") |
| | | .append("utf-8''") |
| | | .append(percentEncodedFileName); |
| | | .append(percentEncodedFileName) |
| | | .append(";") |
| | | .append("filename*=") |
| | | .append("utf-8''") |
| | | .append(percentEncodedFileName); |
| | | |
| | | response.addHeader("Access-Control-Allow-Origin", "*"); |
| | | response.addHeader("Access-Control-Expose-Headers", "Content-Disposition,download-filename"); |
| | |
| | | if (RuoYiConfig.isAddressEnabled()) { |
| | | try { |
| | | String rspStr = HttpUtil.createGet(IP_URL) |
| | | .body("ip=" + ip + "&json=true", Constants.GBK) |
| | | .execute() |
| | | .body(); |
| | | .body("ip=" + ip + "&json=true", Constants.GBK) |
| | | .execute() |
| | | .body(); |
| | | if (StringUtils.isEmpty(rspStr)) { |
| | | log.error("获取地理位置异常 {}", ip); |
| | | return UNKNOWN; |
| | |
| | | |
| | | /** |
| | | * 注册对象监听器 |
| | | * |
| | | * <p> |
| | | * key 监听器需开启 `notify-keyspace-events` 等 redis 相关配置 |
| | | * |
| | | * @param key 缓存的键值 |
| | |
| | | |
| | | /** |
| | | * 注册List监听器 |
| | | * |
| | | * <p> |
| | | * key 监听器需开启 `notify-keyspace-events` 等 redis 相关配置 |
| | | * |
| | | * @param key 缓存的键值 |
| | |
| | | |
| | | /** |
| | | * 注册Set监听器 |
| | | * |
| | | * <p> |
| | | * key 监听器需开启 `notify-keyspace-events` 等 redis 相关配置 |
| | | * |
| | | * @param key 缓存的键值 |
| | |
| | | |
| | | /** |
| | | * 注册Map监听器 |
| | | * |
| | | * <p> |
| | | * key 监听器需开启 `notify-keyspace-events` 等 redis 相关配置 |
| | | * |
| | | * @param key 缓存的键值 |
| | |
| | | /** |
| | | * 定义常用的 sql关键字 |
| | | */ |
| | | public static String SQL_REGEX = "select |insert |delete |update |drop |count |exec |chr |mid |master |truncate |char |and |declare "; |
| | | public static final String SQL_REGEX = "select |insert |delete |update |drop |count |exec |chr |mid |master |truncate |char |and |declare "; |
| | | |
| | | /** |
| | | * 仅支持字母、数字、下划线、空格、逗号、小数点(支持多个字段排序) |
| | |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.cache.annotation.CacheEvict; |
| | | import org.springframework.cache.annotation.CachePut; |
| | | import org.springframework.cache.annotation.Cacheable; |
| | |
| | | // 类级别 缓存统一配置 |
| | | //@CacheConfig(cacheNames = "redissonCacheMap") |
| | | @Api(value = "spring-cache 演示案例", tags = {"spring-cache 演示案例"}) |
| | | @RequiredArgsConstructor(onConstructor_ = @Autowired) |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/demo/cache") |
| | | public class RedisCacheController { |
| | |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | |
| | | * @author Lion Li |
| | | */ |
| | | @Api(value = "Redis发布订阅 演示案例", tags = {"Redis发布订阅"}) |
| | | @RequiredArgsConstructor(onConstructor_ = @Autowired) |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/demo/redis/pubsub") |
| | | public class RedisPubSubController { |
| | |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.DeleteMapping; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | |
| | | * @date 2021-05-30 |
| | | */ |
| | | @Api(value = "测试批量方法", tags = {"测试批量方法"}) |
| | | @RequiredArgsConstructor(onConstructor_ = @Autowired) |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/demo/batch") |
| | | public class TestBatchController extends BaseController { |
| | |
| | | |
| | | /** |
| | | * 新增批量方法 可完美替代 saveBatch 秒级插入上万数据 (对mysql负荷较大) |
| | | * |
| | | * <p> |
| | | * 3.5.0 版本 增加 rewriteBatchedStatements=true 批处理参数 使 MP 原生批处理可以达到同样的速度 |
| | | */ |
| | | @ApiOperation(value = "新增批量方法") |
| | |
| | | |
| | | /** |
| | | * 新增或更新 可完美替代 saveOrUpdateBatch 高性能 |
| | | * |
| | | * <p> |
| | | * 3.5.0 版本 增加 rewriteBatchedStatements=true 批处理参数 使 MP 原生批处理可以达到同样的速度 |
| | | */ |
| | | @ApiOperation(value = "新增或更新批量方法") |
| | |
| | | import com.ruoyi.common.core.validate.EditGroup; |
| | | import com.ruoyi.common.core.validate.QueryGroup; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.utils.ValidatorUtils; |
| | | import com.ruoyi.common.excel.ExcelResult; |
| | | import com.ruoyi.common.utils.ValidatorUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.demo.domain.TestDemo; |
| | | import com.ruoyi.demo.domain.bo.TestDemoBo; |
| | |
| | | import com.ruoyi.demo.service.ITestDemoService; |
| | | import io.swagger.annotations.*; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | |
| | | */ |
| | | @Validated |
| | | @Api(value = "测试单表控制器", tags = {"测试单表管理"}) |
| | | @RequiredArgsConstructor(onConstructor_ = @Autowired) |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/demo/demo") |
| | | public class TestDemoController extends BaseController { |
| | |
| | | */ |
| | | @ApiOperation("删除测试单表") |
| | | @SaCheckPermission("demo:demo:remove") |
| | | @Log(title = "测试单表" , businessType = BusinessType.DELETE) |
| | | @Log(title = "测试单表", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{ids}") |
| | | public AjaxResult<Void> remove(@ApiParam("测试ID串") |
| | | @NotEmpty(message = "主键不能为空") |
| | |
| | | |
| | | /** |
| | | * 测试数据脱敏控制器 |
| | | * |
| | | * <p> |
| | | * 默认管理员不过滤 |
| | | * 需自行根据业务重写实现 |
| | | * |
| | | * @see com.ruoyi.common.core.service.SensitiveService |
| | | * @author Lion Li |
| | | * @version 3.6.0 |
| | | * @see com.ruoyi.common.core.service.SensitiveService |
| | | */ |
| | | @Api(value = "测试数据脱敏控制器", tags = {"测试数据脱敏管理"}) |
| | | @RestController |
| | |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | |
| | | */ |
| | | @Validated |
| | | @Api(value = "测试树表控制器", tags = {"测试树表管理"}) |
| | | @RequiredArgsConstructor(onConstructor_ = @Autowired) |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/demo/tree") |
| | | public class TestTreeController extends BaseController { |
| | |
| | | */ |
| | | @ApiOperation("删除测试树表") |
| | | @SaCheckPermission("demo:tree:remove") |
| | | @Log(title = "测试树表" , businessType = BusinessType.DELETE) |
| | | @Log(title = "测试树表", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{ids}") |
| | | public AjaxResult<Void> remove(@ApiParam("测试树ID串") |
| | | @NotEmpty(message = "主键不能为空") |
| | |
| | | import io.swagger.annotations.ApiParam; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | |
| | | */ |
| | | @Slf4j |
| | | @Api(value = "有界队列 演示案例", tags = {"有界队列"}) |
| | | @RequiredArgsConstructor(onConstructor_ = @Autowired) |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/demo/queue/bounded") |
| | | public class BoundedQueueController { |
| | |
| | | import io.swagger.annotations.ApiParam; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | |
| | | */ |
| | | @Slf4j |
| | | @Api(value = "延迟队列 演示案例", tags = {"延迟队列"}) |
| | | @RequiredArgsConstructor(onConstructor_ = @Autowired) |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/demo/queue/delayed") |
| | | public class DelayedQueueController { |
| | |
| | | import io.swagger.annotations.ApiParam; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | |
| | | */ |
| | | @Slf4j |
| | | @Api(value = "优先队列 演示案例", tags = {"优先队列"}) |
| | | @RequiredArgsConstructor(onConstructor_ = @Autowired) |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/demo/queue/priority") |
| | | public class PriorityQueueController { |
| | |
| | | } |
| | | } |
| | | return o instanceof MultipartFile || o instanceof HttpServletRequest || o instanceof HttpServletResponse |
| | | || o instanceof BindingResult; |
| | | || o instanceof BindingResult; |
| | | } |
| | | } |
| | |
| | | import com.ruoyi.common.annotation.RateLimiter; |
| | | import com.ruoyi.common.enums.LimitType; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.redis.RedisUtils; |
| | | import com.ruoyi.common.utils.ServletUtils; |
| | | import com.ruoyi.common.utils.redis.RedisUtils; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.aspectj.lang.JoinPoint; |
| | | import org.aspectj.lang.annotation.Aspect; |
| | |
| | | if (rateLimiter.limitType() == LimitType.IP) { |
| | | // 获取请求ip |
| | | stringBuffer.append(ServletUtils.getClientIP()).append("-"); |
| | | } else if (rateLimiter.limitType() == LimitType.CLUSTER){ |
| | | } else if (rateLimiter.limitType() == LimitType.CLUSTER) { |
| | | // 获取客户端实例id |
| | | stringBuffer.append(RedisUtils.getClient().getId()).append("-"); |
| | | } |
| | |
| | | import com.ruoyi.common.constant.Constants; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.JsonUtils; |
| | | import com.ruoyi.common.utils.redis.RedisUtils; |
| | | import com.ruoyi.common.utils.ServletUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.redis.RedisUtils; |
| | | import com.ruoyi.framework.config.properties.RepeatSubmitProperties; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.aspectj.lang.JoinPoint; |
| | | import org.aspectj.lang.annotation.Aspect; |
| | | import org.aspectj.lang.annotation.Before; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.validation.BindingResult; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | |
| | | * @author Lion Li |
| | | */ |
| | | @Slf4j |
| | | @RequiredArgsConstructor(onConstructor_ = @Autowired) |
| | | @RequiredArgsConstructor |
| | | @Aspect |
| | | @Component |
| | | public class RepeatSubmitAspect { |
| | |
| | | * 默认的安全上引用 |
| | | */ |
| | | private List<SecurityReference> defaultAuth() { |
| | | AuthorizationScope authorizationScope = new AuthorizationScope("global" , "accessEverything"); |
| | | AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything"); |
| | | AuthorizationScope[] authorizationScopes = new AuthorizationScope[1]; |
| | | authorizationScopes[0] = authorizationScope; |
| | | List<SecurityReference> securityReferences = new ArrayList<>(); |
| | |
| | | @Bean(name = "scheduledExecutorService") |
| | | protected ScheduledExecutorService scheduledExecutorService() { |
| | | return new ScheduledThreadPoolExecutor(threadPoolProperties.getCorePoolSize(), |
| | | new BasicThreadFactory.Builder().namingPattern("schedule-pool-%d").daemon(true).build()) { |
| | | new BasicThreadFactory.Builder().namingPattern("schedule-pool-%d").daemon(true).build()) { |
| | | @Override |
| | | protected void afterExecute(Runnable r, Throwable t) { |
| | | super.afterExecute(r, t); |
| | |
| | | userOnlineDTO.setDeptName(user.getDept().getDeptName()); |
| | | } |
| | | RedisUtils.setCacheObject(Constants.ONLINE_TOKEN_KEY + tokenValue, userOnlineDTO, saTokenConfig.getTimeout(), TimeUnit.SECONDS); |
| | | log.info("user doLogin, useId:{}, token:{}" , loginId, tokenValue); |
| | | log.info("user doLogin, useId:{}, token:{}", loginId, tokenValue); |
| | | } else if (userType == UserType.APP_USER) { |
| | | // app端 自行根据业务编写 |
| | | } |
| | |
| | | @Override |
| | | public void doLogout(String loginType, Object loginId, String tokenValue) { |
| | | RedisUtils.deleteObject(Constants.ONLINE_TOKEN_KEY + tokenValue); |
| | | log.info("user doLogout, useId:{}, token:{}" , loginId, tokenValue); |
| | | log.info("user doLogout, useId:{}, token:{}", loginId, tokenValue); |
| | | } |
| | | |
| | | /** |
| | |
| | | @Override |
| | | public void doKickout(String loginType, Object loginId, String tokenValue) { |
| | | RedisUtils.deleteObject(Constants.ONLINE_TOKEN_KEY + tokenValue); |
| | | log.info("user doLogoutByLoginId, useId:{}, token:{}" , loginId, tokenValue); |
| | | log.info("user doLogoutByLoginId, useId:{}, token:{}", loginId, tokenValue); |
| | | } |
| | | |
| | | /** |
| | |
| | | @Override |
| | | public void doReplaced(String loginType, Object loginId, String tokenValue) { |
| | | RedisUtils.deleteObject(Constants.ONLINE_TOKEN_KEY + tokenValue); |
| | | log.info("user doReplaced, useId:{}, token:{}" , loginId, tokenValue); |
| | | log.info("user doReplaced, useId:{}, token:{}", loginId, tokenValue); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public void set(String key, String value, long timeout) { |
| | | if(timeout == 0 || timeout <= SaTokenDao.NOT_VALUE_EXPIRE) { |
| | | if (timeout == 0 || timeout <= SaTokenDao.NOT_VALUE_EXPIRE) { |
| | | return; |
| | | } |
| | | // 判断是否为永不过期 |
| | | if(timeout == SaTokenDao.NEVER_EXPIRE) { |
| | | if (timeout == SaTokenDao.NEVER_EXPIRE) { |
| | | RedisUtils.setCacheObject(key, value); |
| | | } else { |
| | | RedisUtils.setCacheObject(key, value, timeout, TimeUnit.SECONDS); |
| | |
| | | public void update(String key, String value) { |
| | | long expire = getTimeout(key); |
| | | // -2 = 无此键 |
| | | if(expire == SaTokenDao.NOT_VALUE_EXPIRE) { |
| | | if (expire == SaTokenDao.NOT_VALUE_EXPIRE) { |
| | | return; |
| | | } |
| | | this.set(key, value, expire); |
| | |
| | | @Override |
| | | public void updateTimeout(String key, long timeout) { |
| | | // 判断是否想要设置为永久 |
| | | if(timeout == SaTokenDao.NEVER_EXPIRE) { |
| | | if (timeout == SaTokenDao.NEVER_EXPIRE) { |
| | | long expire = getTimeout(key); |
| | | if(expire == SaTokenDao.NEVER_EXPIRE) { |
| | | if (expire == SaTokenDao.NEVER_EXPIRE) { |
| | | // 如果其已经被设置为永久,则不作任何处理 |
| | | } else { |
| | | // 如果尚未被设置为永久,那么再次set一次 |
| | |
| | | } |
| | | RedisUtils.expire(key, timeout, TimeUnit.SECONDS); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public void setObject(String key, Object object, long timeout) { |
| | | if(timeout == 0 || timeout <= SaTokenDao.NOT_VALUE_EXPIRE) { |
| | | if (timeout == 0 || timeout <= SaTokenDao.NOT_VALUE_EXPIRE) { |
| | | return; |
| | | } |
| | | // 判断是否为永不过期 |
| | | if(timeout == SaTokenDao.NEVER_EXPIRE) { |
| | | if (timeout == SaTokenDao.NEVER_EXPIRE) { |
| | | RedisUtils.setCacheObject(key, object); |
| | | } else { |
| | | RedisUtils.setCacheObject(key, object, timeout, TimeUnit.SECONDS); |
| | |
| | | public void updateObject(String key, Object object) { |
| | | long expire = getObjectTimeout(key); |
| | | // -2 = 无此键 |
| | | if(expire == SaTokenDao.NOT_VALUE_EXPIRE) { |
| | | if (expire == SaTokenDao.NOT_VALUE_EXPIRE) { |
| | | return; |
| | | } |
| | | this.setObject(key, object, expire); |
| | |
| | | @Override |
| | | public void updateObjectTimeout(String key, long timeout) { |
| | | // 判断是否想要设置为永久 |
| | | if(timeout == SaTokenDao.NEVER_EXPIRE) { |
| | | if (timeout == SaTokenDao.NEVER_EXPIRE) { |
| | | long expire = getObjectTimeout(key); |
| | | if(expire == SaTokenDao.NEVER_EXPIRE) { |
| | | if (expire == SaTokenDao.NEVER_EXPIRE) { |
| | | // 如果其已经被设置为永久,则不作任何处理 |
| | | } else { |
| | | // 如果尚未被设置为永久,那么再次set一次 |
| | |
| | | */ |
| | | @ExceptionHandler(HttpRequestMethodNotSupportedException.class) |
| | | public AjaxResult<Void> handleHttpRequestMethodNotSupported(HttpRequestMethodNotSupportedException e, |
| | | HttpServletRequest request) { |
| | | HttpServletRequest request) { |
| | | String requestURI = request.getRequestURI(); |
| | | log.error("请求地址'{}',不支持'{}'请求", requestURI, e.getMethod()); |
| | | return AjaxResult.error(e.getMessage()); |
| | |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | |
| | | */ |
| | | @Validated |
| | | @Api(value = "代码生成", tags = {"代码生成管理"}) |
| | | @RequiredArgsConstructor(onConstructor_ = @Autowired) |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/tool/gen") |
| | | public class GenController extends BaseController { |
| | |
| | | public static boolean isSuperColumn(String tplCategory, String javaField) { |
| | | if (isTree(tplCategory)) { |
| | | return StringUtils.equalsAnyIgnoreCase(javaField, |
| | | ArrayUtils.addAll(GenConstants.TREE_ENTITY, GenConstants.BASE_ENTITY)); |
| | | ArrayUtils.addAll(GenConstants.TREE_ENTITY, GenConstants.BASE_ENTITY)); |
| | | } |
| | | return StringUtils.equalsAnyIgnoreCase(javaField, GenConstants.BASE_ENTITY); |
| | | } |
| | |
| | | |
| | | public static boolean isSuperColumn(String javaField) { |
| | | return StringUtils.equalsAnyIgnoreCase(javaField, |
| | | // BaseEntity |
| | | "createBy", "createTime", "updateBy", "updateTime", |
| | | // TreeEntity |
| | | "parentName", "parentId"); |
| | | // BaseEntity |
| | | "createBy", "createTime", "updateBy", "updateTime", |
| | | // TreeEntity |
| | | "parentName", "parentId"); |
| | | } |
| | | |
| | | public boolean isUsableColumn() { |
| | |
| | | @Override |
| | | public List<GenTableColumn> selectGenTableColumnListByTableId(Long tableId) { |
| | | return baseMapper.selectList(new LambdaQueryWrapper<GenTableColumn>() |
| | | .eq(GenTableColumn::getTableId, tableId) |
| | | .orderByAsc(GenTableColumn::getSort)); |
| | | .eq(GenTableColumn::getTableId, tableId) |
| | | .orderByAsc(GenTableColumn::getSort)); |
| | | } |
| | | |
| | | /** |
| | |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.*; |
| | | import com.ruoyi.common.utils.JsonUtils; |
| | | import com.ruoyi.common.utils.LoginUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.file.FileUtils; |
| | | import com.ruoyi.generator.domain.GenTable; |
| | | import com.ruoyi.generator.domain.GenTableColumn; |
| | |
| | | } |
| | | // 类型&性别字段设置下拉框 |
| | | else if (StringUtils.endsWithIgnoreCase(columnName, "type") |
| | | || StringUtils.endsWithIgnoreCase(columnName, "sex")) { |
| | | || StringUtils.endsWithIgnoreCase(columnName, "sex")) { |
| | | column.setHtmlType(GenConstants.HTML_SELECT); |
| | | } |
| | | // 图片字段设置图片上传控件 |
| | |
| | | Set<String> dicts = new HashSet<String>(); |
| | | for (GenTableColumn column : columns) { |
| | | if (!column.isSuperColumn() && StringUtils.isNotEmpty(column.getDictType()) && StringUtils.equalsAny( |
| | | column.getHtmlType(), |
| | | new String[] { GenConstants.HTML_SELECT, GenConstants.HTML_RADIO, GenConstants.HTML_CHECKBOX })) { |
| | | column.getHtmlType(), |
| | | new String[]{GenConstants.HTML_SELECT, GenConstants.HTML_RADIO, GenConstants.HTML_CHECKBOX})) { |
| | | dicts.add("'" + column.getDictType() + "'"); |
| | | } |
| | | } |
| | |
| | | */ |
| | | public static String getParentMenuId(Map<String, Object> paramsObj) { |
| | | if (StringUtils.isNotEmpty(paramsObj) && paramsObj.containsKey(GenConstants.PARENT_MENU_ID) |
| | | && StringUtils.isNotEmpty(Convert.toStr(paramsObj.get(GenConstants.PARENT_MENU_ID)))) { |
| | | && StringUtils.isNotEmpty(Convert.toStr(paramsObj.get(GenConstants.PARENT_MENU_ID)))) { |
| | | return Convert.toStr(paramsObj.get(GenConstants.PARENT_MENU_ID)); |
| | | } |
| | | return DEFAULT_PARENT_MENU_ID; |
| | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import javax.validation.constraints.*; |
| | | import cn.dev33.satoken.annotation.SaCheckPermission; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import com.ruoyi.common.annotation.RepeatSubmit; |
| | |
| | | */ |
| | | @Validated |
| | | @Api(value = "${functionName}控制器", tags = {"${functionName}管理"}) |
| | | @RequiredArgsConstructor(onConstructor_ = @Autowired) |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/${moduleName}/${businessName}") |
| | | public class ${ClassName}Controller extends BaseController { |
| | |
| | | */ |
| | | @ApiOperation("删除${functionName}") |
| | | @SaCheckPermission("${permissionPrefix}:remove") |
| | | @Log(title = "${functionName}" , businessType = BusinessType.DELETE) |
| | | @Log(title = "${functionName}", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{${pkColumn.javaField}s}") |
| | | public AjaxResult<Void> remove(@ApiParam("主键串") |
| | | @NotEmpty(message = "主键不能为空") |
| | |
| | | package com.ruoyi.oss.factory; |
| | | |
| | | import com.ruoyi.common.utils.JsonUtils; |
| | | import com.ruoyi.common.utils.redis.RedisUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.redis.RedisUtils; |
| | | import com.ruoyi.common.utils.reflect.ReflectUtils; |
| | | import com.ruoyi.oss.constant.OssConstant; |
| | | import com.ruoyi.oss.enumd.OssEnumd; |
| | |
| | | } |
| | | // 获取redis配置信息 创建对象 并缓存 |
| | | IOssStrategy service = (IOssStrategy) ReflectUtils.newInstance(OssEnumd.getServiceClass(type)); |
| | | ((AbstractOssStrategy)service).init(properties); |
| | | ((AbstractOssStrategy) service).init(properties); |
| | | SERVICES.put(type, service); |
| | | } |
| | | |
| | |
| | | |
| | | @Override |
| | | public void delete(String path) { |
| | | path = path.replace(getEndpointLink() + "/" , ""); |
| | | path = path.replace(getEndpointLink() + "/", ""); |
| | | try { |
| | | client.deleteObject(properties.getBucketName(), path); |
| | | } catch (Exception e) { |
| | |
| | | |
| | | default List<SysDictData> selectDictDataByType(String dictType) { |
| | | return selectList( |
| | | new LambdaQueryWrapper<SysDictData>() |
| | | .eq(SysDictData::getStatus, "0") |
| | | .eq(SysDictData::getDictType, dictType) |
| | | .orderByAsc(SysDictData::getDictSort)); |
| | | new LambdaQueryWrapper<SysDictData>() |
| | | .eq(SysDictData::getStatus, "0") |
| | | .eq(SysDictData::getDictType, dictType) |
| | | .orderByAsc(SysDictData::getDictSort)); |
| | | } |
| | | } |
| | |
| | | import com.ruoyi.system.service.ISysOssConfigService; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.boot.ApplicationArguments; |
| | | import org.springframework.boot.ApplicationRunner; |
| | | import org.springframework.stereotype.Component; |
| | |
| | | * @author Lion Li |
| | | */ |
| | | @Slf4j |
| | | @RequiredArgsConstructor(onConstructor_ = @Autowired) |
| | | @RequiredArgsConstructor |
| | | @Component |
| | | public class SystemApplicationRunner implements ApplicationRunner { |
| | | |
| | |
| | | public void run(ApplicationArguments args) throws Exception { |
| | | ossConfigService.init(); |
| | | log.info("初始化OSS配置成功"); |
| | | if (ruoyiConfig.isCacheLazy()){ |
| | | if (ruoyiConfig.isCacheLazy()) { |
| | | return; |
| | | } |
| | | configService.loadingConfigCache(); |
| | |
| | | |
| | | /** |
| | | * 获取角色自定义权限 |
| | | * |
| | | * @param roleId 角色id |
| | | * @return 部门id组 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 获取部门及以下权限 |
| | | * |
| | | * @param deptId 部门id |
| | | * @return 部门id组 |
| | | */ |
| | |
| | | } else if (StringUtils.isEmpty(password)) { |
| | | msg = "用户密码不能为空"; |
| | | } else if (username.length() < UserConstants.USERNAME_MIN_LENGTH |
| | | || username.length() > UserConstants.USERNAME_MAX_LENGTH) { |
| | | || username.length() > UserConstants.USERNAME_MAX_LENGTH) { |
| | | msg = "账户长度必须在2到20个字符之间"; |
| | | } else if (password.length() < UserConstants.PASSWORD_MIN_LENGTH |
| | | || password.length() > UserConstants.PASSWORD_MAX_LENGTH) { |
| | | || password.length() > UserConstants.PASSWORD_MAX_LENGTH) { |
| | | msg = "密码长度必须在5到20个字符之间"; |
| | | } else if (UserConstants.NOT_UNIQUE.equals(userService.checkUserNameUnique(username))) { |
| | | msg = "保存用户'" + username + "'失败,注册账号已存在"; |
| | |
| | | msg = "注册失败,请联系系统管理人员"; |
| | | } else { |
| | | asyncService.recordLogininfor(username, Constants.REGISTER, |
| | | MessageUtils.message("user.register.success"), ServletUtils.getRequest()); |
| | | MessageUtils.message("user.register.success"), ServletUtils.getRequest()); |
| | | } |
| | | } |
| | | return msg; |
| | |
| | | @Override |
| | | public TableDataInfo<SysDictData> selectPageDictDataList(SysDictData dictData, PageQuery pageQuery) { |
| | | LambdaQueryWrapper<SysDictData> lqw = new LambdaQueryWrapper<SysDictData>() |
| | | .eq(StringUtils.isNotBlank(dictData.getDictType()), SysDictData::getDictType, dictData.getDictType()) |
| | | .like(StringUtils.isNotBlank(dictData.getDictLabel()), SysDictData::getDictLabel, dictData.getDictLabel()) |
| | | .eq(StringUtils.isNotBlank(dictData.getStatus()), SysDictData::getStatus, dictData.getStatus()) |
| | | .orderByAsc(SysDictData::getDictSort); |
| | | .eq(StringUtils.isNotBlank(dictData.getDictType()), SysDictData::getDictType, dictData.getDictType()) |
| | | .like(StringUtils.isNotBlank(dictData.getDictLabel()), SysDictData::getDictLabel, dictData.getDictLabel()) |
| | | .eq(StringUtils.isNotBlank(dictData.getStatus()), SysDictData::getStatus, dictData.getStatus()) |
| | | .orderByAsc(SysDictData::getDictSort); |
| | | Page<SysDictData> page = baseMapper.selectPage(pageQuery.build(), lqw); |
| | | return TableDataInfo.build(page); |
| | | } |
| | |
| | | @Override |
| | | public List<SysDictData> selectDictDataList(SysDictData dictData) { |
| | | return baseMapper.selectList(new LambdaQueryWrapper<SysDictData>() |
| | | .eq(StringUtils.isNotBlank(dictData.getDictType()), SysDictData::getDictType, dictData.getDictType()) |
| | | .like(StringUtils.isNotBlank(dictData.getDictLabel()), SysDictData::getDictLabel, dictData.getDictLabel()) |
| | | .eq(StringUtils.isNotBlank(dictData.getStatus()), SysDictData::getStatus, dictData.getStatus()) |
| | | .orderByAsc(SysDictData::getDictSort)); |
| | | .eq(StringUtils.isNotBlank(dictData.getDictType()), SysDictData::getDictType, dictData.getDictType()) |
| | | .like(StringUtils.isNotBlank(dictData.getDictLabel()), SysDictData::getDictLabel, dictData.getDictLabel()) |
| | | .eq(StringUtils.isNotBlank(dictData.getStatus()), SysDictData::getStatus, dictData.getStatus()) |
| | | .orderByAsc(SysDictData::getDictSort)); |
| | | } |
| | | |
| | | /** |
| | |
| | | .select(SysDictData::getDictLabel) |
| | | .eq(SysDictData::getDictType, dictType) |
| | | .eq(SysDictData::getDictValue, dictValue)) |
| | | .getDictLabel(); |
| | | .getDictLabel(); |
| | | } |
| | | |
| | | /** |
| | |
| | | .like(StringUtils.isNotBlank(logininfor.getUserName()), SysLogininfor::getUserName, logininfor.getUserName()) |
| | | .between(params.get("beginTime") != null && params.get("endTime") != null, |
| | | SysLogininfor::getLoginTime, params.get("beginTime"), params.get("endTime")); |
| | | if(StringUtils.isBlank(pageQuery.getOrderByColumn())) { |
| | | if (StringUtils.isBlank(pageQuery.getOrderByColumn())) { |
| | | pageQuery.setOrderByColumn("info_id").setIsAsc("desc"); |
| | | } |
| | | Page<SysLogininfor> page = baseMapper.selectPage(pageQuery.build(), lqw); |
| | |
| | | @Override |
| | | public TableDataInfo<SysNotice> selectPageNoticeList(SysNotice notice, PageQuery pageQuery) { |
| | | LambdaQueryWrapper<SysNotice> lqw = new LambdaQueryWrapper<SysNotice>() |
| | | .like(StringUtils.isNotBlank(notice.getNoticeTitle()), SysNotice::getNoticeTitle, notice.getNoticeTitle()) |
| | | .eq(StringUtils.isNotBlank(notice.getNoticeType()), SysNotice::getNoticeType, notice.getNoticeType()) |
| | | .like(StringUtils.isNotBlank(notice.getCreateBy()), SysNotice::getCreateBy, notice.getCreateBy()); |
| | | .like(StringUtils.isNotBlank(notice.getNoticeTitle()), SysNotice::getNoticeTitle, notice.getNoticeTitle()) |
| | | .eq(StringUtils.isNotBlank(notice.getNoticeType()), SysNotice::getNoticeType, notice.getNoticeType()) |
| | | .like(StringUtils.isNotBlank(notice.getCreateBy()), SysNotice::getCreateBy, notice.getCreateBy()); |
| | | Page<SysNotice> page = baseMapper.selectPage(pageQuery.build(), lqw); |
| | | return TableDataInfo.build(page); |
| | | } |
| | |
| | | @Override |
| | | public List<SysNotice> selectNoticeList(SysNotice notice) { |
| | | return baseMapper.selectList(new LambdaQueryWrapper<SysNotice>() |
| | | .like(StringUtils.isNotBlank(notice.getNoticeTitle()), SysNotice::getNoticeTitle, notice.getNoticeTitle()) |
| | | .eq(StringUtils.isNotBlank(notice.getNoticeType()), SysNotice::getNoticeType, notice.getNoticeType()) |
| | | .like(StringUtils.isNotBlank(notice.getCreateBy()), SysNotice::getCreateBy, notice.getCreateBy())); |
| | | .like(StringUtils.isNotBlank(notice.getNoticeTitle()), SysNotice::getNoticeTitle, notice.getNoticeTitle()) |
| | | .eq(StringUtils.isNotBlank(notice.getNoticeType()), SysNotice::getNoticeType, notice.getNoticeType()) |
| | | .like(StringUtils.isNotBlank(notice.getCreateBy()), SysNotice::getCreateBy, notice.getCreateBy())); |
| | | } |
| | | |
| | | /** |
| | |
| | | .like(StringUtils.isNotBlank(operLog.getOperName()), SysOperLog::getOperName, operLog.getOperName()) |
| | | .between(params.get("beginTime") != null && params.get("endTime") != null, |
| | | SysOperLog::getOperTime, params.get("beginTime"), params.get("endTime")); |
| | | if(StringUtils.isBlank(pageQuery.getOrderByColumn())) { |
| | | if (StringUtils.isBlank(pageQuery.getOrderByColumn())) { |
| | | pageQuery.setOrderByColumn("oper_id").setIsAsc("desc"); |
| | | } |
| | | Page<SysOperLog> page = baseMapper.selectPage(pageQuery.build(), lqw); |
| | |
| | | */ |
| | | private void validEntityBeforeSave(SysOssConfig entity) { |
| | | if (StringUtils.isNotEmpty(entity.getConfigKey()) |
| | | && UserConstants.NOT_UNIQUE.equals(checkConfigKeyUnique(entity))) { |
| | | && UserConstants.NOT_UNIQUE.equals(checkConfigKeyUnique(entity))) { |
| | | throw new ServiceException("操作配置'" + entity.getConfigKey() + "'失败, 配置key已存在!"); |
| | | } |
| | | } |
| | |
| | | private String checkConfigKeyUnique(SysOssConfig sysOssConfig) { |
| | | long ossConfigId = StringUtils.isNull(sysOssConfig.getOssConfigId()) ? -1L : sysOssConfig.getOssConfigId(); |
| | | SysOssConfig info = baseMapper.selectOne(new LambdaQueryWrapper<SysOssConfig>() |
| | | .select(SysOssConfig::getOssConfigId, SysOssConfig::getConfigKey) |
| | | .eq(SysOssConfig::getConfigKey, sysOssConfig.getConfigKey())); |
| | | .select(SysOssConfig::getOssConfigId, SysOssConfig::getConfigKey) |
| | | .eq(SysOssConfig::getConfigKey, sysOssConfig.getConfigKey())); |
| | | if (StringUtils.isNotNull(info) && info.getOssConfigId() != ossConfigId) { |
| | | return UserConstants.NOT_UNIQUE; |
| | | } |
| | |
| | | public int updateOssConfigStatus(SysOssConfigBo bo) { |
| | | SysOssConfig sysOssConfig = BeanUtil.toBean(bo, SysOssConfig.class); |
| | | int row = baseMapper.update(null, new LambdaUpdateWrapper<SysOssConfig>() |
| | | .set(SysOssConfig::getStatus, "1")); |
| | | .set(SysOssConfig::getStatus, "1")); |
| | | row += baseMapper.updateById(sysOssConfig); |
| | | if (row > 0) { |
| | | RedisUtils.setCacheObject(OssConstant.CACHE_CONFIG_KEY, sysOssConfig.getConfigKey()); |
| | |
| | | private boolean setConfigCache(boolean flag, SysOssConfig config) { |
| | | if (flag) { |
| | | RedisUtils.setCacheObject( |
| | | getCacheKey(config.getConfigKey()), |
| | | JsonUtils.toJsonString(config)); |
| | | getCacheKey(config.getConfigKey()), |
| | | JsonUtils.toJsonString(config)); |
| | | RedisUtils.publish(OssConstant.CACHE_CONFIG_KEY, config.getConfigKey(), msg -> { |
| | | log.info("发布刷新OSS配置 => " + msg); |
| | | }); |
| | |
| | | lqw.eq(StringUtils.isNotBlank(bo.getFileSuffix()), SysOss::getFileSuffix, bo.getFileSuffix()); |
| | | lqw.eq(StringUtils.isNotBlank(bo.getUrl()), SysOss::getUrl, bo.getUrl()); |
| | | lqw.between(params.get("beginCreateTime") != null && params.get("endCreateTime") != null, |
| | | SysOss::getCreateTime, params.get("beginCreateTime"), params.get("endCreateTime")); |
| | | SysOss::getCreateTime, params.get("beginCreateTime"), params.get("endCreateTime")); |
| | | lqw.eq(StringUtils.isNotBlank(bo.getCreateBy()), SysOss::getCreateBy, bo.getCreateBy()); |
| | | lqw.eq(StringUtils.isNotBlank(bo.getService()), SysOss::getService, bo.getService()); |
| | | return lqw; |
| | |
| | | } |
| | | // 保存文件信息 |
| | | SysOss oss = new SysOss() |
| | | .setUrl(uploadResult.getUrl()) |
| | | .setFileSuffix(suffix) |
| | | .setFileName(uploadResult.getFilename()) |
| | | .setOriginalName(originalfileName) |
| | | .setService(storage.getServiceType()); |
| | | .setUrl(uploadResult.getUrl()) |
| | | .setFileSuffix(suffix) |
| | | .setFileName(uploadResult.getFilename()) |
| | | .setOriginalName(originalfileName) |
| | | .setService(storage.getServiceType()); |
| | | baseMapper.insert(oss); |
| | | return oss; |
| | | } |
| | |
| | | @Override |
| | | public TableDataInfo<SysPost> selectPagePostList(SysPost post, PageQuery pageQuery) { |
| | | LambdaQueryWrapper<SysPost> lqw = new LambdaQueryWrapper<SysPost>() |
| | | .like(StringUtils.isNotBlank(post.getPostCode()), SysPost::getPostCode, post.getPostCode()) |
| | | .eq(StringUtils.isNotBlank(post.getStatus()), SysPost::getStatus, post.getStatus()) |
| | | .like(StringUtils.isNotBlank(post.getPostName()), SysPost::getPostName, post.getPostName()); |
| | | .like(StringUtils.isNotBlank(post.getPostCode()), SysPost::getPostCode, post.getPostCode()) |
| | | .eq(StringUtils.isNotBlank(post.getStatus()), SysPost::getStatus, post.getStatus()) |
| | | .like(StringUtils.isNotBlank(post.getPostName()), SysPost::getPostName, post.getPostName()); |
| | | Page<SysPost> page = baseMapper.selectPage(pageQuery.build(), lqw); |
| | | return TableDataInfo.build(page); |
| | | } |
| | |
| | | @Override |
| | | public List<SysPost> selectPostList(SysPost post) { |
| | | return baseMapper.selectList(new LambdaQueryWrapper<SysPost>() |
| | | .like(StringUtils.isNotBlank(post.getPostCode()), SysPost::getPostCode, post.getPostCode()) |
| | | .eq(StringUtils.isNotBlank(post.getStatus()), SysPost::getStatus, post.getStatus()) |
| | | .like(StringUtils.isNotBlank(post.getPostName()), SysPost::getPostName, post.getPostName())); |
| | | .like(StringUtils.isNotBlank(post.getPostCode()), SysPost::getPostCode, post.getPostCode()) |
| | | .eq(StringUtils.isNotBlank(post.getStatus()), SysPost::getStatus, post.getStatus()) |
| | | .like(StringUtils.isNotBlank(post.getPostName()), SysPost::getPostName, post.getPostName())); |
| | | } |
| | | |
| | | /** |
| | |
| | | public String checkPostNameUnique(SysPost post) { |
| | | Long postId = StringUtils.isNull(post.getPostId()) ? -1L : post.getPostId(); |
| | | boolean count = baseMapper.exists(new LambdaQueryWrapper<SysPost>() |
| | | .eq(SysPost::getPostName, post.getPostName()) |
| | | .ne(SysPost::getPostId, postId)); |
| | | .eq(SysPost::getPostName, post.getPostName()) |
| | | .ne(SysPost::getPostId, postId)); |
| | | if (count) { |
| | | return UserConstants.NOT_UNIQUE; |
| | | } |
| | |
| | | public String checkPostCodeUnique(SysPost post) { |
| | | Long postId = StringUtils.isNull(post.getPostId()) ? -1L : post.getPostId(); |
| | | boolean count = baseMapper.exists(new LambdaQueryWrapper<SysPost>() |
| | | .eq(SysPost::getPostCode, post.getPostCode()) |
| | | .ne(SysPost::getPostId, postId)); |
| | | .eq(SysPost::getPostCode, post.getPostCode()) |
| | | .ne(SysPost::getPostId, postId)); |
| | | if (count) { |
| | | return UserConstants.NOT_UNIQUE; |
| | | } |
| | |
| | | public String checkRoleNameUnique(SysRole role) { |
| | | Long roleId = StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId(); |
| | | boolean count = baseMapper.exists(new LambdaQueryWrapper<SysRole>() |
| | | .eq(SysRole::getRoleName, role.getRoleName()) |
| | | .ne(SysRole::getRoleId, roleId)); |
| | | .eq(SysRole::getRoleName, role.getRoleName()) |
| | | .ne(SysRole::getRoleId, roleId)); |
| | | if (count) { |
| | | return UserConstants.NOT_UNIQUE; |
| | | } |
| | |
| | | public String checkRoleKeyUnique(SysRole role) { |
| | | Long roleId = StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId(); |
| | | boolean count = baseMapper.exists(new LambdaQueryWrapper<SysRole>() |
| | | .eq(SysRole::getRoleKey, role.getRoleKey()) |
| | | .ne(SysRole::getRoleId, roleId)); |
| | | .eq(SysRole::getRoleKey, role.getRoleKey()) |
| | | .ne(SysRole::getRoleId, roleId)); |
| | | if (count) { |
| | | return UserConstants.NOT_UNIQUE; |
| | | } |
| | |
| | | @Override |
| | | public int deleteAuthUser(SysUserRole userRole) { |
| | | return userRoleMapper.delete(new LambdaQueryWrapper<SysUserRole>() |
| | | .eq(SysUserRole::getRoleId, userRole.getRoleId()) |
| | | .eq(SysUserRole::getUserId, userRole.getUserId())); |
| | | .eq(SysUserRole::getRoleId, userRole.getRoleId()) |
| | | .eq(SysUserRole::getUserId, userRole.getUserId())); |
| | | } |
| | | |
| | | /** |
| | |
| | | @Override |
| | | public int deleteAuthUsers(Long roleId, Long[] userIds) { |
| | | return userRoleMapper.delete(new LambdaQueryWrapper<SysUserRole>() |
| | | .eq(SysUserRole::getRoleId, roleId) |
| | | .in(SysUserRole::getUserId, Arrays.asList(userIds))); |
| | | .eq(SysUserRole::getRoleId, roleId) |
| | | .in(SysUserRole::getUserId, Arrays.asList(userIds))); |
| | | } |
| | | |
| | | /** |
| | |
| | | import com.ruoyi.common.core.service.UserService; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.LoginUtils; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.spring.SpringUtils; |
| | | import com.ruoyi.system.domain.SysPost; |
| | |
| | | public String checkPhoneUnique(SysUser user) { |
| | | Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId(); |
| | | boolean count = baseMapper.exists(new LambdaQueryWrapper<SysUser>() |
| | | .eq(SysUser::getPhonenumber, user.getPhonenumber()) |
| | | .ne(SysUser::getUserId, userId)); |
| | | .eq(SysUser::getPhonenumber, user.getPhonenumber()) |
| | | .ne(SysUser::getUserId, userId)); |
| | | if (count) { |
| | | return UserConstants.NOT_UNIQUE; |
| | | } |
| | |
| | | public String checkEmailUnique(SysUser user) { |
| | | Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId(); |
| | | boolean count = baseMapper.exists(new LambdaQueryWrapper<SysUser>() |
| | | .eq(SysUser::getEmail, user.getEmail()) |
| | | .ne(SysUser::getUserId, userId)); |
| | | .eq(SysUser::getEmail, user.getEmail()) |
| | | .ne(SysUser::getUserId, userId)); |
| | | if (count) { |
| | | return UserConstants.NOT_UNIQUE; |
| | | } |
| | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void insertUserAuth(Long userId, Long[] roleIds) { |
| | | userRoleMapper.delete(new LambdaQueryWrapper<SysUserRole>() |
| | | .eq(SysUserRole::getUserId, userId)); |
| | | .eq(SysUserRole::getUserId, userId)); |
| | | insertUserRole(userId, roleIds); |
| | | } |
| | | |
| | |
| | | @Override |
| | | public boolean updateUserAvatar(String userName, String avatar) { |
| | | return baseMapper.update(null, |
| | | new LambdaUpdateWrapper<SysUser>() |
| | | .set(SysUser::getAvatar, avatar) |
| | | .eq(SysUser::getUserName, userName)) > 0; |
| | | new LambdaUpdateWrapper<SysUser>() |
| | | .set(SysUser::getAvatar, avatar) |
| | | .eq(SysUser::getUserName, userName)) > 0; |
| | | } |
| | | |
| | | /** |
| | |
| | | @Override |
| | | public int resetUserPwd(String userName, String password) { |
| | | return baseMapper.update(null, |
| | | new LambdaUpdateWrapper<SysUser>() |
| | | .set(SysUser::getPassword, password) |
| | | .eq(SysUser::getUserName, userName)); |
| | | new LambdaUpdateWrapper<SysUser>() |
| | | .set(SysUser::getPassword, password) |
| | | .eq(SysUser::getUserName, userName)); |
| | | } |
| | | |
| | | /** |