Create & Init Project...

This commit is contained in:
2019-04-22 18:49:16 +08:00
commit fc4fa37393
25440 changed files with 4054998 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"area.go",
"bulletin.go",
"guest.go",
"http.go",
"item.go",
"place.go",
"seat.go",
"venue.go",
"version.go",
],
importpath = "go-common/app/service/openplatform/ticket-item/server/http",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//app/service/openplatform/ticket-item/api/grpc/v1:go_default_library",
"//app/service/openplatform/ticket-item/conf:go_default_library",
"//app/service/openplatform/ticket-item/model:go_default_library",
"//app/service/openplatform/ticket-item/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/binding:go_default_library",
"//vendor/github.com/pkg/errors: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"],
)

View File

@@ -0,0 +1,27 @@
package http
import (
item "go-common/app/service/openplatform/ticket-item/api/grpc/v1"
"go-common/app/service/openplatform/ticket-item/model"
bm "go-common/library/net/http/blademaster"
"github.com/pkg/errors"
)
// @params AreaInfoParam
// @router post /openplatform/internal/ticket/item/areaInfo
// @response AreaInfoReply
func areaInfo(c *bm.Context) {
arg := new(model.AreaInfoParam)
if err := c.Bind(arg); err != nil {
errors.Wrap(err, "参数验证失败")
return
}
c.JSON(itemSvc.AreaInfo(c, &item.AreaInfoRequest{
ID: arg.ID,
AID: arg.AID,
Name: arg.Name,
Place: arg.Place,
Coordinate: arg.Coordinate,
}))
}

View File

@@ -0,0 +1,20 @@
package http
/**import (
"github.com/pkg/errors"
"go-common/app/service/openplatform/ticket-item/model"
bm "go-common/library/net/http/blademaster"
)
// @params ParamID
// @router get /openplatform/internal/ticket/item/getbulletins
// @response BulletinInfo
func getBulletins(c *bm.Context) {
arg := new(model.ParamID)
if err := c.Bind(arg); err != nil {
errors.Wrap(err, "参数验证失败")
return
}
c.JSON(itemSvc.GetBulletins(c, &arg.ID))
}**/

View File

@@ -0,0 +1,50 @@
package http
import (
"go-common/app/service/openplatform/ticket-item/model"
bm "go-common/library/net/http/blademaster"
)
/** test http
func guestInfo(c *bm.Context) {
arg := new(model.GuestParam)
if err := c.Bind(arg); err != nil {
errors.Wrap(err, "参数验证失败")
return
}
c.JSON(itemSvc.GuestInfo(c, &model.GuestInfoRequest{ID: arg.ID, Name: arg.Name, GuestImg: arg.GuestImg, Description: arg.Description, GuestID: arg.GuestID}))
}
func guestStatus(c *bm.Context) {
arg := new(model.GuestStatusParam)
if err := c.Bind(arg); err != nil {
errors.Wrap(err, "参数验证失败")
return
}
c.JSON(itemSvc.GuestStatus(c, arg.ID, arg.Status))
}**/
// @params ParamID
// @router get /openplatform/internal/ticket/item/getguests
// @response Guest
/**func getGuests(c *bm.Context) {
arg := new(model.ParamID)
if err := c.Bind(arg); err != nil {
errors.Wrap(err, "参数验证失败")
return
}
c.JSON(itemSvc.GetGuests(c, &arg.ID))
}**/
// @params GuestSearchParam
// @router get /openplatform/internal/ticket/item/guest/search
// @response GuestSearchList
func guestSearch(c *bm.Context) {
arg := new(model.GuestSearchParam)
if err := c.Bind(arg); err != nil {
return
}
c.JSON(itemSvc.GuestSearch(c, arg))
}

View File

@@ -0,0 +1,74 @@
package http
import (
"net/http"
"go-common/app/service/openplatform/ticket-item/conf"
"go-common/app/service/openplatform/ticket-item/service"
"go-common/library/log"
bm "go-common/library/net/http/blademaster"
)
var (
itemSvc *service.ItemService
)
// Init init item service.
func Init(c *conf.Config, s *service.ItemService) {
itemSvc = s
//engineIn := bm.DefaultServer(c.BM.Inner)
engineIn := bm.DefaultServer(nil)
innerRouter(engineIn)
// init inner server
if err := engineIn.Start(); err != nil {
log.Error("engineIn.Start error(%v)", err)
panic(err)
}
/** unused
engineLocal := bm.DefaultServer(c.BM.Local)
localRouter(engineLocal)
// init local router
if err := engineLocal.Start(); err != nil {
log.Error("engineLocal.Start error(%v)", err)
panic(err)
}**/
}
// innerRouter init inner router.
func innerRouter(e *bm.Engine) {
e.Ping(ping)
// item
group := e.Group("/openplatform/internal/ticket/item")
{
group.GET("/info", info)
group.GET("/billinfo", billInfo)
group.GET("/cards", cards)
// group.GET("/guestinfo", guestInfo)
// group.GET("/gueststatus", guestStatus)
//group.GET("/getguests", getGuests)
//group.GET("/getbulletins", getBulletins)
group.GET("/guest/search", guestSearch)
group.GET("/venue/search", venueSearch) // 场馆搜索
group.GET("/version/search", versionSearch) // 项目版本搜索
group.POST("/wishstatus", wish) // 想去项目
group.POST("/favstatus", fav) // 收藏/取消收藏项目
group.POST("/venueinfo", venueInfo)
group.POST("/placeinfo", placeInfo)
group.POST("/areainfo", areaInfo)
group.POST("/seatinfo", seatInfo)
group.POST("/seatStock", seatStock)
group.POST("/removeSeatOrders", removeSeatOrders)
}
}
// localRouter init local router.
/**func localRouter(e *bm.Engine) {
}**/
// ping check server ok.
func ping(c *bm.Context) {
if err := itemSvc.Ping(c); err != nil {
log.Error("ticket http service ping error(%v)", err)
c.AbortWithStatus(http.StatusServiceUnavailable)
}
}

View File

@@ -0,0 +1,104 @@
package http
import (
"strings"
item "go-common/app/service/openplatform/ticket-item/api/grpc/v1"
"go-common/app/service/openplatform/ticket-item/model"
"go-common/library/ecode"
"go-common/library/log"
bm "go-common/library/net/http/blademaster"
"go-common/library/net/http/blademaster/binding"
"github.com/pkg/errors"
)
// @params ParamID
// @router get /openplatform/internal/ticket/item/info
// @response InfoReply
func info(c *bm.Context) {
arg := new(model.ParamID)
if err := c.Bind(arg); err != nil {
errors.Wrap(err, "参数验证失败")
return
}
c.JSON(itemSvc.Info(c, &item.InfoRequest{ID: arg.ID}))
}
// @params ParamCards
// @router get /openplatform/internal/ticket/item/cards
// @response CardsReply
func cards(c *bm.Context) {
arg := new(model.ParamCards)
if err := c.Bind(arg); err != nil {
errors.Wrap(err, "参数验证失败")
return
}
ids := model.UniqueInt64(model.String2Int64(strings.Split(arg.IDs, ",")))
if len(ids) == 0 {
err := ecode.RequestErr
errors.Wrap(err, "参数验证失败")
log.Error("ItemID invalid %v", arg.IDs)
return
}
c.JSON(itemSvc.Cards(c, &item.CardsRequest{IDs: ids}))
}
// @params ParamBill
// @router get /openplatform/internal/ticket/item/billinfo
// @response BillReply
func billInfo(c *bm.Context) {
arg := new(model.ParamBill)
if err := c.Bind(arg); err != nil {
errors.Wrap(err, "参数验证失败")
return
}
ids := model.UniqueInt64(model.String2Int64(strings.Split(arg.IDs, ",")))
if len(ids) == 0 {
err := ecode.RequestErr
errors.Wrap(err, "参数验证失败")
log.Error("ItemID empty %v", arg.IDs)
return
}
sids := model.UniqueInt64(model.String2Int64(strings.Split(arg.Sids, ",")))
if len(ids) == 0 {
log.Info("ScreenID empty %v", arg.Sids)
return
}
tids := model.UniqueInt64(model.String2Int64(strings.Split(arg.Tids, ",")))
if len(ids) == 0 {
log.Info("TicketID empty %v", arg.Tids)
return
}
c.JSON(itemSvc.BillInfo(c, &item.BillRequest{IDs: ids, ScIDs: sids, TkIDs: tids}))
}
// @params WishRequest
// @router post /openplatform/internal/ticket/item/wishstatus
// @response WishReply
func wish(c *bm.Context) {
arg := new(item.WishRequest)
if err := c.BindWith(arg, binding.JSON); err != nil {
errors.Wrap(err, "参数验证失败")
return
}
c.JSON(itemSvc.Wish(c, arg))
}
// @params FavRequest
// @router post /openplatform/internal/ticket/item/favstatus
// @response FavReply
func fav(c *bm.Context) {
arg := new(item.FavRequest)
if err := c.BindWith(arg, binding.JSON); err != nil {
errors.Wrap(err, "参数验证失败")
return
}
c.JSON(itemSvc.Fav(c, arg))
}

View File

@@ -0,0 +1,29 @@
package http
import (
item "go-common/app/service/openplatform/ticket-item/api/grpc/v1"
"go-common/app/service/openplatform/ticket-item/model"
bm "go-common/library/net/http/blademaster"
"github.com/pkg/errors"
)
// @params PlaceInfoParam
// @router post /openplatform/internal/ticket/item/placeInfo
// @response PlaceInfoReply
func placeInfo(c *bm.Context) {
arg := new(model.PlaceInfoParam)
if err := c.Bind(arg); err != nil {
errors.Wrap(err, "参数验证失败")
return
}
c.JSON(itemSvc.PlaceInfo(c, &item.PlaceInfoRequest{
ID: arg.ID,
Status: arg.Status,
Name: arg.Name,
BasePic: arg.BasePic,
Venue: arg.Venue,
DWidth: arg.DWidth,
DHeight: arg.DHeight,
}))
}

View File

@@ -0,0 +1,65 @@
package http
import (
"encoding/json"
item "go-common/app/service/openplatform/ticket-item/api/grpc/v1"
"go-common/app/service/openplatform/ticket-item/model"
bm "go-common/library/net/http/blademaster"
"github.com/pkg/errors"
)
// @params SeatInfoParam
// @router post /openplatform/internal/ticket/item/seatInfo
// @response SeatInfoReply
func seatInfo(c *bm.Context) {
arg := new(model.SeatInfoParam)
if err := c.Bind(arg); err != nil {
errors.Wrap(err, "参数验证失败")
return
}
var seats []*item.AreaSeatInfo
json.Unmarshal([]byte(arg.Seats), &seats)
c.JSON(itemSvc.SeatInfo(c, &item.SeatInfoRequest{
Area: arg.Area,
SeatsNum: arg.SeatsNum,
Seats: seats,
Width: arg.Width,
Height: arg.Height,
RowList: arg.RowList,
SeatStart: arg.SeatStart,
}))
}
// @params SeatStockParam
// @router post /openplatform/internal/ticket/item/seatStock
// @response SeatStockReply
func seatStock(c *bm.Context) {
arg := new(model.SeatStockParam)
if err := c.Bind(arg); err != nil {
errors.Wrap(err, "参数验证失败")
return
}
var seatinfo []*item.SeatPrice
json.Unmarshal([]byte(arg.SeatInfo), &seatinfo)
c.JSON(itemSvc.SeatStock(c, &item.SeatStockRequest{
Screen: arg.Screen,
Area: arg.Area,
SeatInfo: seatinfo,
}))
}
// @params RemoveSeatOrdersParam
// @router post /openplatform/internal/ticket/item/RemoveSeatOrders
// @response RemoveSeatOrdersReply
func removeSeatOrders(c *bm.Context) {
arg := new(model.RemoveSeatOrdersParam)
if err := c.Bind(arg); err != nil {
errors.Wrap(err, "参数验证失败")
return
}
c.JSON(itemSvc.RemoveSeatOrders(c, &item.RemoveSeatOrdersRequest{
Price: arg.Price,
}))
}

View File

@@ -0,0 +1,41 @@
package http
import (
item "go-common/app/service/openplatform/ticket-item/api/grpc/v1"
"go-common/app/service/openplatform/ticket-item/model"
bm "go-common/library/net/http/blademaster"
"github.com/pkg/errors"
)
// @params VenueSearchParam
// @router get /openplatform/internal/ticket/item/venue/search
// @response VenueSearchList
func venueSearch(c *bm.Context) {
req := &model.VenueSearchParam{}
if err := c.Bind(req); err != nil {
return
}
c.JSON(itemSvc.VenueSearch(c, req))
}
// @params VenueInfoParam
// @router post /openplatform/internal/ticket/item/venueInfo
// @response VenueInfoReply
func venueInfo(c *bm.Context) {
arg := new(model.VenueInfoParam)
if err := c.Bind(arg); err != nil {
errors.Wrap(err, "参数验证失败")
return
}
c.JSON(itemSvc.VenueInfo(c, &item.VenueInfoRequest{
ID: arg.ID,
Name: arg.Name,
Status: arg.Status,
Province: arg.Province,
City: arg.City,
District: arg.District,
AddressDetail: arg.AddressDetail,
Traffic: arg.Traffic,
}))
}

View File

@@ -0,0 +1,17 @@
package http
import (
"go-common/app/service/openplatform/ticket-item/model"
bm "go-common/library/net/http/blademaster"
)
// @params VersionSearchParam
// @router get /openplatform/internal/ticket/item/version/search
// @response VersionSearchList
func versionSearch(c *bm.Context) {
req := &model.VersionSearchParam{}
if err := c.Bind(req); err != nil {
return
}
c.JSON(itemSvc.VersionSearch(c, req))
}