diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000000000000000000000000000000000000..94a25f7f4cb416c083d265558da75d457237d671
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 1496c7f9e85e9450b5f0c5355c613fb2f3d12f35..9a8ae2284929f0dd9ca3eb3398ffcd58e503927e 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -9,36 +9,33 @@
-
+
-
+
-
-
+
+
-
+
-
+
-
-
+
+
-
+
-
-
-
-
-
+
+
@@ -46,22 +43,26 @@
-
-
-
-
-
+
+
-
+
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
@@ -69,8 +70,8 @@
-
-
+
+
@@ -81,20 +82,29 @@
-
-
+
+
+
+
+
-
+
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
@@ -108,6 +118,11 @@
+
+
+ GetDictPB
+
+
@@ -117,14 +132,17 @@
+
+
+
+
-
-
+
@@ -174,6 +192,11 @@
+
+
+
+
+
@@ -189,6 +212,7 @@
+
-
+
@@ -215,33 +239,60 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
-
-
+
+
-
+
-
+
@@ -261,9 +312,15 @@
file://$PROJECT_DIR$/component/database/account_info_dao.go
- 34
+ 129
-
+
+
+
+ file://$PROJECT_DIR$/component/database/account_info_dao.go
+ 75
+
+
@@ -279,21 +336,96 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -301,13 +433,47 @@
-
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -318,92 +484,129 @@
-
+
-
-
+
+
-
-
-
-
+
-
+
+
+
+
+
+
+
+
-
+
-
+
-
-
+
+
-
+
-
-
-
-
+
+
-
+
+
+
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
-
+
-
-
+
+
-
+
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
diff --git a/component/database/account_info_dao.go b/component/database/account_info_dao.go
index c0fa303d396025188f0b6534f569033bd81a6035..b1e3ac64f28a411a5d07ea2166f0817edcd7ce95 100644
--- a/component/database/account_info_dao.go
+++ b/component/database/account_info_dao.go
@@ -3,27 +3,46 @@ package database
import (
"errors"
"github.com/jinzhu/gorm"
- "github.com/pku-hit/dict/model/entity"
"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 WithId(id string) (dict *entity.DictInfo, err error) {
+//根据code查询节点
+func GetPrincipal(code string) (dict *entity.DictInfo, err error) {
dict = &entity.DictInfo{}
- err = db.Where("parent_id = ?", id).Find(dict).Error
+ err = db.Where("code = ?", code).Where("status = 'Normal'").Find(dict).Error
if err == gorm.ErrRecordNotFound {
dict = nil
}
return
}
+
+//func ExistAccountType(parentId, code string) (dict *entity.DictInfo, err error) {
+// query := db.New()
+// if !util.String.IsEmptyString(parentId) {
+// query.Where("ParentId = ?", parentId).Where("Type in (?)", )
+// } else {
+// query.Where("ParentId is null").Where("Type = ?", proto.DictType_Root.String())
+// }
+// query.Where("Code = ?", code)
+// dict = &entity.DictInfo{}
+// err = query.Find(dict).Error
+//
+// if err == gorm.ErrRecordNotFound {
+// dict = nil
+// }
+// return
+//}
+//查询全部账号信息
func GetAccount(parent_id string) (dicts []*entity.DictInfo, err error) {
query := db.New()
if !util.String.IsEmptyString(parent_id) {
query = query.Where("parent_id = ?", parent_id)
}
//query.Where("Type = ? and ParentId is null", proto.DictType_Root.String())
+ query = query.Where("status = 'Normal'")
err = query.Find(&dicts).Error
if err != nil {
log.Error(util.Json.ToJsonString(err))
@@ -32,10 +51,32 @@ func GetAccount(parent_id string) (dicts []*entity.DictInfo, err error) {
}
return
}
-func NewAcDict(category, parentId, code, name, pyCode string, dictType proto.AcDictType, value interface{}) (dict *entity.DictInfo, err error) {
-
-
-
+//查询父节点下所有子节点
+func ListChildNode(ParentId string) (dicts []*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())
+ query = query.Where("status = 'Normal'")
+ err = query.Find(&dicts).Error
+ if err != nil {
+ log.Error(util.Json.ToJsonString(err))
+ } else {
+ log.Info(util.Json.ToJsonString(dicts))
+ }
+ return
+}
+//新增一条数据
+func NewAcDict(category, parentId, code, name, pyCode string, dictType proto.NodeType, value interface{}) (dict *entity.DictInfo, err error) {
+ //if dict, err = ExistAccountType(parentId, code); err == nil && dict != nil {
+ // log.Warnf("exist dict: %s", util.Json.ToJsonString(dict))
+ // return
+ //}
+ if dict, err = GetPrincipal(code);dict!=nil{
+ err = errors.New("code已存在")
+ return
+ }
now := time.Now()
dict = &entity.DictInfo{
ID: util.Snowflake.GenId(),
@@ -49,17 +90,14 @@ func NewAcDict(category, parentId, code, name, pyCode string, dictType proto.AcD
}
if util.String.IsEmptyString(parentId) {
- if dictType != proto.AcDictType_Root {
- err = errors.New("没有指定ParentId的字典,限制仅允许为Root类型")
- return
- }
- dict.Type = proto.AcDictType_Root.String()
+ err = errors.New("请填写值")
+ return
} else {
- if dictType != proto.AcDictType_Node && dictType != proto.AcDictType_Group {
- err = errors.New("指定ParentId的字典,限制仅允许为Group或Node类型")
+ if dictType != proto.NodeType_Principal && dictType != proto.NodeType_Sub {
+ err = errors.New("指定ParentId的字典,限制仅允许为Principal或Sub类型")
return
}
- if _, err = ExistDictWithId(parentId); err == gorm.ErrRecordNotFound {
+ if _, err = GetPrincipal(parentId); err == gorm.ErrRecordNotFound {
err = errors.New("指定的父节点不存在")
return
}
@@ -76,4 +114,44 @@ func NewAcDict(category, parentId, code, name, pyCode string, dictType proto.AcD
log.Error("save new dict error %s.", err.Error())
}
return
-}
\ No newline at end of file
+}
+//根据id查询是否存在
+func ExistAccountTypeWithId(id string) (dict *entity.DictInfo, err error) {
+ dict = &entity.DictInfo{}
+ err = db.Where("id = ?", id).Find(dict).Error
+ if err == gorm.ErrRecordNotFound {
+ dict = nil
+ }
+ return
+}
+//删除时调用,查询父账户下是否还存在子账户数据,有的话请先删除子节点
+func delQueryAcounnt(parent_id string) (dict *entity.DictInfo, err error) {
+ dict = &entity.DictInfo{}
+ db=db.Where("parent_id = ?", parent_id)
+ err = db.Where("status = 'Normal'").Find(dict).Error
+ if err == gorm.ErrRecordNotFound {
+ dict = nil
+ }
+ return
+}
+func DeleteAccountType(id string, soft bool) (err error) {
+ dict, err := ExistAccountTypeWithId(id)
+ if err == gorm.ErrRecordNotFound {
+ return
+ }
+ dicts, err := delQueryAcounnt(dict.Code)
+ if dicts!=nil{
+ err = errors.New("删除的节点下有子节点,请先删除子节点")
+ 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("id = ?", id).Delete(new(entity.DictInfo)).Error
+ }
+ return
+}
diff --git a/go.mod b/go.mod
index 8a8574b41ea53a42729bfbfd84a6f10960012293..5cf005694ba3383b567c431678e1489d7973268a 100644
--- a/go.mod
+++ b/go.mod
@@ -21,6 +21,7 @@ require (
github.com/nats-io/nats.go v1.10.0 // indirect
github.com/nats-io/nkeys v0.2.0 // indirect
github.com/pku-hit/libresp v0.0.2
+ github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
go.uber.org/zap v1.15.0 // indirect
golang.org/x/crypto v0.0.0-20200602180216-279210d13fed // indirect
golang.org/x/lint v0.0.0-20200302205851-738671d3881b // indirect
diff --git a/go.sum b/go.sum
index 2c6c244dbbde915f44fd6108f5bdcbe6437b385d..1d171df9348abc30a37a4cb5e722aa1adc1eb740 100644
--- a/go.sum
+++ b/go.sum
@@ -485,6 +485,8 @@ github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPx
github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4=
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
+github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e h1:MRM5ITcdelLK2j1vwZ3Je0FKVCfqOLp5zO6trqMLYs0=
+github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e/go.mod h1:XV66xRDqSt+GTGFMVlhk3ULuV0y9ZmzeVGR4mloJI3M=
github.com/skratchdot/open-golang v0.0.0-20160302144031-75fb7ed4208c/go.mod h1:sUM3LWHvSMaG192sy56D9F7CNvL7jUJVXoqM1QKLnog=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
diff --git a/handler/account.go b/handler/account.go
index e593528cd9b7aaf3d9030637321b8e1dec2f4925..3c26ef1a04dd405b6779513f004ffaa76df8b48a 100644
--- a/handler/account.go
+++ b/handler/account.go
@@ -2,6 +2,7 @@ package handler
import (
"context"
+ "github.com/golang/protobuf/ptypes/empty"
"github.com/golang/protobuf/ptypes/wrappers"
"github.com/pku-hit/dict/proto"
@@ -12,11 +13,11 @@ import (
"github.com/pku-hit/libresp"
)
-type Acdict struct{}
+type AccountType struct{}
-func (e *Acdict) GetAccount(ctx context.Context, req * wrappers.StringValue, resp * libresp.ListResponse) error {
+func (e *AccountType) GetAccountType(ctx context.Context, req *empty.Empty, resp * libresp.ListResponse) error {
log.Log("Received Region.ListCountry request")
- dicts, err := database.GetAccount(req.Value)
+ dicts, err := database.GetAccount("")
if err != nil {
resp.GenerateListResponseWithInfo(libresp.GENERAL_ERROR, err.Error())
return nil
@@ -24,9 +25,9 @@ func (e *Acdict) GetAccount(ctx context.Context, req * wrappers.StringValue, re
resp.GenerateListResponseSucc(model.GetDictsAny(dicts))
return nil
}
-func (e *Acdict) DelAcDict(ctx context.Context, req *wrappers.StringValue, resp *libresp.Response) error {
+func (e *AccountType) DelAccountType(ctx context.Context, req *wrappers.StringValue, resp *libresp.Response) error {
log.Log("Received Dict.DelDict request")
- err := database.DeleteDict(req.Value, true)
+ err := database.DeleteAccountType(req.Value, true)
if err != nil {
resp.GenerateResponseWithInfo(libresp.GENERAL_ERROR, err.Error())
} else {
@@ -34,7 +35,7 @@ func (e *Acdict) DelAcDict(ctx context.Context, req *wrappers.StringValue, resp
}
return nil
}
-func (e *Acdict) AddAccountDict(ctx context.Context, req *proto.AddAcDictRequest, resp *libresp.GenericResponse) error {
+func (e *AccountType) AddAccountType(ctx context.Context, req *proto.AddAccountTypeRequest, resp *libresp.GenericResponse) error {
log.Log("Received Dict.AddDict request")
dict, err := database.NewAcDict(req.Category, req.ParentId, req.Code, req.Name, req.PyCode, req.Type, req.Value)
if err != nil {
@@ -43,4 +44,24 @@ func (e *Acdict) AddAccountDict(ctx context.Context, req *proto.AddAcDictRequest
}
resp.GenerateGenericResponseSucc(model.GetDictAny(dict))
return nil
+}
+func (e *AccountType) ListChildNode(ctx context.Context, req *proto.ListChildNodeRequest, resp *libresp.ListResponse) error {
+ log.Log("Received Region.ListCountry request")
+ dicts, err := database.ListChildNode(req.ParentId)
+ if err != nil {
+ resp.GenerateListResponseWithInfo(libresp.GENERAL_ERROR, err.Error())
+ return nil
+ }
+ resp.GenerateListResponseSucc(model.GetDictsAny(dicts))
+ return nil
+}
+func (e *AccountType) GetPrincipalValue(ctx context.Context, req *wrappers.StringValue, resp *libresp.GenericResponse) error {
+ log.Log("Received Dict.GetValue request")
+ dict, err := database.GetPrincipal(req.Value)
+ if err != nil {
+ resp.GenerateGenericResponseWithInfo(libresp.GENERAL_ERROR, err.Error())
+ } else {
+ resp.GenerateGenericResponseSucc(model.GetDictAny(dict))
+ }
+ return nil
}
\ No newline at end of file
diff --git a/handler/dict.go b/handler/dict.go
index cca78afd7999dfd60c3814841916a76c79f56558..0c2437f2dcea9f8d89e0a6ed3753c54797b3debe 100644
--- a/handler/dict.go
+++ b/handler/dict.go
@@ -10,6 +10,7 @@ import (
"github.com/pku-hit/dict/proto"
"github.com/pku-hit/libresp"
+
)
type Dict struct{}
diff --git a/main.go b/main.go
index 5b62550c3d914fc95da943ea2d39e041cd1b26dd..9b7266fa70155041741c487d72354473d5f71270 100644
--- a/main.go
+++ b/main.go
@@ -11,7 +11,9 @@ import (
)
func main() {
-
+//增,先判断是否添加的是主账户还是子账户,主账户就直接新增,子账户就先判断是哪个账号的子账户(查询方法)
+//删,删除子账户直接删除,删除主账户先删除全部子账户在删除主账户
+//查询(1,查询全部账户类型,2根据账户类型进行查询())
// New Service
service := micro.NewService(
micro.Registry(etcdv3.NewRegistry()),
@@ -25,7 +27,7 @@ func main() {
// Register Handler
proto.RegisterDictHandler(server, new(handler.Dict))
proto.RegisterRegionHandler(server, new(handler.Region))
- proto.RegisterAcdictHandler(server, new(handler.Acdict))
+ proto.RegisterAccountTypeHandler(server, new(handler.AccountType))
// Register Struct as Subscriber
micro.RegisterSubscriber(proto.ServiceName, server, new(subscriber.Dict))
diff --git a/proto/account_type.pb.go b/proto/account_type.pb.go
index 8ac42f75961663a34c26ff6c48ad2dd14d6982f4..9dd9b34ae25e9b2fe0192a63e1a4fcef2d656e63 100644
--- a/proto/account_type.pb.go
+++ b/proto/account_type.pb.go
@@ -7,7 +7,7 @@ import (
context "context"
fmt "fmt"
proto "github.com/golang/protobuf/proto"
- _ "github.com/golang/protobuf/ptypes/empty"
+ 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"
@@ -27,158 +27,197 @@ var _ = math.Inf
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
-type AcDictType int32
+type NodeType int32
const (
- AcDictType_OmitType AcDictType = 0
- AcDictType_Root AcDictType = 1
- AcDictType_Group AcDictType = 2
- AcDictType_Node AcDictType = 3
+ NodeType_OmitType NodeType = 0
+ NodeType_Principal NodeType = 1
+ NodeType_Sub NodeType = 2
)
-var AcDictType_name = map[int32]string{
+var NodeType_name = map[int32]string{
0: "OmitType",
- 1: "Root",
- 2: "Group",
- 3: "Node",
+ 1: "Principal",
+ 2: "Sub",
}
-var AcDictType_value = map[string]int32{
- "OmitType": 0,
- "Root": 1,
- "Group": 2,
- "Node": 3,
+var NodeType_value = map[string]int32{
+ "OmitType": 0,
+ "Principal": 1,
+ "Sub": 2,
}
-func (x AcDictType) String() string {
- return proto.EnumName(AcDictType_name, int32(x))
+func (x NodeType) String() string {
+ return proto.EnumName(NodeType_name, int32(x))
}
-func (AcDictType) EnumDescriptor() ([]byte, []int) {
+func (NodeType) EnumDescriptor() ([]byte, []int) {
return fileDescriptor_5e87dcecbad98a24, []int{0}
}
-type AddAcDictRequest 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 AcDictType `protobuf:"varint,3,opt,name=type,proto3,enum=proto.AcDictType" 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:"-"`
+type AddAccountTypeRequest 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 NodeType `protobuf:"varint,3,opt,name=type,proto3,enum=proto.NodeType" 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 *AddAcDictRequest) Reset() { *m = AddAcDictRequest{} }
-func (m *AddAcDictRequest) String() string { return proto.CompactTextString(m) }
-func (*AddAcDictRequest) ProtoMessage() {}
-func (*AddAcDictRequest) Descriptor() ([]byte, []int) {
+func (m *AddAccountTypeRequest) Reset() { *m = AddAccountTypeRequest{} }
+func (m *AddAccountTypeRequest) String() string { return proto.CompactTextString(m) }
+func (*AddAccountTypeRequest) ProtoMessage() {}
+func (*AddAccountTypeRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_5e87dcecbad98a24, []int{0}
}
-func (m *AddAcDictRequest) XXX_Unmarshal(b []byte) error {
- return xxx_messageInfo_AddAcDictRequest.Unmarshal(m, b)
+func (m *AddAccountTypeRequest) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_AddAccountTypeRequest.Unmarshal(m, b)
}
-func (m *AddAcDictRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- return xxx_messageInfo_AddAcDictRequest.Marshal(b, m, deterministic)
+func (m *AddAccountTypeRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_AddAccountTypeRequest.Marshal(b, m, deterministic)
}
-func (m *AddAcDictRequest) XXX_Merge(src proto.Message) {
- xxx_messageInfo_AddAcDictRequest.Merge(m, src)
+func (m *AddAccountTypeRequest) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_AddAccountTypeRequest.Merge(m, src)
}
-func (m *AddAcDictRequest) XXX_Size() int {
- return xxx_messageInfo_AddAcDictRequest.Size(m)
+func (m *AddAccountTypeRequest) XXX_Size() int {
+ return xxx_messageInfo_AddAccountTypeRequest.Size(m)
}
-func (m *AddAcDictRequest) XXX_DiscardUnknown() {
- xxx_messageInfo_AddAcDictRequest.DiscardUnknown(m)
+func (m *AddAccountTypeRequest) XXX_DiscardUnknown() {
+ xxx_messageInfo_AddAccountTypeRequest.DiscardUnknown(m)
}
-var xxx_messageInfo_AddAcDictRequest proto.InternalMessageInfo
+var xxx_messageInfo_AddAccountTypeRequest proto.InternalMessageInfo
-func (m *AddAcDictRequest) GetCategory() string {
+func (m *AddAccountTypeRequest) GetCategory() string {
if m != nil {
return m.Category
}
return ""
}
-func (m *AddAcDictRequest) GetParentId() string {
+func (m *AddAccountTypeRequest) GetParentId() string {
if m != nil {
return m.ParentId
}
return ""
}
-func (m *AddAcDictRequest) GetType() AcDictType {
+func (m *AddAccountTypeRequest) GetType() NodeType {
if m != nil {
return m.Type
}
- return AcDictType_OmitType
+ return NodeType_OmitType
}
-func (m *AddAcDictRequest) GetCode() string {
+func (m *AddAccountTypeRequest) GetCode() string {
if m != nil {
return m.Code
}
return ""
}
-func (m *AddAcDictRequest) GetPyCode() string {
+func (m *AddAccountTypeRequest) GetPyCode() string {
if m != nil {
return m.PyCode
}
return ""
}
-func (m *AddAcDictRequest) GetName() string {
+func (m *AddAccountTypeRequest) GetName() string {
if m != nil {
return m.Name
}
return ""
}
-func (m *AddAcDictRequest) GetValue() string {
+func (m *AddAccountTypeRequest) GetValue() string {
if m != nil {
return m.Value
}
return ""
}
+type ListChildNodeRequest struct {
+ ParentId string `protobuf:"bytes,1,opt,name=parentId,proto3" json:"parentId,omitempty"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *ListChildNodeRequest) Reset() { *m = ListChildNodeRequest{} }
+func (m *ListChildNodeRequest) String() string { return proto.CompactTextString(m) }
+func (*ListChildNodeRequest) ProtoMessage() {}
+func (*ListChildNodeRequest) Descriptor() ([]byte, []int) {
+ return fileDescriptor_5e87dcecbad98a24, []int{1}
+}
+
+func (m *ListChildNodeRequest) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_ListChildNodeRequest.Unmarshal(m, b)
+}
+func (m *ListChildNodeRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_ListChildNodeRequest.Marshal(b, m, deterministic)
+}
+func (m *ListChildNodeRequest) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_ListChildNodeRequest.Merge(m, src)
+}
+func (m *ListChildNodeRequest) XXX_Size() int {
+ return xxx_messageInfo_ListChildNodeRequest.Size(m)
+}
+func (m *ListChildNodeRequest) XXX_DiscardUnknown() {
+ xxx_messageInfo_ListChildNodeRequest.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_ListChildNodeRequest proto.InternalMessageInfo
+
+func (m *ListChildNodeRequest) GetParentId() string {
+ if m != nil {
+ return m.ParentId
+ }
+ return ""
+}
+
func init() {
- proto.RegisterEnum("proto.AcDictType", AcDictType_name, AcDictType_value)
- proto.RegisterType((*AddAcDictRequest)(nil), "proto.AddAcDictRequest")
+ proto.RegisterEnum("proto.NodeType", NodeType_name, NodeType_value)
+ proto.RegisterType((*AddAccountTypeRequest)(nil), "proto.AddAccountTypeRequest")
+ proto.RegisterType((*ListChildNodeRequest)(nil), "proto.ListChildNodeRequest")
}
func init() { proto.RegisterFile("proto/account_type.proto", fileDescriptor_5e87dcecbad98a24) }
var fileDescriptor_5e87dcecbad98a24 = []byte{
- // 387 bytes of a gzipped FileDescriptorProto
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x51, 0x5d, 0x8b, 0xd4, 0x30,
- 0x14, 0xdd, 0xee, 0xb6, 0x75, 0xe6, 0x22, 0x4b, 0x37, 0xf8, 0x11, 0xaa, 0xc8, 0xb2, 0x20, 0x2c,
- 0xc2, 0xa4, 0xb0, 0x3e, 0xf9, 0x22, 0x94, 0x19, 0x19, 0x04, 0x51, 0xa8, 0xe2, 0xab, 0xb4, 0xe9,
- 0xb5, 0x13, 0x6c, 0x9b, 0x98, 0xa6, 0x4a, 0x7f, 0xa1, 0x7f, 0xc0, 0x1f, 0x24, 0x49, 0x3a, 0x33,
- 0x32, 0x2f, 0xfb, 0xd4, 0x7b, 0xce, 0xb9, 0xf7, 0xdc, 0xf4, 0x5c, 0xa0, 0x4a, 0x4b, 0x23, 0xb3,
- 0x92, 0x73, 0x39, 0xf6, 0xe6, 0x9b, 0x99, 0x14, 0x32, 0x47, 0x91, 0xc8, 0x7d, 0xd2, 0x55, 0x23,
- 0xcc, 0x6e, 0xac, 0x18, 0x97, 0x5d, 0xa6, 0x7e, 0x8c, 0xab, 0x9d, 0x30, 0x59, 0x2b, 0x2a, 0x8d,
- 0x83, 0xca, 0xba, 0xa1, 0x59, 0xd9, 0x42, 0xf6, 0xc3, 0x3c, 0x95, 0x3e, 0x6b, 0xa4, 0x6c, 0x5a,
- 0xcc, 0x1c, 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 0xda, 0x6b, 0x23, 0x8f, 0x61, 0xf4, 0x21, 0x65, 0xe6, 0x0a, 0xe3,
+ 0x13, 0x72, 0x01, 0xe7, 0x1f, 0x25, 0xcb, 0x42, 0x26, 0xfc, 0x64, 0x6c, 0x91, 0x33, 0x38, 0xdd,
+ 0x16, 0xc1, 0xb8, 0x37, 0xff, 0xdd, 0x83, 0x47, 0xad, 0x7b, 0x91, 0x15, 0x5c, 0x74, 0xa6, 0x92,
+ 0xdb, 0x7a, 0xe7, 0x43, 0x5a, 0x9c, 0x6b, 0xb7, 0xb6, 0xd2, 0xc0, 0x9b, 0xda, 0xca, 0xc9, 0x09,
+ 0x59, 0x80, 0xbd, 0x46, 0xd5, 0x26, 0xbe, 0x71, 0x2b, 0xf3, 0xdc, 0xbd, 0x79, 0xee, 0x4a, 0x3b,
+ 0xfb, 0x30, 0xc5, 0x3b, 0xb8, 0x5c, 0xa3, 0x6a, 0x44, 0x7f, 0xd6, 0x47, 0x21, 0x77, 0xff, 0xb1,
+ 0x6c, 0x95, 0x64, 0x59, 0x6c, 0x50, 0x87, 0x36, 0x5c, 0x6b, 0xcc, 0x50, 0xb2, 0xb0, 0x45, 0xf7,
+ 0x06, 0xec, 0xee, 0xd3, 0x20, 0x77, 0xf5, 0x66, 0x07, 0x5f, 0xcc, 0x51, 0xae, 0x25, 0xd8, 0xaf,
+ 0x30, 0xe9, 0x72, 0x1d, 0xd3, 0x75, 0xd9, 0x70, 0xfd, 0x25, 0x09, 0x86, 0xa6, 0xf5, 0xe5, 0x9f,
+ 0x00, 0x00, 0x00, 0xff, 0xff, 0x7a, 0x66, 0xca, 0x8d, 0x42, 0x03, 0x00, 0x00,
}
// Reference imports to suppress errors if they are not otherwise used.
@@ -189,150 +228,226 @@ var _ grpc.ClientConn
// is compatible with the grpc package it is being compiled against.
const _ = grpc.SupportPackageIsVersion4
-// AcdictClient is the client API for Acdict service.
+// AccountTypeClient is the client API for AccountType service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
-type AcdictClient interface {
- // 通过字典parent_id获取指定节点的值
- GetAccount(ctx context.Context, in *wrappers.StringValue, opts ...grpc.CallOption) (*libresp.ListResponse, error)
- // 新增
- AddAccountDict(ctx context.Context, in *AddAcDictRequest, opts ...grpc.CallOption) (*libresp.GenericResponse, error)
- // 删除字典项
- DelAcDict(ctx context.Context, in *wrappers.StringValue, opts ...grpc.CallOption) (*libresp.Response, error)
+type AccountTypeClient interface {
+ // 获取主账户下的所有子账户
+ ListChildNode(ctx context.Context, in *ListChildNodeRequest, opts ...grpc.CallOption) (*libresp.ListResponse, error)
+ // 查询全部账户信息
+ GetAccountType(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*libresp.ListResponse, error)
+ // 通过账户的code获取父账户
+ GetPrincipalValue(ctx context.Context, in *wrappers.StringValue, opts ...grpc.CallOption) (*libresp.GenericResponse, error)
+ // 新增账户
+ AddAccountType(ctx context.Context, in *AddAccountTypeRequest, opts ...grpc.CallOption) (*libresp.GenericResponse, error)
+ // 删除账户,如果删除的是父账户,子账户自动删除
+ DelAccountType(ctx context.Context, in *wrappers.StringValue, opts ...grpc.CallOption) (*libresp.Response, error)
+}
+
+type accountTypeClient struct {
+ cc *grpc.ClientConn
}
-type acdictClient struct {
- cc *grpc.ClientConn
+func NewAccountTypeClient(cc *grpc.ClientConn) AccountTypeClient {
+ return &accountTypeClient{cc}
}
-func NewAcdictClient(cc *grpc.ClientConn) AcdictClient {
- return &acdictClient{cc}
+func (c *accountTypeClient) ListChildNode(ctx context.Context, in *ListChildNodeRequest, opts ...grpc.CallOption) (*libresp.ListResponse, error) {
+ out := new(libresp.ListResponse)
+ err := c.cc.Invoke(ctx, "/proto.AccountType/ListChildNode", in, out, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
}
-func (c *acdictClient) GetAccount(ctx context.Context, in *wrappers.StringValue, opts ...grpc.CallOption) (*libresp.ListResponse, error) {
+func (c *accountTypeClient) GetAccountType(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*libresp.ListResponse, error) {
out := new(libresp.ListResponse)
- err := c.cc.Invoke(ctx, "/proto.Acdict/GetAccount", in, out, opts...)
+ err := c.cc.Invoke(ctx, "/proto.AccountType/GetAccountType", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
-func (c *acdictClient) AddAccountDict(ctx context.Context, in *AddAcDictRequest, opts ...grpc.CallOption) (*libresp.GenericResponse, error) {
+func (c *accountTypeClient) GetPrincipalValue(ctx context.Context, in *wrappers.StringValue, opts ...grpc.CallOption) (*libresp.GenericResponse, error) {
out := new(libresp.GenericResponse)
- err := c.cc.Invoke(ctx, "/proto.Acdict/AddAccountDict", in, out, opts...)
+ err := c.cc.Invoke(ctx, "/proto.AccountType/GetPrincipalValue", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
-func (c *acdictClient) DelAcDict(ctx context.Context, in *wrappers.StringValue, opts ...grpc.CallOption) (*libresp.Response, error) {
+func (c *accountTypeClient) AddAccountType(ctx context.Context, in *AddAccountTypeRequest, opts ...grpc.CallOption) (*libresp.GenericResponse, error) {
+ out := new(libresp.GenericResponse)
+ err := c.cc.Invoke(ctx, "/proto.AccountType/AddAccountType", in, out, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+func (c *accountTypeClient) DelAccountType(ctx context.Context, in *wrappers.StringValue, opts ...grpc.CallOption) (*libresp.Response, error) {
out := new(libresp.Response)
- err := c.cc.Invoke(ctx, "/proto.Acdict/DelAcDict", in, out, opts...)
+ err := c.cc.Invoke(ctx, "/proto.AccountType/DelAccountType", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
-// AcdictServer is the server API for Acdict service.
-type AcdictServer interface {
- // 通过字典parent_id获取指定节点的值
- GetAccount(context.Context, *wrappers.StringValue) (*libresp.ListResponse, error)
- // 新增
- AddAccountDict(context.Context, *AddAcDictRequest) (*libresp.GenericResponse, error)
- // 删除字典项
- DelAcDict(context.Context, *wrappers.StringValue) (*libresp.Response, error)
+// AccountTypeServer is the server API for AccountType service.
+type AccountTypeServer interface {
+ // 获取主账户下的所有子账户
+ ListChildNode(context.Context, *ListChildNodeRequest) (*libresp.ListResponse, error)
+ // 查询全部账户信息
+ GetAccountType(context.Context, *empty.Empty) (*libresp.ListResponse, error)
+ // 通过账户的code获取父账户
+ GetPrincipalValue(context.Context, *wrappers.StringValue) (*libresp.GenericResponse, error)
+ // 新增账户
+ AddAccountType(context.Context, *AddAccountTypeRequest) (*libresp.GenericResponse, error)
+ // 删除账户,如果删除的是父账户,子账户自动删除
+ DelAccountType(context.Context, *wrappers.StringValue) (*libresp.Response, error)
}
-// UnimplementedAcdictServer can be embedded to have forward compatible implementations.
-type UnimplementedAcdictServer struct {
+// UnimplementedAccountTypeServer can be embedded to have forward compatible implementations.
+type UnimplementedAccountTypeServer struct {
}
-func (*UnimplementedAcdictServer) GetAccount(ctx context.Context, req *wrappers.StringValue) (*libresp.ListResponse, error) {
- return nil, status.Errorf(codes.Unimplemented, "method GetAccount not implemented")
+func (*UnimplementedAccountTypeServer) ListChildNode(ctx context.Context, req *ListChildNodeRequest) (*libresp.ListResponse, error) {
+ return nil, status.Errorf(codes.Unimplemented, "method ListChildNode not implemented")
+}
+func (*UnimplementedAccountTypeServer) GetAccountType(ctx context.Context, req *empty.Empty) (*libresp.ListResponse, error) {
+ return nil, status.Errorf(codes.Unimplemented, "method GetAccountType not implemented")
}
-func (*UnimplementedAcdictServer) AddAccountDict(ctx context.Context, req *AddAcDictRequest) (*libresp.GenericResponse, error) {
- return nil, status.Errorf(codes.Unimplemented, "method AddAccountDict not implemented")
+func (*UnimplementedAccountTypeServer) GetPrincipalValue(ctx context.Context, req *wrappers.StringValue) (*libresp.GenericResponse, error) {
+ return nil, status.Errorf(codes.Unimplemented, "method GetPrincipalValue not implemented")
}
-func (*UnimplementedAcdictServer) DelAcDict(ctx context.Context, req *wrappers.StringValue) (*libresp.Response, error) {
- return nil, status.Errorf(codes.Unimplemented, "method DelAcDict not implemented")
+func (*UnimplementedAccountTypeServer) AddAccountType(ctx context.Context, req *AddAccountTypeRequest) (*libresp.GenericResponse, error) {
+ return nil, status.Errorf(codes.Unimplemented, "method AddAccountType not implemented")
+}
+func (*UnimplementedAccountTypeServer) DelAccountType(ctx context.Context, req *wrappers.StringValue) (*libresp.Response, error) {
+ return nil, status.Errorf(codes.Unimplemented, "method DelAccountType not implemented")
+}
+
+func RegisterAccountTypeServer(s *grpc.Server, srv AccountTypeServer) {
+ s.RegisterService(&_AccountType_serviceDesc, srv)
}
-func RegisterAcdictServer(s *grpc.Server, srv AcdictServer) {
- s.RegisterService(&_Acdict_serviceDesc, srv)
+func _AccountType_ListChildNode_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(ListChildNodeRequest)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ if interceptor == nil {
+ return srv.(AccountTypeServer).ListChildNode(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: "/proto.AccountType/ListChildNode",
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(AccountTypeServer).ListChildNode(ctx, req.(*ListChildNodeRequest))
+ }
+ return interceptor(ctx, in, info, handler)
}
-func _Acdict_GetAccount_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+func _AccountType_GetAccountType_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.(AccountTypeServer).GetAccountType(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: "/proto.AccountType/GetAccountType",
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(AccountTypeServer).GetAccountType(ctx, req.(*empty.Empty))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
+func _AccountType_GetPrincipalValue_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.(AcdictServer).GetAccount(ctx, in)
+ return srv.(AccountTypeServer).GetPrincipalValue(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
- FullMethod: "/proto.Acdict/GetAccount",
+ FullMethod: "/proto.AccountType/GetPrincipalValue",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(AcdictServer).GetAccount(ctx, req.(*wrappers.StringValue))
+ return srv.(AccountTypeServer).GetPrincipalValue(ctx, req.(*wrappers.StringValue))
}
return interceptor(ctx, in, info, handler)
}
-func _Acdict_AddAccountDict_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(AddAcDictRequest)
+func _AccountType_AddAccountType_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(AddAccountTypeRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
- return srv.(AcdictServer).AddAccountDict(ctx, in)
+ return srv.(AccountTypeServer).AddAccountType(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
- FullMethod: "/proto.Acdict/AddAccountDict",
+ FullMethod: "/proto.AccountType/AddAccountType",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(AcdictServer).AddAccountDict(ctx, req.(*AddAcDictRequest))
+ return srv.(AccountTypeServer).AddAccountType(ctx, req.(*AddAccountTypeRequest))
}
return interceptor(ctx, in, info, handler)
}
-func _Acdict_DelAcDict_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+func _AccountType_DelAccountType_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.(AcdictServer).DelAcDict(ctx, in)
+ return srv.(AccountTypeServer).DelAccountType(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
- FullMethod: "/proto.Acdict/DelAcDict",
+ FullMethod: "/proto.AccountType/DelAccountType",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(AcdictServer).DelAcDict(ctx, req.(*wrappers.StringValue))
+ return srv.(AccountTypeServer).DelAccountType(ctx, req.(*wrappers.StringValue))
}
return interceptor(ctx, in, info, handler)
}
-var _Acdict_serviceDesc = grpc.ServiceDesc{
- ServiceName: "proto.Acdict",
- HandlerType: (*AcdictServer)(nil),
+var _AccountType_serviceDesc = grpc.ServiceDesc{
+ ServiceName: "proto.AccountType",
+ HandlerType: (*AccountTypeServer)(nil),
Methods: []grpc.MethodDesc{
{
- MethodName: "GetAccount",
- Handler: _Acdict_GetAccount_Handler,
+ MethodName: "ListChildNode",
+ Handler: _AccountType_ListChildNode_Handler,
+ },
+ {
+ MethodName: "GetAccountType",
+ Handler: _AccountType_GetAccountType_Handler,
+ },
+ {
+ MethodName: "GetPrincipalValue",
+ Handler: _AccountType_GetPrincipalValue_Handler,
},
{
- MethodName: "AddAccountDict",
- Handler: _Acdict_AddAccountDict_Handler,
+ MethodName: "AddAccountType",
+ Handler: _AccountType_AddAccountType_Handler,
},
{
- MethodName: "DelAcDict",
- Handler: _Acdict_DelAcDict_Handler,
+ MethodName: "DelAccountType",
+ Handler: _AccountType_DelAccountType_Handler,
},
},
Streams: []grpc.StreamDesc{},
diff --git a/proto/account_type.pb.micro.go b/proto/account_type.pb.micro.go
index c05446c0da068fa58f9d3129572f803b84ffdcd1..edd6443d9ef0f35746ff089561c901350ab8ce8d 100644
--- a/proto/account_type.pb.micro.go
+++ b/proto/account_type.pb.micro.go
@@ -6,7 +6,7 @@ package proto
import (
fmt "fmt"
proto "github.com/golang/protobuf/proto"
- _ "github.com/golang/protobuf/ptypes/empty"
+ empty "github.com/golang/protobuf/ptypes/empty"
wrappers "github.com/golang/protobuf/ptypes/wrappers"
libresp "github.com/pku-hit/libresp"
math "math"
@@ -36,37 +36,41 @@ var _ context.Context
var _ client.Option
var _ server.Option
-// Api Endpoints for Acdict service
+// Api Endpoints for AccountType service
-func NewAcdictEndpoints() []*api.Endpoint {
+func NewAccountTypeEndpoints() []*api.Endpoint {
return []*api.Endpoint{}
}
-// Client API for Acdict service
-
-type AcdictService interface {
- // 通过字典parent_id获取指定节点的值
- GetAccount(ctx context.Context, in *wrappers.StringValue, opts ...client.CallOption) (*libresp.ListResponse, error)
- // 新增
- AddAccountDict(ctx context.Context, in *AddAcDictRequest, opts ...client.CallOption) (*libresp.GenericResponse, error)
- // 删除字典项
- DelAcDict(ctx context.Context, in *wrappers.StringValue, opts ...client.CallOption) (*libresp.Response, error)
+// Client API for AccountType service
+
+type AccountTypeService interface {
+ // 获取主账户下的所有子账户
+ ListChildNode(ctx context.Context, in *ListChildNodeRequest, opts ...client.CallOption) (*libresp.ListResponse, error)
+ // 查询全部账户信息
+ GetAccountType(ctx context.Context, in *empty.Empty, opts ...client.CallOption) (*libresp.ListResponse, error)
+ // 通过账户的code获取父账户
+ GetPrincipalValue(ctx context.Context, in *wrappers.StringValue, opts ...client.CallOption) (*libresp.GenericResponse, error)
+ // 新增账户
+ AddAccountType(ctx context.Context, in *AddAccountTypeRequest, opts ...client.CallOption) (*libresp.GenericResponse, error)
+ // 删除账户,如果删除的是父账户,子账户自动删除
+ DelAccountType(ctx context.Context, in *wrappers.StringValue, opts ...client.CallOption) (*libresp.Response, error)
}
-type acdictService struct {
+type accountTypeService struct {
c client.Client
name string
}
-func NewAcdictService(name string, c client.Client) AcdictService {
- return &acdictService{
+func NewAccountTypeService(name string, c client.Client) AccountTypeService {
+ return &accountTypeService{
c: c,
name: name,
}
}
-func (c *acdictService) GetAccount(ctx context.Context, in *wrappers.StringValue, opts ...client.CallOption) (*libresp.ListResponse, error) {
- req := c.c.NewRequest(c.name, "Acdict.GetAccount", in)
+func (c *accountTypeService) ListChildNode(ctx context.Context, in *ListChildNodeRequest, opts ...client.CallOption) (*libresp.ListResponse, error) {
+ req := c.c.NewRequest(c.name, "AccountType.ListChildNode", in)
out := new(libresp.ListResponse)
err := c.c.Call(ctx, req, out, opts...)
if err != nil {
@@ -75,8 +79,18 @@ func (c *acdictService) GetAccount(ctx context.Context, in *wrappers.StringValue
return out, nil
}
-func (c *acdictService) AddAccountDict(ctx context.Context, in *AddAcDictRequest, opts ...client.CallOption) (*libresp.GenericResponse, error) {
- req := c.c.NewRequest(c.name, "Acdict.AddAccountDict", in)
+func (c *accountTypeService) GetAccountType(ctx context.Context, in *empty.Empty, opts ...client.CallOption) (*libresp.ListResponse, error) {
+ req := c.c.NewRequest(c.name, "AccountType.GetAccountType", in)
+ out := new(libresp.ListResponse)
+ err := c.c.Call(ctx, req, out, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+func (c *accountTypeService) GetPrincipalValue(ctx context.Context, in *wrappers.StringValue, opts ...client.CallOption) (*libresp.GenericResponse, error) {
+ req := c.c.NewRequest(c.name, "AccountType.GetPrincipalValue", in)
out := new(libresp.GenericResponse)
err := c.c.Call(ctx, req, out, opts...)
if err != nil {
@@ -85,9 +99,9 @@ func (c *acdictService) AddAccountDict(ctx context.Context, in *AddAcDictRequest
return out, nil
}
-func (c *acdictService) DelAcDict(ctx context.Context, in *wrappers.StringValue, opts ...client.CallOption) (*libresp.Response, error) {
- req := c.c.NewRequest(c.name, "Acdict.DelAcDict", in)
- out := new(libresp.Response)
+func (c *accountTypeService) AddAccountType(ctx context.Context, in *AddAccountTypeRequest, opts ...client.CallOption) (*libresp.GenericResponse, error) {
+ req := c.c.NewRequest(c.name, "AccountType.AddAccountType", in)
+ out := new(libresp.GenericResponse)
err := c.c.Call(ctx, req, out, opts...)
if err != nil {
return nil, err
@@ -95,42 +109,66 @@ func (c *acdictService) DelAcDict(ctx context.Context, in *wrappers.StringValue,
return out, nil
}
-// Server API for Acdict service
+func (c *accountTypeService) DelAccountType(ctx context.Context, in *wrappers.StringValue, opts ...client.CallOption) (*libresp.Response, error) {
+ req := c.c.NewRequest(c.name, "AccountType.DelAccountType", in)
+ out := new(libresp.Response)
+ err := c.c.Call(ctx, req, out, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
-type AcdictHandler interface {
- // 通过字典parent_id获取指定节点的值
- GetAccount(context.Context, *wrappers.StringValue, *libresp.ListResponse) error
- // 新增
- AddAccountDict(context.Context, *AddAcDictRequest, *libresp.GenericResponse) error
- // 删除字典项
- DelAcDict(context.Context, *wrappers.StringValue, *libresp.Response) error
+// Server API for AccountType service
+
+type AccountTypeHandler interface {
+ // 获取主账户下的所有子账户
+ ListChildNode(context.Context, *ListChildNodeRequest, *libresp.ListResponse) error
+ // 查询全部账户信息
+ GetAccountType(context.Context, *empty.Empty, *libresp.ListResponse) error
+ // 通过账户的code获取父账户
+ GetPrincipalValue(context.Context, *wrappers.StringValue, *libresp.GenericResponse) error
+ // 新增账户
+ AddAccountType(context.Context, *AddAccountTypeRequest, *libresp.GenericResponse) error
+ // 删除账户,如果删除的是父账户,子账户自动删除
+ DelAccountType(context.Context, *wrappers.StringValue, *libresp.Response) error
}
-func RegisterAcdictHandler(s server.Server, hdlr AcdictHandler, opts ...server.HandlerOption) error {
- type acdict interface {
- GetAccount(ctx context.Context, in *wrappers.StringValue, out *libresp.ListResponse) error
- AddAccountDict(ctx context.Context, in *AddAcDictRequest, out *libresp.GenericResponse) error
- DelAcDict(ctx context.Context, in *wrappers.StringValue, out *libresp.Response) error
+func RegisterAccountTypeHandler(s server.Server, hdlr AccountTypeHandler, opts ...server.HandlerOption) error {
+ type accountType interface {
+ ListChildNode(ctx context.Context, in *ListChildNodeRequest, out *libresp.ListResponse) error
+ GetAccountType(ctx context.Context, in *empty.Empty, out *libresp.ListResponse) error
+ GetPrincipalValue(ctx context.Context, in *wrappers.StringValue, out *libresp.GenericResponse) error
+ AddAccountType(ctx context.Context, in *AddAccountTypeRequest, out *libresp.GenericResponse) error
+ DelAccountType(ctx context.Context, in *wrappers.StringValue, out *libresp.Response) error
}
- type Acdict struct {
- acdict
+ type AccountType struct {
+ accountType
}
- h := &acdictHandler{hdlr}
- return s.Handle(s.NewHandler(&Acdict{h}, opts...))
+ h := &accountTypeHandler{hdlr}
+ return s.Handle(s.NewHandler(&AccountType{h}, opts...))
+}
+
+type accountTypeHandler struct {
+ AccountTypeHandler
+}
+
+func (h *accountTypeHandler) ListChildNode(ctx context.Context, in *ListChildNodeRequest, out *libresp.ListResponse) error {
+ return h.AccountTypeHandler.ListChildNode(ctx, in, out)
}
-type acdictHandler struct {
- AcdictHandler
+func (h *accountTypeHandler) GetAccountType(ctx context.Context, in *empty.Empty, out *libresp.ListResponse) error {
+ return h.AccountTypeHandler.GetAccountType(ctx, in, out)
}
-func (h *acdictHandler) GetAccount(ctx context.Context, in *wrappers.StringValue, out *libresp.ListResponse) error {
- return h.AcdictHandler.GetAccount(ctx, in, out)
+func (h *accountTypeHandler) GetPrincipalValue(ctx context.Context, in *wrappers.StringValue, out *libresp.GenericResponse) error {
+ return h.AccountTypeHandler.GetPrincipalValue(ctx, in, out)
}
-func (h *acdictHandler) AddAccountDict(ctx context.Context, in *AddAcDictRequest, out *libresp.GenericResponse) error {
- return h.AcdictHandler.AddAccountDict(ctx, in, out)
+func (h *accountTypeHandler) AddAccountType(ctx context.Context, in *AddAccountTypeRequest, out *libresp.GenericResponse) error {
+ return h.AccountTypeHandler.AddAccountType(ctx, in, out)
}
-func (h *acdictHandler) DelAcDict(ctx context.Context, in *wrappers.StringValue, out *libresp.Response) error {
- return h.AcdictHandler.DelAcDict(ctx, in, out)
+func (h *accountTypeHandler) DelAccountType(ctx context.Context, in *wrappers.StringValue, out *libresp.Response) error {
+ return h.AccountTypeHandler.DelAccountType(ctx, in, out)
}
diff --git a/proto/account_type.proto b/proto/account_type.proto
index eba944f387f5b69ed4e089870b3c25834b97b539..efd994a93af02afc3906b7946344fbec385b2da6 100644
--- a/proto/account_type.proto
+++ b/proto/account_type.proto
@@ -7,29 +7,38 @@ import "google/protobuf/wrappers.proto";
package proto;
-service Acdict {
- // 通过字典parent_id获取指定节点的值
- rpc GetAccount(google.protobuf.StringValue) returns (libresp.ListResponse) {
+service AccountType {
+ // 获取主账户下的所有子账户
+ rpc ListChildNode (ListChildNodeRequest) returns (libresp.ListResponse) {
}
- // 新增
- rpc AddAccountDict(AddAcDictRequest) returns (libresp.GenericResponse) {
+ // 查询全部账户信息
+ rpc GetAccountType(google.protobuf.Empty) returns (libresp.ListResponse) {
}
- // 删除字典项
- rpc DelAcDict (google.protobuf.StringValue) returns (libresp.Response) {
+ // 通过账户的code获取父账户
+ rpc GetPrincipalValue(google.protobuf.StringValue) returns (libresp.GenericResponse) {
+ }
+ // 新增账户
+ rpc AddAccountType(AddAccountTypeRequest) returns (libresp.GenericResponse) {
+ }
+ // 删除账户,如果删除的是父账户,子账户自动删除
+ rpc DelAccountType (google.protobuf.StringValue) returns (libresp.Response) {
}
+
}
-message AddAcDictRequest {
+message AddAccountTypeRequest {
string category = 1;
string parentId = 2;
- AcDictType type = 3;
+ NodeType type = 3;
string code = 4;
string pyCode = 5;
string name = 6;
string value = 7;
}
-enum AcDictType {
+message ListChildNodeRequest {
+ string parentId = 1;
+}
+enum NodeType {
OmitType = 0;
- Root = 1;
- Group = 2;
- Node = 3;
+ Principal = 1;
+ Sub = 2;
}
\ No newline at end of file