func toApiProduct(product *products.Product, brand *brands.Brand, author *users.User) *duoerlapi.Product { apiProduct := new(duoerlapi.Product) if product != nil { apiProduct = &duoerlapi.Product{ Id: product.Id.Hex(), Link: product.Link(), Name: product.Name, Alias: product.Alias, Intro: product.Intro, Image: product.ImageUrl(), Brand: toApiBrand(brand), Author: toApiUser(author), Category: GetCategory(product.CategoryId.Hex()), SubCategory: GetSubCategory(product.SubCategoryId.Hex()), Efficacies: GetEfficaciesByIds(utils.TurnObjectIdToPlainIds(product.EfficacyIds)), } } return apiProduct }