/*
 * @Author: zc
 * @description 系统管理- 用户管理
 */
import request from '@/utils/request';

/**
 * @description 获取用户列表
 * @param {object} params
 * @return {*}
 */
export const getUserListPaged = (params?: object) => {
	return request({
		url: '/api/v1/User/paged',
		method: 'get',
		params: params,
	});
};
/**
 * @description 用户列表 导出
 * @param {object} data
 */
export const exportUserList = (data: object) => {
	return request(
		{
			url: '/api/v1/User/paged/_export',
			method: 'post',
			data: data,
			responseType: 'blob',
		},
		{
			reduce_data_format: false,
		}
	);
};
/**
 * @description 新增用户
 * @param {object} params
 * @return {*}
 */
export const addUser = (params: object) => {
	return request({
		url: '/api/v1/User',
		method: 'post',
		data: params,
	});
};
/**
 * @description 更新用户
 * @param {object} params
 * @return {*}
 */
export const updateUser = (params: object) => {
	return request({
		url: '/api/v1/User',
		method: 'put',
		data: params,
	});
};
/**
 * @description 删除用户
 * @param {string} userId 用户ID
 * @return {*}
 */
export const delUser = (userId: string) => {
	return request({
		url: `/api/v1/User/${userId}`,
		method: 'delete',
	});
};
/**
 * @description 重置密码
 * @param {string} userId 用户ID
 * @return {*}
 */
export const restPwd = (userId: string) => {
	return request({
		url: `/api/v1/User/initial-pwd/${userId}`,
		method: 'post',
	});
};
/**
 * @description 查询所有角色
 * @param {string} params
 * @return {*}
 */
export const getRoles = (params: object) => {
	return request({
		url: `/api/v1/Role/paged`,
		method: 'get',
		params: params,
	});
};
/**
 * @description 获取可用组织架构树形
 * @return {*}
 */
export const getCanUseOrg = () => {
	return request({
		url: `/api/v1/Org/getcanuseorg`,
		method: 'get',
	});
};
/**
 * @description 获取可用组织架构树形(部门用户只能查看和添加所属部门及其下级部门的用户)
 * @return {*}
 */
export const getCanUseOrgByUser = () => {
	return request({
		url: `/api/v1/Org/getcanuseorgforuser`,
		method: 'get',
	});
};
/**
 * @description 获取用户页面基础信息
 * @return {*}
 */
export const getBaseData = () => {
	return request({
		url: `/api/v1/User/base-data`,
		method: 'get',
	});
};
/**
 * @description 解锁用户
 * @return {*}
 */
export const unlockUser = (userId: string) => {
	return request({
		url: `/api/v1/User/unlock?id=${userId}`,
		method: 'put',
	});
};
