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.
30 lines
686 B
30 lines
686 B
6 years ago
|
package service
|
||
|
|
||
|
import (
|
||
|
"beeblog/models"
|
||
|
"github.com/astaxie/beego/orm"
|
||
|
"fmt"
|
||
|
)
|
||
|
|
||
|
func SaveLike(like *models.Like) (int64, error) {
|
||
|
return orm.NewOrm().Insert(like)
|
||
|
}
|
||
|
func DelLike(like *models.Like) (int64, error) {
|
||
|
return orm.NewOrm().QueryTable(models.Like{}).Filter("BlogId",like.BlogId).Filter("UserId", like.UserId).Delete()
|
||
|
}
|
||
|
|
||
|
func IsLike(bid int64, uid int64) (bool, error) {
|
||
|
totalCount, err := orm.NewOrm().QueryTable(&models.Like{}).Filter("BlogId", bid).Filter("UserId", uid).Count()
|
||
|
if err == nil {
|
||
|
fmt.Println(totalCount,"like count")
|
||
|
if totalCount > 0 {
|
||
|
return true, nil
|
||
|
} else {
|
||
|
return false, nil
|
||
|
}
|
||
|
}else{
|
||
|
fmt.Println(err)
|
||
|
return false,err
|
||
|
}
|
||
|
}
|