Procházet zdrojové kódy

初始化新增文件

WH01243 před 2 roky
rodič
revize
8835b738ad
1 změnil soubory, kde provedl 71 přidání a 0 odebrání
  1. 71 0
      jyBXSubscribe/rpc/init/pushMapping.go

+ 71 - 0
jyBXSubscribe/rpc/init/pushMapping.go

@@ -0,0 +1,71 @@
+package init
+
+var PushMapping = &pushMapping{}
+
+type pushMapping struct {
+	Area          map[string]int
+	City          map[string]int
+	Toptype       map[string]int
+	Subtype       map[string]int
+	Buyerclass    map[string]int
+	Subscopeclass map[string]int
+}
+
+//推送数据 在mysql中 信息类型和地区等存的对应id;查询的时候需进行转化;
+func (p *pushMapping) Init() {
+	/*infotype := pushServiceMysql.SelectBySql("select id,type,name from infotype")
+	p.Toptype = map[string]int{}
+	p.Subtype = map[string]int{}
+	p.Buyerclass = map[string]int{}
+	p.Subscopeclass = map[string]int{}
+	if infotype != nil && len(*infotype) > 0 {
+		for _, v := range *infotype {
+			id := common.IntAll(v["id"])
+			tp := common.IntAll(v["type"])
+			name := common.ObjToString(v["name"])
+			if tp == 1 {
+				p.Toptype[name] = id
+			} else if tp == 2 {
+				p.Subtype[name] = id
+			} else if tp == 3 {
+				p.Buyerclass[name] = id
+			} else if tp == 4 {
+				p.Subscopeclass[name] = id
+			}
+		}
+		if len(p.Toptype) == 0 {
+			log.Fatalln("PushMapping Toptype Init Error")
+		}
+		if len(p.Subtype) == 0 {
+			log.Fatalln("PushMapping Subtype Init Error")
+		}
+		if len(p.Buyerclass) == 0 {
+			log.Fatalln("PushMapping Buyerclass Init Error")
+		}
+		if len(p.Subscopeclass) == 0 {
+			log.Fatalln("PushMapping Subscopeclass Init Error")
+		}
+	}
+	//
+	p.Area = map[string]int{}
+	p.City = map[string]int{}
+	province := pushServiceMysql.SelectBySql("select id,level,name from province")
+	if province != nil && len(*province) > 0 {
+		for _, v := range *province {
+			id := common.IntAll(v["id"])
+			level := common.IntAll(v["level"])
+			name := common.ObjToString(v["name"])
+			if level == 1 {
+				p.Area[name] = id
+			} else if level == 2 {
+				p.City[name] = id
+			}
+		}
+		if len(p.Area) == 0 {
+			log.Fatalln("PushMapping Area Init Error")
+		}
+		if len(p.City) == 0 {
+			log.Fatalln("PushMapping City Init Error")
+		}
+	}*/
+}