init project
This commit is contained in:
@@ -0,0 +1,95 @@
|
||||
package entity
|
||||
|
||||
import (
|
||||
"furtuna-be/internal/constants/studio"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Studio struct {
|
||||
ID int64
|
||||
BranchId int64
|
||||
Name string
|
||||
Status studio.StudioStatus
|
||||
Price float64
|
||||
Metadata []byte `gorm:"type:jsonb"` // Use jsonb data type for JSON data
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
CreatedBy int64
|
||||
UpdatedBy int64
|
||||
}
|
||||
|
||||
func (s *Studio) TableName() string {
|
||||
return "studios"
|
||||
}
|
||||
|
||||
func (s *Studio) NewStudiosDB() *StudioDB {
|
||||
return &StudioDB{
|
||||
Studio: *s,
|
||||
}
|
||||
}
|
||||
|
||||
type StudioList []*StudioDB
|
||||
|
||||
type StudioDB struct {
|
||||
Studio
|
||||
}
|
||||
|
||||
func (s *StudioDB) ToStudio() *Studio {
|
||||
return &Studio{
|
||||
ID: s.ID,
|
||||
BranchId: s.BranchId,
|
||||
Name: s.Name,
|
||||
Status: s.Status,
|
||||
Price: s.Price,
|
||||
Metadata: s.Metadata,
|
||||
CreatedAt: s.CreatedAt,
|
||||
UpdatedAt: s.UpdatedAt,
|
||||
CreatedBy: s.CreatedBy,
|
||||
UpdatedBy: s.UpdatedBy,
|
||||
}
|
||||
}
|
||||
|
||||
func (s *StudioList) ToStudioList() []*Studio {
|
||||
var studios []*Studio
|
||||
for _, studio := range *s {
|
||||
studios = append(studios, studio.ToStudio())
|
||||
}
|
||||
return studios
|
||||
}
|
||||
|
||||
func (s *StudioDB) ToUpdatedStudio(updatedBy int64, req Studio) {
|
||||
s.UpdatedBy = updatedBy
|
||||
|
||||
if req.BranchId != 0 {
|
||||
s.BranchId = req.BranchId
|
||||
}
|
||||
|
||||
if req.Name != "" {
|
||||
s.Name = req.Name
|
||||
}
|
||||
|
||||
if req.Status != "" {
|
||||
s.Status = req.Status
|
||||
}
|
||||
|
||||
if req.Price != 0 {
|
||||
s.Price = req.Price
|
||||
}
|
||||
|
||||
if req.Metadata != nil {
|
||||
s.Metadata = req.Metadata
|
||||
}
|
||||
}
|
||||
|
||||
func (s *StudioDB) ToStudioDB() *StudioDB {
|
||||
return s
|
||||
}
|
||||
|
||||
type StudioSearch struct {
|
||||
Id int64
|
||||
Name string
|
||||
Status studio.StudioStatus
|
||||
BranchId int64
|
||||
Limit int
|
||||
Offset int
|
||||
}
|
||||
Reference in New Issue
Block a user