54 lines
1.4 KiB
Go
54 lines
1.4 KiB
Go
|
|
package request
|
||
|
|
|
||
|
|
import (
|
||
|
|
"encoding/json"
|
||
|
|
"furtuna-be/internal/constants/studio"
|
||
|
|
"furtuna-be/internal/entity"
|
||
|
|
)
|
||
|
|
|
||
|
|
type StudioParam struct {
|
||
|
|
Id string `form:"id" json:"id" example:"1"`
|
||
|
|
Name string `form:"name" json:"name" example:"Studio A"`
|
||
|
|
Status studio.StudioStatus `form:"status" json:"status" example:"Active"`
|
||
|
|
BranchId int64 `form:"branch_id" json:"branch_id" example:"1"`
|
||
|
|
Limit int `form:"limit" json:"limit" example:"10"`
|
||
|
|
Offset int `form:"offset" json:"offset" example:"0"`
|
||
|
|
}
|
||
|
|
|
||
|
|
func (p *StudioParam) ToEntity() entity.StudioSearch {
|
||
|
|
return entity.StudioSearch{
|
||
|
|
Name: p.Name,
|
||
|
|
Status: p.Status,
|
||
|
|
BranchId: p.BranchId,
|
||
|
|
Limit: p.Limit,
|
||
|
|
Offset: p.Offset,
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
type Studio struct {
|
||
|
|
Name string `json:"name" validate:"required"`
|
||
|
|
BranchId int64 `json:"branch_id" validate:"required"`
|
||
|
|
Status studio.StudioStatus `json:"status"`
|
||
|
|
Price float64 `json:"price" validate:"required"`
|
||
|
|
Metadata map[string]interface{} `json:"metadata"`
|
||
|
|
}
|
||
|
|
|
||
|
|
func (e *Studio) ToEntity() *entity.Studio {
|
||
|
|
studioEntity := &entity.Studio{
|
||
|
|
BranchId: e.BranchId,
|
||
|
|
Name: e.Name,
|
||
|
|
Status: e.Status,
|
||
|
|
Price: e.Price,
|
||
|
|
}
|
||
|
|
|
||
|
|
if e.Metadata != nil {
|
||
|
|
jsonData, err := json.Marshal(e.Metadata)
|
||
|
|
if err != nil {
|
||
|
|
//TODO @taufanvps
|
||
|
|
}
|
||
|
|
studioEntity.Metadata = jsonData
|
||
|
|
}
|
||
|
|
|
||
|
|
return studioEntity
|
||
|
|
}
|