| | |
| | | import cn.hutool.core.convert.Convert; |
| | | import cn.hutool.core.util.IdUtil; |
| | | import com.ruoyi.common.constant.Constants; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.enums.CaptchaType; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.redis.RedisUtils; |
| | |
| | | */ |
| | | @ApiOperation("çæéªè¯ç ") |
| | | @GetMapping("/captchaImage") |
| | | public AjaxResult<Map<String, Object>> getCode() { |
| | | public R<Map<String, Object>> getCode() { |
| | | Map<String, Object> ajax = new HashMap<>(); |
| | | boolean captchaOnOff = configService.selectCaptchaOnOff(); |
| | | ajax.put("captchaOnOff", captchaOnOff); |
| | | if (!captchaOnOff) { |
| | | return AjaxResult.success(ajax); |
| | | return R.ok(ajax); |
| | | } |
| | | // ä¿åéªè¯ç ä¿¡æ¯ |
| | | String uuid = IdUtil.simpleUUID(); |
| | |
| | | RedisUtils.setCacheObject(verifyKey, code, Constants.CAPTCHA_EXPIRATION, TimeUnit.MINUTES); |
| | | ajax.put("uuid", uuid); |
| | | ajax.put("img", captcha.getImageBase64()); |
| | | return AjaxResult.success(ajax); |
| | | return R.ok(ajax); |
| | | } |
| | | |
| | | private String getCodeResult(String capStr) { |
| | |
| | | package com.ruoyi.web.controller.monitor; |
| | | |
| | | import cn.dev33.satoken.annotation.SaCheckPermission; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | |
| | | @ApiOperation("è·åç¼åçæ§è¯¦ç»ä¿¡æ¯") |
| | | @SaCheckPermission("monitor:cache:list") |
| | | @GetMapping() |
| | | public AjaxResult<Map<String, Object>> getInfo() throws Exception { |
| | | public R<Map<String, Object>> getInfo() throws Exception { |
| | | Properties info = (Properties) redisTemplate.execute((RedisCallback<Object>) RedisServerCommands::info); |
| | | Properties commandStats = (Properties) redisTemplate.execute((RedisCallback<Object>) connection -> connection.info("commandstats")); |
| | | Object dbSize = redisTemplate.execute((RedisCallback<Object>) RedisServerCommands::dbSize); |
| | |
| | | }); |
| | | } |
| | | result.put("commandStats", pieList); |
| | | return AjaxResult.success(result); |
| | | return R.ok(result); |
| | | } |
| | | } |
| | |
| | | import cn.dev33.satoken.annotation.SaCheckPermission; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | |
| | | @SaCheckPermission("monitor:logininfor:remove") |
| | | @Log(title = "ç»å½æ¥å¿", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{infoIds}") |
| | | public AjaxResult<Void> remove(@PathVariable Long[] infoIds) { |
| | | public R<Void> remove(@PathVariable Long[] infoIds) { |
| | | return toAjax(logininforService.deleteLogininforByIds(infoIds)); |
| | | } |
| | | |
| | |
| | | @SaCheckPermission("monitor:logininfor:remove") |
| | | @Log(title = "ç»å½æ¥å¿", businessType = BusinessType.CLEAN) |
| | | @DeleteMapping("/clean") |
| | | public AjaxResult<Void> clean() { |
| | | public R<Void> clean() { |
| | | logininforService.cleanLogininfor(); |
| | | return AjaxResult.success(); |
| | | return R.ok(); |
| | | } |
| | | } |
| | |
| | | import cn.dev33.satoken.annotation.SaCheckPermission; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | |
| | | @Log(title = "æä½æ¥å¿", businessType = BusinessType.DELETE) |
| | | @SaCheckPermission("monitor:operlog:remove") |
| | | @DeleteMapping("/{operIds}") |
| | | public AjaxResult<Void> remove(@PathVariable Long[] operIds) { |
| | | public R<Void> remove(@PathVariable Long[] operIds) { |
| | | return toAjax(operLogService.deleteOperLogByIds(operIds)); |
| | | } |
| | | |
| | |
| | | @Log(title = "æä½æ¥å¿", businessType = BusinessType.CLEAN) |
| | | @SaCheckPermission("monitor:operlog:remove") |
| | | @DeleteMapping("/clean") |
| | | public AjaxResult<Void> clean() { |
| | | public R<Void> clean() { |
| | | operLogService.cleanOperLog(); |
| | | return AjaxResult.success(); |
| | | return R.ok(); |
| | | } |
| | | } |
| | |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.constant.Constants; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.domain.dto.UserOnlineDTO; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | |
| | | @SaCheckPermission("monitor:online:forceLogout") |
| | | @Log(title = "å¨çº¿ç¨æ·", businessType = BusinessType.FORCE) |
| | | @DeleteMapping("/{tokenId}") |
| | | public AjaxResult<Void> forceLogout(@PathVariable String tokenId) { |
| | | public R<Void> forceLogout(@PathVariable String tokenId) { |
| | | try { |
| | | StpUtil.kickoutByTokenValue(tokenId); |
| | | } catch (NotLoginException e) { |
| | | } |
| | | return AjaxResult.success(); |
| | | return R.ok(); |
| | | } |
| | | } |
| | |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.constant.UserConstants; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | |
| | | @ApiOperation("æ ¹æ®åæ°ç¼å·è·å详ç»ä¿¡æ¯") |
| | | @SaCheckPermission("system:config:query") |
| | | @GetMapping(value = "/{configId}") |
| | | public AjaxResult<SysConfig> getInfo(@ApiParam("åæ°ID") @PathVariable Long configId) { |
| | | return AjaxResult.success(configService.selectConfigById(configId)); |
| | | public R<SysConfig> getInfo(@ApiParam("åæ°ID") @PathVariable Long configId) { |
| | | return R.ok(configService.selectConfigById(configId)); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @ApiOperation("æ ¹æ®åæ°é®åæ¥è¯¢åæ°å¼") |
| | | @GetMapping(value = "/configKey/{configKey}") |
| | | public AjaxResult<Void> getConfigKey(@ApiParam("åæ°Key") @PathVariable String configKey) { |
| | | return AjaxResult.success(configService.selectConfigByKey(configKey)); |
| | | public R<Void> getConfigKey(@ApiParam("åæ°Key") @PathVariable String configKey) { |
| | | return R.ok(configService.selectConfigByKey(configKey)); |
| | | } |
| | | |
| | | /** |
| | |
| | | @SaCheckPermission("system:config:add") |
| | | @Log(title = "åæ°ç®¡ç", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public AjaxResult<Void> add(@Validated @RequestBody SysConfig config) { |
| | | public R<Void> add(@Validated @RequestBody SysConfig config) { |
| | | if (UserConstants.NOT_UNIQUE.equals(configService.checkConfigKeyUnique(config))) { |
| | | return AjaxResult.error("æ°å¢åæ°'" + config.getConfigName() + "'失败ï¼åæ°é®åå·²åå¨"); |
| | | return R.fail("æ°å¢åæ°'" + config.getConfigName() + "'失败ï¼åæ°é®åå·²åå¨"); |
| | | } |
| | | return toAjax(configService.insertConfig(config)); |
| | | } |
| | |
| | | @SaCheckPermission("system:config:edit") |
| | | @Log(title = "åæ°ç®¡ç", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public AjaxResult<Void> edit(@Validated @RequestBody SysConfig config) { |
| | | public R<Void> edit(@Validated @RequestBody SysConfig config) { |
| | | if (UserConstants.NOT_UNIQUE.equals(configService.checkConfigKeyUnique(config))) { |
| | | return AjaxResult.error("ä¿®æ¹åæ°'" + config.getConfigName() + "'失败ï¼åæ°é®åå·²åå¨"); |
| | | return R.fail("ä¿®æ¹åæ°'" + config.getConfigName() + "'失败ï¼åæ°é®åå·²åå¨"); |
| | | } |
| | | return toAjax(configService.updateConfig(config)); |
| | | } |
| | |
| | | @SaCheckPermission("system:config:remove") |
| | | @Log(title = "åæ°ç®¡ç", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{configIds}") |
| | | public AjaxResult<Void> remove(@ApiParam("忰ID䏲") @PathVariable Long[] configIds) { |
| | | public R<Void> remove(@ApiParam("忰ID䏲") @PathVariable Long[] configIds) { |
| | | configService.deleteConfigByIds(configIds); |
| | | return success(); |
| | | } |
| | |
| | | @SaCheckPermission("system:config:remove") |
| | | @Log(title = "åæ°ç®¡ç", businessType = BusinessType.CLEAN) |
| | | @DeleteMapping("/refreshCache") |
| | | public AjaxResult<Void> refreshCache() { |
| | | public R<Void> refreshCache() { |
| | | configService.resetConfigCache(); |
| | | return AjaxResult.success(); |
| | | return R.ok(); |
| | | } |
| | | } |
| | |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.constant.UserConstants; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.domain.entity.SysDept; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | |
| | | @ApiOperation("è·åé¨é¨å表") |
| | | @SaCheckPermission("system:dept:list") |
| | | @GetMapping("/list") |
| | | public AjaxResult<List<SysDept>> list(SysDept dept) { |
| | | public R<List<SysDept>> list(SysDept dept) { |
| | | List<SysDept> depts = deptService.selectDeptList(dept); |
| | | return AjaxResult.success(depts); |
| | | return R.ok(depts); |
| | | } |
| | | |
| | | /** |
| | |
| | | @ApiOperation("æ¥è¯¢é¨é¨åè¡¨ï¼æé¤èç¹ï¼") |
| | | @SaCheckPermission("system:dept:list") |
| | | @GetMapping("/list/exclude/{deptId}") |
| | | public AjaxResult<List<SysDept>> excludeChild(@ApiParam("é¨é¨ID") @PathVariable(value = "deptId", required = false) Long deptId) { |
| | | public R<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 + "")); |
| | | return AjaxResult.success(depts); |
| | | return R.ok(depts); |
| | | } |
| | | |
| | | /** |
| | |
| | | @ApiOperation("æ ¹æ®é¨é¨ç¼å·è·å详ç»ä¿¡æ¯") |
| | | @SaCheckPermission("system:dept:query") |
| | | @GetMapping(value = "/{deptId}") |
| | | public AjaxResult<SysDept> getInfo(@ApiParam("é¨é¨ID") @PathVariable Long deptId) { |
| | | public R<SysDept> getInfo(@ApiParam("é¨é¨ID") @PathVariable Long deptId) { |
| | | deptService.checkDeptDataScope(deptId); |
| | | return AjaxResult.success(deptService.selectDeptById(deptId)); |
| | | return R.ok(deptService.selectDeptById(deptId)); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @ApiOperation("è·åé¨é¨ä¸ææ å表") |
| | | @GetMapping("/treeselect") |
| | | public AjaxResult<List<Tree<Long>>> treeselect(SysDept dept) { |
| | | public R<List<Tree<Long>>> treeselect(SysDept dept) { |
| | | List<SysDept> depts = deptService.selectDeptList(dept); |
| | | return AjaxResult.success(deptService.buildDeptTreeSelect(depts)); |
| | | return R.ok(deptService.buildDeptTreeSelect(depts)); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @ApiOperation("å 载对åºè§è²é¨é¨å表æ ") |
| | | @GetMapping(value = "/roleDeptTreeselect/{roleId}") |
| | | public AjaxResult<Map<String, Object>> roleDeptTreeselect(@ApiParam("è§è²ID") @PathVariable("roleId") Long roleId) { |
| | | public R<Map<String, Object>> roleDeptTreeselect(@ApiParam("è§è²ID") @PathVariable("roleId") Long roleId) { |
| | | List<SysDept> depts = deptService.selectDeptList(new SysDept()); |
| | | Map<String, Object> ajax = new HashMap<>(); |
| | | ajax.put("checkedKeys", deptService.selectDeptListByRoleId(roleId)); |
| | | ajax.put("depts", deptService.buildDeptTreeSelect(depts)); |
| | | return AjaxResult.success(ajax); |
| | | return R.ok(ajax); |
| | | } |
| | | |
| | | /** |
| | |
| | | @SaCheckPermission("system:dept:add") |
| | | @Log(title = "é¨é¨ç®¡ç", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public AjaxResult<Void> add(@Validated @RequestBody SysDept dept) { |
| | | public R<Void> add(@Validated @RequestBody SysDept dept) { |
| | | if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept))) { |
| | | return AjaxResult.error("æ°å¢é¨é¨'" + dept.getDeptName() + "'失败ï¼é¨é¨åç§°å·²åå¨"); |
| | | return R.fail("æ°å¢é¨é¨'" + dept.getDeptName() + "'失败ï¼é¨é¨åç§°å·²åå¨"); |
| | | } |
| | | return toAjax(deptService.insertDept(dept)); |
| | | } |
| | |
| | | @SaCheckPermission("system:dept:edit") |
| | | @Log(title = "é¨é¨ç®¡ç", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public AjaxResult<Void> edit(@Validated @RequestBody SysDept dept) { |
| | | public R<Void> edit(@Validated @RequestBody SysDept dept) { |
| | | Long deptId = dept.getDeptId(); |
| | | deptService.checkDeptDataScope(deptId); |
| | | if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept))) { |
| | | return AjaxResult.error("ä¿®æ¹é¨é¨'" + dept.getDeptName() + "'失败ï¼é¨é¨åç§°å·²åå¨"); |
| | | return R.fail("ä¿®æ¹é¨é¨'" + dept.getDeptName() + "'失败ï¼é¨é¨åç§°å·²åå¨"); |
| | | } else if (dept.getParentId().equals(deptId)) { |
| | | return AjaxResult.error("ä¿®æ¹é¨é¨'" + dept.getDeptName() + "'失败ï¼ä¸çº§é¨é¨ä¸è½æ¯èªå·±"); |
| | | return R.fail("ä¿®æ¹é¨é¨'" + dept.getDeptName() + "'失败ï¼ä¸çº§é¨é¨ä¸è½æ¯èªå·±"); |
| | | } else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus()) |
| | | && deptService.selectNormalChildrenDeptById(deptId) > 0) { |
| | | return AjaxResult.error("该é¨é¨å
嫿ªåç¨çåé¨é¨ï¼"); |
| | | return R.fail("该é¨é¨å
嫿ªåç¨çåé¨é¨ï¼"); |
| | | } |
| | | return toAjax(deptService.updateDept(dept)); |
| | | } |
| | |
| | | @SaCheckPermission("system:dept:remove") |
| | | @Log(title = "é¨é¨ç®¡ç", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{deptId}") |
| | | public AjaxResult<Void> remove(@ApiParam("é¨é¨ID串") @PathVariable Long deptId) { |
| | | public R<Void> remove(@ApiParam("é¨é¨ID串") @PathVariable Long deptId) { |
| | | if (deptService.hasChildByDeptId(deptId)) { |
| | | return AjaxResult.error("åå¨ä¸çº§é¨é¨,ä¸å
许å é¤"); |
| | | return R.fail("åå¨ä¸çº§é¨é¨,ä¸å
许å é¤"); |
| | | } |
| | | if (deptService.checkDeptExistUser(deptId)) { |
| | | return AjaxResult.error("é¨é¨åå¨ç¨æ·,ä¸å
许å é¤"); |
| | | return R.fail("é¨é¨åå¨ç¨æ·,ä¸å
许å é¤"); |
| | | } |
| | | deptService.checkDeptDataScope(deptId); |
| | | return toAjax(deptService.deleteDeptById(deptId)); |
| | |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.domain.entity.SysDictData; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | |
| | | @ApiOperation("æ¥è¯¢åå
¸æ°æ®è¯¦ç»") |
| | | @SaCheckPermission("system:dict:query") |
| | | @GetMapping(value = "/{dictCode}") |
| | | public AjaxResult<SysDictData> getInfo(@ApiParam("åå
¸code") @PathVariable Long dictCode) { |
| | | return AjaxResult.success(dictDataService.selectDictDataById(dictCode)); |
| | | public R<SysDictData> getInfo(@ApiParam("åå
¸code") @PathVariable Long dictCode) { |
| | | return R.ok(dictDataService.selectDictDataById(dictCode)); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @ApiOperation("æ ¹æ®åå
¸ç±»åæ¥è¯¢åå
¸æ°æ®ä¿¡æ¯") |
| | | @GetMapping(value = "/type/{dictType}") |
| | | public AjaxResult<List<SysDictData>> dictType(@ApiParam("åå
¸ç±»å") @PathVariable String dictType) { |
| | | public R<List<SysDictData>> dictType(@ApiParam("åå
¸ç±»å") @PathVariable String dictType) { |
| | | List<SysDictData> data = dictTypeService.selectDictDataByType(dictType); |
| | | if (ObjectUtil.isNull(data)) { |
| | | data = new ArrayList<>(); |
| | | } |
| | | return AjaxResult.success(data); |
| | | return R.ok(data); |
| | | } |
| | | |
| | | /** |
| | |
| | | @SaCheckPermission("system:dict:add") |
| | | @Log(title = "åå
¸æ°æ®", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public AjaxResult<Void> add(@Validated @RequestBody SysDictData dict) { |
| | | public R<Void> add(@Validated @RequestBody SysDictData dict) { |
| | | return toAjax(dictDataService.insertDictData(dict)); |
| | | } |
| | | |
| | |
| | | @SaCheckPermission("system:dict:edit") |
| | | @Log(title = "åå
¸æ°æ®", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public AjaxResult<Void> edit(@Validated @RequestBody SysDictData dict) { |
| | | public R<Void> edit(@Validated @RequestBody SysDictData dict) { |
| | | return toAjax(dictDataService.updateDictData(dict)); |
| | | } |
| | | |
| | |
| | | @SaCheckPermission("system:dict:remove") |
| | | @Log(title = "åå
¸ç±»å", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{dictCodes}") |
| | | public AjaxResult<Void> remove(@ApiParam("åå
¸code串") @PathVariable Long[] dictCodes) { |
| | | public R<Void> remove(@ApiParam("åå
¸code串") @PathVariable Long[] dictCodes) { |
| | | dictDataService.deleteDictDataByIds(dictCodes); |
| | | return success(); |
| | | } |
| | |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.constant.UserConstants; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.domain.entity.SysDictType; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | |
| | | @ApiOperation("æ¥è¯¢åå
¸ç±»å详ç»") |
| | | @SaCheckPermission("system:dict:query") |
| | | @GetMapping(value = "/{dictId}") |
| | | public AjaxResult<SysDictType> getInfo(@ApiParam("åå
¸ID") @PathVariable Long dictId) { |
| | | return AjaxResult.success(dictTypeService.selectDictTypeById(dictId)); |
| | | public R<SysDictType> getInfo(@ApiParam("åå
¸ID") @PathVariable Long dictId) { |
| | | return R.ok(dictTypeService.selectDictTypeById(dictId)); |
| | | } |
| | | |
| | | /** |
| | |
| | | @SaCheckPermission("system:dict:add") |
| | | @Log(title = "åå
¸ç±»å", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public AjaxResult<Void> add(@Validated @RequestBody SysDictType dict) { |
| | | public R<Void> add(@Validated @RequestBody SysDictType dict) { |
| | | if (UserConstants.NOT_UNIQUE.equals(dictTypeService.checkDictTypeUnique(dict))) { |
| | | return AjaxResult.error("æ°å¢åå
¸'" + dict.getDictName() + "'失败ï¼åå
¸ç±»åå·²åå¨"); |
| | | return R.fail("æ°å¢åå
¸'" + dict.getDictName() + "'失败ï¼åå
¸ç±»åå·²åå¨"); |
| | | } |
| | | return toAjax(dictTypeService.insertDictType(dict)); |
| | | } |
| | |
| | | @SaCheckPermission("system:dict:edit") |
| | | @Log(title = "åå
¸ç±»å", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public AjaxResult<Void> edit(@Validated @RequestBody SysDictType dict) { |
| | | public R<Void> edit(@Validated @RequestBody SysDictType dict) { |
| | | if (UserConstants.NOT_UNIQUE.equals(dictTypeService.checkDictTypeUnique(dict))) { |
| | | return AjaxResult.error("ä¿®æ¹åå
¸'" + dict.getDictName() + "'失败ï¼åå
¸ç±»åå·²åå¨"); |
| | | return R.fail("ä¿®æ¹åå
¸'" + dict.getDictName() + "'失败ï¼åå
¸ç±»åå·²åå¨"); |
| | | } |
| | | return toAjax(dictTypeService.updateDictType(dict)); |
| | | } |
| | |
| | | @SaCheckPermission("system:dict:remove") |
| | | @Log(title = "åå
¸ç±»å", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{dictIds}") |
| | | public AjaxResult<Void> remove(@ApiParam("åå
¸ID串") @PathVariable Long[] dictIds) { |
| | | public R<Void> remove(@ApiParam("åå
¸ID串") @PathVariable Long[] dictIds) { |
| | | dictTypeService.deleteDictTypeByIds(dictIds); |
| | | return success(); |
| | | } |
| | |
| | | @SaCheckPermission("system:dict:remove") |
| | | @Log(title = "åå
¸ç±»å", businessType = BusinessType.CLEAN) |
| | | @DeleteMapping("/refreshCache") |
| | | public AjaxResult<Void> refreshCache() { |
| | | public R<Void> refreshCache() { |
| | | dictTypeService.resetDictCache(); |
| | | return AjaxResult.success(); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @ApiOperation("è·ååå
¸éæ©æ¡å表") |
| | | @GetMapping("/optionselect") |
| | | public AjaxResult<List<SysDictType>> optionselect() { |
| | | public R<List<SysDictType>> optionselect() { |
| | | List<SysDictType> dictTypes = dictTypeService.selectDictTypeAll(); |
| | | return AjaxResult.success(dictTypes); |
| | | return R.ok(dictTypes); |
| | | } |
| | | } |
| | |
| | | import cn.dev33.satoken.exception.NotLoginException; |
| | | import cn.dev33.satoken.stp.StpUtil; |
| | | import com.ruoyi.common.constant.Constants; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.domain.entity.SysMenu; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.core.domain.model.LoginBody; |
| | |
| | | */ |
| | | @ApiOperation("ç»å½æ¹æ³") |
| | | @PostMapping("/login") |
| | | public AjaxResult<Map<String, Object>> login(@Validated @RequestBody LoginBody loginBody) { |
| | | public R<Map<String, Object>> login(@Validated @RequestBody LoginBody loginBody) { |
| | | Map<String, Object> ajax = new HashMap<>(); |
| | | // çæä»¤ç |
| | | String token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(), |
| | | loginBody.getUuid()); |
| | | ajax.put(Constants.TOKEN, token); |
| | | return AjaxResult.success(ajax); |
| | | return R.ok(ajax); |
| | | } |
| | | |
| | | @ApiOperation("ç»åºæ¹æ³") |
| | | @PostMapping("/logout") |
| | | public AjaxResult<Void> logout() { |
| | | public R<Void> logout() { |
| | | try { |
| | | StpUtil.logout(); |
| | | } catch (NotLoginException e) { |
| | | } |
| | | return AjaxResult.success("éåºæå"); |
| | | return R.ok("éåºæå"); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @ApiOperation("è·åç¨æ·ä¿¡æ¯") |
| | | @GetMapping("getInfo") |
| | | public AjaxResult<Map<String, Object>> getInfo() { |
| | | public R<Map<String, Object>> getInfo() { |
| | | SysUser user = userService.selectUserById(LoginHelper.getUserId()); |
| | | // è§è²éå |
| | | Set<String> roles = permissionService.getRolePermission(user); |
| | |
| | | ajax.put("user", user); |
| | | ajax.put("roles", roles); |
| | | ajax.put("permissions", permissions); |
| | | return AjaxResult.success(ajax); |
| | | return R.ok(ajax); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @ApiOperation("è·åè·¯ç±ä¿¡æ¯") |
| | | @GetMapping("getRouters") |
| | | public AjaxResult<List<RouterVo>> getRouters() { |
| | | public R<List<RouterVo>> getRouters() { |
| | | Long userId = LoginHelper.getUserId(); |
| | | List<SysMenu> menus = menuService.selectMenuTreeByUserId(userId); |
| | | return AjaxResult.success(menuService.buildMenus(menus)); |
| | | return R.ok(menuService.buildMenus(menus)); |
| | | } |
| | | } |
| | |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.constant.UserConstants; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.domain.entity.SysMenu; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | |
| | | @ApiOperation("è·åèåå表") |
| | | @SaCheckPermission("system:menu:list") |
| | | @GetMapping("/list") |
| | | public AjaxResult<List<SysMenu>> list(SysMenu menu) { |
| | | public R<List<SysMenu>> list(SysMenu menu) { |
| | | List<SysMenu> menus = menuService.selectMenuList(menu, getUserId()); |
| | | return AjaxResult.success(menus); |
| | | return R.ok(menus); |
| | | } |
| | | |
| | | /** |
| | |
| | | @ApiOperation("æ ¹æ®èåç¼å·è·å详ç»ä¿¡æ¯") |
| | | @SaCheckPermission("system:menu:query") |
| | | @GetMapping(value = "/{menuId}") |
| | | public AjaxResult<SysMenu> getInfo(@ApiParam("èåID") @PathVariable Long menuId) { |
| | | return AjaxResult.success(menuService.selectMenuById(menuId)); |
| | | public R<SysMenu> getInfo(@ApiParam("èåID") @PathVariable Long menuId) { |
| | | return R.ok(menuService.selectMenuById(menuId)); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @ApiOperation("è·åèå䏿æ å表") |
| | | @GetMapping("/treeselect") |
| | | public AjaxResult<List<Tree<Long>>> treeselect(SysMenu menu) { |
| | | public R<List<Tree<Long>>> treeselect(SysMenu menu) { |
| | | List<SysMenu> menus = menuService.selectMenuList(menu, getUserId()); |
| | | return AjaxResult.success(menuService.buildMenuTreeSelect(menus)); |
| | | return R.ok(menuService.buildMenuTreeSelect(menus)); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @ApiOperation("å 载对åºè§è²èåå表æ ") |
| | | @GetMapping(value = "/roleMenuTreeselect/{roleId}") |
| | | public AjaxResult<Map<String, Object>> roleMenuTreeselect(@ApiParam("è§è²ID") @PathVariable("roleId") Long roleId) { |
| | | public R<Map<String, Object>> roleMenuTreeselect(@ApiParam("è§è²ID") @PathVariable("roleId") Long roleId) { |
| | | List<SysMenu> menus = menuService.selectMenuList(getUserId()); |
| | | Map<String, Object> ajax = new HashMap<>(); |
| | | ajax.put("checkedKeys", menuService.selectMenuListByRoleId(roleId)); |
| | | ajax.put("menus", menuService.buildMenuTreeSelect(menus)); |
| | | return AjaxResult.success(ajax); |
| | | return R.ok(ajax); |
| | | } |
| | | |
| | | /** |
| | |
| | | @SaCheckPermission("system:menu:add") |
| | | @Log(title = "èå管ç", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public AjaxResult<Void> add(@Validated @RequestBody SysMenu menu) { |
| | | public R<Void> add(@Validated @RequestBody SysMenu menu) { |
| | | if (UserConstants.NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu))) { |
| | | return AjaxResult.error("æ°å¢èå'" + menu.getMenuName() + "'失败ï¼èååç§°å·²åå¨"); |
| | | return R.fail("æ°å¢èå'" + menu.getMenuName() + "'失败ï¼èååç§°å·²åå¨"); |
| | | } else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) && !StringUtils.ishttp(menu.getPath())) { |
| | | return AjaxResult.error("æ°å¢èå'" + menu.getMenuName() + "'失败ï¼å°åå¿
须以http(s)://å¼å¤´"); |
| | | return R.fail("æ°å¢èå'" + menu.getMenuName() + "'失败ï¼å°åå¿
须以http(s)://å¼å¤´"); |
| | | } |
| | | return toAjax(menuService.insertMenu(menu)); |
| | | } |
| | |
| | | @SaCheckPermission("system:menu:edit") |
| | | @Log(title = "èå管ç", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public AjaxResult<Void> edit(@Validated @RequestBody SysMenu menu) { |
| | | public R<Void> edit(@Validated @RequestBody SysMenu menu) { |
| | | if (UserConstants.NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu))) { |
| | | return AjaxResult.error("ä¿®æ¹èå'" + menu.getMenuName() + "'失败ï¼èååç§°å·²åå¨"); |
| | | return R.fail("ä¿®æ¹èå'" + menu.getMenuName() + "'失败ï¼èååç§°å·²åå¨"); |
| | | } else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) && !StringUtils.ishttp(menu.getPath())) { |
| | | return AjaxResult.error("ä¿®æ¹èå'" + menu.getMenuName() + "'失败ï¼å°åå¿
须以http(s)://å¼å¤´"); |
| | | return R.fail("ä¿®æ¹èå'" + menu.getMenuName() + "'失败ï¼å°åå¿
须以http(s)://å¼å¤´"); |
| | | } else if (menu.getMenuId().equals(menu.getParentId())) { |
| | | return AjaxResult.error("ä¿®æ¹èå'" + menu.getMenuName() + "'失败ï¼ä¸çº§èåä¸è½éæ©èªå·±"); |
| | | return R.fail("ä¿®æ¹èå'" + menu.getMenuName() + "'失败ï¼ä¸çº§èåä¸è½éæ©èªå·±"); |
| | | } |
| | | return toAjax(menuService.updateMenu(menu)); |
| | | } |
| | |
| | | @SaCheckPermission("system:menu:remove") |
| | | @Log(title = "èå管ç", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{menuId}") |
| | | public AjaxResult<Void> remove(@ApiParam("èåID") @PathVariable("menuId") Long menuId) { |
| | | public R<Void> remove(@ApiParam("èåID") @PathVariable("menuId") Long menuId) { |
| | | if (menuService.hasChildByMenuId(menuId)) { |
| | | return AjaxResult.error("åå¨åèå,ä¸å
许å é¤"); |
| | | return R.fail("åå¨åèå,ä¸å
许å é¤"); |
| | | } |
| | | if (menuService.checkMenuExistRole(menuId)) { |
| | | return AjaxResult.error("èåå·²åé
,ä¸å
许å é¤"); |
| | | return R.fail("èåå·²åé
,ä¸å
许å é¤"); |
| | | } |
| | | return toAjax(menuService.deleteMenuById(menuId)); |
| | | } |
| | |
| | | import cn.dev33.satoken.annotation.SaCheckPermission; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | |
| | | @ApiOperation("æ ¹æ®éç¥å
¬åç¼å·è·å详ç»ä¿¡æ¯") |
| | | @SaCheckPermission("system:notice:query") |
| | | @GetMapping(value = "/{noticeId}") |
| | | public AjaxResult<SysNotice> getInfo(@ApiParam("å
ŒID") @PathVariable Long noticeId) { |
| | | return AjaxResult.success(noticeService.selectNoticeById(noticeId)); |
| | | public R<SysNotice> getInfo(@ApiParam("å
ŒID") @PathVariable Long noticeId) { |
| | | return R.ok(noticeService.selectNoticeById(noticeId)); |
| | | } |
| | | |
| | | /** |
| | |
| | | @SaCheckPermission("system:notice:add") |
| | | @Log(title = "éç¥å
Œ", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public AjaxResult<Void> add(@Validated @RequestBody SysNotice notice) { |
| | | public R<Void> add(@Validated @RequestBody SysNotice notice) { |
| | | return toAjax(noticeService.insertNotice(notice)); |
| | | } |
| | | |
| | |
| | | @SaCheckPermission("system:notice:edit") |
| | | @Log(title = "éç¥å
Œ", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public AjaxResult<Void> edit(@Validated @RequestBody SysNotice notice) { |
| | | public R<Void> edit(@Validated @RequestBody SysNotice notice) { |
| | | return toAjax(noticeService.updateNotice(notice)); |
| | | } |
| | | |
| | |
| | | @SaCheckPermission("system:notice:remove") |
| | | @Log(title = "éç¥å
Œ", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{noticeIds}") |
| | | public AjaxResult<Void> remove(@ApiParam("å
¬åID串") @PathVariable Long[] noticeIds) { |
| | | public R<Void> remove(@ApiParam("å
¬åID串") @PathVariable Long[] noticeIds) { |
| | | return toAjax(noticeService.deleteNoticeByIds(noticeIds)); |
| | | } |
| | | } |
| | |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.annotation.RepeatSubmit; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.core.validate.AddGroup; |
| | |
| | | @ApiOperation("è·å对象åå¨é
置详ç»ä¿¡æ¯") |
| | | @SaCheckPermission("system:oss:query") |
| | | @GetMapping("/{ossConfigId}") |
| | | public AjaxResult<SysOssConfigVo> getInfo(@ApiParam("OSSé
ç½®ID") |
| | | public R<SysOssConfigVo> getInfo(@ApiParam("OSSé
ç½®ID") |
| | | @NotNull(message = "主é®ä¸è½ä¸ºç©º") |
| | | @PathVariable("ossConfigId") Integer ossConfigId) { |
| | | return AjaxResult.success(iSysOssConfigService.queryById(ossConfigId)); |
| | | return R.ok(iSysOssConfigService.queryById(ossConfigId)); |
| | | } |
| | | |
| | | /** |
| | |
| | | @Log(title = "对象åå¨é
ç½®", businessType = BusinessType.INSERT) |
| | | @RepeatSubmit() |
| | | @PostMapping() |
| | | public AjaxResult<Void> add(@Validated(AddGroup.class) @RequestBody SysOssConfigBo bo) { |
| | | public R<Void> add(@Validated(AddGroup.class) @RequestBody SysOssConfigBo bo) { |
| | | return toAjax(iSysOssConfigService.insertByBo(bo) ? 1 : 0); |
| | | } |
| | | |
| | |
| | | @Log(title = "对象åå¨é
ç½®", businessType = BusinessType.UPDATE) |
| | | @RepeatSubmit() |
| | | @PutMapping() |
| | | public AjaxResult<Void> edit(@Validated(EditGroup.class) @RequestBody SysOssConfigBo bo) { |
| | | public R<Void> edit(@Validated(EditGroup.class) @RequestBody SysOssConfigBo bo) { |
| | | return toAjax(iSysOssConfigService.updateByBo(bo) ? 1 : 0); |
| | | } |
| | | |
| | |
| | | @SaCheckPermission("system:oss:remove") |
| | | @Log(title = "对象åå¨é
ç½®", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{ossConfigIds}") |
| | | public AjaxResult<Void> remove(@ApiParam("OSSé
置ID串") |
| | | public R<Void> remove(@ApiParam("OSSé
置ID串") |
| | | @NotEmpty(message = "主é®ä¸è½ä¸ºç©º") |
| | | @PathVariable Long[] ossConfigIds) { |
| | | return toAjax(iSysOssConfigService.deleteWithValidByIds(Arrays.asList(ossConfigIds), true) ? 1 : 0); |
| | |
| | | @SaCheckPermission("system:oss:edit") |
| | | @Log(title = "对象åå¨ç¶æä¿®æ¹", businessType = BusinessType.UPDATE) |
| | | @PutMapping("/changeStatus") |
| | | public AjaxResult<Void> changeStatus(@RequestBody SysOssConfigBo bo) { |
| | | public R<Void> changeStatus(@RequestBody SysOssConfigBo bo) { |
| | | return toAjax(iSysOssConfigService.updateOssConfigStatus(bo)); |
| | | } |
| | | } |
| | |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.annotation.RepeatSubmit; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.core.validate.QueryGroup; |
| | |
| | | @Log(title = "OSS对象åå¨", businessType = BusinessType.INSERT) |
| | | @RepeatSubmit |
| | | @PostMapping("/upload") |
| | | public AjaxResult<Map<String, String>> upload(@RequestPart("file") MultipartFile file) { |
| | | public R<Map<String, String>> upload(@RequestPart("file") MultipartFile file) { |
| | | if (ObjectUtil.isNull(file)) { |
| | | throw new ServiceException("ä¸ä¼ æä»¶ä¸è½ä¸ºç©º"); |
| | | } |
| | |
| | | Map<String, String> map = new HashMap<>(2); |
| | | map.put("url", oss.getUrl()); |
| | | map.put("fileName", oss.getFileName()); |
| | | return AjaxResult.success(map); |
| | | return R.ok(map); |
| | | } |
| | | |
| | | @ApiOperation("ä¸è½½OSS对象åå¨") |
| | |
| | | @SaCheckPermission("system:oss:remove") |
| | | @Log(title = "OSS对象åå¨", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{ossIds}") |
| | | public AjaxResult<Void> remove(@ApiParam("OSS对象ID串") |
| | | public R<Void> remove(@ApiParam("OSS对象ID串") |
| | | @NotEmpty(message = "主é®ä¸è½ä¸ºç©º") |
| | | @PathVariable Long[] ossIds) { |
| | | return toAjax(iSysOssService.deleteWithValidByIds(Arrays.asList(ossIds), true) ? 1 : 0); |
| | |
| | | @SaCheckPermission("system:oss:edit") |
| | | @Log(title = "OSS对象åå¨", businessType = BusinessType.UPDATE) |
| | | @PutMapping("/changePreviewListResource") |
| | | public AjaxResult<Void> changePreviewListResource(@RequestBody String body) { |
| | | public R<Void> changePreviewListResource(@RequestBody String body) { |
| | | Map<String, Boolean> map = JsonUtils.parseMap(body); |
| | | SysConfig sysConfig = new SysConfig(); |
| | | sysConfig.setConfigKey(OssConstant.PEREVIEW_LIST_RESOURCE_KEY); |
| | |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.constant.UserConstants; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | |
| | | @ApiOperation("æ ¹æ®å²ä½ç¼å·è·å详ç»ä¿¡æ¯") |
| | | @SaCheckPermission("system:post:query") |
| | | @GetMapping(value = "/{postId}") |
| | | public AjaxResult<SysPost> getInfo(@ApiParam("å²ä½ID") @PathVariable Long postId) { |
| | | return AjaxResult.success(postService.selectPostById(postId)); |
| | | public R<SysPost> getInfo(@ApiParam("å²ä½ID") @PathVariable Long postId) { |
| | | return R.ok(postService.selectPostById(postId)); |
| | | } |
| | | |
| | | /** |
| | |
| | | @SaCheckPermission("system:post:add") |
| | | @Log(title = "å²ä½ç®¡ç", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public AjaxResult<Void> add(@Validated @RequestBody SysPost post) { |
| | | public R<Void> add(@Validated @RequestBody SysPost post) { |
| | | if (UserConstants.NOT_UNIQUE.equals(postService.checkPostNameUnique(post))) { |
| | | return AjaxResult.error("æ°å¢å²ä½'" + post.getPostName() + "'失败ï¼å²ä½åç§°å·²åå¨"); |
| | | return R.fail("æ°å¢å²ä½'" + post.getPostName() + "'失败ï¼å²ä½åç§°å·²åå¨"); |
| | | } else if (UserConstants.NOT_UNIQUE.equals(postService.checkPostCodeUnique(post))) { |
| | | return AjaxResult.error("æ°å¢å²ä½'" + post.getPostName() + "'失败ï¼å²ä½ç¼ç å·²åå¨"); |
| | | return R.fail("æ°å¢å²ä½'" + post.getPostName() + "'失败ï¼å²ä½ç¼ç å·²åå¨"); |
| | | } |
| | | return toAjax(postService.insertPost(post)); |
| | | } |
| | |
| | | @SaCheckPermission("system:post:edit") |
| | | @Log(title = "å²ä½ç®¡ç", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public AjaxResult<Void> edit(@Validated @RequestBody SysPost post) { |
| | | public R<Void> edit(@Validated @RequestBody SysPost post) { |
| | | if (UserConstants.NOT_UNIQUE.equals(postService.checkPostNameUnique(post))) { |
| | | return AjaxResult.error("ä¿®æ¹å²ä½'" + post.getPostName() + "'失败ï¼å²ä½åç§°å·²åå¨"); |
| | | return R.fail("ä¿®æ¹å²ä½'" + post.getPostName() + "'失败ï¼å²ä½åç§°å·²åå¨"); |
| | | } else if (UserConstants.NOT_UNIQUE.equals(postService.checkPostCodeUnique(post))) { |
| | | return AjaxResult.error("ä¿®æ¹å²ä½'" + post.getPostName() + "'失败ï¼å²ä½ç¼ç å·²åå¨"); |
| | | return R.fail("ä¿®æ¹å²ä½'" + post.getPostName() + "'失败ï¼å²ä½ç¼ç å·²åå¨"); |
| | | } |
| | | return toAjax(postService.updatePost(post)); |
| | | } |
| | |
| | | @SaCheckPermission("system:post:remove") |
| | | @Log(title = "å²ä½ç®¡ç", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{postIds}") |
| | | public AjaxResult<Void> remove(@ApiParam("å²ä½ID串") @PathVariable Long[] postIds) { |
| | | public R<Void> remove(@ApiParam("å²ä½ID串") @PathVariable Long[] postIds) { |
| | | return toAjax(postService.deletePostByIds(postIds)); |
| | | } |
| | | |
| | |
| | | */ |
| | | @ApiOperation("è·åå²ä½éæ©æ¡å表") |
| | | @GetMapping("/optionselect") |
| | | public AjaxResult<List<SysPost>> optionselect() { |
| | | public R<List<SysPost>> optionselect() { |
| | | List<SysPost> posts = postService.selectPostAll(); |
| | | return AjaxResult.success(posts); |
| | | return R.ok(posts); |
| | | } |
| | | } |
| | |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.constant.UserConstants; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.helper.LoginHelper; |
| | |
| | | */ |
| | | @ApiOperation("个人信æ¯") |
| | | @GetMapping |
| | | public AjaxResult<Map<String, Object>> profile() { |
| | | public R<Map<String, Object>> profile() { |
| | | SysUser user = userService.selectUserById(getUserId()); |
| | | Map<String, Object> ajax = new HashMap<>(); |
| | | ajax.put("user", user); |
| | | ajax.put("roleGroup", userService.selectUserRoleGroup(user.getUserName())); |
| | | ajax.put("postGroup", userService.selectUserPostGroup(user.getUserName())); |
| | | return AjaxResult.success(ajax); |
| | | return R.ok(ajax); |
| | | } |
| | | |
| | | /** |
| | |
| | | @ApiOperation("ä¿®æ¹ç¨æ·") |
| | | @Log(title = "个人信æ¯", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public AjaxResult<Void> updateProfile(@RequestBody SysUser user) { |
| | | public R<Void> updateProfile(@RequestBody SysUser user) { |
| | | if (StringUtils.isNotEmpty(user.getPhonenumber()) |
| | | && UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user))) { |
| | | return AjaxResult.error("ä¿®æ¹ç¨æ·'" + user.getUserName() + "'å¤±è´¥ï¼ææºå·ç å·²åå¨"); |
| | | return R.fail("ä¿®æ¹ç¨æ·'" + user.getUserName() + "'å¤±è´¥ï¼ææºå·ç å·²åå¨"); |
| | | } |
| | | if (StringUtils.isNotEmpty(user.getEmail()) |
| | | && UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user))) { |
| | | return AjaxResult.error("ä¿®æ¹ç¨æ·'" + user.getUserName() + "'失败ï¼é®ç®±è´¦å·å·²åå¨"); |
| | | return R.fail("ä¿®æ¹ç¨æ·'" + user.getUserName() + "'失败ï¼é®ç®±è´¦å·å·²åå¨"); |
| | | } |
| | | user.setUserId(getUserId()); |
| | | user.setUserName(null); |
| | | user.setPassword(null); |
| | | if (userService.updateUserProfile(user) > 0) { |
| | | return AjaxResult.success(); |
| | | return R.ok(); |
| | | } |
| | | return AjaxResult.error("ä¿®æ¹ä¸ªäººä¿¡æ¯å¼å¸¸ï¼è¯·è系管çå"); |
| | | return R.fail("ä¿®æ¹ä¸ªäººä¿¡æ¯å¼å¸¸ï¼è¯·è系管çå"); |
| | | } |
| | | |
| | | /** |
| | |
| | | }) |
| | | @Log(title = "个人信æ¯", businessType = BusinessType.UPDATE) |
| | | @PutMapping("/updatePwd") |
| | | public AjaxResult<Void> updatePwd(String oldPassword, String newPassword) { |
| | | public R<Void> updatePwd(String oldPassword, String newPassword) { |
| | | SysUser user = userService.selectUserById(LoginHelper.getUserId()); |
| | | String userName = user.getUserName(); |
| | | String password = user.getPassword(); |
| | | if (!SecurityUtils.matchesPassword(oldPassword, password)) { |
| | | return AjaxResult.error("ä¿®æ¹å¯ç å¤±è´¥ï¼æ§å¯ç é误"); |
| | | return R.fail("ä¿®æ¹å¯ç å¤±è´¥ï¼æ§å¯ç é误"); |
| | | } |
| | | if (SecurityUtils.matchesPassword(newPassword, password)) { |
| | | return AjaxResult.error("æ°å¯ç ä¸è½ä¸æ§å¯ç ç¸å"); |
| | | return R.fail("æ°å¯ç ä¸è½ä¸æ§å¯ç ç¸å"); |
| | | } |
| | | if (userService.resetUserPwd(userName, SecurityUtils.encryptPassword(newPassword)) > 0) { |
| | | return AjaxResult.success(); |
| | | return R.ok(); |
| | | } |
| | | return AjaxResult.error("ä¿®æ¹å¯ç å¼å¸¸ï¼è¯·è系管çå"); |
| | | return R.fail("ä¿®æ¹å¯ç å¼å¸¸ï¼è¯·è系管çå"); |
| | | } |
| | | |
| | | /** |
| | |
| | | }) |
| | | @Log(title = "ç¨æ·å¤´å", businessType = BusinessType.UPDATE) |
| | | @PostMapping("/avatar") |
| | | public AjaxResult<Map<String, Object>> avatar(@RequestPart("avatarfile") MultipartFile file) { |
| | | public R<Map<String, Object>> avatar(@RequestPart("avatarfile") MultipartFile file) { |
| | | Map<String, Object> ajax = new HashMap<>(); |
| | | if (!file.isEmpty()) { |
| | | SysOss oss = iSysOssService.upload(file); |
| | | String avatar = oss.getUrl(); |
| | | if (userService.updateUserAvatar(getUsername(), avatar)) { |
| | | ajax.put("imgUrl", avatar); |
| | | return AjaxResult.success(ajax); |
| | | return R.ok(ajax); |
| | | } |
| | | } |
| | | return AjaxResult.error("ä¸ä¼ å¾çå¼å¸¸ï¼è¯·è系管çå", ajax); |
| | | return R.fail("ä¸ä¼ å¾çå¼å¸¸ï¼è¯·è系管çå"); |
| | | } |
| | | } |
| | |
| | | package com.ruoyi.web.controller.system; |
| | | |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.domain.model.RegisterBody; |
| | | import com.ruoyi.system.service.ISysConfigService; |
| | | import com.ruoyi.system.service.SysRegisterService; |
| | |
| | | |
| | | @ApiOperation("ç¨æ·æ³¨å") |
| | | @PostMapping("/register") |
| | | public AjaxResult<Void> register(@Validated @RequestBody RegisterBody user) { |
| | | public R<Void> register(@Validated @RequestBody RegisterBody user) { |
| | | if (!("true".equals(configService.selectConfigByKey("sys.account.registerUser")))) { |
| | | return error("å½åç³»ç»æ²¡æå¼å¯æ³¨ååè½ï¼"); |
| | | } |
| | |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.constant.UserConstants; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.domain.entity.SysRole; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | |
| | | @ApiOperation("æ ¹æ®è§è²ç¼å·è·å详ç»ä¿¡æ¯") |
| | | @SaCheckPermission("system:role:query") |
| | | @GetMapping(value = "/{roleId}") |
| | | public AjaxResult<SysRole> getInfo(@ApiParam("è§è²ID") @PathVariable Long roleId) { |
| | | public R<SysRole> getInfo(@ApiParam("è§è²ID") @PathVariable Long roleId) { |
| | | roleService.checkRoleDataScope(roleId); |
| | | return AjaxResult.success(roleService.selectRoleById(roleId)); |
| | | return R.ok(roleService.selectRoleById(roleId)); |
| | | } |
| | | |
| | | /** |
| | |
| | | @SaCheckPermission("system:role:add") |
| | | @Log(title = "è§è²ç®¡ç", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public AjaxResult<Void> add(@Validated @RequestBody SysRole role) { |
| | | public R<Void> add(@Validated @RequestBody SysRole role) { |
| | | if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role))) { |
| | | return AjaxResult.error("æ°å¢è§è²'" + role.getRoleName() + "'失败ï¼è§è²åç§°å·²åå¨"); |
| | | return R.fail("æ°å¢è§è²'" + role.getRoleName() + "'失败ï¼è§è²åç§°å·²åå¨"); |
| | | } else if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role))) { |
| | | return AjaxResult.error("æ°å¢è§è²'" + role.getRoleName() + "'失败ï¼è§è²æéå·²åå¨"); |
| | | return R.fail("æ°å¢è§è²'" + role.getRoleName() + "'失败ï¼è§è²æéå·²åå¨"); |
| | | } |
| | | return toAjax(roleService.insertRole(role)); |
| | | |
| | |
| | | @SaCheckPermission("system:role:edit") |
| | | @Log(title = "è§è²ç®¡ç", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public AjaxResult<Void> edit(@Validated @RequestBody SysRole role) { |
| | | public R<Void> edit(@Validated @RequestBody SysRole role) { |
| | | roleService.checkRoleAllowed(role); |
| | | roleService.checkRoleDataScope(role.getRoleId()); |
| | | if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role))) { |
| | | return AjaxResult.error("ä¿®æ¹è§è²'" + role.getRoleName() + "'失败ï¼è§è²åç§°å·²åå¨"); |
| | | return R.fail("ä¿®æ¹è§è²'" + role.getRoleName() + "'失败ï¼è§è²åç§°å·²åå¨"); |
| | | } else if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role))) { |
| | | return AjaxResult.error("ä¿®æ¹è§è²'" + role.getRoleName() + "'失败ï¼è§è²æéå·²åå¨"); |
| | | return R.fail("ä¿®æ¹è§è²'" + role.getRoleName() + "'失败ï¼è§è²æéå·²åå¨"); |
| | | } |
| | | |
| | | if (roleService.updateRole(role) > 0) { |
| | |
| | | loginUser.setMenuPermission(permissionService.getMenuPermission(sysUser)); |
| | | LoginHelper.setLoginUser(loginUser); |
| | | } |
| | | return AjaxResult.success(); |
| | | return R.ok(); |
| | | } |
| | | return AjaxResult.error("ä¿®æ¹è§è²'" + role.getRoleName() + "'失败ï¼è¯·è系管çå"); |
| | | return R.fail("ä¿®æ¹è§è²'" + role.getRoleName() + "'失败ï¼è¯·è系管çå"); |
| | | } |
| | | |
| | | /** |
| | |
| | | @SaCheckPermission("system:role:edit") |
| | | @Log(title = "è§è²ç®¡ç", businessType = BusinessType.UPDATE) |
| | | @PutMapping("/dataScope") |
| | | public AjaxResult<Void> dataScope(@RequestBody SysRole role) { |
| | | public R<Void> dataScope(@RequestBody SysRole role) { |
| | | roleService.checkRoleAllowed(role); |
| | | roleService.checkRoleDataScope(role.getRoleId()); |
| | | return toAjax(roleService.authDataScope(role)); |
| | |
| | | @SaCheckPermission("system:role:edit") |
| | | @Log(title = "è§è²ç®¡ç", businessType = BusinessType.UPDATE) |
| | | @PutMapping("/changeStatus") |
| | | public AjaxResult<Void> changeStatus(@RequestBody SysRole role) { |
| | | public R<Void> changeStatus(@RequestBody SysRole role) { |
| | | roleService.checkRoleAllowed(role); |
| | | roleService.checkRoleDataScope(role.getRoleId()); |
| | | return toAjax(roleService.updateRoleStatus(role)); |
| | |
| | | @SaCheckPermission("system:role:remove") |
| | | @Log(title = "è§è²ç®¡ç", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{roleIds}") |
| | | public AjaxResult<Void> remove(@ApiParam("å²ä½ID串") @PathVariable Long[] roleIds) { |
| | | public R<Void> remove(@ApiParam("å²ä½ID串") @PathVariable Long[] roleIds) { |
| | | return toAjax(roleService.deleteRoleByIds(roleIds)); |
| | | } |
| | | |
| | |
| | | @ApiOperation("è·åè§è²éæ©æ¡å表") |
| | | @SaCheckPermission("system:role:query") |
| | | @GetMapping("/optionselect") |
| | | public AjaxResult<List<SysRole>> optionselect() { |
| | | return AjaxResult.success(roleService.selectRoleAll()); |
| | | public R<List<SysRole>> optionselect() { |
| | | return R.ok(roleService.selectRoleAll()); |
| | | } |
| | | |
| | | /** |
| | |
| | | @SaCheckPermission("system:role:edit") |
| | | @Log(title = "è§è²ç®¡ç", businessType = BusinessType.GRANT) |
| | | @PutMapping("/authUser/cancel") |
| | | public AjaxResult<Void> cancelAuthUser(@RequestBody SysUserRole userRole) { |
| | | public R<Void> cancelAuthUser(@RequestBody SysUserRole userRole) { |
| | | return toAjax(roleService.deleteAuthUser(userRole)); |
| | | } |
| | | |
| | |
| | | @SaCheckPermission("system:role:edit") |
| | | @Log(title = "è§è²ç®¡ç", businessType = BusinessType.GRANT) |
| | | @PutMapping("/authUser/cancelAll") |
| | | public AjaxResult<Void> cancelAuthUserAll(Long roleId, Long[] userIds) { |
| | | public R<Void> cancelAuthUserAll(Long roleId, Long[] userIds) { |
| | | return toAjax(roleService.deleteAuthUsers(roleId, userIds)); |
| | | } |
| | | |
| | |
| | | @SaCheckPermission("system:role:edit") |
| | | @Log(title = "è§è²ç®¡ç", businessType = BusinessType.GRANT) |
| | | @PutMapping("/authUser/selectAll") |
| | | public AjaxResult<Void> selectAuthUserAll(Long roleId, Long[] userIds) { |
| | | public R<Void> selectAuthUserAll(Long roleId, Long[] userIds) { |
| | | roleService.checkRoleDataScope(roleId); |
| | | return toAjax(roleService.insertAuthUsers(roleId, userIds)); |
| | | } |
| | |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.constant.UserConstants; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.domain.entity.SysDept; |
| | | import com.ruoyi.common.core.domain.entity.SysRole; |
| | |
| | | @Log(title = "ç¨æ·ç®¡ç", businessType = BusinessType.IMPORT) |
| | | @SaCheckPermission("system:user:import") |
| | | @PostMapping("/importData") |
| | | public AjaxResult<Void> importData(@RequestPart("file") MultipartFile file, boolean updateSupport) throws Exception { |
| | | 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 AjaxResult.success(result.getAnalysis()); |
| | | return R.ok(result.getAnalysis()); |
| | | } |
| | | |
| | | @ApiOperation("ä¸è½½å¯¼å
¥æ¨¡æ¿") |
| | |
| | | @ApiOperation("æ ¹æ®ç¨æ·ç¼å·è·å详ç»ä¿¡æ¯") |
| | | @SaCheckPermission("system:user:query") |
| | | @GetMapping(value = {"/", "/{userId}"}) |
| | | public AjaxResult<Map<String, Object>> getInfo(@ApiParam("ç¨æ·ID") @PathVariable(value = "userId", required = false) Long userId) { |
| | | public R<Map<String, Object>> getInfo(@ApiParam("ç¨æ·ID") @PathVariable(value = "userId", required = false) Long userId) { |
| | | userService.checkUserDataScope(userId); |
| | | Map<String, Object> ajax = new HashMap<>(); |
| | | List<SysRole> roles = roleService.selectRoleAll(); |
| | |
| | | ajax.put("postIds", postService.selectPostListByUserId(userId)); |
| | | ajax.put("roleIds", sysUser.getRoles().stream().map(SysRole::getRoleId).collect(Collectors.toList())); |
| | | } |
| | | return AjaxResult.success(ajax); |
| | | return R.ok(ajax); |
| | | } |
| | | |
| | | /** |
| | |
| | | @SaCheckPermission("system:user:add") |
| | | @Log(title = "ç¨æ·ç®¡ç", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public AjaxResult<Void> add(@Validated @RequestBody SysUser user) { |
| | | public R<Void> add(@Validated @RequestBody SysUser user) { |
| | | if (UserConstants.NOT_UNIQUE.equals(userService.checkUserNameUnique(user.getUserName()))) { |
| | | return AjaxResult.error("æ°å¢ç¨æ·'" + user.getUserName() + "'失败ï¼ç»å½è´¦å·å·²åå¨"); |
| | | return R.fail("æ°å¢ç¨æ·'" + user.getUserName() + "'失败ï¼ç»å½è´¦å·å·²åå¨"); |
| | | } else if (StringUtils.isNotEmpty(user.getPhonenumber()) |
| | | && UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user))) { |
| | | return AjaxResult.error("æ°å¢ç¨æ·'" + user.getUserName() + "'å¤±è´¥ï¼ææºå·ç å·²åå¨"); |
| | | return R.fail("æ°å¢ç¨æ·'" + user.getUserName() + "'å¤±è´¥ï¼ææºå·ç å·²åå¨"); |
| | | } else if (StringUtils.isNotEmpty(user.getEmail()) |
| | | && UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user))) { |
| | | return AjaxResult.error("æ°å¢ç¨æ·'" + user.getUserName() + "'失败ï¼é®ç®±è´¦å·å·²åå¨"); |
| | | return R.fail("æ°å¢ç¨æ·'" + user.getUserName() + "'失败ï¼é®ç®±è´¦å·å·²åå¨"); |
| | | } |
| | | user.setPassword(SecurityUtils.encryptPassword(user.getPassword())); |
| | | return toAjax(userService.insertUser(user)); |
| | |
| | | @SaCheckPermission("system:user:edit") |
| | | @Log(title = "ç¨æ·ç®¡ç", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public AjaxResult<Void> edit(@Validated @RequestBody SysUser user) { |
| | | public R<Void> edit(@Validated @RequestBody SysUser user) { |
| | | userService.checkUserAllowed(user); |
| | | userService.checkUserDataScope(user.getUserId()); |
| | | if (StringUtils.isNotEmpty(user.getPhonenumber()) |
| | | && UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user))) { |
| | | return AjaxResult.error("ä¿®æ¹ç¨æ·'" + user.getUserName() + "'å¤±è´¥ï¼ææºå·ç å·²åå¨"); |
| | | return R.fail("ä¿®æ¹ç¨æ·'" + user.getUserName() + "'å¤±è´¥ï¼ææºå·ç å·²åå¨"); |
| | | } else if (StringUtils.isNotEmpty(user.getEmail()) |
| | | && UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user))) { |
| | | return AjaxResult.error("ä¿®æ¹ç¨æ·'" + user.getUserName() + "'失败ï¼é®ç®±è´¦å·å·²åå¨"); |
| | | return R.fail("ä¿®æ¹ç¨æ·'" + user.getUserName() + "'失败ï¼é®ç®±è´¦å·å·²åå¨"); |
| | | } |
| | | return toAjax(userService.updateUser(user)); |
| | | } |
| | |
| | | @SaCheckPermission("system:user:remove") |
| | | @Log(title = "ç¨æ·ç®¡ç", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{userIds}") |
| | | public AjaxResult<Void> remove(@ApiParam("è§è²ID串") @PathVariable Long[] userIds) { |
| | | public R<Void> remove(@ApiParam("è§è²ID串") @PathVariable Long[] userIds) { |
| | | if (ArrayUtil.contains(userIds, getUserId())) { |
| | | return error("å½åç¨æ·ä¸è½å é¤"); |
| | | } |
| | |
| | | @SaCheckPermission("system:user:resetPwd") |
| | | @Log(title = "ç¨æ·ç®¡ç", businessType = BusinessType.UPDATE) |
| | | @PutMapping("/resetPwd") |
| | | public AjaxResult<Void> resetPwd(@RequestBody SysUser user) { |
| | | public R<Void> resetPwd(@RequestBody SysUser user) { |
| | | userService.checkUserAllowed(user); |
| | | userService.checkUserDataScope(user.getUserId()); |
| | | user.setPassword(SecurityUtils.encryptPassword(user.getPassword())); |
| | |
| | | @SaCheckPermission("system:user:edit") |
| | | @Log(title = "ç¨æ·ç®¡ç", businessType = BusinessType.UPDATE) |
| | | @PutMapping("/changeStatus") |
| | | public AjaxResult<Void> changeStatus(@RequestBody SysUser user) { |
| | | public R<Void> changeStatus(@RequestBody SysUser user) { |
| | | userService.checkUserAllowed(user); |
| | | userService.checkUserDataScope(user.getUserId()); |
| | | return toAjax(userService.updateUserStatus(user)); |
| | |
| | | @ApiOperation("æ ¹æ®ç¨æ·ç¼å·è·åææè§è²") |
| | | @SaCheckPermission("system:user:query") |
| | | @GetMapping("/authRole/{userId}") |
| | | public AjaxResult<Map<String, Object>> authRole(@ApiParam("ç¨æ·ID") @PathVariable("userId") Long userId) { |
| | | public R<Map<String, Object>> authRole(@ApiParam("ç¨æ·ID") @PathVariable("userId") Long userId) { |
| | | SysUser user = userService.selectUserById(userId); |
| | | List<SysRole> roles = roleService.selectRolesByUserId(userId); |
| | | Map<String, Object> ajax = new HashMap<>(); |
| | | ajax.put("user", user); |
| | | ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList())); |
| | | return AjaxResult.success(ajax); |
| | | return R.ok(ajax); |
| | | } |
| | | |
| | | /** |
| | |
| | | @SaCheckPermission("system:user:edit") |
| | | @Log(title = "ç¨æ·ç®¡ç", businessType = BusinessType.GRANT) |
| | | @PutMapping("/authRole") |
| | | public AjaxResult<Void> insertAuthRole(Long userId, Long[] roleIds) { |
| | | public R<Void> insertAuthRole(Long userId, Long[] roleIds) { |
| | | userService.checkUserDataScope(userId); |
| | | userService.insertUserAuth(userId, roleIds); |
| | | return success(); |
| | |
| | | package com.ruoyi.common.core.controller; |
| | | |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.domain.model.LoginUser; |
| | | import com.ruoyi.common.helper.LoginHelper; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | |
| | | /** |
| | | * è¿åæå |
| | | */ |
| | | public AjaxResult<Void> success() { |
| | | return AjaxResult.success(); |
| | | public R<Void> success() { |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * è¿åå¤±è´¥æ¶æ¯ |
| | | */ |
| | | public AjaxResult<Void> error() { |
| | | return AjaxResult.error(); |
| | | public R<Void> error() { |
| | | return R.fail(); |
| | | } |
| | | |
| | | /** |
| | | * è¿åæåæ¶æ¯ |
| | | */ |
| | | public AjaxResult<Void> success(String message) { |
| | | return AjaxResult.success(message); |
| | | public R<Void> success(String message) { |
| | | return R.ok(message); |
| | | } |
| | | |
| | | /** |
| | | * è¿åå¤±è´¥æ¶æ¯ |
| | | */ |
| | | public AjaxResult<Void> error(String message) { |
| | | return AjaxResult.error(message); |
| | | public R<Void> error(String message) { |
| | | return R.fail(message); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @param rows å½±åè¡æ° |
| | | * @return æä½ç»æ |
| | | */ |
| | | protected AjaxResult<Void> toAjax(int rows) { |
| | | return rows > 0 ? AjaxResult.success() : AjaxResult.error(); |
| | | protected R<Void> toAjax(int rows) { |
| | | return rows > 0 ? R.ok() : R.fail(); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @param result ç»æ |
| | | * @return æä½ç»æ |
| | | */ |
| | | protected AjaxResult<Void> toAjax(boolean result) { |
| | | protected R<Void> toAjax(boolean result) { |
| | | return result ? success() : error(); |
| | | } |
| | | |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.common.core.domain; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.NoArgsConstructor; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * ååºä¿¡æ¯ä¸»ä½ |
| | | * |
| | | * @author Lion Li |
| | | */ |
| | | @Data |
| | | @NoArgsConstructor |
| | | @ApiModel("请æ±ååºå¯¹è±¡") |
| | | public class R<T> implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * æå |
| | | */ |
| | | public static final int SUCCESS = 200; |
| | | |
| | | /** |
| | | * 失败 |
| | | */ |
| | | public static final int FAIL = 500; |
| | | |
| | | @ApiModelProperty("æ¶æ¯ç¶æç ") |
| | | private int code; |
| | | |
| | | @ApiModelProperty("æ¶æ¯å
容") |
| | | private String msg; |
| | | |
| | | @ApiModelProperty("æ°æ®å¯¹è±¡") |
| | | private T data; |
| | | |
| | | public static <T> R<T> ok() { |
| | | return restResult(null, SUCCESS, null); |
| | | } |
| | | |
| | | public static <T> R<T> ok(T data) { |
| | | return restResult(data, SUCCESS, null); |
| | | } |
| | | |
| | | public static <T> R<T> ok(String msg) { |
| | | return restResult(null, SUCCESS, msg); |
| | | } |
| | | |
| | | public static <T> R<T> ok(T data, String msg) { |
| | | return restResult(data, SUCCESS, msg); |
| | | } |
| | | |
| | | public static <T> R<T> fail() { |
| | | return restResult(null, FAIL, null); |
| | | } |
| | | |
| | | public static <T> R<T> fail(String msg) { |
| | | return restResult(null, FAIL, msg); |
| | | } |
| | | |
| | | public static <T> R<T> fail(T data) { |
| | | return restResult(data, FAIL, null); |
| | | } |
| | | |
| | | public static <T> R<T> fail(T data, String msg) { |
| | | return restResult(data, FAIL, msg); |
| | | } |
| | | |
| | | public static <T> R<T> fail(int code, String msg) { |
| | | return restResult(null, code, msg); |
| | | } |
| | | |
| | | private static <T> R<T> restResult(T data, int code, String msg) { |
| | | R<T> r = new R<>(); |
| | | r.setCode(code); |
| | | r.setData(data); |
| | | r.setMsg(msg); |
| | | return r; |
| | | } |
| | | |
| | | } |
| | |
| | | package com.ruoyi.demo.controller; |
| | | |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.utils.redis.RedisUtils; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | |
| | | @ApiOperation("æµè¯ @Cacheable") |
| | | @Cacheable(cacheNames = "redissonCacheMap", key = "#key", condition = "#key != null") |
| | | @GetMapping("/test1") |
| | | public AjaxResult<String> test1(String key, String value) { |
| | | return AjaxResult.success("æä½æå", value); |
| | | public R<String> test1(String key, String value) { |
| | | return R.ok("æä½æå", value); |
| | | } |
| | | |
| | | /** |
| | |
| | | @ApiOperation("æµè¯ @CachePut") |
| | | @CachePut(cacheNames = "redissonCacheMap", key = "#key", condition = "#key != null") |
| | | @GetMapping("/test2") |
| | | public AjaxResult<String> test2(String key, String value) { |
| | | return AjaxResult.success("æä½æå", value); |
| | | public R<String> test2(String key, String value) { |
| | | return R.ok("æä½æå", value); |
| | | } |
| | | |
| | | /** |
| | |
| | | @ApiOperation("æµè¯ @CacheEvict") |
| | | @CacheEvict(cacheNames = "redissonCacheMap", key = "#key", condition = "#key != null") |
| | | @GetMapping("/test3") |
| | | public AjaxResult<String> test3(String key, String value) { |
| | | return AjaxResult.success("æä½æå", value); |
| | | public R<String> test3(String key, String value) { |
| | | return R.ok("æä½æå", value); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @ApiOperation("æµè¯è®¾ç½®è¿ææ¶é´") |
| | | @GetMapping("/test6") |
| | | public AjaxResult<Boolean> test6(String key, String value) { |
| | | public R<Boolean> test6(String key, String value) { |
| | | RedisUtils.setCacheObject(key, value); |
| | | boolean flag = RedisUtils.expire(key, 10, TimeUnit.SECONDS); |
| | | System.out.println("***********" + flag); |
| | |
| | | e.printStackTrace(); |
| | | } |
| | | Object obj = RedisUtils.getCacheObject(key); |
| | | return AjaxResult.success("æä½æå", value.equals(obj)); |
| | | return R.ok(value.equals(obj)); |
| | | } |
| | | |
| | | } |
| | |
| | | import com.baomidou.lock.LockTemplate; |
| | | import com.baomidou.lock.annotation.Lock4j; |
| | | import com.baomidou.lock.executor.RedissonLockExecutor; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | @ApiOperation("æµè¯lock4j 注解") |
| | | @Lock4j(keys = {"#key"}) |
| | | @GetMapping("/testLock4j") |
| | | public AjaxResult<String> testLock4j(String key, String value) { |
| | | public R<String> testLock4j(String key, String value) { |
| | | System.out.println("start:" + key + ",time:" + LocalTime.now().toString()); |
| | | try { |
| | | Thread.sleep(10000); |
| | |
| | | e.printStackTrace(); |
| | | } |
| | | System.out.println("end :" + key + ",time:" + LocalTime.now().toString()); |
| | | return AjaxResult.success("æä½æå", value); |
| | | return R.ok("æä½æå", value); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @ApiOperation("æµè¯lock4j å·¥å
·") |
| | | @GetMapping("/testLock4jLockTemplate") |
| | | public AjaxResult<String> testLock4jLockTemplate(String key, String value) { |
| | | public R<String> testLock4jLockTemplate(String key, String value) { |
| | | final LockInfo lockInfo = lockTemplate.lock(key, 30000L, 5000L, RedissonLockExecutor.class); |
| | | if (null == lockInfo) { |
| | | throw new RuntimeException("ä¸å¡å¤çä¸,请ç¨ååè¯"); |
| | |
| | | lockTemplate.releaseLock(lockInfo); |
| | | } |
| | | //ç»æ |
| | | return AjaxResult.success("æä½æå", value); |
| | | return R.ok("æä½æå", value); |
| | | } |
| | | |
| | | } |
| | |
| | | package com.ruoyi.demo.controller; |
| | | |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.utils.redis.RedisUtils; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | |
| | | |
| | | @ApiOperation("å叿¶æ¯") |
| | | @GetMapping("/pub") |
| | | public AjaxResult<Void> pub(@ApiParam("ééKey") String key, @ApiParam("åéå
容") String value) { |
| | | public R<Void> pub(@ApiParam("ééKey") String key, @ApiParam("åéå
容") String value) { |
| | | RedisUtils.publish(key, value, consumer -> { |
| | | System.out.println("åå¸éé => " + key + ", åéå¼ => " + value); |
| | | }); |
| | | return AjaxResult.success("æä½æå"); |
| | | return R.ok("æä½æå"); |
| | | } |
| | | |
| | | @ApiOperation("订é
æ¶æ¯") |
| | | @GetMapping("/sub") |
| | | public AjaxResult<Void> sub(@ApiParam("ééKey") String key) { |
| | | public R<Void> sub(@ApiParam("ééKey") String key) { |
| | | RedisUtils.subscribe(key, String.class, msg -> { |
| | | System.out.println("订é
éé => " + key + ", æ¥æ¶å¼ => " + msg); |
| | | }); |
| | | return AjaxResult.success("æä½æå"); |
| | | return R.ok("æä½æå"); |
| | | } |
| | | |
| | | } |
| | |
| | | package com.ruoyi.demo.controller; |
| | | |
| | | import com.ruoyi.common.annotation.RateLimiter; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.enums.LimitType; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | |
| | | @ApiOperation("æµè¯å
¨å±éæµ") |
| | | @RateLimiter(count = 2, time = 10) |
| | | @GetMapping("/test") |
| | | public AjaxResult<String> test(String value) { |
| | | return AjaxResult.success("æä½æå", value); |
| | | public R<String> test(String value) { |
| | | return R.ok("æä½æå", value); |
| | | } |
| | | |
| | | /** |
| | |
| | | @ApiOperation("æµè¯è¯·æ±IPéæµ") |
| | | @RateLimiter(count = 2, time = 10, limitType = LimitType.IP) |
| | | @GetMapping("/testip") |
| | | public AjaxResult<String> testip(String value) { |
| | | return AjaxResult.success("æä½æå", value); |
| | | public R<String> testip(String value) { |
| | | return R.ok("æä½æå", value); |
| | | } |
| | | |
| | | /** |
| | |
| | | @ApiOperation("æµè¯é群å®ä¾éæµ") |
| | | @RateLimiter(count = 2, time = 10, limitType = LimitType.CLUSTER) |
| | | @GetMapping("/testcluster") |
| | | public AjaxResult<String> testcluster(String value) { |
| | | return AjaxResult.success("æä½æå", value); |
| | | public R<String> testcluster(String value) { |
| | | return R.ok("æä½æå", value); |
| | | } |
| | | |
| | | } |
| | |
| | | package com.ruoyi.demo.controller; |
| | | |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | |
| | | @ApiImplicitParam(name = "file", value = "æä»¶", dataType = "java.io.File", required = true), |
| | | }) |
| | | @PostMapping(value = "/upload") |
| | | public AjaxResult<String> upload(@RequestPart("file") MultipartFile file) { |
| | | return AjaxResult.success("æä½æå", file.getOriginalFilename()); |
| | | public R<String> upload(@RequestPart("file") MultipartFile file) { |
| | | return R.ok("æä½æå", file.getOriginalFilename()); |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.demo.domain.TestDemo; |
| | | import com.ruoyi.demo.mapper.TestDemoMapper; |
| | | import io.swagger.annotations.Api; |
| | |
| | | @ApiOperation(value = "æ°å¢æ¹éæ¹æ³") |
| | | @PostMapping("/add") |
| | | // @DS("slave") |
| | | public AjaxResult<Void> add() { |
| | | public R<Void> add() { |
| | | List<TestDemo> list = new ArrayList<>(); |
| | | for (int i = 0; i < 1000; i++) { |
| | | TestDemo testDemo = new TestDemo(); |
| | |
| | | @ApiOperation(value = "æ°å¢ææ´æ°æ¹éæ¹æ³") |
| | | @PostMapping("/addOrUpdate") |
| | | // @DS("slave") |
| | | public AjaxResult<Void> addOrUpdate() { |
| | | public R<Void> addOrUpdate() { |
| | | List<TestDemo> list = new ArrayList<>(); |
| | | for (int i = 0; i < 1000; i++) { |
| | | TestDemo testDemo = new TestDemo(); |
| | |
| | | @ApiOperation(value = "å 餿¹éæ¹æ³") |
| | | @DeleteMapping() |
| | | // @DS("slave") |
| | | public AjaxResult<Void> remove() { |
| | | public R<Void> remove() { |
| | | return toAjax(testDemoMapper.delete(new LambdaQueryWrapper<TestDemo>() |
| | | .eq(TestDemo::getOrderNum, -1L))); |
| | | } |
| | |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.annotation.RepeatSubmit; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.core.validate.AddGroup; |
| | |
| | | @Log(title = "æµè¯å表", businessType = BusinessType.IMPORT) |
| | | @SaCheckPermission("demo:demo:import") |
| | | @PostMapping("/importData") |
| | | public AjaxResult<Void> importData(@RequestPart("file") MultipartFile file) throws Exception { |
| | | 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(); |
| | | List<TestDemo> list = BeanUtil.copyToList(volist, TestDemo.class); |
| | | iTestDemoService.saveBatch(list); |
| | | return AjaxResult.success(excelResult.getAnalysis()); |
| | | return R.ok(excelResult.getAnalysis()); |
| | | } |
| | | |
| | | /** |
| | |
| | | @ApiOperation("è·åæµè¯å表详ç»ä¿¡æ¯") |
| | | @SaCheckPermission("demo:demo:query") |
| | | @GetMapping("/{id}") |
| | | public AjaxResult<TestDemoVo> getInfo(@ApiParam("æµè¯ID") |
| | | public R<TestDemoVo> getInfo(@ApiParam("æµè¯ID") |
| | | @NotNull(message = "主é®ä¸è½ä¸ºç©º") |
| | | @PathVariable("id") Long id) { |
| | | return AjaxResult.success(iTestDemoService.queryById(id)); |
| | | return R.ok(iTestDemoService.queryById(id)); |
| | | } |
| | | |
| | | /** |
| | |
| | | @Log(title = "æµè¯å表", businessType = BusinessType.INSERT) |
| | | @RepeatSubmit(interval = 2, timeUnit = TimeUnit.SECONDS, message = "ä¸å
许éå¤æäº¤") |
| | | @PostMapping() |
| | | public AjaxResult<Void> add(@RequestBody TestDemoBo bo) { |
| | | public R<Void> add(@RequestBody TestDemoBo bo) { |
| | | // ä½¿ç¨æ ¡éªå·¥å
·å¯¹æ @Validated(AddGroup.class) 注解 |
| | | // ç¨äºå¨é Controller çå°æ¹æ ¡éªå¯¹è±¡ |
| | | ValidatorUtils.validate(bo, AddGroup.class); |
| | |
| | | @Log(title = "æµè¯å表", businessType = BusinessType.UPDATE) |
| | | @RepeatSubmit |
| | | @PutMapping() |
| | | public AjaxResult<Void> edit(@Validated(EditGroup.class) @RequestBody TestDemoBo bo) { |
| | | public R<Void> edit(@Validated(EditGroup.class) @RequestBody TestDemoBo bo) { |
| | | return toAjax(iTestDemoService.updateByBo(bo) ? 1 : 0); |
| | | } |
| | | |
| | |
| | | @SaCheckPermission("demo:demo:remove") |
| | | @Log(title = "æµè¯å表", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{ids}") |
| | | public AjaxResult<Void> remove(@ApiParam("æµè¯ID串") |
| | | public R<Void> remove(@ApiParam("æµè¯ID串") |
| | | @NotEmpty(message = "主é®ä¸è½ä¸ºç©º") |
| | | @PathVariable Long[] ids) { |
| | | return toAjax(iTestDemoService.deleteWithValidByIds(Arrays.asList(ids), true) ? 1 : 0); |
| | |
| | | package com.ruoyi.demo.controller; |
| | | |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.utils.MessageUtils; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | |
| | | */ |
| | | @ApiOperation("éè¿codeè·åå½é
åå
容") |
| | | @GetMapping() |
| | | public AjaxResult<Void> get(@ApiParam("å½é
åcode") String code) { |
| | | return AjaxResult.success(MessageUtils.message(code)); |
| | | public R<Void> get(@ApiParam("å½é
åcode") String code) { |
| | | return R.ok(MessageUtils.message(code)); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @ApiOperation("Validator æ ¡éªå½é
å") |
| | | @GetMapping("/test1") |
| | | public AjaxResult<Void> test1(@NotBlank(message = "{not.null}") String str) { |
| | | return AjaxResult.success(str); |
| | | public R<Void> test1(@NotBlank(message = "{not.null}") String str) { |
| | | return R.ok(str); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @ApiOperation("Bean æ ¡éªå½é
å") |
| | | @GetMapping("/test2") |
| | | public AjaxResult<TestI18nBo> test2(@Validated TestI18nBo bo) { |
| | | return AjaxResult.success(bo); |
| | | public R<TestI18nBo> test2(@Validated TestI18nBo bo) { |
| | | return R.ok(bo); |
| | | } |
| | | |
| | | @Data |
| | |
| | | |
| | | import com.ruoyi.common.annotation.Sensitive; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.enums.SensitiveStrategy; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | |
| | | */ |
| | | @ApiOperation("æ¥è¯¢æµè¯å表å表") |
| | | @GetMapping("/test") |
| | | public AjaxResult<TestSensitive> test() { |
| | | public R<TestSensitive> test() { |
| | | TestSensitive testSensitive = new TestSensitive(); |
| | | testSensitive.setIdCard("210397198608215431"); |
| | | testSensitive.setPhone("17640125371"); |
| | | testSensitive.setAddress("åäº¬å¸æé³åºææååé¢1203室"); |
| | | testSensitive.setEmail("17640125371@163.com"); |
| | | testSensitive.setBankCard("6226456952351452853"); |
| | | return AjaxResult.success(testSensitive); |
| | | return R.ok(testSensitive); |
| | | } |
| | | |
| | | @Data |
| | |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.annotation.RepeatSubmit; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.validate.AddGroup; |
| | | import com.ruoyi.common.core.validate.EditGroup; |
| | | import com.ruoyi.common.core.validate.QueryGroup; |
| | |
| | | @ApiOperation("æ¥è¯¢æµè¯æ 表å表") |
| | | @SaCheckPermission("demo:tree:list") |
| | | @GetMapping("/list") |
| | | public AjaxResult<List<TestTreeVo>> list(@Validated(QueryGroup.class) TestTreeBo bo) { |
| | | public R<List<TestTreeVo>> list(@Validated(QueryGroup.class) TestTreeBo bo) { |
| | | List<TestTreeVo> list = iTestTreeService.queryList(bo); |
| | | return AjaxResult.success(list); |
| | | return R.ok(list); |
| | | } |
| | | |
| | | /** |
| | |
| | | @ApiOperation("è·åæµè¯æ 表详ç»ä¿¡æ¯") |
| | | @SaCheckPermission("demo:tree:query") |
| | | @GetMapping("/{id}") |
| | | public AjaxResult<TestTreeVo> getInfo(@ApiParam("æµè¯æ ID") |
| | | public R<TestTreeVo> getInfo(@ApiParam("æµè¯æ ID") |
| | | @NotNull(message = "主é®ä¸è½ä¸ºç©º") |
| | | @PathVariable("id") Long id) { |
| | | return AjaxResult.success(iTestTreeService.queryById(id)); |
| | | return R.ok(iTestTreeService.queryById(id)); |
| | | } |
| | | |
| | | /** |
| | |
| | | @Log(title = "æµè¯æ 表", businessType = BusinessType.INSERT) |
| | | @RepeatSubmit |
| | | @PostMapping() |
| | | public AjaxResult<Void> add(@Validated(AddGroup.class) @RequestBody TestTreeBo bo) { |
| | | public R<Void> add(@Validated(AddGroup.class) @RequestBody TestTreeBo bo) { |
| | | return toAjax(iTestTreeService.insertByBo(bo) ? 1 : 0); |
| | | } |
| | | |
| | |
| | | @Log(title = "æµè¯æ 表", businessType = BusinessType.UPDATE) |
| | | @RepeatSubmit |
| | | @PutMapping() |
| | | public AjaxResult<Void> edit(@Validated(EditGroup.class) @RequestBody TestTreeBo bo) { |
| | | public R<Void> edit(@Validated(EditGroup.class) @RequestBody TestTreeBo bo) { |
| | | return toAjax(iTestTreeService.updateByBo(bo) ? 1 : 0); |
| | | } |
| | | |
| | |
| | | @SaCheckPermission("demo:tree:remove") |
| | | @Log(title = "æµè¯æ 表", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{ids}") |
| | | public AjaxResult<Void> remove(@ApiParam("æµè¯æ ID串") |
| | | public R<Void> remove(@ApiParam("æµè¯æ ID串") |
| | | @NotEmpty(message = "主é®ä¸è½ä¸ºç©º") |
| | | @PathVariable Long[] ids) { |
| | | return toAjax(iTestTreeService.deleteWithValidByIds(Arrays.asList(ids), true) ? 1 : 0); |
| | |
| | | package com.ruoyi.demo.controller.queue; |
| | | |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.utils.redis.QueueUtils; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | |
| | | |
| | | @ApiOperation("æ·»å éåæ°æ®") |
| | | @GetMapping("/add") |
| | | public AjaxResult<Void> add(@ApiParam("éåå") String queueName, |
| | | public R<Void> add(@ApiParam("éåå") String queueName, |
| | | @ApiParam("容é") int capacity) { |
| | | // ç¨å®äºä¸å®è¦éæ¯ å¦åä¼ä¸ç´åå¨ |
| | | boolean b = QueueUtils.destroyBoundedQueueObject(queueName); |
| | |
| | | log.info("éé: {} , 设置容é: {}", queueName, capacity); |
| | | } else { |
| | | log.info("éé: {} , 设置容é失败", queueName); |
| | | return AjaxResult.error("æä½å¤±è´¥"); |
| | | return R.fail("æä½å¤±è´¥"); |
| | | } |
| | | for (int i = 0; i < 11; i++) { |
| | | String data = "data-" + i; |
| | |
| | | log.info("éé: {} , åéæ°æ®: {}", queueName, data); |
| | | } |
| | | } |
| | | return AjaxResult.success("æä½æå"); |
| | | return R.ok("æä½æå"); |
| | | } |
| | | |
| | | @ApiOperation("å é¤éåæ°æ®") |
| | | @GetMapping("/remove") |
| | | public AjaxResult<Void> remove(@ApiParam("éåå") String queueName) { |
| | | public R<Void> remove(@ApiParam("éåå") String queueName) { |
| | | String data = "data-" + 5; |
| | | if (QueueUtils.removeBoundedQueueObject(queueName, data)) { |
| | | log.info("éé: {} , å 餿°æ®: {}", queueName, data); |
| | | } else { |
| | | return AjaxResult.error("æä½å¤±è´¥"); |
| | | return R.fail("æä½å¤±è´¥"); |
| | | } |
| | | return AjaxResult.success("æä½æå"); |
| | | return R.ok("æä½æå"); |
| | | } |
| | | |
| | | @ApiOperation("è·åéåæ°æ®") |
| | | @GetMapping("/get") |
| | | public AjaxResult<Void> get(@ApiParam("éåå") String queueName) { |
| | | public R<Void> get(@ApiParam("éåå") String queueName) { |
| | | String data; |
| | | do { |
| | | data = QueueUtils.getBoundedQueueObject(queueName); |
| | | log.info("éé: {} , è·åæ°æ®: {}", queueName, data); |
| | | } while (data != null); |
| | | return AjaxResult.success("æä½æå"); |
| | | return R.ok("æä½æå"); |
| | | } |
| | | |
| | | } |
| | |
| | | package com.ruoyi.demo.controller.queue; |
| | | |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.utils.redis.QueueUtils; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | |
| | | |
| | | @ApiOperation("订é
éå") |
| | | @GetMapping("/subscribe") |
| | | public AjaxResult<Void> subscribe(@ApiParam("éåå") String queueName) { |
| | | public R<Void> subscribe(@ApiParam("éåå") String queueName) { |
| | | log.info("éé: {} çå¬ä¸......", queueName); |
| | | // 项ç®åå§åè®¾ç½®ä¸æ¬¡å³å¯ |
| | | QueueUtils.subscribeBlockingQueue(queueName, (String orderNum) -> { |
| | | // è§å¯æ¥æ¶æ¶é´ |
| | | log.info("éé: {}, æ¶å°æ°æ®: {}", queueName, orderNum); |
| | | }); |
| | | return AjaxResult.success("æä½æå"); |
| | | return R.ok("æä½æå"); |
| | | } |
| | | |
| | | @ApiOperation("æ·»å éåæ°æ®") |
| | | @GetMapping("/add") |
| | | public AjaxResult<Void> add(@ApiParam("éåå") String queueName, |
| | | public R<Void> add(@ApiParam("éåå") String queueName, |
| | | @ApiParam("订åå·") String orderNum, |
| | | @ApiParam("å»¶è¿æ¶é´(ç§)") Long time) { |
| | | QueueUtils.addDelayedQueueObject(queueName, orderNum, time, TimeUnit.SECONDS); |
| | | // è§å¯åéæ¶é´ |
| | | log.info("éé: {} , åéæ°æ®: {}", queueName, orderNum); |
| | | return AjaxResult.success("æä½æå"); |
| | | return R.ok("æä½æå"); |
| | | } |
| | | |
| | | @ApiOperation("å é¤éåæ°æ®") |
| | | @GetMapping("/remove") |
| | | public AjaxResult<Void> remove(@ApiParam("éåå") String queueName, |
| | | public R<Void> remove(@ApiParam("éåå") String queueName, |
| | | @ApiParam("订åå·") String orderNum) { |
| | | if (QueueUtils.removeDelayedQueueObject(queueName, orderNum)) { |
| | | log.info("éé: {} , å 餿°æ®: {}", queueName, orderNum); |
| | | } else { |
| | | return AjaxResult.error("æä½å¤±è´¥"); |
| | | return R.fail("æä½å¤±è´¥"); |
| | | } |
| | | return AjaxResult.success("æä½æå"); |
| | | return R.ok("æä½æå"); |
| | | } |
| | | |
| | | @ApiOperation("鿝éå") |
| | | @GetMapping("/destroy") |
| | | public AjaxResult<Void> destroy(@ApiParam("éåå") String queueName) { |
| | | public R<Void> destroy(@ApiParam("éåå") String queueName) { |
| | | // ç¨å®äºä¸å®è¦éæ¯ å¦åä¼ä¸ç´åå¨ |
| | | QueueUtils.destroyDelayedQueue(queueName); |
| | | return AjaxResult.success("æä½æå"); |
| | | return R.ok("æä½æå"); |
| | | } |
| | | |
| | | } |
| | |
| | | package com.ruoyi.demo.controller.queue; |
| | | |
| | | import cn.hutool.core.util.RandomUtil; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.utils.redis.QueueUtils; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | |
| | | |
| | | @ApiOperation("æ·»å éåæ°æ®") |
| | | @GetMapping("/add") |
| | | public AjaxResult<Void> add(@ApiParam("éåå") String queueName) { |
| | | public R<Void> add(@ApiParam("éåå") String queueName) { |
| | | // ç¨å®äºä¸å®è¦éæ¯ å¦åä¼ä¸ç´åå¨ |
| | | boolean b = QueueUtils.destroyPriorityQueueObject(queueName); |
| | | log.info("éé: {} , å é¤: {}", queueName, b); |
| | |
| | | log.info("éé: {} , 设置æ¯è¾å¨æå", queueName); |
| | | } else { |
| | | log.info("éé: {} , 设置æ¯è¾å¨å¤±è´¥", queueName); |
| | | return AjaxResult.error("æä½å¤±è´¥"); |
| | | return R.fail("æä½å¤±è´¥"); |
| | | } |
| | | for (int i = 0; i < 10; i++) { |
| | | int randomNum = RandomUtil.randomInt(10); |
| | |
| | | log.info("éé: {} , åéæ°æ®: {}, åé失败", queueName, data); |
| | | } |
| | | } |
| | | return AjaxResult.success("æä½æå"); |
| | | return R.ok("æä½æå"); |
| | | } |
| | | |
| | | @ApiOperation("å é¤éåæ°æ®") |
| | | @GetMapping("/remove") |
| | | public AjaxResult<Void> remove(@ApiParam("éåå") String queueName, |
| | | public R<Void> remove(@ApiParam("éåå") String queueName, |
| | | @ApiParam("对象å") String name, |
| | | @ApiParam("æåºå·") Integer orderNum) { |
| | | PriorityDemo data = new PriorityDemo(); |
| | |
| | | if (QueueUtils.removePriorityQueueObject(queueName, data)) { |
| | | log.info("éé: {} , å 餿°æ®: {}", queueName, data); |
| | | } else { |
| | | return AjaxResult.error("æä½å¤±è´¥"); |
| | | return R.fail("æä½å¤±è´¥"); |
| | | } |
| | | return AjaxResult.success("æä½æå"); |
| | | return R.ok("æä½æå"); |
| | | } |
| | | |
| | | @ApiOperation("è·åéåæ°æ®") |
| | | @GetMapping("/get") |
| | | public AjaxResult<Void> get(@ApiParam("éåå") String queueName) { |
| | | public R<Void> get(@ApiParam("éåå") String queueName) { |
| | | PriorityDemo data; |
| | | do { |
| | | data = QueueUtils.getPriorityQueueObject(queueName); |
| | | log.info("éé: {} , è·åæ°æ®: {}", queueName, data); |
| | | } while (data != null); |
| | | return AjaxResult.success("æä½æå"); |
| | | return R.ok("æä½æå"); |
| | | } |
| | | |
| | | } |
| | |
| | | import cn.dev33.satoken.exception.NotRoleException; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import cn.hutool.http.HttpStatus; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.exception.DemoModeException; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | * æéç å¼å¸¸ |
| | | */ |
| | | @ExceptionHandler(NotPermissionException.class) |
| | | public AjaxResult<Void> handleNotPermissionException(NotPermissionException e, HttpServletRequest request) { |
| | | public R<Void> handleNotPermissionException(NotPermissionException e, HttpServletRequest request) { |
| | | String requestURI = request.getRequestURI(); |
| | | log.error("请æ±å°å'{}',æéç æ ¡éªå¤±è´¥'{}'", requestURI, e.getMessage()); |
| | | return AjaxResult.error(HttpStatus.HTTP_FORBIDDEN, "没æè®¿é®æéï¼è¯·è系管çåææ"); |
| | | return R.fail(HttpStatus.HTTP_FORBIDDEN, "没æè®¿é®æéï¼è¯·è系管çåææ"); |
| | | } |
| | | |
| | | /** |
| | | * è§è²æéå¼å¸¸ |
| | | */ |
| | | @ExceptionHandler(NotRoleException.class) |
| | | public AjaxResult<Void> handleNotRoleException(NotRoleException e, HttpServletRequest request) { |
| | | public R<Void> handleNotRoleException(NotRoleException e, HttpServletRequest request) { |
| | | String requestURI = request.getRequestURI(); |
| | | log.error("请æ±å°å'{}',è§è²æéæ ¡éªå¤±è´¥'{}'", requestURI, e.getMessage()); |
| | | return AjaxResult.error(HttpStatus.HTTP_FORBIDDEN, "没æè®¿é®æéï¼è¯·è系管çåææ"); |
| | | return R.fail(HttpStatus.HTTP_FORBIDDEN, "没æè®¿é®æéï¼è¯·è系管çåææ"); |
| | | } |
| | | |
| | | /** |
| | | * 认è¯å¤±è´¥ |
| | | */ |
| | | @ExceptionHandler(NotLoginException.class) |
| | | public AjaxResult<Void> handleNotLoginException(NotLoginException e, HttpServletRequest request) { |
| | | public R<Void> handleNotLoginException(NotLoginException e, HttpServletRequest request) { |
| | | String requestURI = request.getRequestURI(); |
| | | log.error("请æ±å°å'{}',认è¯å¤±è´¥'{}',æ æ³è®¿é®ç³»ç»èµæº", requestURI, e.getMessage()); |
| | | return AjaxResult.error(HttpStatus.HTTP_UNAUTHORIZED, "认è¯å¤±è´¥ï¼æ æ³è®¿é®ç³»ç»èµæº"); |
| | | return R.fail(HttpStatus.HTTP_UNAUTHORIZED, "认è¯å¤±è´¥ï¼æ æ³è®¿é®ç³»ç»èµæº"); |
| | | } |
| | | |
| | | /** |
| | | * è¯·æ±æ¹å¼ä¸æ¯æ |
| | | */ |
| | | @ExceptionHandler(HttpRequestMethodNotSupportedException.class) |
| | | public AjaxResult<Void> handleHttpRequestMethodNotSupported(HttpRequestMethodNotSupportedException e, |
| | | public R<Void> handleHttpRequestMethodNotSupported(HttpRequestMethodNotSupportedException e, |
| | | HttpServletRequest request) { |
| | | String requestURI = request.getRequestURI(); |
| | | log.error("请æ±å°å'{}',䏿¯æ'{}'请æ±", requestURI, e.getMethod()); |
| | | return AjaxResult.error(e.getMessage()); |
| | | return R.fail(e.getMessage()); |
| | | } |
| | | |
| | | /** |
| | | * ä¸å¡å¼å¸¸ |
| | | */ |
| | | @ExceptionHandler(ServiceException.class) |
| | | public AjaxResult<Void> handleServiceException(ServiceException e, HttpServletRequest request) { |
| | | public R<Void> handleServiceException(ServiceException e, HttpServletRequest request) { |
| | | log.error(e.getMessage(), e); |
| | | Integer code = e.getCode(); |
| | | return ObjectUtil.isNotNull(code) ? AjaxResult.error(code, e.getMessage()) : AjaxResult.error(e.getMessage()); |
| | | return ObjectUtil.isNotNull(code) ? R.fail(code.intValue(), e.getMessage()) : R.fail(e.getMessage()); |
| | | } |
| | | |
| | | /** |
| | | * æ¦æªæªç¥çè¿è¡æ¶å¼å¸¸ |
| | | */ |
| | | @ExceptionHandler(RuntimeException.class) |
| | | public AjaxResult<Void> handleRuntimeException(RuntimeException e, HttpServletRequest request) { |
| | | public R<Void> handleRuntimeException(RuntimeException e, HttpServletRequest request) { |
| | | String requestURI = request.getRequestURI(); |
| | | log.error("请æ±å°å'{}',åçæªç¥å¼å¸¸.", requestURI, e); |
| | | return AjaxResult.error(e.getMessage()); |
| | | return R.fail(e.getMessage()); |
| | | } |
| | | |
| | | /** |
| | | * ç³»ç»å¼å¸¸ |
| | | */ |
| | | @ExceptionHandler(Exception.class) |
| | | public AjaxResult<Void> handleException(Exception e, HttpServletRequest request) { |
| | | public R<Void> handleException(Exception e, HttpServletRequest request) { |
| | | String requestURI = request.getRequestURI(); |
| | | log.error("请æ±å°å'{}',åçç³»ç»å¼å¸¸.", requestURI, e); |
| | | return AjaxResult.error(e.getMessage()); |
| | | return R.fail(e.getMessage()); |
| | | } |
| | | |
| | | /** |
| | | * èªå®ä¹éªè¯å¼å¸¸ |
| | | */ |
| | | @ExceptionHandler(BindException.class) |
| | | public AjaxResult<Void> handleBindException(BindException e) { |
| | | public R<Void> handleBindException(BindException e) { |
| | | log.error(e.getMessage(), e); |
| | | String message = e.getAllErrors().stream() |
| | | .map(DefaultMessageSourceResolvable::getDefaultMessage) |
| | | .collect(Collectors.joining(", ")); |
| | | return AjaxResult.error(message); |
| | | return R.fail(message); |
| | | } |
| | | |
| | | /** |
| | | * èªå®ä¹éªè¯å¼å¸¸ |
| | | */ |
| | | @ExceptionHandler(ConstraintViolationException.class) |
| | | public AjaxResult<Void> constraintViolationException(ConstraintViolationException e) { |
| | | public R<Void> constraintViolationException(ConstraintViolationException e) { |
| | | log.error(e.getMessage(), e); |
| | | String message = e.getConstraintViolations().stream() |
| | | .map(ConstraintViolation::getMessage) |
| | | .collect(Collectors.joining(", ")); |
| | | return AjaxResult.error(message); |
| | | return R.fail(message); |
| | | } |
| | | |
| | | /** |
| | | * èªå®ä¹éªè¯å¼å¸¸ |
| | | */ |
| | | @ExceptionHandler(MethodArgumentNotValidException.class) |
| | | public AjaxResult<Void> handleMethodArgumentNotValidException(MethodArgumentNotValidException e) { |
| | | public R<Void> handleMethodArgumentNotValidException(MethodArgumentNotValidException e) { |
| | | log.error(e.getMessage(), e); |
| | | String message = e.getBindingResult().getFieldError().getDefaultMessage(); |
| | | return AjaxResult.error(message); |
| | | return R.fail(message); |
| | | } |
| | | |
| | | /** |
| | | * æ¼ç¤ºæ¨¡å¼å¼å¸¸ |
| | | */ |
| | | @ExceptionHandler(DemoModeException.class) |
| | | public AjaxResult<Void> handleDemoModeException(DemoModeException e) { |
| | | return AjaxResult.error("æ¼ç¤ºæ¨¡å¼ï¼ä¸å
许æä½"); |
| | | public R<Void> handleDemoModeException(DemoModeException e) { |
| | | return R.fail("æ¼ç¤ºæ¨¡å¼ï¼ä¸å
许æä½"); |
| | | } |
| | | } |
| | |
| | | import cn.hutool.core.io.IoUtil; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | |
| | | @ApiOperation("ä¿®æ¹ä»£ç çæä¸å¡") |
| | | @SaCheckPermission("tool:gen:query") |
| | | @GetMapping(value = "/{talbleId}") |
| | | public AjaxResult<Map<String, Object>> getInfo(@PathVariable Long talbleId) { |
| | | public R<Map<String, Object>> getInfo(@PathVariable Long talbleId) { |
| | | GenTable table = genTableService.selectGenTableById(talbleId); |
| | | List<GenTable> tables = genTableService.selectGenTableAll(); |
| | | List<GenTableColumn> list = genTableColumnService.selectGenTableColumnListByTableId(talbleId); |
| | |
| | | map.put("info", table); |
| | | map.put("rows", list); |
| | | map.put("tables", tables); |
| | | return AjaxResult.success(map); |
| | | return R.ok(map); |
| | | } |
| | | |
| | | /** |
| | |
| | | @SaCheckPermission("tool:gen:import") |
| | | @Log(title = "代ç çæ", businessType = BusinessType.IMPORT) |
| | | @PostMapping("/importTable") |
| | | public AjaxResult<Void> importTableSave(String tables) { |
| | | public R<Void> importTableSave(String tables) { |
| | | String[] tableNames = Convert.toStrArray(tables); |
| | | // æ¥è¯¢è¡¨ä¿¡æ¯ |
| | | List<GenTable> tableList = genTableService.selectDbTableListByNames(tableNames); |
| | | genTableService.importGenTable(tableList); |
| | | return AjaxResult.success(); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | |
| | | @SaCheckPermission("tool:gen:edit") |
| | | @Log(title = "代ç çæ", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public AjaxResult<Void> editSave(@Validated @RequestBody GenTable genTable) { |
| | | public R<Void> editSave(@Validated @RequestBody GenTable genTable) { |
| | | genTableService.validateEdit(genTable); |
| | | genTableService.updateGenTable(genTable); |
| | | return AjaxResult.success(); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | |
| | | @SaCheckPermission("tool:gen:remove") |
| | | @Log(title = "代ç çæ", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{tableIds}") |
| | | public AjaxResult<Void> remove(@PathVariable Long[] tableIds) { |
| | | public R<Void> remove(@PathVariable Long[] tableIds) { |
| | | genTableService.deleteGenTableByIds(tableIds); |
| | | return AjaxResult.success(); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | |
| | | @ApiOperation("é¢è§ä»£ç ") |
| | | @SaCheckPermission("tool:gen:preview") |
| | | @GetMapping("/preview/{tableId}") |
| | | public AjaxResult<Map<String, String>> preview(@PathVariable("tableId") Long tableId) throws IOException { |
| | | public R<Map<String, String>> preview(@PathVariable("tableId") Long tableId) throws IOException { |
| | | Map<String, String> dataMap = genTableService.previewCode(tableId); |
| | | return AjaxResult.success(dataMap); |
| | | return R.ok(dataMap); |
| | | } |
| | | |
| | | /** |
| | |
| | | @SaCheckPermission("tool:gen:code") |
| | | @Log(title = "代ç çæ", businessType = BusinessType.GENCODE) |
| | | @GetMapping("/genCode/{tableName}") |
| | | public AjaxResult<Void> genCode(@PathVariable("tableName") String tableName) { |
| | | public R<Void> genCode(@PathVariable("tableName") String tableName) { |
| | | genTableService.generatorCode(tableName); |
| | | return AjaxResult.success(); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | |
| | | @SaCheckPermission("tool:gen:edit") |
| | | @Log(title = "代ç çæ", businessType = BusinessType.UPDATE) |
| | | @GetMapping("/synchDb/{tableName}") |
| | | public AjaxResult<Void> synchDb(@PathVariable("tableName") String tableName) { |
| | | public R<Void> synchDb(@PathVariable("tableName") String tableName) { |
| | | genTableService.synchDb(tableName); |
| | | return AjaxResult.success(); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.validate.AddGroup; |
| | | import com.ruoyi.common.core.validate.EditGroup; |
| | | import com.ruoyi.common.core.validate.QueryGroup; |
| | |
| | | return i${ClassName}Service.queryPageList(bo, pageQuery); |
| | | } |
| | | #elseif($table.tree) |
| | | public AjaxResult<List<${ClassName}Vo>> list(@Validated(QueryGroup.class) ${ClassName}Bo bo) { |
| | | public R<List<${ClassName}Vo>> list(@Validated(QueryGroup.class) ${ClassName}Bo bo) { |
| | | List<${ClassName}Vo> list = i${ClassName}Service.queryList(bo); |
| | | return AjaxResult.success(list); |
| | | return R.ok(list); |
| | | } |
| | | #end |
| | | |
| | |
| | | @ApiOperation("è·å${functionName}详ç»ä¿¡æ¯") |
| | | @SaCheckPermission("${permissionPrefix}:query") |
| | | @GetMapping("/{${pkColumn.javaField}}") |
| | | public AjaxResult<${ClassName}Vo> getInfo(@ApiParam("主é®") |
| | | public R<${ClassName}Vo> getInfo(@ApiParam("主é®") |
| | | @NotNull(message = "主é®ä¸è½ä¸ºç©º") |
| | | @PathVariable("${pkColumn.javaField}") ${pkColumn.javaType} ${pkColumn.javaField}) { |
| | | return AjaxResult.success(i${ClassName}Service.queryById(${pkColumn.javaField})); |
| | | return R.ok(i${ClassName}Service.queryById(${pkColumn.javaField})); |
| | | } |
| | | |
| | | /** |
| | |
| | | @Log(title = "${functionName}", businessType = BusinessType.INSERT) |
| | | @RepeatSubmit() |
| | | @PostMapping() |
| | | public AjaxResult<Void> add(@Validated(AddGroup.class) @RequestBody ${ClassName}Bo bo) { |
| | | public R<Void> add(@Validated(AddGroup.class) @RequestBody ${ClassName}Bo bo) { |
| | | return toAjax(i${ClassName}Service.insertByBo(bo) ? 1 : 0); |
| | | } |
| | | |
| | |
| | | @Log(title = "${functionName}", businessType = BusinessType.UPDATE) |
| | | @RepeatSubmit() |
| | | @PutMapping() |
| | | public AjaxResult<Void> edit(@Validated(EditGroup.class) @RequestBody ${ClassName}Bo bo) { |
| | | public R<Void> edit(@Validated(EditGroup.class) @RequestBody ${ClassName}Bo bo) { |
| | | return toAjax(i${ClassName}Service.updateByBo(bo) ? 1 : 0); |
| | | } |
| | | |
| | |
| | | @SaCheckPermission("${permissionPrefix}:remove") |
| | | @Log(title = "${functionName}", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{${pkColumn.javaField}s}") |
| | | public AjaxResult<Void> remove(@ApiParam("主é®ä¸²") |
| | | public R<Void> remove(@ApiParam("主é®ä¸²") |
| | | @NotEmpty(message = "主é®ä¸è½ä¸ºç©º") |
| | | @PathVariable ${pkColumn.javaType}[] ${pkColumn.javaField}s) { |
| | | return toAjax(i${ClassName}Service.deleteWithValidByIds(Arrays.asList(${pkColumn.javaField}s), true) ? 1 : 0); |