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());
}
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;
}
Aggregations