mirror of
https://github.com/timokz/flutter-vienna-hackathon-25.git
synced 2025-11-08 21:04:20 +01:00
Compare commits
3 commits
c64fa677ac
...
68e7a9720a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
68e7a9720a | ||
|
|
83f773abe1 | ||
|
|
be2a58cbd9 |
25 changed files with 3896 additions and 142 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1,2 +1,3 @@
|
||||||
wien_talks/wien_talks_flutter/pubspec.lock
|
wien_talks/wien_talks_flutter/pubspec.lock
|
||||||
wien_talks/wien_talks_flutter/android/app/google-services.json
|
wien_talks/wien_talks_flutter/android/app/google-services.json
|
||||||
|
*.pptx#
|
||||||
|
|
|
||||||
BIN
wien_talks/FunMap_Presentation.pptx
Normal file
BIN
wien_talks/FunMap_Presentation.pptx
Normal file
Binary file not shown.
|
|
@ -13,44 +13,68 @@ import 'package:serverpod_client/serverpod_client.dart' as _i1;
|
||||||
import 'dart:async' as _i2;
|
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/quote.dart' as _i3;
|
||||||
import 'package:wien_talks_client/src/protocol/quotes/create_quote.dart' as _i4;
|
import 'package:wien_talks_client/src/protocol/quotes/create_quote.dart' as _i4;
|
||||||
import 'package:serverpod_auth_client/serverpod_auth_client.dart' as _i5;
|
import 'package:wien_talks_client/src/protocol/votes/vote.dart' as _i5;
|
||||||
import 'protocol.dart' as _i6;
|
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;
|
||||||
|
|
||||||
/// {@category Endpoint}
|
/// {@category Endpoint}
|
||||||
class EndpointShowLatestNewsWidget extends _i1.EndpointRef {
|
class EndpointQuote extends _i1.EndpointRef {
|
||||||
EndpointShowLatestNewsWidget(_i1.EndpointCaller caller) : super(caller);
|
EndpointQuote(_i1.EndpointCaller caller) : super(caller);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get name => 'showLatestNewsWidget';
|
String get name => 'quote';
|
||||||
|
|
||||||
_i2.Future<_i3.Quote> createQuote(_i4.CreateQuoteRequest req) =>
|
_i2.Future<_i3.Quote> createQuote(_i4.CreateQuoteRequest req) =>
|
||||||
caller.callServerEndpoint<_i3.Quote>(
|
caller.callServerEndpoint<_i3.Quote>(
|
||||||
'showLatestNewsWidget',
|
'quote',
|
||||||
'createQuote',
|
'createQuote',
|
||||||
{'req': req},
|
{'req': req},
|
||||||
);
|
);
|
||||||
|
|
||||||
_i2.Future<void> updateQuote(_i3.Quote quote) =>
|
_i2.Future<void> updateQuote(_i3.Quote quote) =>
|
||||||
caller.callServerEndpoint<void>(
|
caller.callServerEndpoint<void>(
|
||||||
'showLatestNewsWidget',
|
'quote',
|
||||||
'updateQuote',
|
'updateQuote',
|
||||||
{'quote': quote},
|
{'quote': quote},
|
||||||
);
|
);
|
||||||
|
|
||||||
_i2.Future<List<_i3.Quote>> getAllQuotes({required int limit}) =>
|
_i2.Future<List<_i3.Quote>> getAllQuotes() =>
|
||||||
caller.callServerEndpoint<List<_i3.Quote>>(
|
caller.callServerEndpoint<List<_i3.Quote>>(
|
||||||
'showLatestNewsWidget',
|
'quote',
|
||||||
'getAllQuotes',
|
'getAllQuotes',
|
||||||
{'limit': limit},
|
{},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// {@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',
|
||||||
|
{},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
class Modules {
|
class Modules {
|
||||||
Modules(Client client) {
|
Modules(Client client) {
|
||||||
auth = _i5.Caller(client);
|
auth = _i7.Caller(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
late final _i5.Caller auth;
|
late final _i7.Caller auth;
|
||||||
}
|
}
|
||||||
|
|
||||||
class Client extends _i1.ServerpodClientShared {
|
class Client extends _i1.ServerpodClientShared {
|
||||||
|
|
@ -69,7 +93,7 @@ class Client extends _i1.ServerpodClientShared {
|
||||||
bool? disconnectStreamsOnLostInternetConnection,
|
bool? disconnectStreamsOnLostInternetConnection,
|
||||||
}) : super(
|
}) : super(
|
||||||
host,
|
host,
|
||||||
_i6.Protocol(),
|
_i8.Protocol(),
|
||||||
securityContext: securityContext,
|
securityContext: securityContext,
|
||||||
authenticationKeyManager: authenticationKeyManager,
|
authenticationKeyManager: authenticationKeyManager,
|
||||||
streamingConnectionTimeout: streamingConnectionTimeout,
|
streamingConnectionTimeout: streamingConnectionTimeout,
|
||||||
|
|
@ -79,17 +103,22 @@ class Client extends _i1.ServerpodClientShared {
|
||||||
disconnectStreamsOnLostInternetConnection:
|
disconnectStreamsOnLostInternetConnection:
|
||||||
disconnectStreamsOnLostInternetConnection,
|
disconnectStreamsOnLostInternetConnection,
|
||||||
) {
|
) {
|
||||||
showLatestNewsWidget = EndpointShowLatestNewsWidget(this);
|
quote = EndpointQuote(this);
|
||||||
|
votes = EndpointVotes(this);
|
||||||
modules = Modules(this);
|
modules = Modules(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
late final EndpointShowLatestNewsWidget showLatestNewsWidget;
|
late final EndpointQuote quote;
|
||||||
|
|
||||||
|
late final EndpointVotes votes;
|
||||||
|
|
||||||
late final Modules modules;
|
late final Modules modules;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Map<String, _i1.EndpointRef> get endpointRefLookup =>
|
Map<String, _i1.EndpointRef> get endpointRefLookup => {
|
||||||
{'showLatestNewsWidget': showLatestNewsWidget};
|
'quote': quote,
|
||||||
|
'votes': votes,
|
||||||
|
};
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Map<String, _i1.ModuleEndpointCaller> get moduleLookup =>
|
Map<String, _i1.ModuleEndpointCaller> get moduleLookup =>
|
||||||
|
|
|
||||||
|
|
@ -12,10 +12,15 @@
|
||||||
import 'package:serverpod_client/serverpod_client.dart' as _i1;
|
import 'package:serverpod_client/serverpod_client.dart' as _i1;
|
||||||
import 'quotes/create_quote.dart' as _i2;
|
import 'quotes/create_quote.dart' as _i2;
|
||||||
import 'quotes/quote.dart' as _i3;
|
import 'quotes/quote.dart' as _i3;
|
||||||
import 'package:wien_talks_client/src/protocol/quotes/quote.dart' as _i4;
|
import 'votes/vote.dart' as _i4;
|
||||||
import 'package:serverpod_auth_client/serverpod_auth_client.dart' as _i5;
|
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;
|
||||||
export 'quotes/create_quote.dart';
|
export 'quotes/create_quote.dart';
|
||||||
export 'quotes/quote.dart';
|
export 'quotes/quote.dart';
|
||||||
|
export 'votes/vote.dart';
|
||||||
|
export 'votes/vote_request.dart';
|
||||||
export 'client.dart';
|
export 'client.dart';
|
||||||
|
|
||||||
class Protocol extends _i1.SerializationManager {
|
class Protocol extends _i1.SerializationManager {
|
||||||
|
|
@ -37,12 +42,24 @@ class Protocol extends _i1.SerializationManager {
|
||||||
if (t == _i3.Quote) {
|
if (t == _i3.Quote) {
|
||||||
return _i3.Quote.fromJson(data) as T;
|
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?>()) {
|
if (t == _i1.getType<_i2.CreateQuoteRequest?>()) {
|
||||||
return (data != null ? _i2.CreateQuoteRequest.fromJson(data) : null) as T;
|
return (data != null ? _i2.CreateQuoteRequest.fromJson(data) : null) as T;
|
||||||
}
|
}
|
||||||
if (t == _i1.getType<_i3.Quote?>()) {
|
if (t == _i1.getType<_i3.Quote?>()) {
|
||||||
return (data != null ? _i3.Quote.fromJson(data) : null) as T;
|
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>?>()) {
|
if (t == _i1.getType<List<String>?>()) {
|
||||||
return (data != null
|
return (data != null
|
||||||
? (data as List).map((e) => deserialize<String>(e)).toList()
|
? (data as List).map((e) => deserialize<String>(e)).toList()
|
||||||
|
|
@ -53,11 +70,14 @@ class Protocol extends _i1.SerializationManager {
|
||||||
? (data as List).map((e) => deserialize<String>(e)).toList()
|
? (data as List).map((e) => deserialize<String>(e)).toList()
|
||||||
: null) as T;
|
: null) as T;
|
||||||
}
|
}
|
||||||
if (t == List<_i4.Quote>) {
|
if (t == List<_i6.Quote>) {
|
||||||
return (data as List).map((e) => deserialize<_i4.Quote>(e)).toList() as T;
|
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;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
return _i5.Protocol().deserialize<T>(data, t);
|
return _i8.Protocol().deserialize<T>(data, t);
|
||||||
} on _i1.DeserializationTypeNotFoundException catch (_) {}
|
} on _i1.DeserializationTypeNotFoundException catch (_) {}
|
||||||
return super.deserialize<T>(data, t);
|
return super.deserialize<T>(data, t);
|
||||||
}
|
}
|
||||||
|
|
@ -72,7 +92,13 @@ class Protocol extends _i1.SerializationManager {
|
||||||
if (data is _i3.Quote) {
|
if (data is _i3.Quote) {
|
||||||
return 'Quote';
|
return 'Quote';
|
||||||
}
|
}
|
||||||
className = _i5.Protocol().getClassNameForObject(data);
|
if (data is _i4.Vote) {
|
||||||
|
return 'Vote';
|
||||||
|
}
|
||||||
|
if (data is _i5.VoteRequest) {
|
||||||
|
return 'VoteRequest';
|
||||||
|
}
|
||||||
|
className = _i8.Protocol().getClassNameForObject(data);
|
||||||
if (className != null) {
|
if (className != null) {
|
||||||
return 'serverpod_auth.$className';
|
return 'serverpod_auth.$className';
|
||||||
}
|
}
|
||||||
|
|
@ -91,9 +117,15 @@ class Protocol extends _i1.SerializationManager {
|
||||||
if (dataClassName == 'Quote') {
|
if (dataClassName == 'Quote') {
|
||||||
return deserialize<_i3.Quote>(data['data']);
|
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.')) {
|
if (dataClassName.startsWith('serverpod_auth.')) {
|
||||||
data['className'] = dataClassName.substring(15);
|
data['className'] = dataClassName.substring(15);
|
||||||
return _i5.Protocol().deserializeByClassName(data);
|
return _i8.Protocol().deserializeByClassName(data);
|
||||||
}
|
}
|
||||||
return super.deserializeByClassName(data);
|
return super.deserializeByClassName(data);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
120
wien_talks/wien_talks_client/lib/src/protocol/votes/vote.dart
Normal file
120
wien_talks/wien_talks_client/lib/src/protocol/votes/vote.dart
Normal file
|
|
@ -0,0 +1,120 @@
|
||||||
|
/* 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,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,108 @@
|
||||||
|
/* 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) {
|
switch (snapshot.connectionState) {
|
||||||
case ConnectionState.none:
|
case ConnectionState.none:
|
||||||
case ConnectionState.waiting:
|
case ConnectionState.waiting:
|
||||||
return CircularProgressIndicator();
|
return Center(child: CircularProgressIndicator());
|
||||||
case ConnectionState.active:
|
case ConnectionState.active:
|
||||||
case ConnectionState.done:
|
case ConnectionState.done:
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:location/location.dart';
|
import 'package:location/location.dart';
|
||||||
import 'package:mapsforge_flutter/core.dart';
|
import 'package:mapsforge_flutter/core.dart';
|
||||||
|
|
@ -34,7 +35,7 @@ class LocationMgr {
|
||||||
|
|
||||||
final SymbolCache symbolCache = FileSymbolCache();
|
final SymbolCache symbolCache = FileSymbolCache();
|
||||||
|
|
||||||
final JobRenderer jobRenderer = MapOnlineRenderer();
|
final JobRenderer jobRenderer = kIsWeb ? MapOnlineRendererWeb() : MapOnlineRenderer();
|
||||||
|
|
||||||
final MarkerByItemDataStore markerDataStore = MarkerByItemDataStore();
|
final MarkerByItemDataStore markerDataStore = MarkerByItemDataStore();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,84 +4,54 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:wien_talks_client/wien_talks_client.dart';
|
import 'package:wien_talks_client/wien_talks_client.dart';
|
||||||
import 'package:wien_talks_flutter/helper/funmap_mgr.dart';
|
import 'package:wien_talks_flutter/helper/funmap_mgr.dart';
|
||||||
|
|
||||||
class ShowLatestNewsWidget extends StatefulWidget {
|
class ShowLatestNewsWidget extends StatelessWidget {
|
||||||
const ShowLatestNewsWidget({super.key});
|
const ShowLatestNewsWidget({super.key});
|
||||||
@override
|
|
||||||
State<ShowLatestNewsWidget> createState() => _ShowLatestNewsWidgetState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _ShowLatestNewsWidgetState extends State<ShowLatestNewsWidget> {
|
Future<List<Quote>> _load() async {
|
||||||
final _controller = StreamController<List<Quote>>.broadcast();
|
final list = await FunmapMgr().client.quote.getAllQuotes();
|
||||||
Timer? _timer;
|
return list.whereType<Quote>().toList(growable: false);
|
||||||
|
|
||||||
@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
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return RefreshIndicator(
|
return FutureBuilder<List<Quote>>(
|
||||||
onRefresh: _reload,
|
future: _load(),
|
||||||
child: StreamBuilder<List<Quote>>(
|
|
||||||
stream: _controller.stream,
|
|
||||||
initialData: const <Quote>[],
|
|
||||||
builder: (context, snap) {
|
builder: (context, snap) {
|
||||||
|
if (snap.connectionState != ConnectionState.done) {
|
||||||
|
return const Center(child: CircularProgressIndicator());
|
||||||
|
}
|
||||||
if (snap.hasError) {
|
if (snap.hasError) {
|
||||||
return ListView(
|
return Center(
|
||||||
children: [
|
child: Padding(
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.all(16),
|
padding: const EdgeInsets.all(16),
|
||||||
child: Text('Error: ${snap.error}'),
|
child: Text('Error: ${snap.error}'),
|
||||||
),
|
),
|
||||||
],
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
final quotes = snap.data ?? const <Quote>[];
|
final quotes = snap.data ?? const <Quote>[];
|
||||||
if (quotes.isEmpty) {
|
if (quotes.isEmpty) {
|
||||||
return ListView(
|
return const Center(child: Text('No quotes yet.'));
|
||||||
children: const [
|
|
||||||
Padding(
|
|
||||||
padding: EdgeInsets.all(16),
|
|
||||||
child: Text('No quotes yet. Pull to refresh.'),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ListView.separated(
|
return ListView.separated(
|
||||||
itemCount: quotes.length,
|
itemCount: quotes.length,
|
||||||
separatorBuilder: (_, __) => const Divider(height: 1),
|
separatorBuilder: (_, __) => const Divider(height: 1),
|
||||||
itemBuilder: (context, i) {
|
itemBuilder: (context, i) {
|
||||||
final q = quotes[i];
|
final q = quotes[i];
|
||||||
|
final author = (q.authorName ?? '').trim();
|
||||||
|
final when = (q.createdAt ?? DateTime.fromMillisecondsSinceEpoch(0))
|
||||||
|
.toLocal()
|
||||||
|
.toString();
|
||||||
return ListTile(
|
return ListTile(
|
||||||
title: Text(q.text),
|
title: Text(q.text),
|
||||||
subtitle: Text([
|
subtitle: Text([
|
||||||
if ((q.authorName ?? '').isNotEmpty) q.authorName!,
|
if (author.isNotEmpty) author,
|
||||||
q.createdAt.toLocal().toString(),
|
when,
|
||||||
].where((e) => e.isNotEmpty).join(' · ')),
|
].join(' · ')),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,32 +11,40 @@
|
||||||
// ignore_for_file: no_leading_underscores_for_library_prefixes
|
// ignore_for_file: no_leading_underscores_for_library_prefixes
|
||||||
import 'package:serverpod/serverpod.dart' as _i1;
|
import 'package:serverpod/serverpod.dart' as _i1;
|
||||||
import '../quotes/quotes_endpoint.dart' as _i2;
|
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'
|
import 'package:wien_talks_server/src/generated/quotes/create_quote.dart'
|
||||||
as _i3;
|
as _i4;
|
||||||
import 'package:wien_talks_server/src/generated/quotes/quote.dart' as _i4;
|
import 'package:wien_talks_server/src/generated/quotes/quote.dart' as _i5;
|
||||||
import 'package:serverpod_auth_server/serverpod_auth_server.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;
|
||||||
|
|
||||||
class Endpoints extends _i1.EndpointDispatch {
|
class Endpoints extends _i1.EndpointDispatch {
|
||||||
@override
|
@override
|
||||||
void initializeEndpoints(_i1.Server server) {
|
void initializeEndpoints(_i1.Server server) {
|
||||||
var endpoints = <String, _i1.Endpoint>{
|
var endpoints = <String, _i1.Endpoint>{
|
||||||
'showLatestNewsWidget': _i2.ShowLatestNewsWidget()
|
'quote': _i2.QuoteEndpoint()
|
||||||
..initialize(
|
..initialize(
|
||||||
server,
|
server,
|
||||||
'showLatestNewsWidget',
|
'quote',
|
||||||
null,
|
null,
|
||||||
)
|
),
|
||||||
|
'votes': _i3.VotesEndpoint()
|
||||||
|
..initialize(
|
||||||
|
server,
|
||||||
|
'votes',
|
||||||
|
null,
|
||||||
|
),
|
||||||
};
|
};
|
||||||
connectors['showLatestNewsWidget'] = _i1.EndpointConnector(
|
connectors['quote'] = _i1.EndpointConnector(
|
||||||
name: 'showLatestNewsWidget',
|
name: 'quote',
|
||||||
endpoint: endpoints['showLatestNewsWidget']!,
|
endpoint: endpoints['quote']!,
|
||||||
methodConnectors: {
|
methodConnectors: {
|
||||||
'createQuote': _i1.MethodConnector(
|
'createQuote': _i1.MethodConnector(
|
||||||
name: 'createQuote',
|
name: 'createQuote',
|
||||||
params: {
|
params: {
|
||||||
'req': _i1.ParameterDescription(
|
'req': _i1.ParameterDescription(
|
||||||
name: 'req',
|
name: 'req',
|
||||||
type: _i1.getType<_i3.CreateQuoteRequest>(),
|
type: _i1.getType<_i4.CreateQuoteRequest>(),
|
||||||
nullable: false,
|
nullable: false,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
|
@ -44,8 +52,7 @@ class Endpoints extends _i1.EndpointDispatch {
|
||||||
_i1.Session session,
|
_i1.Session session,
|
||||||
Map<String, dynamic> params,
|
Map<String, dynamic> params,
|
||||||
) async =>
|
) async =>
|
||||||
(endpoints['showLatestNewsWidget'] as _i2.ShowLatestNewsWidget)
|
(endpoints['quote'] as _i2.QuoteEndpoint).createQuote(
|
||||||
.createQuote(
|
|
||||||
session,
|
session,
|
||||||
params['req'],
|
params['req'],
|
||||||
),
|
),
|
||||||
|
|
@ -55,7 +62,7 @@ class Endpoints extends _i1.EndpointDispatch {
|
||||||
params: {
|
params: {
|
||||||
'quote': _i1.ParameterDescription(
|
'quote': _i1.ParameterDescription(
|
||||||
name: 'quote',
|
name: 'quote',
|
||||||
type: _i1.getType<_i4.Quote>(),
|
type: _i1.getType<_i5.Quote>(),
|
||||||
nullable: false,
|
nullable: false,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
|
@ -63,18 +70,32 @@ class Endpoints extends _i1.EndpointDispatch {
|
||||||
_i1.Session session,
|
_i1.Session session,
|
||||||
Map<String, dynamic> params,
|
Map<String, dynamic> params,
|
||||||
) async =>
|
) async =>
|
||||||
(endpoints['showLatestNewsWidget'] as _i2.ShowLatestNewsWidget)
|
(endpoints['quote'] as _i2.QuoteEndpoint).updateQuote(
|
||||||
.updateQuote(
|
|
||||||
session,
|
session,
|
||||||
params['quote'],
|
params['quote'],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
'getAllQuotes': _i1.MethodConnector(
|
'getAllQuotes': _i1.MethodConnector(
|
||||||
name: 'getAllQuotes',
|
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: {
|
params: {
|
||||||
'limit': _i1.ParameterDescription(
|
'voteRequest': _i1.ParameterDescription(
|
||||||
name: 'limit',
|
name: 'voteRequest',
|
||||||
type: _i1.getType<int>(),
|
type: _i1.getType<_i6.VoteRequest>(),
|
||||||
nullable: false,
|
nullable: false,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
|
@ -82,14 +103,22 @@ class Endpoints extends _i1.EndpointDispatch {
|
||||||
_i1.Session session,
|
_i1.Session session,
|
||||||
Map<String, dynamic> params,
|
Map<String, dynamic> params,
|
||||||
) async =>
|
) async =>
|
||||||
(endpoints['showLatestNewsWidget'] as _i2.ShowLatestNewsWidget)
|
(endpoints['votes'] as _i3.VotesEndpoint).postVote(
|
||||||
.getAllQuotes(
|
|
||||||
session,
|
session,
|
||||||
limit: params['limit'],
|
params['voteRequest'],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
'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'] = _i5.Endpoints()..initializeEndpoints(server);
|
modules['serverpod_auth'] = _i7.Endpoints()..initializeEndpoints(server);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,9 +14,14 @@ import 'package:serverpod/protocol.dart' as _i2;
|
||||||
import 'package:serverpod_auth_server/serverpod_auth_server.dart' as _i3;
|
import 'package:serverpod_auth_server/serverpod_auth_server.dart' as _i3;
|
||||||
import 'quotes/create_quote.dart' as _i4;
|
import 'quotes/create_quote.dart' as _i4;
|
||||||
import 'quotes/quote.dart' as _i5;
|
import 'quotes/quote.dart' as _i5;
|
||||||
import 'package:wien_talks_server/src/generated/quotes/quote.dart' as _i6;
|
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;
|
||||||
export 'quotes/create_quote.dart';
|
export 'quotes/create_quote.dart';
|
||||||
export 'quotes/quote.dart';
|
export 'quotes/quote.dart';
|
||||||
|
export 'votes/vote.dart';
|
||||||
|
export 'votes/vote_request.dart';
|
||||||
|
|
||||||
class Protocol extends _i1.SerializationManagerServer {
|
class Protocol extends _i1.SerializationManagerServer {
|
||||||
Protocol._();
|
Protocol._();
|
||||||
|
|
@ -118,6 +123,112 @@ class Protocol extends _i1.SerializationManagerServer {
|
||||||
],
|
],
|
||||||
managed: true,
|
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,
|
..._i3.Protocol.targetTableDefinitions,
|
||||||
..._i2.Protocol.targetTableDefinitions,
|
..._i2.Protocol.targetTableDefinitions,
|
||||||
];
|
];
|
||||||
|
|
@ -134,12 +245,24 @@ class Protocol extends _i1.SerializationManagerServer {
|
||||||
if (t == _i5.Quote) {
|
if (t == _i5.Quote) {
|
||||||
return _i5.Quote.fromJson(data) as T;
|
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?>()) {
|
if (t == _i1.getType<_i4.CreateQuoteRequest?>()) {
|
||||||
return (data != null ? _i4.CreateQuoteRequest.fromJson(data) : null) as T;
|
return (data != null ? _i4.CreateQuoteRequest.fromJson(data) : null) as T;
|
||||||
}
|
}
|
||||||
if (t == _i1.getType<_i5.Quote?>()) {
|
if (t == _i1.getType<_i5.Quote?>()) {
|
||||||
return (data != null ? _i5.Quote.fromJson(data) : null) as T;
|
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>?>()) {
|
if (t == _i1.getType<List<String>?>()) {
|
||||||
return (data != null
|
return (data != null
|
||||||
? (data as List).map((e) => deserialize<String>(e)).toList()
|
? (data as List).map((e) => deserialize<String>(e)).toList()
|
||||||
|
|
@ -150,8 +273,11 @@ class Protocol extends _i1.SerializationManagerServer {
|
||||||
? (data as List).map((e) => deserialize<String>(e)).toList()
|
? (data as List).map((e) => deserialize<String>(e)).toList()
|
||||||
: null) as T;
|
: null) as T;
|
||||||
}
|
}
|
||||||
if (t == List<_i6.Quote>) {
|
if (t == List<_i8.Quote>) {
|
||||||
return (data as List).map((e) => deserialize<_i6.Quote>(e)).toList() as T;
|
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;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
return _i3.Protocol().deserialize<T>(data, t);
|
return _i3.Protocol().deserialize<T>(data, t);
|
||||||
|
|
@ -172,6 +298,12 @@ class Protocol extends _i1.SerializationManagerServer {
|
||||||
if (data is _i5.Quote) {
|
if (data is _i5.Quote) {
|
||||||
return 'Quote';
|
return 'Quote';
|
||||||
}
|
}
|
||||||
|
if (data is _i6.Vote) {
|
||||||
|
return 'Vote';
|
||||||
|
}
|
||||||
|
if (data is _i7.VoteRequest) {
|
||||||
|
return 'VoteRequest';
|
||||||
|
}
|
||||||
className = _i2.Protocol().getClassNameForObject(data);
|
className = _i2.Protocol().getClassNameForObject(data);
|
||||||
if (className != null) {
|
if (className != null) {
|
||||||
return 'serverpod.$className';
|
return 'serverpod.$className';
|
||||||
|
|
@ -195,6 +327,12 @@ class Protocol extends _i1.SerializationManagerServer {
|
||||||
if (dataClassName == 'Quote') {
|
if (dataClassName == 'Quote') {
|
||||||
return deserialize<_i5.Quote>(data['data']);
|
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.')) {
|
if (dataClassName.startsWith('serverpod.')) {
|
||||||
data['className'] = dataClassName.substring(10);
|
data['className'] = dataClassName.substring(10);
|
||||||
return _i2.Protocol().deserializeByClassName(data);
|
return _i2.Protocol().deserializeByClassName(data);
|
||||||
|
|
@ -223,6 +361,10 @@ class Protocol extends _i1.SerializationManagerServer {
|
||||||
switch (t) {
|
switch (t) {
|
||||||
case _i5.Quote:
|
case _i5.Quote:
|
||||||
return _i5.Quote.t;
|
return _i5.Quote.t;
|
||||||
|
case _i6.Vote:
|
||||||
|
return _i6.Vote.t;
|
||||||
|
case _i7.VoteRequest:
|
||||||
|
return _i7.VoteRequest.t;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,3 +2,6 @@ quote:
|
||||||
- createQuote:
|
- createQuote:
|
||||||
- updateQuote:
|
- updateQuote:
|
||||||
- getAllQuotes:
|
- getAllQuotes:
|
||||||
|
votes:
|
||||||
|
- postVote:
|
||||||
|
- getAllVotes:
|
||||||
|
|
|
||||||
441
wien_talks/wien_talks_server/lib/src/generated/votes/vote.dart
Normal file
441
wien_talks/wien_talks_server/lib/src/generated/votes/vote.dart
Normal file
|
|
@ -0,0 +1,441 @@
|
||||||
|
/* 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,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,422 @@
|
||||||
|
/* 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:async';
|
||||||
|
import 'dart:math';
|
||||||
|
|
||||||
import 'package:serverpod/serverpod.dart';
|
import 'package:serverpod/serverpod.dart';
|
||||||
import 'package:wien_talks_server/src/generated/protocol.dart';
|
import 'package:wien_talks_server/src/generated/protocol.dart';
|
||||||
import 'package:wien_talks_server/src/quotes/quote_util.dart';
|
import 'package:wien_talks_server/src/quotes/quote_util.dart';
|
||||||
|
|
||||||
class ShowLatestNewsWidget extends Endpoint {
|
class QuoteEndpoint extends Endpoint {
|
||||||
static const _channelQuoteUpdates = 'quote-updates';
|
static const _channelQuoteUpdates = 'quote-updates';
|
||||||
|
|
||||||
Future<Quote> createQuote(Session session, CreateQuoteRequest req) async {
|
Future<Quote> createQuote(Session session, CreateQuoteRequest req) async {
|
||||||
|
|
@ -15,8 +15,7 @@ class ShowLatestNewsWidget extends Endpoint {
|
||||||
final text = validateQuote(req);
|
final text = validateQuote(req);
|
||||||
|
|
||||||
final toInsert = Quote(
|
final toInsert = Quote(
|
||||||
id: 0,
|
userId: userId ?? Random().nextInt(1200),
|
||||||
userId: userId ?? 12,
|
|
||||||
text: text,
|
text: text,
|
||||||
authorName: req.authorName,
|
authorName: req.authorName,
|
||||||
lat: req.lat,
|
lat: req.lat,
|
||||||
|
|
@ -37,8 +36,22 @@ class ShowLatestNewsWidget extends Endpoint {
|
||||||
await session.messages.postMessage(_channelQuoteUpdates, quote);
|
await session.messages.postMessage(_channelQuoteUpdates, quote);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<List<Quote>> getAllQuotes(Session session, {int limit = 200}) async {
|
Future<List<Quote>> getAllQuotes(
|
||||||
final quoteList = await Quote.db.find(session);
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
return quoteList;
|
return quoteList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
7
wien_talks/wien_talks_server/lib/src/votes/vote.spy.yaml
Normal file
7
wien_talks/wien_talks_server/lib/src/votes/vote.spy.yaml
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
class: Vote
|
||||||
|
table: vote
|
||||||
|
fields:
|
||||||
|
userId: int
|
||||||
|
createdAt: DateTime
|
||||||
|
quote: Quote
|
||||||
|
upvote: bool
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
class: VoteRequest
|
||||||
|
table: vote_request
|
||||||
|
fields:
|
||||||
|
userId: int
|
||||||
|
quote: Quote
|
||||||
|
upvote: bool
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
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
|
|
@ -0,0 +1,394 @@
|
||||||
|
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;
|
||||||
|
|
@ -0,0 +1,107 @@
|
||||||
|
{
|
||||||
|
"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
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"actions": [],
|
||||||
|
"warnings": [],
|
||||||
|
"migrationApiVersion": 1
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
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,3 +6,4 @@
|
||||||
|
|
||||||
20250816095813247
|
20250816095813247
|
||||||
20250816122625449
|
20250816122625449
|
||||||
|
20250816171653001
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,8 @@ 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/quote.dart' as _i4;
|
||||||
import 'package:wien_talks_server/src/generated/quotes/create_quote.dart'
|
import 'package:wien_talks_server/src/generated/quotes/create_quote.dart'
|
||||||
as _i5;
|
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/protocol.dart';
|
||||||
import 'package:wien_talks_server/src/generated/endpoints.dart';
|
import 'package:wien_talks_server/src/generated/endpoints.dart';
|
||||||
export 'package:serverpod_test/serverpod_test_public_exports.dart';
|
export 'package:serverpod_test/serverpod_test_public_exports.dart';
|
||||||
|
|
@ -103,7 +105,9 @@ void withServerpod(
|
||||||
}
|
}
|
||||||
|
|
||||||
class TestEndpoints {
|
class TestEndpoints {
|
||||||
late final _ShowLatestNewsWidget showLatestNewsWidget;
|
late final _QuoteEndpoint quote;
|
||||||
|
|
||||||
|
late final _VotesEndpoint votes;
|
||||||
}
|
}
|
||||||
|
|
||||||
class _InternalTestEndpoints extends TestEndpoints
|
class _InternalTestEndpoints extends TestEndpoints
|
||||||
|
|
@ -113,15 +117,19 @@ class _InternalTestEndpoints extends TestEndpoints
|
||||||
_i2.SerializationManager serializationManager,
|
_i2.SerializationManager serializationManager,
|
||||||
_i2.EndpointDispatch endpoints,
|
_i2.EndpointDispatch endpoints,
|
||||||
) {
|
) {
|
||||||
showLatestNewsWidget = _ShowLatestNewsWidget(
|
quote = _QuoteEndpoint(
|
||||||
|
endpoints,
|
||||||
|
serializationManager,
|
||||||
|
);
|
||||||
|
votes = _VotesEndpoint(
|
||||||
endpoints,
|
endpoints,
|
||||||
serializationManager,
|
serializationManager,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class _ShowLatestNewsWidget {
|
class _QuoteEndpoint {
|
||||||
_ShowLatestNewsWidget(
|
_QuoteEndpoint(
|
||||||
this._endpointDispatch,
|
this._endpointDispatch,
|
||||||
this._serializationManager,
|
this._serializationManager,
|
||||||
);
|
);
|
||||||
|
|
@ -137,13 +145,13 @@ class _ShowLatestNewsWidget {
|
||||||
return _i1.callAwaitableFunctionAndHandleExceptions(() async {
|
return _i1.callAwaitableFunctionAndHandleExceptions(() async {
|
||||||
var _localUniqueSession =
|
var _localUniqueSession =
|
||||||
(sessionBuilder as _i1.InternalTestSessionBuilder).internalBuild(
|
(sessionBuilder as _i1.InternalTestSessionBuilder).internalBuild(
|
||||||
endpoint: 'showLatestNewsWidget',
|
endpoint: 'quote',
|
||||||
method: 'createQuote',
|
method: 'createQuote',
|
||||||
);
|
);
|
||||||
try {
|
try {
|
||||||
var _localCallContext = await _endpointDispatch.getMethodCallContext(
|
var _localCallContext = await _endpointDispatch.getMethodCallContext(
|
||||||
createSessionCallback: (_) => _localUniqueSession,
|
createSessionCallback: (_) => _localUniqueSession,
|
||||||
endpointPath: 'showLatestNewsWidget',
|
endpointPath: 'quote',
|
||||||
methodName: 'createQuote',
|
methodName: 'createQuote',
|
||||||
parameters: _i1.testObjectToJson({'req': req}),
|
parameters: _i1.testObjectToJson({'req': req}),
|
||||||
serializationManager: _serializationManager,
|
serializationManager: _serializationManager,
|
||||||
|
|
@ -166,13 +174,13 @@ class _ShowLatestNewsWidget {
|
||||||
return _i1.callAwaitableFunctionAndHandleExceptions(() async {
|
return _i1.callAwaitableFunctionAndHandleExceptions(() async {
|
||||||
var _localUniqueSession =
|
var _localUniqueSession =
|
||||||
(sessionBuilder as _i1.InternalTestSessionBuilder).internalBuild(
|
(sessionBuilder as _i1.InternalTestSessionBuilder).internalBuild(
|
||||||
endpoint: 'showLatestNewsWidget',
|
endpoint: 'quote',
|
||||||
method: 'updateQuote',
|
method: 'updateQuote',
|
||||||
);
|
);
|
||||||
try {
|
try {
|
||||||
var _localCallContext = await _endpointDispatch.getMethodCallContext(
|
var _localCallContext = await _endpointDispatch.getMethodCallContext(
|
||||||
createSessionCallback: (_) => _localUniqueSession,
|
createSessionCallback: (_) => _localUniqueSession,
|
||||||
endpointPath: 'showLatestNewsWidget',
|
endpointPath: 'quote',
|
||||||
methodName: 'updateQuote',
|
methodName: 'updateQuote',
|
||||||
parameters: _i1.testObjectToJson({'quote': quote}),
|
parameters: _i1.testObjectToJson({'quote': quote}),
|
||||||
serializationManager: _serializationManager,
|
serializationManager: _serializationManager,
|
||||||
|
|
@ -189,21 +197,19 @@ class _ShowLatestNewsWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
_i3.Future<List<_i4.Quote>> getAllQuotes(
|
_i3.Future<List<_i4.Quote>> getAllQuotes(
|
||||||
_i1.TestSessionBuilder sessionBuilder, {
|
_i1.TestSessionBuilder sessionBuilder) async {
|
||||||
required int limit,
|
|
||||||
}) async {
|
|
||||||
return _i1.callAwaitableFunctionAndHandleExceptions(() async {
|
return _i1.callAwaitableFunctionAndHandleExceptions(() async {
|
||||||
var _localUniqueSession =
|
var _localUniqueSession =
|
||||||
(sessionBuilder as _i1.InternalTestSessionBuilder).internalBuild(
|
(sessionBuilder as _i1.InternalTestSessionBuilder).internalBuild(
|
||||||
endpoint: 'showLatestNewsWidget',
|
endpoint: 'quote',
|
||||||
method: 'getAllQuotes',
|
method: 'getAllQuotes',
|
||||||
);
|
);
|
||||||
try {
|
try {
|
||||||
var _localCallContext = await _endpointDispatch.getMethodCallContext(
|
var _localCallContext = await _endpointDispatch.getMethodCallContext(
|
||||||
createSessionCallback: (_) => _localUniqueSession,
|
createSessionCallback: (_) => _localUniqueSession,
|
||||||
endpointPath: 'showLatestNewsWidget',
|
endpointPath: 'quote',
|
||||||
methodName: 'getAllQuotes',
|
methodName: 'getAllQuotes',
|
||||||
parameters: _i1.testObjectToJson({'limit': limit}),
|
parameters: _i1.testObjectToJson({}),
|
||||||
serializationManager: _serializationManager,
|
serializationManager: _serializationManager,
|
||||||
);
|
);
|
||||||
var _localReturnValue = await (_localCallContext.method.call(
|
var _localReturnValue = await (_localCallContext.method.call(
|
||||||
|
|
@ -217,3 +223,70 @@ class _ShowLatestNewsWidget {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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