Search in sources :

Example 11 with SysUser

use of com.ruoyi.project.system.domain.SysUser in project RuoYi-Vue-fast by yangzongzhuan.

the class SysUserServiceImpl method checkEmailUnique.

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

Example 12 with SysUser

use of com.ruoyi.project.system.domain.SysUser in project RuoYi-Vue-fast 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.project.system.domain.SysUser)

Example 13 with SysUser

use of com.ruoyi.project.system.domain.SysUser in project RuoYi-Vue-fast by yangzongzhuan.

the class SysUserController method authRole.

/**
 * 根据用户编号获取授权角色
 */
@PreAuthorize("@ss.hasPermi('system:user:query')")
@GetMapping("/authRole/{userId}")
public AjaxResult authRole(@PathVariable("userId") Long userId) {
    AjaxResult ajax = AjaxResult.success();
    SysUser user = userService.selectUserById(userId);
    List<SysRole> roles = roleService.selectRolesByUserId(userId);
    ajax.put("user", user);
    ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
    return ajax;
}
Also used : SysUser(com.ruoyi.project.system.domain.SysUser) PathVariable(org.springframework.web.bind.annotation.PathVariable) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) Autowired(org.springframework.beans.factory.annotation.Autowired) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ArrayUtils(org.apache.commons.lang3.ArrayUtils) TableDataInfo(com.ruoyi.framework.web.page.TableDataInfo) ISysRoleService(com.ruoyi.project.system.service.ISysRoleService) Log(com.ruoyi.framework.aspectj.lang.annotation.Log) ISysPostService(com.ruoyi.project.system.service.ISysPostService) RequestBody(org.springframework.web.bind.annotation.RequestBody) AjaxResult(com.ruoyi.framework.web.domain.AjaxResult) StringUtils(com.ruoyi.common.utils.StringUtils) PutMapping(org.springframework.web.bind.annotation.PutMapping) SecurityUtils(com.ruoyi.common.utils.SecurityUtils) GetMapping(org.springframework.web.bind.annotation.GetMapping) SysRole(com.ruoyi.project.system.domain.SysRole) DeleteMapping(org.springframework.web.bind.annotation.DeleteMapping) ISysUserService(com.ruoyi.project.system.service.ISysUserService) PostMapping(org.springframework.web.bind.annotation.PostMapping) Validated(org.springframework.validation.annotation.Validated) HttpServletResponse(javax.servlet.http.HttpServletResponse) Collectors(java.util.stream.Collectors) RestController(org.springframework.web.bind.annotation.RestController) BaseController(com.ruoyi.framework.web.controller.BaseController) List(java.util.List) UserConstants(com.ruoyi.common.constant.UserConstants) ExcelUtil(com.ruoyi.common.utils.poi.ExcelUtil) MultipartFile(org.springframework.web.multipart.MultipartFile) BusinessType(com.ruoyi.framework.aspectj.lang.enums.BusinessType) AjaxResult(com.ruoyi.framework.web.domain.AjaxResult) SysUser(com.ruoyi.project.system.domain.SysUser) SysRole(com.ruoyi.project.system.domain.SysRole) GetMapping(org.springframework.web.bind.annotation.GetMapping) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 14 with SysUser

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

the class SysLoginService method recordLoginInfo.

/**
 * 记录登录信息
 *
 * @param userId 用户ID
 */
public void recordLoginInfo(Long userId) {
    SysUser sysUser = new SysUser();
    sysUser.setUserId(userId);
    sysUser.setLoginIp(IpUtils.getIpAddr(ServletUtils.getRequest()));
    sysUser.setLoginDate(DateUtils.getNowDate());
    userService.updateUserProfile(sysUser);
}
Also used : SysUser(com.ruoyi.project.system.domain.SysUser)

Example 15 with SysUser

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

the class SysRegisterService method register.

/**
 * 注册
 */
public String register(RegisterBody registerBody) {
    String msg = "", username = registerBody.getUsername(), password = registerBody.getPassword();
    boolean captchaOnOff = configService.selectCaptchaOnOff();
    // 验证码开关
    if (captchaOnOff) {
        validateCaptcha(username, registerBody.getCode(), registerBody.getUuid());
    }
    if (StringUtils.isEmpty(username)) {
        msg = "用户名不能为空";
    } else if (StringUtils.isEmpty(password)) {
        msg = "用户密码不能为空";
    } else if (username.length() < UserConstants.USERNAME_MIN_LENGTH || username.length() > UserConstants.USERNAME_MAX_LENGTH) {
        msg = "账户长度必须在2到20个字符之间";
    } else if (password.length() < UserConstants.PASSWORD_MIN_LENGTH || password.length() > UserConstants.PASSWORD_MAX_LENGTH) {
        msg = "密码长度必须在5到20个字符之间";
    } else if (UserConstants.NOT_UNIQUE.equals(userService.checkUserNameUnique(username))) {
        msg = "保存用户'" + username + "'失败,注册账号已存在";
    } else {
        SysUser sysUser = new SysUser();
        sysUser.setUserName(username);
        sysUser.setNickName(username);
        sysUser.setPassword(SecurityUtils.encryptPassword(registerBody.getPassword()));
        boolean regFlag = userService.registerUser(sysUser);
        if (!regFlag) {
            msg = "注册失败,请联系系统管理人员";
        } else {
            AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.REGISTER, MessageUtils.message("user.register.success")));
        }
    }
    return msg;
}
Also used : SysUser(com.ruoyi.project.system.domain.SysUser)

Aggregations

SysUser (com.ruoyi.project.system.domain.SysUser)24 AjaxResult (com.ruoyi.framework.web.domain.AjaxResult)8 GetMapping (org.springframework.web.bind.annotation.GetMapping)8 Log (com.ruoyi.framework.aspectj.lang.annotation.Log)6 PutMapping (org.springframework.web.bind.annotation.PutMapping)6 UserConstants (com.ruoyi.common.constant.UserConstants)4 ServiceException (com.ruoyi.common.exception.ServiceException)4 SecurityUtils (com.ruoyi.common.utils.SecurityUtils)4 StringUtils (com.ruoyi.common.utils.StringUtils)4 ExcelUtil (com.ruoyi.common.utils.poi.ExcelUtil)4 BusinessType (com.ruoyi.framework.aspectj.lang.enums.BusinessType)4 LoginUser (com.ruoyi.framework.security.LoginUser)4 BaseController (com.ruoyi.framework.web.controller.BaseController)4 TableDataInfo (com.ruoyi.framework.web.page.TableDataInfo)4 SysRole (com.ruoyi.project.system.domain.SysRole)4 ISysPostService (com.ruoyi.project.system.service.ISysPostService)4 ISysRoleService (com.ruoyi.project.system.service.ISysRoleService)4 ISysUserService (com.ruoyi.project.system.service.ISysUserService)4 List (java.util.List)4 Collectors (java.util.stream.Collectors)4