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 {
}
type Command struct {
CropCommand *CropCommand
FitCommand *FitCommand
ResizeCommand *ResizeCommand
Crop *CropCommand
Fit *FitCommand
Resize *ResizeCommand
}
type CropCommand struct {
......
......@@ -88,19 +88,31 @@ func ProtoToPtrGetOptions(protoOpts *pbimage.GetRequest_GetOptions) (*service.Ge
}
func ProtoCommandToPtr(cmd *pbimage.Command) *service.Command {
if cmd == nil {
return nil
}
switch cmd.GetCommandType().(type) {
case *pbimage.Command_Crop:
return &service.Command{CropCommand: ProtoCropCommandToPtr(cmd.GetCrop())}
return &service.Command{
Crop: ProtoCropCommandToPtr(cmd.GetCrop()),
}
case *pbimage.Command_Fit:
return &service.Command{FitCommand: ProtoFitCommandToPtr(cmd.GetFit())}
return &service.Command{
Fit: ProtoFitCommandToPtr(cmd.GetFit()),
}
case *pbimage.Command_Resize:
return &service.Command{ResizeCommand: ProtoResizeCommandToPtr(cmd.GetResize())}
return &service.Command{
Resize: ProtoResizeCommandToPtr(cmd.GetResize()),
}
default:
return nil
}
}
func ProtoCropCommandToPtr(cmd *pbimage.CropCommand) *service.CropCommand {
if cmd == nil {
return nil
}
return &service.CropCommand{
Width: int(cmd.Width),
Height: int(cmd.Height),
......@@ -109,6 +121,9 @@ func ProtoCropCommandToPtr(cmd *pbimage.CropCommand) *service.CropCommand {
}
func ProtoFitCommandToPtr(cmd *pbimage.FitCommand) *service.FitCommand {
if cmd == nil {
return nil
}
return &service.FitCommand{
Width: int(cmd.Width),
Height: int(cmd.Height),
......@@ -117,6 +132,9 @@ func ProtoFitCommandToPtr(cmd *pbimage.FitCommand) *service.FitCommand {
}
func ProtoResizeCommandToPtr(cmd *pbimage.ResizeCommand) *service.ResizeCommand {
if cmd == nil {
return nil
}
return &service.ResizeCommand{
Width: int(cmd.Width),
Height: int(cmd.Height),
......@@ -125,23 +143,26 @@ func ProtoResizeCommandToPtr(cmd *pbimage.ResizeCommand) *service.ResizeCommand
}
func PtrCommandToProto(cmd *service.Command) *pbimage.Command {
if cmd == nil {
return nil
}
switch {
case cmd.CropCommand != nil:
case cmd.Crop != nil:
return &pbimage.Command{
CommandType: &pbimage.Command_Crop{
Crop: PtrCropCommandToProto(cmd.CropCommand),
Crop: PtrCropCommandToProto(cmd.Crop),
},
}
case cmd.FitCommand != nil:
case cmd.Fit != nil:
return &pbimage.Command{
CommandType: &pbimage.Command_Fit{
Fit: PtrFitCommandToProto(cmd.FitCommand),
Fit: PtrFitCommandToProto(cmd.Fit),
},
}
case cmd.ResizeCommand != nil:
case cmd.Resize != nil:
return &pbimage.Command{
CommandType: &pbimage.Command_Resize{
Resize: PtrResizeCommandToProto(cmd.ResizeCommand),
Resize: PtrResizeCommandToProto(cmd.Resize),
},
}
default:
......@@ -150,6 +171,9 @@ func PtrCommandToProto(cmd *service.Command) *pbimage.Command {
}
func PtrCropCommandToProto(cmd *service.CropCommand) *pbimage.CropCommand {
if cmd == nil {
return nil
}
return &pbimage.CropCommand{
Width: int64(cmd.Width),
Height: int64(cmd.Height),
......@@ -158,6 +182,9 @@ func PtrCropCommandToProto(cmd *service.CropCommand) *pbimage.CropCommand {
}
func PtrFitCommandToProto(cmd *service.FitCommand) *pbimage.FitCommand {
if cmd == nil {
return nil
}
return &pbimage.FitCommand{
Width: int64(cmd.Width),
Height: int64(cmd.Height),
......@@ -166,6 +193,9 @@ func PtrFitCommandToProto(cmd *service.FitCommand) *pbimage.FitCommand {
}
func PtrResizeCommandToProto(cmd *service.ResizeCommand) *pbimage.ResizeCommand {
if cmd == nil {
return nil
}
return &pbimage.ResizeCommand{
Width: int64(cmd.Width),
Height: int64(cmd.Height),
......
......@@ -56,7 +56,7 @@ func (x *CropCommand) ProtoReflect() protoreflect.Message {
return mi.MessageOf(x)
}
// Deprecated: Use CropCommand.ProtoReflect.Descriptor instead.
// Deprecated: Use Crop.ProtoReflect.Descriptor instead.
func (*CropCommand) Descriptor() ([]byte, []int) {
return file_images_images_proto_rawDescGZIP(), []int{0}
}
......@@ -117,7 +117,7 @@ func (x *FitCommand) ProtoReflect() protoreflect.Message {
return mi.MessageOf(x)
}
// Deprecated: Use FitCommand.ProtoReflect.Descriptor instead.
// Deprecated: Use Fit.ProtoReflect.Descriptor instead.
func (*FitCommand) Descriptor() ([]byte, []int) {
return file_images_images_proto_rawDescGZIP(), []int{1}
}
......@@ -178,7 +178,7 @@ func (x *ResizeCommand) ProtoReflect() protoreflect.Message {
return mi.MessageOf(x)
}
// Deprecated: Use ResizeCommand.ProtoReflect.Descriptor instead.
// Deprecated: Use Resize.ProtoReflect.Descriptor instead.
func (*ResizeCommand) Descriptor() ([]byte, []int) {
return file_images_images_proto_rawDescGZIP(), []int{2}
}
......@@ -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_goTypes = []any{
(*CropCommand)(nil), // 0: images.CropCommand
(*FitCommand)(nil), // 1: images.FitCommand
(*ResizeCommand)(nil), // 2: images.ResizeCommand
(*CropCommand)(nil), // 0: images.Crop
(*FitCommand)(nil), // 1: images.Fit
(*ResizeCommand)(nil), // 2: images.Resize
(*Command)(nil), // 3: images.Command
(*GetRequest)(nil), // 4: images.GetRequest
(*GetResponse)(nil), // 5: images.GetResponse
......@@ -589,9 +589,9 @@ var file_images_images_proto_goTypes = []any{
(*files.File)(nil), // 7: files.File
}
var file_images_images_proto_depIdxs = []int32{
0, // 0: images.Command.crop:type_name -> images.CropCommand
1, // 1: images.Command.fit:type_name -> images.FitCommand
2, // 2: images.Command.resize:type_name -> images.ResizeCommand
0, // 0: images.Command.crop:type_name -> images.Crop
1, // 1: images.Command.fit:type_name -> images.Fit
2, // 2: images.Command.resize:type_name -> images.Resize
7, // 3: images.GetRequest.source:type_name -> files.File
6, // 4: images.GetRequest.opts:type_name -> images.GetRequest.GetOptions
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