Add password protected links

This commit is contained in:
Andrey Chervyakov 2021-04-03 22:25:11 +06:00
parent 2baa74d520
commit a01f540a29
6 changed files with 67 additions and 28 deletions

View file

@ -9,18 +9,21 @@ type CreationModel struct {
Id string `json:"id"`
Name string `json:"name"`
RedirectURL string `json:"redirectUrl"`
Password string `json:"password"`
}
type ResourceModel struct {
Id string `json:"id"`
Name string `json:"name"`
RedirectURL string `json:"redirectUrl"`
Password string `json:"password"`
CreationTime int64 `json:"creationTime"`
}
type UpdateModel struct {
Name string `json:"name,omitempty"`
RedirectURL string `json:"redirectUrl,omitempty"`
Password string `json:"password"`
}
func (m *CreationModel) MapModelToEntity() (*Link, error) {
@ -33,6 +36,7 @@ func (m *CreationModel) MapModelToEntity() (*Link, error) {
Id: m.Id,
Name: m.Name,
RedirectURL: *u,
Password: m.Password,
CreationTime: time.Now().UTC(),
}, nil
}
@ -42,6 +46,7 @@ func MapEntityToModel(entity *Link) ResourceModel {
Id: entity.Id,
Name: entity.Name,
RedirectURL: entity.RedirectURL.String(),
Password: entity.Password,
CreationTime: entity.CreationTime.Unix(),
}
}