refact: recator response
This commit is contained in:
parent
3f1e0a96ca
commit
6df861f776
|
@ -24,6 +24,8 @@ type CartResponse struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type CartItemResponse struct {
|
type CartItemResponse struct {
|
||||||
|
ItemId string `json:"item_id"`
|
||||||
|
TrashId string `json:"trashid"`
|
||||||
TrashIcon string `json:"trashicon"`
|
TrashIcon string `json:"trashicon"`
|
||||||
TrashName string `json:"trashname"`
|
TrashName string `json:"trashname"`
|
||||||
Amount float32 `json:"amount"`
|
Amount float32 `json:"amount"`
|
||||||
|
|
|
@ -30,6 +30,7 @@ func GetCartItems(userID string) ([]dto.RequestCartItems, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return items, nil
|
return items, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -97,6 +97,7 @@ func (s *CartService) GetCartFromRedis(userID string) (*dto.CartResponse, error)
|
||||||
estimatedTotal += subtotal
|
estimatedTotal += subtotal
|
||||||
|
|
||||||
cartItemDTOs = append(cartItemDTOs, dto.CartItemResponse{
|
cartItemDTOs = append(cartItemDTOs, dto.CartItemResponse{
|
||||||
|
TrashId: trash.ID,
|
||||||
TrashIcon: trash.Icon,
|
TrashIcon: trash.Icon,
|
||||||
TrashName: trash.Name,
|
TrashName: trash.Name,
|
||||||
Amount: item.Amount,
|
Amount: item.Amount,
|
||||||
|
@ -131,6 +132,8 @@ func (s *CartService) GetCart(userID string) (*dto.CartResponse, error) {
|
||||||
var items []dto.CartItemResponse
|
var items []dto.CartItemResponse
|
||||||
for _, item := range cartDB.CartItems {
|
for _, item := range cartDB.CartItems {
|
||||||
items = append(items, dto.CartItemResponse{
|
items = append(items, dto.CartItemResponse{
|
||||||
|
ItemId: item.ID,
|
||||||
|
TrashId: item.TrashID,
|
||||||
TrashIcon: item.TrashCategory.Icon,
|
TrashIcon: item.TrashCategory.Icon,
|
||||||
TrashName: item.TrashCategory.Name,
|
TrashName: item.TrashCategory.Name,
|
||||||
Amount: item.Amount,
|
Amount: item.Amount,
|
||||||
|
|
Loading…
Reference in New Issue