✨ Allow other words appear in tag
This commit is contained in:
parent
4fa351b923
commit
fe339e722f
@ -3,7 +3,7 @@ package models
|
||||
type Tag struct {
|
||||
BaseModel
|
||||
|
||||
Alias string `json:"alias" gorm:"uniqueIndex" validate:"lowercase,alphanum"`
|
||||
Alias string `json:"alias" gorm:"uniqueIndex" validate:"lowercase"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
Posts []Post `json:"posts" gorm:"many2many:post_tags"`
|
||||
|
@ -2,6 +2,7 @@ package services
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"strings"
|
||||
|
||||
"git.solsynth.dev/hydrogen/interactive/pkg/internal/database"
|
||||
"git.solsynth.dev/hydrogen/interactive/pkg/internal/models"
|
||||
@ -61,6 +62,7 @@ func DeleteCategory(category models.Category) error {
|
||||
}
|
||||
|
||||
func GetTagOrCreate(alias, name string) (models.Tag, error) {
|
||||
alias = strings.ToLower(alias)
|
||||
var tag models.Tag
|
||||
if err := database.C.Where(models.Category{Alias: alias}).First(&tag).Error; err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
|
Loading…
Reference in New Issue
Block a user