/**
 * 短视频相关API
 */

import {
	http,
	Method
} from "@/utils/request.js";

import api from "@/config/api.js";


/**
 * 根据昵称搜索用户
 */
export function vlogSearchUser({
	id,
	nickname,
	page,
	pageSize
}) {
	return http.request({
		url: api.vlog + "/userInfo/searchByNickname",
		method: Method.GET,
		needToken: true,
		params: {
			id,
			nickname,
			page,
			pageSize
		},
	});
}


/**
 * 短视频详情
 */
export function vlogDetail(vlogId, userId) {
	let data = {
		vlogId,
		userId
	}
	return http.request({
		url: api.vlog + "/vlog/detail",
		method: Method.GET,
		needToken: true,
		params: data,
	});
}

/**
 * 短视频关注列表
 */
export function vlogFollowList(page, pageSize, myId) {
	let data = {
		page,
		pageSize,
		myId
	}
	return http.request({
		url: api.vlog + "/vlog/followList",
		method: Method.GET,
		needToken: true,
		params: data,
	});
}

/**
 * 短视频列表-true
 */
export function vlogList(page, pageSize, userId = '', cityCode = '', search = '') {
	let data = {
		page,
		pageSize,
		userId,
		cityCode,
		search
	}
	return http.request({
		url: api.vlog + "/vlog/indexList",
		method: Method.GET,
		needToken: false,
		params: data,
	});
}

/**
 * 短视频喜欢
 */
export function vlogLike({
	userId,
	vlogId,
	vlogerId
}) {
	return http.request({
		url: api.vlog + "/vlog/like",
		method: Method.POST,
		needToken: true,
		params: {
			userId,
			vlogId,
			vlogerId
		}
	});
}

/**
 * 短视频不喜欢
 */
export function vlogUnLike({
	userId,
	vlogId,
	vlogerId
}) {
	return http.request({
		url: api.vlog + "/vlog/unlike",
		method: Method.POST,
		needToken: true,
		params: {
			userId,
			vlogId,
			vlogerId
		}
	});
}

/**
 * 短视频评论数量统计
 */
export function vlogComment(vlogId) {
	return http.request({
		url: api.vlog + "/comment/counts",
		method: Method.GET,
		needToken: true,
		params: {
			vlogId
		},
	});
}





/**
 * 短视频关注博主
 */
export function vlogFollow(myId, vlogerId) {
	return http.request({
		url: api.vlog + "/fans/follow",
		method: Method.POST,
		needToken: true,
		params: {
			myId,
			vlogerId
		}
	});
}

/**
 * 短视频查询当前点赞数
 */
export function vlogTotalLikedCounts(vlogId) {
	return http.request({
		url: api.vlog + "/vlog/totalLikedCounts",
		method: Method.POST,
		needToken: true,
		params: {
			vlogId
		}
	});
}

/**
 * 查询用户信息
 */
export function vlogUserInfo(userId) {
	return http.request({
		url: api.vlog + "/userInfo/query",
		method: Method.GET,
		needToken: true,
		params: {
			userId
		},
	});
}

/**
 * 查询我的公开视频
 */
export function vlogMyPublicList(page, pageSize, userId) {
	return http.request({
		url: api.vlog + "/vlog/myPublicList",
		method: Method.GET,
		needToken: true,
		params: {
			page,
			pageSize,
			userId
		},
	});
}

/**
 * 查询我的私密视频
 */
export function vlogMyPrivateList(page, pageSize, userId) {
	return http.request({
		url: api.vlog + "/vlog/myPrivateList",
		method: Method.GET,
		needToken: true,
		params: {
			page,
			pageSize,
			userId
		},
	});
}

/**
 * 查询我喜欢的视频
 */
export function vlogMyLikedList(page, pageSize, userId) {
	return http.request({
		url: api.vlog + "/vlog/myLikedList",
		method: Method.GET,
		needToken: true,
		params: {
			page,
			pageSize,
			userId
		},
	});
}

/**
 * 查询我喜欢的视频
 */
export function vlogMeTag(path, page, pageSize, userId) {
	return http.request({
		url: api.vlog + "/vlog/" + path,
		method: Method.GET,
		needToken: true,
		params: {
			page,
			pageSize,
			userId
		},
	});
}

/**
 * 视频评论数量
 */
export function vlogCommentCounts(vlogId) {
	return http.request({
		url: api.vlog + "/comment/counts",
		method: Method.GET,
		needToken: true,
		params: {
			vlogId
		},
	});
}

/**
 * 视频评论不喜欢
 */
export function vlogCommentUnLike(userId, commentId) {
	return http.request({
		url: api.vlog + "/comment/unlike",
		method: Method.POST,
		needToken: true,
		params: {
			userId,
			commentId
		}
	});
}

/**
 * 视频评论喜欢
 */
export function vlogCommentLike(userId, commentId) {
	return http.request({
		url: api.vlog + "/comment/like",
		method: Method.POST,
		needToken: true,
		params: {
			userId,
			commentId
		}
	});
}

/**
 * 视频评论删除
 */
export function vlogCommentDelete(vlogId, commentUserId, commentId) {
	return http.request({
		url: api.vlog + "/comment/delete",
		method: Method.DELETE,
		needToken: true,
		params: {
			vlogId,
			commentUserId,
			commentId
		}
	});
}


/**
 * 查询视频评论内容
 */
export function vlogCommentList(page, pageSize, vlogId, userId) {
	return http.request({
		url: api.vlog + "/comment/list",
		method: Method.GET,
		needToken: true,
		params: {
			page,
			pageSize,
			vlogId,
			userId
		},
	});
}

/**
 * 发表评论
 */
export function vlogCommentCreate(data) {
	return http.request({
		url: api.vlog + "/comment/create",
		method: Method.POST,
		needToken: true,
		data
	});
}

/**
 * 将视频转为公开
 */
export function vlogChangeToPublic(userId, vlogId) {
	return http.request({
		url: api.vlog + "/vlog/changeToPublic",
		method: Method.POST,
		needToken: true,
		params: {
			userId,
			vlogId
		}
	});
}

/**
 * 将视频转为私密
 */
export function vlogChangeToPrivate(userId, vlogId) {
	return http.request({
		url: api.vlog + "/vlog/changeToPrivate",
		method: Method.POST,
		needToken: true,
		params: {
			userId,
			vlogId
		}
	});
}

/**
 * 修改信息
 */
export function vlogModifyUserInfo(data, type) {
	return http.request({
		url: api.vlog + "/userInfo/modifyUserInfo?type=" + type,
		method: Method.POST,
		needToken: true,
		data
	});
}


/**
 * 取关
 */
export function vlogFansCancel({
	myId,
	vlogerId
}) {
	return http.request({
		url: api.vlog + "/fans/cancel",
		method: Method.POST,
		needToken: true,
		params: {
			myId,
			vlogerId
		}
	});
}
/**
 * 关注
 */
export function vlogFansFollow({
	myId,
	vlogerId
}) {
	return http.request({
		url: api.vlog + "/fans/follow",
		method: Method.POST,
		needToken: true,
		params: {
			myId,
			vlogerId
		}
	});
}

/**
 * 我的粉丝
 */
export function vlogQueryMyFans({
	myId,
	page,
	pageSize
}) {
	return http.request({
		url: api.vlog + "/fans/queryMyFans",
		method: Method.GET,
		needToken: true,
		params: {
			myId,
			page,
			pageSize
		}
	});
}

/**
 * 我的关注
 */
export function vlogQueryMyFollows({
	myId,
	page,
	pageSize
}) {
	return http.request({
		url: api.vlog + "/fans/queryMyFollows",
		method: Method.GET,
		needToken: true,
		params: {
			myId,
			page,
			pageSize
		}
	});
}

/**
 * 我的关注
 */
export function vlogQueryDoIFollowVloger({
	myId,
	vlogerId
}) {
	return http.request({
		url: api.vlog + "/fans/queryDoIFollowVloger",
		method: Method.GET,
		needToken: true,
		params: {
			myId,
			vlogerId
		}
	});
}