first commit

This commit is contained in:
yanpeng200212
2026-10-08 10:43:59 +08:00
commit 8430ba0452
288 changed files with 29595 additions and 0 deletions
@@ -0,0 +1,24 @@
namespace F9WebAiTest.Application.Common;
/// <summary>统一 API 响应</summary>
public class ApiResult<T>
{
public int Code { get; set; }
public string Message { get; set; }
public T Data { get; set; }
public static ApiResult<T> Ok(T data, string message = "success")
=> new() { Code = 200, Message = message, Data = data };
public static ApiResult<T> Fail(string message, int code = 400)
=> new() { Code = code, Message = message, Data = default };
}
/// <summary>分页结果</summary>
public class PageResult<T>
{
public List<T> Items { get; set; } = new();
public long Total { get; set; }
public int PageIndex { get; set; }
public int PageSize { get; set; }
}
@@ -0,0 +1,12 @@
namespace F9WebAiTest.Application.Common.Exceptions;
/// <summary>资源不存在异常</summary>
public class F9NotFoundException : Exception
{
public F9NotFoundException(string resourceName, object key)
: base($"{resourceName}不存在'{key}'。")
{
}
public F9NotFoundException(string message) : base(message) { }
}
@@ -0,0 +1,15 @@
namespace F9WebAiTest.Application.Common.Exceptions;
/// <summary>操作失败异常</summary>
public class F9OperationException : Exception
{
/// <summary>操作失败</summary>
/// <param name="resourceName">资源名称</param>
/// <param name="oporation">操作名称</param>
public F9OperationException(string resourceName, string oporation)
: base($"{resourceName}{oporation}失败。")
{
}
public F9OperationException(string message) : base(message) { }
}
@@ -0,0 +1,12 @@
namespace F9WebAiTest.Application.Common;
/// <summary>业务异常</summary>
public class ServiceException : Exception
{
public int Code { get; set; } = 400;
public ServiceException(string message, int code = 400) : base(message)
{
Code = code;
}
}