jaryhe 1 سال پیش
والد
کامیت
b85632fccf
1فایلهای تغییر یافته به همراه45 افزوده شده و 33 حذف شده
  1. 45 33
      impl/v1/query/center.go

+ 45 - 33
impl/v1/query/center.go

@@ -8,48 +8,60 @@ import (
 	"gd_adm_data/errors"
 )
 
-func Query(ctx context.Context, req *apis.QueryRequest, reply *apis.QueryResponse) (err error) {
-	interfaces := map[string]func(ctx context.Context, params string) (reply *apis.QueryResponse, err error){
-		"P01":  P01,
-		"P02":  P02,
-		"P03":  P03,
-		"P04":  P04,
-		"P05":  P05,
-		"P06":  P06,
-		"P07":  P07,
-		"P08":  P08,
-		"P09":  P09,
-		"P10":  P10,
-		"A01":  A01,
-		"A02":  A02,
-		"A03":  A03,
-		"V01":  V01,
-		"IS01": IS01,
-		"V02":  V02,
-		"U01":  U01,
-		"U02":  U02,
-		"A04":  A04,
-		"A05":  A05,
-		"P11":  P11,
-		"F01":  F01,
-	}
+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 := interfaces[code]; ok {
-		vreply, err := v(ctx, req.Params)
+	if v, ok := interfaceFuncMap[code]; ok {
+		vreply, err := v.Function(ctx, req.Params)
 		if err != nil {
 			return err
 		}
 
 		reply.Data = vreply.Data
-		/*if code == "U01" {
-			return nil
+		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
+			}
 		}
 
-		uReply, uerr := U01(ctx, reply.Data)
-		if uerr == nil {
-			reply.Data = uReply.Data
-		}*/
 		return nil
 	}