You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
paopao-ce/internal/dao/tag.go

36 lines
685 B

2 years ago
package dao
import "github.com/rocboss/paopao-ce/internal/model"
2 years ago
func (d *dataServant) CreateTag(tag *model.Tag) (*model.Tag, error) {
2 years ago
t, err := tag.Get(d.engine)
if err != nil {
tag.QuoteNum = 1
return tag.Create(d.engine)
}
// 更新
t.QuoteNum++
err = t.Update(d.engine)
if err != nil {
return nil, err
}
return t, nil
}
func (d *dataServant) DeleteTag(tag *model.Tag) error {
2 years ago
tag, err := tag.Get(d.engine)
if err != nil {
return err
}
tag.QuoteNum--
return tag.Update(d.engine)
}
func (d *dataServant) GetTags(conditions *model.ConditionsT, offset, limit int) ([]*model.Tag, error) {
2 years ago
return (&model.Tag{}).List(d.engine, conditions, offset, limit)
}