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.

43 lines
769 B

package attention
import (
"github.com/gin-gonic/gin"
"recook/internal/back"
"recook/internal/dbc"
"recook/internal/model/attention"
"recook/tools"
)
type createParam struct {
UserID uint `json:"userId"`
FollowID uint `json:"followId"`
}
func CreateAttention(c *gin.Context) {
var p createParam
err := tools.ParseParams(&p, c)
if err != nil {
back.Fail(c, err.Error())
return
}
var one attention.Info
dbc.DB.First(&one, "user_id = ? AND follow_id = ?", p.UserID, p.FollowID)
if one.ID > 0 {
back.Fail(c, "您已关注过该用户")
return
}
one = attention.Info{
UserId: p.UserID,
FollowId: p.FollowID,
}
err = dbc.DB.Create(&one).Error
if err != nil {
back.Err(c, err.Error())
return
}
back.Suc(c, "关注成功", nil)
}