Browse Source

二维码信息添加,获取

icole 4 years ago
parent
commit
b5a194b5d9

+ 21 - 17
internal/logic/get_erp_active_logic.go

@@ -2,6 +2,7 @@ package logic
 
 import (
 	"context"
+	"git.i2edu.net/i2/i2-bill-erp/utils"
 
 	"git.i2edu.net/i2/i2-bill-erp/internal/svc"
 	"git.i2edu.net/i2/i2-bill-erp/transform"
@@ -29,29 +30,32 @@ func (l *GetErpActiveLogic) GetErpActive(in *transform.GetErpActiveReq) (*transf
 		MaName   string `json:"ma_name"`
 		ActiveId int64  `json:"active_id"`
 	}
-	acts := new([]*Active)
+	//acts := new([]*Active)
 	actives := new([]*transform.Active)
-	sql := `
-		select
-    		act.id active_id,act.ma_name
-		from
-    		mkt_activity act
-		left join
-    		mkt_activities_school act_sch
-		on
-    		act.id = act_sch.ma_id
-		where
-    		act.del_flag = 0
-    		and act_sch.school_id = ?  `
-	err := l.svcCtx.DB.SQL(sql, in.SchId).Find(acts)
+	var parmas = make(map[string]interface{})
+	parmas["school_id"] = in.SchId
+	//sql := `
+	//	select
+	//		act.id active_id,act.ma_name
+	//	from
+	//		mkt_activity act
+	//	left join
+	//		mkt_activities_school act_sch
+	//	on
+	//		act.id = act_sch.ma_id
+	//	where
+	//		act.del_flag = 0
+	//		and act_sch.school_id = ?  `
+	result, err := utils.AllSearch(l.svcCtx.DB, "mkt_activity", "all", "mkt_activity", parmas)
+	//err := l.svcCtx.DB.SQL(sql, in.SchId).Find(acts)
 	if err != nil {
 		logx.Error(err.Error())
 		return nil, err
 	}
-	for _, act := range *acts {
+	for _, act := range result {
 		active := new(transform.Active)
-		active.MaName = act.MaName
-		active.ActiveId = act.ActiveId
+		active.MaName = act["ma_name"].(string)
+		active.ActiveId = act["active_id"].(int64)
 		*actives = append(*actives, active)
 	}
 	return &transform.GetErpActiveRes{Active: *actives}, nil

+ 24 - 21
internal/logic/get_erp_organ_sch_per_by_user_id_logic.go

@@ -4,6 +4,7 @@ import (
 	"context"
 	"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"
 
 	"git.i2edu.net/i2/go-zero/core/logx"
 )
@@ -30,33 +31,35 @@ func (l *GetErpOrganSchPerByUserIdLogic) GetErpOrganSchPerByUserId(in *transform
 		OrganId int64  `json:"organ_id"`
 		Id      int64  `json:"id"`
 	}
-	sch := new([]*Sch)
 	schools := new([]*transform.OrganSchool)
-	sql := `
-		SELECT
-    		sch.name,sch.organ_id,sch.id
-		FROM
-    		base_organ_school sch
-		INNER JOIN
-    		base_user_organ_school user_sch
-		ON
-    		sch.id= user_sch.os_id
-		WHERE
-    		sch.del_flag = 0
-    		and user_sch.del_flag = 0
-		    and onoff =98
-    		and user_sch.user_id = ?
-	`
-	err := l.svcCtx.DB.SQL(sql, in.UserId).Find(sch)
+	//sql := `
+	//	SELECT
+	//		sch.name,sch.organ_id,sch.id
+	//	FROM
+	//		base_organ_school sch
+	//	INNER JOIN
+	//		base_user_organ_school user_sch
+	//	ON
+	//		sch.id= user_sch.os_id
+	//	WHERE
+	//		sch.del_flag = 0
+	//		and user_sch.del_flag = 0
+	//	    and onoff =98
+	//		and user_sch.user_id = ?
+	//`
+	var params = make(map[string]interface{})
+	params["user_id"] = in.UserId
+	res, err := utils.AllSearch(l.svcCtx.DB, "base_organ_school", "all", "base_organ_school", params)
+	//err := l.svcCtx.DB.SQL(sql, in.UserId).Find(sch)
 	if err != nil {
 		logx.Error(err.Error())
 		return nil, err
 	}
-	for _, s := range *sch {
+	for _, s := range res {
 		school := new(transform.OrganSchool)
-		school.Id = s.Id
-		school.Name = s.Name
-		school.OrganId = s.OrganId
+		school.Id = s["id"].(int64)
+		school.Name = s["name"].(string)
+		school.OrganId = s["organ_id"].(int64)
 		*schools = append(*schools, school)
 	}
 	return &transform.GetErpOrganSchPerByUserIdRes{School: *schools}, nil

+ 36 - 0
internal/logic/get_erp_organ_sch_tree_logic.go

@@ -0,0 +1,36 @@
+package logic
+
+import (
+	"context"
+	"git.i2edu.net/i2/i2-bill-erp/utils"
+
+	"git.i2edu.net/i2/i2-bill-erp/internal/svc"
+	"git.i2edu.net/i2/i2-bill-erp/transform"
+
+	"github.com/tal-tech/go-zero/core/logx"
+)
+
+type GetErpOrganSchTreeLogic struct {
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+	logx.Logger
+}
+
+func NewGetErpOrganSchTreeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetErpOrganSchTreeLogic {
+	return &GetErpOrganSchTreeLogic{
+		ctx:    ctx,
+		svcCtx: svcCtx,
+		Logger: logx.WithContext(ctx),
+	}
+}
+
+// 获取erp 省、城、校区
+func (l *GetErpOrganSchTreeLogic) GetErpOrganSchTree(in *transform.Empty) (*transform.TreeNodes, error) {
+	// todo: add your logic here and delete this line
+	res, err := utils.TreeSearch(l.svcCtx.DB, "base_organ_school", "tree", "", nil)
+
+	if err != nil {
+		return nil, err
+	}
+	return &transform.TreeNodes{Nodes: res}, err
+}

+ 15 - 6
internal/logic/get_erp_role_logic.go

@@ -3,7 +3,7 @@ package logic
 import (
 	"context"
 	"errors"
-
+	"fmt"
 	"git.i2edu.net/i2/i2-bill-erp/internal/svc"
 	"git.i2edu.net/i2/i2-bill-erp/transform"
 
@@ -27,8 +27,8 @@ func NewGetErpRoleLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetErp
 // 获取 erp 用户角色
 func (l *GetErpRoleLogic) GetErpRole(in *transform.GetErpRoleReq) (*transform.GetErpRoleRes, error) {
 	// todo: add your logic here and delete this line
-	if in.Mobile == "" {
-		return nil, errors.New("mobile is empty")
+	if in.Mobile == "" && in.UserId == "" {
+		return nil, errors.New("mobile and user_id is empty")
 	}
 	sql := `select  
 			sys_user.id user_id,GROUP_CONCAT(sys_role.code)  role
@@ -38,13 +38,22 @@ func (l *GetErpRoleLogic) GetErpRole(in *transform.GetErpRoleReq) (*transform.Ge
 			sys_user_role on sys_user.id=sys_user_role.user_id  
 		  LEFT JOIN  sys_role on sys_user_role.role_id= sys_role.id   
 		  where 
-			 sys_user.mobile = ? GROUP BY sys_user.mobile`
-	result, err := l.svcCtx.DB.SQL(sql, in.Mobile).Query().List()
+			sys_user_role.del_flag =0 and sys_user.status = 0 %s  GROUP BY sys_user.mobile`
+	var args string
+	if in.Mobile != "" {
+		args = in.Mobile
+		sql = fmt.Sprintf(sql, " and sys_user.mobile = ? ")
+	}
+	if in.UserId != "" {
+		args = in.UserId
+		sql = fmt.Sprintf(sql, " and sys_user.id = ? ")
+	}
+	result, err := l.svcCtx.DB.SQL(sql, args).Query().List()
 	if err != nil {
 		return nil, err
 	}
 	if len(result) == 0 {
-		return nil, nil
+		return &transform.GetErpRoleRes{}, nil
 	}
 	user_id, _ := result[0]["user_id"].(string)
 	role, _ := result[0]["role"].(string)

+ 6 - 0
internal/server/transform_server.go

@@ -82,3 +82,9 @@ func (s *TransformServer) GetErpActive(ctx context.Context, in *transform.GetErp
 	l := logic.NewGetErpActiveLogic(ctx, s.svcCtx)
 	return l.GetErpActive(in)
 }
+
+// 获取erp 省、城、校区
+func (s *TransformServer) GetErpOrganSchTree(ctx context.Context, in *transform.Empty) (*transform.TreeNodes, error) {
+	l := logic.NewGetErpOrganSchTreeLogic(ctx, s.svcCtx)
+	return l.GetErpOrganSchTree(in)
+}

+ 13 - 0
sqlconfig/mkt_activity/mkt_activity_all_select.tpl

@@ -0,0 +1,13 @@
+select
+    act.id active_id,act.ma_name
+from
+    mkt_activity act
+left join
+    mkt_activities_school act_sch
+on
+    act.id = act_sch.ma_id
+where
+    {{if .school_id }}
+        act.del_flag = 0
+        and  act_sch.school_id = '{{.school_id}}'
+    {{end}}

+ 0 - 13
sqlconfig/mkt_activity_all.tpl

@@ -1,13 +0,0 @@
-select
-    *
-from
-    mkt_activity act
-left join
-    mkt_activities_school act_sch
-on
-    act.id = act_sch.ma_id
-where
-    act.del_flag = 0
-    {{if ne .school_id ""}}
-    act_sch.school_id = '{{.school_id}}'
-    {{end}}

+ 5 - 4
sqlconfig/base_organ_school_permission_select.tpl → sqlconfig/organ_school/base_organ_school_all_select.tpl

@@ -1,7 +1,8 @@
 SELECT
-    *
+    sch.name,sch.organ_id,sch.id
 FROM
     base_organ_school sch
+{{if .user_id }}
 INNER JOIN
     base_user_organ_school user_sch
 ON
@@ -9,6 +10,6 @@ ON
 WHERE
     sch.del_flag = 0
     and user_sch.del_flag = 0
-    {{if ne .user_id ""}}
-    and user_sch.user_id = '{{.user_id}}'
-    {{end}}
+    and onoff =98
+    and user_sch.user_id = {{.user_id}}
+{{end}}

+ 30 - 0
sqlconfig/organ_school/base_organ_school_tree.tpl

@@ -0,0 +1,30 @@
+SELECT * FROM (
+    SELECT
+        id,
+        name,
+        organ_id + 20000 parent
+    FROM
+        base_organ_school
+WHERE
+        del_flag = 0 and onoff != 99
+UNION
+    SELECT
+        DISTINCT base_organ.id  + 20000 id,
+    name,
+        CASE WHEN base_organ.parent != 0 THEN base_organ.parent + 20000 END parent
+    FROM
+        base_organ
+JOIN (
+    SELECT
+        organ_id,
+        parent,
+        base_organ.inheritance
+    FROM
+        base_organ_school, base_organ
+    WHERE
+        base_organ_school.del_flag = 0
+) base_organ_school ON base_organ.id IN (base_organ_school.organ_id, base_organ_school.parent) OR base_organ_school.inheritance like concat('%|', base_organ.id, '|%')
+WHERE
+    del_flag = 0
+)os_tree
+ORDER BY parent,id

+ 2 - 0
transform.proto

@@ -158,4 +158,6 @@ service Transform {
   rpc GetErpSchool(Empty)  returns(GetErpSchoolRes);
   //获取 erp 活动
   rpc GetErpActive(GetErpActiveReq) returns(GetErpActiveRes);
+  //获取erp 省、城、校区
+  rpc GetErpOrganSchTree(Empty) returns(TreeNodes);
 }

+ 60 - 16
transform/transform.pb.go

@@ -1630,7 +1630,7 @@ var file_transform_proto_rawDesc = []byte{
 	0x76, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0x5f, 0x69, 0x64, 0x18,
 	0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0x49, 0x64, 0x12,
 	0x17, 0x0a, 0x07, 0x6d, 0x61, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09,
-	0x52, 0x06, 0x6d, 0x61, 0x4e, 0x61, 0x6d, 0x65, 0x32, 0x80, 0x06, 0x0a, 0x09, 0x54, 0x72, 0x61,
+	0x52, 0x06, 0x6d, 0x61, 0x4e, 0x61, 0x6d, 0x65, 0x32, 0xbe, 0x06, 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,
@@ -1678,8 +1678,12 @@ var file_transform_proto_rawDesc = []byte{
 	0x69, 0x76, 0x65, 0x12, 0x1a, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x66, 0x6f, 0x72, 0x6d, 0x2e,
 	0x47, 0x65, 0x74, 0x45, 0x72, 0x70, 0x41, 0x63, 0x74, 0x69, 0x76, 0x65, 0x52, 0x65, 0x71, 0x1a,
 	0x1a, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x66, 0x6f, 0x72, 0x6d, 0x2e, 0x47, 0x65, 0x74, 0x45,
-	0x72, 0x70, 0x41, 0x63, 0x74, 0x69, 0x76, 0x65, 0x52, 0x65, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f,
-	0x74, 0x6f, 0x33,
+	0x72, 0x70, 0x41, 0x63, 0x74, 0x69, 0x76, 0x65, 0x52, 0x65, 0x73, 0x12, 0x3c, 0x0a, 0x12, 0x47,
+	0x65, 0x74, 0x45, 0x72, 0x70, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x53, 0x63, 0x68, 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 (
@@ -1743,19 +1747,21 @@ var file_transform_proto_depIdxs = []int32{
 	18, // 15: transform.Transform.GetErpRole:input_type -> transform.GetErpRoleReq
 	4,  // 16: transform.Transform.GetErpSchool:input_type -> transform.Empty
 	23, // 17: transform.Transform.GetErpActive:input_type -> transform.GetErpActiveReq
-	1,  // 18: transform.Transform.GetUser:output_type -> transform.UserResponse
-	3,  // 19: transform.Transform.ParseToken:output_type -> transform.TokenResponse
-	5,  // 20: transform.Transform.GetErpCityTree:output_type -> transform.TreeNodes
-	9,  // 21: transform.Transform.LoadOptionset:output_type -> transform.OptionsetRes
-	14, // 22: transform.Transform.PostExcelLog:output_type -> transform.ExcelLogRes
-	11, // 23: transform.Transform.GetErpOptionset:output_type -> transform.Options
-	5,  // 24: transform.Transform.GetErpMktNetWorkDetailTree:output_type -> transform.TreeNodes
-	20, // 25: transform.Transform.GetErpOrganSchPerByUserId:output_type -> transform.GetErpOrganSchPerByUserIdRes
-	17, // 26: transform.Transform.GetErpRole:output_type -> transform.GetErpRoleRes
-	22, // 27: transform.Transform.GetErpSchool:output_type -> transform.GetErpSchoolRes
-	24, // 28: transform.Transform.GetErpActive:output_type -> transform.GetErpActiveRes
-	18, // [18:29] is the sub-list for method output_type
-	7,  // [7:18] is the sub-list for method input_type
+	4,  // 18: transform.Transform.GetErpOrganSchTree:input_type -> transform.Empty
+	1,  // 19: transform.Transform.GetUser:output_type -> transform.UserResponse
+	3,  // 20: transform.Transform.ParseToken:output_type -> transform.TokenResponse
+	5,  // 21: transform.Transform.GetErpCityTree:output_type -> transform.TreeNodes
+	9,  // 22: transform.Transform.LoadOptionset:output_type -> transform.OptionsetRes
+	14, // 23: transform.Transform.PostExcelLog:output_type -> transform.ExcelLogRes
+	11, // 24: transform.Transform.GetErpOptionset:output_type -> transform.Options
+	5,  // 25: transform.Transform.GetErpMktNetWorkDetailTree:output_type -> transform.TreeNodes
+	20, // 26: transform.Transform.GetErpOrganSchPerByUserId:output_type -> transform.GetErpOrganSchPerByUserIdRes
+	17, // 27: transform.Transform.GetErpRole:output_type -> transform.GetErpRoleRes
+	22, // 28: transform.Transform.GetErpSchool:output_type -> transform.GetErpSchoolRes
+	24, // 29: transform.Transform.GetErpActive:output_type -> transform.GetErpActiveRes
+	5,  // 30: transform.Transform.GetErpOrganSchTree:output_type -> transform.TreeNodes
+	19, // [19:31] is the sub-list for method output_type
+	7,  // [7:19] is the sub-list for method input_type
 	7,  // [7:7] is the sub-list for extension type_name
 	7,  // [7:7] is the sub-list for extension extendee
 	0,  // [0:7] is the sub-list for field type_name
@@ -2130,6 +2136,8 @@ type TransformClient interface {
 	GetErpSchool(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*GetErpSchoolRes, error)
 	//获取 erp 活动
 	GetErpActive(ctx context.Context, in *GetErpActiveReq, opts ...grpc.CallOption) (*GetErpActiveRes, error)
+	//获取erp 省、城、校区
+	GetErpOrganSchTree(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*TreeNodes, error)
 }
 
 type transformClient struct {
@@ -2239,6 +2247,15 @@ func (c *transformClient) GetErpActive(ctx context.Context, in *GetErpActiveReq,
 	return out, nil
 }
 
+func (c *transformClient) GetErpOrganSchTree(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*TreeNodes, error) {
+	out := new(TreeNodes)
+	err := c.cc.Invoke(ctx, "/transform.Transform/GetErpOrganSchTree", 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)
@@ -2259,6 +2276,8 @@ type TransformServer interface {
 	GetErpSchool(context.Context, *Empty) (*GetErpSchoolRes, error)
 	//获取 erp 活动
 	GetErpActive(context.Context, *GetErpActiveReq) (*GetErpActiveRes, error)
+	//获取erp 省、城、校区
+	GetErpOrganSchTree(context.Context, *Empty) (*TreeNodes, error)
 }
 
 // UnimplementedTransformServer can be embedded to have forward compatible implementations.
@@ -2298,6 +2317,9 @@ func (*UnimplementedTransformServer) GetErpSchool(context.Context, *Empty) (*Get
 func (*UnimplementedTransformServer) GetErpActive(context.Context, *GetErpActiveReq) (*GetErpActiveRes, error) {
 	return nil, status.Errorf(codes.Unimplemented, "method GetErpActive not implemented")
 }
+func (*UnimplementedTransformServer) GetErpOrganSchTree(context.Context, *Empty) (*TreeNodes, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method GetErpOrganSchTree not implemented")
+}
 
 func RegisterTransformServer(s *grpc.Server, srv TransformServer) {
 	s.RegisterService(&_Transform_serviceDesc, srv)
@@ -2501,6 +2523,24 @@ func _Transform_GetErpActive_Handler(srv interface{}, ctx context.Context, dec f
 	return interceptor(ctx, in, info, handler)
 }
 
+func _Transform_GetErpOrganSchTree_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).GetErpOrganSchTree(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: "/transform.Transform/GetErpOrganSchTree",
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(TransformServer).GetErpOrganSchTree(ctx, req.(*Empty))
+	}
+	return interceptor(ctx, in, info, handler)
+}
+
 var _Transform_serviceDesc = grpc.ServiceDesc{
 	ServiceName: "transform.Transform",
 	HandlerType: (*TransformServer)(nil),
@@ -2549,6 +2589,10 @@ var _Transform_serviceDesc = grpc.ServiceDesc{
 			MethodName: "GetErpActive",
 			Handler:    _Transform_GetErpActive_Handler,
 		},
+		{
+			MethodName: "GetErpOrganSchTree",
+			Handler:    _Transform_GetErpOrganSchTree_Handler,
+		},
 	},
 	Streams:  []grpc.StreamDesc{},
 	Metadata: "transform.proto",

+ 26 - 18
transformclient/transform.go

@@ -14,32 +14,32 @@ import (
 )
 
 type (
-	ExcelLogRes                  = transform.ExcelLogRes
-	GetErpActiveRes              = transform.GetErpActiveRes
-	UserRequest                  = transform.UserRequest
-	Tag                          = transform.Tag
-	OptionsetReq                 = transform.OptionsetReq
-	OptionCode                   = transform.OptionCode
-	ExcelLogReq                  = transform.ExcelLogReq
+	GetErpActiveReq              = transform.GetErpActiveReq
+	TokenResponse                = transform.TokenResponse
+	TreeNode                     = transform.TreeNode
+	OptionsetRes                 = transform.OptionsetRes
 	Options                      = transform.Options
-	ResponseByte                 = transform.ResponseByte
+	ExcelLogReq                  = transform.ExcelLogReq
 	BytesReq                     = transform.BytesReq
-	GetErpRoleRes                = transform.GetErpRoleRes
-	OrganSchool                  = transform.OrganSchool
-	TokenRequest                 = transform.TokenRequest
+	GetErpRoleReq                = transform.GetErpRoleReq
+	GetErpSchoolRes              = transform.GetErpSchoolRes
+	Empty                        = transform.Empty
 	TreeNodes                    = transform.TreeNodes
+	OptionsetReq                 = transform.OptionsetReq
+	ResponseByte                 = transform.ResponseByte
 	BytesResp                    = transform.BytesResp
 	GetErpOrganSchPerByUserIdReq = transform.GetErpOrganSchPerByUserIdReq
 	GetErpOrganSchPerByUserIdRes = transform.GetErpOrganSchPerByUserIdRes
-	GetErpRoleReq                = transform.GetErpRoleReq
-	GetErpSchoolRes              = transform.GetErpSchoolRes
-	GetErpActiveReq              = transform.GetErpActiveReq
+	GetErpActiveRes              = transform.GetErpActiveRes
 	UserResponse                 = transform.UserResponse
-	TokenResponse                = transform.TokenResponse
-	Empty                        = transform.Empty
-	TreeNode                     = transform.TreeNode
-	OptionsetRes                 = transform.OptionsetRes
+	Tag                          = transform.Tag
+	ExcelLogRes                  = transform.ExcelLogRes
 	Active                       = transform.Active
+	UserRequest                  = transform.UserRequest
+	TokenRequest                 = transform.TokenRequest
+	OptionCode                   = transform.OptionCode
+	GetErpRoleRes                = transform.GetErpRoleRes
+	OrganSchool                  = transform.OrganSchool
 
 	Transform interface {
 		GetUser(ctx context.Context, in *UserRequest) (*UserResponse, error)
@@ -60,6 +60,8 @@ type (
 		GetErpSchool(ctx context.Context, in *Empty) (*GetErpSchoolRes, error)
 		// 获取 erp 活动
 		GetErpActive(ctx context.Context, in *GetErpActiveReq) (*GetErpActiveRes, error)
+		// 获取erp 省、城、校区
+		GetErpOrganSchTree(ctx context.Context, in *Empty) (*TreeNodes, error)
 	}
 
 	defaultTransform struct {
@@ -134,3 +136,9 @@ func (m *defaultTransform) GetErpActive(ctx context.Context, in *GetErpActiveReq
 	client := transform.NewTransformClient(m.cli.Conn())
 	return client.GetErpActive(ctx, in)
 }
+
+// 获取erp 省、城、校区
+func (m *defaultTransform) GetErpOrganSchTree(ctx context.Context, in *Empty) (*TreeNodes, error) {
+	client := transform.NewTransformClient(m.cli.Conn())
+	return client.GetErpOrganSchTree(ctx, in)
+}

+ 39 - 0
utils/build_tree.go

@@ -2,9 +2,37 @@ package utils
 
 import (
 	"container/list"
+	"fmt"
+
 	"git.i2edu.net/i2/i2-bill-erp/transform"
+
+	"github.com/xormplus/xorm"
 )
 
+func TreeSearch(engine *xorm.Engine, controllername string, apiname string, tableName string, paramMap map[string]interface{}) ([]*transform.TreeNode, error) {
+	stplkey := fmt.Sprintf("%s_%s.tpl", controllername, apiname)
+	result, err := engine.SqlTemplateClient(stplkey, &paramMap).Query().List()
+	if err != nil {
+		fmt.Println(err)
+		return nil, err
+	}
+
+	var nodes = new([]*transform.TreeNode)
+
+	if err != nil {
+		return nil, err
+	}
+	for _, n := range result {
+		fmt.Printf("++++++++%T\n", n["parent"])
+		node := new(transform.TreeNode)
+		node.Id = n["id"].(int64)
+		node.Parent, _ = n["parent"].(int64)
+		node.Text = n["name"].(string)
+		*nodes = append(*nodes, node)
+	}
+	return BuildTree(nodes)
+}
+
 func BuildTree(nodes *[]*transform.TreeNode) ([]*transform.TreeNode, error) {
 	originNodeList := list.New()
 	treeNodeList := list.New()
@@ -39,3 +67,14 @@ func BuildTree(nodes *[]*transform.TreeNode) ([]*transform.TreeNode, error) {
 	}
 	return rootArr, nil
 }
+
+func SqlTemplateSearch(engine *xorm.Engine, controllername string, apiname string, tableName string, paramMap map[string]interface{}) ([]map[string]interface{}, error) {
+	stplkey := fmt.Sprintf("%s_%s.tpl", controllername, apiname)
+	result, err := engine.SqlTemplateClient(stplkey, &paramMap).Query().List()
+	if err != nil {
+		fmt.Println(err)
+		return nil, err
+	}
+	return result, nil
+
+}

+ 16 - 0
utils/page_utils.go

@@ -0,0 +1,16 @@
+package utils
+
+import (
+	"fmt"
+	"github.com/xormplus/xorm"
+)
+
+func AllSearch(db *xorm.Engine, controllername string, apiname string, tableName string, params map[string]interface{}) ([]map[string]interface{}, error) {
+	stplkey := fmt.Sprintf("%s_%s_select.tpl", controllername, apiname)
+	result, err := db.SqlTemplateClient(stplkey, &params).Query().List()
+	if err != nil {
+		fmt.Println(err)
+		return nil, err
+	}
+	return result, nil
+}