update 使用 @param 注释替换 @Parameter 注解
fix 修复 token 无法传递 与 无法持久化问题
| | |
| | | <artifactId>lombok</artifactId> |
| | | <version>1.18.24</version> |
| | | </path> |
| | | <path> |
| | | <groupId>org.springframework.boot</groupId> |
| | | <artifactId>spring-boot-configuration-processor</artifactId> |
| | | <version>${spring-boot.version}</version> |
| | | </path> |
| | | </annotationProcessorPaths> |
| | | </configuration> |
| | | </plugin> |
| | |
| | | import com.ruoyi.sms.core.SmsTemplate; |
| | | import com.ruoyi.sms.entity.SmsResult; |
| | | import com.ruoyi.system.service.ISysConfigService; |
| | | import io.swagger.v3.oas.annotations.Parameter; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | @Anonymous |
| | | @Slf4j |
| | | @Validated |
| | | @Tag(name ="验证码操作处理", description = "验证码管理") |
| | | @Tag(name = "验证码操作处理", description = "验证码管理") |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | public class CaptchaController { |
| | |
| | | |
| | | /** |
| | | * 短信验证码 |
| | | * |
| | | * @param phonenumber 用户手机号 |
| | | */ |
| | | @GetMapping("/captchaSms") |
| | | public R<Void> smsCaptcha(@Parameter(name = "用户手机号") |
| | | @NotBlank(message = "{user.phonenumber.not.blank}") |
| | | public R<Void> smsCaptcha(@NotBlank(message = "{user.phonenumber.not.blank}") |
| | | String phonenumber) { |
| | | if (smsProperties.getEnabled()) { |
| | | R.fail("当前系统没有开启短信功能!"); |
| | |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @Tag(name ="缓存监控", description = "缓存监控管理") |
| | | @Tag(name = "缓存监控", description = "缓存监控管理") |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/monitor/cache") |
| | |
| | | CACHES.add(new SysCache(CacheConstants.RATE_LIMIT_KEY, "限流处理")); |
| | | } |
| | | |
| | | /** |
| | | * 获取缓存监控列表 |
| | | */ |
| | | @SaCheckPermission("monitor:cache:list") |
| | | @GetMapping() |
| | | public R<Map<String, Object>> getInfo() throws Exception { |
| | |
| | | return R.ok(result); |
| | | } |
| | | |
| | | /** |
| | | * 获取缓存监控缓存名列表 |
| | | */ |
| | | @SaCheckPermission("monitor:cache:list") |
| | | @GetMapping("/getNames") |
| | | public R<List<SysCache>> cache() { |
| | | return R.ok(CACHES); |
| | | } |
| | | |
| | | /** |
| | | * 获取缓存监控Key列表 |
| | | * |
| | | * @param cacheName 缓存名 |
| | | */ |
| | | @SaCheckPermission("monitor:cache:list") |
| | | @GetMapping("/getKeys/{cacheName}") |
| | | public R<Set<String>> getCacheKeys(@PathVariable String cacheName) { |
| | |
| | | return R.ok(cacheKyes); |
| | | } |
| | | |
| | | /** |
| | | * 获取缓存监控缓存值详情 |
| | | * |
| | | * @param cacheName 缓存名 |
| | | * @param cacheKey 缓存key |
| | | */ |
| | | @SaCheckPermission("monitor:cache:list") |
| | | @GetMapping("/getValue/{cacheName}/{cacheKey}") |
| | | public R<SysCache> getCacheValue(@PathVariable String cacheName, @PathVariable String cacheKey) { |
| | |
| | | return R.ok(sysCache); |
| | | } |
| | | |
| | | /** |
| | | * 清理缓存监控缓存名 |
| | | * |
| | | * @param cacheName 缓存名 |
| | | */ |
| | | @SaCheckPermission("monitor:cache:list") |
| | | @DeleteMapping("/clearCacheName/{cacheName}") |
| | | public R<Void> clearCacheName(@PathVariable String cacheName) { |
| | |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 清理缓存监控Key |
| | | * |
| | | * @param cacheKey key名 |
| | | */ |
| | | @SaCheckPermission("monitor:cache:list") |
| | | @DeleteMapping("/clearCacheKey/{cacheKey}") |
| | | public R<Void> clearCacheKey(@PathVariable String cacheKey) { |
| | |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 清理全部缓存监控 |
| | | */ |
| | | @SaCheckPermission("monitor:cache:list") |
| | | @DeleteMapping("/clearCacheAll") |
| | | public R<Void> clearCacheAll() { |
| | |
| | | * @author Lion Li |
| | | */ |
| | | @Validated |
| | | @Tag(name ="系统访问记录", description = "系统访问记录管理") |
| | | @Tag(name = "系统访问记录", description = "系统访问记录管理") |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/monitor/logininfor") |
| | |
| | | |
| | | private final ISysLogininforService logininforService; |
| | | |
| | | /** |
| | | * 获取系统访问记录列表 |
| | | */ |
| | | @SaCheckPermission("monitor:logininfor:list") |
| | | @GetMapping("/list") |
| | | public TableDataInfo<SysLogininfor> list(SysLogininfor logininfor, PageQuery pageQuery) { |
| | | return logininforService.selectPageLogininforList(logininfor, pageQuery); |
| | | } |
| | | |
| | | /** |
| | | * 导出系统访问记录列表 |
| | | */ |
| | | @Log(title = "登录日志", businessType = BusinessType.EXPORT) |
| | | @SaCheckPermission("monitor:logininfor:export") |
| | | @PostMapping("/export") |
| | |
| | | ExcelUtil.exportExcel(list, "登录日志", SysLogininfor.class, response); |
| | | } |
| | | |
| | | /** |
| | | * 获取系统访问记录详情 |
| | | */ |
| | | @SaCheckPermission("monitor:logininfor:remove") |
| | | @Log(title = "登录日志", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{infoIds}") |
| | |
| | | return toAjax(logininforService.deleteLogininforByIds(infoIds)); |
| | | } |
| | | |
| | | /** |
| | | * 清理系统访问记录 |
| | | */ |
| | | @SaCheckPermission("monitor:logininfor:remove") |
| | | @Log(title = "登录日志", businessType = BusinessType.CLEAN) |
| | | @DeleteMapping("/clean") |
| | |
| | | * @author Lion Li |
| | | */ |
| | | @Validated |
| | | @Tag(name ="操作日志记录", description = "操作日志记录管理") |
| | | @Tag(name = "操作日志记录", description = "操作日志记录管理") |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/monitor/operlog") |
| | |
| | | |
| | | private final ISysOperLogService operLogService; |
| | | |
| | | /** |
| | | * 获取操作日志记录列表 |
| | | */ |
| | | @SaCheckPermission("monitor:operlog:list") |
| | | @GetMapping("/list") |
| | | public TableDataInfo<SysOperLog> list(SysOperLog operLog, PageQuery pageQuery) { |
| | | return operLogService.selectPageOperLogList(operLog, pageQuery); |
| | | } |
| | | |
| | | /** |
| | | * 导出操作日志记录列表 |
| | | */ |
| | | @Log(title = "操作日志", businessType = BusinessType.EXPORT) |
| | | @SaCheckPermission("monitor:operlog:export") |
| | | @PostMapping("/export") |
| | |
| | | ExcelUtil.exportExcel(list, "操作日志", SysOperLog.class, response); |
| | | } |
| | | |
| | | /** |
| | | * 获取操作日志记录详情 |
| | | */ |
| | | @Log(title = "操作日志", businessType = BusinessType.DELETE) |
| | | @SaCheckPermission("monitor:operlog:remove") |
| | | @DeleteMapping("/{operIds}") |
| | |
| | | return toAjax(operLogService.deleteOperLogByIds(operIds)); |
| | | } |
| | | |
| | | /** |
| | | * 清理操作日志记录 |
| | | */ |
| | | @Log(title = "操作日志", businessType = BusinessType.CLEAN) |
| | | @SaCheckPermission("monitor:operlog:remove") |
| | | @DeleteMapping("/clean") |
| | |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @Tag(name ="在线用户监控", description = "在线用户监控管理") |
| | | @Tag(name = "在线用户监控", description = "在线用户监控管理") |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/monitor/online") |
| | | public class SysUserOnlineController extends BaseController { |
| | | |
| | | /** |
| | | * 获取在线用户监控列表 |
| | | * |
| | | * @param ipaddr IP地址 |
| | | * @param userName 用户名 |
| | | */ |
| | | @SaCheckPermission("monitor:online:list") |
| | | @GetMapping("/list") |
| | | public TableDataInfo<SysUserOnline> list(String ipaddr, String userName) { |
| | |
| | | ); |
| | | } else if (StringUtils.isNotEmpty(ipaddr)) { |
| | | userOnlineDTOList = StreamUtils.filter(userOnlineDTOList, userOnline -> |
| | | StringUtils.equals(ipaddr, userOnline.getIpaddr()) |
| | | StringUtils.equals(ipaddr, userOnline.getIpaddr()) |
| | | ); |
| | | } else if (StringUtils.isNotEmpty(userName)) { |
| | | userOnlineDTOList = StreamUtils.filter(userOnlineDTOList, userOnline -> |
| | |
| | | |
| | | /** |
| | | * 强退用户 |
| | | * |
| | | * @param tokenId token值 |
| | | */ |
| | | @SaCheckPermission("monitor:online:forceLogout") |
| | | @Log(title = "在线用户", businessType = BusinessType.FORCE) |
| | |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.system.domain.SysConfig; |
| | | import com.ruoyi.system.service.ISysConfigService; |
| | | import io.swagger.v3.oas.annotations.Parameter; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.validation.annotation.Validated; |
| | |
| | | * @author Lion Li |
| | | */ |
| | | @Validated |
| | | @Tag(name ="参数配置控制器", description = "参数配置管理") |
| | | @Tag(name = "参数配置控制器", description = "参数配置管理") |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/system/config") |
| | |
| | | return configService.selectPageConfigList(config, pageQuery); |
| | | } |
| | | |
| | | /** |
| | | * 导出参数配置列表 |
| | | */ |
| | | @Log(title = "参数管理", businessType = BusinessType.EXPORT) |
| | | @SaCheckPermission("system:config:export") |
| | | @PostMapping("/export") |
| | |
| | | |
| | | /** |
| | | * 根据参数编号获取详细信息 |
| | | * |
| | | * @param configId 参数ID |
| | | */ |
| | | @SaCheckPermission("system:config:query") |
| | | @GetMapping(value = "/{configId}") |
| | | public R<SysConfig> getInfo(@Parameter(name = "参数ID") @PathVariable Long configId) { |
| | | public R<SysConfig> getInfo(@PathVariable Long configId) { |
| | | return R.ok(configService.selectConfigById(configId)); |
| | | } |
| | | |
| | | /** |
| | | * 根据参数键名查询参数值 |
| | | * |
| | | * @param configKey 参数Key |
| | | */ |
| | | @GetMapping(value = "/configKey/{configKey}") |
| | | public R<Void> getConfigKey(@Parameter(name = "参数Key") @PathVariable String configKey) { |
| | | public R<Void> getConfigKey(@PathVariable String configKey) { |
| | | return R.ok(configService.selectConfigByKey(configKey)); |
| | | } |
| | | |
| | |
| | | |
| | | /** |
| | | * 删除参数配置 |
| | | * |
| | | * @param configIds 参数ID串 |
| | | */ |
| | | @SaCheckPermission("system:config:remove") |
| | | @Log(title = "参数管理", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{configIds}") |
| | | public R<Void> remove(@Parameter(name = "参数ID串") @PathVariable Long[] configIds) { |
| | | public R<Void> remove(@PathVariable Long[] configIds) { |
| | | configService.deleteConfigByIds(configIds); |
| | | return R.ok(); |
| | | } |
| | |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.system.service.ISysDeptService; |
| | | import io.swagger.v3.oas.annotations.Parameter; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.validation.annotation.Validated; |
| | |
| | | * @author Lion Li |
| | | */ |
| | | @Validated |
| | | @Tag(name ="部门控制器", description = "部门管理") |
| | | @Tag(name = "部门控制器", description = "部门管理") |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/system/dept") |
| | |
| | | |
| | | /** |
| | | * 查询部门列表(排除节点) |
| | | * |
| | | * @param deptId 部门ID |
| | | */ |
| | | @SaCheckPermission("system:dept:list") |
| | | @GetMapping("/list/exclude/{deptId}") |
| | | public R<List<SysDept>> excludeChild(@Parameter(name = "部门ID") @PathVariable(value = "deptId", required = false) Long deptId) { |
| | | public R<List<SysDept>> excludeChild(@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 + "")); |
| | |
| | | |
| | | /** |
| | | * 根据部门编号获取详细信息 |
| | | * |
| | | * @param deptId 部门ID |
| | | */ |
| | | @SaCheckPermission("system:dept:query") |
| | | @GetMapping(value = "/{deptId}") |
| | | public R<SysDept> getInfo(@Parameter(name = "部门ID") @PathVariable Long deptId) { |
| | | public R<SysDept> getInfo(@PathVariable Long deptId) { |
| | | deptService.checkDeptDataScope(deptId); |
| | | return R.ok(deptService.selectDeptById(deptId)); |
| | | } |
| | |
| | | |
| | | /** |
| | | * 加载对应角色部门列表树 |
| | | * |
| | | * @param roleId 角色ID |
| | | */ |
| | | @GetMapping(value = "/roleDeptTreeselect/{roleId}") |
| | | public R<Map<String, Object>> roleDeptTreeselect(@Parameter(name = "角色ID") @PathVariable("roleId") Long roleId) { |
| | | public R<Map<String, Object>> roleDeptTreeselect(@PathVariable("roleId") Long roleId) { |
| | | List<SysDept> depts = deptService.selectDeptList(new SysDept()); |
| | | Map<String, Object> ajax = new HashMap<>(); |
| | | ajax.put("checkedKeys", deptService.selectDeptListByRoleId(roleId)); |
| | |
| | | |
| | | /** |
| | | * 删除部门 |
| | | * |
| | | * @param deptId 部门ID |
| | | */ |
| | | @SaCheckPermission("system:dept:remove") |
| | | @Log(title = "部门管理", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{deptId}") |
| | | public R<Void> remove(@Parameter(name = "部门ID串") @PathVariable Long deptId) { |
| | | public R<Void> remove(@PathVariable Long deptId) { |
| | | if (deptService.hasChildByDeptId(deptId)) { |
| | | return R.fail("存在下级部门,不允许删除"); |
| | | } |
| | |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.system.service.ISysDictDataService; |
| | | import com.ruoyi.system.service.ISysDictTypeService; |
| | | import io.swagger.v3.oas.annotations.Parameter; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.validation.annotation.Validated; |
| | |
| | | * @author Lion Li |
| | | */ |
| | | @Validated |
| | | @Tag(name ="数据字典信息控制器", description = "数据字典信息管理") |
| | | @Tag(name = "数据字典信息控制器", description = "数据字典信息管理") |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/system/dict/data") |
| | |
| | | private final ISysDictDataService dictDataService; |
| | | private final ISysDictTypeService dictTypeService; |
| | | |
| | | /** |
| | | * 查询字典数据列表 |
| | | */ |
| | | @SaCheckPermission("system:dict:list") |
| | | @GetMapping("/list") |
| | | public TableDataInfo<SysDictData> list(SysDictData dictData, PageQuery pageQuery) { |
| | | return dictDataService.selectPageDictDataList(dictData, pageQuery); |
| | | } |
| | | |
| | | /** |
| | | * 导出字典数据列表 |
| | | */ |
| | | @Log(title = "字典数据", businessType = BusinessType.EXPORT) |
| | | @SaCheckPermission("system:dict:export") |
| | | @PostMapping("/export") |
| | |
| | | |
| | | /** |
| | | * 查询字典数据详细 |
| | | * |
| | | * @param dictCode 字典code |
| | | */ |
| | | @SaCheckPermission("system:dict:query") |
| | | @GetMapping(value = "/{dictCode}") |
| | | public R<SysDictData> getInfo(@Parameter(name = "字典code") @PathVariable Long dictCode) { |
| | | public R<SysDictData> getInfo(@PathVariable Long dictCode) { |
| | | return R.ok(dictDataService.selectDictDataById(dictCode)); |
| | | } |
| | | |
| | | /** |
| | | * 根据字典类型查询字典数据信息 |
| | | * |
| | | * @param dictType 字典类型 |
| | | */ |
| | | @GetMapping(value = "/type/{dictType}") |
| | | public R<List<SysDictData>> dictType(@Parameter(name = "字典类型") @PathVariable String dictType) { |
| | | public R<List<SysDictData>> dictType(@PathVariable String dictType) { |
| | | List<SysDictData> data = dictTypeService.selectDictDataByType(dictType); |
| | | if (ObjectUtil.isNull(data)) { |
| | | data = new ArrayList<>(); |
| | |
| | | |
| | | /** |
| | | * 删除字典类型 |
| | | * |
| | | * @param dictCodes 字典code串 |
| | | */ |
| | | @SaCheckPermission("system:dict:remove") |
| | | @Log(title = "字典类型", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{dictCodes}") |
| | | public R<Void> remove(@Parameter(name = "字典code串") @PathVariable Long[] dictCodes) { |
| | | public R<Void> remove(@PathVariable Long[] dictCodes) { |
| | | dictDataService.deleteDictDataByIds(dictCodes); |
| | | return R.ok(); |
| | | } |
| | |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.system.service.ISysDictTypeService; |
| | | import io.swagger.v3.oas.annotations.Parameter; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.validation.annotation.Validated; |
| | |
| | | * @author Lion Li |
| | | */ |
| | | @Validated |
| | | @Tag(name ="数据字典信息控制器", description = "数据字典信息管理") |
| | | @Tag(name = "数据字典信息控制器", description = "数据字典信息管理") |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/system/dict/type") |
| | |
| | | |
| | | private final ISysDictTypeService dictTypeService; |
| | | |
| | | /** |
| | | * 查询字典类型列表 |
| | | */ |
| | | @SaCheckPermission("system:dict:list") |
| | | @GetMapping("/list") |
| | | public TableDataInfo<SysDictType> list(SysDictType dictType, PageQuery pageQuery) { |
| | | return dictTypeService.selectPageDictTypeList(dictType, pageQuery); |
| | | } |
| | | |
| | | /** |
| | | * 导出字典类型列表 |
| | | */ |
| | | @Log(title = "字典类型", businessType = BusinessType.EXPORT) |
| | | @SaCheckPermission("system:dict:export") |
| | | @PostMapping("/export") |
| | |
| | | |
| | | /** |
| | | * 查询字典类型详细 |
| | | * |
| | | * @param dictId 字典ID |
| | | */ |
| | | @SaCheckPermission("system:dict:query") |
| | | @GetMapping(value = "/{dictId}") |
| | | public R<SysDictType> getInfo(@Parameter(name = "字典ID") @PathVariable Long dictId) { |
| | | public R<SysDictType> getInfo(@PathVariable Long dictId) { |
| | | return R.ok(dictTypeService.selectDictTypeById(dictId)); |
| | | } |
| | | |
| | |
| | | |
| | | /** |
| | | * 删除字典类型 |
| | | * |
| | | * @param dictIds 字典ID串 |
| | | */ |
| | | @SaCheckPermission("system:dict:remove") |
| | | @Log(title = "字典类型", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{dictIds}") |
| | | public R<Void> remove(@Parameter(name = "字典ID串") @PathVariable Long[] dictIds) { |
| | | public R<Void> remove(@PathVariable Long[] dictIds) { |
| | | dictTypeService.deleteDictTypeByIds(dictIds); |
| | | return R.ok(); |
| | | } |
| | |
| | | * @author Lion Li |
| | | */ |
| | | @Validated |
| | | @Tag(name ="登录验证控制器", description = "登录验证管理") |
| | | @Tag(name = "登录验证控制器", description = "登录验证管理") |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | public class SysLoginController { |
| | |
| | | return R.ok(ajax); |
| | | } |
| | | |
| | | /** |
| | | * 退出登录 |
| | | */ |
| | | @Anonymous |
| | | @PostMapping("/logout") |
| | | public R<Void> logout() { |
| | |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.system.service.ISysMenuService; |
| | | import io.swagger.v3.oas.annotations.Parameter; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.validation.annotation.Validated; |
| | |
| | | * @author Lion Li |
| | | */ |
| | | @Validated |
| | | @Tag(name ="菜单信息控制器", description = "菜单信息管理") |
| | | @Tag(name = "菜单信息控制器", description = "菜单信息管理") |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/system/menu") |
| | |
| | | |
| | | /** |
| | | * 根据菜单编号获取详细信息 |
| | | * |
| | | * @param menuId 菜单ID |
| | | */ |
| | | @SaCheckPermission("system:menu:query") |
| | | @GetMapping(value = "/{menuId}") |
| | | public R<SysMenu> getInfo(@Parameter(name = "菜单ID") @PathVariable Long menuId) { |
| | | public R<SysMenu> getInfo(@PathVariable Long menuId) { |
| | | return R.ok(menuService.selectMenuById(menuId)); |
| | | } |
| | | |
| | |
| | | |
| | | /** |
| | | * 加载对应角色菜单列表树 |
| | | * |
| | | * @param roleId 角色ID |
| | | */ |
| | | @GetMapping(value = "/roleMenuTreeselect/{roleId}") |
| | | public R<Map<String, Object>> roleMenuTreeselect(@Parameter(name = "角色ID") @PathVariable("roleId") Long roleId) { |
| | | public R<Map<String, Object>> roleMenuTreeselect(@PathVariable("roleId") Long roleId) { |
| | | List<SysMenu> menus = menuService.selectMenuList(getUserId()); |
| | | Map<String, Object> ajax = new HashMap<>(); |
| | | ajax.put("checkedKeys", menuService.selectMenuListByRoleId(roleId)); |
| | |
| | | |
| | | /** |
| | | * 删除菜单 |
| | | * |
| | | * @param menuId 菜单ID |
| | | */ |
| | | @SaCheckPermission("system:menu:remove") |
| | | @Log(title = "菜单管理", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{menuId}") |
| | | public R<Void> remove(@Parameter(name = "菜单ID") @PathVariable("menuId") Long menuId) { |
| | | public R<Void> remove(@PathVariable("menuId") Long menuId) { |
| | | if (menuService.hasChildByMenuId(menuId)) { |
| | | return R.fail("存在子菜单,不允许删除"); |
| | | } |
| | |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.system.domain.SysNotice; |
| | | import com.ruoyi.system.service.ISysNoticeService; |
| | | import io.swagger.v3.oas.annotations.Parameter; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.validation.annotation.Validated; |
| | |
| | | * @author Lion Li |
| | | */ |
| | | @Validated |
| | | @Tag(name ="公告信息控制器", description = "公告信息管理") |
| | | @Tag(name = "公告信息控制器", description = "公告信息管理") |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/system/notice") |
| | |
| | | |
| | | /** |
| | | * 根据通知公告编号获取详细信息 |
| | | * |
| | | * @param noticeId 公告ID |
| | | */ |
| | | @SaCheckPermission("system:notice:query") |
| | | @GetMapping(value = "/{noticeId}") |
| | | public R<SysNotice> getInfo(@Parameter(name = "公告ID") @PathVariable Long noticeId) { |
| | | public R<SysNotice> getInfo(@PathVariable Long noticeId) { |
| | | return R.ok(noticeService.selectNoticeById(noticeId)); |
| | | } |
| | | |
| | |
| | | |
| | | /** |
| | | * 删除通知公告 |
| | | * |
| | | * @param noticeIds 公告ID串 |
| | | */ |
| | | @SaCheckPermission("system:notice:remove") |
| | | @Log(title = "通知公告", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{noticeIds}") |
| | | public R<Void> remove(@Parameter(name = "公告ID串") @PathVariable Long[] noticeIds) { |
| | | public R<Void> remove(@PathVariable Long[] noticeIds) { |
| | | return toAjax(noticeService.deleteNoticeByIds(noticeIds)); |
| | | } |
| | | } |
| | |
| | | import com.ruoyi.system.domain.bo.SysOssConfigBo; |
| | | import com.ruoyi.system.domain.vo.SysOssConfigVo; |
| | | import com.ruoyi.system.service.ISysOssConfigService; |
| | | import io.swagger.v3.oas.annotations.Parameter; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.validation.annotation.Validated; |
| | |
| | | import java.util.Arrays; |
| | | |
| | | /** |
| | | * 对象存储配置Controller |
| | | * 对象存储配置 |
| | | * |
| | | * @author Lion Li |
| | | * @author 孤舟烟雨 |
| | | * @date 2021-08-13 |
| | | */ |
| | | @Validated |
| | | @Tag(name ="对象存储配置控制器", description = "对象存储配置管理") |
| | | @Tag(name = "对象存储配置控制器", description = "对象存储配置管理") |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/system/oss/config") |
| | |
| | | |
| | | /** |
| | | * 获取对象存储配置详细信息 |
| | | * |
| | | * @param ossConfigId OSS配置ID |
| | | */ |
| | | @SaCheckPermission("system:oss:query") |
| | | @GetMapping("/{ossConfigId}") |
| | | public R<SysOssConfigVo> getInfo(@Parameter(name = "OSS配置ID") |
| | | @NotNull(message = "主键不能为空") |
| | | @PathVariable("ossConfigId") Long ossConfigId) { |
| | | public R<SysOssConfigVo> getInfo(@NotNull(message = "主键不能为空") |
| | | @PathVariable Long ossConfigId) { |
| | | return R.ok(iSysOssConfigService.queryById(ossConfigId)); |
| | | } |
| | | |
| | |
| | | |
| | | /** |
| | | * 删除对象存储配置 |
| | | * |
| | | * @param ossConfigIds OSS配置ID串 |
| | | */ |
| | | @SaCheckPermission("system:oss:remove") |
| | | @Log(title = "对象存储配置", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{ossConfigIds}") |
| | | public R<Void> remove(@Parameter(name = "OSS配置ID串") |
| | | @NotEmpty(message = "主键不能为空") |
| | | @PathVariable Long[] ossConfigIds) { |
| | | public R<Void> remove(@NotEmpty(message = "主键不能为空") |
| | | @PathVariable Long[] ossConfigIds) { |
| | | return toAjax(iSysOssConfigService.deleteWithValidByIds(Arrays.asList(ossConfigIds), true) ? 1 : 0); |
| | | } |
| | | |
| | |
| | | import com.ruoyi.system.domain.bo.SysOssBo; |
| | | import com.ruoyi.system.domain.vo.SysOssVo; |
| | | import com.ruoyi.system.service.ISysOssService; |
| | | import io.swagger.v3.oas.annotations.Parameter; |
| | | import io.swagger.v3.oas.annotations.Parameters; |
| | | import io.swagger.v3.oas.annotations.enums.ParameterIn; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.http.MediaType; |
| | |
| | | * @author Lion Li |
| | | */ |
| | | @Validated |
| | | @Tag(name ="对象存储控制器", description = "对象存储管理") |
| | | @Tag(name = "对象存储控制器", description = "对象存储管理") |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/system/oss") |
| | |
| | | |
| | | /** |
| | | * 查询OSS对象基于id串 |
| | | * |
| | | * @param ossIds OSS对象ID串 |
| | | */ |
| | | @SaCheckPermission("system:oss:list") |
| | | @GetMapping("/listByIds/{ossIds}") |
| | | public R<List<SysOssVo>> listByIds(@Parameter(name = "OSS对象ID串") |
| | | @NotEmpty(message = "主键不能为空") |
| | | @PathVariable Long[] ossIds) { |
| | | public R<List<SysOssVo>> listByIds(@NotEmpty(message = "主键不能为空") |
| | | @PathVariable Long[] ossIds) { |
| | | List<SysOssVo> list = iSysOssService.listByIds(Arrays.asList(ossIds)); |
| | | return R.ok(list); |
| | | } |
| | | |
| | | /** |
| | | * 上传OSS对象存储 |
| | | * |
| | | * @param file 文件 |
| | | */ |
| | | @Parameters({ |
| | | @Parameter(name = "file", description = "文件", in = ParameterIn.QUERY, required = true) |
| | | }) |
| | | @SaCheckPermission("system:oss:upload") |
| | | @Log(title = "OSS对象存储", businessType = BusinessType.INSERT) |
| | | @PostMapping("/upload") |
| | | @PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) |
| | | public R<Map<String, String>> upload(@RequestPart("file") MultipartFile file) { |
| | | if (ObjectUtil.isNull(file)) { |
| | | throw new ServiceException("上传文件不能为空"); |
| | |
| | | return R.ok(map); |
| | | } |
| | | |
| | | /** |
| | | * 下载OSS对象 |
| | | * |
| | | * @param ossId OSS对象ID |
| | | */ |
| | | @SaCheckPermission("system:oss:download") |
| | | @GetMapping("/download/{ossId}") |
| | | public void download(@Parameter(name = "OSS对象ID") @PathVariable Long ossId, HttpServletResponse response) throws IOException { |
| | | public void download(@PathVariable Long ossId, HttpServletResponse response) throws IOException { |
| | | SysOss sysOss = iSysOssService.getById(ossId); |
| | | if (ObjectUtil.isNull(sysOss)) { |
| | | throw new ServiceException("文件数据不存在!"); |
| | |
| | | |
| | | /** |
| | | * 删除OSS对象存储 |
| | | * |
| | | * @param ossIds OSS对象ID串 |
| | | */ |
| | | @SaCheckPermission("system:oss:remove") |
| | | @Log(title = "OSS对象存储", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{ossIds}") |
| | | public R<Void> remove(@Parameter(name = "OSS对象ID串") |
| | | @NotEmpty(message = "主键不能为空") |
| | | @PathVariable Long[] ossIds) { |
| | | public R<Void> remove(@NotEmpty(message = "主键不能为空") |
| | | @PathVariable Long[] ossIds) { |
| | | return toAjax(iSysOssService.deleteWithValidByIds(Arrays.asList(ossIds), true) ? 1 : 0); |
| | | } |
| | | |
| | |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.system.domain.SysPost; |
| | | import com.ruoyi.system.service.ISysPostService; |
| | | import io.swagger.v3.oas.annotations.Parameter; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.validation.annotation.Validated; |
| | |
| | | return postService.selectPagePostList(post, pageQuery); |
| | | } |
| | | |
| | | /** |
| | | * 导出岗位列表 |
| | | */ |
| | | @Log(title = "岗位管理", businessType = BusinessType.EXPORT) |
| | | @SaCheckPermission("system:post:export") |
| | | @PostMapping("/export") |
| | |
| | | |
| | | /** |
| | | * 根据岗位编号获取详细信息 |
| | | * |
| | | * @param postId 岗位ID |
| | | */ |
| | | @SaCheckPermission("system:post:query") |
| | | @GetMapping(value = "/{postId}") |
| | | public R<SysPost> getInfo(@Parameter(name = "岗位ID") @PathVariable Long postId) { |
| | | public R<SysPost> getInfo(@PathVariable Long postId) { |
| | | return R.ok(postService.selectPostById(postId)); |
| | | } |
| | | |
| | |
| | | |
| | | /** |
| | | * 删除岗位 |
| | | * |
| | | * @param postIds 岗位ID串 |
| | | */ |
| | | @SaCheckPermission("system:post:remove") |
| | | @Log(title = "岗位管理", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{postIds}") |
| | | public R<Void> remove(@Parameter(name = "岗位ID串") @PathVariable Long[] postIds) { |
| | | public R<Void> remove(@PathVariable Long[] postIds) { |
| | | return toAjax(postService.deletePostByIds(postIds)); |
| | | } |
| | | |
| | |
| | | import com.ruoyi.system.domain.SysOss; |
| | | import com.ruoyi.system.service.ISysOssService; |
| | | import com.ruoyi.system.service.ISysUserService; |
| | | import io.swagger.v3.oas.annotations.Parameter; |
| | | import io.swagger.v3.oas.annotations.Parameters; |
| | | import io.swagger.v3.oas.annotations.enums.ParameterIn; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | |
| | | * @author Lion Li |
| | | */ |
| | | @Validated |
| | | @Tag(name ="个人信息控制器", description = "个人信息管理") |
| | | @Tag(name = "个人信息控制器", description = "个人信息管理") |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/system/user/profile") |
| | |
| | | |
| | | /** |
| | | * 重置密码 |
| | | * |
| | | * @param newPassword 旧密码 |
| | | * @param oldPassword 新密码 |
| | | */ |
| | | @Parameters({ |
| | | @Parameter(name = "oldPassword", description = "旧密码", in = ParameterIn.QUERY), |
| | | @Parameter(name = "newPassword", description = "新密码", in = ParameterIn.QUERY) |
| | | }) |
| | | @Log(title = "个人信息", businessType = BusinessType.UPDATE) |
| | | @PutMapping("/updatePwd") |
| | | public R<Void> updatePwd(String oldPassword, String newPassword) { |
| | |
| | | |
| | | /** |
| | | * 头像上传 |
| | | * |
| | | * @param avatarfile 用户头像 |
| | | */ |
| | | @Parameters({ |
| | | @Parameter(name = "avatarfile", description = "用户头像", in = ParameterIn.QUERY, required = true) |
| | | }) |
| | | @Log(title = "用户头像", businessType = BusinessType.UPDATE) |
| | | @PostMapping("/avatar") |
| | | public R<Map<String, Object>> avatar(@RequestPart("avatarfile") MultipartFile file) { |
| | | @PostMapping(value = "/avatar", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) |
| | | public R<Map<String, Object>> avatar(@RequestPart("avatarfile") MultipartFile avatarfile) { |
| | | Map<String, Object> ajax = new HashMap<>(); |
| | | if (!file.isEmpty()) { |
| | | String extension = FileUtil.extName(file.getOriginalFilename()); |
| | | if (!avatarfile.isEmpty()) { |
| | | String extension = FileUtil.extName(avatarfile.getOriginalFilename()); |
| | | if (!StringUtils.equalsAnyIgnoreCase(extension, MimeTypeUtils.IMAGE_EXTENSION)) { |
| | | return R.fail("文件格式不正确,请上传" + Arrays.toString(MimeTypeUtils.IMAGE_EXTENSION) + "格式"); |
| | | } |
| | | SysOss oss = iSysOssService.upload(file); |
| | | SysOss oss = iSysOssService.upload(avatarfile); |
| | | String avatar = oss.getUrl(); |
| | | if (userService.updateUserAvatar(getUsername(), avatar)) { |
| | | ajax.put("imgUrl", avatar); |
| | |
| | | * @author Lion Li |
| | | */ |
| | | @Validated |
| | | @Tag(name ="注册验证控制器", description = "注册验证管理") |
| | | @Tag(name = "注册验证控制器", description = "注册验证管理") |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | public class SysRegisterController extends BaseController { |
| | |
| | | private final SysRegisterService registerService; |
| | | private final ISysConfigService configService; |
| | | |
| | | /** |
| | | * 用户注册 |
| | | */ |
| | | @Anonymous |
| | | @PostMapping("/register") |
| | | public R<Void> register(@Validated @RequestBody RegisterBody user) { |
| | |
| | | import com.ruoyi.system.service.ISysRoleService; |
| | | import com.ruoyi.system.service.ISysUserService; |
| | | import com.ruoyi.system.service.SysPermissionService; |
| | | import io.swagger.v3.oas.annotations.Parameter; |
| | | import io.swagger.v3.oas.annotations.Parameters; |
| | | import io.swagger.v3.oas.annotations.enums.ParameterIn; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.validation.annotation.Validated; |
| | |
| | | * @author Lion Li |
| | | */ |
| | | @Validated |
| | | @Tag(name ="角色信息控制器", description = "角色信息管理") |
| | | @Tag(name = "角色信息控制器", description = "角色信息管理") |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/system/role") |
| | |
| | | private final ISysUserService userService; |
| | | private final SysPermissionService permissionService; |
| | | |
| | | /** |
| | | * 获取角色信息列表 |
| | | */ |
| | | @SaCheckPermission("system:role:list") |
| | | @GetMapping("/list") |
| | | public TableDataInfo<SysRole> list(SysRole role, PageQuery pageQuery) { |
| | | return roleService.selectPageRoleList(role, pageQuery); |
| | | } |
| | | |
| | | /** |
| | | * 导出角色信息列表 |
| | | */ |
| | | @Log(title = "角色管理", businessType = BusinessType.EXPORT) |
| | | @SaCheckPermission("system:role:export") |
| | | @PostMapping("/export") |
| | |
| | | |
| | | /** |
| | | * 根据角色编号获取详细信息 |
| | | * |
| | | * @param roleId 角色ID |
| | | */ |
| | | @SaCheckPermission("system:role:query") |
| | | @GetMapping(value = "/{roleId}") |
| | | public R<SysRole> getInfo(@Parameter(name = "角色ID") @PathVariable Long roleId) { |
| | | public R<SysRole> getInfo(@PathVariable Long roleId) { |
| | | roleService.checkRoleDataScope(roleId); |
| | | return R.ok(roleService.selectRoleById(roleId)); |
| | | } |
| | |
| | | |
| | | /** |
| | | * 删除角色 |
| | | * |
| | | * @param roleIds 角色ID串 |
| | | */ |
| | | @SaCheckPermission("system:role:remove") |
| | | @Log(title = "角色管理", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{roleIds}") |
| | | public R<Void> remove(@Parameter(name = "角色ID串") @PathVariable Long[] roleIds) { |
| | | public R<Void> remove(@PathVariable Long[] roleIds) { |
| | | return toAjax(roleService.deleteRoleByIds(roleIds)); |
| | | } |
| | | |
| | |
| | | |
| | | /** |
| | | * 批量取消授权用户 |
| | | * |
| | | * @param roleId 角色ID |
| | | * @param userIds 用户ID串 |
| | | */ |
| | | @Parameters({ |
| | | @Parameter(name = "roleId", description = "角色ID", in = ParameterIn.QUERY), |
| | | @Parameter(name = "userIds", description = "用户ID串", in = ParameterIn.QUERY) |
| | | }) |
| | | @SaCheckPermission("system:role:edit") |
| | | @Log(title = "角色管理", businessType = BusinessType.GRANT) |
| | | @PutMapping("/authUser/cancelAll") |
| | |
| | | |
| | | /** |
| | | * 批量选择用户授权 |
| | | * |
| | | * @param roleId 角色ID |
| | | * @param userIds 用户ID串 |
| | | */ |
| | | @Parameters({ |
| | | @Parameter(name = "roleId", description = "角色ID", in = ParameterIn.QUERY), |
| | | @Parameter(name = "userIds", description = "用户ID串", in = ParameterIn.QUERY) |
| | | }) |
| | | @SaCheckPermission("system:role:edit") |
| | | @Log(title = "角色管理", businessType = BusinessType.GRANT) |
| | | @PutMapping("/authUser/selectAll") |
| | |
| | | import com.ruoyi.system.service.ISysPostService; |
| | | import com.ruoyi.system.service.ISysRoleService; |
| | | import com.ruoyi.system.service.ISysUserService; |
| | | import io.swagger.v3.oas.annotations.Parameter; |
| | | import io.swagger.v3.oas.annotations.Parameters; |
| | | import io.swagger.v3.oas.annotations.enums.ParameterIn; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | |
| | | * @author Lion Li |
| | | */ |
| | | @Validated |
| | | @Tag(name ="用户信息控制器", description = "用户信息管理") |
| | | @Tag(name = "用户信息控制器", description = "用户信息管理") |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/system/user") |
| | |
| | | return userService.selectPageUserList(user, pageQuery); |
| | | } |
| | | |
| | | /** |
| | | * 导出用户列表 |
| | | */ |
| | | @Log(title = "用户管理", businessType = BusinessType.EXPORT) |
| | | @SaCheckPermission("system:user:export") |
| | | @PostMapping("/export") |
| | |
| | | ExcelUtil.exportExcel(listVo, "用户数据", SysUserExportVo.class, response); |
| | | } |
| | | |
| | | @Parameters({ |
| | | @Parameter(name = "file", description = "导入文件", required = true), |
| | | }) |
| | | /** |
| | | * 导入数据 |
| | | * |
| | | * @param file 导入文件 |
| | | * @param updateSupport 是否更新已存在数据 |
| | | */ |
| | | @Log(title = "用户管理", businessType = BusinessType.IMPORT) |
| | | @SaCheckPermission("system:user:import") |
| | | @PostMapping("/importData") |
| | | @PostMapping(value = "/importData", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) |
| | | public R<Void> importData(@RequestPart("file") MultipartFile file, boolean updateSupport) throws Exception { |
| | | ExcelResult<SysUserImportVo> result = ExcelUtil.importExcel(file.getInputStream(), SysUserImportVo.class, new SysUserImportListener(updateSupport)); |
| | | return R.ok(result.getAnalysis()); |
| | | } |
| | | |
| | | /** |
| | | * 获取导入模板 |
| | | */ |
| | | @PostMapping("/importTemplate") |
| | | public void importTemplate(HttpServletResponse response) { |
| | | ExcelUtil.exportExcel(new ArrayList<>(), "用户数据", SysUserImportVo.class, response); |
| | |
| | | |
| | | /** |
| | | * 根据用户编号获取详细信息 |
| | | * |
| | | * @param userId 用户ID |
| | | */ |
| | | @SaCheckPermission("system:user:query") |
| | | @GetMapping(value = {"/", "/{userId}"}) |
| | | public R<Map<String, Object>> getInfo(@Parameter(name = "用户ID") @PathVariable(value = "userId", required = false) Long userId) { |
| | | public R<Map<String, Object>> getInfo(@PathVariable(value = "userId", required = false) Long userId) { |
| | | userService.checkUserDataScope(userId); |
| | | Map<String, Object> ajax = new HashMap<>(); |
| | | List<SysRole> roles = roleService.selectRoleAll(); |
| | |
| | | |
| | | /** |
| | | * 删除用户 |
| | | * |
| | | * @param userIds 角色ID串 |
| | | */ |
| | | @SaCheckPermission("system:user:remove") |
| | | @Log(title = "用户管理", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{userIds}") |
| | | public R<Void> remove(@Parameter(name = "角色ID串") @PathVariable Long[] userIds) { |
| | | public R<Void> remove(@PathVariable Long[] userIds) { |
| | | if (ArrayUtil.contains(userIds, getUserId())) { |
| | | return R.fail("当前用户不能删除"); |
| | | } |
| | |
| | | |
| | | /** |
| | | * 根据用户编号获取授权角色 |
| | | * |
| | | * @param userId 用户ID |
| | | */ |
| | | @SaCheckPermission("system:user:query") |
| | | @GetMapping("/authRole/{userId}") |
| | | public R<Map<String, Object>> authRole(@Parameter(name = "用户ID") @PathVariable("userId") Long userId) { |
| | | public R<Map<String, Object>> authRole(@PathVariable Long userId) { |
| | | SysUser user = userService.selectUserById(userId); |
| | | List<SysRole> roles = roleService.selectRolesByUserId(userId); |
| | | Map<String, Object> ajax = new HashMap<>(); |
| | |
| | | |
| | | /** |
| | | * 用户授权角色 |
| | | * |
| | | * @param userId 用户Id |
| | | * @param roleIds 角色ID串 |
| | | */ |
| | | @Parameters({ |
| | | @Parameter(name = "userId", description = "用户Id", in = ParameterIn.QUERY), |
| | | @Parameter(name = "roleIds", description = "角色ID串", in = ParameterIn.QUERY) |
| | | }) |
| | | @SaCheckPermission("system:user:edit") |
| | | @Log(title = "用户管理", businessType = BusinessType.GRANT) |
| | | @PutMapping("/authRole") |
| | |
| | | swagger-ui: |
| | | # 修改Swagger UI路径 |
| | | path: /doc.html |
| | | # 开启Swagger UI界面 |
| | | enabled: true |
| | | api-docs: |
| | | # 修改api-docs路径 |
| | | path: /v3/api-docs |
| | | # 开启api-docs |
| | | enabled: true |
| | | # 持久化认证数据 |
| | | persistAuthorization: true |
| | | #这里定义了两个分组,可定义多个,也可以不定义 |
| | | group-configs: |
| | | - group: 1.演示模块 |
| | |
| | | |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.utils.email.MailUtils; |
| | | import io.swagger.v3.oas.annotations.Parameter; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.validation.annotation.Validated; |
| | |
| | | * @author Michelle.Chung |
| | | */ |
| | | @Validated |
| | | @Tag(name ="邮件发送案例", description = "邮件发送案例") |
| | | @Tag(name = "邮件发送案例", description = "邮件发送案例") |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/demo/mail") |
| | | public class MailController { |
| | | |
| | | /** |
| | | * 发送邮件 |
| | | * |
| | | * @param to 接收人 |
| | | * @param subject 标题 |
| | | * @param text 内容 |
| | | */ |
| | | @GetMapping("/sendSimpleMessage") |
| | | public R<Void> sendSimpleMessage(@Parameter(name = "接收人") String to, |
| | | @Parameter(name = "标题") String subject, |
| | | @Parameter(name = "内容") String text) { |
| | | public R<Void> sendSimpleMessage(String to, String subject, String text) { |
| | | MailUtils.sendText(to, subject, text); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 发送邮件(带附件) |
| | | * |
| | | * @param to 接收人 |
| | | * @param subject 标题 |
| | | * @param text 内容 |
| | | * @param filePath 附件路径 |
| | | */ |
| | | @GetMapping("/sendMessageWithAttachment") |
| | | public R<Void> sendMessageWithAttachment(@Parameter(name = "接收人") String to, |
| | | @Parameter(name = "标题") String subject, |
| | | @Parameter(name = "内容") String text, |
| | | @Parameter(name = "附件路径") String filePath) { |
| | | public R<Void> sendMessageWithAttachment(String to, String subject, String text, String filePath) { |
| | | MailUtils.sendText(to, subject, text, new File(filePath)); |
| | | return R.ok(); |
| | | } |
| | |
| | | |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.utils.redis.RedisUtils; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.cache.annotation.CacheEvict; |
| | |
| | | */ |
| | | // 类级别 缓存统一配置 |
| | | //@CacheConfig(cacheNames = "redissonCacheMap") |
| | | @Tag(name ="spring-cache 演示案例", description = "spring-cache 演示案例") |
| | | @Tag(name = "spring-cache 演示案例", description = "spring-cache 演示案例") |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/demo/cache") |
| | |
| | | * |
| | | * @author shenxinquan |
| | | */ |
| | | @Tag(name ="测试分布式锁的样例", description = "测试分布式锁的样例") |
| | | @Tag(name = "测试分布式锁的样例", description = "测试分布式锁的样例") |
| | | @Slf4j |
| | | @RestController |
| | | @RequestMapping("/demo/redisLock") |
| | |
| | | |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.utils.redis.RedisUtils; |
| | | import io.swagger.v3.oas.annotations.Parameter; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @Tag(name ="Redis发布订阅 演示案例", description = "Redis发布订阅") |
| | | @Tag(name = "Redis发布订阅 演示案例", description = "Redis发布订阅") |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/demo/redis/pubsub") |
| | | public class RedisPubSubController { |
| | | |
| | | /** |
| | | * 发布消息 |
| | | * |
| | | * @param key 通道Key |
| | | * @param value 发送内容 |
| | | */ |
| | | @GetMapping("/pub") |
| | | public R<Void> pub(@Parameter(name = "通道Key") String key, @Parameter(name = "发送内容") String value) { |
| | | public R<Void> pub(String key, String value) { |
| | | RedisUtils.publish(key, value, consumer -> { |
| | | System.out.println("发布通道 => " + key + ", 发送值 => " + value); |
| | | }); |
| | | return R.ok("操作成功"); |
| | | } |
| | | |
| | | /** |
| | | * 订阅消息 |
| | | * |
| | | * @param key 通道Key |
| | | */ |
| | | @GetMapping("/sub") |
| | | public R<Void> sub(@Parameter(name = "通道Key") String key) { |
| | | public R<Void> sub(String key) { |
| | | RedisUtils.subscribe(key, String.class, msg -> { |
| | | System.out.println("订阅通道 => " + key + ", 接收值 => " + msg); |
| | | }); |
| | |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @Tag(name ="测试分布式限流样例", description = "测试分布式限流样例") |
| | | @Tag(name = "测试分布式限流样例", description = "测试分布式限流样例") |
| | | @Slf4j |
| | | @RestController |
| | | @RequestMapping("/demo/rateLimiter") |
| | |
| | | import com.ruoyi.common.utils.spring.SpringUtils; |
| | | import com.ruoyi.sms.config.properties.SmsProperties; |
| | | import com.ruoyi.sms.core.SmsTemplate; |
| | | import io.swagger.v3.oas.annotations.Parameter; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.validation.annotation.Validated; |
| | |
| | | * @version 4.2.0 |
| | | */ |
| | | @Validated |
| | | @Tag(name ="短信演示案例", description = "短信演示案例") |
| | | @Tag(name = "短信演示案例", description = "短信演示案例") |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/demo/sms") |
| | |
| | | // private final SmsTemplate smsTemplate; // 可以使用spring注入 |
| | | // private final AliyunSmsTemplate smsTemplate; // 也可以注入某个厂家的模板工具 |
| | | |
| | | /** |
| | | * 发送短信Aliyun |
| | | * |
| | | * @param phones 电话号 |
| | | * @param templateId 模板ID |
| | | */ |
| | | @GetMapping("/sendAliyun") |
| | | public R<Object> sendAliyun(@Parameter(name = "电话号") String phones, |
| | | @Parameter(name = "模板ID") String templateId) { |
| | | public R<Object> sendAliyun(String phones, String templateId) { |
| | | if (!smsProperties.getEnabled()) { |
| | | return R.fail("当前系统没有开启短信功能!"); |
| | | } |
| | |
| | | return R.ok(send); |
| | | } |
| | | |
| | | /** |
| | | * 发送短信Tencent |
| | | * |
| | | * @param phones 电话号 |
| | | * @param templateId 模板ID |
| | | */ |
| | | @GetMapping("/sendTencent") |
| | | public R<Object> sendTencent(@Parameter(name = "电话号") String phones, |
| | | @Parameter(name = "模板ID") String templateId) { |
| | | public R<Object> sendTencent(String phones, String templateId) { |
| | | if (!smsProperties.getEnabled()) { |
| | | return R.fail("当前系统没有开启短信功能!"); |
| | | } |
| | |
| | | package com.ruoyi.demo.controller; |
| | | |
| | | import com.ruoyi.common.core.domain.R; |
| | | import io.swagger.v3.oas.annotations.Parameter; |
| | | import io.swagger.v3.oas.annotations.Parameters; |
| | | import io.swagger.v3.oas.annotations.enums.ParameterIn; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestPart; |
| | |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @Tag(name ="演示swagger3控制器", description = "演示swagger3接口") |
| | | @Tag(name = "演示swagger3控制器", description = "演示swagger3接口") |
| | | @RestController |
| | | @RequestMapping("/swagger/demo") |
| | | public class Swagger3DemoController { |
| | |
| | | /** |
| | | * 上传请求 |
| | | * 必须使用 @RequestPart 注解标注为文件 |
| | | * |
| | | * @param file 文件 |
| | | */ |
| | | @Parameters({ |
| | | @Parameter(name = "file", description = "文件", in = ParameterIn.QUERY, required = true) |
| | | }) |
| | | @PostMapping(value = "/upload") |
| | | @PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) |
| | | public R<String> upload(@RequestPart("file") MultipartFile file) { |
| | | return R.ok("操作成功", file.getOriginalFilename()); |
| | | } |
| | |
| | | * @author Lion Li |
| | | * @date 2021-05-30 |
| | | */ |
| | | @Tag(name ="测试批量方法", description = "测试批量方法") |
| | | @Tag(name = "测试批量方法", description = "测试批量方法") |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/demo/batch") |
| | |
| | | testDemo.setOrderNum(-1); |
| | | testDemo.setTestKey("批量新增"); |
| | | testDemo.setValue("测试新增"); |
| | | list.add(testDemo); } |
| | | list.add(testDemo); |
| | | } |
| | | testDemoMapper.insertBatch(list); |
| | | for (int i = 0; i < list.size(); i++) { |
| | | TestDemo testDemo = list.get(i); |
| | |
| | | import com.ruoyi.demo.domain.bo.TestDemoImportVo; |
| | | import com.ruoyi.demo.domain.vo.TestDemoVo; |
| | | import com.ruoyi.demo.service.ITestDemoService; |
| | | import io.swagger.v3.oas.annotations.Parameter; |
| | | import io.swagger.v3.oas.annotations.Parameters; |
| | | import io.swagger.v3.oas.annotations.enums.ParameterIn; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | |
| | | * @date 2021-07-26 |
| | | */ |
| | | @Validated |
| | | @Tag(name ="测试单表控制器", description = "测试单表管理") |
| | | @Tag(name = "测试单表控制器", description = "测试单表管理") |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/demo/demo") |
| | |
| | | return iTestDemoService.customPageList(bo, pageQuery); |
| | | } |
| | | |
| | | @Parameters({ |
| | | @Parameter(name = "file", description = "导入文件", in = ParameterIn.QUERY, required = true), |
| | | }) |
| | | /** |
| | | * 导入数据 |
| | | * |
| | | * @param file 导入文件 |
| | | */ |
| | | @Log(title = "测试单表", businessType = BusinessType.IMPORT) |
| | | @SaCheckPermission("demo:demo:import") |
| | | @PostMapping("/importData") |
| | | @PostMapping(value = "/importData", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) |
| | | public R<Void> importData(@RequestPart("file") MultipartFile file) throws Exception { |
| | | ExcelResult<TestDemoImportVo> excelResult = ExcelUtil.importExcel(file.getInputStream(), TestDemoImportVo.class, true); |
| | | List<TestDemoImportVo> volist = excelResult.getList(); |
| | |
| | | |
| | | /** |
| | | * 获取测试单表详细信息 |
| | | * |
| | | * @param id 测试ID |
| | | */ |
| | | @SaCheckPermission("demo:demo:query") |
| | | @GetMapping("/{id}") |
| | | public R<TestDemoVo> getInfo(@Parameter(name = "测试ID") |
| | | @NotNull(message = "主键不能为空") |
| | | @PathVariable("id") Long id) { |
| | | public R<TestDemoVo> getInfo(@NotNull(message = "主键不能为空") |
| | | @PathVariable("id") Long id) { |
| | | return R.ok(iTestDemoService.queryById(id)); |
| | | } |
| | | |
| | |
| | | |
| | | /** |
| | | * 删除测试单表 |
| | | * |
| | | * @param ids 测试ID串 |
| | | */ |
| | | @SaCheckPermission("demo:demo:remove") |
| | | @Log(title = "测试单表", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{ids}") |
| | | public R<Void> remove(@Parameter(name = "测试ID串") |
| | | @NotEmpty(message = "主键不能为空") |
| | | @PathVariable Long[] ids) { |
| | | public R<Void> remove(@NotEmpty(message = "主键不能为空") |
| | | @PathVariable Long[] ids) { |
| | | return toAjax(iTestDemoService.deleteWithValidByIds(Arrays.asList(ids), true) ? 1 : 0); |
| | | } |
| | | } |
| | |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @Tag(name ="测试Excel功能", description = "测试Excel功能") |
| | | @Tag(name = "测试Excel功能", description = "测试Excel功能") |
| | | @RestController |
| | | @RequestMapping("/demo/excel") |
| | | public class TestExcelController { |
| | |
| | | */ |
| | | @GetMapping("/exportTemplateOne") |
| | | public void exportTemplateOne(HttpServletResponse response) { |
| | | Map<String,String> map = new HashMap<>(); |
| | | map.put("title","单列表多数据"); |
| | | map.put("test1","数据测试1"); |
| | | map.put("test2","数据测试2"); |
| | | map.put("test3","数据测试3"); |
| | | map.put("test4","数据测试4"); |
| | | map.put("testTest","666"); |
| | | Map<String, String> map = new HashMap<>(); |
| | | map.put("title", "单列表多数据"); |
| | | map.put("test1", "数据测试1"); |
| | | map.put("test2", "数据测试2"); |
| | | map.put("test3", "数据测试3"); |
| | | map.put("test4", "数据测试4"); |
| | | map.put("testTest", "666"); |
| | | List<TestObj> list = new ArrayList<>(); |
| | | list.add(new TestObj("单列表测试1", "列表测试1", "列表测试2", "列表测试3", "列表测试4")); |
| | | list.add(new TestObj("单列表测试2", "列表测试5", "列表测试6", "列表测试7", "列表测试8")); |
| | | list.add(new TestObj("单列表测试3", "列表测试9", "列表测试10", "列表测试11", "列表测试12")); |
| | | ExcelUtil.exportTemplate(CollUtil.newArrayList(map,list),"单列表.xlsx", "excel/单列表.xlsx", response); |
| | | ExcelUtil.exportTemplate(CollUtil.newArrayList(map, list), "单列表.xlsx", "excel/单列表.xlsx", response); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @GetMapping("/exportTemplateMuliti") |
| | | public void exportTemplateMuliti(HttpServletResponse response) { |
| | | Map<String,String> map = new HashMap<>(); |
| | | map.put("title1","标题1"); |
| | | map.put("title2","标题2"); |
| | | map.put("title3","标题3"); |
| | | map.put("title4","标题4"); |
| | | map.put("author","Lion Li"); |
| | | Map<String, String> map = new HashMap<>(); |
| | | map.put("title1", "标题1"); |
| | | map.put("title2", "标题2"); |
| | | map.put("title3", "标题3"); |
| | | map.put("title4", "标题4"); |
| | | map.put("author", "Lion Li"); |
| | | List<TestObj1> list1 = new ArrayList<>(); |
| | | list1.add(new TestObj1("list1测试1", "list1测试2", "list1测试3")); |
| | | list1.add(new TestObj1("list1测试4", "list1测试5", "list1测试6")); |
| | |
| | | list4.add(new TestObj1("list4测试4", "list4测试5", "list4测试6")); |
| | | list4.add(new TestObj1("list4测试7", "list4测试8", "list4测试9")); |
| | | list4.add(new TestObj1("list4测试10", "list4测试11", "list4测试12")); |
| | | Map<String,Object> multiListMap = new HashMap<>(); |
| | | multiListMap.put("map",map); |
| | | multiListMap.put("data1",list1); |
| | | multiListMap.put("data2",list2); |
| | | multiListMap.put("data3",list3); |
| | | multiListMap.put("data4",list4); |
| | | Map<String, Object> multiListMap = new HashMap<>(); |
| | | multiListMap.put("map", map); |
| | | multiListMap.put("data1", list1); |
| | | multiListMap.put("data2", list2); |
| | | multiListMap.put("data3", list3); |
| | | multiListMap.put("data4", list4); |
| | | ExcelUtil.exportTemplateMultiList(multiListMap, "多列表.xlsx", "excel/多列表.xlsx", response); |
| | | } |
| | | |
| | |
| | | |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.utils.MessageUtils; |
| | | import io.swagger.v3.oas.annotations.Parameter; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import lombok.Data; |
| | | import org.hibernate.validator.constraints.Range; |
| | |
| | | * @author Lion Li |
| | | */ |
| | | @Validated |
| | | @Tag(name ="测试国际化控制器", description = "测试国际化管理") |
| | | @Tag(name = "测试国际化控制器", description = "测试国际化管理") |
| | | @RestController |
| | | @RequestMapping("/demo/i18n") |
| | | public class TestI18nController { |
| | |
| | | * code为 messages.properties 中的 key |
| | | * <p> |
| | | * 测试使用 user.register.success |
| | | * |
| | | * @param code 国际化code |
| | | */ |
| | | @GetMapping() |
| | | public R<Void> get(@Parameter(name = "国际化code") String code) { |
| | | public R<Void> get(String code) { |
| | | return R.ok(MessageUtils.message(code)); |
| | | } |
| | | |
| | |
| | | * @version 3.6.0 |
| | | * @see com.ruoyi.common.core.service.SensitiveService |
| | | */ |
| | | @Tag(name ="测试数据脱敏控制器", description = "测试数据脱敏管理") |
| | | @Tag(name = "测试数据脱敏控制器", description = "测试数据脱敏管理") |
| | | @RestController |
| | | @RequestMapping("/demo/sensitive") |
| | | public class TestSensitiveController extends BaseController { |
| | |
| | | import com.ruoyi.demo.domain.bo.TestTreeBo; |
| | | import com.ruoyi.demo.domain.vo.TestTreeVo; |
| | | import com.ruoyi.demo.service.ITestTreeService; |
| | | import io.swagger.v3.oas.annotations.Parameter; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.validation.annotation.Validated; |
| | |
| | | * @date 2021-07-26 |
| | | */ |
| | | @Validated |
| | | @Tag(name ="测试树表控制器", description = "测试树表管理") |
| | | @Tag(name = "测试树表控制器", description = "测试树表管理") |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/demo/tree") |
| | |
| | | |
| | | /** |
| | | * 获取测试树表详细信息 |
| | | * |
| | | * @param id 测试树ID |
| | | */ |
| | | @SaCheckPermission("demo:tree:query") |
| | | @GetMapping("/{id}") |
| | | public R<TestTreeVo> getInfo(@Parameter(name = "测试树ID") |
| | | @NotNull(message = "主键不能为空") |
| | | @PathVariable("id") Long id) { |
| | | public R<TestTreeVo> getInfo(@NotNull(message = "主键不能为空") |
| | | @PathVariable("id") Long id) { |
| | | return R.ok(iTestTreeService.queryById(id)); |
| | | } |
| | | |
| | |
| | | |
| | | /** |
| | | * 删除测试树表 |
| | | * |
| | | * @param ids 测试树ID串 |
| | | */ |
| | | @SaCheckPermission("demo:tree:remove") |
| | | @Log(title = "测试树表", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{ids}") |
| | | public R<Void> remove(@Parameter(name = "测试树ID串") |
| | | @NotEmpty(message = "主键不能为空") |
| | | @PathVariable Long[] ids) { |
| | | public R<Void> remove(@NotEmpty(message = "主键不能为空") |
| | | @PathVariable Long[] ids) { |
| | | return toAjax(iTestTreeService.deleteWithValidByIds(Arrays.asList(ids), true) ? 1 : 0); |
| | | } |
| | | } |
| | |
| | | |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.utils.redis.QueueUtils; |
| | | import io.swagger.v3.oas.annotations.Parameter; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | * @version 3.6.0 |
| | | */ |
| | | @Slf4j |
| | | @Tag(name ="有界队列 演示案例", description = "有界队列") |
| | | @Tag(name = "有界队列 演示案例", description = "有界队列") |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/demo/queue/bounded") |
| | | public class BoundedQueueController { |
| | | |
| | | |
| | | /** |
| | | * 添加队列数据 |
| | | * |
| | | * @param queueName 队列名 |
| | | * @param capacity 容量 |
| | | */ |
| | | @GetMapping("/add") |
| | | public R<Void> add(@Parameter(name = "队列名") String queueName, |
| | | @Parameter(name = "容量") int capacity) { |
| | | public R<Void> add(String queueName, int capacity) { |
| | | // 用完了一定要销毁 否则会一直存在 |
| | | boolean b = QueueUtils.destroyBoundedQueueObject(queueName); |
| | | log.info("通道: {} , 删除: {}", queueName, b); |
| | |
| | | return R.ok("操作成功"); |
| | | } |
| | | |
| | | /** |
| | | * 删除队列数据 |
| | | * |
| | | * @param queueName 队列名 |
| | | */ |
| | | @GetMapping("/remove") |
| | | public R<Void> remove(@Parameter(name = "队列名") String queueName) { |
| | | public R<Void> remove(String queueName) { |
| | | String data = "data-" + 5; |
| | | if (QueueUtils.removeBoundedQueueObject(queueName, data)) { |
| | | log.info("通道: {} , 删除数据: {}", queueName, data); |
| | |
| | | return R.ok("操作成功"); |
| | | } |
| | | |
| | | /** |
| | | * 获取队列数据 |
| | | * |
| | | * @param queueName 队列名 |
| | | */ |
| | | @GetMapping("/get") |
| | | public R<Void> get(@Parameter(name = "队列名") String queueName) { |
| | | public R<Void> get(String queueName) { |
| | | String data; |
| | | do { |
| | | data = QueueUtils.getBoundedQueueObject(queueName); |
| | |
| | | |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.utils.redis.QueueUtils; |
| | | import io.swagger.v3.oas.annotations.Parameter; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | * @version 3.6.0 |
| | | */ |
| | | @Slf4j |
| | | @Tag(name ="延迟队列 演示案例", description = "延迟队列") |
| | | @Tag(name = "延迟队列 演示案例", description = "延迟队列") |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/demo/queue/delayed") |
| | | public class DelayedQueueController { |
| | | |
| | | /** |
| | | * 订阅队列 |
| | | * |
| | | * @param queueName 队列名 |
| | | */ |
| | | @GetMapping("/subscribe") |
| | | public R<Void> subscribe(@Parameter(name = "队列名") String queueName) { |
| | | public R<Void> subscribe(String queueName) { |
| | | log.info("通道: {} 监听中......", queueName); |
| | | // 项目初始化设置一次即可 |
| | | QueueUtils.subscribeBlockingQueue(queueName, (String orderNum) -> { |
| | |
| | | return R.ok("操作成功"); |
| | | } |
| | | |
| | | /** |
| | | * 添加队列数据 |
| | | * |
| | | * @param queueName 队列名 |
| | | * @param orderNum 订单号 |
| | | * @param time 延迟时间(秒) |
| | | */ |
| | | @GetMapping("/add") |
| | | public R<Void> add(@Parameter(name = "队列名") String queueName, |
| | | @Parameter(name = "订单号") String orderNum, |
| | | @Parameter(name = "延迟时间(秒)") Long time) { |
| | | public R<Void> add(String queueName, String orderNum, Long time) { |
| | | QueueUtils.addDelayedQueueObject(queueName, orderNum, time, TimeUnit.SECONDS); |
| | | // 观察发送时间 |
| | | log.info("通道: {} , 发送数据: {}", queueName, orderNum); |
| | | return R.ok("操作成功"); |
| | | } |
| | | |
| | | /** |
| | | * 删除队列数据 |
| | | * |
| | | * @param queueName 队列名 |
| | | * @param orderNum 订单号 |
| | | */ |
| | | @GetMapping("/remove") |
| | | public R<Void> remove(@Parameter(name = "队列名") String queueName, |
| | | @Parameter(name = "订单号") String orderNum) { |
| | | public R<Void> remove(String queueName, String orderNum) { |
| | | if (QueueUtils.removeDelayedQueueObject(queueName, orderNum)) { |
| | | log.info("通道: {} , 删除数据: {}", queueName, orderNum); |
| | | } else { |
| | |
| | | return R.ok("操作成功"); |
| | | } |
| | | |
| | | /** |
| | | * 销毁队列 |
| | | * |
| | | * @param queueName 队列名 |
| | | */ |
| | | @GetMapping("/destroy") |
| | | public R<Void> destroy(@Parameter(name = "队列名") String queueName) { |
| | | public R<Void> destroy(String queueName) { |
| | | // 用完了一定要销毁 否则会一直存在 |
| | | QueueUtils.destroyDelayedQueue(queueName); |
| | | return R.ok("操作成功"); |
| | |
| | | import cn.hutool.core.util.RandomUtil; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.utils.redis.QueueUtils; |
| | | import io.swagger.v3.oas.annotations.Parameter; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | * @version 3.6.0 |
| | | */ |
| | | @Slf4j |
| | | @Tag(name ="优先队列 演示案例", description = "优先队列") |
| | | @Tag(name = "优先队列 演示案例", description = "优先队列") |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/demo/queue/priority") |
| | | public class PriorityQueueController { |
| | | |
| | | /** |
| | | * 添加队列数据 |
| | | * |
| | | * @param queueName 队列名 |
| | | */ |
| | | @GetMapping("/add") |
| | | public R<Void> add(@Parameter(name = "队列名") String queueName) { |
| | | public R<Void> add(String queueName) { |
| | | // 用完了一定要销毁 否则会一直存在 |
| | | boolean b = QueueUtils.destroyPriorityQueueObject(queueName); |
| | | log.info("通道: {} , 删除: {}", queueName, b); |
| | |
| | | return R.ok("操作成功"); |
| | | } |
| | | |
| | | /** |
| | | * 删除队列数据 |
| | | * |
| | | * @param queueName 队列名 |
| | | * @param name 对象名 |
| | | * @param orderNum 排序号 |
| | | */ |
| | | @GetMapping("/remove") |
| | | public R<Void> remove(@Parameter(name = "队列名") String queueName, |
| | | @Parameter(name = "对象名") String name, |
| | | @Parameter(name = "排序号") Integer orderNum) { |
| | | public R<Void> remove(String queueName, String name, Integer orderNum) { |
| | | PriorityDemo data = new PriorityDemo(); |
| | | data.setName(name); |
| | | data.setOrderNum(orderNum); |
| | |
| | | return R.ok("操作成功"); |
| | | } |
| | | |
| | | /** |
| | | * 获取队列数据 |
| | | * |
| | | * @param queueName 队列名 |
| | | */ |
| | | @GetMapping("/get") |
| | | public R<Void> get(@Parameter(name = "队列名") String queueName) { |
| | | public R<Void> get(String queueName) { |
| | | PriorityDemo data; |
| | | do { |
| | | data = QueueUtils.getPriorityQueueObject(queueName); |
| | |
| | | import com.ruoyi.framework.config.properties.SwaggerProperties; |
| | | import io.swagger.v3.oas.models.OpenAPI; |
| | | import io.swagger.v3.oas.models.info.Info; |
| | | import io.swagger.v3.oas.models.security.SecurityRequirement; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springdoc.core.SpringDocConfiguration; |
| | | import org.springframework.boot.autoconfigure.AutoConfigureBefore; |
| | |
| | | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * Swagger 文档配置 |
| | |
| | | openApi.tags(swaggerProperties.getTags()); |
| | | openApi.paths(swaggerProperties.getPaths()); |
| | | openApi.components(swaggerProperties.getComponents()); |
| | | List<SecurityRequirement> list = new ArrayList<>(); |
| | | list.add(new SecurityRequirement().addList("apikey")); |
| | | openApi.security(list); |
| | | |
| | | return openApi; |
| | | } |
| | |
| | | |
| | | /** |
| | | * 修改代码生成业务 |
| | | * |
| | | * @param tableId 表ID |
| | | */ |
| | | @SaCheckPermission("tool:gen:query") |
| | | @GetMapping(value = "/{tableId}") |
| | |
| | | |
| | | /** |
| | | * 查询数据表字段列表 |
| | | * |
| | | * @param tableId 表ID |
| | | */ |
| | | @SaCheckPermission("tool:gen:list") |
| | | @GetMapping(value = "/column/{tableId}") |
| | |
| | | |
| | | /** |
| | | * 导入表结构(保存) |
| | | * |
| | | * @param tables 表名串 |
| | | */ |
| | | @SaCheckPermission("tool:gen:import") |
| | | @Log(title = "代码生成", businessType = BusinessType.IMPORT) |
| | |
| | | |
| | | /** |
| | | * 删除代码生成 |
| | | * |
| | | * @param tableIds 表ID串 |
| | | */ |
| | | @SaCheckPermission("tool:gen:remove") |
| | | @Log(title = "代码生成", businessType = BusinessType.DELETE) |
| | |
| | | |
| | | /** |
| | | * 预览代码 |
| | | * |
| | | * @param tableId 表ID |
| | | */ |
| | | @SaCheckPermission("tool:gen:preview") |
| | | @GetMapping("/preview/{tableId}") |
| | |
| | | |
| | | /** |
| | | * 生成代码(下载方式) |
| | | * |
| | | * @param tableName 表名 |
| | | */ |
| | | @SaCheckPermission("tool:gen:code") |
| | | @Log(title = "代码生成", businessType = BusinessType.GENCODE) |
| | |
| | | |
| | | /** |
| | | * 生成代码(自定义路径) |
| | | * |
| | | * @param tableName 表名 |
| | | */ |
| | | @SaCheckPermission("tool:gen:code") |
| | | @Log(title = "代码生成", businessType = BusinessType.GENCODE) |
| | |
| | | |
| | | /** |
| | | * 同步数据库 |
| | | * |
| | | * @param tableName 表名 |
| | | */ |
| | | @SaCheckPermission("tool:gen:edit") |
| | | @Log(title = "代码生成", businessType = BusinessType.UPDATE) |
| | |
| | | |
| | | /** |
| | | * 批量生成代码 |
| | | * |
| | | * @param tables 表名串 |
| | | */ |
| | | @SaCheckPermission("tool:gen:code") |
| | | @Log(title = "代码生成", businessType = BusinessType.GENCODE) |
| | |
| | | |
| | | /** |
| | | * 获取${functionName}详细信息 |
| | | * |
| | | * @param ${pkColumn.javaField} 主键 |
| | | */ |
| | | @SaCheckPermission("${permissionPrefix}:query") |
| | | @GetMapping("/{${pkColumn.javaField}}") |
| | | public R<${ClassName}Vo> getInfo(@Parameter(name = "主键") |
| | | @NotNull(message = "主键不能为空") |
| | | @PathVariable("${pkColumn.javaField}") ${pkColumn.javaType} ${pkColumn.javaField}) { |
| | | public R<${ClassName}Vo> getInfo(@NotNull(message = "主键不能为空") |
| | | @PathVariable ${pkColumn.javaType} ${pkColumn.javaField}) { |
| | | return R.ok(i${ClassName}Service.queryById(${pkColumn.javaField})); |
| | | } |
| | | |
| | |
| | | |
| | | /** |
| | | * 删除${functionName} |
| | | * |
| | | * @param ${pkColumn.javaField}s 主键串 |
| | | */ |
| | | @SaCheckPermission("${permissionPrefix}:remove") |
| | | @Log(title = "${functionName}", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{${pkColumn.javaField}s}") |
| | | public R<Void> remove(@Parameter(name = "主键串") |
| | | @NotEmpty(message = "主键不能为空") |
| | | @PathVariable ${pkColumn.javaType}[] ${pkColumn.javaField}s) { |
| | | public R<Void> remove(@NotEmpty(message = "主键不能为空") |
| | | @PathVariable ${pkColumn.javaType}[] ${pkColumn.javaField}s) { |
| | | return toAjax(i${ClassName}Service.deleteWithValidByIds(Arrays.asList(${pkColumn.javaField}s), true) ? 1 : 0); |
| | | } |
| | | } |