use of build.dream.catering.exceptions.CanNotEditAndDeleteException in project erp-catering by liuyandong33.
the class BasicService method validateCanNotOperate.
public void validateCanNotOperate(BigInteger tenantId, BigInteger branchId, String tableName, BigInteger tableId, int operateType) {
SearchModel searchModel = new SearchModel();
searchModel.addSearchCondition("tenant_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, tenantId);
searchModel.addSearchCondition("branch_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, branchId);
searchModel.addSearchCondition("table_name", Constants.SQL_OPERATION_SYMBOL_EQUALS, tableName);
searchModel.addSearchCondition("table_id", Constants.SQL_OPERATION_SYMBOL_EQUALS, tableId);
searchModel.addSearchCondition("operate_type", Constants.SQL_OPERATION_SYMBOL_IN, new int[] { operateType, 3 });
CanNotOperateReason canNotOperateReason = canNotOperateReasonMapper.find(searchModel);
if (canNotOperateReason != null) {
int persistenceOperateType = canNotOperateReason.getOperateType();
String reason = canNotOperateReason.getReason();
if (persistenceOperateType == 1) {
throw new CanNotDeleteException(reason);
} else if (persistenceOperateType == 2) {
throw new CanNotEditException(reason);
} else if (persistenceOperateType == 3) {
throw new CanNotEditAndDeleteException(String.format(reason, operateType == 1 ? "编辑" : "删除"));
}
}
}
Aggregations