Example #1
0
// userId 取消关注 followId
func User_UnFollow(userId, followId int64) (bool, error) {
	if userId < 1 || followId < 1 {
		return false, errors.New("参数错误")
	}
	if userId == followId {
		return false, errors.New("不能取消关注自己")
	}
	var db *goku.MysqlDB = GetDB()
	defer db.Close()

	r, err := db.Delete("user_follow", "`user_id`=? AND `follow_id`=?", userId, followId)
	if err != nil {
		goku.Logger().Errorln(err.Error())
		return false, err
	}

	var afrow int64
	afrow, err = r.RowsAffected()
	if err != nil {
		goku.Logger().Errorln(err.Error())
		return false, err
	}

	if afrow > 0 {
		LinkForUser_UnFollowUser(userId, followId)
		// 更新粉丝数
		User_IncCount(db, userId, "friend_count", -1)
		// 更新关注数
		User_IncCount(db, followId, "follower_count", -1)
		return true, nil
	}
	return false, nil
}
Example #2
0
// 用户userId 取消关注 话题topicId
func Topic_UnFollow(userId, topicId int64) (bool, error) {
	if userId < 1 || topicId < 1 {
		return false, errors.New("参数错误")
	}
	var db *goku.MysqlDB = GetDB()
	defer db.Close()

	r, err := db.Delete("topic_follow", "`user_id`=? AND `topic_id`=?", userId, topicId)
	if err != nil {
		goku.Logger().Errorln(err.Error())
		return false, err
	}

	var afrow int64
	afrow, err = r.RowsAffected()
	if err != nil {
		goku.Logger().Errorln(err.Error())
		return false, err
	}

	if afrow > 0 {
		// 取消关注话题成功,将话题的链接从用户的推送列表中移除
		LinkForUser_UnFollowTopic(userId, topicId)
		// 更新用户关注话题的数量
		User_IncCount(db, userId, "ftopic_count", -1)
		// 更新话题的关注用户数
		Topic_IncCount(db, topicId, "follower_count", -1)
		return true, nil
	}
	return false, nil
}
Example #3
0
//删除link
func DelUserFavorite(userId int64, linkId int64) error {
	var db *goku.MysqlDB = GetDB()
	defer db.Close()
	_, err := db.Delete("user_favorite_link", "`user_id`=? AND `link_id`=?", userId, linkId)

	return err
}
Example #4
0
// 删除用户
// 应该做成标记删除的方式
func User_Delete(id int) (sql.Result, error) {
	var db *goku.MysqlDB = GetDB()
	defer db.Close()
	r, err := db.Delete("user", "id=?", id)
	return r, err
}
Example #5
0
func DeleteTodo(id int) (sql.Result, error) {
	var db *goku.MysqlDB = GetDB()
	defer db.Close()
	r, err := db.Delete("todo", "id=?", id)
	return r, err
}