Browse Source

查询增加自定义字段

master v0.3.1
guzeng 3 years ago
parent
commit
e426c81793
4 changed files with 26 additions and 8 deletions
  1. +4
    -4
      getinfo.go
  2. +4
    -4
      getskuinfo.go
  3. +16
    -0
      product.pb.go
  4. +2
    -0
      product.proto

+ 4
- 4
getinfo.go View File

@ -12,7 +12,7 @@ import (
* 2021/08/20 * 2021/08/20
* GZ * GZ
*/ */
func Get(dbname, id string, url ...string) (map[string]string, error) {
func Get(dbname, id string, field string, url ...string) (map[string]string, error) {
conn, err := rpc_server_conn(url...) conn, err := rpc_server_conn(url...)
if err != nil { if err != nil {
@ -20,7 +20,7 @@ func Get(dbname, id string, url ...string) (map[string]string, error) {
} }
defer conn.Close() defer conn.Close()
req := &GetRequest{proto.String(dbname), proto.String(id), nil}
req := &GetRequest{proto.String(dbname), proto.String(id), proto.String(field), nil}
res := &GetResponse{} res := &GetResponse{}
@ -45,7 +45,7 @@ func Get(dbname, id string, url ...string) (map[string]string, error) {
* 2021/08/20 * 2021/08/20
* GZ * GZ
*/ */
func GetByUuid(dbname, uuid string, url ...string) (map[string]string, error) {
func GetByUuid(dbname, uuid string, field string, url ...string) (map[string]string, error) {
conn, err := rpc_server_conn(url...) conn, err := rpc_server_conn(url...)
if err != nil { if err != nil {
@ -53,7 +53,7 @@ func GetByUuid(dbname, uuid string, url ...string) (map[string]string, error) {
} }
defer conn.Close() defer conn.Close()
req := &GetUuidRequest{proto.String(dbname), proto.String(uuid), nil}
req := &GetUuidRequest{proto.String(dbname), proto.String(uuid), proto.String(field), nil}
res := &GetResponse{} res := &GetResponse{}


+ 4
- 4
getskuinfo.go View File

@ -12,7 +12,7 @@ import (
* 2021/08/20 * 2021/08/20
* GZ * GZ
*/ */
func GetSku(dbname, id string, url ...string) (map[string]string, error) {
func GetSku(dbname, id string, field string, url ...string) (map[string]string, error) {
conn, err := rpc_server_conn(url...) conn, err := rpc_server_conn(url...)
if err != nil { if err != nil {
@ -20,7 +20,7 @@ func GetSku(dbname, id string, url ...string) (map[string]string, error) {
} }
defer conn.Close() defer conn.Close()
req := &GetRequest{proto.String(dbname), proto.String(id), nil}
req := &GetRequest{proto.String(dbname), proto.String(id), proto.String(field), nil}
res := &GetResponse{} res := &GetResponse{}
@ -45,7 +45,7 @@ func GetSku(dbname, id string, url ...string) (map[string]string, error) {
* 2021/08/20 * 2021/08/20
* GZ * GZ
*/ */
func GetSkuByUuid(dbname, uuid string, url ...string) (map[string]string, error) {
func GetSkuByUuid(dbname, uuid string, field string, url ...string) (map[string]string, error) {
conn, err := rpc_server_conn(url...) conn, err := rpc_server_conn(url...)
if err != nil { if err != nil {
@ -53,7 +53,7 @@ func GetSkuByUuid(dbname, uuid string, url ...string) (map[string]string, error)
} }
defer conn.Close() defer conn.Close()
req := &GetUuidRequest{proto.String(dbname), proto.String(uuid), nil}
req := &GetUuidRequest{proto.String(dbname), proto.String(uuid), proto.String(field), nil}
res := &GetResponse{} res := &GetResponse{}


+ 16
- 0
product.pb.go View File

@ -33,6 +33,7 @@ var _ = math.Inf
type GetRequest struct { type GetRequest struct {
Dbname *string `protobuf:"bytes,1,opt,name=dbname" json:"dbname,omitempty"` Dbname *string `protobuf:"bytes,1,opt,name=dbname" json:"dbname,omitempty"`
Id *string `protobuf:"bytes,2,opt,name=id" json:"id,omitempty"` Id *string `protobuf:"bytes,2,opt,name=id" json:"id,omitempty"`
Field *string `protobuf:"bytes,3,opt,name=field" json:"field,omitempty"`
XXX_unrecognized []byte `json:"-"` XXX_unrecognized []byte `json:"-"`
} }
@ -54,9 +55,17 @@ func (m *GetRequest) GetId() string {
return "" return ""
} }
func (m *GetRequest) GetField() string {
if m != nil && m.Field != nil {
return *m.Field
}
return ""
}
type GetUuidRequest struct { type GetUuidRequest struct {
Dbname *string `protobuf:"bytes,1,opt,name=dbname" json:"dbname,omitempty"` Dbname *string `protobuf:"bytes,1,opt,name=dbname" json:"dbname,omitempty"`
Uuid *string `protobuf:"bytes,2,opt,name=uuid" json:"uuid,omitempty"` Uuid *string `protobuf:"bytes,2,opt,name=uuid" json:"uuid,omitempty"`
Field *string `protobuf:"bytes,3,opt,name=field" json:"field,omitempty"`
XXX_unrecognized []byte `json:"-"` XXX_unrecognized []byte `json:"-"`
} }
@ -78,6 +87,13 @@ func (m *GetUuidRequest) GetUuid() string {
return "" return ""
} }
func (m *GetUuidRequest) GetField() string {
if m != nil && m.Field != nil {
return *m.Field
}
return ""
}
// 使用key查询响应结构 // 使用key查询响应结构
type GetResponse struct { type GetResponse struct {
Value []byte `protobuf:"bytes,1,opt,name=value" json:"value,omitempty"` Value []byte `protobuf:"bytes,1,opt,name=value" json:"value,omitempty"`


+ 2
- 0
product.proto View File

@ -5,11 +5,13 @@ package productrpc;
message GetRequest { message GetRequest {
string dbname = 1; string dbname = 1;
string id = 2; string id = 2;
string field = 3;
} }
message GetUuidRequest { message GetUuidRequest {
string dbname = 1; string dbname = 1;
string uuid = 2; string uuid = 2;
string field = 3;
} }
// 使key查询响应结构 // 使key查询响应结构


Loading…
Cancel
Save