Example #1
0
func (f TagFacade) ScoringTag(userID, tagID uint64) (*models.UserTag, error) {
	userTagService := services.NewUserTagService(f.ctx)
	userTag, err := userTagService.GetFirstOrCreate(userID, tagID)
	if err != nil {
		return nil, err
	}
	userTag.Score = userTag.Score + 1
	return userTagService.UpdateByID(userTag)
}
Example #2
0
func (f TagFacade) FindTagByScore(userID uint64, limit int) ([]models.Tag, error) {
	userTagService := services.NewUserTagService(f.ctx)
	userTags, err := userTagService.FindLatestByUserIDAndCollection(userID, limit)
	if err != nil {
		return nil, err
	}
	tagIDs := make([]uint64, len(userTags))
	for i, userTag := range userTags {
		tagIDs[i] = userTag.TagID
	}
	tagService := services.NewTagService(f.ctx)
	return tagService.FindTagByIDs(tagIDs)
}