62 lines
1.3 KiB
Go
62 lines
1.3 KiB
Go
package domain
|
|
|
|
import (
|
|
"time"
|
|
|
|
dbgen "github.com/SamuelTariku/FortuneBet-Backend/gen/db"
|
|
)
|
|
|
|
type Setting struct {
|
|
Key string
|
|
Value string
|
|
UpdatedAt time.Time
|
|
}
|
|
|
|
type CreateSetting struct {
|
|
Key string
|
|
Value string
|
|
}
|
|
|
|
type SettingRes struct {
|
|
Key string `json:"key"`
|
|
Value string `json:"value"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
type CompanySetting struct {
|
|
Key string
|
|
Value string
|
|
CompanyID int64
|
|
UpdatedAt time.Time
|
|
CreatedAt time.Time
|
|
}
|
|
|
|
type CompanySettingRes struct {
|
|
Key string `json:"key"`
|
|
Value string `json:"value"`
|
|
CompanyID int64 `json:"company_id"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
}
|
|
|
|
func ConvertSetting(setting Setting) SettingRes {
|
|
return SettingRes(setting)
|
|
}
|
|
|
|
func ConvertCompanySetting(companySetting dbgen.CompanySetting) CompanySetting {
|
|
return CompanySetting{
|
|
Key: companySetting.Key,
|
|
Value: companySetting.Value,
|
|
CompanyID: companySetting.CompanyID,
|
|
UpdatedAt: companySetting.UpdatedAt.Time,
|
|
CreatedAt: companySetting.CreatedAt.Time,
|
|
}
|
|
}
|
|
|
|
func ConvertCompanySettings(settings []dbgen.CompanySetting) []CompanySetting {
|
|
result := make([]CompanySetting, 0, len(settings))
|
|
for _, setting := range settings {
|
|
result = append(result, ConvertCompanySetting(setting))
|
|
}
|
|
return result
|
|
}
|