import 'package:drift/drift.dart'; import 'package:im_app/data/local/drift/app_database.dart'; import 'package:im_app/domain/entities/workspace.dart'; /// 工作空间 DTO class WorkspaceDto { final int id; final String? name; final int? ownerId; final String? description; final String? logo; final int? grade; final int? cap; final String? currency; final int? status; final int? createdAt; final int? updatedAt; final int? deletedAt; final int? channelGroupId; const WorkspaceDto({ required this.id, this.name, this.ownerId, this.description, this.logo, this.grade, this.cap, this.currency, this.status, this.createdAt, this.updatedAt, this.deletedAt, this.channelGroupId, }); factory WorkspaceDto.fromJson(Map json) => WorkspaceDto( id: json['id'] as int, name: json['name'], ownerId: json['owner_id'], description: json['description'], logo: json['logo'], grade: json['grade'], cap: json['cap'], currency: json['currency'], status: json['status'], createdAt: json['created_at'], updatedAt: json['updated_at'], deletedAt: json['deleted_at'], channelGroupId: json['channel_group_id'], ); Map toJson() => { 'id': id, 'name': name, 'owner_id': ownerId, 'description': description, 'logo': logo, 'grade': grade, 'cap': cap, 'currency': currency, 'status': status, 'created_at': createdAt, 'updated_at': updatedAt, 'deleted_at': deletedAt, 'channel_group_id': channelGroupId, }; Workspace toEntity() => Workspace( id: id, name: name, ownerId: ownerId, description: description, logo: logo, grade: grade, cap: cap, currency: currency, status: status, createdAt: createdAt, updatedAt: updatedAt, deletedAt: deletedAt, channelGroupId: channelGroupId, ); factory WorkspaceDto.fromEntity(Workspace workspace) => WorkspaceDto( id: workspace.id, name: workspace.name, ownerId: workspace.ownerId, description: workspace.description, logo: workspace.logo, grade: workspace.grade, cap: workspace.cap, currency: workspace.currency, status: workspace.status, createdAt: workspace.createdAt, updatedAt: workspace.updatedAt, deletedAt: workspace.deletedAt, channelGroupId: workspace.channelGroupId, ); WorkspacesCompanion toCompanion() => WorkspacesCompanion( id: Value(id), name: Value(name), ownerId: Value(ownerId), description: Value(description), logo: Value(logo), grade: Value(grade), cap: Value(cap), currency: Value(currency), status: Value(status), createdAt: Value(createdAt), updatedAt: Value(updatedAt), deletedAt: Value(deletedAt), channelGroupId: Value(channelGroupId), ); }