Skip to content
Snippets Groups Projects
Commit 88986447 authored by ko_oler's avatar ko_oler
Browse files

Внесены изменения после внесения изменений в proto, перегенерированы proto-файлы

parent 88a7df56
No related branches found
No related tags found
No related merge requests found
package spaces
import "time"
type State int
const (
......@@ -25,7 +27,7 @@ type Space struct {
Name string `json:"name,omitempty" bson:"name"`
Description string `json:"desc,omitempty" bson:"desc"`
State State `json:"state" bson:"state"`
StateInfo string `json:"stateInfo,omitempty" bson:"stateInfo,omitempty"`
StateInfo *StateInfo `json:"state_info,omitempty" bson:"state_info,omitempty"`
// TransferToOrg - идентификатор организации, в которую был запрошен перенос пространства
TransferToOrg string `json:"transfer_to_org" bson:"transfer_to_org"`
......@@ -33,6 +35,13 @@ type Space struct {
Config *Config `json:"config" bson:"config"`
}
type StateInfo struct {
State State `json:"state" bson:"state"`
Info string `json:"info" bson:"info"`
StartedAt time.Time `json:"started_at,omitempty" bson:"started_at,omitempty"`
DBVersion uint32 `json:"db_version" bson:"db_version"`
}
func (s Space) Clone() *Space {
return &s
}
......
......@@ -7,6 +7,7 @@ package transportgrpc
import (
service "git.perx.ru/perxis/perxis-go/pkg/spaces"
pb "git.perx.ru/perxis/perxis-go/proto/spaces"
"google.golang.org/protobuf/types/known/timestamppb"
)
func PtrConfigToProto(config *service.Config) (*pb.Config, error) {
......@@ -18,6 +19,18 @@ func PtrConfigToProto(config *service.Config) (*pb.Config, error) {
}, nil
}
func PtrStateInfoToProto(stateInfo *service.StateInfo) (*pb.StateInfo, error) {
if stateInfo == nil {
return nil, nil
}
return &pb.StateInfo{
State: pb.State(stateInfo.State),
Info: stateInfo.Info,
DBVersion: int32(stateInfo.DBVersion),
StartedAt: timestamppb.New(stateInfo.StartedAt),
}, nil
}
func ProtoToPtrConfig(protoConfig *pb.Config) (*service.Config, error) {
if protoConfig == nil {
return nil, nil
......@@ -27,17 +40,30 @@ func ProtoToPtrConfig(protoConfig *pb.Config) (*service.Config, error) {
}, nil
}
func ProtoToPtrStateInfo(protoStateInfo *pb.StateInfo) (*service.StateInfo, error) {
if protoStateInfo == nil {
return nil, nil
}
return &service.StateInfo{
State: service.State(protoStateInfo.State),
Info: protoStateInfo.Info,
StartedAt: protoStateInfo.StartedAt.AsTime(),
DBVersion: uint32(protoStateInfo.DBVersion),
}, nil
}
func PtrSpaceToProto(space *service.Space) (*pb.Space, error) {
if space == nil {
return nil, nil
}
cfg, _ := PtrConfigToProto(space.Config)
state, _ := PtrStateInfoToProto(space.StateInfo)
return &pb.Space{
Id: space.ID,
OrgId: space.OrgID,
Name: space.Name,
Description: space.Description,
State: pb.State(space.State),
StateInfo: state,
Config: cfg,
TransferToOrg: space.TransferToOrg,
}, nil
......@@ -48,12 +74,13 @@ func ProtoToPtrSpace(protoSpace *pb.Space) (*service.Space, error) {
return nil, nil
}
cfg, _ := ProtoToPtrConfig(protoSpace.Config)
state, _ := ProtoToPtrStateInfo(protoSpace.StateInfo)
return &service.Space{
ID: protoSpace.Id,
OrgID: protoSpace.OrgId,
Name: protoSpace.Name,
Description: protoSpace.Description,
State: service.State(protoSpace.State),
StateInfo: state,
Config: cfg,
TransferToOrg: protoSpace.TransferToOrg,
}, nil
......
This diff is collapsed.
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.3.0
// - protoc v4.24.3
// - protoc v4.23.4
// source: spaces/spaces.proto
package spaces
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment