- Replace dart:js with package:js in health_check_service_web.dart\n- Implement showHealthCheckNotification in web/index.html\n- Pin js dependency to ^0.6.7 for flutter_secure_storage_web compatibility auth: harden AuthInterceptor + tests - Allow overrideAuthRepository injection for testing\n- Normalize imports to package: paths\n- Add unit test covering token attach, 401→refresh→retry, and failure path\n- Add integration test skeleton gated by env vars ui/data: map User.companyName to list column - Add companyName to domain User\n- Map UserDto.company?.name\n- Render companyName in user_list cleanup: remove legacy equipment table + unused code; minor warnings - Remove _buildFlexibleTable and unused helpers\n- Remove unused zipcode details and cache retry constant\n- Fix null-aware and non-null assertions\n- Address child-last warnings in administrator dialog docs: update AGENTS.md session context
124 lines
3.5 KiB
Dart
124 lines
3.5 KiB
Dart
import 'package:freezed_annotation/freezed_annotation.dart';
|
|
import 'package:superport/data/models/company/company_dto.dart';
|
|
import 'package:superport/models/user_model.dart';
|
|
|
|
part 'user_dto.freezed.dart';
|
|
part 'user_dto.g.dart';
|
|
|
|
@freezed
|
|
class UserDto with _$UserDto {
|
|
const UserDto._(); // Private constructor for getters
|
|
|
|
const factory UserDto({
|
|
int? id,
|
|
required String name,
|
|
String? phone,
|
|
String? email,
|
|
@JsonKey(name: 'companies_id') required int companiesId,
|
|
|
|
// Nested data (optional, populated in GET requests)
|
|
@JsonKey(name: 'company') CompanyNameDto? company,
|
|
}) = _UserDto;
|
|
|
|
factory UserDto.fromJson(Map<String, dynamic> json) => _$UserDtoFromJson(json);
|
|
|
|
// 도메인 모델로 변환
|
|
User toDomainModel() {
|
|
return User(
|
|
id: id,
|
|
name: name,
|
|
email: email,
|
|
phone: phone,
|
|
companyName: company?.name,
|
|
);
|
|
}
|
|
}
|
|
|
|
@freezed
|
|
class UserRequestDto with _$UserRequestDto {
|
|
const factory UserRequestDto({
|
|
required String name,
|
|
String? phone,
|
|
String? email,
|
|
@JsonKey(name: 'companies_id') required int companiesId,
|
|
}) = _UserRequestDto;
|
|
|
|
factory UserRequestDto.fromJson(Map<String, dynamic> json) =>
|
|
_$UserRequestDtoFromJson(json);
|
|
}
|
|
|
|
@freezed
|
|
class UserUpdateRequestDto with _$UserUpdateRequestDto {
|
|
const factory UserUpdateRequestDto({
|
|
String? name,
|
|
String? phone,
|
|
String? email,
|
|
@JsonKey(name: 'companies_id') int? companiesId,
|
|
}) = _UserUpdateRequestDto;
|
|
|
|
factory UserUpdateRequestDto.fromJson(Map<String, dynamic> json) =>
|
|
_$UserUpdateRequestDtoFromJson(json);
|
|
|
|
// 도메인 모델에서 생성
|
|
factory UserUpdateRequestDto.fromDomain(User user, {String? newPassword}) {
|
|
return UserUpdateRequestDto(
|
|
name: user.name,
|
|
phone: user.phone,
|
|
email: user.email,
|
|
companiesId: null, // companiesId는 업데이트에서 처리하지 않음
|
|
);
|
|
}
|
|
}
|
|
|
|
@freezed
|
|
class UserListResponse with _$UserListResponse {
|
|
const factory UserListResponse({
|
|
@JsonKey(name: 'data') required List<UserDto> items,
|
|
@JsonKey(name: 'total') required int totalCount,
|
|
@JsonKey(name: 'page') required int currentPage,
|
|
@JsonKey(name: 'total_pages') required int totalPages,
|
|
@JsonKey(name: 'page_size') int? pageSize,
|
|
}) = _UserListResponse;
|
|
|
|
factory UserListResponse.fromJson(Map<String, dynamic> json) =>
|
|
_$UserListResponseFromJson(json);
|
|
}
|
|
|
|
// UserListDto (legacy support)
|
|
@freezed
|
|
class UserListDto with _$UserListDto {
|
|
const UserListDto._(); // Private constructor for methods
|
|
|
|
const factory UserListDto({
|
|
@JsonKey(name: 'users') required List<UserDto> users,
|
|
@JsonKey(name: 'total') required int total,
|
|
@JsonKey(name: 'page') required int page,
|
|
@JsonKey(name: 'per_page') required int perPage,
|
|
@JsonKey(name: 'total_pages') required int totalPages,
|
|
}) = _UserListDto;
|
|
|
|
factory UserListDto.fromJson(Map<String, dynamic> json) =>
|
|
_$UserListDtoFromJson(json);
|
|
|
|
// 도메인 모델 리스트로 변환
|
|
List<User> toDomainModels() {
|
|
return users.map((dto) => dto.toDomainModel()).toList();
|
|
}
|
|
|
|
// 페이지네이션 정보 접근을 위한 getter들
|
|
int get first => page;
|
|
int get last => totalPages;
|
|
}
|
|
|
|
// CheckUsernameResponse (legacy support)
|
|
@freezed
|
|
class CheckUsernameResponse with _$CheckUsernameResponse {
|
|
const factory CheckUsernameResponse({
|
|
@JsonKey(name: 'available') required bool available,
|
|
String? message,
|
|
}) = _CheckUsernameResponse;
|
|
|
|
factory CheckUsernameResponse.fromJson(Map<String, dynamic> json) =>
|
|
_$CheckUsernameResponseFromJson(json);
|
|
}
|