refact: recator response

This commit is contained in:
pahmiudahgede 2025-05-21 13:00:41 +07:00
parent 3f1e0a96ca
commit 6df861f776
3 changed files with 6 additions and 0 deletions

View File

@ -24,6 +24,8 @@ type CartResponse struct {
}
type CartItemResponse struct {
ItemId string `json:"item_id"`
TrashId string `json:"trashid"`
TrashIcon string `json:"trashicon"`
TrashName string `json:"trashname"`
Amount float32 `json:"amount"`

View File

@ -30,6 +30,7 @@ func GetCartItems(userID string) ([]dto.RequestCartItems, error) {
if err != nil {
return nil, err
}
return items, nil
}

View File

@ -97,6 +97,7 @@ func (s *CartService) GetCartFromRedis(userID string) (*dto.CartResponse, error)
estimatedTotal += subtotal
cartItemDTOs = append(cartItemDTOs, dto.CartItemResponse{
TrashId: trash.ID,
TrashIcon: trash.Icon,
TrashName: trash.Name,
Amount: item.Amount,
@ -131,6 +132,8 @@ func (s *CartService) GetCart(userID string) (*dto.CartResponse, error) {
var items []dto.CartItemResponse
for _, item := range cartDB.CartItems {
items = append(items, dto.CartItemResponse{
ItemId: item.ID,
TrashId: item.TrashID,
TrashIcon: item.TrashCategory.Icon,
TrashName: item.TrashCategory.Name,
Amount: item.Amount,