74 lines
1.7 KiB
Dart
74 lines
1.7 KiB
Dart
// Author: fruit.com.cn
|
|
|
|
import 'json_numbers.dart';
|
|
|
|
/// 互动目标类型。
|
|
enum InteractionTargetType {
|
|
drama('DRAMA'),
|
|
episode('EPISODE'),
|
|
comment('COMMENT');
|
|
|
|
const InteractionTargetType(this.apiValue);
|
|
|
|
final String apiValue;
|
|
}
|
|
|
|
/// 客户端固定举报原因,后端当前未限制枚举值。
|
|
enum ReportReason {
|
|
spam('SPAM'),
|
|
abuse('ABUSE'),
|
|
porn('PORN'),
|
|
ad('AD'),
|
|
other('OTHER');
|
|
|
|
const ReportReason(this.apiValue);
|
|
|
|
final String apiValue;
|
|
}
|
|
|
|
/// 一次性互动请求,供仓库和测试断言使用。
|
|
class ReportRequest {
|
|
const ReportRequest({
|
|
required this.targetType,
|
|
required this.targetId,
|
|
required this.reasonCode,
|
|
this.description = '',
|
|
});
|
|
|
|
final InteractionTargetType targetType;
|
|
final String targetId;
|
|
final String reasonCode;
|
|
final String description;
|
|
}
|
|
|
|
/// 点赞切换后的服务端状态。
|
|
class LikeToggleResult {
|
|
const LikeToggleResult({required this.liked, required this.count});
|
|
|
|
final bool liked;
|
|
final int count;
|
|
|
|
/// 计数按 Long 字符串兼容解析。
|
|
factory LikeToggleResult.fromJson(Map<String, dynamic> json) =>
|
|
LikeToggleResult(
|
|
liked: json['liked'] == true,
|
|
count: jsonToInt(json['count']),
|
|
);
|
|
}
|
|
|
|
/// 控制器统一返回结果;失败消息可直接展示后端 `message`。
|
|
class OperationResult<T> {
|
|
const OperationResult._(this.data, this.errorMessage, this.errorCode);
|
|
|
|
const OperationResult.success([T? data]) : this._(data, null, null);
|
|
|
|
const OperationResult.failure(this.errorMessage, {this.errorCode})
|
|
: data = null;
|
|
|
|
final T? data;
|
|
final String? errorMessage;
|
|
final int? errorCode;
|
|
|
|
bool get isSuccess => errorMessage == null;
|
|
}
|