适配swagger接口文档,泛型进行添加

nacos
dongzeliang 2023-10-23 15:05:06 +08:00
parent 5b84a2fb17
commit dde64c7a0f
27 changed files with 211 additions and 211 deletions

View File

@ -66,7 +66,7 @@ public class CommonController {
*
*/
@PostMapping("/upload")
public Result uploadFile (MultipartFile file) throws Exception {
public Result<UploadFileModel> uploadFile (MultipartFile file) throws Exception {
try {
// 上传文件路径
String filePath = RuoYiConfig.getUploadPath();
@ -89,7 +89,7 @@ public class CommonController {
*
*/
@PostMapping("/uploads")
public Result uploadFiles (List<MultipartFile> files) throws Exception {
public Result<List<UploadFileModel>> uploadFiles (List<MultipartFile> files) throws Exception {
try {
// 上传文件路径
String filePath = RuoYiConfig.getUploadPath();

View File

@ -36,7 +36,7 @@ public class CacheController {
@PreAuthorize("@ss.hasPermi('monitor:cache:list')")
@GetMapping()
public Result getInfo () throws Exception {
public Result<Map<String, Object>> getInfo () throws Exception {
Properties info = (Properties) redisTemplate.execute((RedisCallback<Object>) connection -> connection.info());
Properties commandStats = (Properties) redisTemplate.execute((RedisCallback<Object>) connection -> connection.info("commandstats"));
Object dbSize = redisTemplate.execute((RedisCallback<Object>) connection -> connection.dbSize());
@ -59,20 +59,20 @@ public class CacheController {
@PreAuthorize("@ss.hasPermi('monitor:cache:list')")
@GetMapping("/getNames")
public Result cache () {
public Result<List<SysCache>> cache () {
return Result.success(caches);
}
@PreAuthorize("@ss.hasPermi('monitor:cache:list')")
@GetMapping("/getKeys/{cacheName}")
public Result getCacheKeys (@PathVariable String cacheName) {
public Result<Set<String>> getCacheKeys (@PathVariable String cacheName) {
Set<String> cacheKeys = redisTemplate.keys(cacheName + "*");
return Result.success(cacheKeys);
}
@PreAuthorize("@ss.hasPermi('monitor:cache:list')")
@GetMapping("/getValue/{cacheName}/{cacheKey}")
public Result getCacheValue (@PathVariable String cacheName, @PathVariable String cacheKey) {
public Result<SysCache> getCacheValue (@PathVariable String cacheName, @PathVariable String cacheKey) {
String cacheValue = redisTemplate.opsForValue().get(cacheKey);
SysCache sysCache = new SysCache(cacheName, cacheKey, cacheValue);
return Result.success(sysCache);
@ -80,24 +80,28 @@ public class CacheController {
@PreAuthorize("@ss.hasPermi('monitor:cache:list')")
@DeleteMapping("/clearCacheName/{cacheName}")
public Result clearCacheName (@PathVariable String cacheName) {
public Result<String> clearCacheName (@PathVariable String cacheName) {
Collection<String> cacheKeys = redisTemplate.keys(cacheName + "*");
redisTemplate.delete(cacheKeys);
if (cacheKeys != null) {
redisTemplate.delete(cacheKeys);
}
return Result.success();
}
@PreAuthorize("@ss.hasPermi('monitor:cache:list')")
@DeleteMapping("/clearCacheKey/{cacheKey}")
public Result clearCacheKey (@PathVariable String cacheKey) {
public Result<String> clearCacheKey (@PathVariable String cacheKey) {
redisTemplate.delete(cacheKey);
return Result.success();
}
@PreAuthorize("@ss.hasPermi('monitor:cache:list')")
@DeleteMapping("/clearCacheAll")
public Result clearCacheAll () {
public Result<String> clearCacheAll () {
Collection<String> cacheKeys = redisTemplate.keys("*");
redisTemplate.delete(cacheKeys);
if (cacheKeys != null) {
redisTemplate.delete(cacheKeys);
}
return Result.success();
}
}

View File

@ -17,7 +17,7 @@ import org.springframework.web.bind.annotation.RestController;
public class ServerController {
@PreAuthorize("@ss.hasPermi('monitor:server:list')")
@GetMapping()
public Result getInfo () throws Exception {
public Result<Server> getInfo () throws Exception {
Server server = new Server();
server.copyTo();
return Result.success(server);

View File

@ -32,7 +32,7 @@ public class SysLogininforController extends BaseController {
@PreAuthorize("@ss.hasPermi('monitor:logininfor:list')")
@GetMapping("/list")
public Result<TableDataInfo> list (SysLogininfor logininfor) {
public Result<TableDataInfo<SysLogininfor>> list (SysLogininfor logininfor) {
startPage();
List<SysLogininfor> list = logininforService.selectLogininforList(logininfor);
return getDataTable(list);
@ -50,23 +50,23 @@ public class SysLogininforController extends BaseController {
@PreAuthorize("@ss.hasPermi('monitor:logininfor:remove')")
@Log(title = "登录日志", businessType = BusinessType.DELETE)
@DeleteMapping("/{infoIds}")
public Result remove (@PathVariable Long[] infoIds) {
public Result<String> remove (@PathVariable Long[] infoIds) {
return toAjax(logininforService.deleteLogininforByIds(infoIds));
}
@PreAuthorize("@ss.hasPermi('monitor:logininfor:remove')")
@Log(title = "登录日志", businessType = BusinessType.CLEAN)
@DeleteMapping("/clean")
public Result clean () {
public Result<String> clean () {
logininforService.cleanLogininfor();
return success();
return Result.success();
}
@PreAuthorize("@ss.hasPermi('monitor:logininfor:unlock')")
@Log(title = "账户解锁", businessType = BusinessType.OTHER)
@GetMapping("/unlock/{userName}")
public Result unlock (@PathVariable("userName") String userName) {
public Result<String> unlock (@PathVariable("userName") String userName) {
passwordService.clearLoginRecordCache(userName);
return success();
return Result.success();
}
}

View File

@ -28,7 +28,7 @@ public class SysOperlogController extends BaseController {
@PreAuthorize("@ss.hasPermi('monitor:operlog:list')")
@GetMapping("/list")
public Result<TableDataInfo> list (SysOperLog operLog) {
public Result<TableDataInfo<SysOperLog>> list (SysOperLog operLog) {
startPage();
List<SysOperLog> list = operLogService.selectOperLogList(operLog);
return getDataTable(list);
@ -46,15 +46,15 @@ public class SysOperlogController extends BaseController {
@Log(title = "操作日志", businessType = BusinessType.DELETE)
@PreAuthorize("@ss.hasPermi('monitor:operlog:remove')")
@DeleteMapping("/{operIds}")
public Result remove (@PathVariable Long[] operIds) {
public Result<String> remove (@PathVariable Long[] operIds) {
return toAjax(operLogService.deleteOperLogByIds(operIds));
}
@Log(title = "操作日志", businessType = BusinessType.CLEAN)
@PreAuthorize("@ss.hasPermi('monitor:operlog:remove')")
@DeleteMapping("/clean")
public Result clean () {
public Result<String> clean () {
operLogService.cleanOperLog();
return success();
return Result.success();
}
}

View File

@ -36,7 +36,7 @@ public class SysUserOnlineController extends BaseController {
@PreAuthorize("@ss.hasPermi('monitor:online:list')")
@GetMapping("/list")
public Result<TableDataInfo> list (String ipaddr, String userName) {
public Result<TableDataInfo<SysUserOnline>> list (String ipaddr, String userName) {
Collection<String> keys = redisCache.keys(CacheConstants.LOGIN_TOKEN_KEY + "*");
List<SysUserOnline> userOnlineList = new ArrayList<SysUserOnline>();
for (String key : keys) {
@ -62,8 +62,8 @@ public class SysUserOnlineController extends BaseController {
@PreAuthorize("@ss.hasPermi('monitor:online:forceLogout')")
@Log(title = "在线用户", businessType = BusinessType.FORCE)
@DeleteMapping("/{tokenId}")
public Result forceLogout (@PathVariable String tokenId) {
public Result<String> forceLogout (@PathVariable String tokenId) {
redisCache.deleteObject(CacheConstants.LOGIN_TOKEN_KEY + tokenId);
return success();
return Result.success();
}
}

View File

@ -32,7 +32,7 @@ public class SysConfigController extends BaseController {
*/
@PreAuthorize("@ss.hasPermi('system:config:list')")
@GetMapping("/list")
public Result<TableDataInfo> list (SysConfig config) {
public Result<TableDataInfo<SysConfig>> list (SysConfig config) {
startPage();
List<SysConfig> list = configService.selectConfigList(config);
return getDataTable(list);
@ -52,16 +52,16 @@ public class SysConfigController extends BaseController {
*/
@PreAuthorize("@ss.hasPermi('system:config:query')")
@GetMapping(value = "/{configId}")
public Result getInfo (@PathVariable Long configId) {
return success(configService.selectConfigById(configId));
public Result<SysConfig> getInfo (@PathVariable Long configId) {
return Result.success(configService.selectConfigById(configId));
}
/**
*
*/
@GetMapping(value = "/configKey/{configKey}")
public Result getConfigKey (@PathVariable String configKey) {
return success(configService.selectConfigByKey(configKey));
public Result<String> getConfigKey (@PathVariable String configKey) {
return Result.success(configService.selectConfigByKey(configKey));
}
/**
@ -70,7 +70,7 @@ public class SysConfigController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:config:add')")
@Log(title = "参数管理", businessType = BusinessType.INSERT)
@PostMapping
public Result add (@Validated @RequestBody SysConfig config) {
public Result<String> add (@Validated @RequestBody SysConfig config) {
if (!configService.checkConfigKeyUnique(config)) {
return error("新增参数'" + config.getConfigName() + "'失败,参数键名已存在");
}
@ -84,7 +84,7 @@ public class SysConfigController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:config:edit')")
@Log(title = "参数管理", businessType = BusinessType.UPDATE)
@PutMapping
public Result edit (@Validated @RequestBody SysConfig config) {
public Result<String> edit (@Validated @RequestBody SysConfig config) {
if (!configService.checkConfigKeyUnique(config)) {
return error("修改参数'" + config.getConfigName() + "'失败,参数键名已存在");
}
@ -98,9 +98,9 @@ public class SysConfigController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:config:remove')")
@Log(title = "参数管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{configIds}")
public Result remove (@PathVariable Long[] configIds) {
public Result<String> remove (@PathVariable Long[] configIds) {
configService.deleteConfigByIds(configIds);
return success();
return Result.success();
}
/**
@ -109,8 +109,8 @@ public class SysConfigController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:config:remove')")
@Log(title = "参数管理", businessType = BusinessType.CLEAN)
@DeleteMapping("/refreshCache")
public Result refreshCache () {
public Result<String> refreshCache () {
configService.resetConfigCache();
return success();
return Result.success();
}
}

View File

@ -32,9 +32,9 @@ public class SysDeptController extends BaseController {
*/
@PreAuthorize("@ss.hasPermi('system:dept:list')")
@GetMapping("/list")
public Result list (SysDept dept) {
public Result<List<SysDept>> list (SysDept dept) {
List<SysDept> depts = deptService.selectDeptList(dept);
return success(depts);
return Result.success(depts);
}
/**
@ -42,10 +42,10 @@ public class SysDeptController extends BaseController {
*/
@PreAuthorize("@ss.hasPermi('system:dept:list')")
@GetMapping("/list/exclude/{deptId}")
public Result excludeChild (@PathVariable(value = "deptId", required = false) Long deptId) {
public Result<List<SysDept>> excludeChild (@PathVariable(value = "deptId", required = false) Long deptId) {
List<SysDept> depts = deptService.selectDeptList(new SysDept());
depts.removeIf(d -> d.getDeptId().intValue() == deptId || ArrayUtils.contains(StringUtils.split(d.getAncestors(), ","), deptId + ""));
return success(depts);
return Result.success(depts);
}
/**
@ -53,9 +53,9 @@ public class SysDeptController extends BaseController {
*/
@PreAuthorize("@ss.hasPermi('system:dept:query')")
@GetMapping(value = "/{deptId}")
public Result getInfo (@PathVariable Long deptId) {
public Result<SysDept> getInfo (@PathVariable Long deptId) {
deptService.checkDeptDataScope(deptId);
return success(deptService.selectDeptById(deptId));
return Result.success(deptService.selectDeptById(deptId));
}
/**
@ -64,7 +64,7 @@ public class SysDeptController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:dept:add')")
@Log(title = "部门管理", businessType = BusinessType.INSERT)
@PostMapping
public Result add (@Validated @RequestBody SysDept dept) {
public Result<String> add (@Validated @RequestBody SysDept dept) {
if (!deptService.checkDeptNameUnique(dept)) {
return error("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在");
}
@ -78,7 +78,7 @@ public class SysDeptController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:dept:edit')")
@Log(title = "部门管理", businessType = BusinessType.UPDATE)
@PutMapping
public Result edit (@Validated @RequestBody SysDept dept) {
public Result<String> edit (@Validated @RequestBody SysDept dept) {
Long deptId = dept.getDeptId();
deptService.checkDeptDataScope(deptId);
if (!deptService.checkDeptNameUnique(dept)) {
@ -98,7 +98,7 @@ public class SysDeptController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:dept:remove')")
@Log(title = "部门管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{deptId}")
public Result remove (@PathVariable Long deptId) {
public Result<String> remove (@PathVariable Long deptId) {
if (deptService.hasChildByDeptId(deptId)) {
return warn("存在下级部门,不允许删除");
}

View File

@ -35,7 +35,7 @@ public class SysDictDataController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:dict:list')")
@GetMapping("/list")
public Result<TableDataInfo> list (SysDictData dictData) {
public Result<TableDataInfo<SysDictData>> list (SysDictData dictData) {
startPage();
List<SysDictData> list = dictDataService.selectDictDataList(dictData);
return getDataTable(list);
@ -55,20 +55,20 @@ public class SysDictDataController extends BaseController {
*/
@PreAuthorize("@ss.hasPermi('system:dict:query')")
@GetMapping(value = "/{dictCode}")
public Result getInfo (@PathVariable Long dictCode) {
return success(dictDataService.selectDictDataById(dictCode));
public Result<SysDictData> getInfo (@PathVariable Long dictCode) {
return Result.success(dictDataService.selectDictDataById(dictCode));
}
/**
*
*/
@GetMapping(value = "/type/{dictType}")
public Result dictType (@PathVariable String dictType) {
public Result<List<SysDictData>> dictType (@PathVariable String dictType) {
List<SysDictData> data = dictTypeService.selectDictDataByType(dictType);
if (StringUtils.isNull(data)) {
data = new ArrayList<SysDictData>();
}
return success(data);
return Result.success(data);
}
/**
@ -77,7 +77,7 @@ public class SysDictDataController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:dict:add')")
@Log(title = "字典数据", businessType = BusinessType.INSERT)
@PostMapping
public Result add (@Validated @RequestBody SysDictData dict) {
public Result<String> add (@Validated @RequestBody SysDictData dict) {
dict.setCreateBy(getUserId());
return toAjax(dictDataService.insertDictData(dict));
}
@ -88,7 +88,7 @@ public class SysDictDataController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:dict:edit')")
@Log(title = "字典数据", businessType = BusinessType.UPDATE)
@PutMapping
public Result edit (@Validated @RequestBody SysDictData dict) {
public Result<String> edit (@Validated @RequestBody SysDictData dict) {
dict.setUpdateBy(getUserId());
return toAjax(dictDataService.updateDictData(dict));
}
@ -99,8 +99,8 @@ public class SysDictDataController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:dict:remove')")
@Log(title = "字典类型", businessType = BusinessType.DELETE)
@DeleteMapping("/{dictCodes}")
public Result remove (@PathVariable Long[] dictCodes) {
public Result<String> remove (@PathVariable Long[] dictCodes) {
dictDataService.deleteDictDataByIds(dictCodes);
return success();
return Result.success();
}
}

View File

@ -29,7 +29,7 @@ public class SysDictTypeController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:dict:list')")
@GetMapping("/list")
public Result<TableDataInfo> list (SysDictType dictType) {
public Result<TableDataInfo<SysDictType>> list (SysDictType dictType) {
startPage();
List<SysDictType> list = dictTypeService.selectDictTypeList(dictType);
return getDataTable(list);
@ -49,8 +49,8 @@ public class SysDictTypeController extends BaseController {
*/
@PreAuthorize("@ss.hasPermi('system:dict:query')")
@GetMapping(value = "/{dictId}")
public Result getInfo (@PathVariable Long dictId) {
return success(dictTypeService.selectDictTypeById(dictId));
public Result<SysDictType> getInfo (@PathVariable Long dictId) {
return Result.success(dictTypeService.selectDictTypeById(dictId));
}
/**
@ -59,7 +59,7 @@ public class SysDictTypeController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:dict:add')")
@Log(title = "字典类型", businessType = BusinessType.INSERT)
@PostMapping
public Result add (@Validated @RequestBody SysDictType dict) {
public Result<String> add (@Validated @RequestBody SysDictType dict) {
if (!dictTypeService.checkDictTypeUnique(dict)) {
return error("新增字典'" + dict.getDictName() + "'失败,字典类型已存在");
}
@ -73,7 +73,7 @@ public class SysDictTypeController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:dict:edit')")
@Log(title = "字典类型", businessType = BusinessType.UPDATE)
@PutMapping
public Result edit (@Validated @RequestBody SysDictType dict) {
public Result<String> edit (@Validated @RequestBody SysDictType dict) {
if (!dictTypeService.checkDictTypeUnique(dict)) {
return error("修改字典'" + dict.getDictName() + "'失败,字典类型已存在");
}
@ -87,9 +87,9 @@ public class SysDictTypeController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:dict:remove')")
@Log(title = "字典类型", businessType = BusinessType.DELETE)
@DeleteMapping("/{dictIds}")
public Result remove (@PathVariable Long[] dictIds) {
public Result<String> remove (@PathVariable Long[] dictIds) {
dictTypeService.deleteDictTypeByIds(dictIds);
return success();
return Result.success();
}
/**
@ -98,17 +98,17 @@ public class SysDictTypeController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:dict:remove')")
@Log(title = "字典类型", businessType = BusinessType.CLEAN)
@DeleteMapping("/refreshCache")
public Result refreshCache () {
public Result<String> refreshCache () {
dictTypeService.resetDictCache();
return success();
return Result.success();
}
/**
*
*/
@GetMapping("/optionselect")
public Result optionselect () {
public Result<List<SysDictType>> optionselect () {
List<SysDictType> dictTypes = dictTypeService.selectDictTypeAll();
return success(dictTypes);
return Result.success(dictTypes);
}
}

View File

@ -8,6 +8,7 @@ import com.ruoyi.common.core.domain.resp.UserInfoResp;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.framework.web.service.SysLoginService;
import com.ruoyi.framework.web.service.SysPermissionService;
import com.ruoyi.system.domain.vo.RouterVo;
import com.ruoyi.system.service.SysMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
@ -42,7 +43,7 @@ public class SysLoginController {
* @return
*/
@PostMapping("/login")
public Result login (@RequestBody LoginBody loginBody) {
public Result<String> login (@RequestBody LoginBody loginBody) {
// 生成令牌
String token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(),
loginBody.getUuid());
@ -55,7 +56,7 @@ public class SysLoginController {
* @return
*/
@GetMapping("getInfo")
public Result getInfo () {
public Result<UserInfoResp> getInfo () {
SysUser user = SecurityUtils.getLoginUser().getUser();
// 角色集合
Set<String> roles = permissionService.getRolePermission(user);
@ -76,7 +77,7 @@ public class SysLoginController {
* @return
*/
@GetMapping("getRouters")
public Result getRouters () {
public Result<List<RouterVo>> getRouters () {
Long userId = SecurityUtils.getUserId();
List<SysMenu> menus = menuService.selectMenuTreeByUserId(userId);
return Result.success(menuService.buildMenus(menus));

View File

@ -4,6 +4,7 @@ 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.TreeSelect;
import com.ruoyi.common.core.domain.entity.SysMenu;
import com.ruoyi.common.core.domain.resp.RoleMenuTreeResp;
import com.ruoyi.common.enums.BusinessType;
@ -32,9 +33,9 @@ public class SysMenuController extends BaseController {
*/
@PreAuthorize("@ss.hasPermi('system:menu:list')")
@GetMapping("/list")
public Result list (SysMenu menu) {
public Result<List<SysMenu>> list (SysMenu menu) {
List<SysMenu> menus = menuService.selectMenuList(menu, getUserId());
return success(menus);
return Result.success(menus);
}
/**
@ -42,24 +43,24 @@ public class SysMenuController extends BaseController {
*/
@PreAuthorize("@ss.hasPermi('system:menu:query')")
@GetMapping(value = "/{menuId}")
public Result getInfo (@PathVariable Long menuId) {
return success(menuService.selectMenuById(menuId));
public Result<SysMenu> getInfo (@PathVariable Long menuId) {
return Result.success(menuService.selectMenuById(menuId));
}
/**
*
*/
@GetMapping("/treeselect")
public Result treeselect (SysMenu menu) {
public Result<List<TreeSelect>> treeselect (SysMenu menu) {
List<SysMenu> menus = menuService.selectMenuList(menu, getUserId());
return success(menuService.buildMenuTreeSelect(menus));
return Result.success(menuService.buildMenuTreeSelect(menus));
}
/**
*
*/
@GetMapping(value = "/roleMenuTreeselect/{roleId}")
public Result roleMenuTreeselect (@PathVariable("roleId") Long roleId) {
public Result<RoleMenuTreeResp> roleMenuTreeselect (@PathVariable("roleId") Long roleId) {
List<SysMenu> menus = menuService.selectMenuList(getUserId());
return Result.success(
RoleMenuTreeResp.builder()
@ -75,7 +76,7 @@ public class SysMenuController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:menu:add')")
@Log(title = "菜单管理", businessType = BusinessType.INSERT)
@PostMapping
public Result add (@Validated @RequestBody SysMenu menu) {
public Result<String> add (@Validated @RequestBody SysMenu menu) {
if (!menuService.checkMenuNameUnique(menu)) {
return error("新增菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
} else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) && !StringUtils.ishttp(menu.getPath())) {
@ -91,7 +92,7 @@ public class SysMenuController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:menu:edit')")
@Log(title = "菜单管理", businessType = BusinessType.UPDATE)
@PutMapping
public Result edit (@Validated @RequestBody SysMenu menu) {
public Result<String> edit (@Validated @RequestBody SysMenu menu) {
if (!menuService.checkMenuNameUnique(menu)) {
return error("修改菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
} else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) && !StringUtils.ishttp(menu.getPath())) {
@ -109,7 +110,7 @@ public class SysMenuController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:menu:remove')")
@Log(title = "菜单管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{menuId}")
public Result remove (@PathVariable("menuId") Long menuId) {
public Result<String> remove (@PathVariable("menuId") Long menuId) {
if (menuService.hasChildByMenuId(menuId)) {
return warn("存在子菜单,不允许删除");
}

View File

@ -30,7 +30,7 @@ public class SysNoticeController extends BaseController {
*/
@PreAuthorize("@ss.hasPermi('system:notice:list')")
@GetMapping("/list")
public Result<TableDataInfo> list (SysNotice notice) {
public Result<TableDataInfo<SysNotice>> list (SysNotice notice) {
startPage();
List<SysNotice> list = noticeService.selectNoticeList(notice);
return getDataTable(list);
@ -41,8 +41,8 @@ public class SysNoticeController extends BaseController {
*/
@PreAuthorize("@ss.hasPermi('system:notice:query')")
@GetMapping(value = "/{noticeId}")
public Result getInfo (@PathVariable Long noticeId) {
return success(noticeService.selectNoticeById(noticeId));
public Result<SysNotice> getInfo (@PathVariable Long noticeId) {
return Result.success(noticeService.selectNoticeById(noticeId));
}
/**
@ -51,7 +51,7 @@ public class SysNoticeController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:notice:add')")
@Log(title = "通知公告", businessType = BusinessType.INSERT)
@PostMapping
public Result add (@Validated @RequestBody SysNotice notice) {
public Result<String> add (@Validated @RequestBody SysNotice notice) {
notice.setCreateBy(getUserId());
return toAjax(noticeService.insertNotice(notice));
}
@ -62,7 +62,7 @@ public class SysNoticeController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:notice:edit')")
@Log(title = "通知公告", businessType = BusinessType.UPDATE)
@PutMapping
public Result edit (@Validated @RequestBody SysNotice notice) {
public Result<String> edit (@Validated @RequestBody SysNotice notice) {
notice.setUpdateBy(getUserId());
return toAjax(noticeService.updateNotice(notice));
}
@ -73,7 +73,7 @@ public class SysNoticeController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:notice:remove')")
@Log(title = "通知公告", businessType = BusinessType.DELETE)
@DeleteMapping("/{noticeIds}")
public Result remove (@PathVariable Long[] noticeIds) {
public Result<String> remove (@PathVariable Long[] noticeIds) {
return toAjax(noticeService.deleteNoticeByIds(noticeIds));
}
}

View File

@ -32,7 +32,7 @@ public class SysPostController extends BaseController {
*/
@PreAuthorize("@ss.hasPermi('system:post:list')")
@GetMapping("/list")
public Result<TableDataInfo> list (SysPost post) {
public Result<TableDataInfo<SysPost>> list (SysPost post) {
startPage();
List<SysPost> list = postService.selectPostList(post);
return getDataTable(list);
@ -52,8 +52,8 @@ public class SysPostController extends BaseController {
*/
@PreAuthorize("@ss.hasPermi('system:post:query')")
@GetMapping(value = "/{postId}")
public Result getInfo (@PathVariable Long postId) {
return success(postService.selectPostById(postId));
public Result<SysPost> getInfo (@PathVariable Long postId) {
return Result.success(postService.selectPostById(postId));
}
/**
@ -62,7 +62,7 @@ public class SysPostController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:post:add')")
@Log(title = "岗位管理", businessType = BusinessType.INSERT)
@PostMapping
public Result add (@Validated @RequestBody SysPost post) {
public Result<String> add (@Validated @RequestBody SysPost post) {
if (!postService.checkPostNameUnique(post)) {
return error("新增岗位'" + post.getPostName() + "'失败,岗位名称已存在");
} else if (!postService.checkPostCodeUnique(post)) {
@ -78,7 +78,7 @@ public class SysPostController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:post:edit')")
@Log(title = "岗位管理", businessType = BusinessType.UPDATE)
@PutMapping
public Result edit (@Validated @RequestBody SysPost post) {
public Result<String> edit (@Validated @RequestBody SysPost post) {
if (!postService.checkPostNameUnique(post)) {
return error("修改岗位'" + post.getPostName() + "'失败,岗位名称已存在");
} else if (!postService.checkPostCodeUnique(post)) {
@ -94,7 +94,7 @@ public class SysPostController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:post:remove')")
@Log(title = "岗位管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{postIds}")
public Result remove (@PathVariable Long[] postIds) {
public Result<String> remove (@PathVariable Long[] postIds) {
return toAjax(postService.deletePostByIds(postIds));
}
@ -102,8 +102,8 @@ public class SysPostController extends BaseController {
*
*/
@GetMapping("/optionselect")
public Result optionselect () {
public Result<List<SysPost>> optionselect () {
List<SysPost> posts = postService.selectPostAll();
return success(posts);
return Result.success(posts);
}
}

View File

@ -36,7 +36,7 @@ public class SysProfileController extends BaseController {
*
*/
@GetMapping
public Result profile () {
public Result<ProfileResp> profile () {
LoginUser loginUser = getLoginUser();
SysUser user = loginUser.getUser();
return Result.success(
@ -53,7 +53,7 @@ public class SysProfileController extends BaseController {
*/
@Log(title = "个人信息", businessType = BusinessType.UPDATE)
@PutMapping
public Result updateProfile (@RequestBody SysUser user) {
public Result<String> updateProfile (@RequestBody SysUser user) {
LoginUser loginUser = getLoginUser();
SysUser currentUser = loginUser.getUser();
currentUser.setNickName(user.getNickName());
@ -69,7 +69,7 @@ public class SysProfileController extends BaseController {
if (userService.updateUserProfile(currentUser) > 0) {
// 更新缓存用户信息
tokenService.setLoginUser(loginUser);
return success();
return Result.success();
}
return error("修改个人信息异常,请联系管理员");
}
@ -79,7 +79,7 @@ public class SysProfileController extends BaseController {
*/
@Log(title = "个人信息", businessType = BusinessType.UPDATE)
@PutMapping("/updatePwd")
public Result updatePwd (String oldPassword, String newPassword) {
public Result<String> updatePwd (String oldPassword, String newPassword) {
LoginUser loginUser = getLoginUser();
String userName = loginUser.getUsername();
String password = loginUser.getPassword();
@ -93,7 +93,7 @@ public class SysProfileController extends BaseController {
// 更新缓存用户密码
loginUser.getUser().setPassword(SecurityUtils.encryptPassword(newPassword));
tokenService.setLoginUser(loginUser);
return success();
return Result.success();
}
return error("修改密码异常,请联系管理员");
}
@ -103,7 +103,7 @@ public class SysProfileController extends BaseController {
*/
@Log(title = "用户头像", businessType = BusinessType.UPDATE)
@PostMapping("/avatar")
public Result avatar (@RequestParam("avatarfile") MultipartFile file) throws Exception {
public Result<String> avatar (@RequestParam("avatarfile") MultipartFile file) throws Exception {
if (!file.isEmpty()) {
LoginUser loginUser = getLoginUser();
String avatar = FileUploadUtils.upload(RuoYiConfig.getAvatarPath(), file, MimeTypeUtils.IMAGE_EXTENSION);

View File

@ -25,7 +25,7 @@ public class SysRegisterController extends BaseController {
private SysConfigServic configService;
@PostMapping("/register")
public Result register (@RequestBody RegisterBody user) {
public Result<String> register (@RequestBody RegisterBody user) {
if (!("true".equals(configService.selectConfigByKey("sys.account.registerUser")))) {
return error("当前系统没有开启注册功能!");
}

View File

@ -51,7 +51,7 @@ public class SysRoleController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:role:list')")
@GetMapping("/list")
public Result<TableDataInfo> list (SysRole role) {
public Result<TableDataInfo<SysRole>> list (SysRole role) {
startPage();
List<SysRole> list = roleService.selectRoleList(role);
return getDataTable(list);
@ -71,9 +71,9 @@ public class SysRoleController extends BaseController {
*/
@PreAuthorize("@ss.hasPermi('system:role:query')")
@GetMapping(value = "/{roleId}")
public Result getInfo (@PathVariable Long roleId) {
public Result<SysRole> getInfo (@PathVariable Long roleId) {
roleService.checkRoleDataScope(roleId);
return success(roleService.selectRoleById(roleId));
return Result.success(roleService.selectRoleById(roleId));
}
/**
@ -82,7 +82,7 @@ public class SysRoleController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:role:add')")
@Log(title = "角色管理", businessType = BusinessType.INSERT)
@PostMapping
public Result add (@Validated @RequestBody SysRole role) {
public Result<String> add (@Validated @RequestBody SysRole role) {
if (!roleService.checkRoleNameUnique(role)) {
return error("新增角色'" + role.getRoleName() + "'失败,角色名称已存在");
} else if (!roleService.checkRoleKeyUnique(role)) {
@ -99,7 +99,7 @@ public class SysRoleController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:role:edit')")
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
@PutMapping
public Result edit (@Validated @RequestBody SysRole role) {
public Result<String> edit (@Validated @RequestBody SysRole role) {
roleService.checkRoleAllowed(role);
roleService.checkRoleDataScope(role.getRoleId());
if (!roleService.checkRoleNameUnique(role)) {
@ -117,7 +117,7 @@ public class SysRoleController extends BaseController {
loginUser.setUser(userService.selectUserByUserName(loginUser.getUser().getUserName()));
tokenService.setLoginUser(loginUser);
}
return success();
return Result.success();
}
return error("修改角色'" + role.getRoleName() + "'失败,请联系管理员");
}
@ -128,7 +128,7 @@ public class SysRoleController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:role:edit')")
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
@PutMapping("/dataScope")
public Result dataScope (@RequestBody SysRole role) {
public Result<String> dataScope (@RequestBody SysRole role) {
roleService.checkRoleAllowed(role);
roleService.checkRoleDataScope(role.getRoleId());
return toAjax(roleService.authDataScope(role));
@ -140,7 +140,7 @@ public class SysRoleController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:role:edit')")
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
@PutMapping("/changeStatus")
public Result changeStatus (@RequestBody SysRole role) {
public Result<String> changeStatus (@RequestBody SysRole role) {
roleService.checkRoleAllowed(role);
roleService.checkRoleDataScope(role.getRoleId());
role.setUpdateBy(getUserId());
@ -153,7 +153,7 @@ public class SysRoleController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:role:remove')")
@Log(title = "角色管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{roleIds}")
public Result remove (@PathVariable Long[] roleIds) {
public Result<String> remove (@PathVariable Long[] roleIds) {
return toAjax(roleService.deleteRoleByIds(roleIds));
}
@ -162,8 +162,8 @@ public class SysRoleController extends BaseController {
*/
@PreAuthorize("@ss.hasPermi('system:role:query')")
@GetMapping("/optionselect")
public Result optionselect () {
return success(roleService.selectRoleAll());
public Result<List<SysRole>> optionselect () {
return Result.success(roleService.selectRoleAll());
}
/**
@ -171,7 +171,7 @@ public class SysRoleController extends BaseController {
*/
@PreAuthorize("@ss.hasPermi('system:role:list')")
@GetMapping("/authUser/allocatedList")
public Result<TableDataInfo> allocatedList (SysUser user) {
public Result<TableDataInfo<SysUser>> allocatedList (SysUser user) {
startPage();
List<SysUser> list = userService.selectAllocatedList(user);
return getDataTable(list);
@ -182,7 +182,7 @@ public class SysRoleController extends BaseController {
*/
@PreAuthorize("@ss.hasPermi('system:role:list')")
@GetMapping("/authUser/unallocatedList")
public Result<TableDataInfo> unallocatedList (SysUser user) {
public Result<TableDataInfo<SysUser>> unallocatedList (SysUser user) {
startPage();
List<SysUser> list = userService.selectUnallocatedList(user);
return getDataTable(list);
@ -194,7 +194,7 @@ public class SysRoleController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:role:edit')")
@Log(title = "角色管理", businessType = BusinessType.GRANT)
@PutMapping("/authUser/cancel")
public Result cancelAuthUser (@RequestBody SysUserRole userRole) {
public Result<String> cancelAuthUser (@RequestBody SysUserRole userRole) {
return toAjax(roleService.deleteAuthUser(userRole));
}
@ -204,7 +204,7 @@ public class SysRoleController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:role:edit')")
@Log(title = "角色管理", businessType = BusinessType.GRANT)
@PutMapping("/authUser/cancelAll")
public Result cancelAuthUserAll (Long roleId, Long[] userIds) {
public Result<String> cancelAuthUserAll (Long roleId, Long[] userIds) {
return toAjax(roleService.deleteAuthUsers(roleId, userIds));
}
@ -214,7 +214,7 @@ public class SysRoleController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:role:edit')")
@Log(title = "角色管理", businessType = BusinessType.GRANT)
@PutMapping("/authUser/selectAll")
public Result selectAuthUserAll (Long roleId, Long[] userIds) {
public Result<String> selectAuthUserAll (Long roleId, Long[] userIds) {
roleService.checkRoleDataScope(roleId);
return toAjax(roleService.insertAuthUsers(roleId, userIds));
}
@ -224,7 +224,7 @@ public class SysRoleController extends BaseController {
*/
@PreAuthorize("@ss.hasPermi('system:role:query')")
@GetMapping(value = "/deptTree/{roleId}")
public Result deptTree (@PathVariable("roleId") Long roleId) {
public Result<DeptTreeResp> deptTree (@PathVariable("roleId") Long roleId) {
return Result.success(
DeptTreeResp.builder()
.checkedKeys(deptService.selectDeptListByRoleId(roleId))

View File

@ -3,11 +3,13 @@ package com.ruoyi.web.controller.system;
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.TreeSelect;
import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.core.domain.entity.SysRole;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.domain.resp.AuthRoleResp;
import com.ruoyi.common.core.domain.resp.UserDetailInfoResp;
import com.ruoyi.common.core.domain.resp.UserDetailInfoResp.UserDetailInfoRespBuilder;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.SecurityUtils;
@ -53,7 +55,7 @@ public class SysUserController extends BaseController {
*/
@PreAuthorize("@ss.hasPermi('system:user:list')")
@GetMapping("/list")
public Result<TableDataInfo> list (SysUser user) {
public Result<TableDataInfo<SysUser>> list (SysUser user) {
startPage();
List<SysUser> list = userService.selectUserList(user);
return getDataTable(list);
@ -71,12 +73,12 @@ public class SysUserController extends BaseController {
@Log(title = "用户管理", businessType = BusinessType.IMPORT)
@PreAuthorize("@ss.hasPermi('system:user:import')")
@PostMapping("/importData")
public Result importData (MultipartFile file, boolean updateSupport) throws Exception {
public Result<String> importData (MultipartFile file, boolean updateSupport) throws Exception {
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
List<SysUser> userList = util.importExcel(file.getInputStream());
Long userId = getUserId();
String message = userService.importUser(userList, updateSupport, userId);
return success(message);
return Result.success(message);
}
@PostMapping("/importTemplate")
@ -90,11 +92,10 @@ public class SysUserController extends BaseController {
*/
@PreAuthorize("@ss.hasPermi('system:user:query')")
@GetMapping(value = {"/", "/{userId}"})
public Result getInfo (@PathVariable(value = "userId", required = false) Long userId) {
public Result<UserDetailInfoResp> getInfo (@PathVariable(value = "userId", required = false) Long userId) {
userService.checkUserDataScope(userId);
Result ajax = Result.success();
List<SysRole> roles = roleService.selectRoleAll();
UserDetailInfoResp.UserDetailInfoRespBuilder builder = UserDetailInfoResp.builder()
UserDetailInfoRespBuilder builder = UserDetailInfoResp.builder()
.roles(SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()))
.posts(postService.selectPostAll());
if (StringUtils.isNotNull(userId)) {
@ -114,7 +115,7 @@ public class SysUserController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:user:add')")
@Log(title = "用户管理", businessType = BusinessType.INSERT)
@PostMapping
public Result add (@Validated @RequestBody SysUser user) {
public Result<String> add (@Validated @RequestBody SysUser user) {
if (!userService.checkUserNameUnique(user)) {
return error("新增用户'" + user.getUserName() + "'失败,登录账号已存在");
} else if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user)) {
@ -133,7 +134,7 @@ public class SysUserController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:user:edit')")
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
@PutMapping
public Result edit (@Validated @RequestBody SysUser user) {
public Result<String> edit (@Validated @RequestBody SysUser user) {
userService.checkUserAllowed(user);
userService.checkUserDataScope(user.getUserId());
if (!userService.checkUserNameUnique(user)) {
@ -153,7 +154,7 @@ public class SysUserController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:user:remove')")
@Log(title = "用户管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{userIds}")
public Result remove (@PathVariable Long[] userIds) {
public Result<String> remove (@PathVariable Long[] userIds) {
if (ArrayUtils.contains(userIds, getUserId())) {
return error("当前用户不能删除");
}
@ -166,7 +167,7 @@ public class SysUserController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:user:resetPwd')")
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
@PutMapping("/resetPwd")
public Result resetPwd (@RequestBody SysUser user) {
public Result<String> resetPwd (@RequestBody SysUser user) {
userService.checkUserAllowed(user);
userService.checkUserDataScope(user.getUserId());
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
@ -180,7 +181,7 @@ public class SysUserController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:user:edit')")
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
@PutMapping("/changeStatus")
public Result changeStatus (@RequestBody SysUser user) {
public Result<String> changeStatus (@RequestBody SysUser user) {
userService.checkUserAllowed(user);
userService.checkUserDataScope(user.getUserId());
user.setUpdateBy(getUserId());
@ -192,7 +193,7 @@ public class SysUserController extends BaseController {
*/
@PreAuthorize("@ss.hasPermi('system:user:query')")
@GetMapping("/authRole/{userId}")
public Result authRole (@PathVariable("userId") Long userId) {
public Result<AuthRoleResp> authRole (@PathVariable("userId") Long userId) {
SysUser user = userService.selectUserById(userId);
List<SysRole> roles = roleService.selectRolesByUserId(userId);
return Result.success(
@ -209,10 +210,10 @@ public class SysUserController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:user:edit')")
@Log(title = "用户管理", businessType = BusinessType.GRANT)
@PutMapping("/authRole")
public Result insertAuthRole (Long userId, Long[] roleIds) {
public Result<String> insertAuthRole (Long userId, Long[] roleIds) {
userService.checkUserDataScope(userId);
userService.insertUserAuth(userId, roleIds);
return success();
return Result.success();
}
/**
@ -220,7 +221,7 @@ public class SysUserController extends BaseController {
*/
@PreAuthorize("@ss.hasPermi('system:user:list')")
@GetMapping("/deptTree")
public Result deptTree (SysDept dept) {
return success(deptService.selectDeptTreeList(dept));
public Result<List<TreeSelect>> deptTree (SysDept dept) {
return Result.success(deptService.selectDeptTreeList(dept));
}
}

View File

@ -16,7 +16,7 @@ import java.util.Map;
*
* @author ruoyi
*/
@Api("用户信息管理")
@Api(tags = "用户信息管理")
@RestController
@RequestMapping("/test/user")
public class TestController extends BaseController {

View File

@ -12,6 +12,7 @@ import com.ruoyi.common.utils.PageUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.sql.SqlUtil;
import org.apache.poi.ss.formula.functions.T;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.WebDataBinder;
@ -72,9 +73,9 @@ public class BaseController {
*
*/
@SuppressWarnings({"rawtypes", "unchecked"})
protected Result<TableDataInfo> getDataTable (List<?> list) {
protected <T> Result<TableDataInfo<T>> getDataTable (List<T> list) {
return Result.success(
TableDataInfo.builder()
TableDataInfo.<T>builder()
.total(new PageInfo(list).getTotal())
.rows(list)
.build()
@ -95,31 +96,18 @@ public class BaseController {
return Result.error();
}
/**
*
*/
public Result success (String message) {
return Result.success(message);
}
/**
*
*/
public Result success (Object data) {
return Result.success(data);
}
/**
*
*/
public Result error (String message) {
public Result<String> error (String message) {
return Result.error(message);
}
/**
*
*/
public Result warn (String message) {
public Result<String> warn (String message) {
return Result.warn(message);
}
@ -130,7 +118,7 @@ public class BaseController {
*
* @return
*/
protected Result toAjax (int rows) {
protected Result<String> toAjax (int rows) {
return rows > 0 ? Result.success() : Result.error();
}

View File

@ -17,7 +17,7 @@ import java.util.List;
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class TableDataInfo implements Serializable {
public class TableDataInfo<T> implements Serializable {
private static final long serialVersionUID = 1L;
/**
@ -28,7 +28,7 @@ public class TableDataInfo implements Serializable {
/**
*
*/
private List<?> rows;
private List<T> rows;
}

View File

@ -36,6 +36,8 @@ import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.ParameterizedType;
import java.math.BigDecimal;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.text.DecimalFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
@ -527,7 +529,7 @@ public class ExcelUtil<T> {
*
* @return
*/
public Result exportExcel (List<T> list, String sheetName) {
public Result<String> exportExcel (List<T> list, String sheetName) {
return exportExcel(list, sheetName, StringUtils.EMPTY);
}
@ -540,7 +542,7 @@ public class ExcelUtil<T> {
*
* @return
*/
public Result exportExcel (List<T> list, String sheetName, String title) {
public Result<String> exportExcel (List<T> list, String sheetName, String title) {
this.init(list, sheetName, title, Type.EXPORT);
return exportExcel();
}
@ -582,7 +584,7 @@ public class ExcelUtil<T> {
*
* @return
*/
public Result importTemplateExcel (String sheetName) {
public Result<String> importTemplateExcel (String sheetName) {
return importTemplateExcel(sheetName, StringUtils.EMPTY);
}
@ -594,7 +596,7 @@ public class ExcelUtil<T> {
*
* @return
*/
public Result importTemplateExcel (String sheetName, String title) {
public Result<String> importTemplateExcel (String sheetName, String title) {
this.init(null, sheetName, title, Type.IMPORT);
return exportExcel();
}
@ -646,12 +648,12 @@ public class ExcelUtil<T> {
*
* @return
*/
public Result exportExcel () {
public Result<String> exportExcel () {
OutputStream out = null;
try {
writeSheet();
String filename = encodingFilename(sheetName);
out = new FileOutputStream(getAbsoluteFile(filename));
out = Files.newOutputStream(Paths.get(getAbsoluteFile(filename)));
wb.write(out);
return Result.success(filename);
} catch (Exception e) {

View File

@ -17,6 +17,7 @@ import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException;
import javax.servlet.http.HttpServletRequest;
import java.util.Objects;
/**
*
@ -31,7 +32,7 @@ public class GlobalExceptionHandler {
*
*/
@ExceptionHandler(AccessDeniedException.class)
public Result handleAccessDeniedException (AccessDeniedException e, HttpServletRequest request) {
public Result<String> handleAccessDeniedException (AccessDeniedException e, HttpServletRequest request) {
String requestURI = request.getRequestURI();
log.error("请求地址'{}',权限校验失败'{}'", requestURI, e.getMessage());
return Result.error(HttpStatus.FORBIDDEN, "没有权限,请联系管理员授权");
@ -41,7 +42,7 @@ public class GlobalExceptionHandler {
*
*/
@ExceptionHandler(HttpRequestMethodNotSupportedException.class)
public Result handleHttpRequestMethodNotSupported (HttpRequestMethodNotSupportedException e,
public Result<String> handleHttpRequestMethodNotSupported (HttpRequestMethodNotSupportedException e,
HttpServletRequest request) {
String requestURI = request.getRequestURI();
log.error("请求地址'{}',不支持'{}'请求", requestURI, e.getMethod());
@ -52,17 +53,17 @@ public class GlobalExceptionHandler {
*
*/
@ExceptionHandler(ServiceException.class)
public Result handleServiceException (ServiceException e, HttpServletRequest request) {
public Result<String> 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) ? Result.error(code.intValue(), e.getMessage()) : Result.error(e.getMessage());
}
/**
*
*/
@ExceptionHandler(MissingPathVariableException.class)
public Result handleMissingPathVariableException (MissingPathVariableException e, HttpServletRequest request) {
public Result<String> handleMissingPathVariableException (MissingPathVariableException e, HttpServletRequest request) {
String requestURI = request.getRequestURI();
log.error("请求路径中缺少必需的路径变量'{}',发生系统异常.", requestURI, e);
return Result.error(String.format("请求路径中缺少必需的路径变量[%s]", e.getVariableName()));
@ -72,7 +73,7 @@ public class GlobalExceptionHandler {
*
*/
@ExceptionHandler(MethodArgumentTypeMismatchException.class)
public Result handleMethodArgumentTypeMismatchException (MethodArgumentTypeMismatchException e, HttpServletRequest request) {
public Result<String> handleMethodArgumentTypeMismatchException (MethodArgumentTypeMismatchException e, HttpServletRequest request) {
String requestURI = request.getRequestURI();
log.error("请求参数类型不匹配'{}',发生系统异常.", requestURI, e);
return Result.error(String.format("请求参数类型不匹配,参数[%s]要求类型为:'%s',但输入值为:'%s'", e.getName(), e.getRequiredType().getName(), e.getValue()));
@ -82,7 +83,7 @@ public class GlobalExceptionHandler {
*
*/
@ExceptionHandler(RuntimeException.class)
public Result handleRuntimeException (RuntimeException e, HttpServletRequest request) {
public Result<String> handleRuntimeException (RuntimeException e, HttpServletRequest request) {
String requestURI = request.getRequestURI();
log.error("请求地址'{}',发生未知异常.", requestURI, e);
return Result.error(e.getMessage());
@ -92,7 +93,7 @@ public class GlobalExceptionHandler {
*
*/
@ExceptionHandler(Exception.class)
public Result handleException (Exception e, HttpServletRequest request) {
public Result<String> handleException (Exception e, HttpServletRequest request) {
String requestURI = request.getRequestURI();
log.error("请求地址'{}',发生系统异常.", requestURI, e);
return Result.error(e.getMessage());
@ -102,7 +103,7 @@ public class GlobalExceptionHandler {
*
*/
@ExceptionHandler(BindException.class)
public Result handleBindException (BindException e) {
public Result<String> handleBindException (BindException e) {
log.error(e.getMessage(), e);
String message = e.getAllErrors().get(0).getDefaultMessage();
return Result.error(message);
@ -112,9 +113,10 @@ public class GlobalExceptionHandler {
*
*/
@ExceptionHandler(MethodArgumentNotValidException.class)
public Object handleMethodArgumentNotValidException (MethodArgumentNotValidException e) {
public Result<String> handleMethodArgumentNotValidException (MethodArgumentNotValidException e) {
log.error(e.getMessage(), e);
String message = e.getBindingResult().getFieldError().getDefaultMessage();
String message = Objects.requireNonNull(e.getBindingResult().getFieldError())
.getDefaultMessage();
return Result.error(message);
}
@ -122,7 +124,7 @@ public class GlobalExceptionHandler {
*
*/
@ExceptionHandler(DemoModeException.class)
public Result handleDemoModeException (DemoModeException e) {
public Result<String> handleDemoModeException (DemoModeException e) {
return Result.error("演示模式,不允许操作");
}
}

View File

@ -41,7 +41,7 @@ public class GenController extends BaseController {
*/
@PreAuthorize("@ss.hasPermi('tool:gen:list')")
@GetMapping("/list")
public Result<TableDataInfo> genList (GenTable genTable) {
public Result<TableDataInfo<GenTable>> genList (GenTable genTable) {
startPage();
List<GenTable> list = genTableService.selectGenTableList(genTable);
return getDataTable(list);
@ -52,7 +52,7 @@ public class GenController extends BaseController {
*/
@PreAuthorize("@ss.hasPermi('tool:gen:query')")
@GetMapping(value = "/{tableId}")
public Result getInfo (@PathVariable Long tableId) {
public Result<Map<String, Object>> getInfo (@PathVariable Long tableId) {
GenTable table = genTableService.selectGenTableById(tableId);
List<GenTable> tables = genTableService.selectGenTableAll();
List<GenTableColumn> list = genTableColumnService.selectGenTableColumnListByTableId(tableId);
@ -60,7 +60,7 @@ public class GenController extends BaseController {
map.put("info", table);
map.put("rows", list);
map.put("tables", tables);
return success(map);
return Result.success(map);
}
/**
@ -68,7 +68,7 @@ public class GenController extends BaseController {
*/
@PreAuthorize("@ss.hasPermi('tool:gen:list')")
@GetMapping("/db/list")
public Result<TableDataInfo> dataList (GenTable genTable) {
public Result<TableDataInfo<GenTable>> dataList (GenTable genTable) {
startPage();
List<GenTable> list = genTableService.selectDbTableList(genTable);
return getDataTable(list);
@ -93,12 +93,12 @@ public class GenController extends BaseController {
@PreAuthorize("@ss.hasPermi('tool:gen:import')")
@Log(title = "代码生成", businessType = BusinessType.IMPORT)
@PostMapping("/importTable")
public Result importTableSave (String tables) {
public Result<String> importTableSave (String tables) {
String[] tableNames = Convert.toStrArray(tables);
// 查询表信息
List<GenTable> tableList = genTableService.selectDbTableListByNames(tableNames);
genTableService.importGenTable(tableList);
return success();
return Result.success();
}
/**
@ -107,10 +107,10 @@ public class GenController extends BaseController {
@PreAuthorize("@ss.hasPermi('tool:gen:edit')")
@Log(title = "代码生成", businessType = BusinessType.UPDATE)
@PutMapping
public Result editSave (@Validated @RequestBody GenTable genTable) {
public Result<String> editSave (@Validated @RequestBody GenTable genTable) {
genTableService.validateEdit(genTable);
genTableService.updateGenTable(genTable);
return success();
return Result.success();
}
/**
@ -119,9 +119,9 @@ public class GenController extends BaseController {
@PreAuthorize("@ss.hasPermi('tool:gen:remove')")
@Log(title = "代码生成", businessType = BusinessType.DELETE)
@DeleteMapping("/{tableIds}")
public Result remove (@PathVariable Long[] tableIds) {
public Result<String> remove (@PathVariable Long[] tableIds) {
genTableService.deleteGenTableByIds(tableIds);
return success();
return Result.success();
}
/**
@ -129,9 +129,9 @@ public class GenController extends BaseController {
*/
@PreAuthorize("@ss.hasPermi('tool:gen:preview')")
@GetMapping("/preview/{tableId}")
public Result preview (@PathVariable("tableId") Long tableId) throws IOException {
public Result<Map<String, String>> preview (@PathVariable("tableId") Long tableId) throws IOException {
Map<String, String> dataMap = genTableService.previewCode(tableId);
return success(dataMap);
return Result.success(dataMap);
}
/**
@ -151,9 +151,9 @@ public class GenController extends BaseController {
@PreAuthorize("@ss.hasPermi('tool:gen:code')")
@Log(title = "代码生成", businessType = BusinessType.GENCODE)
@GetMapping("/genCode/{tableName}")
public Result genCode (@PathVariable("tableName") String tableName) {
public Result<String> genCode (@PathVariable("tableName") String tableName) {
genTableService.generatorCode(tableName);
return success();
return Result.success();
}
/**
@ -162,9 +162,9 @@ public class GenController extends BaseController {
@PreAuthorize("@ss.hasPermi('tool:gen:edit')")
@Log(title = "代码生成", businessType = BusinessType.UPDATE)
@GetMapping("/synchDb/{tableName}")
public Result synchDb (@PathVariable("tableName") String tableName) {
public Result<String> synchDb (@PathVariable("tableName") String tableName) {
genTableService.synchDb(tableName);
return success();
return Result.success();
}
/**

View File

@ -35,7 +35,7 @@ import com.ruoyi.common.core.page.TableDataInfo;
* @author ${author}
* @date ${datetime}
*/
@Api("${functionName}")
@Api(tags = "${functionName}")
@RestController
@RequestMapping("/${moduleName}/${businessName}")
public class ${ClassName}Controller extends BaseController {
@ -49,15 +49,15 @@ public class ${ClassName}Controller extends BaseController {
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:list')")
@GetMapping("/list")
#if($table.crud)
public Result<TableDataInfo> list(${ClassName}QueryReq ${className}QueryReq) {
public Result<TableDataInfo<${ClassName}>> list(${ClassName}QueryReq ${className}QueryReq) {
startPage();
List<${ClassName}> list = ${className}Service.list(${ClassName}.queryBuild(${className}QueryReq));
return getDataTable(list);
}
#elseif($table.tree)
public Result list(${ClassName} ${className}) {
public Result<List<${ClassName}>> list(${ClassName} ${className}) {
List<${ClassName}> list = ${className}Service.list(${className});
return success(list);
return Result.success(list);
}
#end
@ -81,8 +81,8 @@ public class ${ClassName}Controller extends BaseController {
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:query')")
@GetMapping(value = "/{${pkColumn.javaField}}")
@ApiImplicitParam(name = "${pkColumn.javaField}", value = "${pkColumn.javaField}", required = true, dataType = "${pkColumn.javaType}", paramType = "path", dataTypeClass = ${pkColumn.javaType}.class)
public Result getInfo(@PathVariable("${pkColumn.javaField}") ${pkColumn.javaType} ${pkColumn.javaField}) {
return success(${className}Service.getById(${pkColumn.javaField}));
public Result<${className}> getInfo(@PathVariable("${pkColumn.javaField}") ${pkColumn.javaType} ${pkColumn.javaField}) {
return Result.success(${className}Service.getById(${pkColumn.javaField}));
}
/**
@ -92,7 +92,7 @@ public class ${ClassName}Controller extends BaseController {
@Log(title = "${functionName}", businessType = BusinessType.INSERT)
@PostMapping
@ApiOperation("新增${functionName}")
public Result add(@RequestBody ${ClassName}SaveReq ${className}SaveReq) {
public Result<String> add(@RequestBody ${ClassName}SaveReq ${className}SaveReq) {
return toAjax(${className}Service.save(${ClassName}.saveBuild(${className}SaveReq)));
}
@ -103,7 +103,7 @@ public class ${ClassName}Controller extends BaseController {
@Log(title = "${functionName}", businessType = BusinessType.UPDATE)
@PutMapping("/{${pkColumn.javaField}}")
@ApiOperation("修改${functionName}")
public Result edit(@PathVariable ${pkColumn.javaType} ${pkColumn.javaField}, @RequestBody ${ClassName}EditReq ${className}EditReq) {
public Result<String> edit(@PathVariable ${pkColumn.javaType} ${pkColumn.javaField}, @RequestBody ${ClassName}EditReq ${className}EditReq) {
return toAjax(${className}Service.updateById(${ClassName}.editBuild(${pkColumn.javaField},${className}EditReq)));
}
@ -115,7 +115,7 @@ public class ${ClassName}Controller extends BaseController {
@DeleteMapping("/{${pkColumn.javaField}s}")
@ApiOperation("删除${functionName}")
@ApiImplicitParam(name = "${pkColumn.javaField}", value = "${pkColumn.javaField}", required = true, dataType = "${pkColumn.javaType}", paramType = "path", dataTypeClass = String.class, example = "1,2,3,4")
public Result remove(@PathVariable List<${pkColumn.javaType}> ${pkColumn.javaField}s) {
public Result<String> remove(@PathVariable List<${pkColumn.javaType}> ${pkColumn.javaField}s) {
return toAjax(${className}Service.removeBatchByIds(${pkColumn.javaField}s));
}
}

View File

@ -10,6 +10,7 @@ import com.ruoyi.common.exception.job.TaskException;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.quartz.domain.SysJob;
import com.ruoyi.quartz.domain.SysJobLog;
import com.ruoyi.quartz.service.SysJobService;
import com.ruoyi.quartz.util.CronUtils;
import com.ruoyi.quartz.util.ScheduleUtils;
@ -37,7 +38,7 @@ public class SysJobController extends BaseController {
*/
@PreAuthorize("@ss.hasPermi('monitor:job:list')")
@GetMapping("/list")
public Result<TableDataInfo> list (SysJob sysJob) {
public Result<TableDataInfo<SysJob>> list (SysJob sysJob) {
startPage();
List<SysJob> list = jobService.selectJobList(sysJob);
return getDataTable(list);
@ -60,8 +61,8 @@ public class SysJobController extends BaseController {
*/
@PreAuthorize("@ss.hasPermi('monitor:job:query')")
@GetMapping(value = "/{jobId}")
public Result getInfo (@PathVariable("jobId") Long jobId) {
return success(jobService.selectJobById(jobId));
public Result<SysJob> getInfo (@PathVariable("jobId") Long jobId) {
return Result.success(jobService.selectJobById(jobId));
}
/**
@ -70,7 +71,7 @@ public class SysJobController extends BaseController {
@PreAuthorize("@ss.hasPermi('monitor:job:add')")
@Log(title = "定时任务", businessType = BusinessType.INSERT)
@PostMapping
public Result add (@RequestBody SysJob job) throws SchedulerException, TaskException {
public Result<String> add (@RequestBody SysJob job) throws SchedulerException, TaskException {
if (!CronUtils.isValid(job.getCronExpression())) {
return error("新增任务'" + job.getJobName() + "'失败Cron表达式不正确");
} else if (StringUtils.containsIgnoreCase(job.getInvokeTarget(), Constants.LOOKUP_RMI)) {
@ -94,7 +95,7 @@ public class SysJobController extends BaseController {
@PreAuthorize("@ss.hasPermi('monitor:job:edit')")
@Log(title = "定时任务", businessType = BusinessType.UPDATE)
@PutMapping
public Result edit (@RequestBody SysJob job) throws SchedulerException, TaskException {
public Result<String> edit (@RequestBody SysJob job) throws SchedulerException, TaskException {
if (!CronUtils.isValid(job.getCronExpression())) {
return error("修改任务'" + job.getJobName() + "'失败Cron表达式不正确");
} else if (StringUtils.containsIgnoreCase(job.getInvokeTarget(), Constants.LOOKUP_RMI)) {
@ -118,7 +119,7 @@ public class SysJobController extends BaseController {
@PreAuthorize("@ss.hasPermi('monitor:job:changeStatus')")
@Log(title = "定时任务", businessType = BusinessType.UPDATE)
@PutMapping("/changeStatus")
public Result changeStatus (@RequestBody SysJob job) throws SchedulerException {
public Result<String> changeStatus (@RequestBody SysJob job) throws SchedulerException {
SysJob newJob = jobService.selectJobById(job.getJobId());
newJob.setStatus(job.getStatus());
return toAjax(jobService.changeStatus(newJob));
@ -130,7 +131,7 @@ public class SysJobController extends BaseController {
@PreAuthorize("@ss.hasPermi('monitor:job:changeStatus')")
@Log(title = "定时任务", businessType = BusinessType.UPDATE)
@PutMapping("/run")
public Result run (@RequestBody SysJob job) throws SchedulerException {
public Result<String> run (@RequestBody SysJob job) throws SchedulerException {
boolean result = jobService.run(job);
return result ? success() : error("任务不存在或已过期!");
}
@ -141,8 +142,8 @@ public class SysJobController extends BaseController {
@PreAuthorize("@ss.hasPermi('monitor:job:remove')")
@Log(title = "定时任务", businessType = BusinessType.DELETE)
@DeleteMapping("/{jobIds}")
public Result remove (@PathVariable Long[] jobIds) throws SchedulerException, TaskException {
public Result<String> remove (@PathVariable Long[] jobIds) throws SchedulerException, TaskException {
jobService.deleteJobByIds(jobIds);
return success();
return Result.success();
}
}

View File

@ -31,7 +31,7 @@ public class SysJobLogController extends BaseController {
*/
@PreAuthorize("@ss.hasPermi('monitor:job:list')")
@GetMapping("/list")
public Result<TableDataInfo> list (SysJobLog sysJobLog) {
public Result<TableDataInfo<SysJobLog>> list (SysJobLog sysJobLog) {
startPage();
List<SysJobLog> list = jobLogService.selectJobLogList(sysJobLog);
return getDataTable(list);
@ -54,8 +54,8 @@ public class SysJobLogController extends BaseController {
*/
@PreAuthorize("@ss.hasPermi('monitor:job:query')")
@GetMapping(value = "/{jobLogId}")
public Result getInfo (@PathVariable Long jobLogId) {
return success(jobLogService.selectJobLogById(jobLogId));
public Result<SysJobLog> getInfo (@PathVariable Long jobLogId) {
return Result.success(jobLogService.selectJobLogById(jobLogId));
}
@ -65,7 +65,7 @@ public class SysJobLogController extends BaseController {
@PreAuthorize("@ss.hasPermi('monitor:job:remove')")
@Log(title = "定时任务调度日志", businessType = BusinessType.DELETE)
@DeleteMapping("/{jobLogIds}")
public Result remove (@PathVariable Long[] jobLogIds) {
public Result<String> remove (@PathVariable Long[] jobLogIds) {
return toAjax(jobLogService.deleteJobLogByIds(jobLogIds));
}
@ -75,8 +75,8 @@ public class SysJobLogController extends BaseController {
@PreAuthorize("@ss.hasPermi('monitor:job:remove')")
@Log(title = "调度日志", businessType = BusinessType.CLEAN)
@DeleteMapping("/clean")
public Result clean () {
public Result<String> clean () {
jobLogService.cleanJobLog();
return success();
return Result.success();
}
}