import { http } from '@/api/request'

export interface WecomDepartment {
  id: number
  name: string
  parentId: number
}

export interface WecomMember {
  id: number
  userid: string
  name: string
  departmentId: number
}

/** 获取部门列表，不传 parentId 时使用后端配置的根部门（测试 0 / 生产 1） */
export function listSubDepartments(parentId?: number): Promise<WecomDepartment[]> {
  return http.get('/wecom/contact/departments', parentId != null ? { params: { parentId } } : {})
}

export function listDepartmentMembers(departmentId: number): Promise<WecomMember[]> {
  return http.get('/wecom/contact/members', { params: { departmentId } })
}

export function getMemberByUserid(userid: string): Promise<WecomMember> {
  return http.get('/wecom/contact/member', { params: { userid } })
}
