将 find 方法的返回值改为 Optional<T>。

pull/1/head
ZhouXY108 2023-02-16 15:42:30 +08:00
parent 02d918d0a4
commit bac7a007e6
16 changed files with 77 additions and 63 deletions

View File

@ -6,12 +6,7 @@ import org.springframework.web.bind.annotation.ResponseStatus;
/**
*
*
* <p>
*
* </p>
*
* @author <a href="https://gitee.com/zhouxy108">ZhouXY</a>
* @see xyz.zhouxy.plusone.util.AssertResult
*/
@ResponseStatus(HttpStatus.NOT_FOUND)
public class DataNotExistException extends PlusoneException {

View File

@ -1,6 +1,7 @@
package xyz.zhouxy.plusone.domain;
import java.io.Serializable;
import java.util.Optional;
/**
* Repository
@ -10,7 +11,7 @@ import java.io.Serializable;
*/
public interface IRepository<T extends AggregateRoot<ID>, ID extends Serializable> {
T find(ID id);
Optional<T> find(ID id);
T save(T entity);

View File

@ -4,6 +4,7 @@ import java.io.Serializable;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
import java.util.Optional;
import java.util.stream.Stream;
import javax.annotation.Nonnull;
@ -20,23 +21,23 @@ public abstract class JdbcEntityDaoSupport<T extends Entity<ID>, ID extends Seri
extends PlusoneJdbcDaoSupport {
protected RowMapper<T> rowMapper;
protected ResultSetExtractor<T> resultSetExtractor;
protected ResultSetExtractor<Optional<T>> resultSetExtractor;
protected JdbcEntityDaoSupport(@Nonnull NamedParameterJdbcTemplate namedParameterJdbcTemplate) {
super(namedParameterJdbcTemplate);
this.rowMapper = (ResultSet rs, int rowNum) -> mapRow(rs);
this.resultSetExtractor = (ResultSet rs) -> rs.next() ? mapRow(rs) : null;
this.resultSetExtractor = (ResultSet rs) -> rs.next() ? Optional.of(mapRow(rs)) : Optional.empty();
}
protected final T queryForObject(String sql) {
protected final Optional<T> queryForObject(String sql) {
return queryForObject(sql, this.resultSetExtractor);
}
protected final T queryForObject(String sql, SqlParameterSource paramSource) {
protected final Optional<T> queryForObject(String sql, SqlParameterSource paramSource) {
return queryForObject(sql, paramSource, this.resultSetExtractor);
}
protected final T queryForObject(String sql, String paramName, Object value) {
protected final Optional<T> queryForObject(String sql, String paramName, Object value) {
return queryForObject(sql, new MapSqlParameterSource(paramName, value), this.resultSetExtractor);
}
@ -66,7 +67,7 @@ public abstract class JdbcEntityDaoSupport<T extends Entity<ID>, ID extends Seri
this.rowMapper = rowMapper;
}
protected void setResultSetExtractor(@Nonnull ResultSetExtractor<T> resultSetExtractor) {
protected void setResultSetExtractor(@Nonnull ResultSetExtractor<Optional<T>> resultSetExtractor) {
this.resultSetExtractor = resultSetExtractor;
}
}

View File

@ -1,6 +1,7 @@
package xyz.zhouxy.plusone.jdbc;
import java.io.Serializable;
import java.util.Optional;
import javax.annotation.Nonnull;
@ -20,7 +21,7 @@ public abstract class JdbcRepositorySupport<T extends AggregateRoot<ID>, ID exte
protected abstract void doDelete(@Nonnull T entity);
protected abstract T doFindById(@Nonnull ID id);
protected abstract Optional<T> doFindById(@Nonnull ID id);
protected abstract T doInsert(@Nonnull T entity);
@ -35,7 +36,7 @@ public abstract class JdbcRepositorySupport<T extends AggregateRoot<ID>, ID exte
}
@Override
public final T find(ID id) {
public final Optional<T> find(ID id) {
if (id == null) {
throw new IllegalArgumentException("Id cannot be null.");
}

View File

@ -20,7 +20,6 @@ import xyz.zhouxy.plusone.system.application.query.params.AccountQueryParams;
import xyz.zhouxy.plusone.system.application.service.AccountManagementService;
import xyz.zhouxy.plusone.system.application.service.command.CreateAccountCommand;
import xyz.zhouxy.plusone.system.application.service.command.UpdateAccountCommand;
import xyz.zhouxy.plusone.util.AssertResult;
import xyz.zhouxy.plusone.util.RestfulResult;
/**
@ -77,7 +76,6 @@ public class AccountManagementController {
adminAuthLogic.checkLogin();
adminAuthLogic.checkPermission("sys-account-details");
var accountDetails = service.queryAccountDetails(accountId);
AssertResult.nonNull(accountDetails);
return success("查询成功", accountDetails);
}
}

View File

@ -1,8 +1,7 @@
package xyz.zhouxy.plusone.system.application.service;
import xyz.zhouxy.plusone.system.constant.AuthLogic;
import java.util.List;
import java.util.Optional;
import javax.annotation.Resource;
@ -10,7 +9,6 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import cn.dev33.satoken.stp.StpLogic;
import cn.hutool.core.lang.Assert;
import xyz.zhouxy.plusone.system.application.common.util.PrincipalUtil;
import xyz.zhouxy.plusone.system.application.exception.AccountLoginException;
import xyz.zhouxy.plusone.system.application.query.AccountQueries;
@ -19,6 +17,7 @@ import xyz.zhouxy.plusone.system.application.query.result.MenuViewObject;
import xyz.zhouxy.plusone.system.application.service.command.ChangePasswordByOtpCommand;
import xyz.zhouxy.plusone.system.application.service.command.ChangePasswordCommand;
import xyz.zhouxy.plusone.system.application.service.command.ChangePasswordWithoutLoginCommand;
import xyz.zhouxy.plusone.system.constant.AuthLogic;
import xyz.zhouxy.plusone.system.domain.model.account.Account;
import xyz.zhouxy.plusone.system.domain.model.account.AccountRepository;
import xyz.zhouxy.plusone.system.domain.model.account.Email;
@ -65,7 +64,8 @@ public class AccountContextService {
@Transactional
public void changePassword(ChangePasswordCommand command) {
adminAuthLogic.checkLogin();
Account account = accountRepository.find(adminAuthLogic.getLoginIdAsLong());
Account account = accountRepository.find(adminAuthLogic.getLoginIdAsLong())
.orElseThrow(() -> AccountLoginException.accountNotExistException("当前所登录的账号不存在"));
account.checkPassword(command.getPassword());
account.changePassword(command.getNewPassword(), command.getPasswordConfirmation());
accountRepository.save(account);
@ -77,9 +77,10 @@ public class AccountContextService {
String principal = command.getAccount();
Principal emailOrMobilePhone = PrincipalUtil.getEmailOrMobilePhone(principal);
Account account = emailOrMobilePhone instanceof Email
Account account = (emailOrMobilePhone instanceof Email
? accountRepository.findByEmail((Email) emailOrMobilePhone)
: accountRepository.findByMobilePhone((MobilePhone) emailOrMobilePhone);
: accountRepository.findByMobilePhone((MobilePhone) emailOrMobilePhone))
.orElseThrow(() -> AccountLoginException.accountNotExistException("当前所登录的账号不存在"));
account.checkPassword(command.getOldPassword());
account.changePassword(command.getNewPassword(), command.getPasswordConfirmation());
accountRepository.save(account);
@ -90,12 +91,12 @@ public class AccountContextService {
public void changePasswordByOtp(ChangePasswordByOtpCommand command) {
var principal = command.getAccount();
Account account = switch (command.getPrincipalType()) {
Optional<Account> account = switch (command.getPrincipalType()) {
case EMAIL -> accountRepository.findByEmail(Email.of(principal));
case MOBILE_PHONE -> accountRepository.findByMobilePhone(MobilePhone.of(principal));
default -> throw InvalidInputException.unsupportedPrincipalTypeException("输入邮箱地址或手机号");
};
Assert.notNull(account, AccountLoginException::accountNotExistException);
account.orElseThrow(AccountLoginException::accountNotExistException);
mailAndSmsVerifyService.checkOtp(principal, command.getOtp());
}

View File

@ -14,6 +14,7 @@ import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.PathVariable;
import xyz.zhouxy.plusone.exception.DataNotExistException;
import xyz.zhouxy.plusone.system.application.exception.AccountRegisterException;
import xyz.zhouxy.plusone.system.application.query.AccountQueries;
import xyz.zhouxy.plusone.system.application.query.params.AccountQueryParams;
@ -76,16 +77,16 @@ public class AccountManagementService {
public void deleteAccounts(List<Long> ids) {
Account accountToDelete;
for (var id : ids) {
accountToDelete = accountRepository.find(id);
AssertResult.nonNull(accountToDelete);
accountToDelete = accountRepository.find(id)
.orElseThrow(() -> new DataNotExistException("该账号不存在"));
accountRepository.delete(accountToDelete);
}
}
public void updateAccountInfo(Long id, @Valid UpdateAccountCommand command) {
Assert.isTrue(Objects.equals(id, command.getId()), "参数错误: id 不匹配");
Account account = accountRepository.find(id);
AssertResult.nonNull(account, "该账号不存在");
Account account = accountRepository.find(id)
.orElseThrow(() -> new DataNotExistException("该账号不存在"));
account.setAccountInfo(command.getNickname(), command.getAvatar(), command.getSex());
account.setUpdatedBy(adminAuthLogic.getLoginIdAsLong());
accountRepository.save(account);
@ -96,6 +97,13 @@ public class AccountManagementService {
return accountQueries.queryAccountOverviewPage(queryParams);
}
/**
* {@link DataNotExistException}
*
* @param accountId id
* @return
* @throws DataNotExistException
*/
@Transactional(propagation = Propagation.SUPPORTS)
public AccountDetails queryAccountDetails(@PathVariable("accountId") Long accountId) {
var accountDetails = accountQueries.queryAccountDetails(accountId);

View File

@ -44,12 +44,11 @@ public class AdminLoginService {
@ValidateDto
public LoginInfoViewObject loginByPassword(LoginByPasswordCommand command) {
var principal = command.getPrincipal();
Account account = switch (command.getPrincipalType()) {
Account account = (switch (command.getPrincipalType()) {
case USERNAME -> accountRepository.findByUsername(Username.of(principal));
case EMAIL -> accountRepository.findByEmail(Email.of(principal));
case MOBILE_PHONE -> accountRepository.findByMobilePhone(MobilePhone.of(principal));
};
Assert.notNull(account, AccountLoginException::accountNotExistException);
}).orElseThrow(AccountLoginException::accountNotExistException);
var isPasswordCorrect = account.checkPassword(command.getPassword());
Assert.isTrue(isPasswordCorrect, AccountLoginException::passwordErrorException);
@ -61,12 +60,11 @@ public class AdminLoginService {
@ValidateDto
public LoginInfoViewObject loginByOtp(LoginByOtpCommand command) {
var principal = command.getPrincipal();
Account account = switch (command.getPrincipalType()) {
Account account = (switch (command.getPrincipalType()) {
case EMAIL -> accountRepository.findByEmail(Email.of(principal));
case MOBILE_PHONE -> accountRepository.findByMobilePhone(MobilePhone.of(principal));
default -> throw InvalidInputException.unsupportedPrincipalTypeException("输入邮箱地址或手机号");
};
Assert.notNull(account, AccountLoginException::accountNotExistException);
}).orElseThrow(AccountLoginException::accountNotExistException);
mailAndSmsVerifyService.checkOtp(principal, command.getOtp());

View File

@ -10,6 +10,7 @@ import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
import xyz.zhouxy.plusone.exception.DataNotExistException;
import xyz.zhouxy.plusone.system.application.query.DictQueries;
import xyz.zhouxy.plusone.system.application.query.params.DictQueryParams;
import xyz.zhouxy.plusone.system.application.query.result.DictOverview;
@ -45,21 +46,21 @@ public class DictManagementService {
public void deleteDicts(List<Long> ids) {
Dict dictToDelete;
for (Long id : ids) {
dictToDelete = dictRepository.find(id);
dictToDelete = dictRepository.find(id).orElseThrow(DataNotExistException::new);
dictRepository.delete(dictToDelete);
}
}
public void updateDict(Long id, @Valid UpdateDictCommand command) {
Assert.isTrue(Objects.equals(id, command.getId()), "id 不匹配");
Dict dictToUpdate = dictRepository.find(command.getId());
Dict dictToUpdate = dictRepository.find(command.getId()).orElseThrow(DataNotExistException::new);
dictToUpdate.updateDict(command.getDictType(), command.getDictLabel(), command.getKeyLabelMap());
dictRepository.save(dictToUpdate);
}
@Transactional(propagation = Propagation.SUPPORTS)
public Dict findDictDetails(Long dictId) {
return dictRepository.find(dictId);
return dictRepository.find(dictId).orElseThrow(DataNotExistException::new);
}
@Transactional(propagation = Propagation.SUPPORTS)

View File

@ -14,6 +14,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
import xyz.zhouxy.plusone.domain.IWithOrderNumber;
import xyz.zhouxy.plusone.exception.DataNotExistException;
import xyz.zhouxy.plusone.system.application.exception.UnsupportedMenuTypeException;
import xyz.zhouxy.plusone.system.application.query.result.MenuViewObject;
import xyz.zhouxy.plusone.system.application.service.command.CreateMenuCommand;
@ -22,7 +23,6 @@ import xyz.zhouxy.plusone.system.domain.model.menu.Menu;
import xyz.zhouxy.plusone.system.domain.model.menu.MenuConstructor;
import xyz.zhouxy.plusone.system.domain.model.menu.MenuRepository;
import xyz.zhouxy.plusone.system.domain.service.MenuService;
import xyz.zhouxy.plusone.util.AssertResult;
/**
*
@ -88,15 +88,16 @@ public class MenuManagementService {
// ==================== delete ====================
public void deleteMenu(Long id) {
Menu menuToDelete = menuRepository.find(id);
AssertResult.nonNull(menuToDelete);
Menu menuToDelete = menuRepository.find(id)
.orElseThrow(DataNotExistException::new);
menuRepository.delete(menuToDelete);
}
// ==================== update ====================
public void updateMenu(Long id, @Valid UpdateMenuCommand command) {
Assert.isTrue(Objects.equals(id, command.getId()), "id 不匹配");
Menu menuToUpdate = menuRepository.find(command.getId());
Menu menuToUpdate = menuRepository.find(command.getId())
.orElseThrow(DataNotExistException::new);
menuToUpdate.updateMenuInfo(
command.getMenuType(),
command.getParentId(),
@ -118,7 +119,7 @@ public class MenuManagementService {
@Transactional(propagation = Propagation.SUPPORTS)
public MenuViewObject findById(Long id) {
var menu = menuRepository.find(id);
return MenuViewObject.of(menu);
return MenuViewObject.of(menu.orElseThrow(DataNotExistException::new));
}
@Transactional(propagation = Propagation.SUPPORTS)

View File

@ -10,6 +10,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import xyz.zhouxy.plusone.exception.DataNotExistException;
import xyz.zhouxy.plusone.system.application.query.RoleQueries;
import xyz.zhouxy.plusone.system.application.query.params.RoleQueryParams;
import xyz.zhouxy.plusone.system.application.query.result.RoleOverview;
@ -62,7 +63,7 @@ public class RoleManagementService {
public void updateRole(@Valid UpdateRoleCommand command) {
Long roleId = command.getId();
Role roleToUpdate = _roleRepository.find(roleId);
Role roleToUpdate = _roleRepository.find(roleId).orElseThrow(DataNotExistException::new);
roleToUpdate.update(
command.getName(),
command.getIdentifier(),
@ -74,7 +75,7 @@ public class RoleManagementService {
}
public void delete(Long id) {
Role role = _roleRepository.find(id);
Role role = _roleRepository.find(id).orElseThrow(DataNotExistException::new);
_roleRepository.delete(role);
}
@ -85,7 +86,7 @@ public class RoleManagementService {
@Transactional(propagation = Propagation.SUPPORTS)
public Role findById(Long id) {
return _roleRepository.find(id);
return _roleRepository.find(id).orElseThrow(DataNotExistException::new);
}
@Transactional(propagation = Propagation.SUPPORTS)

View File

@ -1,6 +1,7 @@
package xyz.zhouxy.plusone.system.domain.model.account;
import java.util.Collection;
import java.util.Optional;
import xyz.zhouxy.plusone.domain.IRepository;
@ -14,11 +15,11 @@ public interface AccountRepository extends IRepository<Account, Long> {
Collection<Account> findByRoleId(Long roleId);
Account findByEmail(Email email);
Optional<Account> findByEmail(Email email);
Account findByMobilePhone(MobilePhone mobilePhone);
Optional<Account> findByMobilePhone(MobilePhone mobilePhone);
Account findByUsername(Username username);
Optional<Account> findByUsername(Username username);
boolean existsUsername(Username username);

View File

@ -5,6 +5,7 @@ import java.sql.SQLException;
import java.time.LocalDateTime;
import java.util.Collection;
import java.util.Objects;
import java.util.Optional;
import javax.annotation.Nonnull;
@ -44,7 +45,7 @@ public class AccountRepositoryImpl extends JdbcRepositorySupport<Account, Long>
}
@Override
protected final Account doFindById(@Nonnull Long id) {
protected final Optional<Account> doFindById(@Nonnull Long id) {
return queryForObject("""
SELECT
id, email, mobile_phone, username, "password", salt, avatar, sex, nickname, status,
@ -56,7 +57,7 @@ public class AccountRepositoryImpl extends JdbcRepositorySupport<Account, Long>
}
@Override
public Account findByEmail(Email email) {
public Optional<Account> findByEmail(Email email) {
return queryForObject("""
SELECT
id, email, mobile_phone, username, "password", salt, avatar, sex, nickname, status,
@ -68,7 +69,7 @@ public class AccountRepositoryImpl extends JdbcRepositorySupport<Account, Long>
}
@Override
public Account findByMobilePhone(MobilePhone mobilePhone) {
public Optional<Account> findByMobilePhone(MobilePhone mobilePhone) {
return queryForObject("""
SELECT
id, email, mobile_phone, username, "password", salt, avatar, sex, nickname, status,
@ -80,7 +81,7 @@ public class AccountRepositoryImpl extends JdbcRepositorySupport<Account, Long>
}
@Override
public Account findByUsername(Username username) {
public Optional<Account> findByUsername(Username username) {
return queryForObject("""
SELECT
id, email, mobile_phone, username, "password", salt, avatar, sex, nickname, status,
@ -143,7 +144,7 @@ public class AccountRepositoryImpl extends JdbcRepositorySupport<Account, Long>
generateParamSource(id, entity));
assertUpdateOneRow(i);
this.accountRoleDAO.insertAccountRoleRefs(id, entity.getRoleIds());
return entity;
return find(id).orElseThrow();
}
@Override
@ -167,7 +168,7 @@ public class AccountRepositoryImpl extends JdbcRepositorySupport<Account, Long>
generateParamSource(entity));
assertUpdateOneRow(i);
this.accountRoleDAO.saveAccountRoleRefs(entity);
return entity;
return find(entity.getId().orElseThrow()).orElseThrow();
}
@Override

View File

@ -6,6 +6,7 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Optional;
import javax.annotation.Nonnull;
@ -15,6 +16,7 @@ import org.springframework.jdbc.core.namedparam.SqlParameterSource;
import org.springframework.stereotype.Repository;
import cn.hutool.core.util.IdUtil;
import xyz.zhouxy.plusone.exception.DataNotExistException;
import xyz.zhouxy.plusone.jdbc.JdbcRepositorySupport;
import xyz.zhouxy.plusone.util.AssertResult;
@ -34,7 +36,7 @@ public class DictRepositoryImpl extends JdbcRepositorySupport<Dict, Long> implem
}
@Override
public Dict doFindById(@Nonnull Long id) {
public Optional<Dict> doFindById(@Nonnull Long id) {
return queryForObject("SELECT id, dict_type, dict_label, \"version\" WHERE id = :id AND deleted = 0",
"id", id);
}
@ -49,7 +51,7 @@ public class DictRepositoryImpl extends JdbcRepositorySupport<Dict, Long> implem
generateParamSource(id, entity));
AssertResult.updateOneRow(i);
this.dictValueDAO.insertDictValues(id, entity);
return find(id);
return find(id).orElseThrow(DataNotExistException::new);
}
@Override
@ -66,7 +68,7 @@ public class DictRepositoryImpl extends JdbcRepositorySupport<Dict, Long> implem
generateParamSource(entity));
AssertResult.updateOneRow(i);
this.dictValueDAO.updateDictValues(entity);
return find(entity.getId().orElseThrow());
return find(entity.getId().orElseThrow()).orElseThrow(DataNotExistException::new);
}
@Override

View File

@ -8,6 +8,7 @@ import java.time.LocalDateTime;
import java.util.Collection;
import java.util.Collections;
import java.util.Objects;
import java.util.Optional;
import javax.annotation.Nonnull;
@ -17,6 +18,7 @@ import org.springframework.stereotype.Repository;
import cn.hutool.core.util.IdUtil;
import xyz.zhouxy.plusone.constant.EntityStatus;
import xyz.zhouxy.plusone.exception.DataNotExistException;
import xyz.zhouxy.plusone.jdbc.JdbcRepositorySupport;
import xyz.zhouxy.plusone.system.domain.model.menu.Menu.MenuType;
import xyz.zhouxy.plusone.util.AssertResult;
@ -38,7 +40,7 @@ public class MenuRepositoryImpl extends JdbcRepositorySupport<Menu, Long> implem
}
@Override
protected final Menu doFindById(@Nonnull Long id) {
protected final Optional<Menu> doFindById(@Nonnull Long id) {
return queryForObject("""
SELECT
id, parent_id, "type", "name", "path", title, icon, hidden, order_number, status, remarks,
@ -64,7 +66,7 @@ public class MenuRepositoryImpl extends JdbcRepositorySupport<Menu, Long> implem
int i = update(sql, paramSource);
AssertResult.updateOneRow(i);
this.actionDAO.saveActions(id, entity.getActions());
return entity;
return find(id).orElseThrow(DataNotExistException::new);
}
@Override
@ -97,7 +99,7 @@ public class MenuRepositoryImpl extends JdbcRepositorySupport<Menu, Long> implem
// 保存权限
Long id = entity.getId().orElseThrow();
this.actionDAO.saveActions(id, entity.getActions());
return entity;
return find(entity.getId().orElseThrow()).orElseThrow(DataNotExistException::new);
}
@Override

View File

@ -6,6 +6,7 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.time.LocalDateTime;
import java.util.Collection;
import java.util.Optional;
import javax.annotation.Nonnull;
@ -15,6 +16,7 @@ import org.springframework.stereotype.Repository;
import cn.hutool.core.util.IdUtil;
import xyz.zhouxy.plusone.constant.EntityStatus;
import xyz.zhouxy.plusone.exception.DataNotExistException;
import xyz.zhouxy.plusone.jdbc.JdbcRepositorySupport;
import xyz.zhouxy.plusone.util.AssertResult;
@ -36,7 +38,7 @@ public class RoleRepositoryImpl extends JdbcRepositorySupport<Role, Long> implem
}
@Override
protected final Role doFindById(@Nonnull Long id) {
protected final Optional<Role> doFindById(@Nonnull Long id) {
return queryForObject("""
SELECT "id","name","identifier","status","remarks","version"
FROM "sys_role"
@ -74,7 +76,7 @@ public class RoleRepositoryImpl extends JdbcRepositorySupport<Role, Long> implem
AssertResult.updateOneRow(i);
this.roleMenuRefDAO.saveRoleMenuRefs(id, entity);
this.rolePermissionRefDAO.saveRolePermissionRefs(id, entity);
return entity;
return find(id).orElseThrow(DataNotExistException::new);
}
@Override
@ -97,7 +99,7 @@ public class RoleRepositoryImpl extends JdbcRepositorySupport<Role, Long> implem
this.roleMenuRefDAO.saveRoleMenuRefs(id, entity);
this.rolePermissionRefDAO.clearRolePermissionRefs(entity);
this.rolePermissionRefDAO.saveRolePermissionRefs(id, entity);
return entity;
return find(entity.getId().orElseThrow()).orElseThrow(DataNotExistException::new);
}
@Override