mirror of
https://github.com/FJurmanovic/wallet-go-api.git
synced 2026-02-06 06:08:16 +00:00
fixes
This commit is contained in:
@@ -22,6 +22,11 @@ func Routes(s *gin.Engine, db *pg.DB) {
|
|||||||
subscription := ver.Group("subscription", middleware.Auth)
|
subscription := ver.Group("subscription", middleware.Auth)
|
||||||
subscriptionType := ver.Group("subscription-type", middleware.Auth)
|
subscriptionType := ver.Group("subscription-type", middleware.Auth)
|
||||||
|
|
||||||
|
s.NoRoute(func(c *gin.Context) {
|
||||||
|
c.JSON(404, gin.H{"code": "PAGE_NOT_FOUND", "message": "Page not found"})
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
apiService := services.ApiService{Db: db}
|
apiService := services.ApiService{Db: db}
|
||||||
usersService := services.UsersService{Db: db}
|
usersService := services.UsersService{Db: db}
|
||||||
walletService := services.WalletService{Db: db}
|
walletService := services.WalletService{Db: db}
|
||||||
|
|||||||
@@ -16,12 +16,16 @@ func NewSubscriptionController(as *services.SubscriptionService, s *gin.RouterGr
|
|||||||
wc := new(SubscriptionController)
|
wc := new(SubscriptionController)
|
||||||
wc.SubscriptionService = as
|
wc.SubscriptionService = as
|
||||||
|
|
||||||
s.PUT("/end/:id", wc.End)
|
|
||||||
s.POST("", wc.New)
|
s.POST("", wc.New)
|
||||||
s.PUT("/:id", wc.Edit)
|
s.PUT("/:id", wc.Edit)
|
||||||
s.GET("/:id", wc.Get)
|
s.GET("/:id", wc.Get)
|
||||||
s.GET("", wc.GetAll)
|
s.GET("", wc.GetAll)
|
||||||
|
|
||||||
|
se := s.Group("/end")
|
||||||
|
{
|
||||||
|
se.POST("", wc.End)
|
||||||
|
}
|
||||||
|
|
||||||
return wc
|
return wc
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,7 +76,13 @@ func (wc *SubscriptionController) End(c *gin.Context) {
|
|||||||
auth := c.MustGet("auth")
|
auth := c.MustGet("auth")
|
||||||
body.Id = auth.(*models.Auth).Id
|
body.Id = auth.(*models.Auth).Id
|
||||||
|
|
||||||
id := c.Param("id")
|
end := new(models.SubscriptionEnd)
|
||||||
|
if err := c.ShouldBind(end); err != nil {
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
id := end.Id
|
||||||
|
|
||||||
fr := wc.SubscriptionService.End(c, id)
|
fr := wc.SubscriptionService.End(c, id)
|
||||||
|
|
||||||
|
|||||||
@@ -45,6 +45,10 @@ type NewSubscriptionBody struct {
|
|||||||
Amount json.Number `json:"amount" form:"amount"`
|
Amount json.Number `json:"amount" form:"amount"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type SubscriptionEnd struct {
|
||||||
|
Id string `json:"id" form:"id"`
|
||||||
|
}
|
||||||
|
|
||||||
func (cm *Subscription) ToTrans() *Transaction {
|
func (cm *Subscription) ToTrans() *Transaction {
|
||||||
trans := new(Transaction)
|
trans := new(Transaction)
|
||||||
trans.Init()
|
trans.Init()
|
||||||
|
|||||||
Reference in New Issue
Block a user