2024-08-11 10:23:20 +07:00
|
|
|
package converts
|
2024-08-05 23:06:32 +07:00
|
|
|
|
|
|
|
import (
|
2024-08-08 10:40:22 +07:00
|
|
|
"github.com/aarondl/opt/omit"
|
2024-08-15 09:36:06 +07:00
|
|
|
"github.com/tigorlazuardi/bluemage/go/gen/jet/model"
|
2024-08-05 23:06:32 +07:00
|
|
|
"github.com/tigorlazuardi/bluemage/go/gen/models"
|
|
|
|
device "github.com/tigorlazuardi/bluemage/go/gen/proto/device/v1"
|
|
|
|
)
|
|
|
|
|
|
|
|
// goverter:converter
|
|
|
|
// goverter:extend BoolToInt8
|
|
|
|
// goverter:extend Int8ToBool
|
2024-08-08 10:40:22 +07:00
|
|
|
// goverter:extend PtrBoolToOmitInt8
|
2024-08-13 14:26:19 +07:00
|
|
|
// goverter:extend BoolToOmitInt8
|
2024-08-08 10:40:22 +07:00
|
|
|
// goverter:extend PtrStringToOmitString
|
|
|
|
// goverter:extend PtrFloat64ToOmitFloat64
|
|
|
|
// goverter:extend PtrInt32ToOmitInt32
|
2024-08-13 14:26:19 +07:00
|
|
|
// goverter:extend PtrInt64ToOmitInt64
|
|
|
|
// goverter:extend PtrIntToOmitInt
|
|
|
|
// goverter:extend PtrInt8ToOmitInt8
|
|
|
|
// goverter:extend IntToOmitInt
|
|
|
|
// goverter:extend Int8ToOmitInt8
|
|
|
|
// goverter:extend Int32ToOmitInt32
|
|
|
|
// goverter:extend Int64ToOmitInt64
|
|
|
|
// goverter:extend Float64ToOmitFloat64
|
|
|
|
// goverter:extend StringToOmitString
|
2024-08-05 23:06:32 +07:00
|
|
|
type DeviceConverter interface {
|
2024-08-13 14:26:19 +07:00
|
|
|
// goverter:ignore CreatedAt UpdatedAt
|
2024-08-05 23:06:32 +07:00
|
|
|
// goverter:map Nsfw NSFW
|
2024-08-13 14:26:19 +07:00
|
|
|
CreateDeviceRequestToModelsDeviceSetter(*device.CreateDeviceRequest) *models.DeviceSetter
|
2024-08-05 23:06:32 +07:00
|
|
|
// goverter:ignore state sizeCache unknownFields
|
|
|
|
ModelsDeviceToCreateDeviceResponse(*models.Device) *device.CreateDeviceResponse
|
|
|
|
// goverter:ignore state sizeCache unknownFields
|
2024-08-15 09:36:06 +07:00
|
|
|
// goverter:useZeroValueOnPointerInconsistency
|
|
|
|
JetModelDeviceToGetDeviceResponse(model.Devices) *device.GetDeviceResponse
|
2024-08-08 10:40:22 +07:00
|
|
|
|
|
|
|
// goverter:ignore Slug SingleFolderMode CreatedAt UpdatedAt
|
|
|
|
// goverter:map Nsfw NSFW
|
|
|
|
DeviceSetterProtoToModelsDeviceSetter(*device.DeviceSetter) *models.DeviceSetter
|
2024-08-05 23:06:32 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
func BoolToInt8(b bool) int8 {
|
|
|
|
if b {
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2024-08-08 10:40:22 +07:00
|
|
|
func PtrBoolToOmitInt8(b *bool) omit.Val[int8] {
|
|
|
|
if b == nil {
|
|
|
|
return omit.Val[int8]{}
|
|
|
|
}
|
|
|
|
v := *b
|
|
|
|
if v {
|
|
|
|
return omit.From(int8(1))
|
|
|
|
}
|
|
|
|
return omit.From(int8(0))
|
|
|
|
}
|
|
|
|
|
|
|
|
func PtrStringToOmitString(s *string) omit.Val[string] {
|
|
|
|
return omit.FromPtr(s)
|
|
|
|
}
|
|
|
|
|
2024-08-13 14:26:19 +07:00
|
|
|
func StringToOmitString(s string) omit.Val[string] {
|
|
|
|
return omit.From(s)
|
|
|
|
}
|
|
|
|
|
2024-08-08 10:40:22 +07:00
|
|
|
func PtrFloat64ToOmitFloat64(f *float64) omit.Val[float64] {
|
|
|
|
return omit.FromPtr(f)
|
|
|
|
}
|
|
|
|
|
2024-08-13 14:26:19 +07:00
|
|
|
func Float64ToOmitFloat64(f float64) omit.Val[float64] {
|
|
|
|
return omit.From(f)
|
|
|
|
}
|
|
|
|
|
|
|
|
func PtrIntToOmitInt(i *int) omit.Val[int] {
|
|
|
|
return omit.FromPtr(i)
|
|
|
|
}
|
|
|
|
|
|
|
|
func IntToOmitInt(i int) omit.Val[int] {
|
|
|
|
return omit.From(i)
|
|
|
|
}
|
|
|
|
|
|
|
|
func PtrInt8ToOmitInt8(i *int8) omit.Val[int8] {
|
|
|
|
return omit.FromPtr(i)
|
|
|
|
}
|
|
|
|
|
|
|
|
func Int8ToOmitInt8(i int8) omit.Val[int8] {
|
|
|
|
return omit.From(i)
|
|
|
|
}
|
|
|
|
|
2024-08-08 10:40:22 +07:00
|
|
|
func PtrInt32ToOmitInt32(i *int32) omit.Val[int32] {
|
|
|
|
return omit.FromPtr(i)
|
|
|
|
}
|
|
|
|
|
2024-08-13 14:26:19 +07:00
|
|
|
func Int32ToOmitInt32(i int32) omit.Val[int32] {
|
|
|
|
return omit.From(i)
|
|
|
|
}
|
|
|
|
|
2024-08-08 10:40:22 +07:00
|
|
|
func PtrInt64ToOmitInt64(i *int64) omit.Val[int64] {
|
|
|
|
return omit.FromPtr(i)
|
|
|
|
}
|
|
|
|
|
2024-08-13 14:26:19 +07:00
|
|
|
func Int64ToOmitInt64(i int64) omit.Val[int64] {
|
|
|
|
return omit.From(i)
|
|
|
|
}
|
|
|
|
|
|
|
|
func BoolToOmitInt8(b bool) omit.Val[int8] {
|
|
|
|
if b {
|
|
|
|
return omit.From(int8(1))
|
|
|
|
}
|
|
|
|
return omit.From(int8(0))
|
|
|
|
}
|
|
|
|
|
2024-08-05 23:06:32 +07:00
|
|
|
func Int8ToBool(i int8) bool {
|
|
|
|
return i > 0
|
|
|
|
}
|