mirror of https://github.com/rocboss/paopao-ce
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.
36 lines
661 B
36 lines
661 B
package dao
|
|
|
|
import "github.com/rocboss/paopao-ce/internal/model"
|
|
|
|
func (d *Dao) CreateTag(tag *model.Tag) (*model.Tag, error) {
|
|
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 *Dao) DeleteTag(tag *model.Tag) error {
|
|
tag, err := tag.Get(d.engine)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
tag.QuoteNum--
|
|
return tag.Update(d.engine)
|
|
}
|
|
|
|
func (d *Dao) GetTags(conditions *model.ConditionsT, offset, limit int) ([]*model.Tag, error) {
|
|
return (&model.Tag{}).List(d.engine, conditions, offset, limit)
|
|
}
|