This commit is contained in:
zhutao
2025-08-22 14:15:02 +08:00
parent 5853bdf004
commit 99a1ce601e
120 changed files with 5297 additions and 101 deletions

View File

@@ -0,0 +1,33 @@
class ArticleDetailDto {
int? id;
String? title;
String? subtitle;
String? content;
int? status;
String? createdAt;
String? updatedAt;
ArticleDetailDto({this.id, this.title, this.subtitle, this.content, this.status, this.createdAt, this.updatedAt});
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map["id"] = id;
map["title"] = title;
map["subtitle"] = subtitle;
map["content"] = content;
map["status"] = status;
map["created_at"] = createdAt;
map["updated_at"] = updatedAt;
return map;
}
ArticleDetailDto.fromJson(dynamic json){
id = json["id"] ?? 0;
title = json["title"] ?? "";
subtitle = json["subtitle"] ?? "";
content = json["content"] ?? "";
status = json["status"] ?? 0;
createdAt = json["created_at"] ?? "";
updatedAt = json["updated_at"] ?? "";
}
}

View File

@@ -0,0 +1,25 @@
class ArticleDto {
int? id;
String? title;
String? subtitle;
ArticleDto({
this.id,
this.title,
this.subtitle,
});
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map["id"] = id;
map["title"] = title;
map["subtitle"] = subtitle;
return map;
}
ArticleDto.fromJson(dynamic json) {
id = json["id"] ?? 0;
title = json["title"] ?? "";
subtitle = json["subtitle"] ?? "";
}
}

15
lib/api/dto/base_dto.dart Normal file
View File

@@ -0,0 +1,15 @@
class ApiDto<T> {
final int code;
final String message;
final T data;
ApiDto({required this.code, required this.message, required this.data});
factory ApiDto.fromJson(Map<String, dynamic> json) {
return ApiDto<T>(
code: json['code'],
message: json['message'],
data: json['data'],
);
}
}

View File

@@ -0,0 +1,86 @@
class UserInfo {
int? id;
String? name;
dynamic avatar;
String? email;
dynamic emailVerifiedAt;
dynamic googleId;
dynamic appleId;
String? lastLoginIp;
String? lastLoginTime;
dynamic lastUsedTime;
int? status;
String? createdAt;
String? updatedAt;
UserInfo({
this.id,
this.name,
this.avatar,
this.email,
this.emailVerifiedAt,
this.googleId,
this.appleId,
this.lastLoginIp,
this.lastLoginTime,
this.lastUsedTime,
this.status,
this.createdAt,
this.updatedAt,
});
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map["id"] = id;
map["name"] = name;
map["avatar"] = avatar;
map["email"] = email;
map["email_verified_at"] = emailVerifiedAt;
map["google_id"] = googleId;
map["apple_id"] = appleId;
map["last_login_ip"] = lastLoginIp;
map["last_login_time"] = lastLoginTime;
map["last_used_time"] = lastUsedTime;
map["status"] = status;
map["created_at"] = createdAt;
map["updated_at"] = updatedAt;
return map;
}
UserInfo.fromJson(dynamic json) {
id = json["id"] ?? 0;
name = json["name"] ?? "";
avatar = json["avatar"];
email = json["email"] ?? "";
emailVerifiedAt = json["email_verified_at"];
googleId = json["google_id"];
appleId = json["apple_id"];
lastLoginIp = json["last_login_ip"] ?? "";
lastLoginTime = json["last_login_time"] ?? "";
lastUsedTime = json["last_used_time"];
status = json["status"] ?? 0;
createdAt = json["created_at"] ?? "";
updatedAt = json["updated_at"] ?? "";
}
}
class LoginDto {
String? accessToken;
UserInfo? userInfo;
LoginDto({this.accessToken, this.userInfo});
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map["accessToken"] = accessToken;
if (userInfo != null) {
map["userInfo"] = userInfo?.toJson();
}
return map;
}
LoginDto.fromJson(dynamic json) {
accessToken = json["accessToken"] ?? "";
userInfo = json["userInfo"] != null ? UserInfo.fromJson(json["userInfo"]) : null;
}
}

View File

@@ -0,0 +1,66 @@
import 'package:derma_flutter/api/dto/skin_check_dto.dart';
class RecordItemDto {
num? id;
num? userId;
String? imageUrl;
num? imageType;
num? skinStatus;
String? createdAt;
SkinCheckDto? result;
RecordItemDto({
this.id,
this.userId,
this.imageUrl,
this.imageType,
this.skinStatus,
this.createdAt,
this.result,
});
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map["id"] = id;
map["user_id"] = userId;
map["image_url"] = imageUrl;
map["image_type"] = imageType;
map["skin_status"] = skinStatus;
map["created_at"] = createdAt;
map["result"] = result?.toJson();
return map;
}
RecordItemDto.fromJson(dynamic json) {
id = json["id"] ?? 0;
userId = json["user_id"] ?? 0;
imageUrl = json["image_url"] ?? "";
imageType = json["image_type"] ?? 0;
skinStatus = json["skin_status"] ?? 0;
createdAt = json["created_at"] ?? "";
result = json["result"] != null ? SkinCheckDto.fromJson(json["result"]) : null;
}
}
class RecordListDto {
num? total;
List<RecordItemDto>? list;
RecordListDto({this.total, this.list});
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map["total"] = total;
if (list != null) {
map["list"] = list?.map((v) => v.toJson()).toList();
}
return map;
}
factory RecordListDto.fromJson(dynamic json) {
return RecordListDto(
total: json["total"] ?? 0,
list: (json["list"] as List<dynamic>? ?? []).map((v) => RecordItemDto.fromJson(v)).toList(),
);
}
}

View File

@@ -0,0 +1,39 @@
import '../../data/models/skin_check_status.dart';
class SkinCheckDto {
int? id;
int? score;
String? rating;
String? concise;
late List<String> tags;
late SkinCheckStatus skinStatus;
SkinCheckDto({
this.id,
this.skinStatus = SkinCheckStatus.unknown,
this.score,
this.rating,
this.concise,
this.tags = const [],
});
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map["id"] = id;
map["score"] = score;
map["rating"] = rating;
map["concise"] = concise;
map["tags"] = tags;
map["skin_status"] = skinStatus.value;
return map;
}
SkinCheckDto.fromJson(dynamic json) {
id = json["id"];
skinStatus = SkinCheckStatus.fromValue(json["skin_status"] ?? 0);
score = json["score"];
rating = json["rating"];
concise = json["concise"];
tags = (json["tags"] as List?)?.map((e) => e.toString()).toList() ?? [];
}
}