Create & Init Project...
This commit is contained in:
52
app/service/openplatform/ticket-item/server/grpc/BUILD
Normal file
52
app/service/openplatform/ticket-item/server/grpc/BUILD
Normal file
@ -0,0 +1,52 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_test",
|
||||
"go_library",
|
||||
)
|
||||
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = ["server_test.go"],
|
||||
embed = [":go_default_library"],
|
||||
rundir = ".",
|
||||
tags = ["automanaged"],
|
||||
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",
|
||||
"//vendor/github.com/smartystreets/goconvey/convey:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["server.go"],
|
||||
importpath = "go-common/app/service/openplatform/ticket-item/server/grpc",
|
||||
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/service:go_default_library",
|
||||
"//library/log:go_default_library",
|
||||
"//library/net/rpc/warden:go_default_library",
|
||||
"@org_golang_google_grpc//: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"],
|
||||
)
|
135
app/service/openplatform/ticket-item/server/grpc/server.go
Normal file
135
app/service/openplatform/ticket-item/server/grpc/server.go
Normal file
@ -0,0 +1,135 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
item "go-common/app/service/openplatform/ticket-item/api/grpc/v1"
|
||||
"go-common/app/service/openplatform/ticket-item/conf"
|
||||
"go-common/app/service/openplatform/ticket-item/service"
|
||||
"go-common/library/log"
|
||||
"go-common/library/net/rpc/warden"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
// New 新建warden实例
|
||||
func New(c *conf.Config) *warden.Server {
|
||||
//server := warden.NewServer(c.RPCServer)
|
||||
server := warden.NewServer(nil)
|
||||
server.Use(middleware())
|
||||
item.RegisterItemServer(server.Server(), service.New(c))
|
||||
item.RegisterGuestServer(server.Server(), service.New(c))
|
||||
item.RegisterBulletinServer(server.Server(), service.New(c))
|
||||
item.RegisterVenueServer(server.Server(), service.New(c))
|
||||
item.RegisterPlaceServer(server.Server(), service.New(c))
|
||||
item.RegisterAreaServer(server.Server(), service.New(c))
|
||||
item.RegisterSeatServer(server.Server(), service.New(c))
|
||||
/**go func() {
|
||||
err := server.Run(c.RPCServer.Addr)
|
||||
if err != nil {
|
||||
panic("run server failed!" + err.Error())
|
||||
}
|
||||
}()
|
||||
log.Info("warden run@%s", c.RPCServer.Addr)
|
||||
**/
|
||||
_, err := server.Start()
|
||||
if err != nil {
|
||||
panic("run server failed!" + err.Error())
|
||||
}
|
||||
return server
|
||||
}
|
||||
|
||||
// 拦截器,作用类似于http中间件
|
||||
func middleware() grpc.UnaryServerInterceptor {
|
||||
return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error) {
|
||||
// 记录调用方法
|
||||
log.Info("method:", info.FullMethod)
|
||||
// call chain
|
||||
resp, err = handler(ctx, req)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
type server struct {
|
||||
is *service.ItemService
|
||||
}
|
||||
|
||||
func (s *server) Info(ctx context.Context, in *item.InfoRequest) (*item.InfoReply, error) {
|
||||
return s.is.Info(ctx, in)
|
||||
}
|
||||
|
||||
func (s *server) Cards(ctx context.Context, in *item.CardsRequest) (*item.CardsReply, error) {
|
||||
return s.is.Cards(ctx, in)
|
||||
}
|
||||
|
||||
func (s *server) BillInfo(ctx context.Context, in *item.BillRequest) (*item.BillReply, error) {
|
||||
return s.is.BillInfo(ctx, in)
|
||||
}
|
||||
|
||||
func (s *server) GuestInfo(ctx context.Context, in *item.GuestInfoRequest) (*item.GuestInfoReply, error) {
|
||||
return s.is.GuestInfo(ctx, in)
|
||||
}
|
||||
|
||||
func (s *server) GuestStatus(ctx context.Context, in *item.GuestStatusRequest) (*item.GuestInfoReply, error) {
|
||||
return s.is.GuestStatus(ctx, in)
|
||||
}
|
||||
|
||||
func (s *server) BulletinInfo(ctx context.Context, in *item.BulletinInfoRequest) (*item.BulletinReply, error) {
|
||||
return s.is.BulletinInfo(ctx, in)
|
||||
}
|
||||
|
||||
func (s *server) BulletinCheck(ctx context.Context, in *item.BulletinCheckRequest) (*item.BulletinReply, error) {
|
||||
return s.is.BulletinCheck(ctx, in)
|
||||
}
|
||||
|
||||
func (s *server) BulletinState(ctx context.Context, in *item.BulletinStateRequest) (*item.BulletinReply, error) {
|
||||
return s.is.BulletinState(ctx, in)
|
||||
}
|
||||
|
||||
func (s *server) Wish(ctx context.Context, in *item.WishRequest) (*item.WishReply, error) {
|
||||
return s.is.Wish(ctx, in)
|
||||
}
|
||||
|
||||
func (s *server) Fav(ctx context.Context, in *item.FavRequest) (*item.FavReply, error) {
|
||||
return s.is.Fav(ctx, in)
|
||||
}
|
||||
|
||||
// VenueInfo 添加/修改场馆信息
|
||||
func (s *server) VenueInfo(ctx context.Context, in *item.VenueInfoRequest) (*item.VenueInfoReply, error) {
|
||||
return s.is.VenueInfo(ctx, in)
|
||||
}
|
||||
|
||||
// PlaceInfo 添加/修改场地信息
|
||||
func (s *server) PlaceInfo(ctx context.Context, in *item.PlaceInfoRequest) (*item.PlaceInfoReply, error) {
|
||||
return s.is.PlaceInfo(ctx, in)
|
||||
}
|
||||
|
||||
// AreaInfo 添加/修改区域信息
|
||||
func (s *server) AreaInfo(ctx context.Context, in *item.AreaInfoRequest) (*item.AreaInfoReply, error) {
|
||||
return s.is.AreaInfo(ctx, in)
|
||||
}
|
||||
|
||||
// DeleteArea 删除区域信息
|
||||
func (s *server) DeleteArea(ctx context.Context, in *item.DeleteAreaRequest) (*item.DeleteAreaReply, error) {
|
||||
return s.is.DeleteArea(ctx, in)
|
||||
}
|
||||
|
||||
// SeatInfo 添加/修改座位信息
|
||||
func (s *server) SeatInfo(ctx context.Context, in *item.SeatInfoRequest) (*item.SeatInfoReply, error) {
|
||||
return s.is.SeatInfo(ctx, in)
|
||||
}
|
||||
|
||||
// SeatStock 设置座位库存
|
||||
func (s *server) SeatStock(ctx context.Context, in *item.SeatStockRequest) (*item.SeatStockReply, error) {
|
||||
return s.is.SeatStock(ctx, in)
|
||||
}
|
||||
|
||||
// RemoveSeatOrders 删除坐票票价下所有座位
|
||||
func (s *server) RemoveSeatOrders(ctx context.Context, in *item.RemoveSeatOrdersRequest) (*item.RemoveSeatOrdersReply, error) {
|
||||
return s.is.RemoveSeatOrders(ctx, in)
|
||||
}
|
||||
|
||||
// Version 添加/修改项目信息
|
||||
func (s *server) Version(ctx context.Context, in *item.VersionRequest) (*item.VersionReply, error) {
|
||||
return s.is.Version(ctx, in)
|
||||
}
|
123
app/service/openplatform/ticket-item/server/grpc/server_test.go
Normal file
123
app/service/openplatform/ticket-item/server/grpc/server_test.go
Normal file
@ -0,0 +1,123 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
item "go-common/app/service/openplatform/ticket-item/api/grpc/v1"
|
||||
"go-common/app/service/openplatform/ticket-item/conf"
|
||||
"go-common/app/service/openplatform/ticket-item/model"
|
||||
"go-common/app/service/openplatform/ticket-item/service"
|
||||
|
||||
. "github.com/smartystreets/goconvey/convey"
|
||||
)
|
||||
|
||||
var (
|
||||
s *server
|
||||
ctx = context.TODO()
|
||||
)
|
||||
|
||||
func init() {
|
||||
dir, _ := filepath.Abs("../../cmd/item.toml")
|
||||
flag.Set("conf", dir)
|
||||
if err := conf.Init(); err != nil {
|
||||
panic(fmt.Sprintf("conf.Init() error(%v)", err))
|
||||
}
|
||||
s = &server{
|
||||
is: service.New(conf.Conf),
|
||||
}
|
||||
}
|
||||
|
||||
// Test_Info
|
||||
func TestInfo(t *testing.T) {
|
||||
Convey("get data", t, func() {
|
||||
res, err := s.Info(ctx, &item.InfoRequest{ID: model.DataID})
|
||||
So(err, ShouldBeNil)
|
||||
So(res, ShouldNotBeNil)
|
||||
So(res, ShouldNotBeEmpty)
|
||||
})
|
||||
Convey("no data", t, func() {
|
||||
res, err := s.Info(ctx, &item.InfoRequest{ID: model.NoDataID})
|
||||
So(err, ShouldNotBeNil)
|
||||
So(res, ShouldNotBeEmpty)
|
||||
})
|
||||
}
|
||||
|
||||
// Test_Cards
|
||||
func TestCards(t *testing.T) {
|
||||
Convey("get data", t, func() {
|
||||
res, err := s.Cards(ctx, &item.CardsRequest{IDs: model.DataIDs})
|
||||
So(err, ShouldBeNil)
|
||||
So(res, ShouldNotBeNil)
|
||||
So(res, ShouldNotBeEmpty)
|
||||
})
|
||||
Convey("no data", t, func() {
|
||||
res, err := s.Cards(ctx, &item.CardsRequest{IDs: model.NoDataIDs})
|
||||
So(err, ShouldNotBeNil)
|
||||
So(res, ShouldNotBeNil)
|
||||
})
|
||||
}
|
||||
|
||||
// TestBillInfo
|
||||
func TestBillInfo(t *testing.T) {
|
||||
Convey("get data", t, func() {
|
||||
res, err := s.BillInfo(ctx, &item.BillRequest{
|
||||
IDs: model.DataIDs,
|
||||
ScIDs: model.DataSIDs,
|
||||
TkIDs: model.DataTIDs,
|
||||
})
|
||||
So(err, ShouldBeNil)
|
||||
So(res, ShouldNotBeNil)
|
||||
So(res, ShouldNotBeEmpty)
|
||||
})
|
||||
Convey("no data", t, func() {
|
||||
res, err := s.BillInfo(ctx, &item.BillRequest{
|
||||
IDs: model.NoDataIDs,
|
||||
ScIDs: model.NoDataSIDs,
|
||||
TkIDs: model.NoDataTIDs,
|
||||
})
|
||||
So(err, ShouldNotBeNil)
|
||||
So(res, ShouldNotBeNil)
|
||||
})
|
||||
}
|
||||
|
||||
// TestWish
|
||||
func TestWish(t *testing.T) {
|
||||
Convey("add wish", t, func() {
|
||||
res, err := s.Wish(ctx, &item.WishRequest{
|
||||
ItemID: 1,
|
||||
MID: 1,
|
||||
Face: "",
|
||||
})
|
||||
So(err, ShouldBeNil)
|
||||
So(res, ShouldNotBeNil)
|
||||
})
|
||||
}
|
||||
|
||||
// TestWish
|
||||
func TestFav(t *testing.T) {
|
||||
Convey("fav add", t, func() {
|
||||
res, err := s.Fav(ctx, &item.FavRequest{
|
||||
ItemID: 1,
|
||||
MID: 1,
|
||||
Type: 1,
|
||||
Status: 1,
|
||||
})
|
||||
So(err, ShouldBeNil)
|
||||
So(res, ShouldNotBeNil)
|
||||
})
|
||||
|
||||
Convey("fav del", t, func() {
|
||||
res, err := s.Fav(ctx, &item.FavRequest{
|
||||
ItemID: 1,
|
||||
MID: 1,
|
||||
Type: 1,
|
||||
Status: 0,
|
||||
})
|
||||
So(err, ShouldBeNil)
|
||||
So(res, ShouldNotBeNil)
|
||||
})
|
||||
}
|
49
app/service/openplatform/ticket-item/server/http/BUILD
Normal file
49
app/service/openplatform/ticket-item/server/http/BUILD
Normal 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"],
|
||||
)
|
27
app/service/openplatform/ticket-item/server/http/area.go
Normal file
27
app/service/openplatform/ticket-item/server/http/area.go
Normal 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,
|
||||
}))
|
||||
}
|
20
app/service/openplatform/ticket-item/server/http/bulletin.go
Normal file
20
app/service/openplatform/ticket-item/server/http/bulletin.go
Normal 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))
|
||||
}**/
|
50
app/service/openplatform/ticket-item/server/http/guest.go
Normal file
50
app/service/openplatform/ticket-item/server/http/guest.go
Normal 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))
|
||||
}
|
74
app/service/openplatform/ticket-item/server/http/http.go
Normal file
74
app/service/openplatform/ticket-item/server/http/http.go
Normal 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)
|
||||
}
|
||||
}
|
104
app/service/openplatform/ticket-item/server/http/item.go
Normal file
104
app/service/openplatform/ticket-item/server/http/item.go
Normal 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))
|
||||
}
|
29
app/service/openplatform/ticket-item/server/http/place.go
Normal file
29
app/service/openplatform/ticket-item/server/http/place.go
Normal 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,
|
||||
}))
|
||||
}
|
65
app/service/openplatform/ticket-item/server/http/seat.go
Normal file
65
app/service/openplatform/ticket-item/server/http/seat.go
Normal 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,
|
||||
}))
|
||||
}
|
41
app/service/openplatform/ticket-item/server/http/venue.go
Normal file
41
app/service/openplatform/ticket-item/server/http/venue.go
Normal 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,
|
||||
}))
|
||||
}
|
17
app/service/openplatform/ticket-item/server/http/version.go
Normal file
17
app/service/openplatform/ticket-item/server/http/version.go
Normal 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))
|
||||
}
|
Reference in New Issue
Block a user