From 1d136145ea8bdc3f8f784f7057e6345bde177515 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=99=E8=80=80=E5=8D=8E?= <793339602@qq.com> Date: Thu, 2 Jul 2020 11:56:39 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E3=80=81=E6=8F=92=E5=85=A5=E3=80=81=E5=88=A0=E9=99=A4=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/vcs.xml | 6 + component/database/dict_info_dao.go | 90 +++++++ handler/dict.go | 46 ++++ main.go | 1 + proto/addressdict.pb.go | 382 ++++++++++++++++++++++++++++ proto/addressdict.pb.micro.go | 155 +++++++++++ proto/addressdict.proto | 41 +++ 7 files changed, 721 insertions(+) create mode 100644 .idea/vcs.xml create mode 100644 proto/addressdict.pb.go create mode 100644 proto/addressdict.pb.micro.go create mode 100644 proto/addressdict.proto diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/component/database/dict_info_dao.go b/component/database/dict_info_dao.go index f29fb24..5d89f60 100644 --- a/component/database/dict_info_dao.go +++ b/component/database/dict_info_dao.go @@ -2,6 +2,7 @@ package database import ( "errors" + "fmt" "github.com/jinzhu/gorm" "github.com/micro/go-micro/util/log" "github.com/pku-hit/dict/model/entity" @@ -130,3 +131,92 @@ func ListChildren(parentId string, dictType ...proto.DictType) (dicts []*entity. err = query.Where("parent_id = ?", parentId).Find(&dicts).Error return } + +func GetParentlist(parentid string)(dict []*entity.DictInfo,err error) { + query := db.New() + if !util.String.IsEmptyString(parentid) { + query = query.Where("parent_id = ?", parentid) + } + //query.Where("Type = ? and ParentId is null", proto.DictType_Root.String()) + err = query.Find(&dict).Error + if err != nil { + log.Error(util.Json.ToJsonString(err)) + } else { + log.Info(util.Json.ToJsonString(dict)) + } + return +} +func ExistDictWithCode(code string) (dict *entity.DictInfo, err error) { + dict = &entity.DictInfo{} + err = db.Where("code = ?", code).Find(dict).Error + if err == gorm.ErrRecordNotFound { + dict = nil + } + return +} +func NewaddressDict(category, parentId, code, name, pyCode string, dictType proto.AddressDictType, value interface{}) (dict *entity.DictInfo, err error) { + + if dict, err = ExistDictWithCode(code); err == nil && dict != nil { + log.Warnf("exist dict: %s", util.Json.ToJsonString(dict)) + fmt.Println("存在该数据!code不能重复!") + return + } + now := time.Now() + dict = &entity.DictInfo{ + ID: util.Snowflake.GenId(), + Code: code, + Name: name, + PyCode: pyCode, + Value: util.Json.ToJsonString(value), + Status: proto.DictStatus_Normal.String(), + CreateAt: &now, + UpdateAt: &now, + } + + if util.String.IsEmptyString(parentId) { + err = errors.New("没有指定ParentId的字典") + return + } else { + if dictType == proto.AddressDictType_country { + dict.Type = proto.AddressDictType_country.String() + } else if dictType == proto.AddressDictType_province { + dict.Type = proto.AddressDictType_province.String() + } else if dictType == proto.AddressDictType_city { + dict.Type = proto.AddressDictType_city.String() + } else if dictType == proto.AddressDictType_area { + dict.Type = proto.AddressDictType_area.String() + } else if dictType == proto.AddressDictType_street{ + dict.Type = proto.AddressDictType_street.String() + } else { + dict.Type = "" + } + dict.ParentId = parentId + dict.Type = dictType.String() + } + dict.Category = "address" + err = db.Save(dict).Error + //db.s + if err != nil { + log.Error("save new dict error %s.", err.Error()) + } + return +} + +//根据code删除数据 + +func DeleteAddressDict(code string, soft bool) (err error) { + dict, err := ExistDictWithCode(code) + if err == gorm.ErrRecordNotFound { + return + } + now := time.Now() + if soft { + dict.Status = proto.DictStatus_Deleted.String() + dict.DeleteAt = &now + log.Info(util.Json.StructToMap(dict)) + err = db.Model(dict).Select("status", "delete_at").Update(util.Json.StructToMap(dict)).Error + } else { + err = db.Where("code = ?", code).Delete(new(entity.DictInfo)).Error + } + return +} diff --git a/handler/dict.go b/handler/dict.go index cca78af..723ce85 100644 --- a/handler/dict.go +++ b/handler/dict.go @@ -13,6 +13,7 @@ import ( ) type Dict struct{} +type AddressDict struct{} func (e *Dict) ListRoot(ctx context.Context, req *empty.Empty, resp *libresp.ListResponse) error { log.Log("Received Dict.ListRoot request") @@ -85,3 +86,48 @@ func (e *Dict) ListCategory(ctx context.Context, req *wrappers.StringValue, resp resp.GenerateListResponseSucc(model.GetDictsAny(dicts)) return nil } + +//根据parent_id取数据 +func (e *AddressDict) GetParentlist(ctx context.Context, req *wrappers.StringValue, resp *libresp.ListResponse) error { + log.Log("Received Dict.GetPatient request") + dicts, err := database.GetParentlist(req.Value); + if err != nil { + resp.GenerateListResponseWithInfo(libresp.GENERAL_ERROR, err.Error()) + return nil + } + resp.GenerateListResponseSucc(model.GetDictsAny(dicts)) + return nil +} +//插入地址数据 +func (e *AddressDict) AddaddressDict(ctx context.Context, req *proto.AddaddressDictRequest, resp *libresp.GenericResponse) error { + log.Log("Received Dict.AddAddaddressDict request") + dict, err := database.NewaddressDict(req.Category, req.ParentId, req.Code, req.Name, req.PyCode, req.Type, req.Value) + if err != nil { + resp.GenerateGenericResponseWithInfo(libresp.GENERAL_ERROR, err.Error()) + return nil + } + resp.GenerateGenericResponseSucc(model.GetDictAny(dict)) + return nil +} + +func (e *AddressDict) GetAll(ctx context.Context,req *empty.Empty,resp *libresp.ListResponse) error { + log.Log("Received Dict.GetAll request") + dicts, err := database.GetParentlist(""); + if err != nil { + resp.GenerateListResponseWithInfo(libresp.GENERAL_ERROR, err.Error()) + return nil + } + resp.GenerateListResponseSucc(model.GetDictsAny(dicts)) + return nil +} +func (e *AddressDict) DeleteAddressDict(ctx context.Context,req *wrappers.StringValue, resp *libresp.Response) error { + log.Log("Received Dict.DeleteAddressDict request") + err := database.DeleteAddressDict(req.Value, true) + if err != nil { + resp.GenerateResponseWithInfo(libresp.GENERAL_ERROR, err.Error()) + } else { + resp.GenerateResponseSucc() + } + return nil +} + diff --git a/main.go b/main.go index b1ee899..c672ca6 100644 --- a/main.go +++ b/main.go @@ -24,6 +24,7 @@ func main() { // Register Handler proto.RegisterDictHandler(service.Server(), new(handler.Dict)) + proto.RegisterAddressDictHandler(service.Server(), new(handler.AddressDict)) // Register Struct as Subscriber micro.RegisterSubscriber(proto.ServiceName, service.Server(), new(subscriber.Dict)) diff --git a/proto/addressdict.pb.go b/proto/addressdict.pb.go new file mode 100644 index 0000000..4cf1bf0 --- /dev/null +++ b/proto/addressdict.pb.go @@ -0,0 +1,382 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// source: proto/addressdict.proto + +package proto + +import ( + context "context" + fmt "fmt" + proto "github.com/golang/protobuf/proto" + empty "github.com/golang/protobuf/ptypes/empty" + wrappers "github.com/golang/protobuf/ptypes/wrappers" + libresp "github.com/pku-hit/libresp" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + math "math" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package + +type AddressDictType int32 + +const ( + AddressDictType_country AddressDictType = 0 + AddressDictType_province AddressDictType = 1 + AddressDictType_city AddressDictType = 2 + AddressDictType_area AddressDictType = 3 + AddressDictType_street AddressDictType = 4 +) + +var AddressDictType_name = map[int32]string{ + 0: "country", + 1: "province", + 2: "city", + 3: "area", + 4: "street", +} + +var AddressDictType_value = map[string]int32{ + "country": 0, + "province": 1, + "city": 2, + "area": 3, + "street": 4, +} + +func (x AddressDictType) String() string { + return proto.EnumName(AddressDictType_name, int32(x)) +} + +func (AddressDictType) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_ebea7e01167d9568, []int{0} +} + +type AddaddressDictRequest struct { + Category string `protobuf:"bytes,1,opt,name=category,proto3" json:"category,omitempty"` + ParentId string `protobuf:"bytes,2,opt,name=parentId,proto3" json:"parentId,omitempty"` + Type AddressDictType `protobuf:"varint,3,opt,name=type,proto3,enum=proto.AddressDictType" json:"type,omitempty"` + Code string `protobuf:"bytes,4,opt,name=code,proto3" json:"code,omitempty"` + PyCode string `protobuf:"bytes,5,opt,name=pyCode,proto3" json:"pyCode,omitempty"` + Name string `protobuf:"bytes,6,opt,name=name,proto3" json:"name,omitempty"` + Value string `protobuf:"bytes,7,opt,name=value,proto3" json:"value,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *AddaddressDictRequest) Reset() { *m = AddaddressDictRequest{} } +func (m *AddaddressDictRequest) String() string { return proto.CompactTextString(m) } +func (*AddaddressDictRequest) ProtoMessage() {} +func (*AddaddressDictRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_ebea7e01167d9568, []int{0} +} + +func (m *AddaddressDictRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_AddaddressDictRequest.Unmarshal(m, b) +} +func (m *AddaddressDictRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_AddaddressDictRequest.Marshal(b, m, deterministic) +} +func (m *AddaddressDictRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_AddaddressDictRequest.Merge(m, src) +} +func (m *AddaddressDictRequest) XXX_Size() int { + return xxx_messageInfo_AddaddressDictRequest.Size(m) +} +func (m *AddaddressDictRequest) XXX_DiscardUnknown() { + xxx_messageInfo_AddaddressDictRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_AddaddressDictRequest proto.InternalMessageInfo + +func (m *AddaddressDictRequest) GetCategory() string { + if m != nil { + return m.Category + } + return "" +} + +func (m *AddaddressDictRequest) GetParentId() string { + if m != nil { + return m.ParentId + } + return "" +} + +func (m *AddaddressDictRequest) GetType() AddressDictType { + if m != nil { + return m.Type + } + return AddressDictType_country +} + +func (m *AddaddressDictRequest) GetCode() string { + if m != nil { + return m.Code + } + return "" +} + +func (m *AddaddressDictRequest) GetPyCode() string { + if m != nil { + return m.PyCode + } + return "" +} + +func (m *AddaddressDictRequest) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *AddaddressDictRequest) GetValue() string { + if m != nil { + return m.Value + } + return "" +} + +func init() { + proto.RegisterEnum("proto.AddressDictType", AddressDictType_name, AddressDictType_value) + proto.RegisterType((*AddaddressDictRequest)(nil), "proto.AddaddressDictRequest") +} + +func init() { proto.RegisterFile("proto/addressdict.proto", fileDescriptor_ebea7e01167d9568) } + +var fileDescriptor_ebea7e01167d9568 = []byte{ + // 415 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x51, 0xc1, 0x6e, 0xd3, 0x40, + 0x10, 0xad, 0x53, 0xc7, 0x0d, 0x53, 0x28, 0xee, 0x88, 0x06, 0xcb, 0x54, 0xa8, 0xea, 0xa9, 0xaa, + 0x14, 0x5b, 0x2a, 0x27, 0x8e, 0x11, 0x85, 0x08, 0xd4, 0x03, 0x0a, 0x88, 0xbb, 0xb3, 0x1e, 0xdc, + 0x15, 0xb6, 0x77, 0xd9, 0x1d, 0x17, 0xf9, 0x7f, 0xf8, 0x21, 0xfe, 0x08, 0x79, 0xed, 0x26, 0xa4, + 0x11, 0x3d, 0x79, 0xde, 0xbc, 0xf1, 0x9b, 0xd9, 0xf7, 0xe0, 0xa5, 0x36, 0x8a, 0x55, 0x9a, 0xe5, + 0xb9, 0x21, 0x6b, 0x73, 0x29, 0x38, 0x71, 0x1d, 0x1c, 0xbb, 0x4f, 0x3c, 0x2b, 0x24, 0xdf, 0x36, + 0xab, 0x44, 0xa8, 0x2a, 0xd5, 0x3f, 0x9a, 0xd9, 0xad, 0xe4, 0xb4, 0x94, 0x2b, 0x43, 0x56, 0xa7, + 0x95, 0x2d, 0x66, 0x5d, 0xa1, 0x6a, 0x4b, 0xfd, 0x5f, 0xf1, 0xab, 0x42, 0xa9, 0xa2, 0xa4, 0xd4, + 0xa1, 0x55, 0xf3, 0x3d, 0xa5, 0x4a, 0x73, 0x3b, 0x90, 0xaf, 0x1f, 0x92, 0xbf, 0x4c, 0xa6, 0x35, + 0x19, 0xdb, 0xf3, 0xe7, 0x7f, 0x3c, 0x38, 0x99, 0xe7, 0xf9, 0x70, 0xcb, 0xb5, 0x14, 0xbc, 0xa4, + 0x9f, 0x0d, 0x59, 0xc6, 0x18, 0x26, 0x22, 0x63, 0x2a, 0x94, 0x69, 0x23, 0xef, 0xcc, 0xbb, 0x78, + 0xb2, 0x5c, 0xe3, 0x8e, 0xd3, 0x99, 0xa1, 0x9a, 0x3f, 0xe6, 0xd1, 0xa8, 0xe7, 0xee, 0x31, 0x5e, + 0x82, 0xcf, 0xad, 0xa6, 0x68, 0xff, 0xcc, 0xbb, 0x38, 0xba, 0x9a, 0xf6, 0x7b, 0x92, 0xf9, 0x66, + 0xc1, 0xd7, 0x56, 0xd3, 0xd2, 0xcd, 0x20, 0x82, 0x2f, 0x54, 0x4e, 0x91, 0xef, 0x34, 0x5c, 0x8d, + 0x53, 0x08, 0x74, 0xfb, 0xae, 0xeb, 0x8e, 0x5d, 0x77, 0x40, 0xdd, 0x6c, 0x9d, 0x55, 0x14, 0x05, + 0xfd, 0x6c, 0x57, 0xe3, 0x0b, 0x18, 0xdf, 0x65, 0x65, 0x43, 0xd1, 0x81, 0x6b, 0xf6, 0xe0, 0xf2, + 0x06, 0x9e, 0x3f, 0x58, 0x87, 0x87, 0x70, 0x20, 0x54, 0x53, 0xb3, 0x69, 0xc3, 0x3d, 0x7c, 0x0a, + 0x13, 0x6d, 0xd4, 0x9d, 0xac, 0x05, 0x85, 0x1e, 0x4e, 0xc0, 0x17, 0x92, 0xdb, 0x70, 0xd4, 0x55, + 0x99, 0xa1, 0x2c, 0xdc, 0x47, 0x80, 0xc0, 0xb2, 0x21, 0xe2, 0xd0, 0xbf, 0xfa, 0x3d, 0x82, 0xc3, + 0x7f, 0xe4, 0xf0, 0x2d, 0x04, 0x0b, 0xe2, 0x79, 0x59, 0xe2, 0x34, 0xe9, 0xcd, 0x4d, 0xee, 0xcd, + 0x4d, 0xde, 0x77, 0xce, 0xc7, 0x27, 0xc9, 0x90, 0x56, 0x72, 0x23, 0x2d, 0x2f, 0x87, 0xb4, 0xce, + 0xf7, 0xf0, 0x03, 0x3c, 0x5b, 0x10, 0x7f, 0x76, 0x4e, 0x95, 0xd2, 0x32, 0x9e, 0xee, 0x28, 0x7c, + 0x61, 0x23, 0xeb, 0xe2, 0x5b, 0xf7, 0x8e, 0xff, 0xeb, 0x7c, 0x82, 0xa3, 0xed, 0xcc, 0xf0, 0x74, + 0x63, 0xf3, 0x6e, 0x94, 0x71, 0xb4, 0x16, 0x5a, 0x50, 0x4d, 0x46, 0x8a, 0xad, 0x9b, 0x8e, 0xaf, + 0xa9, 0x24, 0xa6, 0xf9, 0x96, 0xdc, 0x63, 0x77, 0x1d, 0xaf, 0xe5, 0x36, 0x3a, 0xab, 0xc0, 0x8d, + 0xbe, 0xf9, 0x1b, 0x00, 0x00, 0xff, 0xff, 0xd1, 0x45, 0x38, 0xf7, 0xdd, 0x02, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// AddressDictClient is the client API for AddressDict service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type AddressDictClient interface { + //全部 + GetAll(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*libresp.ListResponse, error) + //通过字典patientid获取指定节点 + GetParentlist(ctx context.Context, in *wrappers.StringValue, opts ...grpc.CallOption) (*libresp.ListResponse, error) + //添加地址字典数据 + AddaddressDict(ctx context.Context, in *AddaddressDictRequest, opts ...grpc.CallOption) (*libresp.GenericResponse, error) + //删除数据 + DeleteAddressDict(ctx context.Context, in *wrappers.StringValue, opts ...grpc.CallOption) (*libresp.Response, error) +} + +type addressDictClient struct { + cc *grpc.ClientConn +} + +func NewAddressDictClient(cc *grpc.ClientConn) AddressDictClient { + return &addressDictClient{cc} +} + +func (c *addressDictClient) GetAll(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*libresp.ListResponse, error) { + out := new(libresp.ListResponse) + err := c.cc.Invoke(ctx, "/proto.AddressDict/GetAll", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *addressDictClient) GetParentlist(ctx context.Context, in *wrappers.StringValue, opts ...grpc.CallOption) (*libresp.ListResponse, error) { + out := new(libresp.ListResponse) + err := c.cc.Invoke(ctx, "/proto.AddressDict/GetParentlist", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *addressDictClient) AddaddressDict(ctx context.Context, in *AddaddressDictRequest, opts ...grpc.CallOption) (*libresp.GenericResponse, error) { + out := new(libresp.GenericResponse) + err := c.cc.Invoke(ctx, "/proto.AddressDict/AddaddressDict", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *addressDictClient) DeleteAddressDict(ctx context.Context, in *wrappers.StringValue, opts ...grpc.CallOption) (*libresp.Response, error) { + out := new(libresp.Response) + err := c.cc.Invoke(ctx, "/proto.AddressDict/DeleteAddressDict", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// AddressDictServer is the server API for AddressDict service. +type AddressDictServer interface { + //全部 + GetAll(context.Context, *empty.Empty) (*libresp.ListResponse, error) + //通过字典patientid获取指定节点 + GetParentlist(context.Context, *wrappers.StringValue) (*libresp.ListResponse, error) + //添加地址字典数据 + AddaddressDict(context.Context, *AddaddressDictRequest) (*libresp.GenericResponse, error) + //删除数据 + DeleteAddressDict(context.Context, *wrappers.StringValue) (*libresp.Response, error) +} + +// UnimplementedAddressDictServer can be embedded to have forward compatible implementations. +type UnimplementedAddressDictServer struct { +} + +func (*UnimplementedAddressDictServer) GetAll(ctx context.Context, req *empty.Empty) (*libresp.ListResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetAll not implemented") +} +func (*UnimplementedAddressDictServer) GetParentlist(ctx context.Context, req *wrappers.StringValue) (*libresp.ListResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetParentlist not implemented") +} +func (*UnimplementedAddressDictServer) AddaddressDict(ctx context.Context, req *AddaddressDictRequest) (*libresp.GenericResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method AddaddressDict not implemented") +} +func (*UnimplementedAddressDictServer) DeleteAddressDict(ctx context.Context, req *wrappers.StringValue) (*libresp.Response, error) { + return nil, status.Errorf(codes.Unimplemented, "method DeleteAddressDict not implemented") +} + +func RegisterAddressDictServer(s *grpc.Server, srv AddressDictServer) { + s.RegisterService(&_AddressDict_serviceDesc, srv) +} + +func _AddressDict_GetAll_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(empty.Empty) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AddressDictServer).GetAll(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/proto.AddressDict/GetAll", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AddressDictServer).GetAll(ctx, req.(*empty.Empty)) + } + return interceptor(ctx, in, info, handler) +} + +func _AddressDict_GetParentlist_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(wrappers.StringValue) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AddressDictServer).GetParentlist(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/proto.AddressDict/GetParentlist", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AddressDictServer).GetParentlist(ctx, req.(*wrappers.StringValue)) + } + return interceptor(ctx, in, info, handler) +} + +func _AddressDict_AddaddressDict_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(AddaddressDictRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AddressDictServer).AddaddressDict(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/proto.AddressDict/AddaddressDict", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AddressDictServer).AddaddressDict(ctx, req.(*AddaddressDictRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _AddressDict_DeleteAddressDict_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(wrappers.StringValue) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AddressDictServer).DeleteAddressDict(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/proto.AddressDict/DeleteAddressDict", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AddressDictServer).DeleteAddressDict(ctx, req.(*wrappers.StringValue)) + } + return interceptor(ctx, in, info, handler) +} + +var _AddressDict_serviceDesc = grpc.ServiceDesc{ + ServiceName: "proto.AddressDict", + HandlerType: (*AddressDictServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "GetAll", + Handler: _AddressDict_GetAll_Handler, + }, + { + MethodName: "GetParentlist", + Handler: _AddressDict_GetParentlist_Handler, + }, + { + MethodName: "AddaddressDict", + Handler: _AddressDict_AddaddressDict_Handler, + }, + { + MethodName: "DeleteAddressDict", + Handler: _AddressDict_DeleteAddressDict_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "proto/addressdict.proto", +} diff --git a/proto/addressdict.pb.micro.go b/proto/addressdict.pb.micro.go new file mode 100644 index 0000000..fa97a38 --- /dev/null +++ b/proto/addressdict.pb.micro.go @@ -0,0 +1,155 @@ +// Code generated by protoc-gen-micro. DO NOT EDIT. +// source: proto/addressdict.proto + +package proto + +import ( + fmt "fmt" + proto "github.com/golang/protobuf/proto" + empty "github.com/golang/protobuf/ptypes/empty" + wrappers "github.com/golang/protobuf/ptypes/wrappers" + libresp "github.com/pku-hit/libresp" + math "math" +) + +import ( + context "context" + api "github.com/micro/go-micro/v2/api" + client "github.com/micro/go-micro/v2/client" + server "github.com/micro/go-micro/v2/server" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package + +// Reference imports to suppress errors if they are not otherwise used. +var _ api.Endpoint +var _ context.Context +var _ client.Option +var _ server.Option + +// Api Endpoints for AddressDict service + +func NewAddressDictEndpoints() []*api.Endpoint { + return []*api.Endpoint{} +} + +// Client API for AddressDict service + +type AddressDictService interface { + //全部 + GetAll(ctx context.Context, in *empty.Empty, opts ...client.CallOption) (*libresp.ListResponse, error) + //通过字典patientid获取指定节点 + GetParentlist(ctx context.Context, in *wrappers.StringValue, opts ...client.CallOption) (*libresp.ListResponse, error) + //添加地址字典数据 + AddaddressDict(ctx context.Context, in *AddaddressDictRequest, opts ...client.CallOption) (*libresp.GenericResponse, error) + //删除数据 + DeleteAddressDict(ctx context.Context, in *wrappers.StringValue, opts ...client.CallOption) (*libresp.Response, error) +} + +type addressDictService struct { + c client.Client + name string +} + +func NewAddressDictService(name string, c client.Client) AddressDictService { + return &addressDictService{ + c: c, + name: name, + } +} + +func (c *addressDictService) GetAll(ctx context.Context, in *empty.Empty, opts ...client.CallOption) (*libresp.ListResponse, error) { + req := c.c.NewRequest(c.name, "AddressDict.GetAll", in) + out := new(libresp.ListResponse) + err := c.c.Call(ctx, req, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *addressDictService) GetParentlist(ctx context.Context, in *wrappers.StringValue, opts ...client.CallOption) (*libresp.ListResponse, error) { + req := c.c.NewRequest(c.name, "AddressDict.GetParentlist", in) + out := new(libresp.ListResponse) + err := c.c.Call(ctx, req, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *addressDictService) AddaddressDict(ctx context.Context, in *AddaddressDictRequest, opts ...client.CallOption) (*libresp.GenericResponse, error) { + req := c.c.NewRequest(c.name, "AddressDict.AddaddressDict", in) + out := new(libresp.GenericResponse) + err := c.c.Call(ctx, req, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *addressDictService) DeleteAddressDict(ctx context.Context, in *wrappers.StringValue, opts ...client.CallOption) (*libresp.Response, error) { + req := c.c.NewRequest(c.name, "AddressDict.DeleteAddressDict", in) + out := new(libresp.Response) + err := c.c.Call(ctx, req, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// Server API for AddressDict service + +type AddressDictHandler interface { + //全部 + GetAll(context.Context, *empty.Empty, *libresp.ListResponse) error + //通过字典patientid获取指定节点 + GetParentlist(context.Context, *wrappers.StringValue, *libresp.ListResponse) error + //添加地址字典数据 + AddaddressDict(context.Context, *AddaddressDictRequest, *libresp.GenericResponse) error + //删除数据 + DeleteAddressDict(context.Context, *wrappers.StringValue, *libresp.Response) error +} + +func RegisterAddressDictHandler(s server.Server, hdlr AddressDictHandler, opts ...server.HandlerOption) error { + type addressDict interface { + GetAll(ctx context.Context, in *empty.Empty, out *libresp.ListResponse) error + GetParentlist(ctx context.Context, in *wrappers.StringValue, out *libresp.ListResponse) error + AddaddressDict(ctx context.Context, in *AddaddressDictRequest, out *libresp.GenericResponse) error + DeleteAddressDict(ctx context.Context, in *wrappers.StringValue, out *libresp.Response) error + } + type AddressDict struct { + addressDict + } + h := &addressDictHandler{hdlr} + return s.Handle(s.NewHandler(&AddressDict{h}, opts...)) +} + +type addressDictHandler struct { + AddressDictHandler +} + +func (h *addressDictHandler) GetAll(ctx context.Context, in *empty.Empty, out *libresp.ListResponse) error { + return h.AddressDictHandler.GetAll(ctx, in, out) +} + +func (h *addressDictHandler) GetParentlist(ctx context.Context, in *wrappers.StringValue, out *libresp.ListResponse) error { + return h.AddressDictHandler.GetParentlist(ctx, in, out) +} + +func (h *addressDictHandler) AddaddressDict(ctx context.Context, in *AddaddressDictRequest, out *libresp.GenericResponse) error { + return h.AddressDictHandler.AddaddressDict(ctx, in, out) +} + +func (h *addressDictHandler) DeleteAddressDict(ctx context.Context, in *wrappers.StringValue, out *libresp.Response) error { + return h.AddressDictHandler.DeleteAddressDict(ctx, in, out) +} diff --git a/proto/addressdict.proto b/proto/addressdict.proto new file mode 100644 index 0000000..decdc8e --- /dev/null +++ b/proto/addressdict.proto @@ -0,0 +1,41 @@ +syntax = "proto3"; + +import "github.com/pku-hit/libresp/msg-response.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/wrappers.proto"; + +package proto; + +service AddressDict { + //全部 + rpc GetAll(google.protobuf.Empty) returns(libresp.ListResponse){ + } + //通过字典patientid获取指定节点 + rpc GetParentlist (google.protobuf.StringValue) returns (libresp.ListResponse){ + } + //添加地址字典数据 + rpc AddaddressDict (AddaddressDictRequest) returns (libresp.GenericResponse){ + } + //删除数据 + rpc DeleteAddressDict(google.protobuf.StringValue) returns (libresp.Response){ + } +} +enum AddressDictType { + country= 0; + province= 1; + city = 2; + area = 3; + street = 4; +} + +message AddaddressDictRequest { + string category = 1; + string parentId = 2; + AddressDictType type = 3; + string code = 4; + string pyCode = 5; + string name = 6; + string value = 7; +} + + -- Gitee From 8a5edcd5b5fc03cc694eab0aca5e4c2c9c3b22d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=99=E8=80=80=E5=8D=8E?= <793339602@qq.com> Date: Thu, 2 Jul 2020 23:46:13 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=88=A0=E9=99=A4addressdict.proto?= =?UTF-8?q?=EF=BC=8C=E5=88=86=E5=BC=80=E6=AF=8F=E4=B8=80=E7=BB=84=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E5=AF=B9=E5=BA=94=E4=B8=80=E7=BB=84=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- component/database/addressdict_info_dao.go | 80 ++++ component/database/dict_info_dao.go | 4 +- handler/addressdict.go | 71 ++++ handler/dict.go | 46 --- proto/countries_regions.pb.go | 407 ++++++++++++++++++++- proto/countries_regions.pb.micro.go | 153 ++++++++ proto/countries_regions.proto | 42 ++- proto/dict.pb.go | 12 +- 8 files changed, 748 insertions(+), 67 deletions(-) create mode 100644 component/database/addressdict_info_dao.go create mode 100644 handler/addressdict.go diff --git a/component/database/addressdict_info_dao.go b/component/database/addressdict_info_dao.go new file mode 100644 index 0000000..6ba3faf --- /dev/null +++ b/component/database/addressdict_info_dao.go @@ -0,0 +1,80 @@ +package database + +import ( + "errors" + "fmt" + "github.com/jinzhu/gorm" + "github.com/micro/go-micro/util/log" + "github.com/pku-hit/dict/model/entity" + "github.com/pku-hit/dict/proto" + "github.com/pku-hit/dict/util" + "time" +) + +func NewaddressDict(category, parentId, code, name, pyCode string, dictType proto.AddressDictType, value interface{}) (dict *entity.DictInfo, err error) { + + if dict, err = ExistDictWithCode(code); err == nil && dict != nil { + log.Warnf("exist dict: %s", util.Json.ToJsonString(dict)) + fmt.Println("存在该数据!code不能重复!") + return + } + now := time.Now() + dict = &entity.DictInfo{ + ID: util.Snowflake.GenId(), + Code: code, + Name: name, + PyCode: pyCode, + Value: util.Json.ToJsonString(value), + Status: proto.DictStatus_Normal.String(), + CreateAt: &now, + UpdateAt: &now, + } + + if util.String.IsEmptyString(parentId) { + err = errors.New("没有指定ParentId的字典") + return + } else { + if dictType == proto.AddressDictType_country { + dict.Type = proto.AddressDictType_country.String() + } else if dictType == proto.AddressDictType_province { + dict.Type = proto.AddressDictType_province.String() + } else if dictType == proto.AddressDictType_city { + dict.Type = proto.AddressDictType_city.String() + } else if dictType == proto.AddressDictType_area { + dict.Type = proto.AddressDictType_area.String() + } else if dictType == proto.AddressDictType_street{ + dict.Type = proto.AddressDictType_street.String() + } else { + dict.Type = "" + } + dict.ParentId = parentId + dict.Type = dictType.String() + } + dict.Category = "address" + err = db.Save(dict).Error + //db.s + if err != nil { + log.Error("save new dict error %s.", err.Error()) + } + return +} + +//根据code删除数据 + +func DeleteAddressDict(code string, soft bool) (err error) { + dict, err := ExistDictWithCode(code) + if err == gorm.ErrRecordNotFound { + return + } + now := time.Now() + if soft { + dict.Status = proto.DictStatus_Deleted.String() + dict.DeleteAt = &now + log.Info(util.Json.StructToMap(dict)) + err = db.Model(dict).Select("status", "delete_at").Update(util.Json.StructToMap(dict)).Error + } else { + err = db.Where("code = ?", code).Delete(new(entity.DictInfo)).Error + } + return +} + diff --git a/component/database/dict_info_dao.go b/component/database/dict_info_dao.go index 5d89f60..15436fd 100644 --- a/component/database/dict_info_dao.go +++ b/component/database/dict_info_dao.go @@ -2,7 +2,6 @@ package database import ( "errors" - "fmt" "github.com/jinzhu/gorm" "github.com/micro/go-micro/util/log" "github.com/pku-hit/dict/model/entity" @@ -154,6 +153,7 @@ func ExistDictWithCode(code string) (dict *entity.DictInfo, err error) { } return } +/* func NewaddressDict(category, parentId, code, name, pyCode string, dictType proto.AddressDictType, value interface{}) (dict *entity.DictInfo, err error) { if dict, err = ExistDictWithCode(code); err == nil && dict != nil { @@ -219,4 +219,4 @@ func DeleteAddressDict(code string, soft bool) (err error) { err = db.Where("code = ?", code).Delete(new(entity.DictInfo)).Error } return -} +}*/ diff --git a/handler/addressdict.go b/handler/addressdict.go new file mode 100644 index 0000000..1e1c198 --- /dev/null +++ b/handler/addressdict.go @@ -0,0 +1,71 @@ +package handler + +import ( + "context" + "github.com/golang/protobuf/ptypes/empty" + "github.com/golang/protobuf/ptypes/wrappers" + "github.com/micro/go-micro/util/log" + "github.com/pku-hit/dict/component/database" + "github.com/pku-hit/dict/model" + "github.com/pku-hit/dict/proto" + + "github.com/pku-hit/libresp" +) + +type AddressDict struct{} + +//获取国家列表 +func (e *AddressDict) Countrieslist(ctx context.Context, req *empty.Empty, resp *libresp.ListResponse) error { + log.Log("Received Dict.GetPatient request") + dicts, err := database.GetParentlist("0"); + if err != nil { + resp.GenerateListResponseWithInfo(libresp.GENERAL_ERROR, err.Error()) + return nil + } + resp.GenerateListResponseSucc(model.GetDictsAny(dicts)) + return nil +} + +//根据parent_id取数据 +func (e *AddressDict) GetParentlist(ctx context.Context, req *wrappers.StringValue, resp *libresp.ListResponse) error { + log.Log("Received Dict.GetPatient request") + dicts, err := database.GetParentlist(req.Value); + if err != nil { + resp.GenerateListResponseWithInfo(libresp.GENERAL_ERROR, err.Error()) + return nil + } + resp.GenerateListResponseSucc(model.GetDictsAny(dicts)) + return nil +} +//插入地址数据 +func (e *AddressDict) AddaddressDict(ctx context.Context, req *proto.AddaddressDictRequest, resp *libresp.GenericResponse) error { + log.Log("Received Dict.AddAddaddressDict request") + dict, err := database.NewaddressDict(req.Category, req.ParentId, req.Code, req.Name, req.PyCode, req.Type, req.Value) + if err != nil { + resp.GenerateGenericResponseWithInfo(libresp.GENERAL_ERROR, err.Error()) + return nil + } + resp.GenerateGenericResponseSucc(model.GetDictAny(dict)) + return nil +} + +func (e *AddressDict) GetAll(ctx context.Context,req *empty.Empty,resp *libresp.ListResponse) error { + log.Log("Received Dict.GetAll request") + dicts, err := database.GetParentlist(""); + if err != nil { + resp.GenerateListResponseWithInfo(libresp.GENERAL_ERROR, err.Error()) + return nil + } + resp.GenerateListResponseSucc(model.GetDictsAny(dicts)) + return nil +} +func (e *AddressDict) DeleteAddressDict(ctx context.Context,req *wrappers.StringValue, resp *libresp.Response) error { + log.Log("Received Dict.DeleteAddressDict request") + err := database.DeleteAddressDict(req.Value, true) + if err != nil { + resp.GenerateResponseWithInfo(libresp.GENERAL_ERROR, err.Error()) + } else { + resp.GenerateResponseSucc() + } + return nil +} \ No newline at end of file diff --git a/handler/dict.go b/handler/dict.go index 723ce85..cca78af 100644 --- a/handler/dict.go +++ b/handler/dict.go @@ -13,7 +13,6 @@ import ( ) type Dict struct{} -type AddressDict struct{} func (e *Dict) ListRoot(ctx context.Context, req *empty.Empty, resp *libresp.ListResponse) error { log.Log("Received Dict.ListRoot request") @@ -86,48 +85,3 @@ func (e *Dict) ListCategory(ctx context.Context, req *wrappers.StringValue, resp resp.GenerateListResponseSucc(model.GetDictsAny(dicts)) return nil } - -//根据parent_id取数据 -func (e *AddressDict) GetParentlist(ctx context.Context, req *wrappers.StringValue, resp *libresp.ListResponse) error { - log.Log("Received Dict.GetPatient request") - dicts, err := database.GetParentlist(req.Value); - if err != nil { - resp.GenerateListResponseWithInfo(libresp.GENERAL_ERROR, err.Error()) - return nil - } - resp.GenerateListResponseSucc(model.GetDictsAny(dicts)) - return nil -} -//插入地址数据 -func (e *AddressDict) AddaddressDict(ctx context.Context, req *proto.AddaddressDictRequest, resp *libresp.GenericResponse) error { - log.Log("Received Dict.AddAddaddressDict request") - dict, err := database.NewaddressDict(req.Category, req.ParentId, req.Code, req.Name, req.PyCode, req.Type, req.Value) - if err != nil { - resp.GenerateGenericResponseWithInfo(libresp.GENERAL_ERROR, err.Error()) - return nil - } - resp.GenerateGenericResponseSucc(model.GetDictAny(dict)) - return nil -} - -func (e *AddressDict) GetAll(ctx context.Context,req *empty.Empty,resp *libresp.ListResponse) error { - log.Log("Received Dict.GetAll request") - dicts, err := database.GetParentlist(""); - if err != nil { - resp.GenerateListResponseWithInfo(libresp.GENERAL_ERROR, err.Error()) - return nil - } - resp.GenerateListResponseSucc(model.GetDictsAny(dicts)) - return nil -} -func (e *AddressDict) DeleteAddressDict(ctx context.Context,req *wrappers.StringValue, resp *libresp.Response) error { - log.Log("Received Dict.DeleteAddressDict request") - err := database.DeleteAddressDict(req.Value, true) - if err != nil { - resp.GenerateResponseWithInfo(libresp.GENERAL_ERROR, err.Error()) - } else { - resp.GenerateResponseSucc() - } - return nil -} - diff --git a/proto/countries_regions.pb.go b/proto/countries_regions.pb.go index 8e4edbc..c2cb5a1 100644 --- a/proto/countries_regions.pb.go +++ b/proto/countries_regions.pb.go @@ -4,8 +4,15 @@ package proto import ( + context "context" fmt "fmt" proto "github.com/golang/protobuf/proto" + empty "github.com/golang/protobuf/ptypes/empty" + wrappers "github.com/golang/protobuf/ptypes/wrappers" + libresp "github.com/pku-hit/libresp" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" math "math" ) @@ -48,21 +55,399 @@ func (CountryCode) EnumDescriptor() ([]byte, []int) { return fileDescriptor_c5f9860c393ac2d9, []int{0} } -func init() { - proto.RegisterEnum("proto.CountryCode", CountryCode_name, CountryCode_value) +type AddressDictType int32 + +const ( + AddressDictType_country AddressDictType = 0 + AddressDictType_province AddressDictType = 1 + AddressDictType_city AddressDictType = 2 + AddressDictType_area AddressDictType = 3 + AddressDictType_street AddressDictType = 4 +) + +var AddressDictType_name = map[int32]string{ + 0: "country", + 1: "province", + 2: "city", + 3: "area", + 4: "street", +} + +var AddressDictType_value = map[string]int32{ + "country": 0, + "province": 1, + "city": 2, + "area": 3, + "street": 4, +} + +func (x AddressDictType) String() string { + return proto.EnumName(AddressDictType_name, int32(x)) +} + +func (AddressDictType) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_c5f9860c393ac2d9, []int{1} +} + +type AddaddressDictRequest struct { + Category string `protobuf:"bytes,1,opt,name=category,proto3" json:"category,omitempty"` + ParentId string `protobuf:"bytes,2,opt,name=parentId,proto3" json:"parentId,omitempty"` + Type AddressDictType `protobuf:"varint,3,opt,name=type,proto3,enum=proto.AddressDictType" json:"type,omitempty"` + Code string `protobuf:"bytes,4,opt,name=code,proto3" json:"code,omitempty"` + PyCode string `protobuf:"bytes,5,opt,name=pyCode,proto3" json:"pyCode,omitempty"` + Name string `protobuf:"bytes,6,opt,name=name,proto3" json:"name,omitempty"` + Value string `protobuf:"bytes,7,opt,name=value,proto3" json:"value,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *AddaddressDictRequest) Reset() { *m = AddaddressDictRequest{} } +func (m *AddaddressDictRequest) String() string { return proto.CompactTextString(m) } +func (*AddaddressDictRequest) ProtoMessage() {} +func (*AddaddressDictRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_c5f9860c393ac2d9, []int{0} +} + +func (m *AddaddressDictRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_AddaddressDictRequest.Unmarshal(m, b) +} +func (m *AddaddressDictRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_AddaddressDictRequest.Marshal(b, m, deterministic) +} +func (m *AddaddressDictRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_AddaddressDictRequest.Merge(m, src) +} +func (m *AddaddressDictRequest) XXX_Size() int { + return xxx_messageInfo_AddaddressDictRequest.Size(m) +} +func (m *AddaddressDictRequest) XXX_DiscardUnknown() { + xxx_messageInfo_AddaddressDictRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_AddaddressDictRequest proto.InternalMessageInfo + +func (m *AddaddressDictRequest) GetCategory() string { + if m != nil { + return m.Category + } + return "" +} + +func (m *AddaddressDictRequest) GetParentId() string { + if m != nil { + return m.ParentId + } + return "" +} + +func (m *AddaddressDictRequest) GetType() AddressDictType { + if m != nil { + return m.Type + } + return AddressDictType_country +} + +func (m *AddaddressDictRequest) GetCode() string { + if m != nil { + return m.Code + } + return "" +} + +func (m *AddaddressDictRequest) GetPyCode() string { + if m != nil { + return m.PyCode + } + return "" +} + +func (m *AddaddressDictRequest) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *AddaddressDictRequest) GetValue() string { + if m != nil { + return m.Value + } + return "" } func init() { - proto.RegisterFile("proto/countries_regions.proto", fileDescriptor_c5f9860c393ac2d9) + proto.RegisterEnum("proto.CountryCode", CountryCode_name, CountryCode_value) + proto.RegisterEnum("proto.AddressDictType", AddressDictType_name, AddressDictType_value) + proto.RegisterType((*AddaddressDictRequest)(nil), "proto.AddaddressDictRequest") } +func init() { proto.RegisterFile("proto/countries_regions.proto", fileDescriptor_c5f9860c393ac2d9) } + var fileDescriptor_c5f9860c393ac2d9 = []byte{ - // 109 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2d, 0x28, 0xca, 0x2f, - 0xc9, 0xd7, 0x4f, 0xce, 0x2f, 0xcd, 0x2b, 0x29, 0xca, 0x4c, 0x2d, 0x8e, 0x2f, 0x4a, 0x4d, 0xcf, - 0xcc, 0xcf, 0x2b, 0xd6, 0x03, 0x8b, 0x0b, 0xb1, 0x82, 0x29, 0x2d, 0x73, 0x2e, 0x6e, 0x67, 0xb0, - 0x8a, 0x4a, 0xe7, 0xfc, 0x94, 0x54, 0x21, 0x7e, 0x2e, 0x6e, 0xff, 0xdc, 0xcc, 0x12, 0xa8, 0x90, - 0x00, 0x83, 0x10, 0x0f, 0x17, 0x87, 0x63, 0x6e, 0x6a, 0x51, 0x66, 0x72, 0x62, 0x9e, 0x00, 0xa3, - 0x10, 0x27, 0x17, 0xab, 0x73, 0x46, 0x66, 0x5e, 0xa2, 0x40, 0x58, 0x12, 0x1b, 0x58, 0xbf, 0x31, - 0x20, 0x00, 0x00, 0xff, 0xff, 0x4d, 0x32, 0x75, 0x02, 0x67, 0x00, 0x00, 0x00, + // 467 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x53, 0xc1, 0x6e, 0xd3, 0x40, + 0x10, 0xad, 0xdb, 0x24, 0x4d, 0x27, 0xb4, 0x75, 0x57, 0x34, 0xb2, 0x42, 0x41, 0x55, 0x4f, 0x55, + 0xa4, 0xd8, 0x52, 0x39, 0x20, 0x6e, 0x58, 0x29, 0x44, 0xa0, 0x4a, 0xa0, 0x80, 0x7a, 0x45, 0x1b, + 0x7b, 0x70, 0x56, 0xd8, 0xbb, 0xcb, 0xee, 0xb8, 0xc8, 0x9f, 0xc9, 0x4f, 0xf0, 0x1d, 0xc8, 0x6b, + 0x27, 0x4d, 0x5a, 0x81, 0xc4, 0xc9, 0x33, 0x6f, 0x66, 0xde, 0x8c, 0xdf, 0xb3, 0xe1, 0xb9, 0x36, + 0x8a, 0x54, 0x94, 0xa8, 0x52, 0x92, 0x11, 0x68, 0xbf, 0x1a, 0xcc, 0x84, 0x92, 0x36, 0x74, 0x38, + 0xeb, 0xba, 0xc7, 0x68, 0x92, 0x09, 0x5a, 0x96, 0x8b, 0x30, 0x51, 0x45, 0xa4, 0xbf, 0x97, 0x93, + 0xa5, 0xa0, 0x28, 0x17, 0x0b, 0x83, 0x56, 0x47, 0x85, 0xcd, 0x26, 0x75, 0xa0, 0xa4, 0xc5, 0x66, + 0x6a, 0xf4, 0x2c, 0x53, 0x2a, 0xcb, 0x31, 0x72, 0xd9, 0xa2, 0xfc, 0x16, 0x61, 0xa1, 0xa9, 0x6a, + 0x8b, 0x2f, 0x1e, 0x16, 0x7f, 0x1a, 0xae, 0x35, 0x9a, 0x76, 0xe5, 0xc5, 0x2f, 0x0f, 0x4e, 0xe3, + 0x34, 0xe5, 0x69, 0x6a, 0xd0, 0xda, 0x6b, 0x91, 0xd0, 0x1c, 0x7f, 0x94, 0x68, 0x89, 0x8d, 0xa0, + 0x9f, 0x70, 0xc2, 0x4c, 0x99, 0x2a, 0xf0, 0xce, 0xbd, 0xcb, 0x83, 0xf9, 0x3a, 0xaf, 0x6b, 0x9a, + 0x1b, 0x94, 0xf4, 0x3e, 0x0d, 0x76, 0x9b, 0xda, 0x2a, 0x67, 0x63, 0xe8, 0x50, 0xa5, 0x31, 0xd8, + 0x3b, 0xf7, 0x2e, 0x8f, 0xae, 0x86, 0xcd, 0x9e, 0x30, 0xbe, 0x5f, 0xf0, 0xa5, 0xd2, 0x38, 0x77, + 0x3d, 0x8c, 0x41, 0x27, 0x51, 0x29, 0x06, 0x1d, 0xc7, 0xe1, 0x62, 0x36, 0x84, 0x9e, 0xae, 0xa6, + 0x35, 0xda, 0x75, 0x68, 0x9b, 0xd5, 0xbd, 0x92, 0x17, 0x18, 0xf4, 0x9a, 0xde, 0x3a, 0x66, 0x4f, + 0xa1, 0x7b, 0xc7, 0xf3, 0x12, 0x83, 0x7d, 0x07, 0x36, 0xc9, 0xf8, 0x15, 0x0c, 0xa6, 0x4e, 0xe1, + 0x66, 0xf0, 0x18, 0x06, 0x1f, 0x0b, 0x41, 0x2d, 0xe4, 0xef, 0xb0, 0x27, 0xd0, 0x8f, 0x0b, 0x34, + 0x22, 0xe1, 0xd2, 0xf7, 0xd8, 0x01, 0x74, 0xa7, 0x4b, 0x21, 0xb9, 0x7f, 0x3b, 0xbe, 0x81, 0xe3, + 0x07, 0x77, 0xb2, 0x01, 0xec, 0x27, 0x9b, 0x83, 0xda, 0xa8, 0x3b, 0x21, 0x13, 0xf4, 0x3d, 0xd6, + 0x87, 0x4e, 0x22, 0xa8, 0xf2, 0x77, 0xeb, 0x88, 0x1b, 0xe4, 0xfe, 0x1e, 0x03, 0xe8, 0x59, 0x32, + 0x88, 0xe4, 0x77, 0xae, 0x7e, 0xef, 0xc2, 0x60, 0x83, 0x8e, 0xbd, 0x86, 0xde, 0x0c, 0x29, 0xce, + 0x73, 0x36, 0x0c, 0x1b, 0x57, 0xc2, 0x95, 0x2b, 0xe1, 0xdb, 0xda, 0xb2, 0xd1, 0x69, 0xd8, 0xda, + 0x1c, 0xde, 0x08, 0x4b, 0xf3, 0xd6, 0xe6, 0x8b, 0x1d, 0xf6, 0x0e, 0x0e, 0x67, 0x48, 0x9f, 0x9c, + 0xc4, 0xb9, 0xb0, 0xc4, 0xce, 0x1e, 0x31, 0x7c, 0x26, 0x23, 0x64, 0x76, 0x5b, 0x0b, 0xf0, 0x77, + 0x9e, 0x0f, 0x70, 0xb4, 0x6d, 0x36, 0x3b, 0xbb, 0xf7, 0xe7, 0xf1, 0x37, 0x30, 0x0a, 0xd6, 0x44, + 0x33, 0x94, 0xb5, 0x62, 0x5b, 0x37, 0x9d, 0x5c, 0x63, 0x8e, 0x84, 0xf1, 0x16, 0xdd, 0xbf, 0xee, + 0x3a, 0x59, 0xd3, 0x6d, 0xf0, 0xbc, 0x81, 0xc3, 0xe9, 0xea, 0x7f, 0x70, 0xef, 0xf6, 0xbf, 0xea, + 0x2c, 0x7a, 0xae, 0xf1, 0xe5, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xa1, 0xae, 0x34, 0xfa, 0x5e, + 0x03, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// AddressDictClient is the client API for AddressDict service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type AddressDictClient interface { + //全部 + GetAll(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*libresp.ListResponse, error) + //通过字典patientid获取指定节点 + GetParentlist(ctx context.Context, in *wrappers.StringValue, opts ...grpc.CallOption) (*libresp.ListResponse, error) + //添加地址字典数据 + AddaddressDict(ctx context.Context, in *AddaddressDictRequest, opts ...grpc.CallOption) (*libresp.GenericResponse, error) + //删除数据 + DeleteAddressDict(ctx context.Context, in *wrappers.StringValue, opts ...grpc.CallOption) (*libresp.Response, error) + //国家 + Countrieslist(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*libresp.ListResponse, error) +} + +type addressDictClient struct { + cc *grpc.ClientConn +} + +func NewAddressDictClient(cc *grpc.ClientConn) AddressDictClient { + return &addressDictClient{cc} +} + +func (c *addressDictClient) GetAll(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*libresp.ListResponse, error) { + out := new(libresp.ListResponse) + err := c.cc.Invoke(ctx, "/proto.AddressDict/GetAll", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *addressDictClient) GetParentlist(ctx context.Context, in *wrappers.StringValue, opts ...grpc.CallOption) (*libresp.ListResponse, error) { + out := new(libresp.ListResponse) + err := c.cc.Invoke(ctx, "/proto.AddressDict/GetParentlist", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *addressDictClient) AddaddressDict(ctx context.Context, in *AddaddressDictRequest, opts ...grpc.CallOption) (*libresp.GenericResponse, error) { + out := new(libresp.GenericResponse) + err := c.cc.Invoke(ctx, "/proto.AddressDict/AddaddressDict", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *addressDictClient) DeleteAddressDict(ctx context.Context, in *wrappers.StringValue, opts ...grpc.CallOption) (*libresp.Response, error) { + out := new(libresp.Response) + err := c.cc.Invoke(ctx, "/proto.AddressDict/DeleteAddressDict", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *addressDictClient) Countrieslist(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*libresp.ListResponse, error) { + out := new(libresp.ListResponse) + err := c.cc.Invoke(ctx, "/proto.AddressDict/Countrieslist", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// AddressDictServer is the server API for AddressDict service. +type AddressDictServer interface { + //全部 + GetAll(context.Context, *empty.Empty) (*libresp.ListResponse, error) + //通过字典patientid获取指定节点 + GetParentlist(context.Context, *wrappers.StringValue) (*libresp.ListResponse, error) + //添加地址字典数据 + AddaddressDict(context.Context, *AddaddressDictRequest) (*libresp.GenericResponse, error) + //删除数据 + DeleteAddressDict(context.Context, *wrappers.StringValue) (*libresp.Response, error) + //国家 + Countrieslist(context.Context, *empty.Empty) (*libresp.ListResponse, error) +} + +// UnimplementedAddressDictServer can be embedded to have forward compatible implementations. +type UnimplementedAddressDictServer struct { +} + +func (*UnimplementedAddressDictServer) GetAll(ctx context.Context, req *empty.Empty) (*libresp.ListResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetAll not implemented") +} +func (*UnimplementedAddressDictServer) GetParentlist(ctx context.Context, req *wrappers.StringValue) (*libresp.ListResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetParentlist not implemented") +} +func (*UnimplementedAddressDictServer) AddaddressDict(ctx context.Context, req *AddaddressDictRequest) (*libresp.GenericResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method AddaddressDict not implemented") +} +func (*UnimplementedAddressDictServer) DeleteAddressDict(ctx context.Context, req *wrappers.StringValue) (*libresp.Response, error) { + return nil, status.Errorf(codes.Unimplemented, "method DeleteAddressDict not implemented") +} +func (*UnimplementedAddressDictServer) Countrieslist(ctx context.Context, req *empty.Empty) (*libresp.ListResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Countrieslist not implemented") +} + +func RegisterAddressDictServer(s *grpc.Server, srv AddressDictServer) { + s.RegisterService(&_AddressDict_serviceDesc, srv) +} + +func _AddressDict_GetAll_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(empty.Empty) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AddressDictServer).GetAll(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/proto.AddressDict/GetAll", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AddressDictServer).GetAll(ctx, req.(*empty.Empty)) + } + return interceptor(ctx, in, info, handler) +} + +func _AddressDict_GetParentlist_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(wrappers.StringValue) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AddressDictServer).GetParentlist(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/proto.AddressDict/GetParentlist", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AddressDictServer).GetParentlist(ctx, req.(*wrappers.StringValue)) + } + return interceptor(ctx, in, info, handler) +} + +func _AddressDict_AddaddressDict_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(AddaddressDictRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AddressDictServer).AddaddressDict(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/proto.AddressDict/AddaddressDict", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AddressDictServer).AddaddressDict(ctx, req.(*AddaddressDictRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _AddressDict_DeleteAddressDict_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(wrappers.StringValue) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AddressDictServer).DeleteAddressDict(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/proto.AddressDict/DeleteAddressDict", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AddressDictServer).DeleteAddressDict(ctx, req.(*wrappers.StringValue)) + } + return interceptor(ctx, in, info, handler) +} + +func _AddressDict_Countrieslist_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(empty.Empty) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AddressDictServer).Countrieslist(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/proto.AddressDict/Countrieslist", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AddressDictServer).Countrieslist(ctx, req.(*empty.Empty)) + } + return interceptor(ctx, in, info, handler) +} + +var _AddressDict_serviceDesc = grpc.ServiceDesc{ + ServiceName: "proto.AddressDict", + HandlerType: (*AddressDictServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "GetAll", + Handler: _AddressDict_GetAll_Handler, + }, + { + MethodName: "GetParentlist", + Handler: _AddressDict_GetParentlist_Handler, + }, + { + MethodName: "AddaddressDict", + Handler: _AddressDict_AddaddressDict_Handler, + }, + { + MethodName: "DeleteAddressDict", + Handler: _AddressDict_DeleteAddressDict_Handler, + }, + { + MethodName: "Countrieslist", + Handler: _AddressDict_Countrieslist_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "proto/countries_regions.proto", } diff --git a/proto/countries_regions.pb.micro.go b/proto/countries_regions.pb.micro.go index 3806590..3aabbd2 100644 --- a/proto/countries_regions.pb.micro.go +++ b/proto/countries_regions.pb.micro.go @@ -6,9 +6,19 @@ package proto import ( fmt "fmt" proto "github.com/golang/protobuf/proto" + empty "github.com/golang/protobuf/ptypes/empty" + wrappers "github.com/golang/protobuf/ptypes/wrappers" + libresp "github.com/pku-hit/libresp" math "math" ) +import ( + context "context" + api "github.com/micro/go-micro/v2/api" + client "github.com/micro/go-micro/v2/client" + server "github.com/micro/go-micro/v2/server" +) + // Reference imports to suppress errors if they are not otherwise used. var _ = proto.Marshal var _ = fmt.Errorf @@ -19,3 +29,146 @@ var _ = math.Inf // A compilation error at this line likely means your copy of the // proto package needs to be updated. const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package + +// Reference imports to suppress errors if they are not otherwise used. +var _ api.Endpoint +var _ context.Context +var _ client.Option +var _ server.Option + +// Api Endpoints for AddressDict service + +func NewAddressDictEndpoints() []*api.Endpoint { + return []*api.Endpoint{} +} + +// Client API for AddressDict service + +type AddressDictService interface { + //全部 + GetAll(ctx context.Context, in *empty.Empty, opts ...client.CallOption) (*libresp.ListResponse, error) + //通过字典patientid获取指定节点 + GetParentlist(ctx context.Context, in *wrappers.StringValue, opts ...client.CallOption) (*libresp.ListResponse, error) + //添加地址字典数据 + AddaddressDict(ctx context.Context, in *AddaddressDictRequest, opts ...client.CallOption) (*libresp.GenericResponse, error) + //删除数据 + DeleteAddressDict(ctx context.Context, in *wrappers.StringValue, opts ...client.CallOption) (*libresp.Response, error) + //国家 + Countrieslist(ctx context.Context, in *empty.Empty, opts ...client.CallOption) (*libresp.ListResponse, error) +} + +type addressDictService struct { + c client.Client + name string +} + +func NewAddressDictService(name string, c client.Client) AddressDictService { + return &addressDictService{ + c: c, + name: name, + } +} + +func (c *addressDictService) GetAll(ctx context.Context, in *empty.Empty, opts ...client.CallOption) (*libresp.ListResponse, error) { + req := c.c.NewRequest(c.name, "AddressDict.GetAll", in) + out := new(libresp.ListResponse) + err := c.c.Call(ctx, req, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *addressDictService) GetParentlist(ctx context.Context, in *wrappers.StringValue, opts ...client.CallOption) (*libresp.ListResponse, error) { + req := c.c.NewRequest(c.name, "AddressDict.GetParentlist", in) + out := new(libresp.ListResponse) + err := c.c.Call(ctx, req, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *addressDictService) AddaddressDict(ctx context.Context, in *AddaddressDictRequest, opts ...client.CallOption) (*libresp.GenericResponse, error) { + req := c.c.NewRequest(c.name, "AddressDict.AddaddressDict", in) + out := new(libresp.GenericResponse) + err := c.c.Call(ctx, req, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *addressDictService) DeleteAddressDict(ctx context.Context, in *wrappers.StringValue, opts ...client.CallOption) (*libresp.Response, error) { + req := c.c.NewRequest(c.name, "AddressDict.DeleteAddressDict", in) + out := new(libresp.Response) + err := c.c.Call(ctx, req, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *addressDictService) Countrieslist(ctx context.Context, in *empty.Empty, opts ...client.CallOption) (*libresp.ListResponse, error) { + req := c.c.NewRequest(c.name, "AddressDict.Countrieslist", in) + out := new(libresp.ListResponse) + err := c.c.Call(ctx, req, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// Server API for AddressDict service + +type AddressDictHandler interface { + //全部 + GetAll(context.Context, *empty.Empty, *libresp.ListResponse) error + //通过字典patientid获取指定节点 + GetParentlist(context.Context, *wrappers.StringValue, *libresp.ListResponse) error + //添加地址字典数据 + AddaddressDict(context.Context, *AddaddressDictRequest, *libresp.GenericResponse) error + //删除数据 + DeleteAddressDict(context.Context, *wrappers.StringValue, *libresp.Response) error + //国家 + Countrieslist(context.Context, *empty.Empty, *libresp.ListResponse) error +} + +func RegisterAddressDictHandler(s server.Server, hdlr AddressDictHandler, opts ...server.HandlerOption) error { + type addressDict interface { + GetAll(ctx context.Context, in *empty.Empty, out *libresp.ListResponse) error + GetParentlist(ctx context.Context, in *wrappers.StringValue, out *libresp.ListResponse) error + AddaddressDict(ctx context.Context, in *AddaddressDictRequest, out *libresp.GenericResponse) error + DeleteAddressDict(ctx context.Context, in *wrappers.StringValue, out *libresp.Response) error + Countrieslist(ctx context.Context, in *empty.Empty, out *libresp.ListResponse) error + } + type AddressDict struct { + addressDict + } + h := &addressDictHandler{hdlr} + return s.Handle(s.NewHandler(&AddressDict{h}, opts...)) +} + +type addressDictHandler struct { + AddressDictHandler +} + +func (h *addressDictHandler) GetAll(ctx context.Context, in *empty.Empty, out *libresp.ListResponse) error { + return h.AddressDictHandler.GetAll(ctx, in, out) +} + +func (h *addressDictHandler) GetParentlist(ctx context.Context, in *wrappers.StringValue, out *libresp.ListResponse) error { + return h.AddressDictHandler.GetParentlist(ctx, in, out) +} + +func (h *addressDictHandler) AddaddressDict(ctx context.Context, in *AddaddressDictRequest, out *libresp.GenericResponse) error { + return h.AddressDictHandler.AddaddressDict(ctx, in, out) +} + +func (h *addressDictHandler) DeleteAddressDict(ctx context.Context, in *wrappers.StringValue, out *libresp.Response) error { + return h.AddressDictHandler.DeleteAddressDict(ctx, in, out) +} + +func (h *addressDictHandler) Countrieslist(ctx context.Context, in *empty.Empty, out *libresp.ListResponse) error { + return h.AddressDictHandler.Countrieslist(ctx, in, out) +} diff --git a/proto/countries_regions.proto b/proto/countries_regions.proto index 88faf03..c727b85 100644 --- a/proto/countries_regions.proto +++ b/proto/countries_regions.proto @@ -2,8 +2,48 @@ syntax = "proto3"; package proto; +import "github.com/pku-hit/libresp/msg-response.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/wrappers.proto"; + enum CountryCode { OmitCountry = 0; American = 1; China = 86; -} \ No newline at end of file +} + + +service AddressDict { + //全部 + rpc GetAll(google.protobuf.Empty) returns(libresp.ListResponse){ + } + //通过字典patientid获取指定节点 + rpc GetParentlist (google.protobuf.StringValue) returns (libresp.ListResponse){ + } + //添加地址字典数据 + rpc AddaddressDict (AddaddressDictRequest) returns (libresp.GenericResponse){ + } + //删除数据 + rpc DeleteAddressDict(google.protobuf.StringValue) returns (libresp.Response){ + } + //国家 + rpc Countrieslist(google.protobuf.Empty) returns (libresp.ListResponse){ + } +} +enum AddressDictType { + country= 0; + province= 1; + city = 2; + area = 3; + street = 4; +} + +message AddaddressDictRequest { + string category = 1; + string parentId = 2; + AddressDictType type = 3; + string code = 4; + string pyCode = 5; + string name = 6; + string value = 7; +} diff --git a/proto/dict.pb.go b/proto/dict.pb.go index f834dc7..be726b2 100644 --- a/proto/dict.pb.go +++ b/proto/dict.pb.go @@ -307,9 +307,7 @@ func init() { proto.RegisterType((*AddDictRequest)(nil), "proto.AddDictRequest") } -func init() { - proto.RegisterFile("proto/dict.proto", fileDescriptor_22c1e80adc3f1fcd) -} +func init() { proto.RegisterFile("proto/dict.proto", fileDescriptor_22c1e80adc3f1fcd) } var fileDescriptor_22c1e80adc3f1fcd = []byte{ // 526 bytes of a gzipped FileDescriptorProto @@ -350,11 +348,11 @@ var fileDescriptor_22c1e80adc3f1fcd = []byte{ // Reference imports to suppress errors if they are not otherwise used. var _ context.Context -var _ grpc.ClientConnInterface +var _ grpc.ClientConn // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion6 +const _ = grpc.SupportPackageIsVersion4 // DictClient is the client API for Dict service. // @@ -375,10 +373,10 @@ type DictClient interface { } type dictClient struct { - cc grpc.ClientConnInterface + cc *grpc.ClientConn } -func NewDictClient(cc grpc.ClientConnInterface) DictClient { +func NewDictClient(cc *grpc.ClientConn) DictClient { return &dictClient{cc} } -- Gitee