查询实体类
判空异常抛出
Model model = modelDao.findById(groupAddParam.getModelId())
.orElseThrow(
() -> new ServiceException(APIResultEnum.NON_EXIST, "Model")
);
ConvertUtils.assertThrow(
!groupAddParam.getModelId().equals(template.getModel().getId()),
() -> new ServiceException(APIResultEnum.MODEL_DIFFERENT, "Group/Template"));
Group entity = Optional.ofNullable(
groupDao.findByIdAndCompanyId(groupUpdateParam.getId(), companyId))
.orElseThrow(() -> {
log.info("[GroupService]Group信息不存在: groupId={}, companyId={}", groupUpdateParam.getId(), companyId);
return new ServiceException(APIResultEnum.NON_EXIST, "Group");
});
网友评论