Search in sources :

Example 11 with UacUser

use of com.paascloud.provider.model.domain.UacUser in project paascloud-master by paascloud.

the class UacUserDetailsServiceImpl method loadUserByUsername.

/**
 * Load user by username user details.
 *
 * @param username the username
 *
 * @return the user details
 */
@Override
public UserDetails loadUserByUsername(String username) {
    Collection<GrantedAuthority> grantedAuthorities;
    UacUser user = uacUserService.findByLoginName(username);
    if (user == null) {
        throw new BadCredentialsException("用户名不存在或者密码错误");
    }
    user = uacUserService.findUserInfoByUserId(user.getId());
    grantedAuthorities = uacUserService.loadUserAuthorities(user.getId());
    return new SecurityUser(user.getId(), user.getLoginName(), user.getLoginPwd(), user.getUserName(), user.getGroupId(), user.getGroupName(), user.getStatus(), grantedAuthorities);
}
Also used : UacUser(com.paascloud.provider.model.domain.UacUser) SecurityUser(com.paascloud.security.core.SecurityUser) GrantedAuthority(org.springframework.security.core.GrantedAuthority) BadCredentialsException(org.springframework.security.authentication.BadCredentialsException)

Example 12 with UacUser

use of com.paascloud.provider.model.domain.UacUser in project paascloud-master by paascloud.

the class UacLoginServiceImpl method loginAfter.

@Override
public LoginRespDto loginAfter(Long applicationId) {
    LoginRespDto loginRespDto = new LoginRespDto();
    String loginName = SecurityUtils.getCurrentLoginName();
    if (StringUtils.isEmpty(loginName)) {
        log.error("操作超时, 请重新登录 loginName={}", loginName);
        Preconditions.checkArgument(StringUtils.isNotEmpty(loginName), "操作超时, 请重新登录");
    }
    UacUser uacUser = uacUserService.findByLoginName(loginName);
    if (PublicUtil.isEmpty(uacUser)) {
        log.info("找不到用户信息 loginName={}", loginName);
        throw new UacBizException(ErrorCodeEnum.UAC10011002, loginName);
    }
    LoginAuthDto loginAuthDto = this.getLoginAuthDto(uacUser);
    List<MenuVo> menuVoList = uacMenuService.getMenuVoList(uacUser.getId(), applicationId);
    if (PublicUtil.isNotEmpty(menuVoList) && UacConstant.MENU_ROOT.equals(menuVoList.get(0).getMenuCode())) {
        menuVoList = menuVoList.get(0).getSubMenu();
    }
    loginRespDto.setLoginAuthDto(loginAuthDto);
    loginRespDto.setMenuList(menuVoList);
    return loginRespDto;
}
Also used : LoginRespDto(com.paascloud.provider.model.dto.user.LoginRespDto) MenuVo(com.paascloud.provider.model.vo.MenuVo) UacUser(com.paascloud.provider.model.domain.UacUser) UacBizException(com.paascloud.provider.model.exceptions.UacBizException) LoginAuthDto(com.paascloud.base.dto.LoginAuthDto)

Example 13 with UacUser

use of com.paascloud.provider.model.domain.UacUser in project paascloud-master by paascloud.

the class MallUserController method updateInformation.

/**
 * 更新用户信息.
 *
 * @param userInfoDto the user info dto
 *
 * @return the wrapper
 */
@PostMapping(value = "/updateInformation")
@ApiOperation(httpMethod = "POST", value = "更新用户信息")
public Wrapper<UserInfoDto> updateInformation(@RequestBody UserInfoDto userInfoDto) {
    logger.info("updateInformation - 更新用户基本信息 userInfoDto={}", userInfoDto);
    UacUser uacUser = new ModelMapper().map(userInfoDto, UacUser.class);
    uacUserService.updateUser(uacUser);
    return WrapMapper.ok();
}
Also used : UacUser(com.paascloud.provider.model.domain.UacUser) ModelMapper(org.modelmapper.ModelMapper) PostMapping(org.springframework.web.bind.annotation.PostMapping) ApiOperation(io.swagger.annotations.ApiOperation)

Example 14 with UacUser

use of com.paascloud.provider.model.domain.UacUser in project paascloud-master by paascloud.

the class MallUserController method getInformation.

/**
 * 获取用户信息.
 *
 * @return the information
 */
@PostMapping(value = "/getInformation")
@ApiOperation(httpMethod = "POST", value = "获取用户信息")
public Wrapper<UserInfoDto> getInformation() {
    LoginAuthDto loginAuthDto = getLoginAuthDto();
    Long userId = loginAuthDto.getUserId();
    logger.info("queryUserInfo - 查询用户基本信息 userId={}", userId);
    UacUser uacUser = uacUserService.queryByUserId(userId);
    if (uacUser == null) {
        return WrapMapper.error("找不到当前用户");
    }
    UserInfoDto userInfoDto = new UserInfoDto();
    BeanUtils.copyProperties(uacUser, userInfoDto);
    return WrapMapper.ok(userInfoDto);
}
Also used : UacUser(com.paascloud.provider.model.domain.UacUser) UserInfoDto(com.paascloud.provider.model.dto.user.UserInfoDto) LoginAuthDto(com.paascloud.base.dto.LoginAuthDto) PostMapping(org.springframework.web.bind.annotation.PostMapping) ApiOperation(io.swagger.annotations.ApiOperation)

Example 15 with UacUser

use of com.paascloud.provider.model.domain.UacUser in project paascloud-master by paascloud.

the class UacUserServiceTest method queryUserListWithPageTest.

/**
 * Query user list with page test.
 */
@Test
public void queryUserListWithPageTest() {
    PageInfo pageInfo = uacUserService.queryUserListWithPage(new UacUser());
    logger.info("queryUserListWithPage = {}", pageInfo);
}
Also used : UacUser(com.paascloud.provider.model.domain.UacUser) PageInfo(com.github.pagehelper.PageInfo) Test(org.junit.Test)

Aggregations

UacUser (com.paascloud.provider.model.domain.UacUser)17 ApiOperation (io.swagger.annotations.ApiOperation)8 LoginAuthDto (com.paascloud.base.dto.LoginAuthDto)4 UacBizException (com.paascloud.provider.model.exceptions.UacBizException)3 UserTokenDto (com.paascloud.base.dto.UserTokenDto)2 MenuVo (com.paascloud.provider.model.vo.MenuVo)2 SecurityUser (com.paascloud.security.core.SecurityUser)2 ModelMapper (org.modelmapper.ModelMapper)2 PostMapping (org.springframework.web.bind.annotation.PostMapping)2 JSONObject (com.alibaba.fastjson.JSONObject)1 HttpConfig (com.arronlong.httpclientutil.common.HttpConfig)1 HttpHeader (com.arronlong.httpclientutil.common.HttpHeader)1 PageInfo (com.github.pagehelper.PageInfo)1 LogAnnotation (com.paascloud.core.annotation.LogAnnotation)1 MqMessageData (com.paascloud.provider.model.domain.MqMessageData)1 UacGroup (com.paascloud.provider.model.domain.UacGroup)1 UacGroupUser (com.paascloud.provider.model.domain.UacGroupUser)1 UacRole (com.paascloud.provider.model.domain.UacRole)1 UacUserToken (com.paascloud.provider.model.domain.UacUserToken)1 LoginRespDto (com.paascloud.provider.model.dto.user.LoginRespDto)1