Beispiel #1
0
func run(args []string) {
	defer StopSrv()
	cfile := "conf/ebs.properties"
	if len(args) > 1 {
		cfile = args[1]
	}
	fmt.Println("Using config file:", cfile)
	err := conf.Cfg.InitWithFilePath(cfile)
	if err != nil {
		fmt.Println(err.Error())
		return
	}
	uap_conf.Cfg = conf.Cfg

	//init js conf
	conf.JsConf()

	log.I("Config:\n%v", conf.Cfg.Show())
	//test connect
	if len(conf.DbConn()) < 1 {
		fmt.Println("DB_CONN is not exist in config")
		return
	}

	// uri := "mongodb://*****:*****@192.168.2.30:27017/fs"
	// dbName := "fs"
	//	err = trak.DbInit(conf.TRACE_DB_CONN(), conf.TRACE_DB())
	//	if err != nil {
	//		panic(fmt.Sprintf("connect mongodb err %v", err.Error()))
	//	}

	dbMgr.Init("mysql", conf.DbConn())
	uap.InitDb(dbMgr.DbConn)
	usr.CheckUcs(dbMgr.DbConn())

	if err := nets.RedirectLog(conf.LOG_ADDR(), conf.LOG_PORT(), conf.LOG_KEY(), true); err != nil {
		fmt.Println("remote log error:", err)
	}
	sinfo := `{"description": "ebs接口文档",
    "version": "1.0.0",
    "title": "ebs接口文档"
    }`
	infoParse := map[string]interface{}{}
	json.Unmarshal([]byte(sinfo), &infoParse)
	go_swagger.NewH().InitSwagger(go_swagger.Swagger{
		SwaggerVersion: "2.0",
		Info:           infoParse,
		Host:           "ebs2.dev.jxzy.com",
		BasePath:       "",
		Schemes:        []string{"http"},
	}).AddTag(go_swagger.Tag{Name: "answer", Description: "作答相关接口"})

	//
	//
	mux := http.NewServeMux()
	mux.Handle("/", NewSrvMux(mux, "", "www"))
	log.D("running server on %s", conf.ListenAddr())
	s := http.Server{Addr: conf.ListenAddr(), Handler: mux}
	err = s.ListenAndServe()
	if err != nil {
		fmt.Println(err)
	}
}
Beispiel #2
0
package bank

import (
	common_ "com.dy.ebs/common"
	"com.dy.ebs/dbMgr"
	"database/sql"
	"encoding/json"
	"fmt"
	"github.com/Centny/gwf/log"
	"github.com/Centny/gwf/routing"
	"github.com/tomlovzki/go_swagger"
)

var _ = go_swagger.NewH().AddPath("/usr/save-answer", map[string]go_swagger.Path{"post": go_swagger.Path{
	Tags:        []string{"answer"},
	Summary:     "保存作答接口",
	Description: "保存作答接口",
	Consumes:    []string{"application/json"},
	Produces:    []string{"application/json"},
	Parameters: []go_swagger.Parameters{
		go_swagger.Parameters{
			In:          "formData",
			Name:        "aId",
			Description: `作答id`,
			Type:        "integer",
		},
		go_swagger.Parameters{
			In:   "formData",
			Name: "a",
			Description: `作答内容,eg:[{"aItem":["A","B"],"seq":"1","qId":6}]
--一个{"aItem":["A","B"],"seq":1,"qId":6}为一道题目的答案,aItem为一道题目的每一个空答案,seq为题目编号,qId为题目id,传参注意区分字符串类型和数字类型`,