30 lines
611 B
Go
30 lines
611 B
Go
package response
|
|
|
|
import "enaklo-pos-be/internal/entity"
|
|
|
|
type CategoryResponse struct {
|
|
ID int64 `json:"id"`
|
|
Name string `json:"name"`
|
|
PartnerID int64 `json:"partner_id"`
|
|
}
|
|
|
|
func MapToCategoryResponse(cat *entity.Category) *CategoryResponse {
|
|
if cat == nil {
|
|
return nil
|
|
}
|
|
|
|
return &CategoryResponse{
|
|
ID: cat.ID,
|
|
Name: cat.Name,
|
|
PartnerID: cat.PartnerID,
|
|
}
|
|
}
|
|
|
|
func MapToCategoryListResponse(cats []*entity.Category) []*CategoryResponse {
|
|
result := make([]*CategoryResponse, len(cats))
|
|
for i, c := range cats {
|
|
result[i] = MapToCategoryResponse(c)
|
|
}
|
|
return result
|
|
}
|