123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298 |
- package http
- import (
- "net/http"
- "strconv"
- "go-common/app/admin/main/tv/conf"
- "go-common/app/admin/main/tv/service"
- "go-common/library/log"
- bm "go-common/library/net/http/blademaster"
- "go-common/library/net/http/blademaster/middleware/permit"
- "go-common/library/net/http/blademaster/middleware/verify"
- "go-common/library/net/http/blademaster/render"
- )
- var (
- tvSrv *service.Service
- vfySvc *verify.Verify
- authSvc *permit.Permit
- )
- const (
- _errIDNotFound = "ids not found"
- _errTitleExist = "Title exists already"
- )
- // Init init http sever instance.
- func Init(c *conf.Config, s *service.Service) {
- initService(c, s)
- engine := bm.DefaultServer(c.HTTPServer)
- innerRouter(engine)
- // init internal server
- if err := engine.Start(); err != nil {
- log.Error("engine.Start error(%v)", err)
- panic(err)
- }
- }
- // initService init service
- func initService(c *conf.Config, s *service.Service) {
- tvSrv = s
- vfySvc = verify.New(nil)
- authSvc = permit.New(c.Auth)
- }
- func parseInt(value string) int64 {
- intval, err := strconv.ParseInt(value, 10, 64)
- if err != nil {
- intval = 0
- }
- return intval
- }
- func atoi(value string) (intval int) {
- intval, err := strconv.Atoi(value)
- if err != nil {
- intval = 0
- }
- return intval
- }
- // innerRouter
- func innerRouter(e *bm.Engine) {
- // ping monitor
- e.GET("/monitor/ping", ping)
- // internal api
- bg := e.Group("/x/admin/tv")
- {
- // cms content edit
- cont := bg.Group("/cont", vfySvc.Verify)
- {
- cont.POST("/online", online)
- cont.POST("/hidden", hidden)
- }
- // pgc ep inject
- epIn := bg.Group("/ep", vfySvc.Verify)
- {
- epIn.POST("/create", createEP)
- epIn.POST("/remove", removeEP)
- }
- // pgc season inject
- snIn := bg.Group("/season", vfySvc.Verify)
- {
- snIn.POST("/create", createSeason)
- snIn.POST("/remove", removeSeason)
- }
- // intervsRank edit
- interv := bg.Group("/intervs", vfySvc.Verify)
- {
- rank := interv.Group("/rank")
- {
- rank.GET("/list", intervsRank)
- rank.POST("/publish", rankPub)
- }
- module := interv.Group("/module")
- {
- module.GET("/list", intervsMod)
- module.POST("/publish", modPub)
- }
- index := interv.Group("/index")
- {
- index.GET("/list", intervsIndex)
- index.POST("/publish", indexPub)
- }
- }
- // audit result
- audit := bg.Group("/audit_result")
- {
- aud := audit.Group("")
- {
- aud.GET("/ep", epResult)
- aud.GET("/season", seasonResult)
- aud.GET("/archive", arcResult)
- aud.GET("/video", videoResult)
- aud.GET("/ugctypes", auditCategory)
- audit.GET("/abnor_export", abnorExport)
- audit.GET("/abnor_debug", abnorDebug)
- }
- audit.POST("/unshelve", authSvc.Permit("TV_MEDIA_DEL"), unShelve)
- }
- // content repository
- crepo := bg.Group("/contrepo", vfySvc.Verify)
- {
- crepo.GET("/list", contList)
- crepo.GET("/info", contInfo)
- crepo.POST("/save", saveCont)
- crepo.GET("/preview", preview)
- crepo.POST("/online", contOnline)
- crepo.POST("/hidden", contHidden)
- crepo.POST("/upload", upbfs)
- }
- // season repo
- srepo := bg.Group("/searepo", vfySvc.Verify)
- {
- srepo.GET("/list", seasonList)
- srepo.GET("/info", seasonInfo)
- srepo.POST("/save", saveSeason)
- srepo.POST("/online", seasonOnline)
- srepo.POST("/hidden", seasonHidden)
- // ugc
- crugc := srepo.Group("/ugc")
- {
- //archive
- crugc.GET("/archive/lists", arcList)
- crugc.GET("/archive/category", arcCategory)
- crugc.POST("/archive/online", arcOnline)
- crugc.POST("/archive/hidden", arcHidden)
- crugc.GET("/archive/arcTypeRPC", arcTypeRPC)
- crugc.POST("/archive/update", arcUpdate)
- //video
- crugc.GET("/video/lists", VideoList)
- crugc.POST("/video/online", VideoOnline)
- crugc.POST("/video/hidden", VideoHidden)
- crugc.GET("/video/preview", VideoPreview)
- crugc.POST("/video/update", videoUpdate)
- }
- }
- // version mgt
- ver := bg.Group("/version", vfySvc.Verify)
- {
- ver.GET("/list", versionList)
- ver.GET("/info", versionInfo)
- ver.POST("/save", saveVersion)
- ver.POST("/add", addVersion)
- ver.POST("/delete", versionDel)
- }
- // version update mgt
- verup := bg.Group("/verupdate", vfySvc.Verify)
- {
- verup.GET("/list", verUpdateList)
- verup.POST("/add", addVerUpdate)
- verup.POST("/save", saveVerUpdate)
- verup.POST("/enable", verUpdateEnable)
- verup.GET("/full", fullPackageImport)
- }
- // channel mgt
- chl := bg.Group("/channel", vfySvc.Verify)
- {
- chl.GET("/list", chlList)
- chl.GET("/info", chlInfo)
- chl.POST("/edit", chlEdit)
- chl.POST("/add", chlAdd)
- chl.POST("/delete", chlDel)
- }
- upper := bg.Group("/upper", authSvc.Permit("TV_AUDIT_MGT"))
- {
- upper.POST("/add", upAdd)
- upper.POST("/import", upImport)
- upper.POST("/del", upDel)
- upper.GET("", upList)
- }
- upCMS := bg.Group("upcms", vfySvc.Verify)
- {
- upCMS.GET("/list", upcmsList)
- upCMS.POST("/audit", upcmsAudit)
- upCMS.POST("/edit", upcmsEdit)
- }
- //search intervene
- si := bg.Group("/searchInter", vfySvc.Verify)
- {
- si.GET("/list", searInterList)
- si.POST("/add", searInterAdd)
- si.POST("/edit", searInterEdit)
- si.POST("/delete", searInterDel)
- si.POST("/rank", searInterRank)
- si.POST("/publish", searInterPublish)
- si.POST("/publishList", searInterPubList)
- }
- bg.POST("/archive/add", authSvc.Permit("TV_AUDIT_MGT"), arcAdd)
- //modules manager
- mod := bg.Group("/modules", vfySvc.Verify)
- {
- mod.POST("/add", modulesAdd)
- mod.GET("/list", modulesList)
- mod.GET("/editGet", modulesEditGet)
- mod.POST("/editPost", modulesEditPost)
- mod.POST("/publish", modulesPublish)
- mod.GET("/sup_cat", supCat)
- }
- //watermark
- wr := bg.Group("/watermark", authSvc.Permit("TV_AUDIT_MGT"))
- {
- wr.GET("/list", waterMarklist)
- wr.POST("/add", waterMarkAdd)
- wr.POST("/delete", waterMarkDelete)
- }
- mango := bg.Group("/mango", authSvc.Permit("TV_AUDIT_MGT"))
- {
- mango.GET("/list", mangoList)
- mango.POST("/add", mangoAdd)
- mango.POST("/edit", mangoEdit)
- mango.POST("/delete", mangoDel)
- mango.POST("/publish", mangoPub)
- }
- trans := bg.Group("/trans", authSvc.Permit("TV_AUDIT_MGT"))
- {
- trans.GET("/list", transList)
- }
- label := bg.Group("/label", vfySvc.Verify)
- {
- label.POST("/act", actLabels)
- label.POST("/edit", editLabel)
- label.POST("/publish", pubLabel)
- ugcLabel := label.Group("/ugc")
- {
- ugcLabel.POST("/add_time", addTime)
- ugcLabel.POST("/edit_time", editTime)
- ugcLabel.POST("/del_time", delTmLabels)
- ugcLabel.GET("/list", ugcLabels)
- }
- pgcLabel := label.Group("/pgc")
- {
- pgcLabel.GET("/list", pgcLabels)
- pgcLabel.GET("/types", pgcLblTps)
- }
- }
- // app manager
- app := bg.Group("/app", vfySvc.Verify)
- {
- // region manager
- reg := app.Group("/region")
- {
- reg.GET("/list", reglist)
- reg.POST("/sort", regSort)
- reg.POST("/save", saveReg)
- reg.POST("/publish", upState)
- }
- }
- // vip tv-vip
- vip := bg.Group("/vip", authSvc.Permit("TV_VIP"))
- {
- // user info
- vip.GET("/user/info", userInfo)
- //order info
- vip.GET("/order/list", orderList)
- //panel info
- panel := vip.Group("/panel")
- {
- panel.GET("/info", panelInfo)
- panel.POST("/status", panelStatus)
- panel.POST("/save", savePanel)
- panel.GET("/list", panelList)
- }
- }
- }
- }
- // ping check server ok.
- func ping(c *bm.Context) {
- }
- func renderErrMsg(c *bm.Context, code int, msg string) {
- data := map[string]interface{}{
- "code": code,
- "message": msg,
- }
- c.Render(http.StatusOK, render.MapJSON(data))
- }
|