package brand

import (
	brandentity "haixun-backend/internal/model/brand/domain/entity"
	domusecase "haixun-backend/internal/model/brand/domain/usecase"
	"haixun-backend/internal/types"
)

func toBrandData(item domusecase.BrandSummary) types.BrandData {
	return types.BrandData{
		ID:             item.ID,
		DisplayName:    item.DisplayName,
		SeedQuery:      item.SeedQuery,
		Brief:          item.Brief,
		ProductBrief:   item.ProductBrief,
		ProductContext: item.ProductContext,
		TargetAudience: item.TargetAudience,
		Goals:          item.Goals,
		ResearchMap:    toResearchMapData(item.ResearchMap),
		CreateAt:       item.CreateAt,
		UpdateAt:       item.UpdateAt,
	}
}

func toResearchMapData(item brandentity.ResearchMap) types.ResearchMapData {
	return types.ResearchMapData{
		AudienceSummary: item.AudienceSummary,
		ContentGoal:     item.ContentGoal,
		Questions:       item.Questions,
		Pillars:         item.Pillars,
		Exclusions:      item.Exclusions,
	}
}

func toListData(result *domusecase.ListResult) *types.ListBrandsData {
	if result == nil {
		return &types.ListBrandsData{List: []types.BrandData{}}
	}
	list := make([]types.BrandData, 0, len(result.List))
	for _, item := range result.List {
		list = append(list, toBrandData(item))
	}
	return &types.ListBrandsData{List: list}
}

func toBrandPatch(req *types.UpdateBrandReq) domusecase.BrandPatch {
	if req == nil {
		return domusecase.BrandPatch{}
	}
	return domusecase.BrandPatch{
		DisplayName:    req.DisplayName,
		SeedQuery:      req.SeedQuery,
		Brief:          req.Brief,
		ProductBrief:   req.ProductBrief,
		ProductContext: req.ProductContext,
		TargetAudience: req.TargetAudience,
		Goals:          req.Goals,
	}
}
