using ERPCore.Common.Http;
using ERPCore.Domain.Enums;
using ERPCore.Dtos.Categories;
using ERPCore.Dtos.Common;

namespace ERPCore.Services.Interfaces;

/// <summary>
/// Category + subcategory master business logic (docs/11-BACKEND-PHASE1.md §2.3).
/// The hierarchy is exactly two levels deep; there is no tree endpoint any more.
/// </summary>
public interface ICategoryService
{
    Task<PagedResponse<CategoryDto>> ListAsync(PageQuery query, EntityStatus? status, CancellationToken ct = default);
    Task<ETagged<CategoryDto>?> GetAsync(int categoryId, CancellationToken ct = default);
    Task<ETagged<CategoryDto>> CreateAsync(CreateCategoryRequest request, CancellationToken ct = default);
    Task<ETagged<CategoryDto>> UpdateAsync(int categoryId, UpdateCategoryRequest request, uint expectedRowVersion, CancellationToken ct = default);
    Task SetStatusAsync(int categoryId, EntityStatus status, CancellationToken ct = default);

    /// <summary>Subcategories of one category. 404s when the category itself does not exist.</summary>
    Task<PagedResponse<SubCategoryDto>> ListSubCategoriesAsync(
        int categoryId, PageQuery query, EntityStatus? status, CancellationToken ct = default);

    Task<ETagged<SubCategoryDto>?> GetSubCategoryAsync(int subCategoryId, CancellationToken ct = default);
    Task<ETagged<SubCategoryDto>> CreateSubCategoryAsync(int categoryId, CreateSubCategoryRequest request, CancellationToken ct = default);
    Task<ETagged<SubCategoryDto>> UpdateSubCategoryAsync(int subCategoryId, UpdateSubCategoryRequest request, uint expectedRowVersion, CancellationToken ct = default);
    Task SetSubCategoryStatusAsync(int subCategoryId, EntityStatus status, CancellationToken ct = default);
}
