feat: 迁移游戏商务绑定审核流程和列表
This commit is contained in:
@@ -98,7 +98,7 @@ func TestGinStartupLogsEveryRegisteredRoute(t *testing.T) {
|
||||
if got, want := strings.Count(text, `"msg":"router registered"`), len(engine.Routes()); got != want {
|
||||
t.Fatalf("registered route log count = %d, want %d", got, want)
|
||||
}
|
||||
if !strings.Contains(text, `"msg":"router register success"`) || !strings.Contains(text, `"route_count":203`) {
|
||||
if !strings.Contains(text, `"msg":"router register success"`) || !strings.Contains(text, `"route_count":207`) {
|
||||
t.Fatalf("startup route summary is missing: %s", text)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,10 +11,62 @@ import (
|
||||
type Business struct {
|
||||
preference *business.UserPreferenceService
|
||||
accounts *business.AccountService
|
||||
bindings *business.BindingService
|
||||
}
|
||||
|
||||
func NewBusiness(preference *business.UserPreferenceService, accounts *business.AccountService) *Business {
|
||||
return &Business{preference: preference, accounts: accounts}
|
||||
func NewBusiness(preference *business.UserPreferenceService, accounts *business.AccountService, bindings *business.BindingService) *Business {
|
||||
return &Business{preference: preference, accounts: accounts, bindings: bindings}
|
||||
}
|
||||
|
||||
func (h *Business) BindingList(c *gin.Context) {
|
||||
var req dto.BusinessBindingQuery
|
||||
if err := c.ShouldBindQuery(&req); err != nil {
|
||||
Fail(c, "绑定查询参数格式错误")
|
||||
return
|
||||
}
|
||||
rows, err := h.bindings.List(c.Request.Context(), &req)
|
||||
if err != nil {
|
||||
Fail(c, errors.FromError(err).Message)
|
||||
return
|
||||
}
|
||||
OKWithData(c, rows)
|
||||
}
|
||||
func (h *Business) UserBindings(c *gin.Context) {
|
||||
id, err := strconv.ParseUint(c.Param("userId"), 10, 64)
|
||||
if err != nil || id == 0 {
|
||||
Fail(c, "商务用户 ID 不正确")
|
||||
return
|
||||
}
|
||||
rows, err := h.bindings.ForUser(c.Request.Context(), uint(id))
|
||||
if err != nil {
|
||||
Fail(c, errors.FromError(err).Message)
|
||||
return
|
||||
}
|
||||
OKWithData(c, rows)
|
||||
}
|
||||
func (h *Business) BindPlatform(c *gin.Context) {
|
||||
var req dto.BusinessBindingRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
Fail(c, "绑定参数格式错误")
|
||||
return
|
||||
}
|
||||
if err := h.bindings.Bind(c.Request.Context(), &req); err != nil {
|
||||
Fail(c, errors.FromError(err).Message)
|
||||
return
|
||||
}
|
||||
OK(c)
|
||||
}
|
||||
func (h *Business) UnbindPlatform(c *gin.Context) {
|
||||
var req dto.BusinessBindingRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
Fail(c, "解绑参数格式错误")
|
||||
return
|
||||
}
|
||||
if err := h.bindings.Unbind(c.Request.Context(), &req); err != nil {
|
||||
Fail(c, errors.FromError(err).Message)
|
||||
return
|
||||
}
|
||||
OK(c)
|
||||
}
|
||||
|
||||
func (h *Business) AccountList(c *gin.Context) {
|
||||
|
||||
@@ -6,6 +6,10 @@ import (
|
||||
)
|
||||
|
||||
func RegisterBusiness(private *gin.RouterGroup, h *handler.Business) {
|
||||
private.GET("/sw/business/bindPlatform", h.BindingList)
|
||||
private.GET("/sw/business/:userId/bindPlatform", h.UserBindings)
|
||||
private.POST("/sw/business/bindPlatform", h.BindPlatform)
|
||||
private.DELETE("/sw/business/bindPlatform", h.UnbindPlatform)
|
||||
private.GET("/sw/business/list", h.AccountList)
|
||||
private.GET("/sw/business/:userId", h.Account)
|
||||
private.POST("/sw/business", h.CreateAccount)
|
||||
|
||||
Reference in New Issue
Block a user