feat(wyatt_app_template): use brickgen
This commit is contained in:
+9
@@ -0,0 +1,9 @@
|
||||
import 'package:starting_template/domain/entities/integer.dart';
|
||||
import 'package:wyatt_architecture/wyatt_architecture.dart';
|
||||
|
||||
abstract class CounterDataSource extends BaseDataSource {
|
||||
Future<Integer> decrement(Integer value);
|
||||
Future<Integer> increment(Integer value);
|
||||
Future<Integer> getCurrent();
|
||||
Future<Integer> reset();
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
# just to keep empty folder in brick generation
|
||||
@@ -0,0 +1,11 @@
|
||||
// ignore_for_file: public_member_api_docs, sort_constructors_first
|
||||
import 'package:wyatt_architecture/wyatt_architecture.dart';
|
||||
|
||||
class Integer extends Entity {
|
||||
const Integer(this.value);
|
||||
|
||||
final int value;
|
||||
|
||||
@override
|
||||
String toString() => 'Integer(value: $value)';
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
import 'package:starting_template/domain/entities/integer.dart';
|
||||
import 'package:wyatt_architecture/wyatt_architecture.dart';
|
||||
|
||||
abstract class CounterRepository extends BaseRepository {
|
||||
FutureOrResult<Integer> decrement({Integer by = const Integer(1)});
|
||||
FutureOrResult<Integer> increment({Integer by = const Integer(1)});
|
||||
FutureOrResult<Integer> getCurrent();
|
||||
FutureOrResult<Integer> reset();
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import 'package:starting_template/domain/entities/integer.dart';
|
||||
import 'package:starting_template/domain/repositories/counter_repository.dart';
|
||||
import 'package:wyatt_architecture/wyatt_architecture.dart';
|
||||
|
||||
class Decrement extends AsyncUseCase<int, Integer> {
|
||||
Decrement({
|
||||
required CounterRepository counterRepository,
|
||||
}) : _counterRepository = counterRepository;
|
||||
|
||||
final CounterRepository _counterRepository;
|
||||
|
||||
@override
|
||||
FutureOrResult<Integer> execute(int? params) async {
|
||||
final step = Integer(params ?? 1);
|
||||
|
||||
return _counterRepository.decrement(by: step);
|
||||
}
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
// Copyright (C) 2023 WYATT GROUP
|
||||
// Please see the AUTHORS file for details.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
import 'package:starting_template/domain/entities/integer.dart';
|
||||
import 'package:starting_template/domain/repositories/counter_repository.dart';
|
||||
import 'package:wyatt_architecture/wyatt_architecture.dart';
|
||||
|
||||
class GetCurrent extends AsyncUseCase<void, Integer> {
|
||||
GetCurrent({
|
||||
required CounterRepository counterRepository,
|
||||
}) : _counterRepository = counterRepository;
|
||||
|
||||
final CounterRepository _counterRepository;
|
||||
|
||||
@override
|
||||
FutureOrResult<Integer> execute(void params) async =>
|
||||
_counterRepository.getCurrent();
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import 'package:starting_template/domain/entities/integer.dart';
|
||||
import 'package:starting_template/domain/repositories/counter_repository.dart';
|
||||
import 'package:wyatt_architecture/wyatt_architecture.dart';
|
||||
|
||||
class Increment extends AsyncUseCase<int, Integer> {
|
||||
Increment({
|
||||
required CounterRepository counterRepository,
|
||||
}) : _counterRepository = counterRepository;
|
||||
|
||||
final CounterRepository _counterRepository;
|
||||
|
||||
@override
|
||||
FutureOrResult<Integer> execute(int? params) async {
|
||||
final step = Integer(params ?? 1);
|
||||
|
||||
return _counterRepository.increment(by: step);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
// Copyright (C) 2023 WYATT GROUP
|
||||
// Please see the AUTHORS file for details.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
import 'package:starting_template/domain/entities/integer.dart';
|
||||
import 'package:starting_template/domain/repositories/counter_repository.dart';
|
||||
import 'package:wyatt_architecture/wyatt_architecture.dart';
|
||||
|
||||
class Reset extends AsyncUseCase<void, Integer> {
|
||||
Reset({
|
||||
required CounterRepository counterRepository,
|
||||
}) : _counterRepository = counterRepository;
|
||||
|
||||
final CounterRepository _counterRepository;
|
||||
|
||||
@override
|
||||
FutureOrResult<Integer> execute(void params) async =>
|
||||
_counterRepository.reset();
|
||||
}
|
||||
Reference in New Issue
Block a user