Create & Init Project...
This commit is contained in:
39
app/service/ep/footman/server/http/BUILD
Normal file
39
app/service/ep/footman/server/http/BUILD
Normal file
@ -0,0 +1,39 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_library",
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"bugly.go",
|
||||
"bugly2tapd.go",
|
||||
"http.go",
|
||||
"tapd.go",
|
||||
],
|
||||
importpath = "go-common/app/service/ep/footman/server/http",
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//app/service/ep/footman/conf:go_default_library",
|
||||
"//app/service/ep/footman/service:go_default_library",
|
||||
"//library/log:go_default_library",
|
||||
"//library/net/http/blademaster:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
35
app/service/ep/footman/server/http/bugly.go
Normal file
35
app/service/ep/footman/server/http/bugly.go
Normal file
@ -0,0 +1,35 @@
|
||||
package http
|
||||
|
||||
import (
|
||||
bm "go-common/library/net/http/blademaster"
|
||||
)
|
||||
|
||||
func queryIssue(c *bm.Context) {
|
||||
v := new(struct {
|
||||
Version string `form:"version"`
|
||||
})
|
||||
if err := c.Bind(v); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(srv.Issue(c, v.Version))
|
||||
}
|
||||
|
||||
func updateToken(c *bm.Context) {
|
||||
c.JSON(srv.UpdateToken(c))
|
||||
}
|
||||
|
||||
func saveIssue(c *bm.Context) {
|
||||
v := new(struct {
|
||||
Version string `form:"version"`
|
||||
})
|
||||
if err := c.Bind(v); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(srv.SaveIssue(c, v.Version))
|
||||
}
|
||||
|
||||
func saveIssues(c *bm.Context) {
|
||||
c.JSON(srv.SaveIssues(c))
|
||||
}
|
17
app/service/ep/footman/server/http/bugly2tapd.go
Normal file
17
app/service/ep/footman/server/http/bugly2tapd.go
Normal file
@ -0,0 +1,17 @@
|
||||
package http
|
||||
|
||||
import (
|
||||
bm "go-common/library/net/http/blademaster"
|
||||
)
|
||||
|
||||
func saveBugly2Tapd(c *bm.Context) {
|
||||
c.JSON(nil, srv.AsyncBuglyInsertTapd(c))
|
||||
}
|
||||
|
||||
func updateBuglyStatusInTapd(c *bm.Context) {
|
||||
c.JSON(nil, srv.AsyncUpdateBuglyStatusInTapd(c))
|
||||
}
|
||||
|
||||
func updateTitleInTapd(c *bm.Context) {
|
||||
c.JSON(nil, srv.AsyncUpdateBugInTapd(c))
|
||||
}
|
75
app/service/ep/footman/server/http/http.go
Normal file
75
app/service/ep/footman/server/http/http.go
Normal file
@ -0,0 +1,75 @@
|
||||
package http
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"go-common/app/service/ep/footman/conf"
|
||||
"go-common/app/service/ep/footman/service"
|
||||
"go-common/library/log"
|
||||
bm "go-common/library/net/http/blademaster"
|
||||
)
|
||||
|
||||
var (
|
||||
srv *service.Service
|
||||
)
|
||||
|
||||
// Init Init.
|
||||
func Init(c *conf.Config, s *service.Service) {
|
||||
srv = s
|
||||
engine := bm.DefaultServer(c.BM)
|
||||
engine.Ping(ping)
|
||||
outerRouter(engine)
|
||||
if err := engine.Start(); err != nil {
|
||||
log.Error("engine.Start error(%v)", err)
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func outerRouter(e *bm.Engine) {
|
||||
version := e.Group("/ep/admin/footman/v1")
|
||||
{
|
||||
version.GET("/version", getVersion)
|
||||
|
||||
bugly := version.Group("/bugly")
|
||||
{
|
||||
bugly.GET("/issue/query", queryIssue)
|
||||
bugly.GET("/issue/save", saveIssue)
|
||||
bugly.GET("/saveissue", saveIssue)
|
||||
bugly.GET("/saveissues", saveIssues)
|
||||
bugly.GET("/updatetoken", updateToken)
|
||||
}
|
||||
|
||||
tapd := version.Group("/tapd")
|
||||
{
|
||||
tapd.GET("/file/save", saveFiles)
|
||||
tapd.GET("/file/story/download", downloadStoryFile)
|
||||
tapd.GET("/file/change/download", downloadChangeFile)
|
||||
tapd.GET("/file/iteration/download", downloadIterationFile)
|
||||
tapd.GET("/file/bug/download", downloadBugFile)
|
||||
}
|
||||
|
||||
bugly2tapd := version.Group("/bugly2tapd")
|
||||
{
|
||||
bugly2tapd.GET("/save", saveBugly2Tapd)
|
||||
bugly2tapd.GET("/status/update", updateBuglyStatusInTapd)
|
||||
bugly2tapd.GET("/title/update", updateTitleInTapd)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func ping(c *bm.Context) {
|
||||
if err := srv.Ping(c); err != nil {
|
||||
log.Error("ping error(%v)", err)
|
||||
c.AbortWithStatus(http.StatusServiceUnavailable)
|
||||
}
|
||||
}
|
||||
|
||||
func getVersion(c *bm.Context) {
|
||||
v := new(struct {
|
||||
Version string `json:"version"`
|
||||
})
|
||||
v.Version = "v.1.5.8.2"
|
||||
c.JSON(v, nil)
|
||||
|
||||
}
|
70
app/service/ep/footman/server/http/tapd.go
Normal file
70
app/service/ep/footman/server/http/tapd.go
Normal file
@ -0,0 +1,70 @@
|
||||
package http
|
||||
|
||||
import (
|
||||
"go-common/library/log"
|
||||
bm "go-common/library/net/http/blademaster"
|
||||
)
|
||||
|
||||
func saveFiles(c *bm.Context) {
|
||||
c.JSON(nil, srv.SaveFiles(c))
|
||||
}
|
||||
|
||||
func downloadStoryFile(c *bm.Context) {
|
||||
var (
|
||||
err error
|
||||
data []byte
|
||||
code int
|
||||
)
|
||||
if data, err = srv.DownloadStoryFile(c); err != nil {
|
||||
log.Error("Download story file failed, error:%v", err)
|
||||
code = -1
|
||||
}
|
||||
contentType := " text/plain;charset:utf-8;"
|
||||
c.Writer.Header().Set("content-disposition", `attachment; filename=story.txt`)
|
||||
c.Bytes(code, contentType, data)
|
||||
}
|
||||
|
||||
func downloadChangeFile(c *bm.Context) {
|
||||
var (
|
||||
err error
|
||||
data []byte
|
||||
code int
|
||||
)
|
||||
if data, err = srv.DownloadChangeFile(c); err != nil {
|
||||
log.Error("Download change file failed, error:%v", err)
|
||||
code = -1
|
||||
}
|
||||
contentType := " text/plain;charset:utf-8;"
|
||||
c.Writer.Header().Set("content-disposition", `attachment; filename=change.txt`)
|
||||
c.Bytes(code, contentType, data)
|
||||
}
|
||||
|
||||
func downloadIterationFile(c *bm.Context) {
|
||||
var (
|
||||
err error
|
||||
data []byte
|
||||
code int
|
||||
)
|
||||
if data, err = srv.DownloadIterationFile(c); err != nil {
|
||||
log.Error("Download iteration file failed, error:%v", err)
|
||||
code = -1
|
||||
}
|
||||
contentType := " text/plain;charset:utf-8;"
|
||||
c.Writer.Header().Set("content-disposition", `attachment; filename=iteration.txt`)
|
||||
c.Bytes(code, contentType, data)
|
||||
}
|
||||
|
||||
func downloadBugFile(c *bm.Context) {
|
||||
var (
|
||||
err error
|
||||
data []byte
|
||||
code int
|
||||
)
|
||||
if data, err = srv.DownBugFile(c); err != nil {
|
||||
log.Error("Download bug file failed, error:%v", err)
|
||||
code = -1
|
||||
}
|
||||
contentType := " text/plain;charset:utf-8;"
|
||||
c.Writer.Header().Set("content-disposition", `attachment; filename=bug.txt`)
|
||||
c.Bytes(code, contentType, data)
|
||||
}
|
Reference in New Issue
Block a user