master
huanghai 5 years ago
parent c94ab39197
commit fb9079f144

@ -52,10 +52,49 @@ func TreeBasePosition() ([]map[string]interface{}, int, error) {
}
//根据单位ID获取职务信息
func ListBasePositionByBureauId(in *BasePositionProto.QueryArg) ([]map[string]interface{}, int32, error) {
//1、哪个级别
in.
//2、这个单位ID是哪个类型的org_type
//3、如果是学校那么还需要知道 xxbxlxm
func ListBasePositionByBureauId(in *BasePositionProto.ListBasePositionByBureauIdArg) ([]map[string]interface{}, int, error) {
//1、所在单位
bureauId := in.BureauId
//2、获取单位信息
list := SqlKit.QueryByIds([]string{bureauId}, "t_base_organization")
if list == nil || len(list) == 0 {
return nil, -1, nil
}
//这个单位ID是哪个类型的org_type
orgType := list[0]["org_type"].(int64)
xxbxlxm := list[0]["xxbxlxm"].(string)
//区域代码
areaCode := list[0]["area_code"].(string)
//级别
var areaLevel int32
//获取org_type 1:教育局2学校
if orgType == 1 {
//通过areaCode 获取区域级别是1还是2
if areaCode[4:] == "00" {
areaLevel = 1
} else {
areaLevel = 2
}
} else { //2是学校
//如果是学校因为学校全都是在县区中存在所以areaLevel=2
areaLevel = 2
//如果是学校,那么还需要知道 xxbxlxm
}
var myBuilder = builder.Dialect(builder.MYSQL).Select("*").From("t_base_position")
myBuilder.Where(builder.Eq{"b_use": 1})
myBuilder.And(builder.Eq{"area_level": areaLevel})
myBuilder.And(builder.Eq{"org_type": orgType})
//如果是学校,那么还需要判断学校办学类型
if orgType == 2 {
myBuilder.And(builder.Eq{"xxbxlxm": xxbxlxm})
}
myBuilder.OrderBy("sort_id")
//获取拼接完成的SQL语句
sql, err := myBuilder.ToBoundSQL()
if err != nil {
return nil, 0, err
}
//调用多查询字段通用方法
list, err = db.SQL(sql).Query().List()
return list, len(list), err
}

@ -460,7 +460,7 @@ var file_BasePosition_proto_rawDesc = []byte{
0x12, 0x12, 0x0a, 0x04, 0x4c, 0x69, 0x73, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04,
0x4c, 0x69, 0x73, 0x74, 0x22, 0x20, 0x0a, 0x0c, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x49, 0x64,
0x73, 0x41, 0x72, 0x67, 0x12, 0x10, 0x0a, 0x03, 0x49, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28,
0x09, 0x52, 0x03, 0x49, 0x64, 0x73, 0x32, 0xf2, 0x03, 0x0a, 0x12, 0x42, 0x61, 0x73, 0x65, 0x50,
0x09, 0x52, 0x03, 0x49, 0x64, 0x73, 0x32, 0x87, 0x04, 0x0a, 0x12, 0x42, 0x61, 0x73, 0x65, 0x50,
0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x12, 0x4a, 0x0a,
0x0f, 0x47, 0x65, 0x74, 0x42, 0x61, 0x73, 0x65, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e,
0x12, 0x1b, 0x2e, 0x42, 0x61, 0x73, 0x65, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x50,
@ -486,17 +486,18 @@ var file_BasePosition_proto_rawDesc = []byte{
0x73, 0x65, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x2e,
0x51, 0x75, 0x65, 0x72, 0x79, 0x41, 0x72, 0x67, 0x1a, 0x18, 0x2e, 0x42, 0x61, 0x73, 0x65, 0x50,
0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x52, 0x65, 0x70,
0x6c, 0x79, 0x22, 0x00, 0x12, 0x55, 0x0a, 0x1a, 0x4c, 0x69, 0x73, 0x74, 0x42, 0x61, 0x73, 0x65,
0x6c, 0x79, 0x22, 0x00, 0x12, 0x6a, 0x0a, 0x1a, 0x4c, 0x69, 0x73, 0x74, 0x42, 0x61, 0x73, 0x65,
0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x79, 0x42, 0x75, 0x72, 0x65, 0x61, 0x75,
0x49, 0x64, 0x12, 0x1b, 0x2e, 0x42, 0x61, 0x73, 0x65, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f,
0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x41, 0x72, 0x67, 0x1a,
0x18, 0x2e, 0x42, 0x61, 0x73, 0x65, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x72,
0x6f, 0x74, 0x6f, 0x2e, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x42, 0x40, 0x0a, 0x16, 0x63,
0x6f, 0x6d, 0x2e, 0x64, 0x73, 0x69, 0x64, 0x65, 0x61, 0x6c, 0x2e, 0x64, 0x73, 0x6d, 0x69, 0x6e,
0x2e, 0x62, 0x61, 0x73, 0x65, 0x42, 0x0c, 0x42, 0x61, 0x73, 0x65, 0x50, 0x6f, 0x73, 0x69, 0x74,
0x69, 0x6f, 0x6e, 0x50, 0x01, 0x5a, 0x13, 0x2e, 0x3b, 0x42, 0x61, 0x73, 0x65, 0x50, 0x6f, 0x73,
0x69, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0xa2, 0x02, 0x00, 0x62, 0x06, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x33,
0x49, 0x64, 0x12, 0x30, 0x2e, 0x42, 0x61, 0x73, 0x65, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f,
0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x42, 0x61, 0x73, 0x65, 0x50,
0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x79, 0x42, 0x75, 0x72, 0x65, 0x61, 0x75, 0x49,
0x64, 0x41, 0x72, 0x67, 0x1a, 0x18, 0x2e, 0x42, 0x61, 0x73, 0x65, 0x50, 0x6f, 0x73, 0x69, 0x74,
0x69, 0x6f, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00,
0x42, 0x40, 0x0a, 0x16, 0x63, 0x6f, 0x6d, 0x2e, 0x64, 0x73, 0x69, 0x64, 0x65, 0x61, 0x6c, 0x2e,
0x64, 0x73, 0x6d, 0x69, 0x6e, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x42, 0x0c, 0x42, 0x61, 0x73, 0x65,
0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x01, 0x5a, 0x13, 0x2e, 0x3b, 0x42, 0x61,
0x73, 0x65, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0xa2,
0x02, 0x00, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@ -525,7 +526,7 @@ var file_BasePosition_proto_depIdxs = []int32{
4, // 2: BasePositionProto.BasePositionManage.DeleteBasePosition:input_type -> BasePositionProto.DeleteIdsArg
1, // 3: BasePositionProto.BasePositionManage.UpdateBasePosition:input_type -> BasePositionProto.ModelArg
2, // 4: BasePositionProto.BasePositionManage.TreeBasePosition:input_type -> BasePositionProto.QueryArg
2, // 5: BasePositionProto.BasePositionManage.ListBasePositionByBureauId:input_type -> BasePositionProto.QueryArg
0, // 5: BasePositionProto.BasePositionManage.ListBasePositionByBureauId:input_type -> BasePositionProto.ListBasePositionByBureauIdArg
3, // 6: BasePositionProto.BasePositionManage.GetBasePosition:output_type -> BasePositionProto.Reply
3, // 7: BasePositionProto.BasePositionManage.AddBasePosition:output_type -> BasePositionProto.Reply
3, // 8: BasePositionProto.BasePositionManage.DeleteBasePosition:output_type -> BasePositionProto.Reply
@ -649,7 +650,7 @@ type BasePositionManageClient interface {
//获取职务所有的树形结构信息
TreeBasePosition(ctx context.Context, in *QueryArg, opts ...grpc.CallOption) (*Reply, error)
//根据单位ID获取职务信息
ListBasePositionByBureauId(ctx context.Context, in *QueryArg, opts ...grpc.CallOption) (*Reply, error)
ListBasePositionByBureauId(ctx context.Context, in *ListBasePositionByBureauIdArg, opts ...grpc.CallOption) (*Reply, error)
}
type basePositionManageClient struct {
@ -705,7 +706,7 @@ func (c *basePositionManageClient) TreeBasePosition(ctx context.Context, in *Que
return out, nil
}
func (c *basePositionManageClient) ListBasePositionByBureauId(ctx context.Context, in *QueryArg, opts ...grpc.CallOption) (*Reply, error) {
func (c *basePositionManageClient) ListBasePositionByBureauId(ctx context.Context, in *ListBasePositionByBureauIdArg, opts ...grpc.CallOption) (*Reply, error) {
out := new(Reply)
err := c.cc.Invoke(ctx, "/BasePositionProto.BasePositionManage/ListBasePositionByBureauId", in, out, opts...)
if err != nil {
@ -727,7 +728,7 @@ type BasePositionManageServer interface {
//获取职务所有的树形结构信息
TreeBasePosition(context.Context, *QueryArg) (*Reply, error)
//根据单位ID获取职务信息
ListBasePositionByBureauId(context.Context, *QueryArg) (*Reply, error)
ListBasePositionByBureauId(context.Context, *ListBasePositionByBureauIdArg) (*Reply, error)
}
// UnimplementedBasePositionManageServer can be embedded to have forward compatible implementations.
@ -749,7 +750,7 @@ func (*UnimplementedBasePositionManageServer) UpdateBasePosition(context.Context
func (*UnimplementedBasePositionManageServer) TreeBasePosition(context.Context, *QueryArg) (*Reply, error) {
return nil, status.Errorf(codes.Unimplemented, "method TreeBasePosition not implemented")
}
func (*UnimplementedBasePositionManageServer) ListBasePositionByBureauId(context.Context, *QueryArg) (*Reply, error) {
func (*UnimplementedBasePositionManageServer) ListBasePositionByBureauId(context.Context, *ListBasePositionByBureauIdArg) (*Reply, error) {
return nil, status.Errorf(codes.Unimplemented, "method ListBasePositionByBureauId not implemented")
}
@ -848,7 +849,7 @@ func _BasePositionManage_TreeBasePosition_Handler(srv interface{}, ctx context.C
}
func _BasePositionManage_ListBasePositionByBureauId_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(QueryArg)
in := new(ListBasePositionByBureauIdArg)
if err := dec(in); err != nil {
return nil, err
}
@ -860,7 +861,7 @@ func _BasePositionManage_ListBasePositionByBureauId_Handler(srv interface{}, ctx
FullMethod: "/BasePositionProto.BasePositionManage/ListBasePositionByBureauId",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(BasePositionManageServer).ListBasePositionByBureauId(ctx, req.(*QueryArg))
return srv.(BasePositionManageServer).ListBasePositionByBureauId(ctx, req.(*ListBasePositionByBureauIdArg))
}
return interceptor(ctx, in, info, handler)
}

@ -25,7 +25,7 @@ service BasePositionManage {
//
rpc TreeBasePosition (QueryArg) returns (Reply) {}
//ID
rpc ListBasePositionByBureauId (QueryArg) returns (Reply) {}
rpc ListBasePositionByBureauId (ListBasePositionByBureauIdArg) returns (Reply) {}
}
message ListBasePositionByBureauIdArg {

@ -145,7 +145,7 @@ func (s *Rpc) TreeBasePosition(ctx context.Context, in *BasePositionProto.QueryA
}
//根据单位ID获取职务信息
func (s *Rpc) ListBasePositionByBureauId(ctx context.Context, in *BasePositionProto.QueryArg) (*BasePositionProto.Reply, error) {
func (s *Rpc) ListBasePositionByBureauId(ctx context.Context, in *BasePositionProto.ListBasePositionByBureauIdArg) (*BasePositionProto.Reply, error) {
//异常处理
defer func() {
if err := recover(); err != nil {

Loading…
Cancel
Save