Solian/lib/models/channel.dart

88 lines
1.8 KiB
Dart
Raw Normal View History

2024-09-16 18:14:23 +00:00
import 'package:json_annotation/json_annotation.dart';
2024-05-18 10:17:16 +00:00
import 'package:solian/models/account.dart';
2024-05-25 17:21:08 +00:00
import 'package:solian/models/realm.dart';
2024-05-18 10:17:16 +00:00
part 'channel.g.dart';
@JsonSerializable()
2024-05-18 10:17:16 +00:00
class Channel {
int id;
DateTime createdAt;
DateTime updatedAt;
DateTime? deletedAt;
String alias;
String name;
String description;
int type;
2024-05-28 16:14:41 +00:00
List<ChannelMember>? members;
2024-05-18 10:17:16 +00:00
Account account;
int accountId;
2024-05-25 17:21:08 +00:00
Realm? realm;
2024-05-18 10:17:16 +00:00
int? realmId;
bool isPublic;
bool isCommunity;
2024-05-18 10:17:16 +00:00
@JsonKey(includeFromJson: false, includeToJson: true)
2024-05-18 10:17:16 +00:00
bool isAvailable = false;
Channel({
required this.id,
required this.createdAt,
required this.updatedAt,
2024-05-28 16:14:41 +00:00
required this.deletedAt,
2024-05-18 10:17:16 +00:00
required this.alias,
required this.name,
required this.description,
required this.type,
2024-05-28 16:14:41 +00:00
required this.members,
2024-05-18 10:17:16 +00:00
required this.account,
required this.accountId,
required this.isPublic,
required this.isCommunity,
2024-05-28 16:14:41 +00:00
required this.realm,
required this.realmId,
2024-05-18 10:17:16 +00:00
});
factory Channel.fromJson(Map<String, dynamic> json) =>
_$ChannelFromJson(json);
2024-05-18 10:17:16 +00:00
Map<String, dynamic> toJson() => _$ChannelToJson(this);
@override
bool operator ==(Object other) {
if (other is! Channel) return false;
return id == other.id;
}
@override
int get hashCode => id;
2024-05-18 10:17:16 +00:00
}
@JsonSerializable()
2024-05-18 10:17:16 +00:00
class ChannelMember {
int id;
DateTime createdAt;
DateTime updatedAt;
DateTime? deletedAt;
int channelId;
int accountId;
Account account;
int notify;
ChannelMember({
required this.id,
required this.createdAt,
required this.updatedAt,
this.deletedAt,
required this.channelId,
required this.accountId,
required this.account,
required this.notify,
});
factory ChannelMember.fromJson(Map<String, dynamic> json) =>
_$ChannelMemberFromJson(json);
2024-05-18 10:17:16 +00:00
Map<String, dynamic> toJson() => _$ChannelMemberToJson(this);
2024-05-18 10:17:16 +00:00
}