| | |
| | | <javase.version>3.4.1</javase.version> |
| | | <minio.version>8.4.3</minio.version> |
| | | <okhttp.version>4.9.0</okhttp.version> |
| | | <hutool.version>5.8.18</hutool.version> |
| | | </properties> |
| | | |
| | | <!-- ä¾èµå£°æ --> |
| | |
| | | <artifactId>javase</artifactId> |
| | | <version>${javase.version}</version> <!-- æè
æ´é«çæ¬ --> |
| | | </dependency> |
| | | |
| | | <!--hutoolå·¥å
·å
--> |
| | | <dependency> |
| | | <groupId>cn.hutool</groupId> |
| | | <artifactId>hutool-all</artifactId> |
| | | <version>${hutool.version}</version> |
| | | </dependency> |
| | | </dependencies> |
| | | |
| | | <modules> |
| | |
| | | import com.ruoyi.common.config.RuoYiConfig; |
| | | import com.ruoyi.common.constant.CacheConstants; |
| | | import com.ruoyi.common.constant.Constants; |
| | | import com.ruoyi.common.core.domain.Result; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.redis.RedisCache; |
| | | import com.ruoyi.common.utils.sign.Base64; |
| | | import com.ruoyi.common.utils.uuid.IdUtils; |
| | |
| | | * çæéªè¯ç |
| | | */ |
| | | @GetMapping("/captchaImage") |
| | | public Result getCode(HttpServletResponse response) throws IOException |
| | | public AjaxResult getCode(HttpServletResponse response) throws IOException |
| | | { |
| | | Result ajax = Result.success(); |
| | | AjaxResult ajax = AjaxResult.success(); |
| | | boolean captchaEnabled = configService.selectCaptchaEnabled(); |
| | | ajax.put("captchaEnabled", captchaEnabled); |
| | | if (!captchaEnabled) |
| | |
| | | } |
| | | catch (IOException e) |
| | | { |
| | | return Result.error(e.getMessage()); |
| | | return AjaxResult.error(e.getMessage()); |
| | | } |
| | | |
| | | ajax.put("uuid", uuid); |
| | |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | import com.ruoyi.common.config.RuoYiConfig; |
| | | import com.ruoyi.common.constant.Constants; |
| | | import com.ruoyi.common.core.domain.Result; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.file.FileUploadUtils; |
| | | import com.ruoyi.common.utils.file.FileUtils; |
| | |
| | | * éç¨ä¸ä¼ 请æ±ï¼åä¸ªï¼ |
| | | */ |
| | | @PostMapping("/upload") |
| | | public Result uploadFile(MultipartFile file) throws Exception |
| | | public AjaxResult uploadFile(MultipartFile file) throws Exception |
| | | { |
| | | try |
| | | { |
| | |
| | | // ä¸ä¼ å¹¶è¿åæ°æä»¶åç§° |
| | | String fileName = FileUploadUtils.upload(filePath, file); |
| | | String url = serverConfig.getUrl() + fileName; |
| | | Result ajax = Result.success(); |
| | | AjaxResult ajax = AjaxResult.success(); |
| | | ajax.put("url", url); |
| | | ajax.put("fileName", fileName); |
| | | ajax.put("newFileName", FileUtils.getName(fileName)); |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | return Result.error(e.getMessage()); |
| | | return AjaxResult.error(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | |
| | | * éç¨ä¸ä¼ 请æ±ï¼å¤ä¸ªï¼ |
| | | */ |
| | | @PostMapping("/uploads") |
| | | public Result uploadFiles(List<MultipartFile> files) throws Exception |
| | | public AjaxResult uploadFiles(List<MultipartFile> files) throws Exception |
| | | { |
| | | try |
| | | { |
| | |
| | | newFileNames.add(FileUtils.getName(fileName)); |
| | | originalFilenames.add(file.getOriginalFilename()); |
| | | } |
| | | Result ajax = Result.success(); |
| | | AjaxResult ajax = AjaxResult.success(); |
| | | ajax.put("urls", StringUtils.join(urls, FILE_DELIMETER)); |
| | | ajax.put("fileNames", StringUtils.join(fileNames, FILE_DELIMETER)); |
| | | ajax.put("newFileNames", StringUtils.join(newFileNames, FILE_DELIMETER)); |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | return Result.error(e.getMessage()); |
| | | return AjaxResult.error(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import com.ruoyi.common.constant.CacheConstants; |
| | | import com.ruoyi.common.core.domain.Result; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.system.domain.SysCache; |
| | | |
| | |
| | | |
| | | @PreAuthorize("@ss.hasPermi('monitor:cache:list')") |
| | | @GetMapping() |
| | | public Result getInfo() throws Exception |
| | | public AjaxResult getInfo() throws Exception |
| | | { |
| | | Properties info = (Properties) redisTemplate.execute((RedisCallback<Object>) connection -> connection.info()); |
| | | Properties commandStats = (Properties) redisTemplate.execute((RedisCallback<Object>) connection -> connection.info("commandstats")); |
| | |
| | | pieList.add(data); |
| | | }); |
| | | result.put("commandStats", pieList); |
| | | return Result.success(result); |
| | | return AjaxResult.success(result); |
| | | } |
| | | |
| | | @PreAuthorize("@ss.hasPermi('monitor:cache:list')") |
| | | @GetMapping("/getNames") |
| | | public Result cache() |
| | | public AjaxResult cache() |
| | | { |
| | | return Result.success(caches); |
| | | return AjaxResult.success(caches); |
| | | } |
| | | |
| | | @PreAuthorize("@ss.hasPermi('monitor:cache:list')") |
| | | @GetMapping("/getKeys/{cacheName}") |
| | | public Result getCacheKeys(@PathVariable String cacheName) |
| | | public AjaxResult getCacheKeys(@PathVariable String cacheName) |
| | | { |
| | | Set<String> cacheKeys = redisTemplate.keys(cacheName + "*"); |
| | | return Result.success(new TreeSet<>(cacheKeys)); |
| | | return AjaxResult.success(new TreeSet<>(cacheKeys)); |
| | | } |
| | | |
| | | @PreAuthorize("@ss.hasPermi('monitor:cache:list')") |
| | | @GetMapping("/getValue/{cacheName}/{cacheKey}") |
| | | public Result getCacheValue(@PathVariable String cacheName, @PathVariable String cacheKey) |
| | | public AjaxResult getCacheValue(@PathVariable String cacheName, @PathVariable String cacheKey) |
| | | { |
| | | String cacheValue = redisTemplate.opsForValue().get(cacheKey); |
| | | SysCache sysCache = new SysCache(cacheName, cacheKey, cacheValue); |
| | | return Result.success(sysCache); |
| | | return AjaxResult.success(sysCache); |
| | | } |
| | | |
| | | @PreAuthorize("@ss.hasPermi('monitor:cache:list')") |
| | | @DeleteMapping("/clearCacheName/{cacheName}") |
| | | public Result clearCacheName(@PathVariable String cacheName) |
| | | public AjaxResult clearCacheName(@PathVariable String cacheName) |
| | | { |
| | | Collection<String> cacheKeys = redisTemplate.keys(cacheName + "*"); |
| | | redisTemplate.delete(cacheKeys); |
| | | return Result.success(); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | @PreAuthorize("@ss.hasPermi('monitor:cache:list')") |
| | | @DeleteMapping("/clearCacheKey/{cacheKey}") |
| | | public Result clearCacheKey(@PathVariable String cacheKey) |
| | | public AjaxResult clearCacheKey(@PathVariable String cacheKey) |
| | | { |
| | | redisTemplate.delete(cacheKey); |
| | | return Result.success(); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | @PreAuthorize("@ss.hasPermi('monitor:cache:list')") |
| | | @DeleteMapping("/clearCacheAll") |
| | | public Result clearCacheAll() |
| | | public AjaxResult clearCacheAll() |
| | | { |
| | | Collection<String> cacheKeys = redisTemplate.keys("*"); |
| | | redisTemplate.delete(cacheKeys); |
| | | return Result.success(); |
| | | return AjaxResult.success(); |
| | | } |
| | | } |
| | |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import com.ruoyi.common.core.domain.Result; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.framework.web.domain.Server; |
| | | |
| | | /** |
| | |
| | | { |
| | | @PreAuthorize("@ss.hasPermi('monitor:server:list')") |
| | | @GetMapping() |
| | | public Result getInfo() throws Exception |
| | | public AjaxResult getInfo() throws Exception |
| | | { |
| | | Server server = new Server(); |
| | | server.copyTo(); |
| | | return Result.success(server); |
| | | return AjaxResult.success(server); |
| | | } |
| | | } |
| | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.Result; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | |
| | | @PreAuthorize("@ss.hasPermi('monitor:logininfor:remove')") |
| | | @Log(title = "ç»å½æ¥å¿", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{infoIds}") |
| | | public Result remove(@PathVariable Long[] infoIds) |
| | | public AjaxResult remove(@PathVariable Long[] infoIds) |
| | | { |
| | | return toAjax(logininforService.deleteLogininforByIds(infoIds)); |
| | | } |
| | |
| | | @PreAuthorize("@ss.hasPermi('monitor:logininfor:remove')") |
| | | @Log(title = "ç»å½æ¥å¿", businessType = BusinessType.CLEAN) |
| | | @DeleteMapping("/clean") |
| | | public Result clean() |
| | | public AjaxResult clean() |
| | | { |
| | | logininforService.cleanLogininfor(); |
| | | return success(); |
| | |
| | | @PreAuthorize("@ss.hasPermi('monitor:logininfor:unlock')") |
| | | @Log(title = "è´¦æ·è§£é", businessType = BusinessType.OTHER) |
| | | @GetMapping("/unlock/{userName}") |
| | | public Result unlock(@PathVariable("userName") String userName) |
| | | public AjaxResult unlock(@PathVariable("userName") String userName) |
| | | { |
| | | passwordService.clearLoginRecordCache(userName); |
| | | return success(); |
| | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.Result; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | |
| | | @Log(title = "æä½æ¥å¿", businessType = BusinessType.DELETE) |
| | | @PreAuthorize("@ss.hasPermi('monitor:operlog:remove')") |
| | | @DeleteMapping("/{operIds}") |
| | | public Result remove(@PathVariable Long[] operIds) |
| | | public AjaxResult remove(@PathVariable Long[] operIds) |
| | | { |
| | | return toAjax(operLogService.deleteOperLogByIds(operIds)); |
| | | } |
| | |
| | | @Log(title = "æä½æ¥å¿", businessType = BusinessType.CLEAN) |
| | | @PreAuthorize("@ss.hasPermi('monitor:operlog:remove')") |
| | | @DeleteMapping("/clean") |
| | | public Result clean() |
| | | public AjaxResult clean() |
| | | { |
| | | operLogService.cleanOperLog(); |
| | | return success(); |
| | |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.constant.CacheConstants; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.Result; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.model.LoginUser; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.core.redis.RedisCache; |
| | |
| | | @PreAuthorize("@ss.hasPermi('monitor:online:forceLogout')") |
| | | @Log(title = "å¨çº¿ç¨æ·", businessType = BusinessType.FORCE) |
| | | @DeleteMapping("/{tokenId}") |
| | | public Result forceLogout(@PathVariable String tokenId) |
| | | public AjaxResult forceLogout(@PathVariable String tokenId) |
| | | { |
| | | redisCache.deleteObject(CacheConstants.LOGIN_TOKEN_KEY + tokenId); |
| | | return success(); |
| | |
| | | package com.ruoyi.web.controller.system; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.core.domain.Result; |
| | | import com.ruoyi.common.core.domain.entity.Custom; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.system.service.CustomService; |
| | | import com.ruoyi.system.service.UserService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Map; |
| | | import java.util.List; |
| | | |
| | | |
| | | /** |
| | |
| | | private CustomService customService; |
| | | |
| | | @ApiOperation(value = "è·å客æ·å表") |
| | | @PostMapping("/selectCustomPageList") |
| | | public Result selectCustomPageList(@RequestBody Map<String, Object> data) throws Exception { |
| | | return Result.success(customService.selectCustomPageList(null, null)); |
| | | @GetMapping("/selectCustomPageList") |
| | | public Result<IPage<Custom>> selectCustomPageList(Page page, Custom custom) throws Exception { |
| | | return Result.success(customService.selectCustomPageList(page, custom)); |
| | | } |
| | | @ApiOperation(value = "å é¤å®¢æ·ä¿¡æ¯") |
| | | @PostMapping("/delCustomById") |
| | |
| | | return Result.success(customService.upCustom(custom)); |
| | | } |
| | | |
| | | @ApiOperation(value = "è·åå®¢æ·æä¸¾") |
| | | @GetMapping ("/selectCustomEnum") |
| | | public Result<List<Custom>> selectCustomEnum(){ |
| | | return Result.success(customService.selectCustomEnum()); |
| | | } |
| | | |
| | | } |
| | | |
| | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.Result; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:config:query')") |
| | | @GetMapping(value = "/{configId}") |
| | | public Result getInfo(@PathVariable Long configId) |
| | | public AjaxResult getInfo(@PathVariable Long configId) |
| | | { |
| | | return success(configService.selectConfigById(configId)); |
| | | } |
| | |
| | | * æ ¹æ®åæ°é®åæ¥è¯¢åæ°å¼ |
| | | */ |
| | | @GetMapping(value = "/configKey/{configKey}") |
| | | public Result getConfigKey(@PathVariable String configKey) |
| | | public AjaxResult getConfigKey(@PathVariable String configKey) |
| | | { |
| | | return success(configService.selectConfigByKey(configKey)); |
| | | } |
| | |
| | | @PreAuthorize("@ss.hasPermi('system:config:add')") |
| | | @Log(title = "åæ°ç®¡ç", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public Result add(@Validated @RequestBody SysConfig config) |
| | | public AjaxResult add(@Validated @RequestBody SysConfig config) |
| | | { |
| | | if (!configService.checkConfigKeyUnique(config)) |
| | | { |
| | |
| | | @PreAuthorize("@ss.hasPermi('system:config:edit')") |
| | | @Log(title = "åæ°ç®¡ç", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public Result edit(@Validated @RequestBody SysConfig config) |
| | | public AjaxResult edit(@Validated @RequestBody SysConfig config) |
| | | { |
| | | if (!configService.checkConfigKeyUnique(config)) |
| | | { |
| | |
| | | @PreAuthorize("@ss.hasPermi('system:config:remove')") |
| | | @Log(title = "åæ°ç®¡ç", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{configIds}") |
| | | public Result remove(@PathVariable Long[] configIds) |
| | | public AjaxResult remove(@PathVariable Long[] configIds) |
| | | { |
| | | configService.deleteConfigByIds(configIds); |
| | | return success(); |
| | |
| | | @PreAuthorize("@ss.hasPermi('system:config:remove')") |
| | | @Log(title = "åæ°ç®¡ç", businessType = BusinessType.CLEAN) |
| | | @DeleteMapping("/refreshCache") |
| | | public Result refreshCache() |
| | | public AjaxResult refreshCache() |
| | | { |
| | | configService.resetConfigCache(); |
| | | 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.Result; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.entity.SysDept; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:dept:list')") |
| | | @GetMapping("/list") |
| | | public Result list(SysDept dept) |
| | | public AjaxResult list(SysDept dept) |
| | | { |
| | | List<SysDept> depts = deptService.selectDeptList(dept); |
| | | return success(depts); |
| | |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:dept:list')") |
| | | @GetMapping("/list/exclude/{deptId}") |
| | | public Result excludeChild(@PathVariable(value = "deptId", required = false) Long deptId) |
| | | public AjaxResult excludeChild(@PathVariable(value = "deptId", required = false) Long deptId) |
| | | { |
| | | List<SysDept> depts = deptService.selectDeptList(new SysDept()); |
| | | depts.removeIf(d -> d.getDeptId().intValue() == deptId || ArrayUtils.contains(StringUtils.split(d.getAncestors(), ","), deptId + "")); |
| | |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:dept:query')") |
| | | @GetMapping(value = "/{deptId}") |
| | | public Result getInfo(@PathVariable Long deptId) |
| | | public AjaxResult getInfo(@PathVariable Long deptId) |
| | | { |
| | | deptService.checkDeptDataScope(deptId); |
| | | return success(deptService.selectDeptById(deptId)); |
| | |
| | | @PreAuthorize("@ss.hasPermi('system:dept:add')") |
| | | @Log(title = "é¨é¨ç®¡ç", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public Result add(@Validated @RequestBody SysDept dept) |
| | | public AjaxResult add(@Validated @RequestBody SysDept dept) |
| | | { |
| | | if (!deptService.checkDeptNameUnique(dept)) |
| | | { |
| | |
| | | @PreAuthorize("@ss.hasPermi('system:dept:edit')") |
| | | @Log(title = "é¨é¨ç®¡ç", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public Result edit(@Validated @RequestBody SysDept dept) |
| | | public AjaxResult edit(@Validated @RequestBody SysDept dept) |
| | | { |
| | | Long deptId = dept.getDeptId(); |
| | | deptService.checkDeptDataScope(deptId); |
| | |
| | | @PreAuthorize("@ss.hasPermi('system:dept:remove')") |
| | | @Log(title = "é¨é¨ç®¡ç", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{deptId}") |
| | | public Result remove(@PathVariable Long deptId) |
| | | public AjaxResult remove(@PathVariable Long deptId) |
| | | { |
| | | if (deptService.hasChildByDeptId(deptId)) |
| | | { |
| | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.Result; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.entity.SysDictData; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:dict:query')") |
| | | @GetMapping(value = "/{dictCode}") |
| | | public Result getInfo(@PathVariable Long dictCode) |
| | | public AjaxResult getInfo(@PathVariable Long dictCode) |
| | | { |
| | | return success(dictDataService.selectDictDataById(dictCode)); |
| | | } |
| | |
| | | * æ ¹æ®åå
¸ç±»åæ¥è¯¢åå
¸æ°æ®ä¿¡æ¯ |
| | | */ |
| | | @GetMapping(value = "/type/{dictType}") |
| | | public Result dictType(@PathVariable String dictType) |
| | | public AjaxResult dictType(@PathVariable String dictType) |
| | | { |
| | | List<SysDictData> data = dictTypeService.selectDictDataByType(dictType); |
| | | if (StringUtils.isNull(data)) |
| | |
| | | @PreAuthorize("@ss.hasPermi('system:dict:add')") |
| | | @Log(title = "åå
¸æ°æ®", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public Result add(@Validated @RequestBody SysDictData dict) |
| | | public AjaxResult add(@Validated @RequestBody SysDictData dict) |
| | | { |
| | | dict.setCreateBy(getUsername()); |
| | | return toAjax(dictDataService.insertDictData(dict)); |
| | |
| | | @PreAuthorize("@ss.hasPermi('system:dict:edit')") |
| | | @Log(title = "åå
¸æ°æ®", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public Result edit(@Validated @RequestBody SysDictData dict) |
| | | public AjaxResult edit(@Validated @RequestBody SysDictData dict) |
| | | { |
| | | dict.setUpdateBy(getUsername()); |
| | | return toAjax(dictDataService.updateDictData(dict)); |
| | |
| | | @PreAuthorize("@ss.hasPermi('system:dict:remove')") |
| | | @Log(title = "åå
¸ç±»å", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{dictCodes}") |
| | | public Result remove(@PathVariable Long[] dictCodes) |
| | | public AjaxResult remove(@PathVariable Long[] dictCodes) |
| | | { |
| | | dictDataService.deleteDictDataByIds(dictCodes); |
| | | return success(); |
| | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.Result; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.entity.SysDictType; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:dict:query')") |
| | | @GetMapping(value = "/{dictId}") |
| | | public Result getInfo(@PathVariable Long dictId) |
| | | public AjaxResult getInfo(@PathVariable Long dictId) |
| | | { |
| | | return success(dictTypeService.selectDictTypeById(dictId)); |
| | | } |
| | |
| | | @PreAuthorize("@ss.hasPermi('system:dict:add')") |
| | | @Log(title = "åå
¸ç±»å", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public Result add(@Validated @RequestBody SysDictType dict) |
| | | public AjaxResult add(@Validated @RequestBody SysDictType dict) |
| | | { |
| | | if (!dictTypeService.checkDictTypeUnique(dict)) |
| | | { |
| | |
| | | @PreAuthorize("@ss.hasPermi('system:dict:edit')") |
| | | @Log(title = "åå
¸ç±»å", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public Result edit(@Validated @RequestBody SysDictType dict) |
| | | public AjaxResult edit(@Validated @RequestBody SysDictType dict) |
| | | { |
| | | if (!dictTypeService.checkDictTypeUnique(dict)) |
| | | { |
| | |
| | | @PreAuthorize("@ss.hasPermi('system:dict:remove')") |
| | | @Log(title = "åå
¸ç±»å", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{dictIds}") |
| | | public Result remove(@PathVariable Long[] dictIds) |
| | | public AjaxResult remove(@PathVariable Long[] dictIds) |
| | | { |
| | | dictTypeService.deleteDictTypeByIds(dictIds); |
| | | return success(); |
| | |
| | | @PreAuthorize("@ss.hasPermi('system:dict:remove')") |
| | | @Log(title = "åå
¸ç±»å", businessType = BusinessType.CLEAN) |
| | | @DeleteMapping("/refreshCache") |
| | | public Result refreshCache() |
| | | public AjaxResult refreshCache() |
| | | { |
| | | dictTypeService.resetDictCache(); |
| | | return success(); |
| | |
| | | * è·ååå
¸éæ©æ¡å表 |
| | | */ |
| | | @GetMapping("/optionselect") |
| | | public Result optionselect() |
| | | public AjaxResult optionselect() |
| | | { |
| | | List<SysDictType> dictTypes = dictTypeService.selectDictTypeAll(); |
| | | return success(dictTypes); |
| | |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import com.ruoyi.common.constant.Constants; |
| | | import com.ruoyi.common.core.domain.Result; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.entity.SysMenu; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.core.domain.model.LoginBody; |
| | |
| | | * @return ç»æ |
| | | */ |
| | | @PostMapping("/login") |
| | | public Result login(@RequestBody LoginBody loginBody) |
| | | public AjaxResult login(@RequestBody LoginBody loginBody) |
| | | { |
| | | Result ajax = Result.success(); |
| | | AjaxResult ajax = AjaxResult.success(); |
| | | // çæä»¤ç |
| | | String token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(), |
| | | loginBody.getUuid()); |
| | |
| | | * @return ç¨æ·ä¿¡æ¯ |
| | | */ |
| | | @GetMapping("getInfo") |
| | | public Result getInfo() |
| | | public AjaxResult getInfo() |
| | | { |
| | | LoginUser loginUser = SecurityUtils.getLoginUser(); |
| | | SysUser user = loginUser.getUser(); |
| | |
| | | loginUser.setPermissions(permissions); |
| | | tokenService.refreshToken(loginUser); |
| | | } |
| | | Result ajax = Result.success(); |
| | | AjaxResult ajax = AjaxResult.success(); |
| | | ajax.put("user", user); |
| | | ajax.put("roles", roles); |
| | | ajax.put("permissions", permissions); |
| | |
| | | * @return è·¯ç±ä¿¡æ¯ |
| | | */ |
| | | @GetMapping("getRouters") |
| | | public Result getRouters() |
| | | public AjaxResult getRouters() |
| | | { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | List<SysMenu> menus = menuService.selectMenuTreeByUserId(userId); |
| | | return Result.success(menuService.buildMenus(menus)); |
| | | return AjaxResult.success(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.Result; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.entity.SysMenu; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:menu:list')") |
| | | @GetMapping("/list") |
| | | public Result list(SysMenu menu) |
| | | public AjaxResult list(SysMenu menu) |
| | | { |
| | | List<SysMenu> menus = menuService.selectMenuList(menu, getUserId()); |
| | | return success(menus); |
| | |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:menu:query')") |
| | | @GetMapping(value = "/{menuId}") |
| | | public Result getInfo(@PathVariable Long menuId) |
| | | public AjaxResult getInfo(@PathVariable Long menuId) |
| | | { |
| | | return success(menuService.selectMenuById(menuId)); |
| | | } |
| | |
| | | * è·åèå䏿æ å表 |
| | | */ |
| | | @GetMapping("/treeselect") |
| | | public Result treeselect(SysMenu menu) |
| | | public AjaxResult treeselect(SysMenu menu) |
| | | { |
| | | List<SysMenu> menus = menuService.selectMenuList(menu, getUserId()); |
| | | return success(menuService.buildMenuTreeSelect(menus)); |
| | |
| | | * å 载对åºè§è²èåå表æ |
| | | */ |
| | | @GetMapping(value = "/roleMenuTreeselect/{roleId}") |
| | | public Result roleMenuTreeselect(@PathVariable("roleId") Long roleId) |
| | | public AjaxResult roleMenuTreeselect(@PathVariable("roleId") Long roleId) |
| | | { |
| | | List<SysMenu> menus = menuService.selectMenuList(getUserId()); |
| | | Result ajax = Result.success(); |
| | | AjaxResult ajax = AjaxResult.success(); |
| | | ajax.put("checkedKeys", menuService.selectMenuListByRoleId(roleId)); |
| | | ajax.put("menus", menuService.buildMenuTreeSelect(menus)); |
| | | return ajax; |
| | |
| | | @PreAuthorize("@ss.hasPermi('system:menu:add')") |
| | | @Log(title = "èå管ç", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public Result add(@Validated @RequestBody SysMenu menu) |
| | | public AjaxResult add(@Validated @RequestBody SysMenu menu) |
| | | { |
| | | if (!menuService.checkMenuNameUnique(menu)) |
| | | { |
| | |
| | | @PreAuthorize("@ss.hasPermi('system:menu:edit')") |
| | | @Log(title = "èå管ç", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public Result edit(@Validated @RequestBody SysMenu menu) |
| | | public AjaxResult edit(@Validated @RequestBody SysMenu menu) |
| | | { |
| | | if (!menuService.checkMenuNameUnique(menu)) |
| | | { |
| | |
| | | @PreAuthorize("@ss.hasPermi('system:menu:remove')") |
| | | @Log(title = "èå管ç", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{menuId}") |
| | | public Result remove(@PathVariable("menuId") Long menuId) |
| | | public AjaxResult remove(@PathVariable("menuId") Long menuId) |
| | | { |
| | | if (menuService.hasChildByMenuId(menuId)) |
| | | { |
| | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.Result; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.system.domain.SysNotice; |
| | |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:notice:query')") |
| | | @GetMapping(value = "/{noticeId}") |
| | | public Result getInfo(@PathVariable Long noticeId) |
| | | public AjaxResult getInfo(@PathVariable Long noticeId) |
| | | { |
| | | return success(noticeService.selectNoticeById(noticeId)); |
| | | } |
| | |
| | | @PreAuthorize("@ss.hasPermi('system:notice:add')") |
| | | @Log(title = "éç¥å
Œ", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public Result add(@Validated @RequestBody SysNotice notice) |
| | | public AjaxResult add(@Validated @RequestBody SysNotice notice) |
| | | { |
| | | notice.setCreateBy(getUsername()); |
| | | return toAjax(noticeService.insertNotice(notice)); |
| | |
| | | @PreAuthorize("@ss.hasPermi('system:notice:edit')") |
| | | @Log(title = "éç¥å
Œ", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public Result edit(@Validated @RequestBody SysNotice notice) |
| | | public AjaxResult edit(@Validated @RequestBody SysNotice notice) |
| | | { |
| | | notice.setUpdateBy(getUsername()); |
| | | return toAjax(noticeService.updateNotice(notice)); |
| | |
| | | @PreAuthorize("@ss.hasPermi('system:notice:remove')") |
| | | @Log(title = "éç¥å
Œ", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{noticeIds}") |
| | | public Result remove(@PathVariable Long[] noticeIds) |
| | | public AjaxResult remove(@PathVariable Long[] noticeIds) |
| | | { |
| | | return toAjax(noticeService.deleteNoticeByIds(noticeIds)); |
| | | } |
| | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.Result; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:post:query')") |
| | | @GetMapping(value = "/{postId}") |
| | | public Result getInfo(@PathVariable Long postId) |
| | | public AjaxResult getInfo(@PathVariable Long postId) |
| | | { |
| | | return success(postService.selectPostById(postId)); |
| | | } |
| | |
| | | @PreAuthorize("@ss.hasPermi('system:post:add')") |
| | | @Log(title = "å²ä½ç®¡ç", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public Result add(@Validated @RequestBody SysPost post) |
| | | public AjaxResult add(@Validated @RequestBody SysPost post) |
| | | { |
| | | if (!postService.checkPostNameUnique(post)) |
| | | { |
| | |
| | | @PreAuthorize("@ss.hasPermi('system:post:edit')") |
| | | @Log(title = "å²ä½ç®¡ç", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public Result edit(@Validated @RequestBody SysPost post) |
| | | public AjaxResult edit(@Validated @RequestBody SysPost post) |
| | | { |
| | | if (!postService.checkPostNameUnique(post)) |
| | | { |
| | |
| | | @PreAuthorize("@ss.hasPermi('system:post:remove')") |
| | | @Log(title = "å²ä½ç®¡ç", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{postIds}") |
| | | public Result remove(@PathVariable Long[] postIds) |
| | | public AjaxResult remove(@PathVariable Long[] postIds) |
| | | { |
| | | return toAjax(postService.deletePostByIds(postIds)); |
| | | } |
| | |
| | | * è·åå²ä½éæ©æ¡å表 |
| | | */ |
| | | @GetMapping("/optionselect") |
| | | public Result optionselect() |
| | | public AjaxResult optionselect() |
| | | { |
| | | List<SysPost> posts = postService.selectPostAll(); |
| | | return success(posts); |
| | |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.config.RuoYiConfig; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.Result; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.core.domain.model.LoginUser; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | |
| | | * ä¸ªäººä¿¡æ¯ |
| | | */ |
| | | @GetMapping |
| | | public Result profile() |
| | | public AjaxResult profile() |
| | | { |
| | | LoginUser loginUser = getLoginUser(); |
| | | SysUser user = loginUser.getUser(); |
| | | Result ajax = Result.success(user); |
| | | AjaxResult ajax = AjaxResult.success(user); |
| | | ajax.put("roleGroup", userService.selectUserRoleGroup(loginUser.getUsername())); |
| | | ajax.put("postGroup", userService.selectUserPostGroup(loginUser.getUsername())); |
| | | return ajax; |
| | |
| | | */ |
| | | @Log(title = "个人信æ¯", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public Result updateProfile(@RequestBody SysUser user) |
| | | public AjaxResult updateProfile(@RequestBody SysUser user) |
| | | { |
| | | LoginUser loginUser = getLoginUser(); |
| | | SysUser currentUser = loginUser.getUser(); |
| | |
| | | */ |
| | | @Log(title = "个人信æ¯", businessType = BusinessType.UPDATE) |
| | | @PutMapping("/updatePwd") |
| | | public Result updatePwd(@RequestBody Map<String, String> params) |
| | | public AjaxResult updatePwd(@RequestBody Map<String, String> params) |
| | | { |
| | | String oldPassword = params.get("oldPassword"); |
| | | String newPassword = params.get("newPassword"); |
| | |
| | | */ |
| | | @Log(title = "ç¨æ·å¤´å", businessType = BusinessType.UPDATE) |
| | | @PostMapping("/avatar") |
| | | public Result avatar(@RequestParam("avatarfile") MultipartFile file) throws Exception |
| | | public AjaxResult avatar(@RequestParam("avatarfile") MultipartFile file) throws Exception |
| | | { |
| | | if (!file.isEmpty()) |
| | | { |
| | |
| | | String avatar = FileUploadUtils.upload(RuoYiConfig.getAvatarPath(), file, MimeTypeUtils.IMAGE_EXTENSION); |
| | | if (userService.updateUserAvatar(loginUser.getUsername(), avatar)) |
| | | { |
| | | Result ajax = Result.success(); |
| | | AjaxResult ajax = AjaxResult.success(); |
| | | ajax.put("imgUrl", avatar); |
| | | // æ´æ°ç¼åç¨æ·å¤´å |
| | | loginUser.getUser().setAvatar(avatar); |
| | |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.Result; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.model.RegisterBody; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.framework.web.service.SysRegisterService; |
| | |
| | | private ISysConfigService configService; |
| | | |
| | | @PostMapping("/register") |
| | | public Result register(@RequestBody RegisterBody user) |
| | | public AjaxResult register(@RequestBody RegisterBody user) |
| | | { |
| | | if (!("true".equals(configService.selectConfigByKey("sys.account.registerUser")))) |
| | | { |
| | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.Result; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.entity.SysDept; |
| | | import com.ruoyi.common.core.domain.entity.SysRole; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:role:query')") |
| | | @GetMapping(value = "/{roleId}") |
| | | public Result getInfo(@PathVariable Long roleId) |
| | | public AjaxResult getInfo(@PathVariable Long roleId) |
| | | { |
| | | roleService.checkRoleDataScope(roleId); |
| | | return success(roleService.selectRoleById(roleId)); |
| | |
| | | @PreAuthorize("@ss.hasPermi('system:role:add')") |
| | | @Log(title = "è§è²ç®¡ç", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public Result add(@Validated @RequestBody SysRole role) |
| | | public AjaxResult add(@Validated @RequestBody SysRole role) |
| | | { |
| | | if (!roleService.checkRoleNameUnique(role)) |
| | | { |
| | |
| | | @PreAuthorize("@ss.hasPermi('system:role:edit')") |
| | | @Log(title = "è§è²ç®¡ç", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public Result edit(@Validated @RequestBody SysRole role) |
| | | public AjaxResult edit(@Validated @RequestBody SysRole role) |
| | | { |
| | | roleService.checkRoleAllowed(role); |
| | | roleService.checkRoleDataScope(role.getRoleId()); |
| | |
| | | @PreAuthorize("@ss.hasPermi('system:role:edit')") |
| | | @Log(title = "è§è²ç®¡ç", businessType = BusinessType.UPDATE) |
| | | @PutMapping("/dataScope") |
| | | public Result dataScope(@RequestBody SysRole role) |
| | | public AjaxResult dataScope(@RequestBody SysRole role) |
| | | { |
| | | roleService.checkRoleAllowed(role); |
| | | roleService.checkRoleDataScope(role.getRoleId()); |
| | |
| | | @PreAuthorize("@ss.hasPermi('system:role:edit')") |
| | | @Log(title = "è§è²ç®¡ç", businessType = BusinessType.UPDATE) |
| | | @PutMapping("/changeStatus") |
| | | public Result changeStatus(@RequestBody SysRole role) |
| | | public AjaxResult changeStatus(@RequestBody SysRole role) |
| | | { |
| | | roleService.checkRoleAllowed(role); |
| | | roleService.checkRoleDataScope(role.getRoleId()); |
| | |
| | | @PreAuthorize("@ss.hasPermi('system:role:remove')") |
| | | @Log(title = "è§è²ç®¡ç", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{roleIds}") |
| | | public Result remove(@PathVariable Long[] roleIds) |
| | | public AjaxResult remove(@PathVariable Long[] roleIds) |
| | | { |
| | | return toAjax(roleService.deleteRoleByIds(roleIds)); |
| | | } |
| | |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:role:query')") |
| | | @GetMapping("/optionselect") |
| | | public Result optionselect() |
| | | public AjaxResult optionselect() |
| | | { |
| | | return success(roleService.selectRoleAll()); |
| | | } |
| | |
| | | @PreAuthorize("@ss.hasPermi('system:role:edit')") |
| | | @Log(title = "è§è²ç®¡ç", businessType = BusinessType.GRANT) |
| | | @PutMapping("/authUser/cancel") |
| | | public Result cancelAuthUser(@RequestBody SysUserRole userRole) |
| | | public AjaxResult cancelAuthUser(@RequestBody SysUserRole userRole) |
| | | { |
| | | return toAjax(roleService.deleteAuthUser(userRole)); |
| | | } |
| | |
| | | @PreAuthorize("@ss.hasPermi('system:role:edit')") |
| | | @Log(title = "è§è²ç®¡ç", businessType = BusinessType.GRANT) |
| | | @PutMapping("/authUser/cancelAll") |
| | | public Result cancelAuthUserAll(Long roleId, Long[] userIds) |
| | | public AjaxResult cancelAuthUserAll(Long roleId, Long[] userIds) |
| | | { |
| | | return toAjax(roleService.deleteAuthUsers(roleId, userIds)); |
| | | } |
| | |
| | | @PreAuthorize("@ss.hasPermi('system:role:edit')") |
| | | @Log(title = "è§è²ç®¡ç", businessType = BusinessType.GRANT) |
| | | @PutMapping("/authUser/selectAll") |
| | | public Result selectAuthUserAll(Long roleId, Long[] userIds) |
| | | public AjaxResult selectAuthUserAll(Long roleId, Long[] userIds) |
| | | { |
| | | roleService.checkRoleDataScope(roleId); |
| | | return toAjax(roleService.insertAuthUsers(roleId, userIds)); |
| | |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:role:query')") |
| | | @GetMapping(value = "/deptTree/{roleId}") |
| | | public Result deptTree(@PathVariable("roleId") Long roleId) |
| | | public AjaxResult deptTree(@PathVariable("roleId") Long roleId) |
| | | { |
| | | Result ajax = Result.success(); |
| | | AjaxResult ajax = AjaxResult.success(); |
| | | ajax.put("checkedKeys", deptService.selectDeptListByRoleId(roleId)); |
| | | ajax.put("depts", deptService.selectDeptTreeList(new SysDept())); |
| | | return ajax; |
| | |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.Result; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.entity.SysDept; |
| | | import com.ruoyi.common.core.domain.entity.SysRole; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | |
| | | @Log(title = "ç¨æ·ç®¡ç", businessType = BusinessType.IMPORT) |
| | | @PreAuthorize("@ss.hasPermi('system:user:import')") |
| | | @PostMapping("/importData") |
| | | public Result importData(MultipartFile file, boolean updateSupport) throws Exception |
| | | public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception |
| | | { |
| | | ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class); |
| | | List<SysUser> userList = util.importExcel(file.getInputStream()); |
| | |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:user:query')") |
| | | @GetMapping(value = { "/", "/{userId}" }) |
| | | public Result getInfo(@PathVariable(value = "userId", required = false) Long userId) |
| | | public AjaxResult getInfo(@PathVariable(value = "userId", required = false) Long userId) |
| | | { |
| | | Result ajax = Result.success(); |
| | | AjaxResult ajax = AjaxResult.success(); |
| | | if (StringUtils.isNotNull(userId)) |
| | | { |
| | | userService.checkUserDataScope(userId); |
| | | SysUser sysUser = userService.selectUserById(userId); |
| | | ajax.put(Result.DATA_TAG, sysUser); |
| | | ajax.put(AjaxResult.DATA_TAG, sysUser); |
| | | ajax.put("postIds", postService.selectPostListByUserId(userId)); |
| | | ajax.put("roleIds", sysUser.getRoles().stream().map(SysRole::getRoleId).collect(Collectors.toList())); |
| | | } |
| | |
| | | @PreAuthorize("@ss.hasPermi('system:user:add')") |
| | | @Log(title = "ç¨æ·ç®¡ç", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public Result add(@Validated @RequestBody SysUser user) |
| | | public AjaxResult add(@Validated @RequestBody SysUser user) |
| | | { |
| | | deptService.checkDeptDataScope(user.getDeptId()); |
| | | roleService.checkRoleDataScope(user.getRoleIds()); |
| | |
| | | @PreAuthorize("@ss.hasPermi('system:user:edit')") |
| | | @Log(title = "ç¨æ·ç®¡ç", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public Result edit(@Validated @RequestBody SysUser user) |
| | | public AjaxResult edit(@Validated @RequestBody SysUser user) |
| | | { |
| | | userService.checkUserAllowed(user); |
| | | userService.checkUserDataScope(user.getUserId()); |
| | |
| | | @PreAuthorize("@ss.hasPermi('system:user:remove')") |
| | | @Log(title = "ç¨æ·ç®¡ç", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{userIds}") |
| | | public Result remove(@PathVariable Long[] userIds) |
| | | public AjaxResult remove(@PathVariable Long[] userIds) |
| | | { |
| | | if (ArrayUtils.contains(userIds, getUserId())) |
| | | { |
| | |
| | | @PreAuthorize("@ss.hasPermi('system:user:resetPwd')") |
| | | @Log(title = "ç¨æ·ç®¡ç", businessType = BusinessType.UPDATE) |
| | | @PutMapping("/resetPwd") |
| | | public Result resetPwd(@RequestBody SysUser user) |
| | | public AjaxResult resetPwd(@RequestBody SysUser user) |
| | | { |
| | | userService.checkUserAllowed(user); |
| | | userService.checkUserDataScope(user.getUserId()); |
| | |
| | | @PreAuthorize("@ss.hasPermi('system:user:edit')") |
| | | @Log(title = "ç¨æ·ç®¡ç", businessType = BusinessType.UPDATE) |
| | | @PutMapping("/changeStatus") |
| | | public Result changeStatus(@RequestBody SysUser user) |
| | | public AjaxResult changeStatus(@RequestBody SysUser user) |
| | | { |
| | | userService.checkUserAllowed(user); |
| | | userService.checkUserDataScope(user.getUserId()); |
| | |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:user:query')") |
| | | @GetMapping("/authRole/{userId}") |
| | | public Result authRole(@PathVariable("userId") Long userId) |
| | | public AjaxResult authRole(@PathVariable("userId") Long userId) |
| | | { |
| | | Result ajax = Result.success(); |
| | | AjaxResult ajax = AjaxResult.success(); |
| | | SysUser user = userService.selectUserById(userId); |
| | | List<SysRole> roles = roleService.selectRolesByUserId(userId); |
| | | ajax.put("user", user); |
| | |
| | | @PreAuthorize("@ss.hasPermi('system:user:edit')") |
| | | @Log(title = "ç¨æ·ç®¡ç", businessType = BusinessType.GRANT) |
| | | @PutMapping("/authRole") |
| | | public Result insertAuthRole(Long userId, Long[] roleIds) |
| | | public AjaxResult insertAuthRole(Long userId, Long[] roleIds) |
| | | { |
| | | userService.checkUserDataScope(userId); |
| | | roleService.checkRoleDataScope(roleIds); |
| | |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:user:list')") |
| | | @GetMapping("/deptTree") |
| | | public Result deptTree(SysDept dept) |
| | | public AjaxResult deptTree(SysDept dept) |
| | | { |
| | | return success(deptService.selectDeptTreeList(dept)); |
| | | } |
| | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.domain.Result; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | |
| | | |
| | | /** |
| | | * swagger ç¨æ·æµè¯æ¹æ³ |
| | | * |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Api("ç¨æ·ä¿¡æ¯ç®¡ç") |
| | |
| | | |
| | | @ApiOperation("è·åç¨æ·å表") |
| | | @GetMapping("/list") |
| | | public R<List<UserEntity>> userList() |
| | | public Result<List<UserEntity>> userList() |
| | | { |
| | | List<UserEntity> userList = new ArrayList<UserEntity>(users.values()); |
| | | return R.ok(userList); |
| | | return Result.success(userList); |
| | | } |
| | | |
| | | @ApiOperation("è·åç¨æ·è¯¦ç»") |
| | | @ApiImplicitParam(name = "userId", value = "ç¨æ·ID", required = true, dataType = "int", paramType = "path", dataTypeClass = Integer.class) |
| | | @GetMapping("/{userId}") |
| | | public R<UserEntity> getUser(@PathVariable Integer userId) |
| | | public Result<UserEntity> getUser(@PathVariable Integer userId) |
| | | { |
| | | if (!users.isEmpty() && users.containsKey(userId)) |
| | | { |
| | | return R.ok(users.get(userId)); |
| | | return Result.success(users.get(userId)); |
| | | } |
| | | else |
| | | { |
| | | return R.fail("ç¨æ·ä¸åå¨"); |
| | | return Result.fail("ç¨æ·ä¸åå¨"); |
| | | } |
| | | } |
| | | |
| | |
| | | @ApiImplicitParam(name = "mobile", value = "ç¨æ·ææº", dataType = "String", dataTypeClass = String.class) |
| | | }) |
| | | @PostMapping("/save") |
| | | public R<String> save(UserEntity user) |
| | | public Result<String> save(UserEntity user) |
| | | { |
| | | if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId())) |
| | | { |
| | | return R.fail("ç¨æ·IDä¸è½ä¸ºç©º"); |
| | | return Result.fail("ç¨æ·IDä¸è½ä¸ºç©º"); |
| | | } |
| | | users.put(user.getUserId(), user); |
| | | return R.ok(); |
| | | return Result.success(); |
| | | } |
| | | |
| | | @ApiOperation("æ´æ°ç¨æ·") |
| | | @PutMapping("/update") |
| | | public R<String> update(@RequestBody UserEntity user) |
| | | public Result<String> update(@RequestBody UserEntity user) |
| | | { |
| | | if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId())) |
| | | { |
| | | return R.fail("ç¨æ·IDä¸è½ä¸ºç©º"); |
| | | return Result.fail("ç¨æ·IDä¸è½ä¸ºç©º"); |
| | | } |
| | | if (users.isEmpty() || !users.containsKey(user.getUserId())) |
| | | { |
| | | return R.fail("ç¨æ·ä¸åå¨"); |
| | | return Result.fail("ç¨æ·ä¸åå¨"); |
| | | } |
| | | users.remove(user.getUserId()); |
| | | users.put(user.getUserId(), user); |
| | | return R.ok(); |
| | | return Result.success(); |
| | | } |
| | | |
| | | @ApiOperation("å é¤ç¨æ·ä¿¡æ¯") |
| | | @ApiImplicitParam(name = "userId", value = "ç¨æ·ID", required = true, dataType = "int", paramType = "path", dataTypeClass = Integer.class) |
| | | @DeleteMapping("/{userId}") |
| | | public R<String> delete(@PathVariable Integer userId) |
| | | public Result<String> delete(@PathVariable Integer userId) |
| | | { |
| | | if (!users.isEmpty() && users.containsKey(userId)) |
| | | { |
| | | users.remove(userId); |
| | | return R.ok(); |
| | | return Result.success(); |
| | | } |
| | | else |
| | | { |
| | | return R.fail("ç¨æ·ä¸åå¨"); |
| | | return Result.fail("ç¨æ·ä¸åå¨"); |
| | | } |
| | | } |
| | | } |
| | |
| | | import com.github.pagehelper.PageHelper; |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.ruoyi.common.constant.HttpStatus; |
| | | import com.ruoyi.common.core.domain.Result; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.model.LoginUser; |
| | | import com.ruoyi.common.core.page.PageDomain; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | |
| | | /** |
| | | * è¿åæå |
| | | */ |
| | | public Result success() |
| | | public AjaxResult success() |
| | | { |
| | | return Result.success(); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | /** |
| | | * è¿åå¤±è´¥æ¶æ¯ |
| | | */ |
| | | public Result error() |
| | | public AjaxResult error() |
| | | { |
| | | return Result.error(); |
| | | return AjaxResult.error(); |
| | | } |
| | | |
| | | /** |
| | | * è¿åæåæ¶æ¯ |
| | | */ |
| | | public Result success(String message) |
| | | public AjaxResult success(String message) |
| | | { |
| | | return Result.success(message); |
| | | return AjaxResult.success(message); |
| | | } |
| | | |
| | | /** |
| | | * è¿åæåæ¶æ¯ |
| | | */ |
| | | public Result success(Object data) |
| | | public AjaxResult success(Object data) |
| | | { |
| | | return Result.success(data); |
| | | return AjaxResult.success(data); |
| | | } |
| | | |
| | | /** |
| | | * è¿åå¤±è´¥æ¶æ¯ |
| | | */ |
| | | public Result error(String message) |
| | | public AjaxResult error(String message) |
| | | { |
| | | return Result.error(message); |
| | | return AjaxResult.error(message); |
| | | } |
| | | |
| | | /** |
| | | * è¿åè¦åæ¶æ¯ |
| | | */ |
| | | public Result warn(String message) |
| | | public AjaxResult warn(String message) |
| | | { |
| | | return Result.warn(message); |
| | | return AjaxResult.warn(message); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @param rows å½±åè¡æ° |
| | | * @return æä½ç»æ |
| | | */ |
| | | protected Result toAjax(int rows) |
| | | protected AjaxResult toAjax(int rows) |
| | | { |
| | | return rows > 0 ? Result.success() : Result.error(); |
| | | return rows > 0 ? AjaxResult.success() : AjaxResult.error(); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @param result ç»æ |
| | | * @return æä½ç»æ |
| | | */ |
| | | protected Result toAjax(boolean result) |
| | | protected AjaxResult toAjax(boolean result) |
| | | { |
| | | return result ? success() : error(); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.common.core.domain; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Objects; |
| | | import com.ruoyi.common.constant.HttpStatus; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | |
| | | /** |
| | | * æä½æ¶æ¯æé |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class AjaxResult extends HashMap<String, Object> |
| | | { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** ç¶æç */ |
| | | public static final String CODE_TAG = "code"; |
| | | |
| | | /** è¿åå
容 */ |
| | | public static final String MSG_TAG = "msg"; |
| | | |
| | | /** æ°æ®å¯¹è±¡ */ |
| | | public static final String DATA_TAG = "data"; |
| | | |
| | | /** |
| | | * åå§åä¸ä¸ªæ°å建ç AjaxResult 对象ï¼ä½¿å
¶è¡¨ç¤ºä¸ä¸ªç©ºæ¶æ¯ã |
| | | */ |
| | | public AjaxResult() |
| | | { |
| | | } |
| | | |
| | | /** |
| | | * åå§åä¸ä¸ªæ°å建ç AjaxResult 对象 |
| | | * |
| | | * @param code ç¶æç |
| | | * @param msg è¿åå
容 |
| | | */ |
| | | public AjaxResult(int code, String msg) |
| | | { |
| | | super.put(CODE_TAG, code); |
| | | super.put(MSG_TAG, msg); |
| | | } |
| | | |
| | | /** |
| | | * åå§åä¸ä¸ªæ°å建ç AjaxResult 对象 |
| | | * |
| | | * @param code ç¶æç |
| | | * @param msg è¿åå
容 |
| | | * @param data æ°æ®å¯¹è±¡ |
| | | */ |
| | | public AjaxResult(int code, String msg, Object data) |
| | | { |
| | | super.put(CODE_TAG, code); |
| | | super.put(MSG_TAG, msg); |
| | | if (StringUtils.isNotNull(data)) |
| | | { |
| | | super.put(DATA_TAG, data); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * è¿åæåæ¶æ¯ |
| | | * |
| | | * @return æåæ¶æ¯ |
| | | */ |
| | | public static AjaxResult success() |
| | | { |
| | | return AjaxResult.success("æä½æå"); |
| | | } |
| | | |
| | | /** |
| | | * è¿åæåæ°æ® |
| | | * |
| | | * @return æåæ¶æ¯ |
| | | */ |
| | | public static AjaxResult success(Object data) |
| | | { |
| | | return AjaxResult.success("æä½æå", data); |
| | | } |
| | | |
| | | /** |
| | | * è¿åæåæ¶æ¯ |
| | | * |
| | | * @param msg è¿åå
容 |
| | | * @return æåæ¶æ¯ |
| | | */ |
| | | public static AjaxResult success(String msg) |
| | | { |
| | | return AjaxResult.success(msg, null); |
| | | } |
| | | |
| | | /** |
| | | * è¿åæåæ¶æ¯ |
| | | * |
| | | * @param msg è¿åå
容 |
| | | * @param data æ°æ®å¯¹è±¡ |
| | | * @return æåæ¶æ¯ |
| | | */ |
| | | public static AjaxResult success(String msg, Object data) |
| | | { |
| | | return new AjaxResult(HttpStatus.SUCCESS, msg, data); |
| | | } |
| | | |
| | | /** |
| | | * è¿åè¦åæ¶æ¯ |
| | | * |
| | | * @param msg è¿åå
容 |
| | | * @return è¦åæ¶æ¯ |
| | | */ |
| | | public static AjaxResult warn(String msg) |
| | | { |
| | | return AjaxResult.warn(msg, null); |
| | | } |
| | | |
| | | /** |
| | | * è¿åè¦åæ¶æ¯ |
| | | * |
| | | * @param msg è¿åå
容 |
| | | * @param data æ°æ®å¯¹è±¡ |
| | | * @return è¦åæ¶æ¯ |
| | | */ |
| | | public static AjaxResult warn(String msg, Object data) |
| | | { |
| | | return new AjaxResult(HttpStatus.WARN, msg, data); |
| | | } |
| | | |
| | | /** |
| | | * è¿åéè¯¯æ¶æ¯ |
| | | * |
| | | * @return éè¯¯æ¶æ¯ |
| | | */ |
| | | public static AjaxResult error() |
| | | { |
| | | return AjaxResult.error("æä½å¤±è´¥"); |
| | | } |
| | | |
| | | /** |
| | | * è¿åéè¯¯æ¶æ¯ |
| | | * |
| | | * @param msg è¿åå
容 |
| | | * @return éè¯¯æ¶æ¯ |
| | | */ |
| | | public static AjaxResult error(String msg) |
| | | { |
| | | return AjaxResult.error(msg, null); |
| | | } |
| | | |
| | | /** |
| | | * è¿åéè¯¯æ¶æ¯ |
| | | * |
| | | * @param msg è¿åå
容 |
| | | * @param data æ°æ®å¯¹è±¡ |
| | | * @return éè¯¯æ¶æ¯ |
| | | */ |
| | | public static AjaxResult error(String msg, Object data) |
| | | { |
| | | return new AjaxResult(HttpStatus.ERROR, msg, data); |
| | | } |
| | | |
| | | /** |
| | | * è¿åéè¯¯æ¶æ¯ |
| | | * |
| | | * @param code ç¶æç |
| | | * @param msg è¿åå
容 |
| | | * @return éè¯¯æ¶æ¯ |
| | | */ |
| | | public static AjaxResult error(int code, String msg) |
| | | { |
| | | return new AjaxResult(code, msg, null); |
| | | } |
| | | |
| | | /** |
| | | * æ¯å¦ä¸ºæåæ¶æ¯ |
| | | * |
| | | * @return ç»æ |
| | | */ |
| | | public boolean isSuccess() |
| | | { |
| | | return Objects.equals(HttpStatus.SUCCESS, this.get(CODE_TAG)); |
| | | } |
| | | |
| | | /** |
| | | * æ¯å¦ä¸ºè¦åæ¶æ¯ |
| | | * |
| | | * @return ç»æ |
| | | */ |
| | | public boolean isWarn() |
| | | { |
| | | return Objects.equals(HttpStatus.WARN, this.get(CODE_TAG)); |
| | | } |
| | | |
| | | /** |
| | | * æ¯å¦ä¸ºéè¯¯æ¶æ¯ |
| | | * |
| | | * @return ç»æ |
| | | */ |
| | | public boolean isError() |
| | | { |
| | | return Objects.equals(HttpStatus.ERROR, this.get(CODE_TAG)); |
| | | } |
| | | |
| | | /** |
| | | * æ¹ä¾¿é¾å¼è°ç¨ |
| | | * |
| | | * @param key é® |
| | | * @param value å¼ |
| | | * @return æ°æ®å¯¹è±¡ |
| | | */ |
| | | @Override |
| | | public AjaxResult put(String key, Object value) |
| | | { |
| | | super.put(key, value); |
| | | return this; |
| | | } |
| | | } |
| | |
| | | package com.ruoyi.common.core.domain; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Objects; |
| | | import java.io.Serializable; |
| | | import com.ruoyi.common.constant.HttpStatus; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | |
| | | /** |
| | | * æä½æ¶æ¯æé |
| | | * ååºä¿¡æ¯ä¸»ä½ |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class Result extends HashMap<String, Object> |
| | | public class Result<T> implements Serializable |
| | | { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** ç¶æç */ |
| | | public static final String CODE_TAG = "code"; |
| | | /** æå */ |
| | | public static final int SUCCESS = HttpStatus.SUCCESS; |
| | | |
| | | /** è¿åå
容 */ |
| | | public static final String MSG_TAG = "msg"; |
| | | /** 失败 */ |
| | | public static final int FAIL = HttpStatus.ERROR; |
| | | |
| | | /** æ°æ®å¯¹è±¡ */ |
| | | public static final String DATA_TAG = "data"; |
| | | private int code; |
| | | |
| | | /** |
| | | * åå§åä¸ä¸ªæ°å建ç AjaxResult 对象ï¼ä½¿å
¶è¡¨ç¤ºä¸ä¸ªç©ºæ¶æ¯ã |
| | | */ |
| | | public Result() |
| | | private String msg; |
| | | |
| | | private T data; |
| | | |
| | | public static <T> Result<T> success() |
| | | { |
| | | return restResult(null, SUCCESS, "æä½æå"); |
| | | } |
| | | |
| | | /** |
| | | * åå§åä¸ä¸ªæ°å建ç AjaxResult 对象 |
| | | * |
| | | * @param code ç¶æç |
| | | * @param msg è¿åå
容 |
| | | */ |
| | | public Result(int code, String msg) |
| | | public static <T> Result<T> success(T data) |
| | | { |
| | | super.put(CODE_TAG, code); |
| | | super.put(MSG_TAG, msg); |
| | | return restResult(data, SUCCESS, "æä½æå"); |
| | | } |
| | | |
| | | /** |
| | | * åå§åä¸ä¸ªæ°å建ç AjaxResult 对象 |
| | | * |
| | | * @param code ç¶æç |
| | | * @param msg è¿åå
容 |
| | | * @param data æ°æ®å¯¹è±¡ |
| | | */ |
| | | public Result(int code, String msg, Object data) |
| | | public static <T> Result<T> success(T data, String msg) |
| | | { |
| | | super.put(CODE_TAG, code); |
| | | super.put(MSG_TAG, msg); |
| | | if (StringUtils.isNotNull(data)) |
| | | { |
| | | super.put(DATA_TAG, data); |
| | | } |
| | | return restResult(data, SUCCESS, msg); |
| | | } |
| | | |
| | | /** |
| | | * è¿åæåæ¶æ¯ |
| | | * |
| | | * @return æåæ¶æ¯ |
| | | */ |
| | | public static Result success() |
| | | public static <T> Result<T> fail() |
| | | { |
| | | return Result.success("æä½æå"); |
| | | return restResult(null, FAIL, "æä½å¤±è´¥"); |
| | | } |
| | | |
| | | /** |
| | | * è¿åæåæ°æ® |
| | | * |
| | | * @return æåæ¶æ¯ |
| | | */ |
| | | public static Result success(Object data) |
| | | public static <T> Result<T> fail(String msg) |
| | | { |
| | | return Result.success("æä½æå", data); |
| | | return restResult(null, FAIL, msg); |
| | | } |
| | | |
| | | /** |
| | | * è¿åæåæ¶æ¯ |
| | | * |
| | | * @param msg è¿åå
容 |
| | | * @return æåæ¶æ¯ |
| | | */ |
| | | public static Result success(String msg) |
| | | public static <T> Result<T> fail(T data) |
| | | { |
| | | return Result.success(msg, null); |
| | | return restResult(data, FAIL, "æä½å¤±è´¥"); |
| | | } |
| | | |
| | | /** |
| | | * è¿åæåæ¶æ¯ |
| | | * |
| | | * @param msg è¿åå
容 |
| | | * @param data æ°æ®å¯¹è±¡ |
| | | * @return æåæ¶æ¯ |
| | | */ |
| | | public static Result success(String msg, Object data) |
| | | public static <T> Result<T> fail(T data, String msg) |
| | | { |
| | | return new Result(HttpStatus.SUCCESS, msg, data); |
| | | return restResult(data, FAIL, msg); |
| | | } |
| | | |
| | | /** |
| | | * è¿åè¦åæ¶æ¯ |
| | | * |
| | | * @param msg è¿åå
容 |
| | | * @return è¦åæ¶æ¯ |
| | | */ |
| | | public static Result warn(String msg) |
| | | public static <T> Result<T> fail(int code, String msg) |
| | | { |
| | | return Result.warn(msg, null); |
| | | return restResult(null, code, msg); |
| | | } |
| | | |
| | | /** |
| | | * è¿åè¦åæ¶æ¯ |
| | | * |
| | | * @param msg è¿åå
容 |
| | | * @param data æ°æ®å¯¹è±¡ |
| | | * @return è¦åæ¶æ¯ |
| | | */ |
| | | public static Result warn(String msg, Object data) |
| | | private static <T> Result<T> restResult(T data, int code, String msg) |
| | | { |
| | | return new Result(HttpStatus.WARN, msg, data); |
| | | Result<T> apiResult = new Result<>(); |
| | | apiResult.setCode(code); |
| | | apiResult.setData(data); |
| | | apiResult.setMsg(msg); |
| | | return apiResult; |
| | | } |
| | | |
| | | /** |
| | | * è¿åéè¯¯æ¶æ¯ |
| | | * |
| | | * @return éè¯¯æ¶æ¯ |
| | | */ |
| | | public static Result error() |
| | | public int getCode() |
| | | { |
| | | return Result.error("æä½å¤±è´¥"); |
| | | return code; |
| | | } |
| | | |
| | | /** |
| | | * è¿åéè¯¯æ¶æ¯ |
| | | * |
| | | * @param msg è¿åå
容 |
| | | * @return éè¯¯æ¶æ¯ |
| | | */ |
| | | public static Result error(String msg) |
| | | public void setCode(int code) |
| | | { |
| | | return Result.error(msg, null); |
| | | this.code = code; |
| | | } |
| | | |
| | | /** |
| | | * è¿åéè¯¯æ¶æ¯ |
| | | * |
| | | * @param msg è¿åå
容 |
| | | * @param data æ°æ®å¯¹è±¡ |
| | | * @return éè¯¯æ¶æ¯ |
| | | */ |
| | | public static Result error(String msg, Object data) |
| | | public String getMsg() |
| | | { |
| | | return new Result(HttpStatus.ERROR, msg, data); |
| | | return msg; |
| | | } |
| | | |
| | | /** |
| | | * è¿åéè¯¯æ¶æ¯ |
| | | * |
| | | * @param code ç¶æç |
| | | * @param msg è¿åå
容 |
| | | * @return éè¯¯æ¶æ¯ |
| | | */ |
| | | public static Result error(int code, String msg) |
| | | public void setMsg(String msg) |
| | | { |
| | | return new Result(code, msg, null); |
| | | this.msg = msg; |
| | | } |
| | | |
| | | /** |
| | | * æ¯å¦ä¸ºæåæ¶æ¯ |
| | | * |
| | | * @return ç»æ |
| | | */ |
| | | public boolean isSuccess() |
| | | public T getData() |
| | | { |
| | | return Objects.equals(HttpStatus.SUCCESS, this.get(CODE_TAG)); |
| | | return data; |
| | | } |
| | | |
| | | /** |
| | | * æ¯å¦ä¸ºè¦åæ¶æ¯ |
| | | * |
| | | * @return ç»æ |
| | | */ |
| | | public boolean isWarn() |
| | | public void setData(T data) |
| | | { |
| | | return Objects.equals(HttpStatus.WARN, this.get(CODE_TAG)); |
| | | this.data = data; |
| | | } |
| | | |
| | | /** |
| | | * æ¯å¦ä¸ºéè¯¯æ¶æ¯ |
| | | * |
| | | * @return ç»æ |
| | | */ |
| | | public boolean isError() |
| | | public static <T> Boolean isError(Result<T> ret) |
| | | { |
| | | return Objects.equals(HttpStatus.ERROR, this.get(CODE_TAG)); |
| | | return !isSuccess(ret); |
| | | } |
| | | |
| | | /** |
| | | * æ¹ä¾¿é¾å¼è°ç¨ |
| | | * |
| | | * @param key é® |
| | | * @param value å¼ |
| | | * @return æ°æ®å¯¹è±¡ |
| | | */ |
| | | @Override |
| | | public Result put(String key, Object value) |
| | | public static <T> Boolean isSuccess(Result<T> ret) |
| | | { |
| | | super.put(key, value); |
| | | return this; |
| | | return Result.SUCCESS == ret.getCode(); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.common.utils; |
| | | |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.lang.reflect.Field; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /* |
| | | * ææ |
| | | * çæSQLè¯å¥*/ |
| | | |
| | | @Component |
| | | @AllArgsConstructor |
| | | public class QueryWrappers<T> { |
| | | |
| | | public static <T> QueryWrapper<T> queryWrappers(T entity) { |
| | | if (ObjectUtil.isEmpty(entity)) return null; |
| | | Class<?> aClass = entity.getClass(); |
| | | QueryWrapper<T> wrapper = Wrappers.<T>query(); |
| | | List<Field> fieldList = new ArrayList<>(); |
| | | while (aClass != null) { |
| | | fieldList.addAll(new ArrayList<>(Arrays.asList(aClass.getDeclaredFields()))); |
| | | aClass = aClass.getSuperclass(); |
| | | } |
| | | for (Field field : fieldList) { |
| | | field.setAccessible(true); |
| | | Object value; |
| | | try { |
| | | value = field.get(entity); |
| | | } catch (IllegalAccessException e) { |
| | | e.printStackTrace(); |
| | | throw new RuntimeException("æ¥è¯¢æ¡ä»¶çæé误"); |
| | | } |
| | | // System.out.println(field.getName() + "|" + (value == null || value.equals("")) + "|" + value); |
| | | if(value == null || value.equals("")){ |
| | | continue; |
| | | } |
| | | /*boolean bool = field.isAnnotationPresent(TableField.class); |
| | | if (bool){ |
| | | if(field.getAnnotation(TableField.class).exist()==false)continue; |
| | | }*/ |
| | | if (!field.getName().equals("orderBy")) { |
| | | if(value.getClass()== LocalDateTime.class){ |
| | | wrapper.like(StrUtil.toUnderlineCase(field.getName()), ((LocalDateTime) value).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))); |
| | | }else{ |
| | | wrapper.like(StrUtil.toUnderlineCase(field.getName()), value); |
| | | } |
| | | } else { |
| | | Map<String, String> map = (Map<String, String>) value; |
| | | if(map.get("order")!=null){ |
| | | wrapper.orderBy(true, map.get("order").equals("asc"), StrUtil.toUnderlineCase(map.get("field"))); |
| | | } |
| | | } |
| | | } |
| | | // System.out.println(wrapper.getExpression().getSqlSegment()); |
| | | return wrapper; |
| | | } |
| | | } |
| | |
| | | import com.ruoyi.common.annotation.Excel.Type; |
| | | import com.ruoyi.common.annotation.Excels; |
| | | import com.ruoyi.common.config.RuoYiConfig; |
| | | import com.ruoyi.common.core.domain.Result; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.text.Convert; |
| | | import com.ruoyi.common.exception.UtilException; |
| | | import com.ruoyi.common.utils.DateUtils; |
| | |
| | | * @param sheetName å·¥ä½è¡¨çåç§° |
| | | * @return ç»æ |
| | | */ |
| | | public Result exportExcel(List<T> list, String sheetName) |
| | | public AjaxResult exportExcel(List<T> list, String sheetName) |
| | | { |
| | | return exportExcel(list, sheetName, StringUtils.EMPTY); |
| | | } |
| | |
| | | * @param title æ é¢ |
| | | * @return ç»æ |
| | | */ |
| | | public Result exportExcel(List<T> list, String sheetName, String title) |
| | | public AjaxResult exportExcel(List<T> list, String sheetName, String title) |
| | | { |
| | | this.init(list, sheetName, title, Type.EXPORT); |
| | | return exportExcel(); |
| | |
| | | * @param sheetName å·¥ä½è¡¨çåç§° |
| | | * @return ç»æ |
| | | */ |
| | | public Result importTemplateExcel(String sheetName) |
| | | public AjaxResult importTemplateExcel(String sheetName) |
| | | { |
| | | return importTemplateExcel(sheetName, StringUtils.EMPTY); |
| | | } |
| | |
| | | * @param title æ é¢ |
| | | * @return ç»æ |
| | | */ |
| | | public Result importTemplateExcel(String sheetName, String title) |
| | | public AjaxResult importTemplateExcel(String sheetName, String title) |
| | | { |
| | | this.init(null, sheetName, title, Type.IMPORT); |
| | | return exportExcel(); |
| | |
| | | * |
| | | * @return ç»æ |
| | | */ |
| | | public Result exportExcel() |
| | | public AjaxResult exportExcel() |
| | | { |
| | | OutputStream out = null; |
| | | try |
| | |
| | | String filename = encodingFilename(sheetName); |
| | | out = new FileOutputStream(getAbsoluteFile(filename)); |
| | | wb.write(out); |
| | | return Result.success(filename); |
| | | return AjaxResult.success(filename); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | import org.springframework.web.servlet.HandlerInterceptor; |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.ruoyi.common.annotation.RepeatSubmit; |
| | | import com.ruoyi.common.core.domain.Result; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.utils.ServletUtils; |
| | | |
| | | /** |
| | |
| | | { |
| | | if (this.isRepeatSubmit(request, annotation)) |
| | | { |
| | | Result ajaxResult = Result.error(annotation.message()); |
| | | AjaxResult ajaxResult = AjaxResult.error(annotation.message()); |
| | | ServletUtils.renderString(response, JSON.toJSONString(ajaxResult)); |
| | | return false; |
| | | } |
| | |
| | | import org.springframework.stereotype.Component; |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.ruoyi.common.constant.HttpStatus; |
| | | import com.ruoyi.common.core.domain.Result; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.utils.ServletUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | |
| | |
| | | { |
| | | int code = HttpStatus.UNAUTHORIZED; |
| | | String msg = StringUtils.format("请æ±è®¿é®ï¼{}ï¼è®¤è¯å¤±è´¥ï¼æ æ³è®¿é®ç³»ç»èµæº", request.getRequestURI()); |
| | | ServletUtils.renderString(response, JSON.toJSONString(Result.error(code, msg))); |
| | | ServletUtils.renderString(response, JSON.toJSONString(AjaxResult.error(code, msg))); |
| | | } |
| | | } |
| | |
| | | import org.springframework.security.web.authentication.logout.LogoutSuccessHandler; |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.ruoyi.common.constant.Constants; |
| | | import com.ruoyi.common.core.domain.Result; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.model.LoginUser; |
| | | import com.ruoyi.common.utils.MessageUtils; |
| | | import com.ruoyi.common.utils.ServletUtils; |
| | |
| | | // è®°å½ç¨æ·éåºæ¥å¿ |
| | | AsyncManager.me().execute(AsyncFactory.recordLogininfor(userName, Constants.LOGOUT, MessageUtils.message("user.logout.success"))); |
| | | } |
| | | ServletUtils.renderString(response, JSON.toJSONString(Result.success(MessageUtils.message("user.logout.success")))); |
| | | ServletUtils.renderString(response, JSON.toJSONString(AjaxResult.success(MessageUtils.message("user.logout.success")))); |
| | | } |
| | | } |
| | |
| | | import org.springframework.web.bind.annotation.RestControllerAdvice; |
| | | import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException; |
| | | import com.ruoyi.common.constant.HttpStatus; |
| | | import com.ruoyi.common.core.domain.Result; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.text.Convert; |
| | | import com.ruoyi.common.exception.DemoModeException; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | |
| | | * æéæ ¡éªå¼å¸¸ |
| | | */ |
| | | @ExceptionHandler(AccessDeniedException.class) |
| | | public Result handleAccessDeniedException(AccessDeniedException e, HttpServletRequest request) |
| | | public AjaxResult handleAccessDeniedException(AccessDeniedException e, HttpServletRequest request) |
| | | { |
| | | String requestURI = request.getRequestURI(); |
| | | log.error("请æ±å°å'{}',æéæ ¡éªå¤±è´¥'{}'", requestURI, e.getMessage()); |
| | | return Result.error(HttpStatus.FORBIDDEN, "没ææéï¼è¯·è系管çåææ"); |
| | | return AjaxResult.error(HttpStatus.FORBIDDEN, "没ææéï¼è¯·è系管çåææ"); |
| | | } |
| | | |
| | | /** |
| | | * è¯·æ±æ¹å¼ä¸æ¯æ |
| | | */ |
| | | @ExceptionHandler(HttpRequestMethodNotSupportedException.class) |
| | | public Result handleHttpRequestMethodNotSupported(HttpRequestMethodNotSupportedException e, |
| | | HttpServletRequest request) |
| | | public AjaxResult handleHttpRequestMethodNotSupported(HttpRequestMethodNotSupportedException e, |
| | | HttpServletRequest request) |
| | | { |
| | | String requestURI = request.getRequestURI(); |
| | | log.error("请æ±å°å'{}',䏿¯æ'{}'请æ±", requestURI, e.getMethod()); |
| | | return Result.error(e.getMessage()); |
| | | return AjaxResult.error(e.getMessage()); |
| | | } |
| | | |
| | | /** |
| | | * ä¸å¡å¼å¸¸ |
| | | */ |
| | | @ExceptionHandler(ServiceException.class) |
| | | public Result handleServiceException(ServiceException e, HttpServletRequest request) |
| | | public AjaxResult handleServiceException(ServiceException e, HttpServletRequest request) |
| | | { |
| | | log.error(e.getMessage(), e); |
| | | Integer code = e.getCode(); |
| | | return StringUtils.isNotNull(code) ? Result.error(code, e.getMessage()) : Result.error(e.getMessage()); |
| | | return StringUtils.isNotNull(code) ? AjaxResult.error(code, e.getMessage()) : AjaxResult.error(e.getMessage()); |
| | | } |
| | | |
| | | /** |
| | | * 请æ±è·¯å¾ä¸ç¼ºå°å¿
éçè·¯å¾åé |
| | | */ |
| | | @ExceptionHandler(MissingPathVariableException.class) |
| | | public Result handleMissingPathVariableException(MissingPathVariableException e, HttpServletRequest request) |
| | | public AjaxResult handleMissingPathVariableException(MissingPathVariableException e, HttpServletRequest request) |
| | | { |
| | | String requestURI = request.getRequestURI(); |
| | | log.error("请æ±è·¯å¾ä¸ç¼ºå°å¿
éçè·¯å¾åé'{}',åçç³»ç»å¼å¸¸.", requestURI, e); |
| | | return Result.error(String.format("请æ±è·¯å¾ä¸ç¼ºå°å¿
éçè·¯å¾åé[%s]", e.getVariableName())); |
| | | return AjaxResult.error(String.format("请æ±è·¯å¾ä¸ç¼ºå°å¿
éçè·¯å¾åé[%s]", e.getVariableName())); |
| | | } |
| | | |
| | | /** |
| | | * 请æ±åæ°ç±»åä¸å¹é
|
| | | */ |
| | | @ExceptionHandler(MethodArgumentTypeMismatchException.class) |
| | | public Result handleMethodArgumentTypeMismatchException(MethodArgumentTypeMismatchException e, HttpServletRequest request) |
| | | public AjaxResult handleMethodArgumentTypeMismatchException(MethodArgumentTypeMismatchException e, HttpServletRequest request) |
| | | { |
| | | String requestURI = request.getRequestURI(); |
| | | String value = Convert.toStr(e.getValue()); |
| | |
| | | value = EscapeUtil.clean(value); |
| | | } |
| | | log.error("请æ±åæ°ç±»åä¸å¹é
'{}',åçç³»ç»å¼å¸¸.", requestURI, e); |
| | | return Result.error(String.format("请æ±åæ°ç±»åä¸å¹é
ï¼åæ°[%s]è¦æ±ç±»å为ï¼'%s'ï¼ä½è¾å
¥å¼ä¸ºï¼'%s'", e.getName(), e.getRequiredType().getName(), value)); |
| | | return AjaxResult.error(String.format("请æ±åæ°ç±»åä¸å¹é
ï¼åæ°[%s]è¦æ±ç±»å为ï¼'%s'ï¼ä½è¾å
¥å¼ä¸ºï¼'%s'", e.getName(), e.getRequiredType().getName(), value)); |
| | | } |
| | | |
| | | /** |
| | | * æ¦æªæªç¥çè¿è¡æ¶å¼å¸¸ |
| | | */ |
| | | @ExceptionHandler(RuntimeException.class) |
| | | public Result handleRuntimeException(RuntimeException e, HttpServletRequest request) |
| | | public AjaxResult handleRuntimeException(RuntimeException e, HttpServletRequest request) |
| | | { |
| | | String requestURI = request.getRequestURI(); |
| | | log.error("请æ±å°å'{}',åçæªç¥å¼å¸¸.", requestURI, e); |
| | | return Result.error(e.getMessage()); |
| | | return AjaxResult.error(e.getMessage()); |
| | | } |
| | | |
| | | /** |
| | | * ç³»ç»å¼å¸¸ |
| | | */ |
| | | @ExceptionHandler(Exception.class) |
| | | public Result handleException(Exception e, HttpServletRequest request) |
| | | public AjaxResult handleException(Exception e, HttpServletRequest request) |
| | | { |
| | | String requestURI = request.getRequestURI(); |
| | | log.error("请æ±å°å'{}',åçç³»ç»å¼å¸¸.", requestURI, e); |
| | | return Result.error(e.getMessage()); |
| | | return AjaxResult.error(e.getMessage()); |
| | | } |
| | | |
| | | /** |
| | | * èªå®ä¹éªè¯å¼å¸¸ |
| | | */ |
| | | @ExceptionHandler(BindException.class) |
| | | public Result handleBindException(BindException e) |
| | | public AjaxResult handleBindException(BindException e) |
| | | { |
| | | log.error(e.getMessage(), e); |
| | | String message = e.getAllErrors().get(0).getDefaultMessage(); |
| | | return Result.error(message); |
| | | return AjaxResult.error(message); |
| | | } |
| | | |
| | | /** |
| | |
| | | { |
| | | log.error(e.getMessage(), e); |
| | | String message = e.getBindingResult().getFieldError().getDefaultMessage(); |
| | | return Result.error(message); |
| | | return AjaxResult.error(message); |
| | | } |
| | | |
| | | /** |
| | | * æ¼ç¤ºæ¨¡å¼å¼å¸¸ |
| | | */ |
| | | @ExceptionHandler(DemoModeException.class) |
| | | public Result handleDemoModeException(DemoModeException e) |
| | | public AjaxResult handleDemoModeException(DemoModeException e) |
| | | { |
| | | return Result.error("æ¼ç¤ºæ¨¡å¼ï¼ä¸å
许æä½"); |
| | | return AjaxResult.error("æ¼ç¤ºæ¨¡å¼ï¼ä¸å
许æä½"); |
| | | } |
| | | } |
| | |
| | | import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlCreateTableStatement; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.Result; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.core.text.Convert; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('tool:gen:query')") |
| | | @GetMapping(value = "/{tableId}") |
| | | public Result getInfo(@PathVariable Long tableId) |
| | | public AjaxResult getInfo(@PathVariable Long tableId) |
| | | { |
| | | GenTable table = genTableService.selectGenTableById(tableId); |
| | | List<GenTable> tables = genTableService.selectGenTableAll(); |
| | |
| | | @PreAuthorize("@ss.hasPermi('tool:gen:import')") |
| | | @Log(title = "代ç çæ", businessType = BusinessType.IMPORT) |
| | | @PostMapping("/importTable") |
| | | public Result importTableSave(String tables) |
| | | public AjaxResult importTableSave(String tables) |
| | | { |
| | | String[] tableNames = Convert.toStrArray(tables); |
| | | // æ¥è¯¢è¡¨ä¿¡æ¯ |
| | |
| | | @PreAuthorize("@ss.hasRole('admin')") |
| | | @Log(title = "å建表", businessType = BusinessType.OTHER) |
| | | @PostMapping("/createTable") |
| | | public Result createTableSave(String sql) |
| | | public AjaxResult createTableSave(String sql) |
| | | { |
| | | try |
| | | { |
| | |
| | | List<GenTable> tableList = genTableService.selectDbTableListByNames(tableNames.toArray(new String[tableNames.size()])); |
| | | String operName = SecurityUtils.getUsername(); |
| | | genTableService.importGenTable(tableList, operName); |
| | | return Result.success(); |
| | | return AjaxResult.success(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | logger.error(e.getMessage(), e); |
| | | return Result.error("åå»ºè¡¨ç»æå¼å¸¸"); |
| | | return AjaxResult.error("åå»ºè¡¨ç»æå¼å¸¸"); |
| | | } |
| | | } |
| | | |
| | |
| | | @PreAuthorize("@ss.hasPermi('tool:gen:edit')") |
| | | @Log(title = "代ç çæ", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public Result editSave(@Validated @RequestBody GenTable genTable) |
| | | public AjaxResult editSave(@Validated @RequestBody GenTable genTable) |
| | | { |
| | | genTableService.validateEdit(genTable); |
| | | genTableService.updateGenTable(genTable); |
| | |
| | | @PreAuthorize("@ss.hasPermi('tool:gen:remove')") |
| | | @Log(title = "代ç çæ", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{tableIds}") |
| | | public Result remove(@PathVariable Long[] tableIds) |
| | | public AjaxResult remove(@PathVariable Long[] tableIds) |
| | | { |
| | | genTableService.deleteGenTableByIds(tableIds); |
| | | return success(); |
| | |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('tool:gen:preview')") |
| | | @GetMapping("/preview/{tableId}") |
| | | public Result preview(@PathVariable("tableId") Long tableId) throws IOException |
| | | public AjaxResult preview(@PathVariable("tableId") Long tableId) throws IOException |
| | | { |
| | | Map<String, String> dataMap = genTableService.previewCode(tableId); |
| | | return success(dataMap); |
| | |
| | | @PreAuthorize("@ss.hasPermi('tool:gen:code')") |
| | | @Log(title = "代ç çæ", businessType = BusinessType.GENCODE) |
| | | @GetMapping("/genCode/{tableName}") |
| | | public Result genCode(@PathVariable("tableName") String tableName) |
| | | public AjaxResult genCode(@PathVariable("tableName") String tableName) |
| | | { |
| | | if (!GenConfig.isAllowOverwrite()) |
| | | { |
| | | return Result.error("ãç³»ç»é¢è®¾ãä¸å
è®¸çææä»¶è¦çå°æ¬å°"); |
| | | return AjaxResult.error("ãç³»ç»é¢è®¾ãä¸å
è®¸çææä»¶è¦çå°æ¬å°"); |
| | | } |
| | | genTableService.generatorCode(tableName); |
| | | return success(); |
| | |
| | | @PreAuthorize("@ss.hasPermi('tool:gen:edit')") |
| | | @Log(title = "代ç çæ", businessType = BusinessType.UPDATE) |
| | | @GetMapping("/synchDb/{tableName}") |
| | | public Result synchDb(@PathVariable("tableName") String tableName) |
| | | public AjaxResult synchDb(@PathVariable("tableName") String tableName) |
| | | { |
| | | genTableService.synchDb(tableName); |
| | | return success(); |
| | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.Result; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import ${packageName}.domain.${ClassName}; |
| | | import ${packageName}.service.I${ClassName}Service; |
| | |
| | | return getDataTable(list); |
| | | } |
| | | #elseif($table.tree) |
| | | public Result list(${ClassName} ${className}) |
| | | public AjaxResult list(${ClassName} ${className}) |
| | | { |
| | | List<${ClassName}> list = ${className}Service.select${ClassName}List(${className}); |
| | | return success(list); |
| | |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('${permissionPrefix}:query')") |
| | | @GetMapping(value = "/{${pkColumn.javaField}}") |
| | | public Result getInfo(@PathVariable("${pkColumn.javaField}") ${pkColumn.javaType} ${pkColumn.javaField}) |
| | | public AjaxResult getInfo(@PathVariable("${pkColumn.javaField}") ${pkColumn.javaType} ${pkColumn.javaField}) |
| | | { |
| | | return success(${className}Service.select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaField})); |
| | | } |
| | |
| | | @PreAuthorize("@ss.hasPermi('${permissionPrefix}:add')") |
| | | @Log(title = "${functionName}", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public Result add(@RequestBody ${ClassName} ${className}) |
| | | public AjaxResult add(@RequestBody ${ClassName} ${className}) |
| | | { |
| | | return toAjax(${className}Service.insert${ClassName}(${className})); |
| | | } |
| | |
| | | @PreAuthorize("@ss.hasPermi('${permissionPrefix}:edit')") |
| | | @Log(title = "${functionName}", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public Result edit(@RequestBody ${ClassName} ${className}) |
| | | public AjaxResult edit(@RequestBody ${ClassName} ${className}) |
| | | { |
| | | return toAjax(${className}Service.update${ClassName}(${className})); |
| | | } |
| | |
| | | @PreAuthorize("@ss.hasPermi('${permissionPrefix}:remove')") |
| | | @Log(title = "${functionName}", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{${pkColumn.javaField}s}") |
| | | public Result remove(@PathVariable ${pkColumn.javaType}[] ${pkColumn.javaField}s) |
| | | public AjaxResult remove(@PathVariable ${pkColumn.javaType}[] ${pkColumn.javaField}s) |
| | | { |
| | | return toAjax(${className}Service.delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaField}s)); |
| | | } |
| | |
| | | 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.Result; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.exception.job.TaskException; |
| | |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('monitor:job:query')") |
| | | @GetMapping(value = "/{jobId}") |
| | | public Result getInfo(@PathVariable("jobId") Long jobId) |
| | | public AjaxResult getInfo(@PathVariable("jobId") Long jobId) |
| | | { |
| | | return success(jobService.selectJobById(jobId)); |
| | | } |
| | |
| | | @PreAuthorize("@ss.hasPermi('monitor:job:add')") |
| | | @Log(title = "宿¶ä»»å¡", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public Result add(@RequestBody SysJob job) throws SchedulerException, TaskException |
| | | public AjaxResult add(@RequestBody SysJob job) throws SchedulerException, TaskException |
| | | { |
| | | if (!CronUtils.isValid(job.getCronExpression())) |
| | | { |
| | |
| | | @PreAuthorize("@ss.hasPermi('monitor:job:edit')") |
| | | @Log(title = "宿¶ä»»å¡", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public Result edit(@RequestBody SysJob job) throws SchedulerException, TaskException |
| | | public AjaxResult edit(@RequestBody SysJob job) throws SchedulerException, TaskException |
| | | { |
| | | if (!CronUtils.isValid(job.getCronExpression())) |
| | | { |
| | |
| | | @PreAuthorize("@ss.hasPermi('monitor:job:changeStatus')") |
| | | @Log(title = "宿¶ä»»å¡", businessType = BusinessType.UPDATE) |
| | | @PutMapping("/changeStatus") |
| | | public Result changeStatus(@RequestBody SysJob job) throws SchedulerException |
| | | public AjaxResult changeStatus(@RequestBody SysJob job) throws SchedulerException |
| | | { |
| | | SysJob newJob = jobService.selectJobById(job.getJobId()); |
| | | newJob.setStatus(job.getStatus()); |
| | |
| | | @PreAuthorize("@ss.hasPermi('monitor:job:changeStatus')") |
| | | @Log(title = "宿¶ä»»å¡", businessType = BusinessType.UPDATE) |
| | | @PutMapping("/run") |
| | | public Result run(@RequestBody SysJob job) throws SchedulerException |
| | | public AjaxResult run(@RequestBody SysJob job) throws SchedulerException |
| | | { |
| | | boolean result = jobService.run(job); |
| | | return result ? success() : error("ä»»å¡ä¸åå¨æå·²è¿æï¼"); |
| | |
| | | @PreAuthorize("@ss.hasPermi('monitor:job:remove')") |
| | | @Log(title = "宿¶ä»»å¡", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{jobIds}") |
| | | public Result remove(@PathVariable Long[] jobIds) throws SchedulerException, TaskException |
| | | public AjaxResult remove(@PathVariable Long[] jobIds) throws SchedulerException, TaskException |
| | | { |
| | | jobService.deleteJobByIds(jobIds); |
| | | return success(); |
| | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.Result; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('monitor:job:query')") |
| | | @GetMapping(value = "/{jobLogId}") |
| | | public Result getInfo(@PathVariable Long jobLogId) |
| | | public AjaxResult getInfo(@PathVariable Long jobLogId) |
| | | { |
| | | return success(jobLogService.selectJobLogById(jobLogId)); |
| | | } |
| | |
| | | @PreAuthorize("@ss.hasPermi('monitor:job:remove')") |
| | | @Log(title = "宿¶ä»»å¡è°åº¦æ¥å¿", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{jobLogIds}") |
| | | public Result remove(@PathVariable Long[] jobLogIds) |
| | | public AjaxResult remove(@PathVariable Long[] jobLogIds) |
| | | { |
| | | return toAjax(jobLogService.deleteJobLogByIds(jobLogIds)); |
| | | } |
| | |
| | | @PreAuthorize("@ss.hasPermi('monitor:job:remove')") |
| | | @Log(title = "è°åº¦æ¥å¿", businessType = BusinessType.CLEAN) |
| | | @DeleteMapping("/clean") |
| | | public Result clean() |
| | | public AjaxResult clean() |
| | | { |
| | | jobLogService.cleanJobLog(); |
| | | return success(); |
| | |
| | | */ |
| | | public interface CustomService extends IService<Custom> { |
| | | |
| | | Map<String, Object> selectCustomPageList(IPage<Custom> page, Custom custom); |
| | | IPage<Custom> selectCustomPageList(IPage<Custom> page, Custom custom); |
| | | |
| | | int delCustomById(Long id); |
| | | |
| | |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.core.domain.entity.Custom; |
| | | import com.ruoyi.common.utils.QueryWrappers; |
| | | import com.ruoyi.system.mapper.CustomMapper; |
| | | import com.ruoyi.system.service.CustomService; |
| | | import lombok.AllArgsConstructor; |
| | |
| | | private CustomMapper customMapper; |
| | | |
| | | @Override |
| | | public Map<String, Object> selectCustomPageList(IPage<Custom> page, Custom custom) { |
| | | |
| | | return null; |
| | | public IPage<Custom> selectCustomPageList(IPage<Custom> page, Custom custom) { |
| | | return customMapper.selectCustomPageList(page, QueryWrappers.queryWrappers(custom)); |
| | | } |
| | | |
| | | @Override |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?xml version="1.0" encoding="UTF-8" ?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > |
| | | <mapper namespace="com.ruoyi.system.mapper.CustomMapper"> |
| | | <update id="delCustomById"> |
| | | update user set is_custom = 0 |
| | | where id = #{id} |
| | | </update> |
| | | <select id="selectCustomPageList" resultType="com.ruoyi.common.core.domain.entity.Custom"> |
| | | select * from custom |
| | | <if test="ew.customSqlSegment != null and ew.customSqlSegment != ''"> |
| | | ${ew.customSqlSegment} |
| | | </if> |
| | | </select> |
| | | </mapper> |