Merge pull request 'refactor(trade): remove OriginalPrice and Location fields from trade items' (#3) from feature/flea-market into master
Reviewed-on: #3
This commit was merged in pull request #3.
This commit is contained in:
@@ -39,9 +39,7 @@ func ConvertTradeItemToResponse(item *model.TradeItem, isFavorited bool) *TradeI
|
||||
Title: item.Title,
|
||||
Content: item.Content,
|
||||
Price: item.Price,
|
||||
OriginalPrice: item.OriginalPrice,
|
||||
Condition: item.Condition,
|
||||
Location: item.Location,
|
||||
Status: string(item.Status),
|
||||
ViewsCount: item.ViewsCount,
|
||||
FavoritesCount: item.FavoritesCount,
|
||||
@@ -80,9 +78,7 @@ func ConvertTradeItemToDetailResponse(item *model.TradeItem, isFavorited bool) *
|
||||
Title: item.Title,
|
||||
Content: item.Content,
|
||||
Price: item.Price,
|
||||
OriginalPrice: item.OriginalPrice,
|
||||
Condition: item.Condition,
|
||||
Location: item.Location,
|
||||
Status: string(item.Status),
|
||||
ViewsCount: item.ViewsCount,
|
||||
FavoritesCount: item.FavoritesCount,
|
||||
|
||||
@@ -24,9 +24,7 @@ type TradeItemResponse struct {
|
||||
Segments model.MessageSegments `json:"segments,omitempty"`
|
||||
Images []TradeImageResponse `json:"images"`
|
||||
Price *float64 `json:"price,omitempty"`
|
||||
OriginalPrice *float64 `json:"original_price,omitempty"`
|
||||
Condition string `json:"condition,omitempty"`
|
||||
Location string `json:"location,omitempty"`
|
||||
Status string `json:"status"`
|
||||
ViewsCount int `json:"views_count"`
|
||||
FavoritesCount int `json:"favorites_count"`
|
||||
@@ -46,9 +44,7 @@ type TradeItemDetailResponse struct {
|
||||
Segments model.MessageSegments `json:"segments,omitempty"`
|
||||
Images []TradeImageResponse `json:"images"`
|
||||
Price *float64 `json:"price,omitempty"`
|
||||
OriginalPrice *float64 `json:"original_price,omitempty"`
|
||||
Condition string `json:"condition,omitempty"`
|
||||
Location string `json:"location,omitempty"`
|
||||
Status string `json:"status"`
|
||||
ViewsCount int `json:"views_count"`
|
||||
FavoritesCount int `json:"favorites_count"`
|
||||
@@ -66,9 +62,7 @@ type CreateTradeItemRequest struct {
|
||||
Segments model.MessageSegments `json:"segments"`
|
||||
Images []string `json:"images"`
|
||||
Price *float64 `json:"price"`
|
||||
OriginalPrice *float64 `json:"original_price"`
|
||||
Condition string `json:"condition" binding:"omitempty,oneof=brand_new like_new lightly_used well_used"`
|
||||
Location string `json:"location" binding:"omitempty,max=100"`
|
||||
}
|
||||
|
||||
type UpdateTradeItemRequest struct {
|
||||
@@ -79,9 +73,7 @@ type UpdateTradeItemRequest struct {
|
||||
Segments model.MessageSegments `json:"segments"`
|
||||
Images []string `json:"images"`
|
||||
Price *float64 `json:"price"`
|
||||
OriginalPrice *float64 `json:"original_price"`
|
||||
Condition *string `json:"condition" binding:"omitempty,oneof=brand_new like_new lightly_used well_used"`
|
||||
Location *string `json:"location" binding:"omitempty,max=100"`
|
||||
}
|
||||
|
||||
type UpdateTradeItemStatusRequest struct {
|
||||
|
||||
@@ -47,9 +47,7 @@ type TradeItem struct {
|
||||
User *User `json:"user,omitempty" gorm:"foreignKey:UserID"`
|
||||
Images []TradeImage `json:"images" gorm:"foreignKey:TradeItemID"`
|
||||
Price *float64 `json:"price,omitempty" gorm:"type:decimal(10,2)"`
|
||||
OriginalPrice *float64 `json:"original_price,omitempty" gorm:"type:decimal(10,2)"`
|
||||
Condition string `json:"condition,omitempty" gorm:"type:varchar(20)"`
|
||||
Location string `json:"location,omitempty" gorm:"type:varchar(100)"`
|
||||
Status TradeItemStatus `json:"status" gorm:"type:varchar(10);not null;default:'active';index"`
|
||||
ViewsCount int `json:"views_count" gorm:"default:0"`
|
||||
FavoritesCount int `json:"favorites_count" gorm:"default:0"`
|
||||
|
||||
@@ -44,9 +44,7 @@ func (s *tradeService) Create(ctx context.Context, userID string, req dto.Create
|
||||
Content: req.Content,
|
||||
Segments: req.Segments,
|
||||
Price: req.Price,
|
||||
OriginalPrice: req.OriginalPrice,
|
||||
Condition: req.Condition,
|
||||
Location: req.Location,
|
||||
Status: model.TradeItemActive,
|
||||
}
|
||||
if item.Content == "" {
|
||||
@@ -112,15 +110,9 @@ func (s *tradeService) Update(ctx context.Context, userID string, id string, req
|
||||
if req.Price != nil {
|
||||
item.Price = req.Price
|
||||
}
|
||||
if req.OriginalPrice != nil {
|
||||
item.OriginalPrice = req.OriginalPrice
|
||||
}
|
||||
if req.Condition != nil {
|
||||
item.Condition = *req.Condition
|
||||
}
|
||||
if req.Location != nil {
|
||||
item.Location = *req.Location
|
||||
}
|
||||
item.UpdatedAt = time.Now()
|
||||
|
||||
if req.Images != nil {
|
||||
|
||||
Reference in New Issue
Block a user