Add endpoint resource model
This commit is contained in:
parent
750899c93f
commit
4ed0bba1a0
1 changed files with 16 additions and 0 deletions
16
link/dto.go
16
link/dto.go
|
|
@ -11,6 +11,13 @@ type CreationModel struct {
|
|||
RedirectURL string `json:"redirectUrl"`
|
||||
}
|
||||
|
||||
type ResourceModel struct {
|
||||
Id string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
RedirectURL string `json:"redirectUrl"`
|
||||
CreationTime int64 `json:"creationTime"`
|
||||
}
|
||||
|
||||
func (m *CreationModel) MapModelToEntity() (*Link, error) {
|
||||
u, err := url.Parse(m.RedirectURL)
|
||||
if err != nil {
|
||||
|
|
@ -24,3 +31,12 @@ func (m *CreationModel) MapModelToEntity() (*Link, error) {
|
|||
CreationTime: time.Now().UTC(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func MapEntityToModel(entity *Link) ResourceModel {
|
||||
return ResourceModel{
|
||||
Id: entity.Id,
|
||||
Name: entity.Name,
|
||||
RedirectURL: entity.RedirectURL.String(),
|
||||
CreationTime: entity.CreationTime.Unix(),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue