
Input/Output Models
Namespace:
ZhonTai.Admin.Core.Dto
Zhongtai Admin defines a unified API input/output convention. All API responses are wrapped in ResultOutput<T> format, and pagination uses PageInput / PageOutput.
Unified Response ResultOutput
Response Structure
json
{
"success": true,
"code": null,
"msg": null,
"data": {}
}| Field | Type | Description |
|---|---|---|
Success | bool | Whether successful |
Code | string | Business code |
Msg | string | Message |
Data | T | Data |
Usage in Services
csharp
// Success with data
return ResultOutput.Ok(entity);
// Success with message
return ResultOutput.Ok(entity, "Operation successful");
// Success without data
return ResultOutput.Ok();
// Failure
return ResultOutput.NotOk("Operation failed");
// Based on boolean
return ResultOutput.Result(rows > 0);
// Throw business exception
throw ResultOutput.Exception("User not found");
// With code and status
throw ResultOutput.Exception("Invalid parameter", "PARAM_ERROR", 400);Business Exception AppException
AppException is caught by the global exception filter and returned as ResultOutput format.
csharp
throw new AppException("User not found");
throw new AppException("Invalid parameter", "PARAM_ERROR");
throw new AppException("Invalid parameter", "PARAM_ERROR", 400);Pagination Input PageInput
| Property | Type | Description |
|---|---|---|
CurrentPage | int | Current page (default 1, min 1) |
PageSize | int | Page size (default 1, min 1) |
DynamicFilter | DynamicFilterInfo | Advanced filter conditions |
SortList | List<SortInput> | Sort conditions |
With Filter
csharp
public class ArticlePageInput : PageInput<ArticleFilterInput>
{
}
public class ArticleFilterInput
{
public string Title { get; set; }
public int? Status { get; set; }
}
// In Service
public async Task<PageOutput<ArticleListOutput>> GetPageAsync(ArticlePageInput input)
{
return await _repository.Select
.WhereIf(input.Filter.Title.NotNull(), a => a.Title.Contains(input.Filter.Title))
.OrderByDescending(a => a.Id)
.ToPageOutputAsync(input);
}Without Filter
csharp
public class MyQueryInput : PageInput
{
public string Keyword { get; set; }
}Pagination Output PageOutput
csharp
public class PageOutput<T>
{
public long Total { get; set; } // Total records
public IList<T> List { get; set; } // Data list
}Query Base Class QueryInput
Base class for non-paginated queries.
csharp
public abstract class QueryInput
{
public DynamicFilterInfo DynamicFilter { get; set; }
public List<SortInput> SortList { get; set; }
}Sort Input SortInput
csharp
public class SortInput
{
public string PropName { get; set; } // Property name
public SortOrder? Order { get; set; } // Asc / Desc
}Import/Export
ExportInput
csharp
public class ExportInput
{
public string FileName { get; set; }
}
public class ExportInput<T> : ExportInput
{
public T Filter { get; set; }
}ImportOutput
csharp
public class ImportOutput
{
public long Total { get; set; }
public long InsertCount { get; set; }
public long UpdateCount { get; set; }
}Status Code Enum
| Enum Value | Value | Description |
|---|---|---|
Status0NotOk | 0 | Operation failed |
Status1Ok | 1 | Operation successful |
Status401Unauthorized | 401 | Unauthorized |
Status403Forbidden | 403 | Forbidden |
Status404NotFound | 404 | Not found |
Status500InternalServerError | 500 | Server error |