refact: recator response
This commit is contained in:
parent
3f1e0a96ca
commit
6df861f776
|
@ -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"`
|
||||
|
|
|
@ -30,6 +30,7 @@ func GetCartItems(userID string) ([]dto.RequestCartItems, error) {
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return items, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue