wangshan пре 7 година
комит
a785d03444

+ 30 - 0
src/apiservice/config/config.go

@@ -0,0 +1,30 @@
+package config
+
+import (
+	"log"
+	"qfw/util"
+)
+
+const (
+	REDISDB     = "jyOpenAPI"
+	CODE_E1     = 40000
+	MSG_E1      = "签名错误"
+	CODE_E2     = 40001
+	MSG_E2      = "参数错误"
+	CODE_E3     = 40002
+	MSG_E3      = "签名过期"
+	CODE_E4     = 40003
+	MSG_E4      = "调用接口超过限制"
+	CODE_E5     = 40004
+	MSG_E5      = "内部错误"
+	CODE_ERR_E0 = 40005
+	MSG_ERR_E   = "IP未授权"
+	MSG_SUCCESS = "请求成功"
+)
+
+var Sysconfig map[string]interface{}
+
+func init() {
+	log.Println("--111")
+	util.ReadConfig(&Sysconfig)
+}

+ 22 - 0
src/apiservice/oamanager/oamanager.go

@@ -0,0 +1,22 @@
+package oamanager
+
+import (
+	"log"
+
+	"github.com/go-xweb/xweb"
+)
+
+type Oamanager struct {
+	*xweb.Action
+	openAction xweb.Mapper `xweb:"/open"`
+}
+
+func init() {
+	log.Println("0----")
+	xweb.AddAction(&Oamanager{})
+}
+
+func (o *Oamanager) OpenAction() error {
+	log.Println("000000")
+	return o.Render("/pc/article.html")
+}

+ 6 - 0
src/config.json

@@ -0,0 +1,6 @@
+{
+    "elasticsearch": "http://192.168.3.18:9800",
+    "elasticPoolSize": 30,
+    "redisaddrs": "jyOpenAPI=192.168.3.18:3380",
+    "webport": "8081"
+}

+ 33 - 0
src/main.go

@@ -0,0 +1,33 @@
+package main
+
+import (
+	. "apiservice/config"
+	_ "apiservice/oamanager"
+	"log"
+	"qfw/util"
+	"qfw/util/elastic"
+	"qfw/util/redis"
+
+	"github.com/go-xweb/xweb"
+)
+
+func init() {
+	initXweb()
+	redis.InitRedisBySize(Sysconfig["redisaddrs"].(string), 100, 30, 300)
+	elastic.InitElasticSize(Sysconfig["elasticsearch"].(string), util.IntAllDef(Sysconfig["elasticPoolSize"], 30))
+}
+
+func main() {
+	log.Println(Sysconfig["webport"].(string))
+	go func() {
+		xweb.Run(":" + Sysconfig["webport"].(string))
+	}()
+	b := make(chan bool, 1)
+	<-b
+}
+
+func initXweb() {
+	xweb.RootApp().AppConfig.TemplateDir = "web/templates"
+	xweb.RootApp().AppConfig.StaticDir = "web/staticres"
+	xweb.RootApp().AppConfig.ReloadTemplates = true
+}


+ 1 - 0
src/web/templates/pc/article.html

@@ -0,0 +1 @@
+11111111111