Search in sources :

Example 46 with SysUser

use of com.ruoyi.common.core.domain.entity.SysUser in project RuoYi-Vue-Plus by JavaLionLi.

the class SysProfileController method profile.

/**
 * 个人信息
 */
@ApiOperation("个人信息")
@GetMapping
public R<Map<String, Object>> profile() {
    SysUser user = userService.selectUserById(getUserId());
    Map<String, Object> ajax = new HashMap<>();
    ajax.put("user", user);
    ajax.put("roleGroup", userService.selectUserRoleGroup(user.getUserName()));
    ajax.put("postGroup", userService.selectUserPostGroup(user.getUserName()));
    return R.ok(ajax);
}
Also used : SysUser(com.ruoyi.common.core.domain.entity.SysUser) HashMap(java.util.HashMap) ApiOperation(io.swagger.annotations.ApiOperation)

Example 47 with SysUser

use of com.ruoyi.common.core.domain.entity.SysUser in project RuoYi-Vue-Plus by JavaLionLi.

the class SysProfileController method updatePwd.

/**
 * 重置密码
 */
@ApiOperation("重置密码")
@ApiImplicitParams({ @ApiImplicitParam(name = "oldPassword", value = "旧密码", paramType = "query", dataTypeClass = String.class), @ApiImplicitParam(name = "newPassword", value = "新密码", paramType = "query", dataTypeClass = String.class) })
@Log(title = "个人信息", businessType = BusinessType.UPDATE)
@PutMapping("/updatePwd")
public R<Void> updatePwd(String oldPassword, String newPassword) {
    SysUser user = userService.selectUserById(LoginHelper.getUserId());
    String userName = user.getUserName();
    String password = user.getPassword();
    if (!BCrypt.checkpw(oldPassword, password)) {
        return R.fail("修改密码失败,旧密码错误");
    }
    if (BCrypt.checkpw(newPassword, password)) {
        return R.fail("新密码不能与旧密码相同");
    }
    if (userService.resetUserPwd(userName, BCrypt.hashpw(newPassword)) > 0) {
        return R.ok();
    }
    return R.fail("修改密码异常,请联系管理员");
}
Also used : SysUser(com.ruoyi.common.core.domain.entity.SysUser) ApiImplicitParams(io.swagger.annotations.ApiImplicitParams) Log(com.ruoyi.common.annotation.Log) ApiOperation(io.swagger.annotations.ApiOperation)

Example 48 with SysUser

use of com.ruoyi.common.core.domain.entity.SysUser in project RuoYi-Vue-Plus by JavaLionLi.

the class SysUserController method export.

@ApiOperation("导出用户列表")
@Log(title = "用户管理", businessType = BusinessType.EXPORT)
@SaCheckPermission("system:user:export")
@PostMapping("/export")
public void export(SysUser user, HttpServletResponse response) {
    List<SysUser> list = userService.selectUserList(user);
    List<SysUserExportVo> listVo = BeanUtil.copyToList(list, SysUserExportVo.class);
    for (int i = 0; i < list.size(); i++) {
        SysDept dept = list.get(i).getDept();
        SysUserExportVo vo = listVo.get(i);
        if (ObjectUtil.isNotEmpty(dept)) {
            vo.setDeptName(dept.getDeptName());
            vo.setLeader(dept.getLeader());
        }
    }
    ExcelUtil.exportExcel(listVo, "用户数据", SysUserExportVo.class, response);
}
Also used : SysUser(com.ruoyi.common.core.domain.entity.SysUser) SysDept(com.ruoyi.common.core.domain.entity.SysDept) SysUserExportVo(com.ruoyi.system.domain.vo.SysUserExportVo) Log(com.ruoyi.common.annotation.Log) SaCheckPermission(cn.dev33.satoken.annotation.SaCheckPermission)

Example 49 with SysUser

use of com.ruoyi.common.core.domain.entity.SysUser in project RuoYi-Vue-Plus by JavaLionLi.

the class SysUserController method getInfo.

/**
 * 根据用户编号获取详细信息
 */
@ApiOperation("根据用户编号获取详细信息")
@SaCheckPermission("system:user:query")
@GetMapping(value = { "/", "/{userId}" })
public R<Map<String, Object>> getInfo(@ApiParam("用户ID") @PathVariable(value = "userId", required = false) Long userId) {
    userService.checkUserDataScope(userId);
    Map<String, Object> ajax = new HashMap<>();
    List<SysRole> roles = roleService.selectRoleAll();
    ajax.put("roles", LoginHelper.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
    ajax.put("posts", postService.selectPostAll());
    if (ObjectUtil.isNotNull(userId)) {
        SysUser sysUser = userService.selectUserById(userId);
        ajax.put("user", sysUser);
        ajax.put("postIds", postService.selectPostListByUserId(userId));
        ajax.put("roleIds", sysUser.getRoles().stream().map(SysRole::getRoleId).collect(Collectors.toList()));
    }
    return R.ok(ajax);
}
Also used : R(com.ruoyi.common.core.domain.R) SysDept(com.ruoyi.common.core.domain.entity.SysDept) SysUser(com.ruoyi.common.core.domain.entity.SysUser) TableDataInfo(com.ruoyi.common.core.page.TableDataInfo) SysUserImportListener(com.ruoyi.system.listener.SysUserImportListener) BCrypt(cn.dev33.satoken.secure.BCrypt) ObjectUtil(cn.hutool.core.util.ObjectUtil) RequiredArgsConstructor(lombok.RequiredArgsConstructor) HashMap(java.util.HashMap) BeanUtil(cn.hutool.core.bean.BeanUtil) PageQuery(com.ruoyi.common.core.domain.PageQuery) ArrayList(java.util.ArrayList) SysUserExportVo(com.ruoyi.system.domain.vo.SysUserExportVo) StringUtils(com.ruoyi.common.utils.StringUtils) Map(java.util.Map) ISysRoleService(com.ruoyi.system.service.ISysRoleService) io.swagger.annotations(io.swagger.annotations) BaseController(com.ruoyi.common.core.controller.BaseController) SysUserImportVo(com.ruoyi.system.domain.vo.SysUserImportVo) Validated(org.springframework.validation.annotation.Validated) HttpServletResponse(javax.servlet.http.HttpServletResponse) LoginHelper(com.ruoyi.common.helper.LoginHelper) Collectors(java.util.stream.Collectors) BusinessType(com.ruoyi.common.enums.BusinessType) ISysUserService(com.ruoyi.system.service.ISysUserService) List(java.util.List) UserConstants(com.ruoyi.common.constant.UserConstants) Log(com.ruoyi.common.annotation.Log) ExcelUtil(com.ruoyi.common.utils.poi.ExcelUtil) ArrayUtil(cn.hutool.core.util.ArrayUtil) org.springframework.web.bind.annotation(org.springframework.web.bind.annotation) MultipartFile(org.springframework.web.multipart.MultipartFile) SysRole(com.ruoyi.common.core.domain.entity.SysRole) ISysPostService(com.ruoyi.system.service.ISysPostService) SaCheckPermission(cn.dev33.satoken.annotation.SaCheckPermission) ExcelResult(com.ruoyi.common.excel.ExcelResult) SysUser(com.ruoyi.common.core.domain.entity.SysUser) HashMap(java.util.HashMap) SysRole(com.ruoyi.common.core.domain.entity.SysRole) SaCheckPermission(cn.dev33.satoken.annotation.SaCheckPermission)

Example 50 with SysUser

use of com.ruoyi.common.core.domain.entity.SysUser in project RuoYi-Vue-Plus by JavaLionLi.

the class SysUserController method authRole.

/**
 * 根据用户编号获取授权角色
 */
@ApiOperation("根据用户编号获取授权角色")
@SaCheckPermission("system:user:query")
@GetMapping("/authRole/{userId}")
public R<Map<String, Object>> authRole(@ApiParam("用户ID") @PathVariable("userId") Long userId) {
    SysUser user = userService.selectUserById(userId);
    List<SysRole> roles = roleService.selectRolesByUserId(userId);
    Map<String, Object> ajax = new HashMap<>();
    ajax.put("user", user);
    ajax.put("roles", LoginHelper.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
    return R.ok(ajax);
}
Also used : R(com.ruoyi.common.core.domain.R) SysDept(com.ruoyi.common.core.domain.entity.SysDept) SysUser(com.ruoyi.common.core.domain.entity.SysUser) TableDataInfo(com.ruoyi.common.core.page.TableDataInfo) SysUserImportListener(com.ruoyi.system.listener.SysUserImportListener) BCrypt(cn.dev33.satoken.secure.BCrypt) ObjectUtil(cn.hutool.core.util.ObjectUtil) RequiredArgsConstructor(lombok.RequiredArgsConstructor) HashMap(java.util.HashMap) BeanUtil(cn.hutool.core.bean.BeanUtil) PageQuery(com.ruoyi.common.core.domain.PageQuery) ArrayList(java.util.ArrayList) SysUserExportVo(com.ruoyi.system.domain.vo.SysUserExportVo) StringUtils(com.ruoyi.common.utils.StringUtils) Map(java.util.Map) ISysRoleService(com.ruoyi.system.service.ISysRoleService) io.swagger.annotations(io.swagger.annotations) BaseController(com.ruoyi.common.core.controller.BaseController) SysUserImportVo(com.ruoyi.system.domain.vo.SysUserImportVo) Validated(org.springframework.validation.annotation.Validated) HttpServletResponse(javax.servlet.http.HttpServletResponse) LoginHelper(com.ruoyi.common.helper.LoginHelper) Collectors(java.util.stream.Collectors) BusinessType(com.ruoyi.common.enums.BusinessType) ISysUserService(com.ruoyi.system.service.ISysUserService) List(java.util.List) UserConstants(com.ruoyi.common.constant.UserConstants) Log(com.ruoyi.common.annotation.Log) ExcelUtil(com.ruoyi.common.utils.poi.ExcelUtil) ArrayUtil(cn.hutool.core.util.ArrayUtil) org.springframework.web.bind.annotation(org.springframework.web.bind.annotation) MultipartFile(org.springframework.web.multipart.MultipartFile) SysRole(com.ruoyi.common.core.domain.entity.SysRole) ISysPostService(com.ruoyi.system.service.ISysPostService) SaCheckPermission(cn.dev33.satoken.annotation.SaCheckPermission) ExcelResult(com.ruoyi.common.excel.ExcelResult) SysUser(com.ruoyi.common.core.domain.entity.SysUser) HashMap(java.util.HashMap) SysRole(com.ruoyi.common.core.domain.entity.SysRole) SaCheckPermission(cn.dev33.satoken.annotation.SaCheckPermission)

Aggregations

SysUser (com.ruoyi.common.core.domain.entity.SysUser)78 Log (com.ruoyi.common.annotation.Log)16 SysRole (com.ruoyi.common.core.domain.entity.SysRole)13 LoginUser (com.ruoyi.common.core.domain.model.LoginUser)13 GetMapping (org.springframework.web.bind.annotation.GetMapping)11 AjaxResult (com.ruoyi.common.core.domain.AjaxResult)10 ServiceException (com.ruoyi.common.exception.ServiceException)10 SaCheckPermission (cn.dev33.satoken.annotation.SaCheckPermission)8 ExcelUtil (com.ruoyi.common.utils.poi.ExcelUtil)8 Transactional (org.springframework.transaction.annotation.Transactional)8 UserConstants (com.ruoyi.common.constant.UserConstants)7 BaseController (com.ruoyi.common.core.controller.BaseController)7 TableDataInfo (com.ruoyi.common.core.page.TableDataInfo)7 BusinessType (com.ruoyi.common.enums.BusinessType)7 StringUtils (com.ruoyi.common.utils.StringUtils)7 ISysPostService (com.ruoyi.system.service.ISysPostService)7 ISysRoleService (com.ruoyi.system.service.ISysRoleService)7 ISysUserService (com.ruoyi.system.service.ISysUserService)7 List (java.util.List)7 Collectors (java.util.stream.Collectors)7