Search in sources :

Example 31 with SysUser

use of com.ruoyi.system.api.domain.SysUser in project RuoYi-Cloud-Plus by JavaLionLi.

the class SysProfileController method profile.

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

Example 32 with SysUser

use of com.ruoyi.system.api.domain.SysUser in project RuoYi-Cloud-Plus by JavaLionLi.

the class SysUserController method getInfo.

/**
 * 根据用户编号获取详细信息
 */
@ApiOperation("根据用户编号获取详细信息")
@SaCheckPermission("system:user:query")
@GetMapping(value = { "/", "/{userId}" })
public R<Map<String, Object>> getInfo(@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) Log(com.ruoyi.common.log.annotation.Log) SysRole(com.ruoyi.system.api.domain.SysRole) java.util(java.util) SysUserImportListener(com.ruoyi.system.listener.SysUserImportListener) BCrypt(cn.dev33.satoken.secure.BCrypt) ObjectUtil(cn.hutool.core.util.ObjectUtil) RequiredArgsConstructor(lombok.RequiredArgsConstructor) ArrayUtils(org.apache.commons.lang3.ArrayUtils) BeanUtil(cn.hutool.core.bean.BeanUtil) TableDataInfo(com.ruoyi.common.mybatis.core.page.TableDataInfo) LoginHelper(com.ruoyi.common.satoken.utils.LoginHelper) ApiOperation(io.swagger.annotations.ApiOperation) BaseController(com.ruoyi.common.core.web.controller.BaseController) ExcelUtil(com.ruoyi.common.excel.utils.ExcelUtil) SysUserExportVo(com.ruoyi.system.domain.vo.SysUserExportVo) ISysRoleService(com.ruoyi.system.service.ISysRoleService) SysDept(com.ruoyi.system.api.domain.SysDept) Api(io.swagger.annotations.Api) BusinessType(com.ruoyi.common.log.enums.BusinessType) ISysPermissionService(com.ruoyi.system.service.ISysPermissionService) SysUserImportVo(com.ruoyi.system.domain.vo.SysUserImportVo) Validated(org.springframework.validation.annotation.Validated) ApiImplicitParam(io.swagger.annotations.ApiImplicitParam) HttpServletResponse(javax.servlet.http.HttpServletResponse) IOException(java.io.IOException) StringUtils(com.ruoyi.common.core.utils.StringUtils) SysUser(com.ruoyi.system.api.domain.SysUser) Collectors(java.util.stream.Collectors) ISysUserService(com.ruoyi.system.service.ISysUserService) ExcelResult(com.ruoyi.common.excel.core.ExcelResult) org.springframework.web.bind.annotation(org.springframework.web.bind.annotation) MultipartFile(org.springframework.web.multipart.MultipartFile) UserConstants(com.ruoyi.common.core.constant.UserConstants) ISysPostService(com.ruoyi.system.service.ISysPostService) PageQuery(com.ruoyi.common.mybatis.core.page.PageQuery) ApiImplicitParams(io.swagger.annotations.ApiImplicitParams) SaCheckPermission(cn.dev33.satoken.annotation.SaCheckPermission) SysUser(com.ruoyi.system.api.domain.SysUser) SysRole(com.ruoyi.system.api.domain.SysRole) ApiOperation(io.swagger.annotations.ApiOperation) SaCheckPermission(cn.dev33.satoken.annotation.SaCheckPermission)

Example 33 with SysUser

use of com.ruoyi.system.api.domain.SysUser in project RuoYi-Cloud-Plus by JavaLionLi.

the class SysUserController method export.

@ApiOperation("导出用户列表")
@Log(title = "用户管理", businessType = BusinessType.EXPORT)
@SaCheckPermission("system:user:export")
@PostMapping("/export")
public void export(HttpServletResponse response, SysUser user) {
    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.system.api.domain.SysUser) SysDept(com.ruoyi.system.api.domain.SysDept) SysUserExportVo(com.ruoyi.system.domain.vo.SysUserExportVo) Log(com.ruoyi.common.log.annotation.Log) ApiOperation(io.swagger.annotations.ApiOperation) SaCheckPermission(cn.dev33.satoken.annotation.SaCheckPermission)

Example 34 with SysUser

use of com.ruoyi.system.api.domain.SysUser in project RuoYi-Cloud-Plus by JavaLionLi.

the class SysUserController method authRole.

/**
 * 根据用户编号获取授权角色
 */
@ApiOperation("根据用户编号获取授权角色")
@SaCheckPermission("system:user:query")
@GetMapping("/authRole/{userId}")
public R<Map<String, Object>> authRole(@PathVariable("userId") Long userId) {
    Map<String, Object> ajax = new HashMap<>();
    SysUser user = userService.selectUserById(userId);
    List<SysRole> roles = roleService.selectRolesByUserId(userId);
    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) Log(com.ruoyi.common.log.annotation.Log) SysRole(com.ruoyi.system.api.domain.SysRole) java.util(java.util) SysUserImportListener(com.ruoyi.system.listener.SysUserImportListener) BCrypt(cn.dev33.satoken.secure.BCrypt) ObjectUtil(cn.hutool.core.util.ObjectUtil) RequiredArgsConstructor(lombok.RequiredArgsConstructor) ArrayUtils(org.apache.commons.lang3.ArrayUtils) BeanUtil(cn.hutool.core.bean.BeanUtil) TableDataInfo(com.ruoyi.common.mybatis.core.page.TableDataInfo) LoginHelper(com.ruoyi.common.satoken.utils.LoginHelper) ApiOperation(io.swagger.annotations.ApiOperation) BaseController(com.ruoyi.common.core.web.controller.BaseController) ExcelUtil(com.ruoyi.common.excel.utils.ExcelUtil) SysUserExportVo(com.ruoyi.system.domain.vo.SysUserExportVo) ISysRoleService(com.ruoyi.system.service.ISysRoleService) SysDept(com.ruoyi.system.api.domain.SysDept) Api(io.swagger.annotations.Api) BusinessType(com.ruoyi.common.log.enums.BusinessType) ISysPermissionService(com.ruoyi.system.service.ISysPermissionService) SysUserImportVo(com.ruoyi.system.domain.vo.SysUserImportVo) Validated(org.springframework.validation.annotation.Validated) ApiImplicitParam(io.swagger.annotations.ApiImplicitParam) HttpServletResponse(javax.servlet.http.HttpServletResponse) IOException(java.io.IOException) StringUtils(com.ruoyi.common.core.utils.StringUtils) SysUser(com.ruoyi.system.api.domain.SysUser) Collectors(java.util.stream.Collectors) ISysUserService(com.ruoyi.system.service.ISysUserService) ExcelResult(com.ruoyi.common.excel.core.ExcelResult) org.springframework.web.bind.annotation(org.springframework.web.bind.annotation) MultipartFile(org.springframework.web.multipart.MultipartFile) UserConstants(com.ruoyi.common.core.constant.UserConstants) ISysPostService(com.ruoyi.system.service.ISysPostService) PageQuery(com.ruoyi.common.mybatis.core.page.PageQuery) ApiImplicitParams(io.swagger.annotations.ApiImplicitParams) SaCheckPermission(cn.dev33.satoken.annotation.SaCheckPermission) SysUser(com.ruoyi.system.api.domain.SysUser) SysRole(com.ruoyi.system.api.domain.SysRole) ApiOperation(io.swagger.annotations.ApiOperation) SaCheckPermission(cn.dev33.satoken.annotation.SaCheckPermission)

Example 35 with SysUser

use of com.ruoyi.system.api.domain.SysUser in project RuoYi-Cloud-Plus by JavaLionLi.

the class SysUserServiceImpl method deleteUserByIds.

/**
 * 批量删除用户信息
 *
 * @param userIds 需要删除的用户ID
 * @return 结果
 */
@Override
@Transactional(rollbackFor = Exception.class)
public int deleteUserByIds(Long[] userIds) {
    for (Long userId : userIds) {
        checkUserAllowed(new SysUser(userId));
        checkUserDataScope(userId);
    }
    List<Long> ids = Arrays.asList(userIds);
    // 删除用户与角色关联
    userRoleMapper.delete(new LambdaQueryWrapper<SysUserRole>().in(SysUserRole::getUserId, ids));
    // 删除用户与岗位表
    userPostMapper.delete(new LambdaQueryWrapper<SysUserPost>().in(SysUserPost::getUserId, ids));
    return baseMapper.deleteBatchIds(ids);
}
Also used : SysUser(com.ruoyi.system.api.domain.SysUser) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

SysUser (com.ruoyi.system.api.domain.SysUser)37 LoginUser (com.ruoyi.system.api.model.LoginUser)13 Log (com.ruoyi.common.log.annotation.Log)12 ServiceException (com.ruoyi.common.core.exception.ServiceException)10 GetMapping (org.springframework.web.bind.annotation.GetMapping)8 PutMapping (org.springframework.web.bind.annotation.PutMapping)8 UserConstants (com.ruoyi.common.core.constant.UserConstants)6 R (com.ruoyi.common.core.domain.R)6 StringUtils (com.ruoyi.common.core.utils.StringUtils)6 BaseController (com.ruoyi.common.core.web.controller.BaseController)6 AjaxResult (com.ruoyi.common.core.web.domain.AjaxResult)6 BusinessType (com.ruoyi.common.log.enums.BusinessType)6 InnerAuth (com.ruoyi.common.security.annotation.InnerAuth)6 SysRole (com.ruoyi.system.api.domain.SysRole)6 ISysPermissionService (com.ruoyi.system.service.ISysPermissionService)6 ISysPostService (com.ruoyi.system.service.ISysPostService)6 ISysRoleService (com.ruoyi.system.service.ISysRoleService)6 ISysUserService (com.ruoyi.system.service.ISysUserService)6 IOException (java.io.IOException)6 Collectors (java.util.stream.Collectors)6