mirror of
https://github.com/dromara/RuoYi-Vue-Plus.git
synced 2025-09-24 07:19:46 +08:00
update 请求响应对象 与 分页对象 结构修改 适配接口文档配置
This commit is contained in:
@ -19,6 +19,8 @@ import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
@ -88,10 +90,10 @@ public class CaptchaController {
|
||||
code = captcha.getCode();
|
||||
}
|
||||
redisCache.setCacheObject(verifyKey, code, Constants.CAPTCHA_EXPIRATION, TimeUnit.MINUTES);
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
Map<String,Object> ajax = new HashMap<>();
|
||||
ajax.put("uuid", uuid);
|
||||
ajax.put("img", captcha.getImageBase64());
|
||||
return ajax;
|
||||
return AjaxResult.success(ajax);
|
||||
}
|
||||
|
||||
private String getCodeResult(String capStr) {
|
||||
|
@ -18,10 +18,12 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 通用请求处理
|
||||
*
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@RestController
|
||||
@ -34,7 +36,7 @@ public class CommonController
|
||||
|
||||
/**
|
||||
* 通用下载请求
|
||||
*
|
||||
*
|
||||
* @param fileName 文件名称
|
||||
* @param delete 是否删除
|
||||
*/
|
||||
@ -77,10 +79,10 @@ public class CommonController
|
||||
// 上传并返回新文件名称
|
||||
String fileName = FileUploadUtils.upload(filePath, file);
|
||||
String url = serverConfig.getUrl() + fileName;
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
Map<String,Object> ajax = new HashMap<>();
|
||||
ajax.put("fileName", fileName);
|
||||
ajax.put("url", url);
|
||||
return ajax;
|
||||
return AjaxResult.success(ajax);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -15,12 +15,14 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 部门信息
|
||||
*
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@RestController
|
||||
@ -89,10 +91,10 @@ public class SysDeptController extends BaseController
|
||||
public AjaxResult roleDeptTreeselect(@PathVariable("roleId") Long roleId)
|
||||
{
|
||||
List<SysDept> depts = deptService.selectDeptList(new SysDept());
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
Map<String,Object> ajax = new HashMap<>();
|
||||
ajax.put("checkedKeys", deptService.selectDeptListByRoleId(roleId));
|
||||
ajax.put("depts", deptService.buildDeptTreeSelect(depts));
|
||||
return ajax;
|
||||
return AjaxResult.success(ajax);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -17,12 +17,14 @@ import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 登录验证
|
||||
*
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@RestController
|
||||
@ -42,24 +44,24 @@ public class SysLoginController
|
||||
|
||||
/**
|
||||
* 登录方法
|
||||
*
|
||||
*
|
||||
* @param loginBody 登录信息
|
||||
* @return 结果
|
||||
*/
|
||||
@PostMapping("/login")
|
||||
public AjaxResult login(@RequestBody LoginBody loginBody)
|
||||
{
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
Map<String,Object> ajax = new HashMap<>();
|
||||
// 生成令牌
|
||||
String token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(),
|
||||
loginBody.getUuid());
|
||||
ajax.put(Constants.TOKEN, token);
|
||||
return ajax;
|
||||
return AjaxResult.success(ajax);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户信息
|
||||
*
|
||||
*
|
||||
* @return 用户信息
|
||||
*/
|
||||
@GetMapping("getInfo")
|
||||
@ -71,16 +73,16 @@ public class SysLoginController
|
||||
Set<String> roles = permissionService.getRolePermission(user);
|
||||
// 权限集合
|
||||
Set<String> permissions = permissionService.getMenuPermission(user);
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
Map<String,Object> ajax = new HashMap<>();
|
||||
ajax.put("user", user);
|
||||
ajax.put("roles", roles);
|
||||
ajax.put("permissions", permissions);
|
||||
return ajax;
|
||||
return AjaxResult.success(ajax);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取路由信息
|
||||
*
|
||||
*
|
||||
* @return 路由信息
|
||||
*/
|
||||
@GetMapping("getRouters")
|
||||
|
@ -18,11 +18,13 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 菜单信息
|
||||
*
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@RestController
|
||||
@ -78,10 +80,10 @@ public class SysMenuController extends BaseController
|
||||
{
|
||||
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
||||
List<SysMenu> menus = menuService.selectMenuList(loginUser.getUser().getUserId());
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
Map<String,Object> ajax = new HashMap<>();
|
||||
ajax.put("checkedKeys", menuService.selectMenuListByRoleId(roleId));
|
||||
ajax.put("menus", menuService.buildMenuTreeSelect(menus));
|
||||
return ajax;
|
||||
return AjaxResult.success(ajax);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -148,4 +150,4 @@ public class SysMenuController extends BaseController
|
||||
}
|
||||
return toAjax(menuService.deleteMenuById(menuId));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,10 +19,12 @@ import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 个人信息 业务处理
|
||||
*
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@RestController
|
||||
@ -43,10 +45,11 @@ public class SysProfileController extends BaseController
|
||||
{
|
||||
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
||||
SysUser user = loginUser.getUser();
|
||||
AjaxResult ajax = AjaxResult.success(user);
|
||||
Map<String,Object> ajax = new HashMap<>();
|
||||
ajax.put("user", user);
|
||||
ajax.put("roleGroup", userService.selectUserRoleGroup(loginUser.getUsername()));
|
||||
ajax.put("postGroup", userService.selectUserPostGroup(loginUser.getUsername()));
|
||||
return ajax;
|
||||
return AjaxResult.success(ajax);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -121,12 +124,12 @@ public class SysProfileController extends BaseController
|
||||
String avatar = FileUploadUtils.upload(RuoYiConfig.getAvatarPath(), file);
|
||||
if (userService.updateUserAvatar(loginUser.getUsername(), avatar))
|
||||
{
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
Map<String,Object> ajax = new HashMap<>();
|
||||
ajax.put("imgUrl", avatar);
|
||||
// 更新缓存用户头像
|
||||
loginUser.getUser().setAvatar(avatar);
|
||||
tokenService.setLoginUser(loginUser);
|
||||
return ajax;
|
||||
return AjaxResult.success(ajax);
|
||||
}
|
||||
}
|
||||
return AjaxResult.error("上传图片异常,请联系管理员");
|
||||
|
@ -23,12 +23,14 @@ import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 用户信息
|
||||
*
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@RestController
|
||||
@ -94,17 +96,17 @@ public class SysUserController extends BaseController
|
||||
@GetMapping(value = { "/", "/{userId}" })
|
||||
public AjaxResult getInfo(@PathVariable(value = "userId", required = false) Long userId)
|
||||
{
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
Map<String, Object> ajax = new HashMap<>();
|
||||
List<SysRole> roles = roleService.selectRoleAll();
|
||||
ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
|
||||
ajax.put("posts", postService.selectPostAll());
|
||||
if (Validator.isNotNull(userId))
|
||||
{
|
||||
ajax.put(AjaxResult.DATA_TAG, userService.selectUserById(userId));
|
||||
ajax.put("user", userService.selectUserById(userId));
|
||||
ajax.put("postIds", postService.selectPostListByUserId(userId));
|
||||
ajax.put("roleIds", roleService.selectRoleListByUserId(userId));
|
||||
}
|
||||
return ajax;
|
||||
return AjaxResult.success(ajax);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user