From 4f0a4b9bf9c322182fb3366c0d64ea4f8776dddb Mon Sep 17 00:00:00 2001 From: SEAN Date: Mon, 9 Feb 2026 13:57:37 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20ApiResponse=20=EA=B3=B5=ED=86=B5=20?= =?UTF-8?q?=EC=9D=91=EB=8B=B5=20=ED=8F=AC=EB=A7=B7=20=EA=B5=AC=ED=98=84=20?= =?UTF-8?q?(#14)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SPMS.Domain/Common/ApiResponse.cs | 33 +++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 SPMS.Domain/Common/ApiResponse.cs diff --git a/SPMS.Domain/Common/ApiResponse.cs b/SPMS.Domain/Common/ApiResponse.cs new file mode 100644 index 0000000..35d38c4 --- /dev/null +++ b/SPMS.Domain/Common/ApiResponse.cs @@ -0,0 +1,33 @@ +using System.Text.Json.Serialization; + +namespace SPMS.Domain.Common; + +public class ApiResponse +{ + [JsonPropertyName("result")] + public bool Result { get; init; } + + [JsonPropertyName("code")] + public string Code { get; init; } = ErrorCodes.Success; + + [JsonPropertyName("msg")] + public string Msg { get; init; } = string.Empty; + + public static ApiResponse Success() + => new() { Result = true, Code = ErrorCodes.Success }; + + public static ApiResponse Fail(string code, string msg) + => new() { Result = false, Code = code, Msg = msg }; +} + +public class ApiResponse : ApiResponse +{ + [JsonPropertyName("data")] + public T? Data { get; init; } + + public static ApiResponse Success(T data) + => new() { Result = true, Code = ErrorCodes.Success, Data = data }; + + public new static ApiResponse Fail(string code, string msg) + => new() { Result = false, Code = code, Msg = msg }; +}