Search in sources :

Example 1 with SysUser

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

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);
    }
    // 删除用户与角色关联
    userRoleMapper.deleteUserRole(userIds);
    // 删除用户与岗位关联
    userPostMapper.deleteUserPost(userIds);
    return userMapper.deleteUserByIds(userIds);
}
Also used : SysUser(com.ruoyi.system.api.domain.SysUser) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with SysUser

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

the class SysUserServiceImpl method checkPhoneUnique.

/**
 * 校验手机号码是否唯一
 *
 * @param user 用户信息
 * @return
 */
@Override
public String checkPhoneUnique(SysUser user) {
    Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId();
    SysUser info = userMapper.checkPhoneUnique(user.getPhonenumber());
    if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue()) {
        return UserConstants.NOT_UNIQUE;
    }
    return UserConstants.UNIQUE;
}
Also used : SysUser(com.ruoyi.system.api.domain.SysUser)

Example 3 with SysUser

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

the class SysProfileController method profile.

/**
 * 个人信息
 */
@GetMapping
public AjaxResult profile() {
    String username = SecurityUtils.getUsername();
    SysUser user = userService.selectUserByUserName(username);
    AjaxResult ajax = AjaxResult.success(user);
    ajax.put("roleGroup", userService.selectUserRoleGroup(username));
    ajax.put("postGroup", userService.selectUserPostGroup(username));
    return ajax;
}
Also used : AjaxResult(com.ruoyi.common.core.web.domain.AjaxResult) SysUser(com.ruoyi.system.api.domain.SysUser) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 4 with SysUser

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

the class SysUserController method getInfo.

/**
 * 根据用户编号获取详细信息
 */
@RequiresPermissions("system:user:query")
@GetMapping(value = { "/", "/{userId}" })
public AjaxResult getInfo(@PathVariable(value = "userId", required = false) Long userId) {
    userService.checkUserDataScope(userId);
    AjaxResult ajax = AjaxResult.success();
    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 (StringUtils.isNotNull(userId)) {
        SysUser sysUser = userService.selectUserById(userId);
        ajax.put(AjaxResult.DATA_TAG, sysUser);
        ajax.put("postIds", postService.selectPostListByUserId(userId));
        ajax.put("roleIds", sysUser.getRoles().stream().map(SysRole::getRoleId).collect(Collectors.toList()));
    }
    return ajax;
}
Also used : R(com.ruoyi.common.core.domain.R) PathVariable(org.springframework.web.bind.annotation.PathVariable) Log(com.ruoyi.common.log.annotation.Log) SysRole(com.ruoyi.system.api.domain.SysRole) Autowired(org.springframework.beans.factory.annotation.Autowired) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ArrayUtils(org.apache.commons.lang3.ArrayUtils) InnerAuth(com.ruoyi.common.security.annotation.InnerAuth) TableDataInfo(com.ruoyi.common.core.web.page.TableDataInfo) RequiresPermissions(com.ruoyi.common.security.annotation.RequiresPermissions) RequestBody(org.springframework.web.bind.annotation.RequestBody) ISysConfigService(com.ruoyi.system.service.ISysConfigService) BaseController(com.ruoyi.common.core.web.controller.BaseController) PutMapping(org.springframework.web.bind.annotation.PutMapping) ISysRoleService(com.ruoyi.system.service.ISysRoleService) GetMapping(org.springframework.web.bind.annotation.GetMapping) DeleteMapping(org.springframework.web.bind.annotation.DeleteMapping) BusinessType(com.ruoyi.common.log.enums.BusinessType) LoginUser(com.ruoyi.system.api.model.LoginUser) ISysPermissionService(com.ruoyi.system.service.ISysPermissionService) PostMapping(org.springframework.web.bind.annotation.PostMapping) Validated(org.springframework.validation.annotation.Validated) HttpServletResponse(javax.servlet.http.HttpServletResponse) Set(java.util.Set) IOException(java.io.IOException) AjaxResult(com.ruoyi.common.core.web.domain.AjaxResult) StringUtils(com.ruoyi.common.core.utils.StringUtils) SysUser(com.ruoyi.system.api.domain.SysUser) Collectors(java.util.stream.Collectors) RestController(org.springframework.web.bind.annotation.RestController) List(java.util.List) ISysUserService(com.ruoyi.system.service.ISysUserService) MultipartFile(org.springframework.web.multipart.MultipartFile) UserConstants(com.ruoyi.common.core.constant.UserConstants) ExcelUtil(com.ruoyi.common.core.utils.poi.ExcelUtil) ISysPostService(com.ruoyi.system.service.ISysPostService) SecurityUtils(com.ruoyi.common.security.utils.SecurityUtils) AjaxResult(com.ruoyi.common.core.web.domain.AjaxResult) SysUser(com.ruoyi.system.api.domain.SysUser) SysRole(com.ruoyi.system.api.domain.SysRole) RequiresPermissions(com.ruoyi.common.security.annotation.RequiresPermissions) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 5 with SysUser

use of com.ruoyi.system.api.domain.SysUser in project RuoYi-Cloud-Oracle by yangzongzhuan.

the class SysLoginService method register.

/**
 * 注册
 */
public void register(String username, String password) {
    // 用户名或密码为空 错误
    if (StringUtils.isAnyBlank(username, password)) {
        throw new ServiceException("用户/密码必须填写");
    }
    if (username.length() < UserConstants.USERNAME_MIN_LENGTH || username.length() > UserConstants.USERNAME_MAX_LENGTH) {
        throw new ServiceException("账户长度必须在2到20个字符之间");
    }
    if (password.length() < UserConstants.PASSWORD_MIN_LENGTH || password.length() > UserConstants.PASSWORD_MAX_LENGTH) {
        throw new ServiceException("密码长度必须在5到20个字符之间");
    }
    // 注册用户信息
    SysUser sysUser = new SysUser();
    sysUser.setUserName(username);
    sysUser.setNickName(username);
    sysUser.setPassword(SecurityUtils.encryptPassword(password));
    R<?> registerResult = remoteUserService.registerUserInfo(sysUser, SecurityConstants.INNER);
    if (R.FAIL == registerResult.getCode()) {
        throw new ServiceException(registerResult.getMsg());
    }
    recordLogininfor(username, Constants.REGISTER, "注册成功");
}
Also used : ServiceException(com.ruoyi.common.core.exception.ServiceException) SysUser(com.ruoyi.system.api.domain.SysUser)

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