2026-06-24 10:02:42 +00:00
|
|
|
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 {
|
2026-06-24 16:48:56 +00:00
|
|
|
products := make([]types.BrandProductData, 0, len(item.Products))
|
|
|
|
|
for _, product := range item.Products {
|
|
|
|
|
products = append(products, toBrandProductData(product))
|
|
|
|
|
}
|
2026-06-24 10:02:42 +00:00
|
|
|
return types.BrandData{
|
|
|
|
|
ID: item.ID,
|
|
|
|
|
DisplayName: item.DisplayName,
|
2026-06-24 16:48:56 +00:00
|
|
|
TopicName: item.TopicName,
|
2026-06-24 10:02:42 +00:00
|
|
|
SeedQuery: item.SeedQuery,
|
|
|
|
|
Brief: item.Brief,
|
|
|
|
|
ProductBrief: item.ProductBrief,
|
|
|
|
|
ProductContext: item.ProductContext,
|
2026-06-24 16:48:56 +00:00
|
|
|
ProductID: item.ProductID,
|
|
|
|
|
Products: products,
|
2026-06-24 10:02:42 +00:00
|
|
|
TargetAudience: item.TargetAudience,
|
|
|
|
|
Goals: item.Goals,
|
|
|
|
|
ResearchMap: toResearchMapData(item.ResearchMap),
|
|
|
|
|
CreateAt: item.CreateAt,
|
|
|
|
|
UpdateAt: item.UpdateAt,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-24 16:48:56 +00:00
|
|
|
func toBrandProductData(item domusecase.ProductSummary) types.BrandProductData {
|
|
|
|
|
return types.BrandProductData{
|
|
|
|
|
ID: item.ID,
|
|
|
|
|
Label: item.Label,
|
|
|
|
|
ProductContext: item.ProductContext,
|
|
|
|
|
MatchTags: append([]string(nil), item.MatchTags...),
|
|
|
|
|
CreateAt: item.CreateAt,
|
|
|
|
|
UpdateAt: item.UpdateAt,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func toListBrandProductsData(result *domusecase.ListProductsResult) *types.ListBrandProductsData {
|
|
|
|
|
if result == nil {
|
|
|
|
|
return &types.ListBrandProductsData{List: []types.BrandProductData{}}
|
|
|
|
|
}
|
|
|
|
|
list := make([]types.BrandProductData, 0, len(result.List))
|
|
|
|
|
for _, item := range result.List {
|
|
|
|
|
list = append(list, toBrandProductData(item))
|
|
|
|
|
}
|
|
|
|
|
return &types.ListBrandProductsData{List: list}
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-24 10:02:42 +00:00
|
|
|
func toResearchMapData(item brandentity.ResearchMap) types.ResearchMapData {
|
2026-06-24 16:48:56 +00:00
|
|
|
items := make([]types.ResearchItemData, 0, len(item.ResearchItems))
|
|
|
|
|
for _, researchItem := range item.ResearchItems {
|
|
|
|
|
items = append(items, types.ResearchItemData{
|
|
|
|
|
Title: researchItem.Title,
|
|
|
|
|
URL: researchItem.URL,
|
|
|
|
|
Snippet: researchItem.Snippet,
|
|
|
|
|
Query: researchItem.Query,
|
|
|
|
|
})
|
|
|
|
|
}
|
2026-06-24 10:02:42 +00:00
|
|
|
return types.ResearchMapData{
|
|
|
|
|
AudienceSummary: item.AudienceSummary,
|
|
|
|
|
ContentGoal: item.ContentGoal,
|
|
|
|
|
Questions: item.Questions,
|
|
|
|
|
Pillars: item.Pillars,
|
|
|
|
|
Exclusions: item.Exclusions,
|
2026-06-24 16:48:56 +00:00
|
|
|
ResearchItems: items,
|
|
|
|
|
ExpandStrategy: item.ExpandStrategy,
|
|
|
|
|
PatrolKeywords: append([]string(nil), item.PatrolKeywords...),
|
2026-06-24 10:02:42 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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{}
|
|
|
|
|
}
|
2026-06-24 16:48:56 +00:00
|
|
|
patch := domusecase.BrandPatch{
|
2026-06-24 10:02:42 +00:00
|
|
|
DisplayName: req.DisplayName,
|
2026-06-24 16:48:56 +00:00
|
|
|
TopicName: req.TopicName,
|
2026-06-24 10:02:42 +00:00
|
|
|
SeedQuery: req.SeedQuery,
|
|
|
|
|
Brief: req.Brief,
|
|
|
|
|
ProductBrief: req.ProductBrief,
|
|
|
|
|
ProductContext: req.ProductContext,
|
2026-06-24 16:48:56 +00:00
|
|
|
ProductID: req.ProductID,
|
2026-06-24 10:02:42 +00:00
|
|
|
TargetAudience: req.TargetAudience,
|
|
|
|
|
Goals: req.Goals,
|
|
|
|
|
}
|
2026-06-24 16:48:56 +00:00
|
|
|
if req.AudienceSummary != nil {
|
|
|
|
|
patch.AudienceSummary = req.AudienceSummary
|
|
|
|
|
}
|
|
|
|
|
if req.ContentGoal != nil {
|
|
|
|
|
patch.ContentGoal = req.ContentGoal
|
|
|
|
|
}
|
|
|
|
|
if req.Questions != nil {
|
|
|
|
|
patch.QuestionsSet = true
|
|
|
|
|
patch.Questions = append([]string(nil), req.Questions...)
|
|
|
|
|
}
|
|
|
|
|
if req.Pillars != nil {
|
|
|
|
|
patch.PillarsSet = true
|
|
|
|
|
patch.Pillars = append([]string(nil), req.Pillars...)
|
|
|
|
|
}
|
|
|
|
|
if req.Exclusions != nil {
|
|
|
|
|
patch.ExclusionsSet = true
|
|
|
|
|
patch.Exclusions = append([]string(nil), req.Exclusions...)
|
|
|
|
|
}
|
|
|
|
|
if req.PatrolKeywords != nil {
|
|
|
|
|
patch.PatrolKeywordsSet = true
|
|
|
|
|
patch.PatrolKeywords = append([]string(nil), req.PatrolKeywords...)
|
|
|
|
|
}
|
|
|
|
|
return patch
|
2026-06-24 10:02:42 +00:00
|
|
|
}
|