Skip to content

Commit

Permalink
fix: trim space when create tag with hole
Browse files Browse the repository at this point in the history
  • Loading branch information
JingYiJun committed Mar 29, 2024
1 parent a37d098 commit 96a8b71
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions apis/tag/apis.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func CreateTag(c *fiber.Ctx) error {

// ModifyTag
//
// @Summary Modify A Tag
// @Summary Modify A Tag, admin only
// @Tags Tag
// @Produce application/json
// @Router /tags/{id} [put]
Expand Down Expand Up @@ -163,7 +163,7 @@ func ModifyTag(c *fiber.Ctx) error {
// modify tag
var tag Tag
DB.Find(&tag, id)
tag.Name = body.Name
tag.Name = strings.TrimSpace(body.Name)
tag.Temperature = body.Temperature

sensitiveResp, err := sensitive.CheckSensitive(sensitive.ParamsForCheck{
Expand Down
3 changes: 3 additions & 0 deletions models/tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ func (tag *Tag) AfterCreate(_ *gorm.DB) (err error) {

func FindOrCreateTags(tx *gorm.DB, user *User, names []string) (Tags, error) {
tags := make(Tags, 0)
for i, name := range names {
names[i] = strings.TrimSpace(name)
}
err := tx.Where("name in ?", names).Find(&tags).Error
if err != nil {
return nil, err
Expand Down

0 comments on commit 96a8b71

Please sign in to comment.