Contracts.cs 2.37 KB
using System.Text.Json.Serialization;

namespace RobotProductionSystem.Api.Contracts;

public sealed record AvatarDto(string? Src, string? Alt = null);
public sealed record AuthUserDto(int Id, string Username, string Name, string Email, string[] Roles, string Station, AvatarDto? Avatar);
public sealed record LoginRequest(string? Username, string? Password);
public sealed record LoginResponse(bool Success, string State, string NextAction, string? ErrorCode, string Message, string? Token = null, string? ExpiresAt = null, AuthUserDto? User = null);
public sealed record MeResponse(bool Success, string State, string NextAction, string? ErrorCode, string Message, AuthUserDto? User = null, string? ExpiresAt = null);

public sealed record MutationResponse(bool Success, string? ErrorCode, string Message);

public sealed record DeviceTypePayload(string? Name, string? Model, string? Category, int LengthMm, int WidthMm, int HeightMm, decimal WeightKg, bool HasBattery, string? BatterySpec, string? Description);
public sealed record WorkOrderPayload(string? OrderNo, string? DeviceCode, string? BatchNo, string? Line, string? OwnerUsername, string? PlannedDate, int TotalSn, string? Operator);
public sealed record TransitionPayload(string? Operator, string? Remark);

public sealed record SnImportPayload(string? WorkOrderNo, string? CurrentStep, string[]? SnList, string? Operator);
public sealed record SnActionPayload(string? Operator, string? Reason);

public sealed record OperationActionPayload(string? Operator, string? Remark, bool? TestPassed, string? Workstation, string? StepName);

public sealed record SettingsProfileDto(string Name, string Email, string Username, string? Avatar, string? Bio);
public sealed record SettingsProfilePayload(string? Name, string? Email, string? Username, string? Avatar, string? Bio);

public sealed class SettingsNotificationsDto
{
    public bool Email { get; set; }
    public bool Desktop { get; set; }
    [JsonPropertyName("product_updates")]
    public bool ProductUpdates { get; set; }
    [JsonPropertyName("weekly_digest")]
    public bool WeeklyDigest { get; set; }
    [JsonPropertyName("important_updates")]
    public bool ImportantUpdates { get; set; }
}

public sealed record PasswordPayload(string? CurrentPassword, string? NewPassword);
public sealed record MemberPayload(string? Name, string? Email, string? Username, string? Role, string? Avatar, string? Bio);