implemented user service (no auth!)
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
import 'package:backend_dart/domain/interface/error.dart';
|
||||
import 'package:fpdart/fpdart.dart';
|
||||
|
||||
abstract class UserDataSource<T> {
|
||||
TaskEither<IError, T> create(T user);
|
||||
|
||||
TaskEither<IError, T> findByEmail(String email);
|
||||
|
||||
TaskEither<IError, T> findById(String id);
|
||||
|
||||
TaskEither<IError, T> update(T user);
|
||||
|
||||
TaskEither<IError, void> delete(String id);
|
||||
|
||||
TaskEither<IError, List<T>> findAll();
|
||||
|
||||
TaskEither<IError,String> generateId();
|
||||
}
|
||||
@@ -1,14 +1,13 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'user.freezed.dart';
|
||||
part 'user.g.dart';
|
||||
|
||||
@freezed
|
||||
class User with _$User {
|
||||
const factory User({
|
||||
required String id,
|
||||
required String name,
|
||||
required String email,
|
||||
String? id,
|
||||
String? name,
|
||||
String? email,
|
||||
String? password,
|
||||
DateTime? createdAt,
|
||||
DateTime? updatedAt,
|
||||
|
||||
@@ -0,0 +1,247 @@
|
||||
// coverage:ignore-file
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
||||
|
||||
part of 'user.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
T _$identity<T>(T value) => value;
|
||||
|
||||
final _privateConstructorUsedError = UnsupportedError(
|
||||
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models');
|
||||
|
||||
/// @nodoc
|
||||
mixin _$User {
|
||||
String? get id => throw _privateConstructorUsedError;
|
||||
String? get name => throw _privateConstructorUsedError;
|
||||
String? get email => throw _privateConstructorUsedError;
|
||||
String? get password => throw _privateConstructorUsedError;
|
||||
DateTime? get createdAt => throw _privateConstructorUsedError;
|
||||
DateTime? get updatedAt => throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of User
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
$UserCopyWith<User> get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $UserCopyWith<$Res> {
|
||||
factory $UserCopyWith(User value, $Res Function(User) then) =
|
||||
_$UserCopyWithImpl<$Res, User>;
|
||||
@useResult
|
||||
$Res call(
|
||||
{String? id,
|
||||
String? name,
|
||||
String? email,
|
||||
String? password,
|
||||
DateTime? createdAt,
|
||||
DateTime? updatedAt});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$UserCopyWithImpl<$Res, $Val extends User>
|
||||
implements $UserCopyWith<$Res> {
|
||||
_$UserCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of User
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? id = freezed,
|
||||
Object? name = freezed,
|
||||
Object? email = freezed,
|
||||
Object? password = freezed,
|
||||
Object? createdAt = freezed,
|
||||
Object? updatedAt = freezed,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
id: freezed == id
|
||||
? _value.id
|
||||
: id // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
name: freezed == name
|
||||
? _value.name
|
||||
: name // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
email: freezed == email
|
||||
? _value.email
|
||||
: email // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
password: freezed == password
|
||||
? _value.password
|
||||
: password // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
createdAt: freezed == createdAt
|
||||
? _value.createdAt
|
||||
: createdAt // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime?,
|
||||
updatedAt: freezed == updatedAt
|
||||
? _value.updatedAt
|
||||
: updatedAt // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime?,
|
||||
) as $Val);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$UserImplCopyWith<$Res> implements $UserCopyWith<$Res> {
|
||||
factory _$$UserImplCopyWith(
|
||||
_$UserImpl value, $Res Function(_$UserImpl) then) =
|
||||
__$$UserImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call(
|
||||
{String? id,
|
||||
String? name,
|
||||
String? email,
|
||||
String? password,
|
||||
DateTime? createdAt,
|
||||
DateTime? updatedAt});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$UserImplCopyWithImpl<$Res>
|
||||
extends _$UserCopyWithImpl<$Res, _$UserImpl>
|
||||
implements _$$UserImplCopyWith<$Res> {
|
||||
__$$UserImplCopyWithImpl(_$UserImpl _value, $Res Function(_$UserImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
/// Create a copy of User
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? id = freezed,
|
||||
Object? name = freezed,
|
||||
Object? email = freezed,
|
||||
Object? password = freezed,
|
||||
Object? createdAt = freezed,
|
||||
Object? updatedAt = freezed,
|
||||
}) {
|
||||
return _then(_$UserImpl(
|
||||
id: freezed == id
|
||||
? _value.id
|
||||
: id // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
name: freezed == name
|
||||
? _value.name
|
||||
: name // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
email: freezed == email
|
||||
? _value.email
|
||||
: email // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
password: freezed == password
|
||||
? _value.password
|
||||
: password // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
createdAt: freezed == createdAt
|
||||
? _value.createdAt
|
||||
: createdAt // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime?,
|
||||
updatedAt: freezed == updatedAt
|
||||
? _value.updatedAt
|
||||
: updatedAt // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime?,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$UserImpl implements _User {
|
||||
const _$UserImpl(
|
||||
{this.id,
|
||||
this.name,
|
||||
this.email,
|
||||
this.password,
|
||||
this.createdAt,
|
||||
this.updatedAt});
|
||||
|
||||
@override
|
||||
final String? id;
|
||||
@override
|
||||
final String? name;
|
||||
@override
|
||||
final String? email;
|
||||
@override
|
||||
final String? password;
|
||||
@override
|
||||
final DateTime? createdAt;
|
||||
@override
|
||||
final DateTime? updatedAt;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'User(id: $id, name: $name, email: $email, password: $password, createdAt: $createdAt, updatedAt: $updatedAt)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$UserImpl &&
|
||||
(identical(other.id, id) || other.id == id) &&
|
||||
(identical(other.name, name) || other.name == name) &&
|
||||
(identical(other.email, email) || other.email == email) &&
|
||||
(identical(other.password, password) ||
|
||||
other.password == password) &&
|
||||
(identical(other.createdAt, createdAt) ||
|
||||
other.createdAt == createdAt) &&
|
||||
(identical(other.updatedAt, updatedAt) ||
|
||||
other.updatedAt == updatedAt));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
Object.hash(runtimeType, id, name, email, password, createdAt, updatedAt);
|
||||
|
||||
/// Create a copy of User
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$UserImplCopyWith<_$UserImpl> get copyWith =>
|
||||
__$$UserImplCopyWithImpl<_$UserImpl>(this, _$identity);
|
||||
}
|
||||
|
||||
abstract class _User implements User {
|
||||
const factory _User(
|
||||
{final String? id,
|
||||
final String? name,
|
||||
final String? email,
|
||||
final String? password,
|
||||
final DateTime? createdAt,
|
||||
final DateTime? updatedAt}) = _$UserImpl;
|
||||
|
||||
@override
|
||||
String? get id;
|
||||
@override
|
||||
String? get name;
|
||||
@override
|
||||
String? get email;
|
||||
@override
|
||||
String? get password;
|
||||
@override
|
||||
DateTime? get createdAt;
|
||||
@override
|
||||
DateTime? get updatedAt;
|
||||
|
||||
/// Create a copy of User
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$UserImplCopyWith<_$UserImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
import 'package:backend_dart/domain/interface/error.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'error_code.dart';
|
||||
|
||||
part 'app_error.freezed.dart';
|
||||
|
||||
@freezed
|
||||
class AppError with _$AppError implements IError {
|
||||
const factory AppError({
|
||||
required ErrorCode code,
|
||||
required String message,
|
||||
Map<String, String>? details,
|
||||
StackTrace? stackTrace,
|
||||
Object? originalError,
|
||||
}) = _AppError;
|
||||
|
||||
factory AppError.fromException(Exception e) {
|
||||
return AppError(
|
||||
code: ErrorCode.exception,
|
||||
message: e.toString(),
|
||||
originalError: e,
|
||||
);
|
||||
}
|
||||
|
||||
factory AppError.fromErrorCode(ErrorCode code, {String? message}) {
|
||||
return AppError(
|
||||
code: code,
|
||||
message: message ?? "No message",
|
||||
stackTrace: StackTrace.current);
|
||||
}
|
||||
|
||||
factory AppError.notFound(String? message) {
|
||||
return AppError.fromErrorCode(ErrorCode.notFound, message: message);
|
||||
}
|
||||
|
||||
factory AppError.mappingError({String? message}) {
|
||||
return AppError.fromErrorCode(ErrorCode.mappingError, message: message);
|
||||
}
|
||||
|
||||
factory AppError.databaseError({String? message}) {
|
||||
return AppError.fromErrorCode(ErrorCode.databaseError, message: message);
|
||||
}
|
||||
|
||||
factory AppError.validationError({String? message}) {
|
||||
return AppError.fromErrorCode(ErrorCode.validationError, message: message);
|
||||
}
|
||||
|
||||
factory AppError.inputError({String? message}) {
|
||||
return AppError.fromErrorCode(ErrorCode.inputError, message: message);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,239 @@
|
||||
// coverage:ignore-file
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
||||
|
||||
part of 'app_error.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
T _$identity<T>(T value) => value;
|
||||
|
||||
final _privateConstructorUsedError = UnsupportedError(
|
||||
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models');
|
||||
|
||||
/// @nodoc
|
||||
mixin _$AppError {
|
||||
ErrorCode get code => throw _privateConstructorUsedError;
|
||||
String get message => throw _privateConstructorUsedError;
|
||||
Map<String, String>? get details => throw _privateConstructorUsedError;
|
||||
StackTrace? get stackTrace => throw _privateConstructorUsedError;
|
||||
Object? get originalError => throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of AppError
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
$AppErrorCopyWith<AppError> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $AppErrorCopyWith<$Res> {
|
||||
factory $AppErrorCopyWith(AppError value, $Res Function(AppError) then) =
|
||||
_$AppErrorCopyWithImpl<$Res, AppError>;
|
||||
@useResult
|
||||
$Res call(
|
||||
{ErrorCode code,
|
||||
String message,
|
||||
Map<String, String>? details,
|
||||
StackTrace? stackTrace,
|
||||
Object? originalError});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$AppErrorCopyWithImpl<$Res, $Val extends AppError>
|
||||
implements $AppErrorCopyWith<$Res> {
|
||||
_$AppErrorCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of AppError
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? code = null,
|
||||
Object? message = null,
|
||||
Object? details = freezed,
|
||||
Object? stackTrace = freezed,
|
||||
Object? originalError = freezed,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
code: null == code
|
||||
? _value.code
|
||||
: code // ignore: cast_nullable_to_non_nullable
|
||||
as ErrorCode,
|
||||
message: null == message
|
||||
? _value.message
|
||||
: message // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
details: freezed == details
|
||||
? _value.details
|
||||
: details // ignore: cast_nullable_to_non_nullable
|
||||
as Map<String, String>?,
|
||||
stackTrace: freezed == stackTrace
|
||||
? _value.stackTrace
|
||||
: stackTrace // ignore: cast_nullable_to_non_nullable
|
||||
as StackTrace?,
|
||||
originalError:
|
||||
freezed == originalError ? _value.originalError : originalError,
|
||||
) as $Val);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$AppErrorImplCopyWith<$Res>
|
||||
implements $AppErrorCopyWith<$Res> {
|
||||
factory _$$AppErrorImplCopyWith(
|
||||
_$AppErrorImpl value, $Res Function(_$AppErrorImpl) then) =
|
||||
__$$AppErrorImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call(
|
||||
{ErrorCode code,
|
||||
String message,
|
||||
Map<String, String>? details,
|
||||
StackTrace? stackTrace,
|
||||
Object? originalError});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$AppErrorImplCopyWithImpl<$Res>
|
||||
extends _$AppErrorCopyWithImpl<$Res, _$AppErrorImpl>
|
||||
implements _$$AppErrorImplCopyWith<$Res> {
|
||||
__$$AppErrorImplCopyWithImpl(
|
||||
_$AppErrorImpl _value, $Res Function(_$AppErrorImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
/// Create a copy of AppError
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? code = null,
|
||||
Object? message = null,
|
||||
Object? details = freezed,
|
||||
Object? stackTrace = freezed,
|
||||
Object? originalError = freezed,
|
||||
}) {
|
||||
return _then(_$AppErrorImpl(
|
||||
code: null == code
|
||||
? _value.code
|
||||
: code // ignore: cast_nullable_to_non_nullable
|
||||
as ErrorCode,
|
||||
message: null == message
|
||||
? _value.message
|
||||
: message // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
details: freezed == details
|
||||
? _value._details
|
||||
: details // ignore: cast_nullable_to_non_nullable
|
||||
as Map<String, String>?,
|
||||
stackTrace: freezed == stackTrace
|
||||
? _value.stackTrace
|
||||
: stackTrace // ignore: cast_nullable_to_non_nullable
|
||||
as StackTrace?,
|
||||
originalError:
|
||||
freezed == originalError ? _value.originalError : originalError,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$AppErrorImpl implements _AppError {
|
||||
const _$AppErrorImpl(
|
||||
{required this.code,
|
||||
required this.message,
|
||||
final Map<String, String>? details,
|
||||
this.stackTrace,
|
||||
this.originalError})
|
||||
: _details = details;
|
||||
|
||||
@override
|
||||
final ErrorCode code;
|
||||
@override
|
||||
final String message;
|
||||
final Map<String, String>? _details;
|
||||
@override
|
||||
Map<String, String>? get details {
|
||||
final value = _details;
|
||||
if (value == null) return null;
|
||||
if (_details is EqualUnmodifiableMapView) return _details;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableMapView(value);
|
||||
}
|
||||
|
||||
@override
|
||||
final StackTrace? stackTrace;
|
||||
@override
|
||||
final Object? originalError;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'AppError(code: $code, message: $message, details: $details, stackTrace: $stackTrace, originalError: $originalError)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$AppErrorImpl &&
|
||||
(identical(other.code, code) || other.code == code) &&
|
||||
(identical(other.message, message) || other.message == message) &&
|
||||
const DeepCollectionEquality().equals(other._details, _details) &&
|
||||
(identical(other.stackTrace, stackTrace) ||
|
||||
other.stackTrace == stackTrace) &&
|
||||
const DeepCollectionEquality()
|
||||
.equals(other.originalError, originalError));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(
|
||||
runtimeType,
|
||||
code,
|
||||
message,
|
||||
const DeepCollectionEquality().hash(_details),
|
||||
stackTrace,
|
||||
const DeepCollectionEquality().hash(originalError));
|
||||
|
||||
/// Create a copy of AppError
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$AppErrorImplCopyWith<_$AppErrorImpl> get copyWith =>
|
||||
__$$AppErrorImplCopyWithImpl<_$AppErrorImpl>(this, _$identity);
|
||||
}
|
||||
|
||||
abstract class _AppError implements AppError {
|
||||
const factory _AppError(
|
||||
{required final ErrorCode code,
|
||||
required final String message,
|
||||
final Map<String, String>? details,
|
||||
final StackTrace? stackTrace,
|
||||
final Object? originalError}) = _$AppErrorImpl;
|
||||
|
||||
@override
|
||||
ErrorCode get code;
|
||||
@override
|
||||
String get message;
|
||||
@override
|
||||
Map<String, String>? get details;
|
||||
@override
|
||||
StackTrace? get stackTrace;
|
||||
@override
|
||||
Object? get originalError;
|
||||
|
||||
/// Create a copy of AppError
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$AppErrorImplCopyWith<_$AppErrorImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
enum ErrorCode {
|
||||
networkError, // Fehler bei der Netzwerkkommunikation
|
||||
validationError, // Eingabevalidierungsfehler
|
||||
unexpectedError, // Unerwarteter Fehler
|
||||
authenticationError, // Authentifizierungsfehler
|
||||
permissionDenied, // Berechtigungsfehler
|
||||
notFound, // Ressource nicht gefunden
|
||||
exception, // Ausnahme
|
||||
mappingError, // Fehler beim Zuordnen von Daten
|
||||
databaseError, // Datenbankfehler
|
||||
inputError, // Eingabefehler
|
||||
outputError, // Ausgabefehler
|
||||
internalError, // Interner Fehler
|
||||
unknownError, // Unbekannter Fehler
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import 'package:backend_dart/domain/data/user_data_source.dart';
|
||||
import 'package:backend_dart/domain/entities/user.dart';
|
||||
|
||||
abstract class IDatabase {
|
||||
UserDataSource<User> get users;
|
||||
Future<void> close();
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import 'package:backend_dart/domain/errors/error_code.dart';
|
||||
|
||||
abstract class IError {
|
||||
ErrorCode get code; // Fehlercode
|
||||
String get message; // Fehlermeldung
|
||||
StackTrace? get stackTrace; // Stacktrace
|
||||
Map<String, String>? get details; // Zusätzliche Details
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import 'package:backend_dart/domain/interface/error.dart';
|
||||
import 'package:fpdart/fpdart.dart';
|
||||
|
||||
abstract class IMapper<U, V> {
|
||||
/// Konvertiert von Typ U (Origin) zu Typ V (Target)
|
||||
TaskEither<IError, V> to(U origin);
|
||||
|
||||
/// Konvertiert von Typ V (Target) zu Typ U (Origin)
|
||||
TaskEither<IError, U> from(V target);
|
||||
|
||||
/// Konvertiert eine Liste von Typ U (Origin) zu einer Liste von Typ V (Target)
|
||||
TaskEither<IError, List<V>> listTo(Iterable<U> origins);
|
||||
|
||||
/// Konvertiert eine Liste von Typ V (Target) zu einer Liste von Typ U (Origin)
|
||||
TaskEither<IError, List<U>> listFrom(Iterable<V> targets);
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
import 'package:backend_dart/domain/entities/user.dart';
|
||||
|
||||
abstract class UserRepository {
|
||||
Future<void> create(User user);
|
||||
Future<User?> findByEmail(String email);
|
||||
Future<User?> findById(String id);
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
import 'package:backend_dart/domain/entities/user.dart';
|
||||
import 'package:backend_dart/domain/interface/error.dart';
|
||||
import 'package:fpdart/fpdart.dart';
|
||||
|
||||
abstract class UserRepository {
|
||||
TaskEither<IError, User> create(User user);
|
||||
|
||||
TaskEither<IError, User> findByEmail(String email);
|
||||
|
||||
TaskEither<IError, User> findById(String id);
|
||||
|
||||
TaskEither<IError, User> update(User user);
|
||||
|
||||
TaskEither<IError, void> delete(String id);
|
||||
|
||||
TaskEither<IError, List<User>> findAll();
|
||||
}
|
||||
Reference in New Issue
Block a user