Search in sources :

Example 1 with AjaxResult

use of com.dimple.framework.web.domain.AjaxResult in project DimpleBlog by martin-chips.

the class LoginController method getInfo.

/**
 * 获取用户信息
 *
 * @return 用户信息
 */
@GetMapping("getInfo")
public AjaxResult getInfo() {
    LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
    SysUser user = loginUser.getUser();
    // 角色集合
    Set<String> roles = permissionService.getRolePermission(user);
    // 权限集合
    Set<String> permissions = permissionService.getMenuPermission(user);
    AjaxResult ajax = AjaxResult.success();
    ajax.put("user", user);
    ajax.put("roles", roles);
    ajax.put("permissions", permissions);
    return ajax;
}
Also used : AjaxResult(com.dimple.framework.web.domain.AjaxResult) SysUser(com.dimple.project.system.domain.SysUser) LoginUser(com.dimple.framework.security.LoginUser) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 2 with AjaxResult

use of com.dimple.framework.web.domain.AjaxResult in project DimpleBlog by martin-chips.

the class LoginController method login.

/**
 * 登录方法
 *
 * @param username 用户名
 * @param password 密码
 * @param code     验证码
 * @param uuid     唯一标识
 * @return 结果
 */
@PostMapping("/login")
public AjaxResult login(String username, String password, String code, String uuid) {
    AjaxResult ajax = AjaxResult.success();
    // 生成令牌
    String token = loginService.login(username, password, code, uuid);
    ajax.put(Constants.TOKEN, token);
    return ajax;
}
Also used : AjaxResult(com.dimple.framework.web.domain.AjaxResult) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 3 with AjaxResult

use of com.dimple.framework.web.domain.AjaxResult in project DimpleBlog by martin-chips.

the class MenuController method roleMenuTreeselect.

/**
 * 加载对应角色菜单列表树
 */
@PreAuthorize("@permissionService.hasPermission('system:menu:query')")
@GetMapping(value = "/roleMenuTreeselect/{roleId}")
@ResponseBody
public AjaxResult roleMenuTreeselect(@PathVariable Long roleId) {
    List<Menu> menus = menuService.selectMenuList(new Menu());
    AjaxResult ajax = AjaxResult.success();
    ajax.put("checkedKeys", menuService.selectMenuListByRoleId(roleId));
    ajax.put("menus", menuService.buildMenuTreeSelect(menus));
    return ajax;
}
Also used : AjaxResult(com.dimple.framework.web.domain.AjaxResult) Menu(com.dimple.project.system.domain.Menu) GetMapping(org.springframework.web.bind.annotation.GetMapping) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 4 with AjaxResult

use of com.dimple.framework.web.domain.AjaxResult in project DimpleBlog by martin-chips.

the class ProfileController method profile.

/**
 * 个人信息
 */
@GetMapping
public AjaxResult profile() {
    LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
    SysUser user = loginUser.getUser();
    AjaxResult ajax = AjaxResult.success(user);
    ajax.put("roleGroup", userService.selectUserRoleGroup(loginUser.getUsername()));
    return ajax;
}
Also used : AjaxResult(com.dimple.framework.web.domain.AjaxResult) SysUser(com.dimple.project.system.domain.SysUser) LoginUser(com.dimple.framework.security.LoginUser) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 5 with AjaxResult

use of com.dimple.framework.web.domain.AjaxResult in project DimpleBlog by martin-chips.

the class UserController method getInfo.

/**
 * 根据用户编号获取详细信息
 */
@PreAuthorize("@permissionService.hasPermission('system:user:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable Long id) {
    AjaxResult ajax = AjaxResult.success(userService.selectUserById(id));
    ajax.put("roleIds", roleService.selectRoleListByUserId(id));
    return ajax;
}
Also used : AjaxResult(com.dimple.framework.web.domain.AjaxResult) GetMapping(org.springframework.web.bind.annotation.GetMapping) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Aggregations

AjaxResult (com.dimple.framework.web.domain.AjaxResult)6 GetMapping (org.springframework.web.bind.annotation.GetMapping)5 LoginUser (com.dimple.framework.security.LoginUser)2 SysUser (com.dimple.project.system.domain.SysUser)2 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)2 Menu (com.dimple.project.system.domain.Menu)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 PostMapping (org.springframework.web.bind.annotation.PostMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1