/** {@inheritDoc} **/ @Override public PageList<UserCoreBean> list(UserCoreWhere where, OrderPaging paging) throws ServiceException { String msg = "Failed to query UserCore. "; if (paging == null) { log.error(msg + "params is null: paging"); throw new ServiceException(ResultCode.PARAMETER_IS_REQUIRED); } if (where == null) { where = new UserCoreWhere(); where.setDataState(DataState.NORMAL); } else if (where.getDataState() == null) { where.setDataState(DataState.NORMAL); } doHandleDate(where); try { OrderWhere<UserCoreWhere> ow = OrderWhere.of(where, paging.getOrderings()); return PageList.of(userCoreBasicDao.list(ow, paging)); } catch (Exception e) { ServiceException.throwWhenServiceException(e); log.error(msg + "\n\t" + JsonTools.toJsonString(where), e); throw new ServiceException(ResultCode.DB_SELECT_ERROR, e); } }
/** {@inheritDoc} **/ @Override public UserCoreBean find(UserCoreWhere where) throws ServiceException { String msg = "Failed to query UserCore. "; if (where == null) { log.error(msg + "params is null: where"); throw new ServiceException(ResultCode.PARAMETER_IS_REQUIRED); } if (where.getDataState() == null) { where.setDataState(DataState.NORMAL); } doHandleDate(where); UserCoreBean bean; try { bean = userCoreBasicDao.find(Where.of(where)); } catch (Exception e) { ServiceException.throwWhenServiceException(e); log.error(msg + "\n\t" + JsonTools.toJsonString(where), e); throw new ServiceException(ResultCode.DB_SELECT_ERROR, e); } if (bean == null) { log.trace("UserCore not found. {}", JsonTools.toJsonString(where)); } return bean; }
/** * 根据条件删除用户基础信息 * * @param where 条件 * @param size 应删除条数, 0表示未知 * @param errorOnRowsNotMatch 删除行数不匹配时是否抛异常 * @param isId 是不是唯一主键 * @return 删除行数 * @throws ServiceException 删除失败 */ private int doDelete(UserCoreWhere where, int size, boolean errorOnRowsNotMatch) throws ServiceException { // 逻辑删除 if (where.getDataState() == null) { where.setDataState(DataState.NORMAL); } UserCoreUpdate model = new UserCoreUpdate(); model.setDataState(DataState.DELETED); model.setWhere(where); return doUpdate(model, size, errorOnRowsNotMatch); }
/** {@inheritDoc} **/ @Override public int update(UserCoreUpdate model, boolean errorOnUnaffected) throws ServiceException { String msg = "Failed to update UserCore. "; if (model == null) { log.error(msg + "params is null: model"); throw new ServiceException(ResultCode.PARAMETER_IS_REQUIRED); } UserCoreWhere where = model.getWhere(true); if (VerifyTools.isBlank(where.getId()) && VerifyTools.isNotBlank(model.getId())) { where.setId(model.getId()); } model.setDataState(null); // 数据状态只允许通过删除操作来修改 if (where.getDataState() == null) { where.setDataState(DataState.NORMAL); } return doUpdate(model, 0, errorOnUnaffected); }