瀏覽代碼

获取城市树

icole 4 年之前
父節點
當前提交
6ee141af68

+ 1 - 1
go.mod

@@ -10,5 +10,5 @@ require (
 	github.com/thoas/go-funk v0.8.0
 	go.uber.org/automaxprocs v1.4.0 // indirect
 	google.golang.org/grpc v1.29.1
-	google.golang.org/protobuf v1.26.0-rc.1 // indirect
+	google.golang.org/protobuf v1.26.0-rc.1
 )

+ 42 - 0
internal/logic/get_erp_city_tree_logic.go

@@ -0,0 +1,42 @@
+package logic
+
+import (
+	"context"
+	"git.i2edu.net/i2/go-zero/core/logx"
+	"git.i2edu.net/i2/i2-bill-erp/internal/svc"
+	"git.i2edu.net/i2/i2-bill-erp/transform"
+	"git.i2edu.net/i2/i2-bill-erp/utils"
+)
+
+type GetErpCityTreeLogic struct {
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+	logx.Logger
+}
+
+func NewGetErpCityTreeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetErpCityTreeLogic {
+	return &GetErpCityTreeLogic{
+		ctx:    ctx,
+		svcCtx: svcCtx,
+		Logger: logx.WithContext(ctx),
+	}
+}
+
+func (l *GetErpCityTreeLogic) GetErpCityTree() (*transform.TreeNodes, error) {
+	var nodes = new([]*transform.TreeNode)
+	sql := `select
+			base_organ.id,
+			base_organ.name,
+			CASE WHEN base_organ.parent != 0 THEN base_organ.parent END parent
+		from
+			base_organ
+		where
+			base_organ.del_flag = 0
+			group by base_organ.id`
+	err := l.svcCtx.SqlConn.QueryRows(nodes, sql)
+	if err != nil {
+		return nil, err
+	}
+	res, err := utils.BuildTree(nodes)
+	return &transform.TreeNodes{Nodes: res}, err
+}

+ 5 - 0
internal/server/transformserver.go

@@ -25,3 +25,8 @@ func (s *TransformServer) GetUser(ctx context.Context, in *transform.UserRequest
 	l := logic.NewGetUserLogic(ctx, s.svcCtx)
 	return l.GetUser(in)
 }
+
+func (s *TransformServer) GetErpCityTree(ctx context.Context, in *transform.Empty) (*transform.TreeNodes, error) {
+	l := logic.NewGetErpCityTreeLogic(ctx, s.svcCtx)
+	return l.GetErpCityTree()
+}

+ 22 - 0
model/base_organ.sql

@@ -0,0 +1,22 @@
+CREATE TABLE `base_organ`  (
+  `id` int(0) NOT NULL AUTO_INCREMENT,
+  `name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
+  `parent` int(0) NULL DEFAULT NULL,
+  `inheritance` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
+  `create_time` datetime(0) NULL DEFAULT NULL,
+  `last_update_time` datetime(0) NULL DEFAULT NULL,
+  `organ_pinyin` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
+  `organ_number` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
+  `create_by` varchar(36) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
+  `last_update_by` varchar(36) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
+  `if_buy_online` int(0) NULL DEFAULT NULL,
+  `organ_tell` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
+  `del_flag` int(0) NOT NULL DEFAULT 0,
+  `sheng_id` int(0) NULL DEFAULT NULL,
+  `organ_name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
+  `parent_id` int(0) NULL DEFAULT NULL,
+  `organ_type` int(0) NULL DEFAULT NULL,
+  PRIMARY KEY (`id`) USING BTREE,
+  INDEX `IDX_base_organ_parent`(`parent`) USING BTREE,
+  INDEX `IDX_base_organ_sheng_id`(`sheng_id`) USING BTREE
+) ENGINE = InnoDB AUTO_INCREMENT = 20058 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;

+ 92 - 0
model/baseorganmodel.go

@@ -0,0 +1,92 @@
+package model
+
+import (
+	"database/sql"
+	"fmt"
+	"strings"
+
+	"git.i2edu.net/i2/go-zero/core/stores/sqlc"
+	"git.i2edu.net/i2/go-zero/core/stores/sqlx"
+	"git.i2edu.net/i2/go-zero/core/stringx"
+	"git.i2edu.net/i2/go-zero/tools/goctl/model/sql/builderx"
+)
+
+var (
+	baseOrganFieldNames          = builderx.RawFieldNames(&BaseOrgan{})
+	baseOrganRows                = strings.Join(baseOrganFieldNames, ",")
+	baseOrganRowsExpectAutoSet   = strings.Join(stringx.Remove(baseOrganFieldNames, "`id`", "`create_time`", "`update_time`"), ",")
+	baseOrganRowsWithPlaceHolder = strings.Join(stringx.Remove(baseOrganFieldNames, "`id`", "`create_time`", "`update_time`"), "=?,") + "=?"
+)
+
+type (
+	BaseOrganModel interface {
+		Insert(data BaseOrgan) (sql.Result, error)
+		FindOne(id int64) (*BaseOrgan, error)
+		Update(data BaseOrgan) error
+		Delete(id int64) error
+	}
+
+	defaultBaseOrganModel struct {
+		conn  sqlx.SqlConn
+		table string
+	}
+
+	BaseOrgan struct {
+		LastUpdateTime sql.NullTime   `db:"last_update_time" json:"last_update_time"`
+		OrganPinyin    sql.NullString `db:"organ_pinyin" json:"organ_pinyin"`
+		CreateBy       sql.NullString `db:"create_by" json:"create_by"`
+		Inheritance    sql.NullString `db:"inheritance" json:"inheritance"`
+		Parent         sql.NullInt64  `db:"parent" json:"parent"`
+		CreateTime     sql.NullTime   `db:"create_time" json:"create_time"`
+		IfBuyOnline    sql.NullInt64  `db:"if_buy_online" json:"if_buy_online"`
+		DelFlag        int64          `db:"del_flag" json:"del_flag"`
+		ShengId        sql.NullInt64  `db:"sheng_id" json:"sheng_id"`
+		Id             int64          `db:"id" json:"id"`
+		OrganTell      sql.NullString `db:"organ_tell" json:"organ_tell"`
+		OrganName      sql.NullString `db:"organ_name" json:"organ_name"`
+		OrganType      sql.NullInt64  `db:"organ_type" json:"organ_type"`
+		LastUpdateBy   sql.NullString `db:"last_update_by" json:"last_update_by"`
+		OrganNumber    sql.NullString `db:"organ_number" json:"organ_number"`
+		ParentId       sql.NullInt64  `db:"parent_id" json:"parent_id"`
+		Name           sql.NullString `db:"name" json:"name"`
+	}
+)
+
+func NewBaseOrganModel(conn sqlx.SqlConn) BaseOrganModel {
+	return &defaultBaseOrganModel{
+		conn:  conn,
+		table: "`base_organ`",
+	}
+}
+
+func (m *defaultBaseOrganModel) Insert(data BaseOrgan) (sql.Result, error) {
+	query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", m.table, baseOrganRowsExpectAutoSet)
+	ret, err := m.conn.Exec(query, data.LastUpdateTime, data.OrganPinyin, data.CreateBy, data.Inheritance, data.Parent, data.IfBuyOnline, data.DelFlag, data.ShengId, data.OrganTell, data.OrganName, data.OrganType, data.LastUpdateBy, data.OrganNumber, data.ParentId, data.Name)
+	return ret, err
+}
+
+func (m *defaultBaseOrganModel) FindOne(id int64) (*BaseOrgan, error) {
+	query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", baseOrganRows, m.table)
+	var resp BaseOrgan
+	err := m.conn.QueryRow(&resp, query, id)
+	switch err {
+	case nil:
+		return &resp, nil
+	case sqlc.ErrNotFound:
+		return nil, ErrNotFound
+	default:
+		return nil, err
+	}
+}
+
+func (m *defaultBaseOrganModel) Update(data BaseOrgan) error {
+	query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, baseOrganRowsWithPlaceHolder)
+	_, err := m.conn.Exec(query, data.LastUpdateTime, data.OrganPinyin, data.CreateBy, data.Inheritance, data.Parent, data.IfBuyOnline, data.DelFlag, data.ShengId, data.OrganTell, data.OrganName, data.OrganType, data.LastUpdateBy, data.OrganNumber, data.ParentId, data.Name, data.Id)
+	return err
+}
+
+func (m *defaultBaseOrganModel) Delete(id int64) error {
+	query := fmt.Sprintf("delete from %s where `id` = ?", m.table)
+	_, err := m.conn.Exec(query, id)
+	return err
+}

+ 0 - 1
transform.go

@@ -3,7 +3,6 @@ package main
 import (
 	"flag"
 	"fmt"
-
 	"git.i2edu.net/i2/i2-bill-erp/internal/config"
 	"git.i2edu.net/i2/i2-bill-erp/internal/server"
 	"git.i2edu.net/i2/i2-bill-erp/internal/svc"

+ 23 - 0
transform.proto

@@ -2,6 +2,7 @@ syntax = "proto3";
 
 package transform;
 
+
 message UserRequest {
   string id = 1;
   string phone = 2;
@@ -18,6 +19,28 @@ message UserResponse {
   int64 gender          = 8;
 }
 
+message Empty {}
+
+message TreeNodes{
+  repeated  TreeNode nodes = 1;
+}
+
+message TreeNode{
+  int64 id = 1;
+  string text = 2;
+  int64 parent = 3;
+  Tag tag = 4;
+  repeated TreeNode nodes = 5;
+}
+
+message Tag{
+  int64 id = 1;
+  string name = 2;
+}
+
+
+
 service Transform {
   rpc GetUser(UserRequest) returns(UserResponse);
+  rpc GetErpCityTree(Empty) returns(TreeNodes);
 }

+ 556 - 122
transform/transform.pb.go

@@ -1,217 +1,616 @@
 // Code generated by protoc-gen-go. DO NOT EDIT.
+// versions:
+// 	protoc-gen-go v1.23.0
+// 	protoc        v3.12.3
 // source: transform.proto
 
 package transform
 
 import (
 	context "context"
-	fmt "fmt"
 	proto "github.com/golang/protobuf/proto"
 	grpc "google.golang.org/grpc"
 	codes "google.golang.org/grpc/codes"
 	status "google.golang.org/grpc/status"
-	math "math"
+	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
+	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
+	reflect "reflect"
+	sync "sync"
 )
 
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
+const (
+	// Verify that this generated code is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
+	// Verify that runtime/protoimpl is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
+)
 
-// 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
+// This is a compile-time assertion that a sufficiently up-to-date version
+// of the legacy proto package is being used.
+const _ = proto.ProtoPackageIsVersion4
 
 type UserRequest struct {
-	Id                   string   `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
-	Phone                string   `protobuf:"bytes,2,opt,name=phone,proto3" json:"phone,omitempty"`
-	XXX_NoUnkeyedLiteral struct{} `json:"-"`
-	XXX_unrecognized     []byte   `json:"-"`
-	XXX_sizecache        int32    `json:"-"`
-}
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
 
-func (m *UserRequest) Reset()         { *m = UserRequest{} }
-func (m *UserRequest) String() string { return proto.CompactTextString(m) }
-func (*UserRequest) ProtoMessage()    {}
-func (*UserRequest) Descriptor() ([]byte, []int) {
-	return fileDescriptor_cb4a498eeb2ba07d, []int{0}
+	Id    string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
+	Phone string `protobuf:"bytes,2,opt,name=phone,proto3" json:"phone,omitempty"`
 }
 
-func (m *UserRequest) XXX_Unmarshal(b []byte) error {
-	return xxx_messageInfo_UserRequest.Unmarshal(m, b)
-}
-func (m *UserRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
-	return xxx_messageInfo_UserRequest.Marshal(b, m, deterministic)
-}
-func (m *UserRequest) XXX_Merge(src proto.Message) {
-	xxx_messageInfo_UserRequest.Merge(m, src)
+func (x *UserRequest) Reset() {
+	*x = UserRequest{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_transform_proto_msgTypes[0]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
 }
-func (m *UserRequest) XXX_Size() int {
-	return xxx_messageInfo_UserRequest.Size(m)
+
+func (x *UserRequest) String() string {
+	return protoimpl.X.MessageStringOf(x)
 }
-func (m *UserRequest) XXX_DiscardUnknown() {
-	xxx_messageInfo_UserRequest.DiscardUnknown(m)
+
+func (*UserRequest) ProtoMessage() {}
+
+func (x *UserRequest) ProtoReflect() protoreflect.Message {
+	mi := &file_transform_proto_msgTypes[0]
+	if protoimpl.UnsafeEnabled && x != nil {
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		if ms.LoadMessageInfo() == nil {
+			ms.StoreMessageInfo(mi)
+		}
+		return ms
+	}
+	return mi.MessageOf(x)
 }
 
-var xxx_messageInfo_UserRequest proto.InternalMessageInfo
+// Deprecated: Use UserRequest.ProtoReflect.Descriptor instead.
+func (*UserRequest) Descriptor() ([]byte, []int) {
+	return file_transform_proto_rawDescGZIP(), []int{0}
+}
 
-func (m *UserRequest) GetId() string {
-	if m != nil {
-		return m.Id
+func (x *UserRequest) GetId() string {
+	if x != nil {
+		return x.Id
 	}
 	return ""
 }
 
-func (m *UserRequest) GetPhone() string {
-	if m != nil {
-		return m.Phone
+func (x *UserRequest) GetPhone() string {
+	if x != nil {
+		return x.Phone
 	}
 	return ""
 }
 
 type UserResponse struct {
-	Id                   string   `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
-	Phone                string   `protobuf:"bytes,2,opt,name=phone,proto3" json:"phone,omitempty"`
-	Roles                string   `protobuf:"bytes,3,opt,name=roles,proto3" json:"roles,omitempty"`
-	Status               int64    `protobuf:"varint,4,opt,name=status,proto3" json:"status,omitempty"`
-	ErpRoleType          int64    `protobuf:"varint,5,opt,name=erpRoleType,proto3" json:"erpRoleType,omitempty"`
-	UserName             string   `protobuf:"bytes,6,opt,name=userName,proto3" json:"userName,omitempty"`
-	CityName             string   `protobuf:"bytes,7,opt,name=cityName,proto3" json:"cityName,omitempty"`
-	Gender               int64    `protobuf:"varint,8,opt,name=gender,proto3" json:"gender,omitempty"`
-	XXX_NoUnkeyedLiteral struct{} `json:"-"`
-	XXX_unrecognized     []byte   `json:"-"`
-	XXX_sizecache        int32    `json:"-"`
-}
-
-func (m *UserResponse) Reset()         { *m = UserResponse{} }
-func (m *UserResponse) String() string { return proto.CompactTextString(m) }
-func (*UserResponse) ProtoMessage()    {}
-func (*UserResponse) Descriptor() ([]byte, []int) {
-	return fileDescriptor_cb4a498eeb2ba07d, []int{1}
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	Id          string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
+	Phone       string `protobuf:"bytes,2,opt,name=phone,proto3" json:"phone,omitempty"`
+	Roles       string `protobuf:"bytes,3,opt,name=roles,proto3" json:"roles,omitempty"`
+	Status      int64  `protobuf:"varint,4,opt,name=status,proto3" json:"status,omitempty"`
+	ErpRoleType int64  `protobuf:"varint,5,opt,name=erpRoleType,proto3" json:"erpRoleType,omitempty"`
+	UserName    string `protobuf:"bytes,6,opt,name=userName,proto3" json:"userName,omitempty"`
+	CityName    string `protobuf:"bytes,7,opt,name=cityName,proto3" json:"cityName,omitempty"`
+	Gender      int64  `protobuf:"varint,8,opt,name=gender,proto3" json:"gender,omitempty"`
+}
+
+func (x *UserResponse) Reset() {
+	*x = UserResponse{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_transform_proto_msgTypes[1]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
 }
 
-func (m *UserResponse) XXX_Unmarshal(b []byte) error {
-	return xxx_messageInfo_UserResponse.Unmarshal(m, b)
-}
-func (m *UserResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
-	return xxx_messageInfo_UserResponse.Marshal(b, m, deterministic)
+func (x *UserResponse) String() string {
+	return protoimpl.X.MessageStringOf(x)
 }
-func (m *UserResponse) XXX_Merge(src proto.Message) {
-	xxx_messageInfo_UserResponse.Merge(m, src)
+
+func (*UserResponse) ProtoMessage() {}
+
+func (x *UserResponse) ProtoReflect() protoreflect.Message {
+	mi := &file_transform_proto_msgTypes[1]
+	if protoimpl.UnsafeEnabled && x != nil {
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		if ms.LoadMessageInfo() == nil {
+			ms.StoreMessageInfo(mi)
+		}
+		return ms
+	}
+	return mi.MessageOf(x)
 }
-func (m *UserResponse) XXX_Size() int {
-	return xxx_messageInfo_UserResponse.Size(m)
+
+// Deprecated: Use UserResponse.ProtoReflect.Descriptor instead.
+func (*UserResponse) Descriptor() ([]byte, []int) {
+	return file_transform_proto_rawDescGZIP(), []int{1}
 }
-func (m *UserResponse) XXX_DiscardUnknown() {
-	xxx_messageInfo_UserResponse.DiscardUnknown(m)
+
+func (x *UserResponse) GetId() string {
+	if x != nil {
+		return x.Id
+	}
+	return ""
 }
 
-var xxx_messageInfo_UserResponse proto.InternalMessageInfo
+func (x *UserResponse) GetPhone() string {
+	if x != nil {
+		return x.Phone
+	}
+	return ""
+}
 
-func (m *UserResponse) GetId() string {
-	if m != nil {
-		return m.Id
+func (x *UserResponse) GetRoles() string {
+	if x != nil {
+		return x.Roles
 	}
 	return ""
 }
 
-func (m *UserResponse) GetPhone() string {
-	if m != nil {
-		return m.Phone
+func (x *UserResponse) GetStatus() int64 {
+	if x != nil {
+		return x.Status
+	}
+	return 0
+}
+
+func (x *UserResponse) GetErpRoleType() int64 {
+	if x != nil {
+		return x.ErpRoleType
+	}
+	return 0
+}
+
+func (x *UserResponse) GetUserName() string {
+	if x != nil {
+		return x.UserName
 	}
 	return ""
 }
 
-func (m *UserResponse) GetRoles() string {
-	if m != nil {
-		return m.Roles
+func (x *UserResponse) GetCityName() string {
+	if x != nil {
+		return x.CityName
 	}
 	return ""
 }
 
-func (m *UserResponse) GetStatus() int64 {
-	if m != nil {
-		return m.Status
+func (x *UserResponse) GetGender() int64 {
+	if x != nil {
+		return x.Gender
 	}
 	return 0
 }
 
-func (m *UserResponse) GetErpRoleType() int64 {
-	if m != nil {
-		return m.ErpRoleType
+type Empty struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+}
+
+func (x *Empty) Reset() {
+	*x = Empty{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_transform_proto_msgTypes[2]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *Empty) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*Empty) ProtoMessage() {}
+
+func (x *Empty) ProtoReflect() protoreflect.Message {
+	mi := &file_transform_proto_msgTypes[2]
+	if protoimpl.UnsafeEnabled && x != nil {
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		if ms.LoadMessageInfo() == nil {
+			ms.StoreMessageInfo(mi)
+		}
+		return ms
+	}
+	return mi.MessageOf(x)
+}
+
+// Deprecated: Use Empty.ProtoReflect.Descriptor instead.
+func (*Empty) Descriptor() ([]byte, []int) {
+	return file_transform_proto_rawDescGZIP(), []int{2}
+}
+
+type TreeNodes struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	Nodes []*TreeNode `protobuf:"bytes,1,rep,name=nodes,proto3" json:"nodes,omitempty"`
+}
+
+func (x *TreeNodes) Reset() {
+	*x = TreeNodes{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_transform_proto_msgTypes[3]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *TreeNodes) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*TreeNodes) ProtoMessage() {}
+
+func (x *TreeNodes) ProtoReflect() protoreflect.Message {
+	mi := &file_transform_proto_msgTypes[3]
+	if protoimpl.UnsafeEnabled && x != nil {
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		if ms.LoadMessageInfo() == nil {
+			ms.StoreMessageInfo(mi)
+		}
+		return ms
+	}
+	return mi.MessageOf(x)
+}
+
+// Deprecated: Use TreeNodes.ProtoReflect.Descriptor instead.
+func (*TreeNodes) Descriptor() ([]byte, []int) {
+	return file_transform_proto_rawDescGZIP(), []int{3}
+}
+
+func (x *TreeNodes) GetNodes() []*TreeNode {
+	if x != nil {
+		return x.Nodes
+	}
+	return nil
+}
+
+type TreeNode struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	Id     int64       `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
+	Text   string      `protobuf:"bytes,2,opt,name=text,proto3" json:"text,omitempty"`
+	Parent int64       `protobuf:"varint,3,opt,name=parent,proto3" json:"parent,omitempty"`
+	Tag    *Tag        `protobuf:"bytes,4,opt,name=tag,proto3" json:"tag,omitempty"`
+	Nodes  []*TreeNode `protobuf:"bytes,5,rep,name=nodes,proto3" json:"nodes,omitempty"`
+}
+
+func (x *TreeNode) Reset() {
+	*x = TreeNode{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_transform_proto_msgTypes[4]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *TreeNode) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*TreeNode) ProtoMessage() {}
+
+func (x *TreeNode) ProtoReflect() protoreflect.Message {
+	mi := &file_transform_proto_msgTypes[4]
+	if protoimpl.UnsafeEnabled && x != nil {
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		if ms.LoadMessageInfo() == nil {
+			ms.StoreMessageInfo(mi)
+		}
+		return ms
+	}
+	return mi.MessageOf(x)
+}
+
+// Deprecated: Use TreeNode.ProtoReflect.Descriptor instead.
+func (*TreeNode) Descriptor() ([]byte, []int) {
+	return file_transform_proto_rawDescGZIP(), []int{4}
+}
+
+func (x *TreeNode) GetId() int64 {
+	if x != nil {
+		return x.Id
 	}
 	return 0
 }
 
-func (m *UserResponse) GetUserName() string {
-	if m != nil {
-		return m.UserName
+func (x *TreeNode) GetText() string {
+	if x != nil {
+		return x.Text
 	}
 	return ""
 }
 
-func (m *UserResponse) GetCityName() string {
-	if m != nil {
-		return m.CityName
+func (x *TreeNode) GetParent() int64 {
+	if x != nil {
+		return x.Parent
 	}
-	return ""
+	return 0
 }
 
-func (m *UserResponse) GetGender() int64 {
-	if m != nil {
-		return m.Gender
+func (x *TreeNode) GetTag() *Tag {
+	if x != nil {
+		return x.Tag
+	}
+	return nil
+}
+
+func (x *TreeNode) GetNodes() []*TreeNode {
+	if x != nil {
+		return x.Nodes
+	}
+	return nil
+}
+
+type Tag struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	Id   int64  `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
+	Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
+}
+
+func (x *Tag) Reset() {
+	*x = Tag{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_transform_proto_msgTypes[5]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *Tag) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*Tag) ProtoMessage() {}
+
+func (x *Tag) ProtoReflect() protoreflect.Message {
+	mi := &file_transform_proto_msgTypes[5]
+	if protoimpl.UnsafeEnabled && x != nil {
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		if ms.LoadMessageInfo() == nil {
+			ms.StoreMessageInfo(mi)
+		}
+		return ms
+	}
+	return mi.MessageOf(x)
+}
+
+// Deprecated: Use Tag.ProtoReflect.Descriptor instead.
+func (*Tag) Descriptor() ([]byte, []int) {
+	return file_transform_proto_rawDescGZIP(), []int{5}
+}
+
+func (x *Tag) GetId() int64 {
+	if x != nil {
+		return x.Id
 	}
 	return 0
 }
 
-func init() {
-	proto.RegisterType((*UserRequest)(nil), "transform.UserRequest")
-	proto.RegisterType((*UserResponse)(nil), "transform.UserResponse")
+func (x *Tag) GetName() string {
+	if x != nil {
+		return x.Name
+	}
+	return ""
 }
 
-func init() { proto.RegisterFile("transform.proto", fileDescriptor_cb4a498eeb2ba07d) }
+var File_transform_proto protoreflect.FileDescriptor
+
+var file_transform_proto_rawDesc = []byte{
+	0x0a, 0x0f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x66, 0x6f, 0x72, 0x6d, 0x2e, 0x70, 0x72, 0x6f, 0x74,
+	0x6f, 0x12, 0x09, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x66, 0x6f, 0x72, 0x6d, 0x22, 0x33, 0x0a, 0x0b,
+	0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69,
+	0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x70,
+	0x68, 0x6f, 0x6e, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x70, 0x68, 0x6f, 0x6e,
+	0x65, 0x22, 0xd4, 0x01, 0x0a, 0x0c, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
+	0x73, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02,
+	0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28,
+	0x09, 0x52, 0x05, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x6f, 0x6c, 0x65,
+	0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x72, 0x6f, 0x6c, 0x65, 0x73, 0x12, 0x16,
+	0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06,
+	0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x65, 0x72, 0x70, 0x52, 0x6f, 0x6c,
+	0x65, 0x54, 0x79, 0x70, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0b, 0x65, 0x72, 0x70,
+	0x52, 0x6f, 0x6c, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72,
+	0x4e, 0x61, 0x6d, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72,
+	0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x69, 0x74, 0x79, 0x4e, 0x61, 0x6d, 0x65,
+	0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x63, 0x69, 0x74, 0x79, 0x4e, 0x61, 0x6d, 0x65,
+	0x12, 0x16, 0x0a, 0x06, 0x67, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x18, 0x08, 0x20, 0x01, 0x28, 0x03,
+	0x52, 0x06, 0x67, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x22, 0x07, 0x0a, 0x05, 0x45, 0x6d, 0x70, 0x74,
+	0x79, 0x22, 0x36, 0x0a, 0x09, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x73, 0x12, 0x29,
+	0x0a, 0x05, 0x6e, 0x6f, 0x64, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x13, 0x2e,
+	0x74, 0x72, 0x61, 0x6e, 0x73, 0x66, 0x6f, 0x72, 0x6d, 0x2e, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f,
+	0x64, 0x65, 0x52, 0x05, 0x6e, 0x6f, 0x64, 0x65, 0x73, 0x22, 0x93, 0x01, 0x0a, 0x08, 0x54, 0x72,
+	0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01,
+	0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x65, 0x78, 0x74, 0x18, 0x02,
+	0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x65, 0x78, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x61,
+	0x72, 0x65, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x70, 0x61, 0x72, 0x65,
+	0x6e, 0x74, 0x12, 0x20, 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32,
+	0x0e, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x66, 0x6f, 0x72, 0x6d, 0x2e, 0x54, 0x61, 0x67, 0x52,
+	0x03, 0x74, 0x61, 0x67, 0x12, 0x29, 0x0a, 0x05, 0x6e, 0x6f, 0x64, 0x65, 0x73, 0x18, 0x05, 0x20,
+	0x03, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x66, 0x6f, 0x72, 0x6d, 0x2e,
+	0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x05, 0x6e, 0x6f, 0x64, 0x65, 0x73, 0x22,
+	0x29, 0x0a, 0x03, 0x54, 0x61, 0x67, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01,
+	0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02,
+	0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x32, 0x81, 0x01, 0x0a, 0x09, 0x54,
+	0x72, 0x61, 0x6e, 0x73, 0x66, 0x6f, 0x72, 0x6d, 0x12, 0x3a, 0x0a, 0x07, 0x47, 0x65, 0x74, 0x55,
+	0x73, 0x65, 0x72, 0x12, 0x16, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x66, 0x6f, 0x72, 0x6d, 0x2e,
+	0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x74, 0x72,
+	0x61, 0x6e, 0x73, 0x66, 0x6f, 0x72, 0x6d, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70,
+	0x6f, 0x6e, 0x73, 0x65, 0x12, 0x38, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x45, 0x72, 0x70, 0x43, 0x69,
+	0x74, 0x79, 0x54, 0x72, 0x65, 0x65, 0x12, 0x10, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x66, 0x6f,
+	0x72, 0x6d, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x14, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73,
+	0x66, 0x6f, 0x72, 0x6d, 0x2e, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x73, 0x62, 0x06,
+	0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
+}
+
+var (
+	file_transform_proto_rawDescOnce sync.Once
+	file_transform_proto_rawDescData = file_transform_proto_rawDesc
+)
 
-var fileDescriptor_cb4a498eeb2ba07d = []byte{
-	// 232 bytes of a gzipped FileDescriptorProto
-	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x90, 0xb1, 0x4e, 0xc3, 0x30,
-	0x10, 0x86, 0xe5, 0x94, 0xa6, 0xcd, 0x15, 0x81, 0x74, 0x42, 0xc5, 0xea, 0x14, 0x75, 0xea, 0xd4,
-	0x81, 0x6e, 0xbc, 0x40, 0x37, 0x06, 0xab, 0x3c, 0x40, 0x20, 0x07, 0x44, 0x6a, 0x6d, 0x73, 0xe7,
-	0x0c, 0x7d, 0x4f, 0x1e, 0x08, 0xd9, 0xa6, 0x21, 0x12, 0x0b, 0xe3, 0xf7, 0xfd, 0x3a, 0xff, 0xf2,
-	0x0f, 0xb7, 0x81, 0x1b, 0x2b, 0x6f, 0x8e, 0x4f, 0x5b, 0xcf, 0x2e, 0x38, 0xac, 0x06, 0xb1, 0xde,
-	0xc1, 0xe2, 0x59, 0x88, 0x0d, 0x7d, 0xf6, 0x24, 0x01, 0x6f, 0xa0, 0xe8, 0x5a, 0xad, 0x6a, 0xb5,
-	0xa9, 0x4c, 0xd1, 0xb5, 0x78, 0x07, 0x53, 0xff, 0xe1, 0x2c, 0xe9, 0x22, 0xa9, 0x0c, 0xeb, 0x2f,
-	0x05, 0xd7, 0xf9, 0x4a, 0xbc, 0xb3, 0x42, 0xff, 0x3b, 0x8b, 0x96, 0xdd, 0x91, 0x44, 0x4f, 0xb2,
-	0x4d, 0x80, 0x4b, 0x28, 0x25, 0x34, 0xa1, 0x17, 0x7d, 0x55, 0xab, 0xcd, 0xc4, 0xfc, 0x10, 0xd6,
-	0xb0, 0x20, 0xf6, 0xc6, 0x1d, 0xe9, 0x70, 0xf6, 0xa4, 0xa7, 0x29, 0x1c, 0x2b, 0x5c, 0xc1, 0xbc,
-	0x17, 0xe2, 0xa7, 0xe6, 0x44, 0xba, 0x4c, 0x4f, 0x0e, 0x1c, 0xb3, 0xd7, 0x2e, 0x9c, 0x53, 0x36,
-	0xcb, 0xd9, 0x85, 0x63, 0xe3, 0x3b, 0xd9, 0x96, 0x58, 0xcf, 0x73, 0x63, 0xa6, 0x87, 0x3d, 0x54,
-	0x87, 0xcb, 0x30, 0xf8, 0x08, 0xb3, 0x3d, 0x85, 0xf8, 0x4b, 0x5c, 0x6e, 0x7f, 0x07, 0x1c, 0x8d,
-	0xb5, 0xba, 0xff, 0xe3, 0xf3, 0x1c, 0x2f, 0x65, 0x9a, 0x79, 0xf7, 0x1d, 0x00, 0x00, 0xff, 0xff,
-	0x03, 0x6c, 0x0e, 0x00, 0x79, 0x01, 0x00, 0x00,
+func file_transform_proto_rawDescGZIP() []byte {
+	file_transform_proto_rawDescOnce.Do(func() {
+		file_transform_proto_rawDescData = protoimpl.X.CompressGZIP(file_transform_proto_rawDescData)
+	})
+	return file_transform_proto_rawDescData
+}
+
+var file_transform_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
+var file_transform_proto_goTypes = []interface{}{
+	(*UserRequest)(nil),  // 0: transform.UserRequest
+	(*UserResponse)(nil), // 1: transform.UserResponse
+	(*Empty)(nil),        // 2: transform.Empty
+	(*TreeNodes)(nil),    // 3: transform.TreeNodes
+	(*TreeNode)(nil),     // 4: transform.TreeNode
+	(*Tag)(nil),          // 5: transform.Tag
+}
+var file_transform_proto_depIdxs = []int32{
+	4, // 0: transform.TreeNodes.nodes:type_name -> transform.TreeNode
+	5, // 1: transform.TreeNode.tag:type_name -> transform.Tag
+	4, // 2: transform.TreeNode.nodes:type_name -> transform.TreeNode
+	0, // 3: transform.Transform.GetUser:input_type -> transform.UserRequest
+	2, // 4: transform.Transform.GetErpCityTree:input_type -> transform.Empty
+	1, // 5: transform.Transform.GetUser:output_type -> transform.UserResponse
+	3, // 6: transform.Transform.GetErpCityTree:output_type -> transform.TreeNodes
+	5, // [5:7] is the sub-list for method output_type
+	3, // [3:5] is the sub-list for method input_type
+	3, // [3:3] is the sub-list for extension type_name
+	3, // [3:3] is the sub-list for extension extendee
+	0, // [0:3] is the sub-list for field type_name
+}
+
+func init() { file_transform_proto_init() }
+func file_transform_proto_init() {
+	if File_transform_proto != nil {
+		return
+	}
+	if !protoimpl.UnsafeEnabled {
+		file_transform_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*UserRequest); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
+		file_transform_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*UserResponse); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
+		file_transform_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*Empty); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
+		file_transform_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*TreeNodes); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
+		file_transform_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*TreeNode); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
+		file_transform_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*Tag); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
+	}
+	type x struct{}
+	out := protoimpl.TypeBuilder{
+		File: protoimpl.DescBuilder{
+			GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
+			RawDescriptor: file_transform_proto_rawDesc,
+			NumEnums:      0,
+			NumMessages:   6,
+			NumExtensions: 0,
+			NumServices:   1,
+		},
+		GoTypes:           file_transform_proto_goTypes,
+		DependencyIndexes: file_transform_proto_depIdxs,
+		MessageInfos:      file_transform_proto_msgTypes,
+	}.Build()
+	File_transform_proto = out.File
+	file_transform_proto_rawDesc = nil
+	file_transform_proto_goTypes = nil
+	file_transform_proto_depIdxs = nil
 }
 
 // Reference imports to suppress errors if they are not otherwise used.
 var _ context.Context
-var _ grpc.ClientConn
+var _ grpc.ClientConnInterface
 
 // 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
+const _ = grpc.SupportPackageIsVersion6
 
 // TransformClient is the client API for Transform service.
 //
 // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
 type TransformClient interface {
 	GetUser(ctx context.Context, in *UserRequest, opts ...grpc.CallOption) (*UserResponse, error)
+	GetErpCityTree(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*TreeNodes, error)
 }
 
 type transformClient struct {
-	cc *grpc.ClientConn
+	cc grpc.ClientConnInterface
 }
 
-func NewTransformClient(cc *grpc.ClientConn) TransformClient {
+func NewTransformClient(cc grpc.ClientConnInterface) TransformClient {
 	return &transformClient{cc}
 }
 
@@ -224,18 +623,31 @@ func (c *transformClient) GetUser(ctx context.Context, in *UserRequest, opts ...
 	return out, nil
 }
 
+func (c *transformClient) GetErpCityTree(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*TreeNodes, error) {
+	out := new(TreeNodes)
+	err := c.cc.Invoke(ctx, "/transform.Transform/GetErpCityTree", in, out, opts...)
+	if err != nil {
+		return nil, err
+	}
+	return out, nil
+}
+
 // TransformServer is the server API for Transform service.
 type TransformServer interface {
 	GetUser(context.Context, *UserRequest) (*UserResponse, error)
+	GetErpCityTree(context.Context, *Empty) (*TreeNodes, error)
 }
 
 // UnimplementedTransformServer can be embedded to have forward compatible implementations.
 type UnimplementedTransformServer struct {
 }
 
-func (*UnimplementedTransformServer) GetUser(ctx context.Context, req *UserRequest) (*UserResponse, error) {
+func (*UnimplementedTransformServer) GetUser(context.Context, *UserRequest) (*UserResponse, error) {
 	return nil, status.Errorf(codes.Unimplemented, "method GetUser not implemented")
 }
+func (*UnimplementedTransformServer) GetErpCityTree(context.Context, *Empty) (*TreeNodes, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method GetErpCityTree not implemented")
+}
 
 func RegisterTransformServer(s *grpc.Server, srv TransformServer) {
 	s.RegisterService(&_Transform_serviceDesc, srv)
@@ -259,6 +671,24 @@ func _Transform_GetUser_Handler(srv interface{}, ctx context.Context, dec func(i
 	return interceptor(ctx, in, info, handler)
 }
 
+func _Transform_GetErpCityTree_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(Empty)
+	if err := dec(in); err != nil {
+		return nil, err
+	}
+	if interceptor == nil {
+		return srv.(TransformServer).GetErpCityTree(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: "/transform.Transform/GetErpCityTree",
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(TransformServer).GetErpCityTree(ctx, req.(*Empty))
+	}
+	return interceptor(ctx, in, info, handler)
+}
+
 var _Transform_serviceDesc = grpc.ServiceDesc{
 	ServiceName: "transform.Transform",
 	HandlerType: (*TransformServer)(nil),
@@ -267,6 +697,10 @@ var _Transform_serviceDesc = grpc.ServiceDesc{
 			MethodName: "GetUser",
 			Handler:    _Transform_GetUser_Handler,
 		},
+		{
+			MethodName: "GetErpCityTree",
+			Handler:    _Transform_GetErpCityTree_Handler,
+		},
 	},
 	Streams:  []grpc.StreamDesc{},
 	Metadata: "transform.proto",

+ 6 - 0
transformclient/transform.go

@@ -19,6 +19,7 @@ type (
 
 	Transform interface {
 		GetUser(ctx context.Context, in *UserRequest) (*UserResponse, error)
+		GetErpCityTree(ctx context.Context, in *transform.Empty) (*transform.TreeNodes, error)
 	}
 
 	defaultTransform struct {
@@ -36,3 +37,8 @@ func (m *defaultTransform) GetUser(ctx context.Context, in *UserRequest) (*UserR
 	client := transform.NewTransformClient(m.cli.Conn())
 	return client.GetUser(ctx, in)
 }
+
+func (m *defaultTransform) GetErpCityTree(ctx context.Context, in *transform.Empty) (*transform.TreeNodes, error) {
+	client := transform.NewTransformClient(m.cli.Conn())
+	return client.GetErpCityTree(ctx, in)
+}

+ 41 - 0
utils/build_tree.go

@@ -0,0 +1,41 @@
+package utils
+
+import (
+	"container/list"
+	"git.i2edu.net/i2/i2-bill-erp/transform"
+)
+
+func BuildTree(nodes *[]*transform.TreeNode) ([]*transform.TreeNode, error) {
+	originNodeList := list.New()
+	treeNodeList := list.New()
+	var rootArr []*transform.TreeNode
+	for _, node := range *nodes {
+		if node.Parent == 0 {
+			treeNodeList.PushBack(node)
+			rootArr = append(rootArr, node)
+		} else {
+			originNodeList.PushBack(node)
+		}
+	}
+
+	// 把子节点根据parent分配到对应的父节点上
+	for ele := treeNodeList.Front(); ele != nil; ele = ele.Next() {
+		treeNode := ele.Value.(*transform.TreeNode)
+		originEle := originNodeList.Front()
+		if originEle == nil {
+			break
+		}
+		for originEle != nil {
+			originNextEle := originEle.Next()
+			originNode := originEle.Value.(*transform.TreeNode)
+			if originNode.Parent == treeNode.Id {
+				treeNodeList.InsertAfter(originNode, ele)
+				treeNode.Nodes = append(treeNode.Nodes, originNode)
+
+				originNodeList.Remove(originEle)
+			}
+			originEle = originNextEle
+		}
+	}
+	return rootArr, nil
+}