-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented the GetAllByCategory functionality for the property model
- Loading branch information
Showing
11 changed files
with
161 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package dto | ||
|
||
type LocationDto struct { | ||
Country string `json:"country"` | ||
State string `json:"state"` | ||
City string `json:"city"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package dto | ||
|
||
type PostDto struct { | ||
Title string `json:"title"` | ||
Description string `json:"description"` | ||
PropertyId uint `json:"propertyId"` | ||
} | ||
|
||
type PostCreationDto struct { | ||
Title string `json:"title"` | ||
Description string `json:"description"` | ||
} | ||
|
||
type PostCommentDto struct { | ||
Id uint `json:"id"` | ||
Description string `json:"description"` | ||
} | ||
|
||
type PostCommentCreationDto struct { | ||
Description string `json:"description"` | ||
PostId uint `json:"postId"` | ||
} | ||
|
||
type AnnounceCreationDto struct { | ||
Property PropertyCreationDto `json:"property"` | ||
Post PostCommentCreationDto `json:"post"` | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package dto | ||
|
||
type PropertyDto struct { | ||
Owner UserDetail `json:"owner"` | ||
CurrentCurrency string `json:"currentCurrency"` | ||
CurrentPrice float32 `json:"currentPrice"` | ||
PropertyDetail PropertyDetailDto `json:"propertyDetail"` | ||
Location LocationDto `json:"location"` | ||
Announcement PostDto `json:"announcement"` | ||
} | ||
|
||
type PropertyCreationDto struct { | ||
OwnerId uint `json:"ownerId"` | ||
CurrentCurrency string `json:"currentCurrency"` | ||
CurrentPrice float32 `json:"currentPrice"` | ||
} | ||
|
||
type PropertyDetailDto struct { | ||
NumberOfRooms int `json:"numberOfRooms"` | ||
NumberOfBathrooms int `json:"numberOfBathrooms"` | ||
NumberOfKitchens int `json:"numberOfKitchens"` | ||
NumberOfParkingSpaces int `json:"numberOfParkingSpaces"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package repository | ||
|
||
import ( | ||
"github.com/Stefan923/go-estate-market/data/database" | ||
"github.com/Stefan923/go-estate-market/data/model" | ||
"github.com/Stefan923/go-estate-market/metrics" | ||
"reflect" | ||
) | ||
|
||
type PropertyDetailRepository struct { | ||
BaseRepository[model.PropertyDetail] | ||
} | ||
|
||
func NewPropertyDetailRepository() *PropertyDetailRepository { | ||
return &PropertyDetailRepository{ | ||
BaseRepository: BaseRepository[model.PropertyDetail]{ | ||
Database: database.GetDatabase(), | ||
Preloads: []PreloadSetting{}, | ||
}, | ||
} | ||
} | ||
|
||
func (repository *PropertyDetailRepository) FindByPropertyId(propertyId uint) (*model.PropertyDetail, error) { | ||
var propertyDetail *model.PropertyDetail | ||
|
||
err := repository.Database. | ||
Where("property_id = ? and deleted_at is null", propertyId). | ||
First(propertyDetail). | ||
Error | ||
if err != nil { | ||
metrics.DatabaseCallCounter.WithLabelValues(reflect.TypeOf(*propertyDetail).String(), "FindByPropertyId", "Failed").Inc() | ||
return nil, err | ||
} | ||
|
||
metrics.DatabaseCallCounter.WithLabelValues(reflect.TypeOf(*propertyDetail).String(), "FindByPropertyId", "Success").Inc() | ||
return propertyDetail, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters