Skip to content
This repository has been archived by the owner on Dec 27, 2023. It is now read-only.

Commit

Permalink
feat: Return Id to POST rulersheet
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardaguterres committed Oct 27, 2022
1 parent 3eb30ac commit dec4962
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 2 additions & 0 deletions controllers/v1/rulesheets.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,10 @@ func (rc *rulesheets) CreateRulesheet() gin.HandlerFunc {
}

var response = responses.NewRulesheet(&dto)
//id := c.Query("id")
c.JSON(http.StatusCreated, response)
}

}

// GetRulesheets godoc
Expand Down
9 changes: 6 additions & 3 deletions services/rulesheets.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,20 @@ func NewRulesheets(repository repository.Rulesheets, gitlabService Gitlab) Rules
// CreateRulesheet ...
func (rs rulesheets) Create(ctx context.Context, rulesheetDTO *dtos.Rulesheet) (err error) {

//TODO verifica unicidade do nome
rulesheet, _ := models.NewRulesheetV1(*rulesheetDTO)
rulesheet.Slug = slug.Make(rulesheet.Slug)
if rulesheet.Slug == "" {
rulesheet.Slug = slug.Make(rulesheet.Name)
}

fmt.Print(rulesheet.Slug)

err = rs.repository.Create(ctx, &rulesheet)
if err != nil {
log.Errorf("Error on create rulesheet into repository: %v", err)
return
}

rulesheetDTO.ID = rulesheet.ID
rulesheetDTO.Slug = rulesheet.Slug
err = rs.gitlabService.Save(rulesheetDTO, "[FEATWS BOT] Create Repo")
if err != nil {
log.Errorf("Error on save rulesheet into repository: %v", err)
Expand Down

0 comments on commit dec4962

Please sign in to comment.