This commit is contained in:
Fran Jurmanovic
2021-08-02 04:31:09 -07:00
parent 149fbfa211
commit 26e39322e4
4 changed files with 22 additions and 3 deletions

View File

@@ -16,12 +16,16 @@ func NewSubscriptionController(as *services.SubscriptionService, s *gin.RouterGr
wc := new(SubscriptionController)
wc.SubscriptionService = as
s.PUT("/end/:id", wc.End)
s.POST("", wc.New)
s.PUT("/:id", wc.Edit)
s.GET("/:id", wc.Get)
s.GET("", wc.GetAll)
se := s.Group("/end")
{
se.POST("", wc.End)
}
return wc
}
@@ -72,7 +76,13 @@ func (wc *SubscriptionController) End(c *gin.Context) {
auth := c.MustGet("auth")
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)