25개 이상의 토픽을 선택하실 수 없습니다.
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
888 B
49 lines
888 B
package service
|
|
|
|
import (
|
|
"beeblog/models"
|
|
"github.com/astaxie/beego/orm"
|
|
)
|
|
|
|
type NoteService struct {
|
|
}
|
|
|
|
func SaveNote(note *models.Note) error {
|
|
o := orm.NewOrm()
|
|
id, err := o.Insert(note)
|
|
if err == nil {
|
|
note.Id = id
|
|
}
|
|
return err
|
|
}
|
|
|
|
func GetNote(note *models.Note) error {
|
|
o := orm.NewOrm()
|
|
return o.Read(note)
|
|
}
|
|
|
|
func GetNoteByPid(pid int64) ([]*models.Note, error) {
|
|
var notes []*models.Note
|
|
o := orm.NewOrm()
|
|
qs := o.QueryTable(models.Note{})
|
|
_, err := qs.Filter("Pid", pid).All(¬es)
|
|
return notes,err
|
|
}
|
|
|
|
|
|
func SaveNoteColl(note *models.NoteColl) error {
|
|
o := orm.NewOrm()
|
|
id, err := o.Insert(note)
|
|
if err == nil {
|
|
note.Id = id
|
|
}
|
|
return err
|
|
}
|
|
|
|
func GetNoteColl(uid int64) ([]*models.NoteColl, error) {
|
|
var notes []*models.NoteColl
|
|
o := orm.NewOrm()
|
|
qs := o.QueryTable(models.NoteColl{})
|
|
_, err := qs.Filter("UserId", uid).All(¬es)
|
|
return notes,err
|
|
}
|