123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- package query
- import (
- "context"
- "gd_adm_data/apis"
- "strings"
- "gd_adm_data/errors"
- )
- type InterfaceFunc struct {
- Function func(ctx context.Context, params string) (reply *apis.QueryResponse, err error)
- NeedSupple bool
- NeedFormat bool
- }
- var interfaceFuncMap = map[string]InterfaceFunc{
- "P01": {P01, false, false},
- "P02": {P02, false, false},
- "P03": {P03, false, false},
- "P04": {P04, false, false},
- "P05": {P05, false, false},
- "P06": {P06, false, false},
- "P07": {P07, false, false},
- "P08": {P08, false, false},
- "P09": {P09, false, false},
- "P10": {P10, false, false},
- "A01": {A01, false, false},
- "A02": {A02, true, true},
- "A03": {A03, false, true},
- "V01": {V01, false, false},
- "IS01": {IS01, false, true},
- "V02": {V02, false, false},
- "U01": {U01, false, false},
- "U02": {U02, false, false},
- "A04": {A04, true, true},
- "A05": {A05, false, true},
- "P11": {P11, false, false},
- "F01": {F01, false, false},
- }
- func Query(ctx context.Context, req *apis.QueryRequest, reply *apis.QueryResponse) (err error) {
- code := strings.ToUpper(req.Code)
- if v, ok := interfaceFuncMap[code]; ok {
- vreply, err := v.Function(ctx, req.Params)
- if err != nil {
- return err
- }
- reply.Data = vreply.Data
- if v.NeedSupple {
- u02Reply, uerr := U02(ctx, reply.Data)
- if uerr == nil {
- reply.Data = u02Reply.Data
- }
- }
- if v.NeedFormat {
- f01Reply, ferr := F01(ctx, reply.Data)
- if ferr == nil {
- reply.Data = f01Reply.Data
- }
- }
- return nil
- }
- return errors.InterfaceNoExistError
- }
|