mirror of
https://github.com/timokz/flutter-vienna-hackathon-25.git
synced 2025-11-08 23:44:19 +01:00
Compare commits
No commits in common. "68e7a9720ac4917c184315a7aaae65df9fee86ff" and "c64fa677ac86e05ce5a03cbc9e6f0aee77e1e75b" have entirely different histories.
68e7a9720a
...
c64fa677ac
25 changed files with 142 additions and 3896 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1,3 +1,2 @@
|
|||
wien_talks/wien_talks_flutter/pubspec.lock
|
||||
wien_talks/wien_talks_flutter/android/app/google-services.json
|
||||
*.pptx#
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -13,68 +13,44 @@ import 'package:serverpod_client/serverpod_client.dart' as _i1;
|
|||
import 'dart:async' as _i2;
|
||||
import 'package:wien_talks_client/src/protocol/quotes/quote.dart' as _i3;
|
||||
import 'package:wien_talks_client/src/protocol/quotes/create_quote.dart' as _i4;
|
||||
import 'package:wien_talks_client/src/protocol/votes/vote.dart' as _i5;
|
||||
import 'package:wien_talks_client/src/protocol/votes/vote_request.dart' as _i6;
|
||||
import 'package:serverpod_auth_client/serverpod_auth_client.dart' as _i7;
|
||||
import 'protocol.dart' as _i8;
|
||||
import 'package:serverpod_auth_client/serverpod_auth_client.dart' as _i5;
|
||||
import 'protocol.dart' as _i6;
|
||||
|
||||
/// {@category Endpoint}
|
||||
class EndpointQuote extends _i1.EndpointRef {
|
||||
EndpointQuote(_i1.EndpointCaller caller) : super(caller);
|
||||
class EndpointShowLatestNewsWidget extends _i1.EndpointRef {
|
||||
EndpointShowLatestNewsWidget(_i1.EndpointCaller caller) : super(caller);
|
||||
|
||||
@override
|
||||
String get name => 'quote';
|
||||
String get name => 'showLatestNewsWidget';
|
||||
|
||||
_i2.Future<_i3.Quote> createQuote(_i4.CreateQuoteRequest req) =>
|
||||
caller.callServerEndpoint<_i3.Quote>(
|
||||
'quote',
|
||||
'showLatestNewsWidget',
|
||||
'createQuote',
|
||||
{'req': req},
|
||||
);
|
||||
|
||||
_i2.Future<void> updateQuote(_i3.Quote quote) =>
|
||||
caller.callServerEndpoint<void>(
|
||||
'quote',
|
||||
'showLatestNewsWidget',
|
||||
'updateQuote',
|
||||
{'quote': quote},
|
||||
);
|
||||
|
||||
_i2.Future<List<_i3.Quote>> getAllQuotes() =>
|
||||
_i2.Future<List<_i3.Quote>> getAllQuotes({required int limit}) =>
|
||||
caller.callServerEndpoint<List<_i3.Quote>>(
|
||||
'quote',
|
||||
'showLatestNewsWidget',
|
||||
'getAllQuotes',
|
||||
{},
|
||||
);
|
||||
}
|
||||
|
||||
/// {@category Endpoint}
|
||||
class EndpointVotes extends _i1.EndpointRef {
|
||||
EndpointVotes(_i1.EndpointCaller caller) : super(caller);
|
||||
|
||||
@override
|
||||
String get name => 'votes';
|
||||
|
||||
_i2.Future<_i5.Vote> postVote(_i6.VoteRequest voteRequest) =>
|
||||
caller.callServerEndpoint<_i5.Vote>(
|
||||
'votes',
|
||||
'postVote',
|
||||
{'voteRequest': voteRequest},
|
||||
);
|
||||
|
||||
_i2.Future<List<_i5.Vote>> getAllVotes() =>
|
||||
caller.callServerEndpoint<List<_i5.Vote>>(
|
||||
'votes',
|
||||
'getAllVotes',
|
||||
{},
|
||||
{'limit': limit},
|
||||
);
|
||||
}
|
||||
|
||||
class Modules {
|
||||
Modules(Client client) {
|
||||
auth = _i7.Caller(client);
|
||||
auth = _i5.Caller(client);
|
||||
}
|
||||
|
||||
late final _i7.Caller auth;
|
||||
late final _i5.Caller auth;
|
||||
}
|
||||
|
||||
class Client extends _i1.ServerpodClientShared {
|
||||
|
|
@ -93,7 +69,7 @@ class Client extends _i1.ServerpodClientShared {
|
|||
bool? disconnectStreamsOnLostInternetConnection,
|
||||
}) : super(
|
||||
host,
|
||||
_i8.Protocol(),
|
||||
_i6.Protocol(),
|
||||
securityContext: securityContext,
|
||||
authenticationKeyManager: authenticationKeyManager,
|
||||
streamingConnectionTimeout: streamingConnectionTimeout,
|
||||
|
|
@ -103,22 +79,17 @@ class Client extends _i1.ServerpodClientShared {
|
|||
disconnectStreamsOnLostInternetConnection:
|
||||
disconnectStreamsOnLostInternetConnection,
|
||||
) {
|
||||
quote = EndpointQuote(this);
|
||||
votes = EndpointVotes(this);
|
||||
showLatestNewsWidget = EndpointShowLatestNewsWidget(this);
|
||||
modules = Modules(this);
|
||||
}
|
||||
|
||||
late final EndpointQuote quote;
|
||||
|
||||
late final EndpointVotes votes;
|
||||
late final EndpointShowLatestNewsWidget showLatestNewsWidget;
|
||||
|
||||
late final Modules modules;
|
||||
|
||||
@override
|
||||
Map<String, _i1.EndpointRef> get endpointRefLookup => {
|
||||
'quote': quote,
|
||||
'votes': votes,
|
||||
};
|
||||
Map<String, _i1.EndpointRef> get endpointRefLookup =>
|
||||
{'showLatestNewsWidget': showLatestNewsWidget};
|
||||
|
||||
@override
|
||||
Map<String, _i1.ModuleEndpointCaller> get moduleLookup =>
|
||||
|
|
|
|||
|
|
@ -12,15 +12,10 @@
|
|||
import 'package:serverpod_client/serverpod_client.dart' as _i1;
|
||||
import 'quotes/create_quote.dart' as _i2;
|
||||
import 'quotes/quote.dart' as _i3;
|
||||
import 'votes/vote.dart' as _i4;
|
||||
import 'votes/vote_request.dart' as _i5;
|
||||
import 'package:wien_talks_client/src/protocol/quotes/quote.dart' as _i6;
|
||||
import 'package:wien_talks_client/src/protocol/votes/vote.dart' as _i7;
|
||||
import 'package:serverpod_auth_client/serverpod_auth_client.dart' as _i8;
|
||||
import 'package:wien_talks_client/src/protocol/quotes/quote.dart' as _i4;
|
||||
import 'package:serverpod_auth_client/serverpod_auth_client.dart' as _i5;
|
||||
export 'quotes/create_quote.dart';
|
||||
export 'quotes/quote.dart';
|
||||
export 'votes/vote.dart';
|
||||
export 'votes/vote_request.dart';
|
||||
export 'client.dart';
|
||||
|
||||
class Protocol extends _i1.SerializationManager {
|
||||
|
|
@ -42,24 +37,12 @@ class Protocol extends _i1.SerializationManager {
|
|||
if (t == _i3.Quote) {
|
||||
return _i3.Quote.fromJson(data) as T;
|
||||
}
|
||||
if (t == _i4.Vote) {
|
||||
return _i4.Vote.fromJson(data) as T;
|
||||
}
|
||||
if (t == _i5.VoteRequest) {
|
||||
return _i5.VoteRequest.fromJson(data) as T;
|
||||
}
|
||||
if (t == _i1.getType<_i2.CreateQuoteRequest?>()) {
|
||||
return (data != null ? _i2.CreateQuoteRequest.fromJson(data) : null) as T;
|
||||
}
|
||||
if (t == _i1.getType<_i3.Quote?>()) {
|
||||
return (data != null ? _i3.Quote.fromJson(data) : null) as T;
|
||||
}
|
||||
if (t == _i1.getType<_i4.Vote?>()) {
|
||||
return (data != null ? _i4.Vote.fromJson(data) : null) as T;
|
||||
}
|
||||
if (t == _i1.getType<_i5.VoteRequest?>()) {
|
||||
return (data != null ? _i5.VoteRequest.fromJson(data) : null) as T;
|
||||
}
|
||||
if (t == _i1.getType<List<String>?>()) {
|
||||
return (data != null
|
||||
? (data as List).map((e) => deserialize<String>(e)).toList()
|
||||
|
|
@ -70,14 +53,11 @@ class Protocol extends _i1.SerializationManager {
|
|||
? (data as List).map((e) => deserialize<String>(e)).toList()
|
||||
: null) as T;
|
||||
}
|
||||
if (t == List<_i6.Quote>) {
|
||||
return (data as List).map((e) => deserialize<_i6.Quote>(e)).toList() as T;
|
||||
}
|
||||
if (t == List<_i7.Vote>) {
|
||||
return (data as List).map((e) => deserialize<_i7.Vote>(e)).toList() as T;
|
||||
if (t == List<_i4.Quote>) {
|
||||
return (data as List).map((e) => deserialize<_i4.Quote>(e)).toList() as T;
|
||||
}
|
||||
try {
|
||||
return _i8.Protocol().deserialize<T>(data, t);
|
||||
return _i5.Protocol().deserialize<T>(data, t);
|
||||
} on _i1.DeserializationTypeNotFoundException catch (_) {}
|
||||
return super.deserialize<T>(data, t);
|
||||
}
|
||||
|
|
@ -92,13 +72,7 @@ class Protocol extends _i1.SerializationManager {
|
|||
if (data is _i3.Quote) {
|
||||
return 'Quote';
|
||||
}
|
||||
if (data is _i4.Vote) {
|
||||
return 'Vote';
|
||||
}
|
||||
if (data is _i5.VoteRequest) {
|
||||
return 'VoteRequest';
|
||||
}
|
||||
className = _i8.Protocol().getClassNameForObject(data);
|
||||
className = _i5.Protocol().getClassNameForObject(data);
|
||||
if (className != null) {
|
||||
return 'serverpod_auth.$className';
|
||||
}
|
||||
|
|
@ -117,15 +91,9 @@ class Protocol extends _i1.SerializationManager {
|
|||
if (dataClassName == 'Quote') {
|
||||
return deserialize<_i3.Quote>(data['data']);
|
||||
}
|
||||
if (dataClassName == 'Vote') {
|
||||
return deserialize<_i4.Vote>(data['data']);
|
||||
}
|
||||
if (dataClassName == 'VoteRequest') {
|
||||
return deserialize<_i5.VoteRequest>(data['data']);
|
||||
}
|
||||
if (dataClassName.startsWith('serverpod_auth.')) {
|
||||
data['className'] = dataClassName.substring(15);
|
||||
return _i8.Protocol().deserializeByClassName(data);
|
||||
return _i5.Protocol().deserializeByClassName(data);
|
||||
}
|
||||
return super.deserializeByClassName(data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,120 +0,0 @@
|
|||
/* AUTOMATICALLY GENERATED CODE DO NOT MODIFY */
|
||||
/* To generate run: "serverpod generate" */
|
||||
|
||||
// ignore_for_file: implementation_imports
|
||||
// ignore_for_file: library_private_types_in_public_api
|
||||
// ignore_for_file: non_constant_identifier_names
|
||||
// ignore_for_file: public_member_api_docs
|
||||
// ignore_for_file: type_literal_in_constant_pattern
|
||||
// ignore_for_file: use_super_parameters
|
||||
|
||||
// ignore_for_file: no_leading_underscores_for_library_prefixes
|
||||
import 'package:serverpod_client/serverpod_client.dart' as _i1;
|
||||
import '../quotes/quote.dart' as _i2;
|
||||
|
||||
abstract class Vote implements _i1.SerializableModel {
|
||||
Vote._({
|
||||
this.id,
|
||||
required this.userId,
|
||||
required this.createdAt,
|
||||
required this.quote,
|
||||
required this.upvote,
|
||||
});
|
||||
|
||||
factory Vote({
|
||||
int? id,
|
||||
required int userId,
|
||||
required DateTime createdAt,
|
||||
required _i2.Quote quote,
|
||||
required bool upvote,
|
||||
}) = _VoteImpl;
|
||||
|
||||
factory Vote.fromJson(Map<String, dynamic> jsonSerialization) {
|
||||
return Vote(
|
||||
id: jsonSerialization['id'] as int?,
|
||||
userId: jsonSerialization['userId'] as int,
|
||||
createdAt:
|
||||
_i1.DateTimeJsonExtension.fromJson(jsonSerialization['createdAt']),
|
||||
quote: _i2.Quote.fromJson(
|
||||
(jsonSerialization['quote'] as Map<String, dynamic>)),
|
||||
upvote: jsonSerialization['upvote'] as bool,
|
||||
);
|
||||
}
|
||||
|
||||
/// The database id, set if the object has been inserted into the
|
||||
/// database or if it has been fetched from the database. Otherwise,
|
||||
/// the id will be null.
|
||||
int? id;
|
||||
|
||||
int userId;
|
||||
|
||||
DateTime createdAt;
|
||||
|
||||
_i2.Quote quote;
|
||||
|
||||
bool upvote;
|
||||
|
||||
/// Returns a shallow copy of this [Vote]
|
||||
/// with some or all fields replaced by the given arguments.
|
||||
@_i1.useResult
|
||||
Vote copyWith({
|
||||
int? id,
|
||||
int? userId,
|
||||
DateTime? createdAt,
|
||||
_i2.Quote? quote,
|
||||
bool? upvote,
|
||||
});
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
if (id != null) 'id': id,
|
||||
'userId': userId,
|
||||
'createdAt': createdAt.toJson(),
|
||||
'quote': quote.toJson(),
|
||||
'upvote': upvote,
|
||||
};
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return _i1.SerializationManager.encode(this);
|
||||
}
|
||||
}
|
||||
|
||||
class _Undefined {}
|
||||
|
||||
class _VoteImpl extends Vote {
|
||||
_VoteImpl({
|
||||
int? id,
|
||||
required int userId,
|
||||
required DateTime createdAt,
|
||||
required _i2.Quote quote,
|
||||
required bool upvote,
|
||||
}) : super._(
|
||||
id: id,
|
||||
userId: userId,
|
||||
createdAt: createdAt,
|
||||
quote: quote,
|
||||
upvote: upvote,
|
||||
);
|
||||
|
||||
/// Returns a shallow copy of this [Vote]
|
||||
/// with some or all fields replaced by the given arguments.
|
||||
@_i1.useResult
|
||||
@override
|
||||
Vote copyWith({
|
||||
Object? id = _Undefined,
|
||||
int? userId,
|
||||
DateTime? createdAt,
|
||||
_i2.Quote? quote,
|
||||
bool? upvote,
|
||||
}) {
|
||||
return Vote(
|
||||
id: id is int? ? id : this.id,
|
||||
userId: userId ?? this.userId,
|
||||
createdAt: createdAt ?? this.createdAt,
|
||||
quote: quote ?? this.quote.copyWith(),
|
||||
upvote: upvote ?? this.upvote,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,108 +0,0 @@
|
|||
/* AUTOMATICALLY GENERATED CODE DO NOT MODIFY */
|
||||
/* To generate run: "serverpod generate" */
|
||||
|
||||
// ignore_for_file: implementation_imports
|
||||
// ignore_for_file: library_private_types_in_public_api
|
||||
// ignore_for_file: non_constant_identifier_names
|
||||
// ignore_for_file: public_member_api_docs
|
||||
// ignore_for_file: type_literal_in_constant_pattern
|
||||
// ignore_for_file: use_super_parameters
|
||||
|
||||
// ignore_for_file: no_leading_underscores_for_library_prefixes
|
||||
import 'package:serverpod_client/serverpod_client.dart' as _i1;
|
||||
import '../quotes/quote.dart' as _i2;
|
||||
|
||||
abstract class VoteRequest implements _i1.SerializableModel {
|
||||
VoteRequest._({
|
||||
this.id,
|
||||
required this.userId,
|
||||
required this.quote,
|
||||
required this.upvote,
|
||||
});
|
||||
|
||||
factory VoteRequest({
|
||||
int? id,
|
||||
required int userId,
|
||||
required _i2.Quote quote,
|
||||
required bool upvote,
|
||||
}) = _VoteRequestImpl;
|
||||
|
||||
factory VoteRequest.fromJson(Map<String, dynamic> jsonSerialization) {
|
||||
return VoteRequest(
|
||||
id: jsonSerialization['id'] as int?,
|
||||
userId: jsonSerialization['userId'] as int,
|
||||
quote: _i2.Quote.fromJson(
|
||||
(jsonSerialization['quote'] as Map<String, dynamic>)),
|
||||
upvote: jsonSerialization['upvote'] as bool,
|
||||
);
|
||||
}
|
||||
|
||||
/// The database id, set if the object has been inserted into the
|
||||
/// database or if it has been fetched from the database. Otherwise,
|
||||
/// the id will be null.
|
||||
int? id;
|
||||
|
||||
int userId;
|
||||
|
||||
_i2.Quote quote;
|
||||
|
||||
bool upvote;
|
||||
|
||||
/// Returns a shallow copy of this [VoteRequest]
|
||||
/// with some or all fields replaced by the given arguments.
|
||||
@_i1.useResult
|
||||
VoteRequest copyWith({
|
||||
int? id,
|
||||
int? userId,
|
||||
_i2.Quote? quote,
|
||||
bool? upvote,
|
||||
});
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
if (id != null) 'id': id,
|
||||
'userId': userId,
|
||||
'quote': quote.toJson(),
|
||||
'upvote': upvote,
|
||||
};
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return _i1.SerializationManager.encode(this);
|
||||
}
|
||||
}
|
||||
|
||||
class _Undefined {}
|
||||
|
||||
class _VoteRequestImpl extends VoteRequest {
|
||||
_VoteRequestImpl({
|
||||
int? id,
|
||||
required int userId,
|
||||
required _i2.Quote quote,
|
||||
required bool upvote,
|
||||
}) : super._(
|
||||
id: id,
|
||||
userId: userId,
|
||||
quote: quote,
|
||||
upvote: upvote,
|
||||
);
|
||||
|
||||
/// Returns a shallow copy of this [VoteRequest]
|
||||
/// with some or all fields replaced by the given arguments.
|
||||
@_i1.useResult
|
||||
@override
|
||||
VoteRequest copyWith({
|
||||
Object? id = _Undefined,
|
||||
int? userId,
|
||||
_i2.Quote? quote,
|
||||
bool? upvote,
|
||||
}) {
|
||||
return VoteRequest(
|
||||
id: id is int? ? id : this.id,
|
||||
userId: userId ?? this.userId,
|
||||
quote: quote ?? this.quote.copyWith(),
|
||||
upvote: upvote ?? this.upvote,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -25,7 +25,7 @@ class _GetLocationWidgetState extends State<GetLocationWidget> {
|
|||
switch (snapshot.connectionState) {
|
||||
case ConnectionState.none:
|
||||
case ConnectionState.waiting:
|
||||
return Center(child: CircularProgressIndicator());
|
||||
return CircularProgressIndicator();
|
||||
case ConnectionState.active:
|
||||
case ConnectionState.done:
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:location/location.dart';
|
||||
import 'package:mapsforge_flutter/core.dart';
|
||||
|
|
@ -35,7 +34,7 @@ class LocationMgr {
|
|||
|
||||
final SymbolCache symbolCache = FileSymbolCache();
|
||||
|
||||
final JobRenderer jobRenderer = kIsWeb ? MapOnlineRendererWeb() : MapOnlineRenderer();
|
||||
final JobRenderer jobRenderer = MapOnlineRenderer();
|
||||
|
||||
final MarkerByItemDataStore markerDataStore = MarkerByItemDataStore();
|
||||
|
||||
|
|
|
|||
|
|
@ -4,54 +4,84 @@ import 'package:flutter/material.dart';
|
|||
import 'package:wien_talks_client/wien_talks_client.dart';
|
||||
import 'package:wien_talks_flutter/helper/funmap_mgr.dart';
|
||||
|
||||
class ShowLatestNewsWidget extends StatelessWidget {
|
||||
class ShowLatestNewsWidget extends StatefulWidget {
|
||||
const ShowLatestNewsWidget({super.key});
|
||||
@override
|
||||
State<ShowLatestNewsWidget> createState() => _ShowLatestNewsWidgetState();
|
||||
}
|
||||
|
||||
Future<List<Quote>> _load() async {
|
||||
final list = await FunmapMgr().client.quote.getAllQuotes();
|
||||
return list.whereType<Quote>().toList(growable: false);
|
||||
class _ShowLatestNewsWidgetState extends State<ShowLatestNewsWidget> {
|
||||
final _controller = StreamController<List<Quote>>.broadcast();
|
||||
Timer? _timer;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_reload();
|
||||
_timer = Timer.periodic(const Duration(seconds: 30), (_) => _reload());
|
||||
}
|
||||
|
||||
Future<void> _reload() async {
|
||||
try {
|
||||
final quotes = await FunmapMgr().client.quote.getAllQuotes(limit: 200);
|
||||
_controller.add(quotes);
|
||||
} catch (e, st) {
|
||||
_controller.addError(e, st);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_timer?.cancel();
|
||||
_controller.close();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return FutureBuilder<List<Quote>>(
|
||||
future: _load(),
|
||||
builder: (context, snap) {
|
||||
if (snap.connectionState != ConnectionState.done) {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
}
|
||||
if (snap.hasError) {
|
||||
return Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Text('Error: ${snap.error}'),
|
||||
),
|
||||
);
|
||||
}
|
||||
final quotes = snap.data ?? const <Quote>[];
|
||||
if (quotes.isEmpty) {
|
||||
return const Center(child: Text('No quotes yet.'));
|
||||
}
|
||||
|
||||
return ListView.separated(
|
||||
itemCount: quotes.length,
|
||||
separatorBuilder: (_, __) => const Divider(height: 1),
|
||||
itemBuilder: (context, i) {
|
||||
final q = quotes[i];
|
||||
final author = (q.authorName ?? '').trim();
|
||||
final when = (q.createdAt ?? DateTime.fromMillisecondsSinceEpoch(0))
|
||||
.toLocal()
|
||||
.toString();
|
||||
return ListTile(
|
||||
title: Text(q.text),
|
||||
subtitle: Text([
|
||||
if (author.isNotEmpty) author,
|
||||
when,
|
||||
].join(' · ')),
|
||||
return RefreshIndicator(
|
||||
onRefresh: _reload,
|
||||
child: StreamBuilder<List<Quote>>(
|
||||
stream: _controller.stream,
|
||||
initialData: const <Quote>[],
|
||||
builder: (context, snap) {
|
||||
if (snap.hasError) {
|
||||
return ListView(
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Text('Error: ${snap.error}'),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
}
|
||||
final quotes = snap.data ?? const <Quote>[];
|
||||
if (quotes.isEmpty) {
|
||||
return ListView(
|
||||
children: const [
|
||||
Padding(
|
||||
padding: EdgeInsets.all(16),
|
||||
child: Text('No quotes yet. Pull to refresh.'),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
return ListView.separated(
|
||||
itemCount: quotes.length,
|
||||
separatorBuilder: (_, __) => const Divider(height: 1),
|
||||
itemBuilder: (context, i) {
|
||||
final q = quotes[i];
|
||||
return ListTile(
|
||||
title: Text(q.text),
|
||||
subtitle: Text([
|
||||
if ((q.authorName ?? '').isNotEmpty) q.authorName!,
|
||||
q.createdAt.toLocal().toString(),
|
||||
].where((e) => e.isNotEmpty).join(' · ')),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,40 +11,32 @@
|
|||
// ignore_for_file: no_leading_underscores_for_library_prefixes
|
||||
import 'package:serverpod/serverpod.dart' as _i1;
|
||||
import '../quotes/quotes_endpoint.dart' as _i2;
|
||||
import '../votes/votes_endpoint.dart' as _i3;
|
||||
import 'package:wien_talks_server/src/generated/quotes/create_quote.dart'
|
||||
as _i4;
|
||||
import 'package:wien_talks_server/src/generated/quotes/quote.dart' as _i5;
|
||||
import 'package:wien_talks_server/src/generated/votes/vote_request.dart' as _i6;
|
||||
import 'package:serverpod_auth_server/serverpod_auth_server.dart' as _i7;
|
||||
as _i3;
|
||||
import 'package:wien_talks_server/src/generated/quotes/quote.dart' as _i4;
|
||||
import 'package:serverpod_auth_server/serverpod_auth_server.dart' as _i5;
|
||||
|
||||
class Endpoints extends _i1.EndpointDispatch {
|
||||
@override
|
||||
void initializeEndpoints(_i1.Server server) {
|
||||
var endpoints = <String, _i1.Endpoint>{
|
||||
'quote': _i2.QuoteEndpoint()
|
||||
'showLatestNewsWidget': _i2.ShowLatestNewsWidget()
|
||||
..initialize(
|
||||
server,
|
||||
'quote',
|
||||
'showLatestNewsWidget',
|
||||
null,
|
||||
),
|
||||
'votes': _i3.VotesEndpoint()
|
||||
..initialize(
|
||||
server,
|
||||
'votes',
|
||||
null,
|
||||
),
|
||||
)
|
||||
};
|
||||
connectors['quote'] = _i1.EndpointConnector(
|
||||
name: 'quote',
|
||||
endpoint: endpoints['quote']!,
|
||||
connectors['showLatestNewsWidget'] = _i1.EndpointConnector(
|
||||
name: 'showLatestNewsWidget',
|
||||
endpoint: endpoints['showLatestNewsWidget']!,
|
||||
methodConnectors: {
|
||||
'createQuote': _i1.MethodConnector(
|
||||
name: 'createQuote',
|
||||
params: {
|
||||
'req': _i1.ParameterDescription(
|
||||
name: 'req',
|
||||
type: _i1.getType<_i4.CreateQuoteRequest>(),
|
||||
type: _i1.getType<_i3.CreateQuoteRequest>(),
|
||||
nullable: false,
|
||||
)
|
||||
},
|
||||
|
|
@ -52,7 +44,8 @@ class Endpoints extends _i1.EndpointDispatch {
|
|||
_i1.Session session,
|
||||
Map<String, dynamic> params,
|
||||
) async =>
|
||||
(endpoints['quote'] as _i2.QuoteEndpoint).createQuote(
|
||||
(endpoints['showLatestNewsWidget'] as _i2.ShowLatestNewsWidget)
|
||||
.createQuote(
|
||||
session,
|
||||
params['req'],
|
||||
),
|
||||
|
|
@ -62,7 +55,7 @@ class Endpoints extends _i1.EndpointDispatch {
|
|||
params: {
|
||||
'quote': _i1.ParameterDescription(
|
||||
name: 'quote',
|
||||
type: _i1.getType<_i5.Quote>(),
|
||||
type: _i1.getType<_i4.Quote>(),
|
||||
nullable: false,
|
||||
)
|
||||
},
|
||||
|
|
@ -70,32 +63,18 @@ class Endpoints extends _i1.EndpointDispatch {
|
|||
_i1.Session session,
|
||||
Map<String, dynamic> params,
|
||||
) async =>
|
||||
(endpoints['quote'] as _i2.QuoteEndpoint).updateQuote(
|
||||
(endpoints['showLatestNewsWidget'] as _i2.ShowLatestNewsWidget)
|
||||
.updateQuote(
|
||||
session,
|
||||
params['quote'],
|
||||
),
|
||||
),
|
||||
'getAllQuotes': _i1.MethodConnector(
|
||||
name: 'getAllQuotes',
|
||||
params: {},
|
||||
call: (
|
||||
_i1.Session session,
|
||||
Map<String, dynamic> params,
|
||||
) async =>
|
||||
(endpoints['quote'] as _i2.QuoteEndpoint).getAllQuotes(session),
|
||||
),
|
||||
},
|
||||
);
|
||||
connectors['votes'] = _i1.EndpointConnector(
|
||||
name: 'votes',
|
||||
endpoint: endpoints['votes']!,
|
||||
methodConnectors: {
|
||||
'postVote': _i1.MethodConnector(
|
||||
name: 'postVote',
|
||||
params: {
|
||||
'voteRequest': _i1.ParameterDescription(
|
||||
name: 'voteRequest',
|
||||
type: _i1.getType<_i6.VoteRequest>(),
|
||||
'limit': _i1.ParameterDescription(
|
||||
name: 'limit',
|
||||
type: _i1.getType<int>(),
|
||||
nullable: false,
|
||||
)
|
||||
},
|
||||
|
|
@ -103,22 +82,14 @@ class Endpoints extends _i1.EndpointDispatch {
|
|||
_i1.Session session,
|
||||
Map<String, dynamic> params,
|
||||
) async =>
|
||||
(endpoints['votes'] as _i3.VotesEndpoint).postVote(
|
||||
(endpoints['showLatestNewsWidget'] as _i2.ShowLatestNewsWidget)
|
||||
.getAllQuotes(
|
||||
session,
|
||||
params['voteRequest'],
|
||||
limit: params['limit'],
|
||||
),
|
||||
),
|
||||
'getAllVotes': _i1.MethodConnector(
|
||||
name: 'getAllVotes',
|
||||
params: {},
|
||||
call: (
|
||||
_i1.Session session,
|
||||
Map<String, dynamic> params,
|
||||
) async =>
|
||||
(endpoints['votes'] as _i3.VotesEndpoint).getAllVotes(session),
|
||||
),
|
||||
},
|
||||
);
|
||||
modules['serverpod_auth'] = _i7.Endpoints()..initializeEndpoints(server);
|
||||
modules['serverpod_auth'] = _i5.Endpoints()..initializeEndpoints(server);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,14 +14,9 @@ import 'package:serverpod/protocol.dart' as _i2;
|
|||
import 'package:serverpod_auth_server/serverpod_auth_server.dart' as _i3;
|
||||
import 'quotes/create_quote.dart' as _i4;
|
||||
import 'quotes/quote.dart' as _i5;
|
||||
import 'votes/vote.dart' as _i6;
|
||||
import 'votes/vote_request.dart' as _i7;
|
||||
import 'package:wien_talks_server/src/generated/quotes/quote.dart' as _i8;
|
||||
import 'package:wien_talks_server/src/generated/votes/vote.dart' as _i9;
|
||||
import 'package:wien_talks_server/src/generated/quotes/quote.dart' as _i6;
|
||||
export 'quotes/create_quote.dart';
|
||||
export 'quotes/quote.dart';
|
||||
export 'votes/vote.dart';
|
||||
export 'votes/vote_request.dart';
|
||||
|
||||
class Protocol extends _i1.SerializationManagerServer {
|
||||
Protocol._();
|
||||
|
|
@ -123,112 +118,6 @@ class Protocol extends _i1.SerializationManagerServer {
|
|||
],
|
||||
managed: true,
|
||||
),
|
||||
_i2.TableDefinition(
|
||||
name: 'vote',
|
||||
dartName: 'Vote',
|
||||
schema: 'public',
|
||||
module: 'wien_talks',
|
||||
columns: [
|
||||
_i2.ColumnDefinition(
|
||||
name: 'id',
|
||||
columnType: _i2.ColumnType.bigint,
|
||||
isNullable: false,
|
||||
dartType: 'int?',
|
||||
columnDefault: 'nextval(\'vote_id_seq\'::regclass)',
|
||||
),
|
||||
_i2.ColumnDefinition(
|
||||
name: 'userId',
|
||||
columnType: _i2.ColumnType.bigint,
|
||||
isNullable: false,
|
||||
dartType: 'int',
|
||||
),
|
||||
_i2.ColumnDefinition(
|
||||
name: 'createdAt',
|
||||
columnType: _i2.ColumnType.timestampWithoutTimeZone,
|
||||
isNullable: false,
|
||||
dartType: 'DateTime',
|
||||
),
|
||||
_i2.ColumnDefinition(
|
||||
name: 'quote',
|
||||
columnType: _i2.ColumnType.json,
|
||||
isNullable: false,
|
||||
dartType: 'protocol:Quote',
|
||||
),
|
||||
_i2.ColumnDefinition(
|
||||
name: 'upvote',
|
||||
columnType: _i2.ColumnType.boolean,
|
||||
isNullable: false,
|
||||
dartType: 'bool',
|
||||
),
|
||||
],
|
||||
foreignKeys: [],
|
||||
indexes: [
|
||||
_i2.IndexDefinition(
|
||||
indexName: 'vote_pkey',
|
||||
tableSpace: null,
|
||||
elements: [
|
||||
_i2.IndexElementDefinition(
|
||||
type: _i2.IndexElementDefinitionType.column,
|
||||
definition: 'id',
|
||||
)
|
||||
],
|
||||
type: 'btree',
|
||||
isUnique: true,
|
||||
isPrimary: true,
|
||||
)
|
||||
],
|
||||
managed: true,
|
||||
),
|
||||
_i2.TableDefinition(
|
||||
name: 'vote_request',
|
||||
dartName: 'VoteRequest',
|
||||
schema: 'public',
|
||||
module: 'wien_talks',
|
||||
columns: [
|
||||
_i2.ColumnDefinition(
|
||||
name: 'id',
|
||||
columnType: _i2.ColumnType.bigint,
|
||||
isNullable: false,
|
||||
dartType: 'int?',
|
||||
columnDefault: 'nextval(\'vote_request_id_seq\'::regclass)',
|
||||
),
|
||||
_i2.ColumnDefinition(
|
||||
name: 'userId',
|
||||
columnType: _i2.ColumnType.bigint,
|
||||
isNullable: false,
|
||||
dartType: 'int',
|
||||
),
|
||||
_i2.ColumnDefinition(
|
||||
name: 'quote',
|
||||
columnType: _i2.ColumnType.json,
|
||||
isNullable: false,
|
||||
dartType: 'protocol:Quote',
|
||||
),
|
||||
_i2.ColumnDefinition(
|
||||
name: 'upvote',
|
||||
columnType: _i2.ColumnType.boolean,
|
||||
isNullable: false,
|
||||
dartType: 'bool',
|
||||
),
|
||||
],
|
||||
foreignKeys: [],
|
||||
indexes: [
|
||||
_i2.IndexDefinition(
|
||||
indexName: 'vote_request_pkey',
|
||||
tableSpace: null,
|
||||
elements: [
|
||||
_i2.IndexElementDefinition(
|
||||
type: _i2.IndexElementDefinitionType.column,
|
||||
definition: 'id',
|
||||
)
|
||||
],
|
||||
type: 'btree',
|
||||
isUnique: true,
|
||||
isPrimary: true,
|
||||
)
|
||||
],
|
||||
managed: true,
|
||||
),
|
||||
..._i3.Protocol.targetTableDefinitions,
|
||||
..._i2.Protocol.targetTableDefinitions,
|
||||
];
|
||||
|
|
@ -245,24 +134,12 @@ class Protocol extends _i1.SerializationManagerServer {
|
|||
if (t == _i5.Quote) {
|
||||
return _i5.Quote.fromJson(data) as T;
|
||||
}
|
||||
if (t == _i6.Vote) {
|
||||
return _i6.Vote.fromJson(data) as T;
|
||||
}
|
||||
if (t == _i7.VoteRequest) {
|
||||
return _i7.VoteRequest.fromJson(data) as T;
|
||||
}
|
||||
if (t == _i1.getType<_i4.CreateQuoteRequest?>()) {
|
||||
return (data != null ? _i4.CreateQuoteRequest.fromJson(data) : null) as T;
|
||||
}
|
||||
if (t == _i1.getType<_i5.Quote?>()) {
|
||||
return (data != null ? _i5.Quote.fromJson(data) : null) as T;
|
||||
}
|
||||
if (t == _i1.getType<_i6.Vote?>()) {
|
||||
return (data != null ? _i6.Vote.fromJson(data) : null) as T;
|
||||
}
|
||||
if (t == _i1.getType<_i7.VoteRequest?>()) {
|
||||
return (data != null ? _i7.VoteRequest.fromJson(data) : null) as T;
|
||||
}
|
||||
if (t == _i1.getType<List<String>?>()) {
|
||||
return (data != null
|
||||
? (data as List).map((e) => deserialize<String>(e)).toList()
|
||||
|
|
@ -273,11 +150,8 @@ class Protocol extends _i1.SerializationManagerServer {
|
|||
? (data as List).map((e) => deserialize<String>(e)).toList()
|
||||
: null) as T;
|
||||
}
|
||||
if (t == List<_i8.Quote>) {
|
||||
return (data as List).map((e) => deserialize<_i8.Quote>(e)).toList() as T;
|
||||
}
|
||||
if (t == List<_i9.Vote>) {
|
||||
return (data as List).map((e) => deserialize<_i9.Vote>(e)).toList() as T;
|
||||
if (t == List<_i6.Quote>) {
|
||||
return (data as List).map((e) => deserialize<_i6.Quote>(e)).toList() as T;
|
||||
}
|
||||
try {
|
||||
return _i3.Protocol().deserialize<T>(data, t);
|
||||
|
|
@ -298,12 +172,6 @@ class Protocol extends _i1.SerializationManagerServer {
|
|||
if (data is _i5.Quote) {
|
||||
return 'Quote';
|
||||
}
|
||||
if (data is _i6.Vote) {
|
||||
return 'Vote';
|
||||
}
|
||||
if (data is _i7.VoteRequest) {
|
||||
return 'VoteRequest';
|
||||
}
|
||||
className = _i2.Protocol().getClassNameForObject(data);
|
||||
if (className != null) {
|
||||
return 'serverpod.$className';
|
||||
|
|
@ -327,12 +195,6 @@ class Protocol extends _i1.SerializationManagerServer {
|
|||
if (dataClassName == 'Quote') {
|
||||
return deserialize<_i5.Quote>(data['data']);
|
||||
}
|
||||
if (dataClassName == 'Vote') {
|
||||
return deserialize<_i6.Vote>(data['data']);
|
||||
}
|
||||
if (dataClassName == 'VoteRequest') {
|
||||
return deserialize<_i7.VoteRequest>(data['data']);
|
||||
}
|
||||
if (dataClassName.startsWith('serverpod.')) {
|
||||
data['className'] = dataClassName.substring(10);
|
||||
return _i2.Protocol().deserializeByClassName(data);
|
||||
|
|
@ -361,10 +223,6 @@ class Protocol extends _i1.SerializationManagerServer {
|
|||
switch (t) {
|
||||
case _i5.Quote:
|
||||
return _i5.Quote.t;
|
||||
case _i6.Vote:
|
||||
return _i6.Vote.t;
|
||||
case _i7.VoteRequest:
|
||||
return _i7.VoteRequest.t;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,3 @@ quote:
|
|||
- createQuote:
|
||||
- updateQuote:
|
||||
- getAllQuotes:
|
||||
votes:
|
||||
- postVote:
|
||||
- getAllVotes:
|
||||
|
|
|
|||
|
|
@ -1,441 +0,0 @@
|
|||
/* AUTOMATICALLY GENERATED CODE DO NOT MODIFY */
|
||||
/* To generate run: "serverpod generate" */
|
||||
|
||||
// ignore_for_file: implementation_imports
|
||||
// ignore_for_file: library_private_types_in_public_api
|
||||
// ignore_for_file: non_constant_identifier_names
|
||||
// ignore_for_file: public_member_api_docs
|
||||
// ignore_for_file: type_literal_in_constant_pattern
|
||||
// ignore_for_file: use_super_parameters
|
||||
|
||||
// ignore_for_file: no_leading_underscores_for_library_prefixes
|
||||
import 'package:serverpod/serverpod.dart' as _i1;
|
||||
import '../quotes/quote.dart' as _i2;
|
||||
|
||||
abstract class Vote implements _i1.TableRow<int?>, _i1.ProtocolSerialization {
|
||||
Vote._({
|
||||
this.id,
|
||||
required this.userId,
|
||||
required this.createdAt,
|
||||
required this.quote,
|
||||
required this.upvote,
|
||||
});
|
||||
|
||||
factory Vote({
|
||||
int? id,
|
||||
required int userId,
|
||||
required DateTime createdAt,
|
||||
required _i2.Quote quote,
|
||||
required bool upvote,
|
||||
}) = _VoteImpl;
|
||||
|
||||
factory Vote.fromJson(Map<String, dynamic> jsonSerialization) {
|
||||
return Vote(
|
||||
id: jsonSerialization['id'] as int?,
|
||||
userId: jsonSerialization['userId'] as int,
|
||||
createdAt:
|
||||
_i1.DateTimeJsonExtension.fromJson(jsonSerialization['createdAt']),
|
||||
quote: _i2.Quote.fromJson(
|
||||
(jsonSerialization['quote'] as Map<String, dynamic>)),
|
||||
upvote: jsonSerialization['upvote'] as bool,
|
||||
);
|
||||
}
|
||||
|
||||
static final t = VoteTable();
|
||||
|
||||
static const db = VoteRepository._();
|
||||
|
||||
@override
|
||||
int? id;
|
||||
|
||||
int userId;
|
||||
|
||||
DateTime createdAt;
|
||||
|
||||
_i2.Quote quote;
|
||||
|
||||
bool upvote;
|
||||
|
||||
@override
|
||||
_i1.Table<int?> get table => t;
|
||||
|
||||
/// Returns a shallow copy of this [Vote]
|
||||
/// with some or all fields replaced by the given arguments.
|
||||
@_i1.useResult
|
||||
Vote copyWith({
|
||||
int? id,
|
||||
int? userId,
|
||||
DateTime? createdAt,
|
||||
_i2.Quote? quote,
|
||||
bool? upvote,
|
||||
});
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
if (id != null) 'id': id,
|
||||
'userId': userId,
|
||||
'createdAt': createdAt.toJson(),
|
||||
'quote': quote.toJson(),
|
||||
'upvote': upvote,
|
||||
};
|
||||
}
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJsonForProtocol() {
|
||||
return {
|
||||
if (id != null) 'id': id,
|
||||
'userId': userId,
|
||||
'createdAt': createdAt.toJson(),
|
||||
'quote': quote.toJsonForProtocol(),
|
||||
'upvote': upvote,
|
||||
};
|
||||
}
|
||||
|
||||
static VoteInclude include() {
|
||||
return VoteInclude._();
|
||||
}
|
||||
|
||||
static VoteIncludeList includeList({
|
||||
_i1.WhereExpressionBuilder<VoteTable>? where,
|
||||
int? limit,
|
||||
int? offset,
|
||||
_i1.OrderByBuilder<VoteTable>? orderBy,
|
||||
bool orderDescending = false,
|
||||
_i1.OrderByListBuilder<VoteTable>? orderByList,
|
||||
VoteInclude? include,
|
||||
}) {
|
||||
return VoteIncludeList._(
|
||||
where: where,
|
||||
limit: limit,
|
||||
offset: offset,
|
||||
orderBy: orderBy?.call(Vote.t),
|
||||
orderDescending: orderDescending,
|
||||
orderByList: orderByList?.call(Vote.t),
|
||||
include: include,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return _i1.SerializationManager.encode(this);
|
||||
}
|
||||
}
|
||||
|
||||
class _Undefined {}
|
||||
|
||||
class _VoteImpl extends Vote {
|
||||
_VoteImpl({
|
||||
int? id,
|
||||
required int userId,
|
||||
required DateTime createdAt,
|
||||
required _i2.Quote quote,
|
||||
required bool upvote,
|
||||
}) : super._(
|
||||
id: id,
|
||||
userId: userId,
|
||||
createdAt: createdAt,
|
||||
quote: quote,
|
||||
upvote: upvote,
|
||||
);
|
||||
|
||||
/// Returns a shallow copy of this [Vote]
|
||||
/// with some or all fields replaced by the given arguments.
|
||||
@_i1.useResult
|
||||
@override
|
||||
Vote copyWith({
|
||||
Object? id = _Undefined,
|
||||
int? userId,
|
||||
DateTime? createdAt,
|
||||
_i2.Quote? quote,
|
||||
bool? upvote,
|
||||
}) {
|
||||
return Vote(
|
||||
id: id is int? ? id : this.id,
|
||||
userId: userId ?? this.userId,
|
||||
createdAt: createdAt ?? this.createdAt,
|
||||
quote: quote ?? this.quote.copyWith(),
|
||||
upvote: upvote ?? this.upvote,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class VoteTable extends _i1.Table<int?> {
|
||||
VoteTable({super.tableRelation}) : super(tableName: 'vote') {
|
||||
userId = _i1.ColumnInt(
|
||||
'userId',
|
||||
this,
|
||||
);
|
||||
createdAt = _i1.ColumnDateTime(
|
||||
'createdAt',
|
||||
this,
|
||||
);
|
||||
quote = _i1.ColumnSerializable(
|
||||
'quote',
|
||||
this,
|
||||
);
|
||||
upvote = _i1.ColumnBool(
|
||||
'upvote',
|
||||
this,
|
||||
);
|
||||
}
|
||||
|
||||
late final _i1.ColumnInt userId;
|
||||
|
||||
late final _i1.ColumnDateTime createdAt;
|
||||
|
||||
late final _i1.ColumnSerializable quote;
|
||||
|
||||
late final _i1.ColumnBool upvote;
|
||||
|
||||
@override
|
||||
List<_i1.Column> get columns => [
|
||||
id,
|
||||
userId,
|
||||
createdAt,
|
||||
quote,
|
||||
upvote,
|
||||
];
|
||||
}
|
||||
|
||||
class VoteInclude extends _i1.IncludeObject {
|
||||
VoteInclude._();
|
||||
|
||||
@override
|
||||
Map<String, _i1.Include?> get includes => {};
|
||||
|
||||
@override
|
||||
_i1.Table<int?> get table => Vote.t;
|
||||
}
|
||||
|
||||
class VoteIncludeList extends _i1.IncludeList {
|
||||
VoteIncludeList._({
|
||||
_i1.WhereExpressionBuilder<VoteTable>? where,
|
||||
super.limit,
|
||||
super.offset,
|
||||
super.orderBy,
|
||||
super.orderDescending,
|
||||
super.orderByList,
|
||||
super.include,
|
||||
}) {
|
||||
super.where = where?.call(Vote.t);
|
||||
}
|
||||
|
||||
@override
|
||||
Map<String, _i1.Include?> get includes => include?.includes ?? {};
|
||||
|
||||
@override
|
||||
_i1.Table<int?> get table => Vote.t;
|
||||
}
|
||||
|
||||
class VoteRepository {
|
||||
const VoteRepository._();
|
||||
|
||||
/// Returns a list of [Vote]s matching the given query parameters.
|
||||
///
|
||||
/// Use [where] to specify which items to include in the return value.
|
||||
/// If none is specified, all items will be returned.
|
||||
///
|
||||
/// To specify the order of the items use [orderBy] or [orderByList]
|
||||
/// when sorting by multiple columns.
|
||||
///
|
||||
/// The maximum number of items can be set by [limit]. If no limit is set,
|
||||
/// all items matching the query will be returned.
|
||||
///
|
||||
/// [offset] defines how many items to skip, after which [limit] (or all)
|
||||
/// items are read from the database.
|
||||
///
|
||||
/// ```dart
|
||||
/// var persons = await Persons.db.find(
|
||||
/// session,
|
||||
/// where: (t) => t.lastName.equals('Jones'),
|
||||
/// orderBy: (t) => t.firstName,
|
||||
/// limit: 100,
|
||||
/// );
|
||||
/// ```
|
||||
Future<List<Vote>> find(
|
||||
_i1.Session session, {
|
||||
_i1.WhereExpressionBuilder<VoteTable>? where,
|
||||
int? limit,
|
||||
int? offset,
|
||||
_i1.OrderByBuilder<VoteTable>? orderBy,
|
||||
bool orderDescending = false,
|
||||
_i1.OrderByListBuilder<VoteTable>? orderByList,
|
||||
_i1.Transaction? transaction,
|
||||
}) async {
|
||||
return session.db.find<Vote>(
|
||||
where: where?.call(Vote.t),
|
||||
orderBy: orderBy?.call(Vote.t),
|
||||
orderByList: orderByList?.call(Vote.t),
|
||||
orderDescending: orderDescending,
|
||||
limit: limit,
|
||||
offset: offset,
|
||||
transaction: transaction,
|
||||
);
|
||||
}
|
||||
|
||||
/// Returns the first matching [Vote] matching the given query parameters.
|
||||
///
|
||||
/// Use [where] to specify which items to include in the return value.
|
||||
/// If none is specified, all items will be returned.
|
||||
///
|
||||
/// To specify the order use [orderBy] or [orderByList]
|
||||
/// when sorting by multiple columns.
|
||||
///
|
||||
/// [offset] defines how many items to skip, after which the next one will be picked.
|
||||
///
|
||||
/// ```dart
|
||||
/// var youngestPerson = await Persons.db.findFirstRow(
|
||||
/// session,
|
||||
/// where: (t) => t.lastName.equals('Jones'),
|
||||
/// orderBy: (t) => t.age,
|
||||
/// );
|
||||
/// ```
|
||||
Future<Vote?> findFirstRow(
|
||||
_i1.Session session, {
|
||||
_i1.WhereExpressionBuilder<VoteTable>? where,
|
||||
int? offset,
|
||||
_i1.OrderByBuilder<VoteTable>? orderBy,
|
||||
bool orderDescending = false,
|
||||
_i1.OrderByListBuilder<VoteTable>? orderByList,
|
||||
_i1.Transaction? transaction,
|
||||
}) async {
|
||||
return session.db.findFirstRow<Vote>(
|
||||
where: where?.call(Vote.t),
|
||||
orderBy: orderBy?.call(Vote.t),
|
||||
orderByList: orderByList?.call(Vote.t),
|
||||
orderDescending: orderDescending,
|
||||
offset: offset,
|
||||
transaction: transaction,
|
||||
);
|
||||
}
|
||||
|
||||
/// Finds a single [Vote] by its [id] or null if no such row exists.
|
||||
Future<Vote?> findById(
|
||||
_i1.Session session,
|
||||
int id, {
|
||||
_i1.Transaction? transaction,
|
||||
}) async {
|
||||
return session.db.findById<Vote>(
|
||||
id,
|
||||
transaction: transaction,
|
||||
);
|
||||
}
|
||||
|
||||
/// Inserts all [Vote]s in the list and returns the inserted rows.
|
||||
///
|
||||
/// The returned [Vote]s will have their `id` fields set.
|
||||
///
|
||||
/// This is an atomic operation, meaning that if one of the rows fails to
|
||||
/// insert, none of the rows will be inserted.
|
||||
Future<List<Vote>> insert(
|
||||
_i1.Session session,
|
||||
List<Vote> rows, {
|
||||
_i1.Transaction? transaction,
|
||||
}) async {
|
||||
return session.db.insert<Vote>(
|
||||
rows,
|
||||
transaction: transaction,
|
||||
);
|
||||
}
|
||||
|
||||
/// Inserts a single [Vote] and returns the inserted row.
|
||||
///
|
||||
/// The returned [Vote] will have its `id` field set.
|
||||
Future<Vote> insertRow(
|
||||
_i1.Session session,
|
||||
Vote row, {
|
||||
_i1.Transaction? transaction,
|
||||
}) async {
|
||||
return session.db.insertRow<Vote>(
|
||||
row,
|
||||
transaction: transaction,
|
||||
);
|
||||
}
|
||||
|
||||
/// Updates all [Vote]s in the list and returns the updated rows. If
|
||||
/// [columns] is provided, only those columns will be updated. Defaults to
|
||||
/// all columns.
|
||||
/// This is an atomic operation, meaning that if one of the rows fails to
|
||||
/// update, none of the rows will be updated.
|
||||
Future<List<Vote>> update(
|
||||
_i1.Session session,
|
||||
List<Vote> rows, {
|
||||
_i1.ColumnSelections<VoteTable>? columns,
|
||||
_i1.Transaction? transaction,
|
||||
}) async {
|
||||
return session.db.update<Vote>(
|
||||
rows,
|
||||
columns: columns?.call(Vote.t),
|
||||
transaction: transaction,
|
||||
);
|
||||
}
|
||||
|
||||
/// Updates a single [Vote]. The row needs to have its id set.
|
||||
/// Optionally, a list of [columns] can be provided to only update those
|
||||
/// columns. Defaults to all columns.
|
||||
Future<Vote> updateRow(
|
||||
_i1.Session session,
|
||||
Vote row, {
|
||||
_i1.ColumnSelections<VoteTable>? columns,
|
||||
_i1.Transaction? transaction,
|
||||
}) async {
|
||||
return session.db.updateRow<Vote>(
|
||||
row,
|
||||
columns: columns?.call(Vote.t),
|
||||
transaction: transaction,
|
||||
);
|
||||
}
|
||||
|
||||
/// Deletes all [Vote]s in the list and returns the deleted rows.
|
||||
/// This is an atomic operation, meaning that if one of the rows fail to
|
||||
/// be deleted, none of the rows will be deleted.
|
||||
Future<List<Vote>> delete(
|
||||
_i1.Session session,
|
||||
List<Vote> rows, {
|
||||
_i1.Transaction? transaction,
|
||||
}) async {
|
||||
return session.db.delete<Vote>(
|
||||
rows,
|
||||
transaction: transaction,
|
||||
);
|
||||
}
|
||||
|
||||
/// Deletes a single [Vote].
|
||||
Future<Vote> deleteRow(
|
||||
_i1.Session session,
|
||||
Vote row, {
|
||||
_i1.Transaction? transaction,
|
||||
}) async {
|
||||
return session.db.deleteRow<Vote>(
|
||||
row,
|
||||
transaction: transaction,
|
||||
);
|
||||
}
|
||||
|
||||
/// Deletes all rows matching the [where] expression.
|
||||
Future<List<Vote>> deleteWhere(
|
||||
_i1.Session session, {
|
||||
required _i1.WhereExpressionBuilder<VoteTable> where,
|
||||
_i1.Transaction? transaction,
|
||||
}) async {
|
||||
return session.db.deleteWhere<Vote>(
|
||||
where: where(Vote.t),
|
||||
transaction: transaction,
|
||||
);
|
||||
}
|
||||
|
||||
/// Counts the number of rows matching the [where] expression. If omitted,
|
||||
/// will return the count of all rows in the table.
|
||||
Future<int> count(
|
||||
_i1.Session session, {
|
||||
_i1.WhereExpressionBuilder<VoteTable>? where,
|
||||
int? limit,
|
||||
_i1.Transaction? transaction,
|
||||
}) async {
|
||||
return session.db.count<Vote>(
|
||||
where: where?.call(Vote.t),
|
||||
limit: limit,
|
||||
transaction: transaction,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,422 +0,0 @@
|
|||
/* AUTOMATICALLY GENERATED CODE DO NOT MODIFY */
|
||||
/* To generate run: "serverpod generate" */
|
||||
|
||||
// ignore_for_file: implementation_imports
|
||||
// ignore_for_file: library_private_types_in_public_api
|
||||
// ignore_for_file: non_constant_identifier_names
|
||||
// ignore_for_file: public_member_api_docs
|
||||
// ignore_for_file: type_literal_in_constant_pattern
|
||||
// ignore_for_file: use_super_parameters
|
||||
|
||||
// ignore_for_file: no_leading_underscores_for_library_prefixes
|
||||
import 'package:serverpod/serverpod.dart' as _i1;
|
||||
import '../quotes/quote.dart' as _i2;
|
||||
|
||||
abstract class VoteRequest
|
||||
implements _i1.TableRow<int?>, _i1.ProtocolSerialization {
|
||||
VoteRequest._({
|
||||
this.id,
|
||||
required this.userId,
|
||||
required this.quote,
|
||||
required this.upvote,
|
||||
});
|
||||
|
||||
factory VoteRequest({
|
||||
int? id,
|
||||
required int userId,
|
||||
required _i2.Quote quote,
|
||||
required bool upvote,
|
||||
}) = _VoteRequestImpl;
|
||||
|
||||
factory VoteRequest.fromJson(Map<String, dynamic> jsonSerialization) {
|
||||
return VoteRequest(
|
||||
id: jsonSerialization['id'] as int?,
|
||||
userId: jsonSerialization['userId'] as int,
|
||||
quote: _i2.Quote.fromJson(
|
||||
(jsonSerialization['quote'] as Map<String, dynamic>)),
|
||||
upvote: jsonSerialization['upvote'] as bool,
|
||||
);
|
||||
}
|
||||
|
||||
static final t = VoteRequestTable();
|
||||
|
||||
static const db = VoteRequestRepository._();
|
||||
|
||||
@override
|
||||
int? id;
|
||||
|
||||
int userId;
|
||||
|
||||
_i2.Quote quote;
|
||||
|
||||
bool upvote;
|
||||
|
||||
@override
|
||||
_i1.Table<int?> get table => t;
|
||||
|
||||
/// Returns a shallow copy of this [VoteRequest]
|
||||
/// with some or all fields replaced by the given arguments.
|
||||
@_i1.useResult
|
||||
VoteRequest copyWith({
|
||||
int? id,
|
||||
int? userId,
|
||||
_i2.Quote? quote,
|
||||
bool? upvote,
|
||||
});
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
if (id != null) 'id': id,
|
||||
'userId': userId,
|
||||
'quote': quote.toJson(),
|
||||
'upvote': upvote,
|
||||
};
|
||||
}
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJsonForProtocol() {
|
||||
return {
|
||||
if (id != null) 'id': id,
|
||||
'userId': userId,
|
||||
'quote': quote.toJsonForProtocol(),
|
||||
'upvote': upvote,
|
||||
};
|
||||
}
|
||||
|
||||
static VoteRequestInclude include() {
|
||||
return VoteRequestInclude._();
|
||||
}
|
||||
|
||||
static VoteRequestIncludeList includeList({
|
||||
_i1.WhereExpressionBuilder<VoteRequestTable>? where,
|
||||
int? limit,
|
||||
int? offset,
|
||||
_i1.OrderByBuilder<VoteRequestTable>? orderBy,
|
||||
bool orderDescending = false,
|
||||
_i1.OrderByListBuilder<VoteRequestTable>? orderByList,
|
||||
VoteRequestInclude? include,
|
||||
}) {
|
||||
return VoteRequestIncludeList._(
|
||||
where: where,
|
||||
limit: limit,
|
||||
offset: offset,
|
||||
orderBy: orderBy?.call(VoteRequest.t),
|
||||
orderDescending: orderDescending,
|
||||
orderByList: orderByList?.call(VoteRequest.t),
|
||||
include: include,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return _i1.SerializationManager.encode(this);
|
||||
}
|
||||
}
|
||||
|
||||
class _Undefined {}
|
||||
|
||||
class _VoteRequestImpl extends VoteRequest {
|
||||
_VoteRequestImpl({
|
||||
int? id,
|
||||
required int userId,
|
||||
required _i2.Quote quote,
|
||||
required bool upvote,
|
||||
}) : super._(
|
||||
id: id,
|
||||
userId: userId,
|
||||
quote: quote,
|
||||
upvote: upvote,
|
||||
);
|
||||
|
||||
/// Returns a shallow copy of this [VoteRequest]
|
||||
/// with some or all fields replaced by the given arguments.
|
||||
@_i1.useResult
|
||||
@override
|
||||
VoteRequest copyWith({
|
||||
Object? id = _Undefined,
|
||||
int? userId,
|
||||
_i2.Quote? quote,
|
||||
bool? upvote,
|
||||
}) {
|
||||
return VoteRequest(
|
||||
id: id is int? ? id : this.id,
|
||||
userId: userId ?? this.userId,
|
||||
quote: quote ?? this.quote.copyWith(),
|
||||
upvote: upvote ?? this.upvote,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class VoteRequestTable extends _i1.Table<int?> {
|
||||
VoteRequestTable({super.tableRelation}) : super(tableName: 'vote_request') {
|
||||
userId = _i1.ColumnInt(
|
||||
'userId',
|
||||
this,
|
||||
);
|
||||
quote = _i1.ColumnSerializable(
|
||||
'quote',
|
||||
this,
|
||||
);
|
||||
upvote = _i1.ColumnBool(
|
||||
'upvote',
|
||||
this,
|
||||
);
|
||||
}
|
||||
|
||||
late final _i1.ColumnInt userId;
|
||||
|
||||
late final _i1.ColumnSerializable quote;
|
||||
|
||||
late final _i1.ColumnBool upvote;
|
||||
|
||||
@override
|
||||
List<_i1.Column> get columns => [
|
||||
id,
|
||||
userId,
|
||||
quote,
|
||||
upvote,
|
||||
];
|
||||
}
|
||||
|
||||
class VoteRequestInclude extends _i1.IncludeObject {
|
||||
VoteRequestInclude._();
|
||||
|
||||
@override
|
||||
Map<String, _i1.Include?> get includes => {};
|
||||
|
||||
@override
|
||||
_i1.Table<int?> get table => VoteRequest.t;
|
||||
}
|
||||
|
||||
class VoteRequestIncludeList extends _i1.IncludeList {
|
||||
VoteRequestIncludeList._({
|
||||
_i1.WhereExpressionBuilder<VoteRequestTable>? where,
|
||||
super.limit,
|
||||
super.offset,
|
||||
super.orderBy,
|
||||
super.orderDescending,
|
||||
super.orderByList,
|
||||
super.include,
|
||||
}) {
|
||||
super.where = where?.call(VoteRequest.t);
|
||||
}
|
||||
|
||||
@override
|
||||
Map<String, _i1.Include?> get includes => include?.includes ?? {};
|
||||
|
||||
@override
|
||||
_i1.Table<int?> get table => VoteRequest.t;
|
||||
}
|
||||
|
||||
class VoteRequestRepository {
|
||||
const VoteRequestRepository._();
|
||||
|
||||
/// Returns a list of [VoteRequest]s matching the given query parameters.
|
||||
///
|
||||
/// Use [where] to specify which items to include in the return value.
|
||||
/// If none is specified, all items will be returned.
|
||||
///
|
||||
/// To specify the order of the items use [orderBy] or [orderByList]
|
||||
/// when sorting by multiple columns.
|
||||
///
|
||||
/// The maximum number of items can be set by [limit]. If no limit is set,
|
||||
/// all items matching the query will be returned.
|
||||
///
|
||||
/// [offset] defines how many items to skip, after which [limit] (or all)
|
||||
/// items are read from the database.
|
||||
///
|
||||
/// ```dart
|
||||
/// var persons = await Persons.db.find(
|
||||
/// session,
|
||||
/// where: (t) => t.lastName.equals('Jones'),
|
||||
/// orderBy: (t) => t.firstName,
|
||||
/// limit: 100,
|
||||
/// );
|
||||
/// ```
|
||||
Future<List<VoteRequest>> find(
|
||||
_i1.Session session, {
|
||||
_i1.WhereExpressionBuilder<VoteRequestTable>? where,
|
||||
int? limit,
|
||||
int? offset,
|
||||
_i1.OrderByBuilder<VoteRequestTable>? orderBy,
|
||||
bool orderDescending = false,
|
||||
_i1.OrderByListBuilder<VoteRequestTable>? orderByList,
|
||||
_i1.Transaction? transaction,
|
||||
}) async {
|
||||
return session.db.find<VoteRequest>(
|
||||
where: where?.call(VoteRequest.t),
|
||||
orderBy: orderBy?.call(VoteRequest.t),
|
||||
orderByList: orderByList?.call(VoteRequest.t),
|
||||
orderDescending: orderDescending,
|
||||
limit: limit,
|
||||
offset: offset,
|
||||
transaction: transaction,
|
||||
);
|
||||
}
|
||||
|
||||
/// Returns the first matching [VoteRequest] matching the given query parameters.
|
||||
///
|
||||
/// Use [where] to specify which items to include in the return value.
|
||||
/// If none is specified, all items will be returned.
|
||||
///
|
||||
/// To specify the order use [orderBy] or [orderByList]
|
||||
/// when sorting by multiple columns.
|
||||
///
|
||||
/// [offset] defines how many items to skip, after which the next one will be picked.
|
||||
///
|
||||
/// ```dart
|
||||
/// var youngestPerson = await Persons.db.findFirstRow(
|
||||
/// session,
|
||||
/// where: (t) => t.lastName.equals('Jones'),
|
||||
/// orderBy: (t) => t.age,
|
||||
/// );
|
||||
/// ```
|
||||
Future<VoteRequest?> findFirstRow(
|
||||
_i1.Session session, {
|
||||
_i1.WhereExpressionBuilder<VoteRequestTable>? where,
|
||||
int? offset,
|
||||
_i1.OrderByBuilder<VoteRequestTable>? orderBy,
|
||||
bool orderDescending = false,
|
||||
_i1.OrderByListBuilder<VoteRequestTable>? orderByList,
|
||||
_i1.Transaction? transaction,
|
||||
}) async {
|
||||
return session.db.findFirstRow<VoteRequest>(
|
||||
where: where?.call(VoteRequest.t),
|
||||
orderBy: orderBy?.call(VoteRequest.t),
|
||||
orderByList: orderByList?.call(VoteRequest.t),
|
||||
orderDescending: orderDescending,
|
||||
offset: offset,
|
||||
transaction: transaction,
|
||||
);
|
||||
}
|
||||
|
||||
/// Finds a single [VoteRequest] by its [id] or null if no such row exists.
|
||||
Future<VoteRequest?> findById(
|
||||
_i1.Session session,
|
||||
int id, {
|
||||
_i1.Transaction? transaction,
|
||||
}) async {
|
||||
return session.db.findById<VoteRequest>(
|
||||
id,
|
||||
transaction: transaction,
|
||||
);
|
||||
}
|
||||
|
||||
/// Inserts all [VoteRequest]s in the list and returns the inserted rows.
|
||||
///
|
||||
/// The returned [VoteRequest]s will have their `id` fields set.
|
||||
///
|
||||
/// This is an atomic operation, meaning that if one of the rows fails to
|
||||
/// insert, none of the rows will be inserted.
|
||||
Future<List<VoteRequest>> insert(
|
||||
_i1.Session session,
|
||||
List<VoteRequest> rows, {
|
||||
_i1.Transaction? transaction,
|
||||
}) async {
|
||||
return session.db.insert<VoteRequest>(
|
||||
rows,
|
||||
transaction: transaction,
|
||||
);
|
||||
}
|
||||
|
||||
/// Inserts a single [VoteRequest] and returns the inserted row.
|
||||
///
|
||||
/// The returned [VoteRequest] will have its `id` field set.
|
||||
Future<VoteRequest> insertRow(
|
||||
_i1.Session session,
|
||||
VoteRequest row, {
|
||||
_i1.Transaction? transaction,
|
||||
}) async {
|
||||
return session.db.insertRow<VoteRequest>(
|
||||
row,
|
||||
transaction: transaction,
|
||||
);
|
||||
}
|
||||
|
||||
/// Updates all [VoteRequest]s in the list and returns the updated rows. If
|
||||
/// [columns] is provided, only those columns will be updated. Defaults to
|
||||
/// all columns.
|
||||
/// This is an atomic operation, meaning that if one of the rows fails to
|
||||
/// update, none of the rows will be updated.
|
||||
Future<List<VoteRequest>> update(
|
||||
_i1.Session session,
|
||||
List<VoteRequest> rows, {
|
||||
_i1.ColumnSelections<VoteRequestTable>? columns,
|
||||
_i1.Transaction? transaction,
|
||||
}) async {
|
||||
return session.db.update<VoteRequest>(
|
||||
rows,
|
||||
columns: columns?.call(VoteRequest.t),
|
||||
transaction: transaction,
|
||||
);
|
||||
}
|
||||
|
||||
/// Updates a single [VoteRequest]. The row needs to have its id set.
|
||||
/// Optionally, a list of [columns] can be provided to only update those
|
||||
/// columns. Defaults to all columns.
|
||||
Future<VoteRequest> updateRow(
|
||||
_i1.Session session,
|
||||
VoteRequest row, {
|
||||
_i1.ColumnSelections<VoteRequestTable>? columns,
|
||||
_i1.Transaction? transaction,
|
||||
}) async {
|
||||
return session.db.updateRow<VoteRequest>(
|
||||
row,
|
||||
columns: columns?.call(VoteRequest.t),
|
||||
transaction: transaction,
|
||||
);
|
||||
}
|
||||
|
||||
/// Deletes all [VoteRequest]s in the list and returns the deleted rows.
|
||||
/// This is an atomic operation, meaning that if one of the rows fail to
|
||||
/// be deleted, none of the rows will be deleted.
|
||||
Future<List<VoteRequest>> delete(
|
||||
_i1.Session session,
|
||||
List<VoteRequest> rows, {
|
||||
_i1.Transaction? transaction,
|
||||
}) async {
|
||||
return session.db.delete<VoteRequest>(
|
||||
rows,
|
||||
transaction: transaction,
|
||||
);
|
||||
}
|
||||
|
||||
/// Deletes a single [VoteRequest].
|
||||
Future<VoteRequest> deleteRow(
|
||||
_i1.Session session,
|
||||
VoteRequest row, {
|
||||
_i1.Transaction? transaction,
|
||||
}) async {
|
||||
return session.db.deleteRow<VoteRequest>(
|
||||
row,
|
||||
transaction: transaction,
|
||||
);
|
||||
}
|
||||
|
||||
/// Deletes all rows matching the [where] expression.
|
||||
Future<List<VoteRequest>> deleteWhere(
|
||||
_i1.Session session, {
|
||||
required _i1.WhereExpressionBuilder<VoteRequestTable> where,
|
||||
_i1.Transaction? transaction,
|
||||
}) async {
|
||||
return session.db.deleteWhere<VoteRequest>(
|
||||
where: where(VoteRequest.t),
|
||||
transaction: transaction,
|
||||
);
|
||||
}
|
||||
|
||||
/// Counts the number of rows matching the [where] expression. If omitted,
|
||||
/// will return the count of all rows in the table.
|
||||
Future<int> count(
|
||||
_i1.Session session, {
|
||||
_i1.WhereExpressionBuilder<VoteRequestTable>? where,
|
||||
int? limit,
|
||||
_i1.Transaction? transaction,
|
||||
}) async {
|
||||
return session.db.count<VoteRequest>(
|
||||
where: where?.call(VoteRequest.t),
|
||||
limit: limit,
|
||||
transaction: transaction,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
// lib/src/endpoints/quote_endpoint.dart
|
||||
import 'dart:async';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:serverpod/serverpod.dart';
|
||||
import 'package:wien_talks_server/src/generated/protocol.dart';
|
||||
import 'package:wien_talks_server/src/quotes/quote_util.dart';
|
||||
|
||||
class QuoteEndpoint extends Endpoint {
|
||||
class ShowLatestNewsWidget extends Endpoint {
|
||||
static const _channelQuoteUpdates = 'quote-updates';
|
||||
|
||||
Future<Quote> createQuote(Session session, CreateQuoteRequest req) async {
|
||||
|
|
@ -15,7 +15,8 @@ class QuoteEndpoint extends Endpoint {
|
|||
final text = validateQuote(req);
|
||||
|
||||
final toInsert = Quote(
|
||||
userId: userId ?? Random().nextInt(1200),
|
||||
id: 0,
|
||||
userId: userId ?? 12,
|
||||
text: text,
|
||||
authorName: req.authorName,
|
||||
lat: req.lat,
|
||||
|
|
@ -36,22 +37,8 @@ class QuoteEndpoint extends Endpoint {
|
|||
await session.messages.postMessage(_channelQuoteUpdates, quote);
|
||||
}
|
||||
|
||||
Future<List<Quote>> getAllQuotes(
|
||||
Session session,
|
||||
) async {
|
||||
session.log('$session');
|
||||
|
||||
final quoteList = await Quote.db.find(
|
||||
session,
|
||||
// where: (t) => t.visibility.equals(0),
|
||||
// orderBy: (t) => t.createdAt,
|
||||
// orderDescending: true,
|
||||
);
|
||||
|
||||
for (var element in quoteList) {
|
||||
session.log(element.text);
|
||||
}
|
||||
|
||||
Future<List<Quote>> getAllQuotes(Session session, {int limit = 200}) async {
|
||||
final quoteList = await Quote.db.find(session);
|
||||
return quoteList;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +0,0 @@
|
|||
class: Vote
|
||||
table: vote
|
||||
fields:
|
||||
userId: int
|
||||
createdAt: DateTime
|
||||
quote: Quote
|
||||
upvote: bool
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
class: VoteRequest
|
||||
table: vote_request
|
||||
fields:
|
||||
userId: int
|
||||
quote: Quote
|
||||
upvote: bool
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
import 'package:serverpod/serverpod.dart';
|
||||
import 'package:wien_talks_server/src/generated/protocol.dart';
|
||||
|
||||
class VotesEndpoint extends Endpoint {
|
||||
Future<Vote> postVote(Session session, VoteRequest voteRequest) async {
|
||||
final row = Vote(
|
||||
createdAt: DateTime.now(),
|
||||
quote: voteRequest.quote,
|
||||
upvote: voteRequest.upvote,
|
||||
userId: voteRequest.userId);
|
||||
|
||||
final persistedVote = await Vote.db.insertRow(session, row);
|
||||
|
||||
return persistedVote;
|
||||
}
|
||||
|
||||
Future<List<Vote>> getAllVotes(Session session) async {
|
||||
final rows = Vote.db.find(session, limit: 50);
|
||||
return rows;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,394 +0,0 @@
|
|||
BEGIN;
|
||||
|
||||
--
|
||||
-- Class Quote as table quote
|
||||
--
|
||||
CREATE TABLE "quote" (
|
||||
"id" bigserial PRIMARY KEY,
|
||||
"userId" bigint NOT NULL,
|
||||
"text" text NOT NULL,
|
||||
"authorName" text,
|
||||
"lat" double precision NOT NULL,
|
||||
"long" double precision NOT NULL,
|
||||
"createdAt" timestamp without time zone NOT NULL,
|
||||
"visibility" bigint NOT NULL,
|
||||
"upvotes" bigint NOT NULL,
|
||||
"downvotes" bigint NOT NULL,
|
||||
"tags" json
|
||||
);
|
||||
|
||||
--
|
||||
-- Class CloudStorageEntry as table serverpod_cloud_storage
|
||||
--
|
||||
CREATE TABLE "serverpod_cloud_storage" (
|
||||
"id" bigserial PRIMARY KEY,
|
||||
"storageId" text NOT NULL,
|
||||
"path" text NOT NULL,
|
||||
"addedTime" timestamp without time zone NOT NULL,
|
||||
"expiration" timestamp without time zone,
|
||||
"byteData" bytea NOT NULL,
|
||||
"verified" boolean NOT NULL
|
||||
);
|
||||
|
||||
-- Indexes
|
||||
CREATE UNIQUE INDEX "serverpod_cloud_storage_path_idx" ON "serverpod_cloud_storage" USING btree ("storageId", "path");
|
||||
CREATE INDEX "serverpod_cloud_storage_expiration" ON "serverpod_cloud_storage" USING btree ("expiration");
|
||||
|
||||
--
|
||||
-- Class CloudStorageDirectUploadEntry as table serverpod_cloud_storage_direct_upload
|
||||
--
|
||||
CREATE TABLE "serverpod_cloud_storage_direct_upload" (
|
||||
"id" bigserial PRIMARY KEY,
|
||||
"storageId" text NOT NULL,
|
||||
"path" text NOT NULL,
|
||||
"expiration" timestamp without time zone NOT NULL,
|
||||
"authKey" text NOT NULL
|
||||
);
|
||||
|
||||
-- Indexes
|
||||
CREATE UNIQUE INDEX "serverpod_cloud_storage_direct_upload_storage_path" ON "serverpod_cloud_storage_direct_upload" USING btree ("storageId", "path");
|
||||
|
||||
--
|
||||
-- Class FutureCallEntry as table serverpod_future_call
|
||||
--
|
||||
CREATE TABLE "serverpod_future_call" (
|
||||
"id" bigserial PRIMARY KEY,
|
||||
"name" text NOT NULL,
|
||||
"time" timestamp without time zone NOT NULL,
|
||||
"serializedObject" text,
|
||||
"serverId" text NOT NULL,
|
||||
"identifier" text
|
||||
);
|
||||
|
||||
-- Indexes
|
||||
CREATE INDEX "serverpod_future_call_time_idx" ON "serverpod_future_call" USING btree ("time");
|
||||
CREATE INDEX "serverpod_future_call_serverId_idx" ON "serverpod_future_call" USING btree ("serverId");
|
||||
CREATE INDEX "serverpod_future_call_identifier_idx" ON "serverpod_future_call" USING btree ("identifier");
|
||||
|
||||
--
|
||||
-- Class ServerHealthConnectionInfo as table serverpod_health_connection_info
|
||||
--
|
||||
CREATE TABLE "serverpod_health_connection_info" (
|
||||
"id" bigserial PRIMARY KEY,
|
||||
"serverId" text NOT NULL,
|
||||
"timestamp" timestamp without time zone NOT NULL,
|
||||
"active" bigint NOT NULL,
|
||||
"closing" bigint NOT NULL,
|
||||
"idle" bigint NOT NULL,
|
||||
"granularity" bigint NOT NULL
|
||||
);
|
||||
|
||||
-- Indexes
|
||||
CREATE UNIQUE INDEX "serverpod_health_connection_info_timestamp_idx" ON "serverpod_health_connection_info" USING btree ("timestamp", "serverId", "granularity");
|
||||
|
||||
--
|
||||
-- Class ServerHealthMetric as table serverpod_health_metric
|
||||
--
|
||||
CREATE TABLE "serverpod_health_metric" (
|
||||
"id" bigserial PRIMARY KEY,
|
||||
"name" text NOT NULL,
|
||||
"serverId" text NOT NULL,
|
||||
"timestamp" timestamp without time zone NOT NULL,
|
||||
"isHealthy" boolean NOT NULL,
|
||||
"value" double precision NOT NULL,
|
||||
"granularity" bigint NOT NULL
|
||||
);
|
||||
|
||||
-- Indexes
|
||||
CREATE UNIQUE INDEX "serverpod_health_metric_timestamp_idx" ON "serverpod_health_metric" USING btree ("timestamp", "serverId", "name", "granularity");
|
||||
|
||||
--
|
||||
-- Class LogEntry as table serverpod_log
|
||||
--
|
||||
CREATE TABLE "serverpod_log" (
|
||||
"id" bigserial PRIMARY KEY,
|
||||
"sessionLogId" bigint NOT NULL,
|
||||
"messageId" bigint,
|
||||
"reference" text,
|
||||
"serverId" text NOT NULL,
|
||||
"time" timestamp without time zone NOT NULL,
|
||||
"logLevel" bigint NOT NULL,
|
||||
"message" text NOT NULL,
|
||||
"error" text,
|
||||
"stackTrace" text,
|
||||
"order" bigint NOT NULL
|
||||
);
|
||||
|
||||
-- Indexes
|
||||
CREATE INDEX "serverpod_log_sessionLogId_idx" ON "serverpod_log" USING btree ("sessionLogId");
|
||||
|
||||
--
|
||||
-- Class MessageLogEntry as table serverpod_message_log
|
||||
--
|
||||
CREATE TABLE "serverpod_message_log" (
|
||||
"id" bigserial PRIMARY KEY,
|
||||
"sessionLogId" bigint NOT NULL,
|
||||
"serverId" text NOT NULL,
|
||||
"messageId" bigint NOT NULL,
|
||||
"endpoint" text NOT NULL,
|
||||
"messageName" text NOT NULL,
|
||||
"duration" double precision NOT NULL,
|
||||
"error" text,
|
||||
"stackTrace" text,
|
||||
"slow" boolean NOT NULL,
|
||||
"order" bigint NOT NULL
|
||||
);
|
||||
|
||||
--
|
||||
-- Class MethodInfo as table serverpod_method
|
||||
--
|
||||
CREATE TABLE "serverpod_method" (
|
||||
"id" bigserial PRIMARY KEY,
|
||||
"endpoint" text NOT NULL,
|
||||
"method" text NOT NULL
|
||||
);
|
||||
|
||||
-- Indexes
|
||||
CREATE UNIQUE INDEX "serverpod_method_endpoint_method_idx" ON "serverpod_method" USING btree ("endpoint", "method");
|
||||
|
||||
--
|
||||
-- Class DatabaseMigrationVersion as table serverpod_migrations
|
||||
--
|
||||
CREATE TABLE "serverpod_migrations" (
|
||||
"id" bigserial PRIMARY KEY,
|
||||
"module" text NOT NULL,
|
||||
"version" text NOT NULL,
|
||||
"timestamp" timestamp without time zone
|
||||
);
|
||||
|
||||
-- Indexes
|
||||
CREATE UNIQUE INDEX "serverpod_migrations_ids" ON "serverpod_migrations" USING btree ("module");
|
||||
|
||||
--
|
||||
-- Class QueryLogEntry as table serverpod_query_log
|
||||
--
|
||||
CREATE TABLE "serverpod_query_log" (
|
||||
"id" bigserial PRIMARY KEY,
|
||||
"serverId" text NOT NULL,
|
||||
"sessionLogId" bigint NOT NULL,
|
||||
"messageId" bigint,
|
||||
"query" text NOT NULL,
|
||||
"duration" double precision NOT NULL,
|
||||
"numRows" bigint,
|
||||
"error" text,
|
||||
"stackTrace" text,
|
||||
"slow" boolean NOT NULL,
|
||||
"order" bigint NOT NULL
|
||||
);
|
||||
|
||||
-- Indexes
|
||||
CREATE INDEX "serverpod_query_log_sessionLogId_idx" ON "serverpod_query_log" USING btree ("sessionLogId");
|
||||
|
||||
--
|
||||
-- Class ReadWriteTestEntry as table serverpod_readwrite_test
|
||||
--
|
||||
CREATE TABLE "serverpod_readwrite_test" (
|
||||
"id" bigserial PRIMARY KEY,
|
||||
"number" bigint NOT NULL
|
||||
);
|
||||
|
||||
--
|
||||
-- Class RuntimeSettings as table serverpod_runtime_settings
|
||||
--
|
||||
CREATE TABLE "serverpod_runtime_settings" (
|
||||
"id" bigserial PRIMARY KEY,
|
||||
"logSettings" json NOT NULL,
|
||||
"logSettingsOverrides" json NOT NULL,
|
||||
"logServiceCalls" boolean NOT NULL,
|
||||
"logMalformedCalls" boolean NOT NULL
|
||||
);
|
||||
|
||||
--
|
||||
-- Class SessionLogEntry as table serverpod_session_log
|
||||
--
|
||||
CREATE TABLE "serverpod_session_log" (
|
||||
"id" bigserial PRIMARY KEY,
|
||||
"serverId" text NOT NULL,
|
||||
"time" timestamp without time zone NOT NULL,
|
||||
"module" text,
|
||||
"endpoint" text,
|
||||
"method" text,
|
||||
"duration" double precision,
|
||||
"numQueries" bigint,
|
||||
"slow" boolean,
|
||||
"error" text,
|
||||
"stackTrace" text,
|
||||
"authenticatedUserId" bigint,
|
||||
"isOpen" boolean,
|
||||
"touched" timestamp without time zone NOT NULL
|
||||
);
|
||||
|
||||
-- Indexes
|
||||
CREATE INDEX "serverpod_session_log_serverid_idx" ON "serverpod_session_log" USING btree ("serverId");
|
||||
CREATE INDEX "serverpod_session_log_touched_idx" ON "serverpod_session_log" USING btree ("touched");
|
||||
CREATE INDEX "serverpod_session_log_isopen_idx" ON "serverpod_session_log" USING btree ("isOpen");
|
||||
|
||||
--
|
||||
-- Class AuthKey as table serverpod_auth_key
|
||||
--
|
||||
CREATE TABLE "serverpod_auth_key" (
|
||||
"id" bigserial PRIMARY KEY,
|
||||
"userId" bigint NOT NULL,
|
||||
"hash" text NOT NULL,
|
||||
"scopeNames" json NOT NULL,
|
||||
"method" text NOT NULL
|
||||
);
|
||||
|
||||
-- Indexes
|
||||
CREATE INDEX "serverpod_auth_key_userId_idx" ON "serverpod_auth_key" USING btree ("userId");
|
||||
|
||||
--
|
||||
-- Class EmailAuth as table serverpod_email_auth
|
||||
--
|
||||
CREATE TABLE "serverpod_email_auth" (
|
||||
"id" bigserial PRIMARY KEY,
|
||||
"userId" bigint NOT NULL,
|
||||
"email" text NOT NULL,
|
||||
"hash" text NOT NULL
|
||||
);
|
||||
|
||||
-- Indexes
|
||||
CREATE UNIQUE INDEX "serverpod_email_auth_email" ON "serverpod_email_auth" USING btree ("email");
|
||||
|
||||
--
|
||||
-- Class EmailCreateAccountRequest as table serverpod_email_create_request
|
||||
--
|
||||
CREATE TABLE "serverpod_email_create_request" (
|
||||
"id" bigserial PRIMARY KEY,
|
||||
"userName" text NOT NULL,
|
||||
"email" text NOT NULL,
|
||||
"hash" text NOT NULL,
|
||||
"verificationCode" text NOT NULL
|
||||
);
|
||||
|
||||
-- Indexes
|
||||
CREATE UNIQUE INDEX "serverpod_email_auth_create_account_request_idx" ON "serverpod_email_create_request" USING btree ("email");
|
||||
|
||||
--
|
||||
-- Class EmailFailedSignIn as table serverpod_email_failed_sign_in
|
||||
--
|
||||
CREATE TABLE "serverpod_email_failed_sign_in" (
|
||||
"id" bigserial PRIMARY KEY,
|
||||
"email" text NOT NULL,
|
||||
"time" timestamp without time zone NOT NULL,
|
||||
"ipAddress" text NOT NULL
|
||||
);
|
||||
|
||||
-- Indexes
|
||||
CREATE INDEX "serverpod_email_failed_sign_in_email_idx" ON "serverpod_email_failed_sign_in" USING btree ("email");
|
||||
CREATE INDEX "serverpod_email_failed_sign_in_time_idx" ON "serverpod_email_failed_sign_in" USING btree ("time");
|
||||
|
||||
--
|
||||
-- Class EmailReset as table serverpod_email_reset
|
||||
--
|
||||
CREATE TABLE "serverpod_email_reset" (
|
||||
"id" bigserial PRIMARY KEY,
|
||||
"userId" bigint NOT NULL,
|
||||
"verificationCode" text NOT NULL,
|
||||
"expiration" timestamp without time zone NOT NULL
|
||||
);
|
||||
|
||||
-- Indexes
|
||||
CREATE UNIQUE INDEX "serverpod_email_reset_verification_idx" ON "serverpod_email_reset" USING btree ("verificationCode");
|
||||
|
||||
--
|
||||
-- Class GoogleRefreshToken as table serverpod_google_refresh_token
|
||||
--
|
||||
CREATE TABLE "serverpod_google_refresh_token" (
|
||||
"id" bigserial PRIMARY KEY,
|
||||
"userId" bigint NOT NULL,
|
||||
"refreshToken" text NOT NULL
|
||||
);
|
||||
|
||||
-- Indexes
|
||||
CREATE UNIQUE INDEX "serverpod_google_refresh_token_userId_idx" ON "serverpod_google_refresh_token" USING btree ("userId");
|
||||
|
||||
--
|
||||
-- Class UserImage as table serverpod_user_image
|
||||
--
|
||||
CREATE TABLE "serverpod_user_image" (
|
||||
"id" bigserial PRIMARY KEY,
|
||||
"userId" bigint NOT NULL,
|
||||
"version" bigint NOT NULL,
|
||||
"url" text NOT NULL
|
||||
);
|
||||
|
||||
-- Indexes
|
||||
CREATE INDEX "serverpod_user_image_user_id" ON "serverpod_user_image" USING btree ("userId", "version");
|
||||
|
||||
--
|
||||
-- Class UserInfo as table serverpod_user_info
|
||||
--
|
||||
CREATE TABLE "serverpod_user_info" (
|
||||
"id" bigserial PRIMARY KEY,
|
||||
"userIdentifier" text NOT NULL,
|
||||
"userName" text,
|
||||
"fullName" text,
|
||||
"email" text,
|
||||
"created" timestamp without time zone NOT NULL,
|
||||
"imageUrl" text,
|
||||
"scopeNames" json NOT NULL,
|
||||
"blocked" boolean NOT NULL
|
||||
);
|
||||
|
||||
-- Indexes
|
||||
CREATE UNIQUE INDEX "serverpod_user_info_user_identifier" ON "serverpod_user_info" USING btree ("userIdentifier");
|
||||
CREATE INDEX "serverpod_user_info_email" ON "serverpod_user_info" USING btree ("email");
|
||||
|
||||
--
|
||||
-- Foreign relations for "serverpod_log" table
|
||||
--
|
||||
ALTER TABLE ONLY "serverpod_log"
|
||||
ADD CONSTRAINT "serverpod_log_fk_0"
|
||||
FOREIGN KEY("sessionLogId")
|
||||
REFERENCES "serverpod_session_log"("id")
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION;
|
||||
|
||||
--
|
||||
-- Foreign relations for "serverpod_message_log" table
|
||||
--
|
||||
ALTER TABLE ONLY "serverpod_message_log"
|
||||
ADD CONSTRAINT "serverpod_message_log_fk_0"
|
||||
FOREIGN KEY("sessionLogId")
|
||||
REFERENCES "serverpod_session_log"("id")
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION;
|
||||
|
||||
--
|
||||
-- Foreign relations for "serverpod_query_log" table
|
||||
--
|
||||
ALTER TABLE ONLY "serverpod_query_log"
|
||||
ADD CONSTRAINT "serverpod_query_log_fk_0"
|
||||
FOREIGN KEY("sessionLogId")
|
||||
REFERENCES "serverpod_session_log"("id")
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION;
|
||||
|
||||
|
||||
--
|
||||
-- MIGRATION VERSION FOR wien_talks
|
||||
--
|
||||
INSERT INTO "serverpod_migrations" ("module", "version", "timestamp")
|
||||
VALUES ('wien_talks', '20250816171653001', now())
|
||||
ON CONFLICT ("module")
|
||||
DO UPDATE SET "version" = '20250816171653001', "timestamp" = now();
|
||||
|
||||
--
|
||||
-- MIGRATION VERSION FOR serverpod
|
||||
--
|
||||
INSERT INTO "serverpod_migrations" ("module", "version", "timestamp")
|
||||
VALUES ('serverpod', '20240516151843329', now())
|
||||
ON CONFLICT ("module")
|
||||
DO UPDATE SET "version" = '20240516151843329', "timestamp" = now();
|
||||
|
||||
--
|
||||
-- MIGRATION VERSION FOR serverpod_auth
|
||||
--
|
||||
INSERT INTO "serverpod_migrations" ("module", "version", "timestamp")
|
||||
VALUES ('serverpod_auth', '20240520102713718', now())
|
||||
ON CONFLICT ("module")
|
||||
DO UPDATE SET "version" = '20240520102713718', "timestamp" = now();
|
||||
|
||||
|
||||
COMMIT;
|
||||
|
|
@ -1,107 +0,0 @@
|
|||
{
|
||||
"moduleName": "wien_talks",
|
||||
"tables": [
|
||||
{
|
||||
"name": "quote",
|
||||
"dartName": "Quote",
|
||||
"module": "wien_talks",
|
||||
"schema": "public",
|
||||
"columns": [
|
||||
{
|
||||
"name": "id",
|
||||
"columnType": 6,
|
||||
"isNullable": false,
|
||||
"columnDefault": "nextval('quote_id_seq'::regclass)",
|
||||
"dartType": "int?"
|
||||
},
|
||||
{
|
||||
"name": "userId",
|
||||
"columnType": 6,
|
||||
"isNullable": false,
|
||||
"dartType": "int"
|
||||
},
|
||||
{
|
||||
"name": "text",
|
||||
"columnType": 0,
|
||||
"isNullable": false,
|
||||
"dartType": "String"
|
||||
},
|
||||
{
|
||||
"name": "authorName",
|
||||
"columnType": 0,
|
||||
"isNullable": true,
|
||||
"dartType": "String?"
|
||||
},
|
||||
{
|
||||
"name": "lat",
|
||||
"columnType": 3,
|
||||
"isNullable": false,
|
||||
"dartType": "double"
|
||||
},
|
||||
{
|
||||
"name": "long",
|
||||
"columnType": 3,
|
||||
"isNullable": false,
|
||||
"dartType": "double"
|
||||
},
|
||||
{
|
||||
"name": "createdAt",
|
||||
"columnType": 4,
|
||||
"isNullable": false,
|
||||
"dartType": "DateTime"
|
||||
},
|
||||
{
|
||||
"name": "visibility",
|
||||
"columnType": 6,
|
||||
"isNullable": false,
|
||||
"dartType": "int"
|
||||
},
|
||||
{
|
||||
"name": "upvotes",
|
||||
"columnType": 6,
|
||||
"isNullable": false,
|
||||
"dartType": "int"
|
||||
},
|
||||
{
|
||||
"name": "downvotes",
|
||||
"columnType": 6,
|
||||
"isNullable": false,
|
||||
"dartType": "int"
|
||||
},
|
||||
{
|
||||
"name": "tags",
|
||||
"columnType": 8,
|
||||
"isNullable": true,
|
||||
"dartType": "List<String>?"
|
||||
}
|
||||
],
|
||||
"foreignKeys": [],
|
||||
"indexes": [
|
||||
{
|
||||
"indexName": "quote_pkey",
|
||||
"elements": [
|
||||
{
|
||||
"type": 0,
|
||||
"definition": "id"
|
||||
}
|
||||
],
|
||||
"type": "btree",
|
||||
"isUnique": true,
|
||||
"isPrimary": true
|
||||
}
|
||||
],
|
||||
"managed": true
|
||||
}
|
||||
],
|
||||
"installedModules": [
|
||||
{
|
||||
"module": "serverpod",
|
||||
"version": "20240516151843329"
|
||||
},
|
||||
{
|
||||
"module": "serverpod_auth",
|
||||
"version": "20240520102713718"
|
||||
}
|
||||
],
|
||||
"migrationApiVersion": 1
|
||||
}
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
{
|
||||
"actions": [],
|
||||
"warnings": [],
|
||||
"migrationApiVersion": 1
|
||||
}
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
BEGIN;
|
||||
|
||||
|
||||
--
|
||||
-- MIGRATION VERSION FOR wien_talks
|
||||
--
|
||||
INSERT INTO "serverpod_migrations" ("module", "version", "timestamp")
|
||||
VALUES ('wien_talks', '20250816171653001', now())
|
||||
ON CONFLICT ("module")
|
||||
DO UPDATE SET "version" = '20250816171653001', "timestamp" = now();
|
||||
|
||||
--
|
||||
-- MIGRATION VERSION FOR serverpod
|
||||
--
|
||||
INSERT INTO "serverpod_migrations" ("module", "version", "timestamp")
|
||||
VALUES ('serverpod', '20240516151843329', now())
|
||||
ON CONFLICT ("module")
|
||||
DO UPDATE SET "version" = '20240516151843329', "timestamp" = now();
|
||||
|
||||
--
|
||||
-- MIGRATION VERSION FOR serverpod_auth
|
||||
--
|
||||
INSERT INTO "serverpod_migrations" ("module", "version", "timestamp")
|
||||
VALUES ('serverpod_auth', '20240520102713718', now())
|
||||
ON CONFLICT ("module")
|
||||
DO UPDATE SET "version" = '20240520102713718', "timestamp" = now();
|
||||
|
||||
|
||||
COMMIT;
|
||||
|
|
@ -6,4 +6,3 @@
|
|||
|
||||
20250816095813247
|
||||
20250816122625449
|
||||
20250816171653001
|
||||
|
|
|
|||
|
|
@ -17,8 +17,6 @@ import 'dart:async' as _i3;
|
|||
import 'package:wien_talks_server/src/generated/quotes/quote.dart' as _i4;
|
||||
import 'package:wien_talks_server/src/generated/quotes/create_quote.dart'
|
||||
as _i5;
|
||||
import 'package:wien_talks_server/src/generated/votes/vote.dart' as _i6;
|
||||
import 'package:wien_talks_server/src/generated/votes/vote_request.dart' as _i7;
|
||||
import 'package:wien_talks_server/src/generated/protocol.dart';
|
||||
import 'package:wien_talks_server/src/generated/endpoints.dart';
|
||||
export 'package:serverpod_test/serverpod_test_public_exports.dart';
|
||||
|
|
@ -105,9 +103,7 @@ void withServerpod(
|
|||
}
|
||||
|
||||
class TestEndpoints {
|
||||
late final _QuoteEndpoint quote;
|
||||
|
||||
late final _VotesEndpoint votes;
|
||||
late final _ShowLatestNewsWidget showLatestNewsWidget;
|
||||
}
|
||||
|
||||
class _InternalTestEndpoints extends TestEndpoints
|
||||
|
|
@ -117,19 +113,15 @@ class _InternalTestEndpoints extends TestEndpoints
|
|||
_i2.SerializationManager serializationManager,
|
||||
_i2.EndpointDispatch endpoints,
|
||||
) {
|
||||
quote = _QuoteEndpoint(
|
||||
endpoints,
|
||||
serializationManager,
|
||||
);
|
||||
votes = _VotesEndpoint(
|
||||
showLatestNewsWidget = _ShowLatestNewsWidget(
|
||||
endpoints,
|
||||
serializationManager,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _QuoteEndpoint {
|
||||
_QuoteEndpoint(
|
||||
class _ShowLatestNewsWidget {
|
||||
_ShowLatestNewsWidget(
|
||||
this._endpointDispatch,
|
||||
this._serializationManager,
|
||||
);
|
||||
|
|
@ -145,13 +137,13 @@ class _QuoteEndpoint {
|
|||
return _i1.callAwaitableFunctionAndHandleExceptions(() async {
|
||||
var _localUniqueSession =
|
||||
(sessionBuilder as _i1.InternalTestSessionBuilder).internalBuild(
|
||||
endpoint: 'quote',
|
||||
endpoint: 'showLatestNewsWidget',
|
||||
method: 'createQuote',
|
||||
);
|
||||
try {
|
||||
var _localCallContext = await _endpointDispatch.getMethodCallContext(
|
||||
createSessionCallback: (_) => _localUniqueSession,
|
||||
endpointPath: 'quote',
|
||||
endpointPath: 'showLatestNewsWidget',
|
||||
methodName: 'createQuote',
|
||||
parameters: _i1.testObjectToJson({'req': req}),
|
||||
serializationManager: _serializationManager,
|
||||
|
|
@ -174,13 +166,13 @@ class _QuoteEndpoint {
|
|||
return _i1.callAwaitableFunctionAndHandleExceptions(() async {
|
||||
var _localUniqueSession =
|
||||
(sessionBuilder as _i1.InternalTestSessionBuilder).internalBuild(
|
||||
endpoint: 'quote',
|
||||
endpoint: 'showLatestNewsWidget',
|
||||
method: 'updateQuote',
|
||||
);
|
||||
try {
|
||||
var _localCallContext = await _endpointDispatch.getMethodCallContext(
|
||||
createSessionCallback: (_) => _localUniqueSession,
|
||||
endpointPath: 'quote',
|
||||
endpointPath: 'showLatestNewsWidget',
|
||||
methodName: 'updateQuote',
|
||||
parameters: _i1.testObjectToJson({'quote': quote}),
|
||||
serializationManager: _serializationManager,
|
||||
|
|
@ -197,19 +189,21 @@ class _QuoteEndpoint {
|
|||
}
|
||||
|
||||
_i3.Future<List<_i4.Quote>> getAllQuotes(
|
||||
_i1.TestSessionBuilder sessionBuilder) async {
|
||||
_i1.TestSessionBuilder sessionBuilder, {
|
||||
required int limit,
|
||||
}) async {
|
||||
return _i1.callAwaitableFunctionAndHandleExceptions(() async {
|
||||
var _localUniqueSession =
|
||||
(sessionBuilder as _i1.InternalTestSessionBuilder).internalBuild(
|
||||
endpoint: 'quote',
|
||||
endpoint: 'showLatestNewsWidget',
|
||||
method: 'getAllQuotes',
|
||||
);
|
||||
try {
|
||||
var _localCallContext = await _endpointDispatch.getMethodCallContext(
|
||||
createSessionCallback: (_) => _localUniqueSession,
|
||||
endpointPath: 'quote',
|
||||
endpointPath: 'showLatestNewsWidget',
|
||||
methodName: 'getAllQuotes',
|
||||
parameters: _i1.testObjectToJson({}),
|
||||
parameters: _i1.testObjectToJson({'limit': limit}),
|
||||
serializationManager: _serializationManager,
|
||||
);
|
||||
var _localReturnValue = await (_localCallContext.method.call(
|
||||
|
|
@ -223,70 +217,3 @@ class _QuoteEndpoint {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
class _VotesEndpoint {
|
||||
_VotesEndpoint(
|
||||
this._endpointDispatch,
|
||||
this._serializationManager,
|
||||
);
|
||||
|
||||
final _i2.EndpointDispatch _endpointDispatch;
|
||||
|
||||
final _i2.SerializationManager _serializationManager;
|
||||
|
||||
_i3.Future<_i6.Vote> postVote(
|
||||
_i1.TestSessionBuilder sessionBuilder,
|
||||
_i7.VoteRequest voteRequest,
|
||||
) async {
|
||||
return _i1.callAwaitableFunctionAndHandleExceptions(() async {
|
||||
var _localUniqueSession =
|
||||
(sessionBuilder as _i1.InternalTestSessionBuilder).internalBuild(
|
||||
endpoint: 'votes',
|
||||
method: 'postVote',
|
||||
);
|
||||
try {
|
||||
var _localCallContext = await _endpointDispatch.getMethodCallContext(
|
||||
createSessionCallback: (_) => _localUniqueSession,
|
||||
endpointPath: 'votes',
|
||||
methodName: 'postVote',
|
||||
parameters: _i1.testObjectToJson({'voteRequest': voteRequest}),
|
||||
serializationManager: _serializationManager,
|
||||
);
|
||||
var _localReturnValue = await (_localCallContext.method.call(
|
||||
_localUniqueSession,
|
||||
_localCallContext.arguments,
|
||||
) as _i3.Future<_i6.Vote>);
|
||||
return _localReturnValue;
|
||||
} finally {
|
||||
await _localUniqueSession.close();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
_i3.Future<List<_i6.Vote>> getAllVotes(
|
||||
_i1.TestSessionBuilder sessionBuilder) async {
|
||||
return _i1.callAwaitableFunctionAndHandleExceptions(() async {
|
||||
var _localUniqueSession =
|
||||
(sessionBuilder as _i1.InternalTestSessionBuilder).internalBuild(
|
||||
endpoint: 'votes',
|
||||
method: 'getAllVotes',
|
||||
);
|
||||
try {
|
||||
var _localCallContext = await _endpointDispatch.getMethodCallContext(
|
||||
createSessionCallback: (_) => _localUniqueSession,
|
||||
endpointPath: 'votes',
|
||||
methodName: 'getAllVotes',
|
||||
parameters: _i1.testObjectToJson({}),
|
||||
serializationManager: _serializationManager,
|
||||
);
|
||||
var _localReturnValue = await (_localCallContext.method.call(
|
||||
_localUniqueSession,
|
||||
_localCallContext.arguments,
|
||||
) as _i3.Future<List<_i6.Vote>>);
|
||||
return _localReturnValue;
|
||||
} finally {
|
||||
await _localUniqueSession.close();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue