以下是Service.java的一个方法
@Override
public AuthAccountDTO getAccountInfo(Long id) {
AuthAccountDO accountDO = this.authAccountMapper.selectByPrimaryKey(id);
AuthAccountDTO accountDTO = new AuthAccountDTO();
if (accountDO == null) {
// throw new BusinessException(AuthBusinessError.SYS_DATA_NOT_EXISTS_ERROR, "员工信息不存在");
logger.info("员工信息不存在 {} id :"+ JsonUtil.toJson(id));
return null;
}
BeanUtils.copyProperties(accountDO, accountDTO);
return accountDTO;
}
如果this.authAccountMapper.selectByPrimaryKey(id)返回值为Null,即查询数据为空,那么accountDo=null,再用下边的if判断就能走到方法里,而如果是
AuthAccountDO accountDO = new AuthAccountDO
if(accountDO == null){
logger.info("员工信息不存在 {} id :"+ JsonUtil.toJson(id)); //if判断是不会走到方法里的,非null
}
菜鸟一枚,记得都是最简单的