Create & Init Project...
This commit is contained in:
23
app/interface/main/mcn/server/BUILD
Normal file
23
app/interface/main/mcn/server/BUILD
Normal file
@ -0,0 +1,23 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_test",
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [
|
||||
":package-srcs",
|
||||
"//app/interface/main/mcn/server/http:all-srcs",
|
||||
],
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
60
app/interface/main/mcn/server/http/BUILD
Normal file
60
app/interface/main/mcn/server/http/BUILD
Normal file
@ -0,0 +1,60 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_library",
|
||||
"go_test",
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"api.go",
|
||||
"creative.go",
|
||||
"data.go",
|
||||
"http.go",
|
||||
"http_base.go",
|
||||
"mcn.go",
|
||||
"upload.go",
|
||||
],
|
||||
importpath = "go-common/app/interface/main/mcn/server/http",
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//app/interface/main/mcn/conf:go_default_library",
|
||||
"//app/interface/main/mcn/model/mcnmodel:go_default_library",
|
||||
"//app/interface/main/mcn/service:go_default_library",
|
||||
"//library/ecode:go_default_library",
|
||||
"//library/log:go_default_library",
|
||||
"//library/net/http/blademaster:go_default_library",
|
||||
"//library/net/http/blademaster/middleware/antispam:go_default_library",
|
||||
"//library/net/http/blademaster/middleware/auth:go_default_library",
|
||||
"//library/net/http/blademaster/middleware/verify: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"],
|
||||
)
|
||||
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = ["http_test.go"],
|
||||
embed = [":go_default_library"],
|
||||
rundir = ".",
|
||||
tags = ["automanaged"],
|
||||
deps = [
|
||||
"//app/admin/main/mcn/model:go_default_library",
|
||||
"//library/net/http/blademaster/binding:go_default_library",
|
||||
],
|
||||
)
|
177
app/interface/main/mcn/server/http/api.go
Normal file
177
app/interface/main/mcn/server/http/api.go
Normal file
@ -0,0 +1,177 @@
|
||||
package http
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"go-common/app/interface/main/mcn/model/mcnmodel"
|
||||
"go-common/library/net/http/blademaster"
|
||||
)
|
||||
|
||||
func mcnGetRankArchiveLikesAPI(c *blademaster.Context) {
|
||||
oarg := new(mcnmodel.McnGetRankAPIReq)
|
||||
httpGetFunc(
|
||||
oarg,
|
||||
func(context context.Context, arg interface{}) (res interface{}, err error) {
|
||||
return srv.McnGetRankArchiveLikesAPI(context, arg.(*mcnmodel.McnGetRankAPIReq))
|
||||
},
|
||||
"McnGetRankArchiveLikesAPI",
|
||||
nil,
|
||||
nil,
|
||||
)(c)
|
||||
}
|
||||
|
||||
func getMcnSummaryAPI(c *blademaster.Context) {
|
||||
oarg := new(mcnmodel.McnGetDataSummaryReq)
|
||||
httpGetFunc(
|
||||
oarg,
|
||||
func(context context.Context, arg interface{}) (res interface{}, err error) {
|
||||
return srv.GetMcnSummaryAPI(context, arg.(*mcnmodel.McnGetDataSummaryReq))
|
||||
},
|
||||
"GetMcnSummaryAPI",
|
||||
nil,
|
||||
nil,
|
||||
)(c)
|
||||
}
|
||||
|
||||
func getIndexIncAPI(c *blademaster.Context) {
|
||||
oarg := new(mcnmodel.McnGetIndexIncReq)
|
||||
httpGetFunc(
|
||||
oarg,
|
||||
func(context context.Context, arg interface{}) (res interface{}, err error) {
|
||||
return srv.GetIndexIncAPI(context, arg.(*mcnmodel.McnGetIndexIncReq))
|
||||
},
|
||||
"GetIndexIncAPI",
|
||||
nil,
|
||||
nil,
|
||||
)(c)
|
||||
}
|
||||
|
||||
func getIndexSourceAPI(c *blademaster.Context) {
|
||||
oarg := new(mcnmodel.McnGetIndexSourceReq)
|
||||
httpGetFunc(
|
||||
oarg,
|
||||
func(context context.Context, arg interface{}) (res interface{}, err error) {
|
||||
return srv.GetIndexSourceAPI(context, arg.(*mcnmodel.McnGetIndexSourceReq))
|
||||
},
|
||||
"GetIndexSourceAPI",
|
||||
nil,
|
||||
nil,
|
||||
)(c)
|
||||
}
|
||||
|
||||
func getPlaySourceAPI(c *blademaster.Context) {
|
||||
oarg := new(mcnmodel.McnGetPlaySourceReq)
|
||||
httpGetFunc(
|
||||
oarg,
|
||||
func(context context.Context, arg interface{}) (res interface{}, err error) {
|
||||
return srv.GetPlaySourceAPI(context, arg.(*mcnmodel.McnGetPlaySourceReq))
|
||||
},
|
||||
"GetPlaySourceAPI",
|
||||
nil,
|
||||
nil,
|
||||
)(c)
|
||||
}
|
||||
|
||||
func getMcnFansAPI(c *blademaster.Context) {
|
||||
oarg := new(mcnmodel.McnGetMcnFansReq)
|
||||
httpGetFunc(
|
||||
oarg,
|
||||
func(context context.Context, arg interface{}) (res interface{}, err error) {
|
||||
return srv.GetMcnFansAPI(context, arg.(*mcnmodel.McnGetMcnFansReq))
|
||||
},
|
||||
"GetMcnFansAPI",
|
||||
nil,
|
||||
nil,
|
||||
)(c)
|
||||
}
|
||||
|
||||
func getMcnFansIncAPI(c *blademaster.Context) {
|
||||
oarg := new(mcnmodel.McnGetMcnFansIncReq)
|
||||
httpGetFunc(
|
||||
oarg,
|
||||
func(context context.Context, arg interface{}) (res interface{}, err error) {
|
||||
return srv.GetMcnFansIncAPI(context, arg.(*mcnmodel.McnGetMcnFansIncReq))
|
||||
},
|
||||
"GetMcnFansIncAPI",
|
||||
nil,
|
||||
nil,
|
||||
)(c)
|
||||
}
|
||||
|
||||
func getMcnFansDecAPI(c *blademaster.Context) {
|
||||
oarg := new(mcnmodel.McnGetMcnFansDecReq)
|
||||
httpGetFunc(
|
||||
oarg,
|
||||
func(context context.Context, arg interface{}) (res interface{}, err error) {
|
||||
return srv.GetMcnFansDecAPI(context, arg.(*mcnmodel.McnGetMcnFansDecReq))
|
||||
},
|
||||
"GetMcnFansDecAPI",
|
||||
nil,
|
||||
nil,
|
||||
)(c)
|
||||
}
|
||||
|
||||
func getMcnFansAttentionWayAPI(c *blademaster.Context) {
|
||||
oarg := new(mcnmodel.McnGetMcnFansAttentionWayReq)
|
||||
httpGetFunc(
|
||||
oarg,
|
||||
func(context context.Context, arg interface{}) (res interface{}, err error) {
|
||||
return srv.GetMcnFansAttentionWayAPI(context, arg.(*mcnmodel.McnGetMcnFansAttentionWayReq))
|
||||
},
|
||||
"GetMcnFansAttentionWayAPI",
|
||||
nil,
|
||||
nil,
|
||||
)(c)
|
||||
}
|
||||
|
||||
func getFansBaseFansAttrAPI(c *blademaster.Context) {
|
||||
oarg := new(mcnmodel.McnGetBaseFansAttrReq)
|
||||
httpGetFunc(
|
||||
oarg,
|
||||
func(context context.Context, arg interface{}) (res interface{}, err error) {
|
||||
return srv.GetFansBaseFansAttrAPI(context, arg.(*mcnmodel.McnGetBaseFansAttrReq))
|
||||
},
|
||||
"GetFansBaseFansAttrAPI",
|
||||
nil,
|
||||
nil,
|
||||
)(c)
|
||||
}
|
||||
|
||||
func getFansAreaAPI(c *blademaster.Context) {
|
||||
oarg := new(mcnmodel.McnGetFansAreaReq)
|
||||
httpGetFunc(
|
||||
oarg,
|
||||
func(context context.Context, arg interface{}) (res interface{}, err error) {
|
||||
return srv.GetFansAreaAPI(context, arg.(*mcnmodel.McnGetFansAreaReq))
|
||||
},
|
||||
"GetFansAreaAPI",
|
||||
nil,
|
||||
nil,
|
||||
)(c)
|
||||
}
|
||||
|
||||
func getFansTypeAPI(c *blademaster.Context) {
|
||||
oarg := new(mcnmodel.McnGetFansTypeReq)
|
||||
httpGetFunc(
|
||||
oarg,
|
||||
func(context context.Context, arg interface{}) (res interface{}, err error) {
|
||||
return srv.GetFansTypeAPI(context, arg.(*mcnmodel.McnGetFansTypeReq))
|
||||
},
|
||||
"GetFansTypeAPI",
|
||||
nil,
|
||||
nil,
|
||||
)(c)
|
||||
}
|
||||
|
||||
func getFansTagAPI(c *blademaster.Context) {
|
||||
oarg := new(mcnmodel.McnGetFansTagReq)
|
||||
httpGetFunc(
|
||||
oarg,
|
||||
func(context context.Context, arg interface{}) (res interface{}, err error) {
|
||||
return srv.GetFansTagAPI(context, arg.(*mcnmodel.McnGetFansTagReq))
|
||||
},
|
||||
"GetFansTagAPI",
|
||||
nil,
|
||||
nil,
|
||||
)(c)
|
||||
}
|
231
app/interface/main/mcn/server/http/creative.go
Normal file
231
app/interface/main/mcn/server/http/creative.go
Normal file
@ -0,0 +1,231 @@
|
||||
package http
|
||||
|
||||
import (
|
||||
"go-common/app/interface/main/mcn/model/mcnmodel"
|
||||
"go-common/library/net/http/blademaster"
|
||||
)
|
||||
|
||||
// archives handler
|
||||
func archives(c *blademaster.Context) {
|
||||
var err error
|
||||
v := new(mcnmodel.ArchivesReq)
|
||||
if err = c.Bind(v); err != nil {
|
||||
return
|
||||
}
|
||||
mcnMid, _ := c.Get("mid")
|
||||
common := &mcnmodel.CreativeCommonReq{
|
||||
UpMid: v.UpMid,
|
||||
McnMid: mcnMid.(int64),
|
||||
}
|
||||
c.JSON(srv.CreativeHandle(c, common, c.Request.Form, "archives"))
|
||||
}
|
||||
|
||||
// archiveHistoryList handler
|
||||
func archiveHistoryList(c *blademaster.Context) {
|
||||
var err error
|
||||
v := new(mcnmodel.ArchiveHistoryListReq)
|
||||
if err = c.Bind(v); err != nil {
|
||||
return
|
||||
}
|
||||
mcnMid, _ := c.Get("mid")
|
||||
common := &mcnmodel.CreativeCommonReq{
|
||||
UpMid: v.UpMid,
|
||||
McnMid: mcnMid.(int64),
|
||||
}
|
||||
c.JSON(srv.CreativeHandle(c, common, c.Request.Form, "archiveHistoryList"))
|
||||
}
|
||||
|
||||
// archiveVideos handler
|
||||
func archiveVideos(c *blademaster.Context) {
|
||||
var err error
|
||||
v := new(mcnmodel.ArchiveVideosReq)
|
||||
if err = c.Bind(v); err != nil {
|
||||
return
|
||||
}
|
||||
mcnMid, _ := c.Get("mid")
|
||||
common := &mcnmodel.CreativeCommonReq{
|
||||
UpMid: v.UpMid,
|
||||
McnMid: mcnMid.(int64),
|
||||
}
|
||||
c.JSON(srv.CreativeHandle(c, common, c.Request.Form, "archiveVideos"))
|
||||
}
|
||||
|
||||
// dataArchive handler
|
||||
func dataArchive(c *blademaster.Context) {
|
||||
var err error
|
||||
v := new(mcnmodel.DataArchiveReq)
|
||||
if err = c.Bind(v); err != nil {
|
||||
return
|
||||
}
|
||||
mcnMid, _ := c.Get("mid")
|
||||
common := &mcnmodel.CreativeCommonReq{
|
||||
UpMid: v.UpMid,
|
||||
McnMid: mcnMid.(int64),
|
||||
}
|
||||
c.JSON(srv.CreativeHandle(c, common, c.Request.Form, "dataArchive"))
|
||||
}
|
||||
|
||||
// dataVideoQuit handler
|
||||
func dataVideoQuit(c *blademaster.Context) {
|
||||
var err error
|
||||
v := new(mcnmodel.DataVideoQuitReq)
|
||||
if err = c.Bind(v); err != nil {
|
||||
return
|
||||
}
|
||||
mcnMid, _ := c.Get("mid")
|
||||
common := &mcnmodel.CreativeCommonReq{
|
||||
UpMid: v.UpMid,
|
||||
McnMid: mcnMid.(int64),
|
||||
}
|
||||
c.JSON(srv.CreativeHandle(c, common, c.Request.Form, "dataVideoQuit"))
|
||||
}
|
||||
|
||||
// danmuDistri handler
|
||||
func danmuDistri(c *blademaster.Context) {
|
||||
var err error
|
||||
v := new(mcnmodel.DanmuDistriReq)
|
||||
if err = c.Bind(v); err != nil {
|
||||
return
|
||||
}
|
||||
mcnMid, _ := c.Get("mid")
|
||||
common := &mcnmodel.CreativeCommonReq{
|
||||
UpMid: v.UpMid,
|
||||
McnMid: mcnMid.(int64),
|
||||
}
|
||||
c.JSON(srv.CreativeHandle(c, common, c.Request.Form, "danmuDistri"))
|
||||
}
|
||||
|
||||
// dataBase handler
|
||||
func dataBase(c *blademaster.Context) {
|
||||
var err error
|
||||
v := new(mcnmodel.DataBaseReq)
|
||||
if err = c.Bind(v); err != nil {
|
||||
return
|
||||
}
|
||||
mcnMid, _ := c.Get("mid")
|
||||
common := &mcnmodel.CreativeCommonReq{
|
||||
UpMid: v.UpMid,
|
||||
McnMid: mcnMid.(int64),
|
||||
}
|
||||
c.JSON(srv.CreativeHandle(c, common, c.Request.Form, "dataBase"))
|
||||
}
|
||||
|
||||
// dataTrend handler
|
||||
func dataTrend(c *blademaster.Context) {
|
||||
var err error
|
||||
v := new(mcnmodel.DataTrendReq)
|
||||
if err = c.Bind(v); err != nil {
|
||||
return
|
||||
}
|
||||
mcnMid, _ := c.Get("mid")
|
||||
common := &mcnmodel.CreativeCommonReq{
|
||||
UpMid: v.UpMid,
|
||||
McnMid: mcnMid.(int64),
|
||||
}
|
||||
c.JSON(srv.CreativeHandle(c, common, c.Request.Form, "dataTrend"))
|
||||
}
|
||||
|
||||
// dataAction handler
|
||||
func dataAction(c *blademaster.Context) {
|
||||
var err error
|
||||
v := new(mcnmodel.DataActionReq)
|
||||
if err = c.Bind(v); err != nil {
|
||||
return
|
||||
}
|
||||
mcnMid, _ := c.Get("mid")
|
||||
common := &mcnmodel.CreativeCommonReq{
|
||||
UpMid: v.UpMid,
|
||||
McnMid: mcnMid.(int64),
|
||||
}
|
||||
c.JSON(srv.CreativeHandle(c, common, c.Request.Form, "dataAction"))
|
||||
}
|
||||
|
||||
// dataFan handler
|
||||
func dataFan(c *blademaster.Context) {
|
||||
var err error
|
||||
v := new(mcnmodel.DataFanReq)
|
||||
if err = c.Bind(v); err != nil {
|
||||
return
|
||||
}
|
||||
mcnMid, _ := c.Get("mid")
|
||||
common := &mcnmodel.CreativeCommonReq{
|
||||
UpMid: v.UpMid,
|
||||
McnMid: mcnMid.(int64),
|
||||
}
|
||||
c.JSON(srv.CreativeHandle(c, common, c.Request.Form, "dataFan"))
|
||||
}
|
||||
|
||||
// dataPandect handler
|
||||
func dataPandect(c *blademaster.Context) {
|
||||
var err error
|
||||
v := new(mcnmodel.DataPandectReq)
|
||||
if err = c.Bind(v); err != nil {
|
||||
return
|
||||
}
|
||||
mcnMid, _ := c.Get("mid")
|
||||
common := &mcnmodel.CreativeCommonReq{
|
||||
UpMid: v.UpMid,
|
||||
McnMid: mcnMid.(int64),
|
||||
}
|
||||
c.JSON(srv.CreativeHandle(c, common, c.Request.Form, "dataPandect"))
|
||||
}
|
||||
|
||||
// dataSurvey handler
|
||||
func dataSurvey(c *blademaster.Context) {
|
||||
var err error
|
||||
v := new(mcnmodel.DataSurveyReq)
|
||||
if err = c.Bind(v); err != nil {
|
||||
return
|
||||
}
|
||||
mcnMid, _ := c.Get("mid")
|
||||
common := &mcnmodel.CreativeCommonReq{
|
||||
UpMid: v.UpMid,
|
||||
McnMid: mcnMid.(int64),
|
||||
}
|
||||
c.JSON(srv.CreativeHandle(c, common, c.Request.Form, "dataSurvey"))
|
||||
}
|
||||
|
||||
// dataPlaySource handler
|
||||
func dataPlaySource(c *blademaster.Context) {
|
||||
var err error
|
||||
v := new(mcnmodel.DataPlaySourceReq)
|
||||
if err = c.Bind(v); err != nil {
|
||||
return
|
||||
}
|
||||
mcnMid, _ := c.Get("mid")
|
||||
common := &mcnmodel.CreativeCommonReq{
|
||||
UpMid: v.UpMid,
|
||||
McnMid: mcnMid.(int64),
|
||||
}
|
||||
c.JSON(srv.CreativeHandle(c, common, c.Request.Form, "dataPlaySource"))
|
||||
}
|
||||
|
||||
// dataPlayAnalysis handler
|
||||
func dataPlayAnalysis(c *blademaster.Context) {
|
||||
var err error
|
||||
v := new(mcnmodel.DataPlayAnalysisReq)
|
||||
if err = c.Bind(v); err != nil {
|
||||
return
|
||||
}
|
||||
mcnMid, _ := c.Get("mid")
|
||||
common := &mcnmodel.CreativeCommonReq{
|
||||
UpMid: v.UpMid,
|
||||
McnMid: mcnMid.(int64),
|
||||
}
|
||||
c.JSON(srv.CreativeHandle(c, common, c.Request.Form, "dataPlayAnalysis"))
|
||||
}
|
||||
|
||||
// dataArticleRank handler
|
||||
func dataArticleRank(c *blademaster.Context) {
|
||||
var err error
|
||||
v := new(mcnmodel.DataArticleRankReq)
|
||||
if err = c.Bind(v); err != nil {
|
||||
return
|
||||
}
|
||||
mcnMid, _ := c.Get("mid")
|
||||
common := &mcnmodel.CreativeCommonReq{
|
||||
UpMid: v.UpMid,
|
||||
McnMid: mcnMid.(int64),
|
||||
}
|
||||
c.JSON(srv.CreativeHandle(c, common, c.Request.Form, "dataArticleRank"))
|
||||
}
|
150
app/interface/main/mcn/server/http/data.go
Normal file
150
app/interface/main/mcn/server/http/data.go
Normal file
@ -0,0 +1,150 @@
|
||||
package http
|
||||
|
||||
import (
|
||||
"context"
|
||||
"go-common/app/interface/main/mcn/model/mcnmodel"
|
||||
"go-common/library/net/http/blademaster"
|
||||
)
|
||||
|
||||
func mcnGetMcnGetIndexInc(c *blademaster.Context) {
|
||||
oarg := new(mcnmodel.McnGetIndexIncReq)
|
||||
httpGetFunc(
|
||||
oarg,
|
||||
func(context context.Context, arg interface{}) (res interface{}, err error) {
|
||||
return srv.GetMcnGetIndexInc(context, arg.(*mcnmodel.McnGetIndexIncReq))
|
||||
},
|
||||
"GetMcnGetIndexInc",
|
||||
[]preBindFuncType{getCookieMid(c, oarg)},
|
||||
[]preHandleFuncType{cheatReq},
|
||||
)(c)
|
||||
}
|
||||
|
||||
func mcnGetMcnGetIndexSource(c *blademaster.Context) {
|
||||
oarg := new(mcnmodel.McnGetIndexSourceReq)
|
||||
httpGetFunc(
|
||||
oarg,
|
||||
func(context context.Context, arg interface{}) (res interface{}, err error) {
|
||||
return srv.GetMcnGetIndexSource(context, arg.(*mcnmodel.McnGetIndexSourceReq))
|
||||
},
|
||||
"GetMcnGetIndexSource",
|
||||
[]preBindFuncType{getCookieMid(c, oarg)},
|
||||
[]preHandleFuncType{cheatReq},
|
||||
)(c)
|
||||
}
|
||||
|
||||
func mcnGetPlaySource(c *blademaster.Context) {
|
||||
oarg := new(mcnmodel.McnGetPlaySourceReq)
|
||||
httpGetFunc(
|
||||
oarg,
|
||||
func(context context.Context, arg interface{}) (res interface{}, err error) {
|
||||
return srv.GetPlaySource(context, arg.(*mcnmodel.McnGetPlaySourceReq))
|
||||
},
|
||||
"GetPlaySource",
|
||||
[]preBindFuncType{getCookieMid(c, oarg)},
|
||||
[]preHandleFuncType{cheatReq},
|
||||
)(c)
|
||||
}
|
||||
|
||||
func mcnGetMcnFans(c *blademaster.Context) {
|
||||
oarg := new(mcnmodel.McnGetMcnFansReq)
|
||||
httpGetFunc(
|
||||
oarg,
|
||||
func(context context.Context, arg interface{}) (res interface{}, err error) {
|
||||
return srv.GetMcnFans(context, arg.(*mcnmodel.McnGetMcnFansReq))
|
||||
},
|
||||
"GetMcnFans",
|
||||
[]preBindFuncType{getCookieMid(c, oarg)},
|
||||
[]preHandleFuncType{cheatReq},
|
||||
)(c)
|
||||
}
|
||||
|
||||
func mcnGetMcnFansInc(c *blademaster.Context) {
|
||||
oarg := new(mcnmodel.McnGetMcnFansIncReq)
|
||||
httpGetFunc(
|
||||
oarg,
|
||||
func(context context.Context, arg interface{}) (res interface{}, err error) {
|
||||
return srv.GetMcnFansInc(context, arg.(*mcnmodel.McnGetMcnFansIncReq))
|
||||
},
|
||||
"GetMcnFansInc",
|
||||
[]preBindFuncType{getCookieMid(c, oarg)},
|
||||
[]preHandleFuncType{cheatReq},
|
||||
)(c)
|
||||
}
|
||||
|
||||
func mcnGetMcnFansDec(c *blademaster.Context) {
|
||||
oarg := new(mcnmodel.McnGetMcnFansDecReq)
|
||||
httpGetFunc(
|
||||
oarg,
|
||||
func(context context.Context, arg interface{}) (res interface{}, err error) {
|
||||
return srv.GetMcnFansDec(context, arg.(*mcnmodel.McnGetMcnFansDecReq))
|
||||
},
|
||||
"GetMcnFansDec",
|
||||
[]preBindFuncType{getCookieMid(c, oarg)},
|
||||
[]preHandleFuncType{cheatReq},
|
||||
)(c)
|
||||
}
|
||||
|
||||
func mcnGetMcnFansAttentionWay(c *blademaster.Context) {
|
||||
oarg := new(mcnmodel.McnGetMcnFansAttentionWayReq)
|
||||
httpGetFunc(
|
||||
oarg,
|
||||
func(context context.Context, arg interface{}) (res interface{}, err error) {
|
||||
return srv.GetMcnFansAttentionWay(context, arg.(*mcnmodel.McnGetMcnFansAttentionWayReq))
|
||||
},
|
||||
"GetMcnFansAttentionWay",
|
||||
[]preBindFuncType{getCookieMid(c, oarg)},
|
||||
[]preHandleFuncType{cheatReq},
|
||||
)(c)
|
||||
}
|
||||
|
||||
func mcnGetBaseFansAttrReq(c *blademaster.Context) {
|
||||
oarg := new(mcnmodel.McnGetBaseFansAttrReq)
|
||||
httpGetFunc(
|
||||
oarg,
|
||||
func(context context.Context, arg interface{}) (res interface{}, err error) {
|
||||
return srv.GetBaseFansAttrReq(context, arg.(*mcnmodel.McnGetBaseFansAttrReq))
|
||||
},
|
||||
"GetBaseFansAttrReq",
|
||||
[]preBindFuncType{getCookieMid(c, oarg)},
|
||||
[]preHandleFuncType{cheatReq},
|
||||
)(c)
|
||||
}
|
||||
|
||||
func mcnGetFansArea(c *blademaster.Context) {
|
||||
oarg := new(mcnmodel.McnGetFansAreaReq)
|
||||
httpGetFunc(
|
||||
oarg,
|
||||
func(context context.Context, arg interface{}) (res interface{}, err error) {
|
||||
return srv.GetFansArea(context, arg.(*mcnmodel.McnGetFansAreaReq))
|
||||
},
|
||||
"GetFansArea",
|
||||
[]preBindFuncType{getCookieMid(c, oarg)},
|
||||
[]preHandleFuncType{cheatReq},
|
||||
)(c)
|
||||
}
|
||||
|
||||
func mcnGetFansType(c *blademaster.Context) {
|
||||
oarg := new(mcnmodel.McnGetFansTypeReq)
|
||||
httpGetFunc(
|
||||
oarg,
|
||||
func(context context.Context, arg interface{}) (res interface{}, err error) {
|
||||
return srv.GetFansType(context, arg.(*mcnmodel.McnGetFansTypeReq))
|
||||
},
|
||||
"GetFansType",
|
||||
[]preBindFuncType{getCookieMid(c, oarg)},
|
||||
[]preHandleFuncType{cheatReq},
|
||||
)(c)
|
||||
}
|
||||
|
||||
func mcnGetFansTag(c *blademaster.Context) {
|
||||
oarg := new(mcnmodel.McnGetFansTagReq)
|
||||
httpGetFunc(
|
||||
oarg,
|
||||
func(context context.Context, arg interface{}) (res interface{}, err error) {
|
||||
return srv.GetFansTag(context, arg.(*mcnmodel.McnGetFansTagReq))
|
||||
},
|
||||
"GetFansTag",
|
||||
[]preBindFuncType{getCookieMid(c, oarg)},
|
||||
[]preHandleFuncType{cheatReq},
|
||||
)(c)
|
||||
}
|
142
app/interface/main/mcn/server/http/http.go
Normal file
142
app/interface/main/mcn/server/http/http.go
Normal file
@ -0,0 +1,142 @@
|
||||
package http
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"go-common/app/interface/main/mcn/conf"
|
||||
"go-common/app/interface/main/mcn/service"
|
||||
"go-common/library/log"
|
||||
bm "go-common/library/net/http/blademaster"
|
||||
"go-common/library/net/http/blademaster/middleware/antispam"
|
||||
"go-common/library/net/http/blademaster/middleware/auth"
|
||||
"go-common/library/net/http/blademaster/middleware/verify"
|
||||
)
|
||||
|
||||
var (
|
||||
srv *service.Service
|
||||
authSvc *auth.Auth
|
||||
uploadAnti *antispam.Antispam
|
||||
verifySvc *verify.Verify
|
||||
)
|
||||
|
||||
// Init init
|
||||
func Init(c *conf.Config) {
|
||||
initService(c)
|
||||
engine := bm.DefaultServer(c.BM)
|
||||
route(engine)
|
||||
if err := engine.Start(); err != nil {
|
||||
log.Error("bm Start error(%v)", err)
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func initService(c *conf.Config) {
|
||||
srv = service.New(c)
|
||||
authSvc = auth.New(nil)
|
||||
uploadAnti = antispam.New(c.UploadAntispam)
|
||||
verifySvc = verify.New(nil)
|
||||
}
|
||||
|
||||
func route(e *bm.Engine) {
|
||||
e.Ping(ping)
|
||||
e.Register(register)
|
||||
// 以下接口在 api.bilibili.com,对外使用
|
||||
g := e.Group("/x/mcn")
|
||||
{
|
||||
//g.GET("/start", vfy.Verify, howToStart)
|
||||
g.GET("/state", authSvc.User, mcnState)
|
||||
g.GET("/exist", authSvc.User, mcnExist)
|
||||
g.POST("/file/upload", multipartForm, authSvc.User, uploadAnti.ServeHTTP, upload)
|
||||
g.GET("/account/info", authSvc.User, mcnGetAccountInfo)
|
||||
g.GET("/base/info", authSvc.User, mcnBaseInfo)
|
||||
|
||||
g.POST("/apply", authSvc.User, mcnApply)
|
||||
g.POST("/mcn/bindup", authSvc.User, mcnBindUpApply)
|
||||
g.GET("/mcn/get_data_summary", authSvc.User, mcnGetDataSummary)
|
||||
g.GET("/mcn/get_data_up_list", authSvc.User, mcnGetDataUpList)
|
||||
g.GET("/mcn/get_old_info", authSvc.User, mcnGetOldInfo)
|
||||
g.POST("/mcn/permit/change", authSvc.User, mcnGetChangePermit)
|
||||
g.POST("/mcn/publication/change-price", authSvc.User, mcnPublicationPriceChange)
|
||||
|
||||
g.POST("/up/confirm", authSvc.User, mcnUpConfirm)
|
||||
g.GET("/up/get_bind", authSvc.User, mcnUpGetBind)
|
||||
g.POST("/up/permit/confirm-reauth", authSvc.User, mcnUpPermitApplyConfirm)
|
||||
g.GET("/up/permit/get-reauth", authSvc.User, mcnPermitApplyGetBind)
|
||||
|
||||
g.GET("/rank/up_fans", authSvc.User, mcnGetRankUpFans)
|
||||
g.GET("/rank/archive_likes", authSvc.User, mcnGetRankArchiveLikesOuter)
|
||||
g.GET("/recommend/list", authSvc.User, mcnGetRecommendPool)
|
||||
g.GET("/recommend/list_tids", authSvc.User, mcnGetRecommendPoolTidList)
|
||||
|
||||
g.GET("/data/index/inc", authSvc.User, mcnGetMcnGetIndexInc)
|
||||
g.GET("/data/index/source", authSvc.User, mcnGetMcnGetIndexSource)
|
||||
g.GET("/data/play/source", authSvc.User, mcnGetPlaySource)
|
||||
g.GET("/data/fans", authSvc.User, mcnGetMcnFans)
|
||||
g.GET("/data/fans/inc", authSvc.User, mcnGetMcnFansInc)
|
||||
g.GET("/data/fans/dec", authSvc.User, mcnGetMcnFansDec)
|
||||
g.GET("/data/fans/attention/way", authSvc.User, mcnGetMcnFansAttentionWay)
|
||||
|
||||
// mcn粉丝和游客的粉丝分析
|
||||
g.GET("/data/fans/base/attr", authSvc.User, mcnGetBaseFansAttrReq)
|
||||
g.GET("/data/fans/area", authSvc.User, mcnGetFansArea)
|
||||
g.GET("/data/fans/type", authSvc.User, mcnGetFansType)
|
||||
g.GET("/data/fans/tag", authSvc.User, mcnGetFansTag)
|
||||
|
||||
// mcn创作中心数据分析
|
||||
g.GET("/creative/archives", authSvc.User, archives)
|
||||
g.GET("/creative/archive/history/list", authSvc.User, archiveHistoryList)
|
||||
g.GET("/creative/archive/videos", authSvc.User, archiveVideos)
|
||||
g.GET("/creative/data/archive", authSvc.User, dataArchive)
|
||||
g.GET("/creative/data/videoquit", authSvc.User, dataVideoQuit)
|
||||
g.GET("/creative/danmu/distri", authSvc.User, danmuDistri)
|
||||
g.GET("/creative/data/base", authSvc.User, dataBase)
|
||||
g.GET("/creative/data/trend", authSvc.User, dataTrend)
|
||||
g.GET("/creative/data/action", authSvc.User, dataAction)
|
||||
g.GET("/creative/data/fan", authSvc.User, dataFan)
|
||||
g.GET("/creative/data/pandect", authSvc.User, dataPandect)
|
||||
g.GET("/creative/data/survey", authSvc.User, dataSurvey)
|
||||
g.GET("/creative/data/playsource", authSvc.User, dataPlaySource)
|
||||
g.GET("/creative/data/playanalysis", authSvc.User, dataPlayAnalysis)
|
||||
g.GET("/creative/data/article/rank", authSvc.User, dataArticleRank)
|
||||
}
|
||||
|
||||
cmd := e.Group("/cmd")
|
||||
{
|
||||
cmd.GET("/reload_rank", cmdReloadRank)
|
||||
}
|
||||
|
||||
// 以下接口在 api.bilibili.co,内部使用
|
||||
internal := e.Group("/x/internal/mcn")
|
||||
{
|
||||
internal.GET("/rank/archive_likes", verifySvc.Verify, mcnGetRankArchiveLikesAPI)
|
||||
// mcn 数据概况
|
||||
internal.GET("/data/mcn/summary", verifySvc.Verify, getMcnSummaryAPI)
|
||||
internal.GET("/data/index/inc", verifySvc.Verify, getIndexIncAPI)
|
||||
internal.GET("/data/index/source", verifySvc.Verify, getIndexSourceAPI)
|
||||
internal.GET("/data/play/source", verifySvc.Verify, getPlaySourceAPI)
|
||||
internal.GET("/data/fans", verifySvc.Verify, getMcnFansAPI)
|
||||
internal.GET("/data/fans/inc", verifySvc.Verify, getMcnFansIncAPI)
|
||||
internal.GET("/data/fans/dec", verifySvc.Verify, getMcnFansDecAPI)
|
||||
internal.GET("/data/fans/attention/way", verifySvc.Verify, getMcnFansAttentionWayAPI)
|
||||
// mcn粉丝和游客的粉丝分析
|
||||
internal.GET("/data/fans/base/attr", verifySvc.Verify, getFansBaseFansAttrAPI)
|
||||
internal.GET("/data/fans/area", verifySvc.Verify, getFansAreaAPI)
|
||||
internal.GET("/data/fans/type", verifySvc.Verify, getFansTypeAPI)
|
||||
internal.GET("/data/fans/tag", verifySvc.Verify, getFansTagAPI)
|
||||
}
|
||||
}
|
||||
|
||||
func ping(c *bm.Context) {
|
||||
if err := srv.Ping(c); err != nil {
|
||||
log.Error("ping error(%v)", err)
|
||||
c.AbortWithStatus(http.StatusServiceUnavailable)
|
||||
}
|
||||
}
|
||||
|
||||
func register(c *bm.Context) {
|
||||
c.JSON(map[string]interface{}{}, nil)
|
||||
}
|
||||
|
||||
func multipartForm(c *bm.Context) {
|
||||
c.Request.ParseMultipartForm(maxFileSize)
|
||||
}
|
199
app/interface/main/mcn/server/http/http_base.go
Normal file
199
app/interface/main/mcn/server/http/http_base.go
Normal file
@ -0,0 +1,199 @@
|
||||
package http
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"go-common/app/interface/main/mcn/conf"
|
||||
"go-common/app/interface/main/mcn/model/mcnmodel"
|
||||
"go-common/library/ecode"
|
||||
"go-common/library/log"
|
||||
"go-common/library/net/http/blademaster"
|
||||
)
|
||||
|
||||
// func bmHTTPErrorWithMsg(c *blademaster.Context, err error, msg string) {
|
||||
// if c.IsAborted() {
|
||||
// return
|
||||
// }
|
||||
// c.Error = err
|
||||
// bcode := ecode.Cause(err)
|
||||
// if msg == "" {
|
||||
// msg = err.Error()
|
||||
// }
|
||||
// c.Render(http.StatusOK, render.JSON{
|
||||
// Code: bcode.Code(),
|
||||
// Message: msg,
|
||||
// Data: nil,
|
||||
// })
|
||||
// }
|
||||
|
||||
// service的函数原型
|
||||
type serviceFunc func(context context.Context, arg interface{}) (res interface{}, err error)
|
||||
|
||||
// response writer
|
||||
type responseWriter func(c *blademaster.Context, arg interface{}, res interface{}, err error)
|
||||
|
||||
type argParser func(c *blademaster.Context, arg interface{}) (err error)
|
||||
|
||||
func argGetParser(c *blademaster.Context, arg interface{}) (err error) {
|
||||
err = c.Bind(arg)
|
||||
return
|
||||
}
|
||||
|
||||
// argPostJSONParser .
|
||||
// func argPostJSONParser(c *blademaster.Context, arg interface{}) (err error) {
|
||||
// respBody, _ := ioutil.ReadAll(c.Request.Body)
|
||||
// if err = json.Unmarshal(respBody, arg); err != nil {
|
||||
// log.Error("json unmarshal fail, err=%v", err)
|
||||
// return
|
||||
// }
|
||||
// if err = binding.Validator.ValidateStruct(arg); err != nil {
|
||||
// log.Error("binding.Validator.ValidateStruct(%+v) error(%+v)", arg, err)
|
||||
// }
|
||||
// return
|
||||
// }
|
||||
|
||||
func jsonWriter(c *blademaster.Context, arg interface{}, res interface{}, err error) {
|
||||
c.JSON(res, err)
|
||||
}
|
||||
|
||||
// func csvWriter(c *blademaster.Context, arg interface{}, res interface{}, err error) {
|
||||
// formater, ok := res.(model.CsvFormatter)
|
||||
// if !ok {
|
||||
// log.Error("res cannot convert CsvFommater, res type=%s", reflect.TypeOf(res).Name())
|
||||
// c.String(ecode.ServerErr.Code(), "res cannot convert CsvFommater")
|
||||
// return
|
||||
// }
|
||||
|
||||
// c.Writer.Header().Set("Content-Type", "application/csv")
|
||||
// c.Writer.Header().Set("Content-Disposition", fmt.Sprintf("attachment;filename=\"%s\"", formater.GetFileName()))
|
||||
|
||||
// var buf = &bytes.Buffer{}
|
||||
// var csvWriter = csv.NewWriter(buf)
|
||||
// formater.ToCsv(csvWriter)
|
||||
// csvWriter.Flush()
|
||||
// c.Writer.Write(buf.Bytes())
|
||||
// }
|
||||
|
||||
// func decideWriter(c *blademaster.Context, arg interface{}, res interface{}, err error) {
|
||||
// var writer responseWriter
|
||||
// var decider, ok = arg.(model.ExportArgInterface)
|
||||
// if ok {
|
||||
// switch decider.ExportFormat() {
|
||||
// case "json":
|
||||
// writer = jsonWriter
|
||||
// case "csv":
|
||||
// writer = csvWriter
|
||||
// }
|
||||
// }
|
||||
|
||||
// if writer != nil {
|
||||
// writer(c, arg, res, err)
|
||||
// } else {
|
||||
// jsonWriter(c, arg, res, err)
|
||||
// }
|
||||
// }
|
||||
|
||||
type preBindFuncType func(*blademaster.Context) error
|
||||
type preHandleFuncType func(*blademaster.Context, interface{}) error
|
||||
|
||||
func httpGenerateFunc(arg interface{}, sfunc serviceFunc, description string, parser argParser, writer responseWriter, preBindFuncs []preBindFuncType, preHandleFuncs []preHandleFuncType) func(*blademaster.Context) {
|
||||
return func(c *blademaster.Context) {
|
||||
var res interface{}
|
||||
var err error
|
||||
//var errMsg string
|
||||
exitswitch:
|
||||
switch {
|
||||
default:
|
||||
for _, f := range preBindFuncs {
|
||||
err = f(c)
|
||||
if err != nil {
|
||||
break exitswitch
|
||||
}
|
||||
}
|
||||
if err = parser(c, arg); err != nil {
|
||||
log.Error("%s, request argument bind fail, err=%v", description, err)
|
||||
//errMsg = fmt.Sprintf("wrong argument, %s", err.Error())
|
||||
err = ecode.RequestErr
|
||||
break
|
||||
}
|
||||
for _, f := range preHandleFuncs {
|
||||
err = f(c, arg)
|
||||
if err != nil {
|
||||
break exitswitch
|
||||
}
|
||||
}
|
||||
var scoreRes, e = sfunc(c, arg)
|
||||
err = e
|
||||
if e != nil {
|
||||
//errMsg = err.Error()
|
||||
log.Error("%s query fail, req=%+v, err=%+v", description, arg, err)
|
||||
break
|
||||
}
|
||||
log.Info("%s query ok, req=%+v, result=%+v", description, arg, scoreRes)
|
||||
res = scoreRes
|
||||
}
|
||||
if err != nil {
|
||||
//bmHTTPErrorWithMsg(c, err, errMsg)
|
||||
if c.IsAborted() {
|
||||
return
|
||||
}
|
||||
c.JSON(nil, err)
|
||||
} else {
|
||||
writer(c, arg, res, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func httpGetFunc(arg interface{}, sfunc serviceFunc, description string, preBindFuncs []preBindFuncType, preHandleFunc []preHandleFuncType) func(*blademaster.Context) {
|
||||
return httpGetFuncWithWriter(arg, sfunc, description, jsonWriter, preBindFuncs, preHandleFunc)
|
||||
}
|
||||
|
||||
func httpGetFuncWithWriter(arg interface{}, sfunc serviceFunc, description string, writer responseWriter, preBindFuncs []preBindFuncType, preHandleFunc []preHandleFuncType) func(*blademaster.Context) {
|
||||
return httpGenerateFunc(arg, sfunc, description, argGetParser, writer, preBindFuncs, preHandleFunc)
|
||||
}
|
||||
|
||||
func getMid(bc *blademaster.Context) int64 {
|
||||
mid, exists := bc.Get("mid")
|
||||
if !exists {
|
||||
return 0
|
||||
}
|
||||
realmid, ok := mid.(int64)
|
||||
if !ok {
|
||||
return 0
|
||||
}
|
||||
return realmid
|
||||
}
|
||||
|
||||
// 根据cookie中的mid来设置请求中的mid,请求的arg必需是mcnmodel.CookieMidInterface
|
||||
func getCookieMid(c *blademaster.Context, arg interface{}) preBindFuncType {
|
||||
return func(c *blademaster.Context) (err error) {
|
||||
var cookieInterface, ok = arg.(mcnmodel.CookieMidInterface)
|
||||
if !ok || cookieInterface == nil {
|
||||
return nil
|
||||
}
|
||||
var mid = getMid(c)
|
||||
if mid == 0 {
|
||||
err = ecode.AccessDenied
|
||||
return
|
||||
}
|
||||
cookieInterface.SetMid(mid)
|
||||
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func cheatReq(c *blademaster.Context, arg interface{}) (err error) {
|
||||
var mid = getMid(c)
|
||||
if mid == 0 {
|
||||
return
|
||||
}
|
||||
if conf.Conf.Other.IsWhiteList(mid) {
|
||||
var cheatInterface, ok = arg.(mcnmodel.CheatInterface)
|
||||
if ok && cheatInterface != nil {
|
||||
if cheatInterface.Cheat() {
|
||||
log.Warn("cheat happend, uri=%s, req=%+v", c.Request.RequestURI, arg)
|
||||
}
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
22
app/interface/main/mcn/server/http/http_test.go
Normal file
22
app/interface/main/mcn/server/http/http_test.go
Normal file
@ -0,0 +1,22 @@
|
||||
package http
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"go-common/app/admin/main/mcn/model"
|
||||
"go-common/library/net/http/blademaster/binding"
|
||||
)
|
||||
|
||||
func TestValidater(t *testing.T) {
|
||||
var req = model.MCNSignEntryReq{
|
||||
MCNMID: 1,
|
||||
BeginDate: "2018-01-01",
|
||||
EndDate: "2018-01-01",
|
||||
}
|
||||
var err = binding.Validator.ValidateStruct(&req)
|
||||
if err == nil {
|
||||
t.FailNow()
|
||||
} else {
|
||||
t.Logf("err=%s", err)
|
||||
}
|
||||
}
|
269
app/interface/main/mcn/server/http/mcn.go
Normal file
269
app/interface/main/mcn/server/http/mcn.go
Normal file
@ -0,0 +1,269 @@
|
||||
package http
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"go-common/app/interface/main/mcn/model/mcnmodel"
|
||||
"go-common/library/net/http/blademaster"
|
||||
)
|
||||
|
||||
func mcnState(c *blademaster.Context) {
|
||||
oarg := new(mcnmodel.GetStateReq)
|
||||
httpGetFunc(
|
||||
oarg,
|
||||
func(context context.Context, arg interface{}) (res interface{}, err error) {
|
||||
return srv.McnGetState(context, arg.(*mcnmodel.GetStateReq))
|
||||
},
|
||||
"mcnState",
|
||||
[]preBindFuncType{getCookieMid(c, oarg)},
|
||||
[]preHandleFuncType{cheatReq},
|
||||
)(c)
|
||||
}
|
||||
|
||||
func mcnExist(c *blademaster.Context) {
|
||||
oarg := new(mcnmodel.GetStateReq)
|
||||
httpGetFunc(
|
||||
oarg,
|
||||
func(context context.Context, arg interface{}) (res interface{}, err error) {
|
||||
return srv.McnExist(context, arg.(*mcnmodel.GetStateReq))
|
||||
},
|
||||
"mcnExist",
|
||||
[]preBindFuncType{getCookieMid(c, oarg)},
|
||||
[]preHandleFuncType{cheatReq},
|
||||
)(c)
|
||||
}
|
||||
|
||||
func mcnBaseInfo(c *blademaster.Context) {
|
||||
oarg := new(mcnmodel.GetStateReq)
|
||||
httpGetFunc(
|
||||
oarg,
|
||||
func(context context.Context, arg interface{}) (res interface{}, err error) {
|
||||
return srv.McnBaseInfo(context, arg.(*mcnmodel.GetStateReq))
|
||||
},
|
||||
"mcnBaseInfo",
|
||||
[]preBindFuncType{getCookieMid(c, oarg)},
|
||||
[]preHandleFuncType{cheatReq},
|
||||
)(c)
|
||||
}
|
||||
|
||||
func mcnApply(c *blademaster.Context) {
|
||||
oarg := new(mcnmodel.McnApplyReq)
|
||||
httpGetFunc(
|
||||
oarg,
|
||||
func(context context.Context, arg interface{}) (res interface{}, err error) {
|
||||
return srv.McnApply(context, arg.(*mcnmodel.McnApplyReq))
|
||||
},
|
||||
"mcnApply",
|
||||
[]preBindFuncType{getCookieMid(c, oarg)},
|
||||
[]preHandleFuncType{cheatReq},
|
||||
)(c)
|
||||
}
|
||||
|
||||
func mcnBindUpApply(c *blademaster.Context) {
|
||||
oarg := new(mcnmodel.McnBindUpApplyReq)
|
||||
httpGetFunc(
|
||||
oarg,
|
||||
func(context context.Context, arg interface{}) (res interface{}, err error) {
|
||||
return srv.McnBindUpApply(context, arg.(*mcnmodel.McnBindUpApplyReq))
|
||||
},
|
||||
"mcnBindUpApply",
|
||||
[]preBindFuncType{getCookieMid(c, oarg)},
|
||||
[]preHandleFuncType{cheatReq},
|
||||
)(c)
|
||||
}
|
||||
|
||||
func mcnUpConfirm(c *blademaster.Context) {
|
||||
oarg := new(mcnmodel.McnUpConfirmReq)
|
||||
httpGetFunc(
|
||||
oarg,
|
||||
func(context context.Context, arg interface{}) (res interface{}, err error) {
|
||||
return srv.McnUpConfirm(context, arg.(*mcnmodel.McnUpConfirmReq))
|
||||
},
|
||||
"mcnBindUpApply",
|
||||
[]preBindFuncType{getCookieMid(c, oarg)},
|
||||
[]preHandleFuncType{cheatReq},
|
||||
)(c)
|
||||
}
|
||||
|
||||
func mcnUpGetBind(c *blademaster.Context) {
|
||||
oarg := new(mcnmodel.McnUpGetBindReq)
|
||||
httpGetFunc(
|
||||
oarg,
|
||||
func(context context.Context, arg interface{}) (res interface{}, err error) {
|
||||
return srv.McnUpGetBind(context, arg.(*mcnmodel.McnUpGetBindReq))
|
||||
},
|
||||
"mcnUpGetBind",
|
||||
[]preBindFuncType{getCookieMid(c, oarg)},
|
||||
[]preHandleFuncType{cheatReq},
|
||||
)(c)
|
||||
}
|
||||
|
||||
func mcnGetDataSummary(c *blademaster.Context) {
|
||||
oarg := new(mcnmodel.McnGetDataSummaryReq)
|
||||
httpGetFunc(
|
||||
oarg,
|
||||
func(context context.Context, arg interface{}) (res interface{}, err error) {
|
||||
return srv.McnDataSummary(context, arg.(*mcnmodel.McnGetDataSummaryReq))
|
||||
},
|
||||
"mcnGetDataSummary",
|
||||
[]preBindFuncType{getCookieMid(c, oarg)},
|
||||
[]preHandleFuncType{cheatReq},
|
||||
)(c)
|
||||
}
|
||||
|
||||
func mcnGetDataUpList(c *blademaster.Context) {
|
||||
oarg := new(mcnmodel.McnGetUpListReq)
|
||||
httpGetFunc(
|
||||
oarg,
|
||||
func(context context.Context, arg interface{}) (res interface{}, err error) {
|
||||
return srv.McnDataUpList(context, arg.(*mcnmodel.McnGetUpListReq))
|
||||
},
|
||||
"mcnGetDataUpList",
|
||||
[]preBindFuncType{getCookieMid(c, oarg)},
|
||||
[]preHandleFuncType{cheatReq},
|
||||
)(c)
|
||||
}
|
||||
|
||||
func mcnGetAccountInfo(c *blademaster.Context) {
|
||||
oarg := new(mcnmodel.McnGetAccountReq)
|
||||
httpGetFunc(
|
||||
oarg,
|
||||
func(context context.Context, arg interface{}) (res interface{}, err error) {
|
||||
return srv.GetUpAccountInfo(context, arg.(*mcnmodel.McnGetAccountReq))
|
||||
},
|
||||
"mcnGetAccountInfo",
|
||||
nil,
|
||||
nil,
|
||||
)(c)
|
||||
}
|
||||
|
||||
func mcnGetOldInfo(c *blademaster.Context) {
|
||||
oarg := new(mcnmodel.McnGetMcnOldInfoReq)
|
||||
httpGetFunc(
|
||||
oarg,
|
||||
func(context context.Context, arg interface{}) (res interface{}, err error) {
|
||||
return srv.McnGetOldInfo(context, arg.(*mcnmodel.McnGetMcnOldInfoReq))
|
||||
},
|
||||
"McnGetOldInfo",
|
||||
[]preBindFuncType{getCookieMid(c, oarg)},
|
||||
[]preHandleFuncType{cheatReq},
|
||||
)(c)
|
||||
}
|
||||
|
||||
func mcnGetRankUpFans(c *blademaster.Context) {
|
||||
oarg := new(mcnmodel.McnGetRankReq)
|
||||
httpGetFunc(
|
||||
oarg,
|
||||
func(context context.Context, arg interface{}) (res interface{}, err error) {
|
||||
return srv.McnGetRankUpFans(context, arg.(*mcnmodel.McnGetRankReq))
|
||||
},
|
||||
"McnGetRankUpFans",
|
||||
[]preBindFuncType{getCookieMid(c, oarg)},
|
||||
[]preHandleFuncType{cheatReq},
|
||||
)(c)
|
||||
}
|
||||
|
||||
func mcnGetRankArchiveLikesOuter(c *blademaster.Context) {
|
||||
oarg := new(mcnmodel.McnGetRankReq)
|
||||
httpGetFunc(
|
||||
oarg,
|
||||
func(context context.Context, arg interface{}) (res interface{}, err error) {
|
||||
return srv.McnGetRankArchiveLikes(context, arg.(*mcnmodel.McnGetRankReq))
|
||||
},
|
||||
"mcnGetRankArchiveLikesOuter",
|
||||
[]preBindFuncType{getCookieMid(c, oarg)},
|
||||
[]preHandleFuncType{cheatReq},
|
||||
)(c)
|
||||
}
|
||||
|
||||
func mcnGetRecommendPool(c *blademaster.Context) {
|
||||
oarg := new(mcnmodel.McnGetRecommendPoolReq)
|
||||
httpGetFunc(
|
||||
oarg,
|
||||
func(context context.Context, arg interface{}) (res interface{}, err error) {
|
||||
return srv.GetRecommendPool(context, arg.(*mcnmodel.McnGetRecommendPoolReq))
|
||||
},
|
||||
"GetRecommendPool",
|
||||
[]preBindFuncType{getCookieMid(c, oarg)},
|
||||
[]preHandleFuncType{cheatReq},
|
||||
)(c)
|
||||
}
|
||||
|
||||
func mcnGetRecommendPoolTidList(c *blademaster.Context) {
|
||||
oarg := new(mcnmodel.McnGetRecommendPoolTidListReq)
|
||||
httpGetFunc(
|
||||
oarg,
|
||||
func(context context.Context, arg interface{}) (res interface{}, err error) {
|
||||
return srv.GetRecommendPoolTidList(context, arg.(*mcnmodel.McnGetRecommendPoolTidListReq))
|
||||
},
|
||||
"GetRecommendPoolTidList",
|
||||
[]preBindFuncType{getCookieMid(c, oarg)},
|
||||
[]preHandleFuncType{cheatReq},
|
||||
)(c)
|
||||
}
|
||||
|
||||
func mcnGetChangePermit(c *blademaster.Context) {
|
||||
oarg := new(mcnmodel.McnChangePermitReq)
|
||||
httpGetFunc(
|
||||
oarg,
|
||||
func(context context.Context, arg interface{}) (res interface{}, err error) {
|
||||
return srv.McnChangePermit(context, arg.(*mcnmodel.McnChangePermitReq))
|
||||
},
|
||||
"McnChangePermit",
|
||||
[]preBindFuncType{getCookieMid(c, oarg)},
|
||||
[]preHandleFuncType{cheatReq},
|
||||
)(c)
|
||||
}
|
||||
|
||||
func mcnPermitApplyGetBind(c *blademaster.Context) {
|
||||
oarg := new(mcnmodel.McnUpGetBindReq)
|
||||
httpGetFunc(
|
||||
oarg,
|
||||
func(context context.Context, arg interface{}) (res interface{}, err error) {
|
||||
return srv.McnPermitApplyGetBind(context, arg.(*mcnmodel.McnUpGetBindReq))
|
||||
},
|
||||
"McnPermitApplyGetBind",
|
||||
[]preBindFuncType{getCookieMid(c, oarg)},
|
||||
[]preHandleFuncType{cheatReq},
|
||||
)(c)
|
||||
}
|
||||
|
||||
func mcnUpPermitApplyConfirm(c *blademaster.Context) {
|
||||
oarg := new(mcnmodel.McnUpConfirmReq)
|
||||
httpGetFunc(
|
||||
oarg,
|
||||
func(context context.Context, arg interface{}) (res interface{}, err error) {
|
||||
return srv.McnUpPermitApplyConfirm(context, arg.(*mcnmodel.McnUpConfirmReq))
|
||||
},
|
||||
"McnUpPermitApplyConfirm",
|
||||
[]preBindFuncType{getCookieMid(c, oarg)},
|
||||
[]preHandleFuncType{cheatReq},
|
||||
)(c)
|
||||
}
|
||||
|
||||
func mcnPublicationPriceChange(c *blademaster.Context) {
|
||||
oarg := new(mcnmodel.McnPublicationPriceChangeReq)
|
||||
httpGetFunc(
|
||||
oarg,
|
||||
func(context context.Context, arg interface{}) (res interface{}, err error) {
|
||||
return srv.McnPublicationPriceChange(context, arg.(*mcnmodel.McnPublicationPriceChangeReq))
|
||||
},
|
||||
"McnPublicationPriceChange",
|
||||
[]preBindFuncType{getCookieMid(c, oarg)},
|
||||
[]preHandleFuncType{cheatReq},
|
||||
)(c)
|
||||
}
|
||||
|
||||
// -------------- command ------------------
|
||||
func cmdReloadRank(c *blademaster.Context) {
|
||||
oarg := new(mcnmodel.CmdReloadRank)
|
||||
httpGetFunc(
|
||||
oarg,
|
||||
func(context context.Context, arg interface{}) (res interface{}, err error) {
|
||||
return srv.CmdReloadRankCache(context, arg.(*mcnmodel.CmdReloadRank))
|
||||
},
|
||||
"CmdReloadRank",
|
||||
nil,
|
||||
nil,
|
||||
)(c)
|
||||
}
|
69
app/interface/main/mcn/server/http/upload.go
Normal file
69
app/interface/main/mcn/server/http/upload.go
Normal file
@ -0,0 +1,69 @@
|
||||
package http
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"path"
|
||||
"time"
|
||||
|
||||
"go-common/library/ecode"
|
||||
"go-common/library/log"
|
||||
bm "go-common/library/net/http/blademaster"
|
||||
)
|
||||
|
||||
const (
|
||||
maxFileSize = 20 << 20
|
||||
)
|
||||
|
||||
func upload(c *bm.Context) {
|
||||
c.Request.ParseMultipartForm(maxFileSize)
|
||||
imageFile, header, err := c.Request.FormFile("file")
|
||||
if err != nil {
|
||||
log.Error("upload fail, no field file")
|
||||
c.JSON(nil, err)
|
||||
return
|
||||
}
|
||||
if header.Size > maxFileSize {
|
||||
c.JSON(nil, ecode.MCNContractFileSize)
|
||||
return
|
||||
}
|
||||
fileExt := path.Ext(header.Filename)
|
||||
if fileExt == "" {
|
||||
c.JSON(nil, ecode.MCNUnknownFileExt)
|
||||
return
|
||||
}
|
||||
defer imageFile.Close()
|
||||
bs, err := ioutil.ReadAll(imageFile)
|
||||
if err != nil {
|
||||
c.JSON(nil, err)
|
||||
return
|
||||
}
|
||||
filetype := http.DetectContentType(bs)
|
||||
switch filetype {
|
||||
case
|
||||
"image/jpeg",
|
||||
"image/jpg",
|
||||
"image/png",
|
||||
"application/pdf":
|
||||
case "application/octet-stream", "application/zip":
|
||||
switch fileExt[1:] {
|
||||
case "doc":
|
||||
filetype = "application/doc"
|
||||
case "docx":
|
||||
filetype = "application/docx"
|
||||
case "docm":
|
||||
filetype = "application/docm"
|
||||
}
|
||||
case "application/msword":
|
||||
filetype = "application/doc"
|
||||
case "application/vnd.openxmlformats-officedocument.wordprocessingml.document":
|
||||
filetype = "application/docx"
|
||||
case "application/vnd.ms-word.document.macroEnabled.12":
|
||||
filetype = "application/docm"
|
||||
default:
|
||||
c.JSON(nil, ecode.MCNUnknownFileTypeErr)
|
||||
return
|
||||
}
|
||||
c.JSON(srv.Upload(c, "", filetype, time.Now().Unix(), bytes.NewReader(bs)))
|
||||
}
|
Reference in New Issue
Block a user