Skip to content
Snippets Groups Projects
Commit abd388a1 authored by Semyon Krestyaninov's avatar Semyon Krestyaninov :dog2:
Browse files

fix

parent 9eb24e8f
No related branches found
No related tags found
No related merge requests found
...@@ -26,9 +26,9 @@ type GetOptions struct { ...@@ -26,9 +26,9 @@ type GetOptions struct {
} }
type Command struct { type Command struct {
CropCommand *CropCommand Crop *CropCommand
FitCommand *FitCommand Fit *FitCommand
ResizeCommand *ResizeCommand Resize *ResizeCommand
} }
type CropCommand struct { type CropCommand struct {
......
...@@ -88,19 +88,31 @@ func ProtoToPtrGetOptions(protoOpts *pbimage.GetRequest_GetOptions) (*service.Ge ...@@ -88,19 +88,31 @@ func ProtoToPtrGetOptions(protoOpts *pbimage.GetRequest_GetOptions) (*service.Ge
} }
func ProtoCommandToPtr(cmd *pbimage.Command) *service.Command { func ProtoCommandToPtr(cmd *pbimage.Command) *service.Command {
if cmd == nil {
return nil
}
switch cmd.GetCommandType().(type) { switch cmd.GetCommandType().(type) {
case *pbimage.Command_Crop: case *pbimage.Command_Crop:
return &service.Command{CropCommand: ProtoCropCommandToPtr(cmd.GetCrop())} return &service.Command{
Crop: ProtoCropCommandToPtr(cmd.GetCrop()),
}
case *pbimage.Command_Fit: case *pbimage.Command_Fit:
return &service.Command{FitCommand: ProtoFitCommandToPtr(cmd.GetFit())} return &service.Command{
Fit: ProtoFitCommandToPtr(cmd.GetFit()),
}
case *pbimage.Command_Resize: case *pbimage.Command_Resize:
return &service.Command{ResizeCommand: ProtoResizeCommandToPtr(cmd.GetResize())} return &service.Command{
Resize: ProtoResizeCommandToPtr(cmd.GetResize()),
}
default: default:
return nil return nil
} }
} }
func ProtoCropCommandToPtr(cmd *pbimage.CropCommand) *service.CropCommand { func ProtoCropCommandToPtr(cmd *pbimage.CropCommand) *service.CropCommand {
if cmd == nil {
return nil
}
return &service.CropCommand{ return &service.CropCommand{
Width: int(cmd.Width), Width: int(cmd.Width),
Height: int(cmd.Height), Height: int(cmd.Height),
...@@ -109,6 +121,9 @@ func ProtoCropCommandToPtr(cmd *pbimage.CropCommand) *service.CropCommand { ...@@ -109,6 +121,9 @@ func ProtoCropCommandToPtr(cmd *pbimage.CropCommand) *service.CropCommand {
} }
func ProtoFitCommandToPtr(cmd *pbimage.FitCommand) *service.FitCommand { func ProtoFitCommandToPtr(cmd *pbimage.FitCommand) *service.FitCommand {
if cmd == nil {
return nil
}
return &service.FitCommand{ return &service.FitCommand{
Width: int(cmd.Width), Width: int(cmd.Width),
Height: int(cmd.Height), Height: int(cmd.Height),
...@@ -117,6 +132,9 @@ func ProtoFitCommandToPtr(cmd *pbimage.FitCommand) *service.FitCommand { ...@@ -117,6 +132,9 @@ func ProtoFitCommandToPtr(cmd *pbimage.FitCommand) *service.FitCommand {
} }
func ProtoResizeCommandToPtr(cmd *pbimage.ResizeCommand) *service.ResizeCommand { func ProtoResizeCommandToPtr(cmd *pbimage.ResizeCommand) *service.ResizeCommand {
if cmd == nil {
return nil
}
return &service.ResizeCommand{ return &service.ResizeCommand{
Width: int(cmd.Width), Width: int(cmd.Width),
Height: int(cmd.Height), Height: int(cmd.Height),
...@@ -125,23 +143,26 @@ func ProtoResizeCommandToPtr(cmd *pbimage.ResizeCommand) *service.ResizeCommand ...@@ -125,23 +143,26 @@ func ProtoResizeCommandToPtr(cmd *pbimage.ResizeCommand) *service.ResizeCommand
} }
func PtrCommandToProto(cmd *service.Command) *pbimage.Command { func PtrCommandToProto(cmd *service.Command) *pbimage.Command {
if cmd == nil {
return nil
}
switch { switch {
case cmd.CropCommand != nil: case cmd.Crop != nil:
return &pbimage.Command{ return &pbimage.Command{
CommandType: &pbimage.Command_Crop{ CommandType: &pbimage.Command_Crop{
Crop: PtrCropCommandToProto(cmd.CropCommand), Crop: PtrCropCommandToProto(cmd.Crop),
}, },
} }
case cmd.FitCommand != nil: case cmd.Fit != nil:
return &pbimage.Command{ return &pbimage.Command{
CommandType: &pbimage.Command_Fit{ CommandType: &pbimage.Command_Fit{
Fit: PtrFitCommandToProto(cmd.FitCommand), Fit: PtrFitCommandToProto(cmd.Fit),
}, },
} }
case cmd.ResizeCommand != nil: case cmd.Resize != nil:
return &pbimage.Command{ return &pbimage.Command{
CommandType: &pbimage.Command_Resize{ CommandType: &pbimage.Command_Resize{
Resize: PtrResizeCommandToProto(cmd.ResizeCommand), Resize: PtrResizeCommandToProto(cmd.Resize),
}, },
} }
default: default:
...@@ -150,6 +171,9 @@ func PtrCommandToProto(cmd *service.Command) *pbimage.Command { ...@@ -150,6 +171,9 @@ func PtrCommandToProto(cmd *service.Command) *pbimage.Command {
} }
func PtrCropCommandToProto(cmd *service.CropCommand) *pbimage.CropCommand { func PtrCropCommandToProto(cmd *service.CropCommand) *pbimage.CropCommand {
if cmd == nil {
return nil
}
return &pbimage.CropCommand{ return &pbimage.CropCommand{
Width: int64(cmd.Width), Width: int64(cmd.Width),
Height: int64(cmd.Height), Height: int64(cmd.Height),
...@@ -158,6 +182,9 @@ func PtrCropCommandToProto(cmd *service.CropCommand) *pbimage.CropCommand { ...@@ -158,6 +182,9 @@ func PtrCropCommandToProto(cmd *service.CropCommand) *pbimage.CropCommand {
} }
func PtrFitCommandToProto(cmd *service.FitCommand) *pbimage.FitCommand { func PtrFitCommandToProto(cmd *service.FitCommand) *pbimage.FitCommand {
if cmd == nil {
return nil
}
return &pbimage.FitCommand{ return &pbimage.FitCommand{
Width: int64(cmd.Width), Width: int64(cmd.Width),
Height: int64(cmd.Height), Height: int64(cmd.Height),
...@@ -166,6 +193,9 @@ func PtrFitCommandToProto(cmd *service.FitCommand) *pbimage.FitCommand { ...@@ -166,6 +193,9 @@ func PtrFitCommandToProto(cmd *service.FitCommand) *pbimage.FitCommand {
} }
func PtrResizeCommandToProto(cmd *service.ResizeCommand) *pbimage.ResizeCommand { func PtrResizeCommandToProto(cmd *service.ResizeCommand) *pbimage.ResizeCommand {
if cmd == nil {
return nil
}
return &pbimage.ResizeCommand{ return &pbimage.ResizeCommand{
Width: int64(cmd.Width), Width: int64(cmd.Width),
Height: int64(cmd.Height), Height: int64(cmd.Height),
......
...@@ -56,7 +56,7 @@ func (x *CropCommand) ProtoReflect() protoreflect.Message { ...@@ -56,7 +56,7 @@ func (x *CropCommand) ProtoReflect() protoreflect.Message {
return mi.MessageOf(x) return mi.MessageOf(x)
} }
// Deprecated: Use CropCommand.ProtoReflect.Descriptor instead. // Deprecated: Use Crop.ProtoReflect.Descriptor instead.
func (*CropCommand) Descriptor() ([]byte, []int) { func (*CropCommand) Descriptor() ([]byte, []int) {
return file_images_images_proto_rawDescGZIP(), []int{0} return file_images_images_proto_rawDescGZIP(), []int{0}
} }
...@@ -117,7 +117,7 @@ func (x *FitCommand) ProtoReflect() protoreflect.Message { ...@@ -117,7 +117,7 @@ func (x *FitCommand) ProtoReflect() protoreflect.Message {
return mi.MessageOf(x) return mi.MessageOf(x)
} }
// Deprecated: Use FitCommand.ProtoReflect.Descriptor instead. // Deprecated: Use Fit.ProtoReflect.Descriptor instead.
func (*FitCommand) Descriptor() ([]byte, []int) { func (*FitCommand) Descriptor() ([]byte, []int) {
return file_images_images_proto_rawDescGZIP(), []int{1} return file_images_images_proto_rawDescGZIP(), []int{1}
} }
...@@ -178,7 +178,7 @@ func (x *ResizeCommand) ProtoReflect() protoreflect.Message { ...@@ -178,7 +178,7 @@ func (x *ResizeCommand) ProtoReflect() protoreflect.Message {
return mi.MessageOf(x) return mi.MessageOf(x)
} }
// Deprecated: Use ResizeCommand.ProtoReflect.Descriptor instead. // Deprecated: Use Resize.ProtoReflect.Descriptor instead.
func (*ResizeCommand) Descriptor() ([]byte, []int) { func (*ResizeCommand) Descriptor() ([]byte, []int) {
return file_images_images_proto_rawDescGZIP(), []int{2} return file_images_images_proto_rawDescGZIP(), []int{2}
} }
...@@ -579,9 +579,9 @@ func file_images_images_proto_rawDescGZIP() []byte { ...@@ -579,9 +579,9 @@ func file_images_images_proto_rawDescGZIP() []byte {
var file_images_images_proto_msgTypes = make([]protoimpl.MessageInfo, 7) var file_images_images_proto_msgTypes = make([]protoimpl.MessageInfo, 7)
var file_images_images_proto_goTypes = []any{ var file_images_images_proto_goTypes = []any{
(*CropCommand)(nil), // 0: images.CropCommand (*CropCommand)(nil), // 0: images.Crop
(*FitCommand)(nil), // 1: images.FitCommand (*FitCommand)(nil), // 1: images.Fit
(*ResizeCommand)(nil), // 2: images.ResizeCommand (*ResizeCommand)(nil), // 2: images.Resize
(*Command)(nil), // 3: images.Command (*Command)(nil), // 3: images.Command
(*GetRequest)(nil), // 4: images.GetRequest (*GetRequest)(nil), // 4: images.GetRequest
(*GetResponse)(nil), // 5: images.GetResponse (*GetResponse)(nil), // 5: images.GetResponse
...@@ -589,9 +589,9 @@ var file_images_images_proto_goTypes = []any{ ...@@ -589,9 +589,9 @@ var file_images_images_proto_goTypes = []any{
(*files.File)(nil), // 7: files.File (*files.File)(nil), // 7: files.File
} }
var file_images_images_proto_depIdxs = []int32{ var file_images_images_proto_depIdxs = []int32{
0, // 0: images.Command.crop:type_name -> images.CropCommand 0, // 0: images.Command.crop:type_name -> images.Crop
1, // 1: images.Command.fit:type_name -> images.FitCommand 1, // 1: images.Command.fit:type_name -> images.Fit
2, // 2: images.Command.resize:type_name -> images.ResizeCommand 2, // 2: images.Command.resize:type_name -> images.Resize
7, // 3: images.GetRequest.source:type_name -> files.File 7, // 3: images.GetRequest.source:type_name -> files.File
6, // 4: images.GetRequest.opts:type_name -> images.GetRequest.GetOptions 6, // 4: images.GetRequest.opts:type_name -> images.GetRequest.GetOptions
7, // 5: images.GetResponse.result:type_name -> files.File 7, // 5: images.GetResponse.result:type_name -> files.File
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment