import request from '@/utils/request';

// ==================== 部门管理 ====================

/**
 * 查询部门树
 */
export function getDeptTree() {
  return request({
    url: '/customer/organization/dept/tree',
    method: 'get'
  });
}

/**
 * 查询部门列表
 */
export function getDeptList(params?: any) {
  return request({
    url: '/customer/organization/dept/list',
    method: 'get',
    params: params
  });
}

/**
 * 查询部门详情
 */
export function getDeptInfo(id: number) {
  return request({
    url: `/customer/organization/dept/${id}`,
    method: 'get'
  });
}

/**
 * 新增部门
 */
export function addDept(data: any) {
  return request({
    url: '/customer/organization/dept',
    method: 'post',
    data: data
  });
}

/**
 * 修改部门
 */
export function updateDept(data: any) {
  return request({
    url: '/customer/organization/dept',
    method: 'put',
    data: data
  });
}

/**
 * 删除部门
 */
export function deleteDept(ids: number[]) {
  return request({
    url: `/customer/organization/dept/${ids.join(',')}`,
    method: 'delete'
  });
}

// ==================== 人员管理 ====================

/**
 * 获取当前登录用户的个人信息
 */
export function getCurrentUserInfo() {
  return request({
    url: '/customer/organization/contact/current',
    method: 'get'
  });
}

/**
 * 查询联系人列表
 */
export function getContactList(params?: any) {
  return request({
    url: '/customer/organization/contact/list',
    method: 'get',
    params: params
  });
}

/**
 * 查询联系人详情
 */
export function getContactInfo(id: number) {
  return request({
    url: `/customer/organization/contact/${id}`,
    method: 'get'
  });
}

/**
 * 新增联系人
 */
export function addContact(data: any) {
  return request({
    url: '/customer/organization/contact',
    method: 'post',
    data: data
  });
}

/**
 * 修改联系人
 */
export function updateContact(data: any) {
  return request({
    url: '/customer/organization/contact',
    method: 'put',
    data: data
  });
}

/**
 * 删除联系人
 */
export function deleteContact(ids: number[]) {
  return request({
    url: `/customer/organization/contact/${ids.join(',')}`,
    method: 'delete'
  });
}

// ==================== 角色管理 ====================

/**
 * 查询角色列表
 */
export function getRoleList(params?: any) {
  return request({
    url: '/system/organization/role/list',
    method: 'get',
    params: params
  });
}

/**
 * 查询角色详情
 */
export function getRoleInfo(id: number) {
  return request({
    url: `/system/organization/role/${id}`,
    method: 'get'
  });
}

/**
 * 新增角色
 */
export function addRole(data: any) {
  return request({
    url: '/system/organization/role',
    method: 'post',
    data: data
  });
}

/**
 * 修改角色
 */
export function updateRole(data: any) {
  return request({
    url: '/system/organization/role',
    method: 'put',
    data: data
  });
}

/**
 * 删除角色
 */
export function deleteRole(ids: number[]) {
  return request({
    url: `/system/organization/role/${ids.join(',')}`,
    method: 'delete'
  });
}

// ==================== 人员管理 ====================

/**
 * 查询人员列表
 */
export function getComStaffList(params?: any) {
  return request({
    url: '/system/organization/comStaff/list',
    method: 'get',
    params: params
  });
}

/**
 * 查询人员详情
 */
export function getComStaffInfo(id: number) {
  return request({
    url: `/system/organization/comStaff/${id}`,
    method: 'get'
  });
}

/**
 * 新增人员
 */
export function addComStaff(data: any) {
  return request({
    url: '/system/organization/comStaff',
    method: 'post',
    data: data
  });
}

/**
 * 修改人员
 */
export function updateComStaff(data: any) {
  return request({
    url: '/system/organization/comStaff',
    method: 'put',
    data: data
  });
}

/**
 * 删除人员
 */
export function deleteComStaff(ids: number[]) {
  return request({
    url: `/system/organization/comStaff/${ids.join(',')}`,
    method: 'delete'
  });
}
