feat: implement some api; add md editor to app; login and signup logic.
This commit is contained in:
+34
-1
@@ -1,3 +1,5 @@
|
||||
import 'package:angel3_migration/angel3_migration.dart';
|
||||
import 'package:angel3_orm_postgres/angel3_orm_postgres.dart';
|
||||
import 'package:dde_gesture_manager_api/src/config/plugins/orm.dart';
|
||||
import 'package:dde_gesture_manager_api/models.dart';
|
||||
import 'package:angel3_configuration/angel3_configuration.dart';
|
||||
@@ -6,6 +8,8 @@ import 'package:angel3_migration_runner/postgres.dart';
|
||||
import 'package:file/local.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
|
||||
late Map configuration;
|
||||
|
||||
void main(List<String> args) async {
|
||||
// Enable the logging
|
||||
Logger.root.level = Level.INFO;
|
||||
@@ -19,10 +23,39 @@ void main(List<String> args) async {
|
||||
});
|
||||
|
||||
var fs = LocalFileSystem();
|
||||
var configuration = await loadStandaloneConfiguration(fs);
|
||||
configuration = await loadStandaloneConfiguration(fs);
|
||||
var connection = await connectToPostgres(configuration);
|
||||
var migrationRunner = PostgresMigrationRunner(connection, migrations: [
|
||||
UserMigration(),
|
||||
UserSeed(),
|
||||
]);
|
||||
await runMigrations(migrationRunner, args);
|
||||
}
|
||||
|
||||
class UserSeed extends Migration {
|
||||
@override
|
||||
void up(Schema schema) async {
|
||||
await doUserSeed();
|
||||
}
|
||||
|
||||
@override
|
||||
void down(Schema schema) async {}
|
||||
}
|
||||
|
||||
Future doUserSeed() async {
|
||||
var connection = await connectToPostgres(configuration);
|
||||
await connection.open();
|
||||
var executor = PostgreSqlExecutor(connection);
|
||||
var userQuery = UserQuery();
|
||||
userQuery.where?.email.equals('admin@admin.com');
|
||||
var one = await userQuery.getOne(executor);
|
||||
if (one.isEmpty) {
|
||||
userQuery = UserQuery();
|
||||
userQuery.values.copyFrom(User(
|
||||
email: 'admin@admin.com',
|
||||
password: '1234567890',
|
||||
));
|
||||
return userQuery.insert(executor).then((value) => connection.close());
|
||||
}
|
||||
return connection.close();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user