Search in sources :

Example 11 with IamAccount

use of com.diboot.iam.entity.IamAccount in project diboot by dibo-software.

the class IamUserServiceImpl method createAccount.

private void createAccount(IamUserAccountDTO userAccountDTO) {
    // 创建账号信息
    IamAccount iamAccount = new IamAccount();
    iamAccount.setUserType(IamUser.class.getSimpleName()).setUserId(userAccountDTO.getId()).setAuthAccount(userAccountDTO.getUsername()).setAuthSecret(userAccountDTO.getPassword()).setAuthType(Cons.DICTCODE_AUTH_TYPE.PWD.name()).setStatus(userAccountDTO.getStatus());
    // 保存账号
    iamAccountService.createEntity(iamAccount);
    // 批量创建角色关联关系
    iamUserRoleService.createUserRoleRelations(iamAccount.getUserType(), iamAccount.getUserId(), userAccountDTO.getRoleIdList());
}
Also used : IamAccount(com.diboot.iam.entity.IamAccount)

Example 12 with IamAccount

use of com.diboot.iam.entity.IamAccount in project diboot by dibo-software.

the class IamUserServiceImpl method updateUserAndAccount.

@Override
@Transactional(rollbackFor = Exception.class)
public boolean updateUserAndAccount(IamUserAccountDTO userAccountDTO) {
    // 更新用户信息
    this.updateEntity(userAccountDTO);
    IamAccount iamAccount = iamAccountService.getSingleEntity(Wrappers.<IamAccount>lambdaQuery().eq(IamAccount::getUserType, IamUser.class.getSimpleName()).eq(IamAccount::getUserId, userAccountDTO.getId()));
    if (iamAccount == null) {
        if (V.isEmpty(userAccountDTO.getUsername())) {
            return true;
        } else {
            // 新建account账号
            this.createAccount(userAccountDTO);
        }
    } else {
        if (V.isEmpty(userAccountDTO.getUsername())) {
            // 删除账号
            this.deleteAccount(userAccountDTO.getId());
        } else {
            // 更新账号
            iamAccount.setAuthAccount(userAccountDTO.getUsername()).setStatus(userAccountDTO.getStatus());
            // 设置密码
            if (V.notEmpty(userAccountDTO.getPassword())) {
                iamAccount.setAuthSecret(userAccountDTO.getPassword());
                iamCustomize.encryptPwd(iamAccount);
            }
            iamAccountService.updateEntity(iamAccount);
            // 批量更新角色关联关系
            iamUserRoleService.updateUserRoleRelations(iamAccount.getUserType(), iamAccount.getUserId(), userAccountDTO.getRoleIdList());
        }
    }
    return true;
}
Also used : IamAccount(com.diboot.iam.entity.IamAccount) IamUser(com.diboot.iam.entity.IamUser) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

IamAccount (com.diboot.iam.entity.IamAccount)12 BusinessException (com.diboot.core.exception.BusinessException)5 IamMember (com.diboot.mobile.entity.IamMember)4 AuthenticationException (org.apache.shiro.authc.AuthenticationException)4 IamUser (com.diboot.iam.entity.IamUser)3 WxOAuth2AccessToken (me.chanjar.weixin.common.bean.oauth2.WxOAuth2AccessToken)3 Transactional (org.springframework.transaction.annotation.Transactional)3 LambdaQueryWrapper (com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)2 MobileCredential (com.diboot.mobile.dto.MobileCredential)2 WxOAuth2UserInfo (me.chanjar.weixin.common.bean.WxOAuth2UserInfo)2 QueryWrapper (com.baomidou.mybatisplus.core.conditions.query.QueryWrapper)1 BaseService (com.diboot.core.service.BaseService)1 LabelValue (com.diboot.core.vo.LabelValue)1 AuthService (com.diboot.iam.auth.AuthService)1 IamExtensible (com.diboot.iam.auth.IamExtensible)1 BaseLoginUser (com.diboot.iam.entity.BaseLoginUser)1 SimpleAuthenticationInfo (org.apache.shiro.authc.SimpleAuthenticationInfo)1