import { request } from '@/utils'

export default {
  login: (data) => request.post('/base/access_token', data, { noNeedToken: true }),
  getUserInfo: () => request.get('/base/userinfo'),
  getUserMenu: () => request.get('/base/usermenu'),
  getUserApi: () => request.get('/base/userapi'),
  updatePassword: (data = {}) => request.post('/base/update_password', data),

  // User
  getUserList: (params) => request.get('/user/list', { params }),
  createUser: (data) => request.post('/user/create', data),
  updateUser: (data) => request.post('/user/update', data),
  deleteUser: (params) => request.delete('/user/delete', { params }),
  resetUserPassword: (data) => request.post('/user/reset_password', data),

  // Role
  getRoleList: (params) => request.get('/role/list', { params }),
  createRole: (data) => request.post('/role/create', data),
  updateRole: (data) => request.post('/role/update', data),
  deleteRole: (params) => request.delete('/role/delete', { params }),
  getRoleAuthorized: (params) => request.get('/role/authorized', { params }),
  updateRoleAuthorized: (data) => request.post('/role/authorized', data),

  // Menu
  getMenus: (params) => request.get('/menu/list', { params }),
  createMenu: (data) => request.post('/menu/create', data),
  updateMenu: (data) => request.post('/menu/update', data),
  deleteMenu: (params) => request.delete('/menu/delete', { params }),

  // Api
  getApis: (params) => request.get('/api/list', { params }),
  createApi: (data) => request.post('/api/create', data),
  updateApi: (data) => request.post('/api/update', data),
  deleteApi: (params) => request.delete('/api/delete', { params }),
  refreshApi: () => request.post('/api/refresh'),

  // Dept
  getDepts: (params) => request.get('/dept/list', { params }),
  createDept: (data) => request.post('/dept/create', data),
  updateDept: (data) => request.post('/dept/update', data),
  deleteDept: (params) => request.delete('/dept/delete', { params }),
  
  // 数据统计 / 数据报表（统一改用 /reports 路由）
  getDailyStatistics: (params = {}) => request.get('/reports/daily', { params }),
  getWeeklyStatistics: (params = {}) => request.get('/reports/weekly', { params }),
  getPlatformSummary: (params = {}) => request.get('/reports/summary', { params }),

  getTrendAnalysis: (params = {}) => request.get('/reports/trend', { params }),
  getCityDistribution: (params = {}) => request.get('/reports/city-distribution', { params }),
  getIndustryAnalysis: (params = {}) => request.get('/reports/industry-analysis', { params }),
  getCompanyRanking: (params = {}) => request.get('/reports/company-ranking', { params }),
  getReportsHealth: () => request.get('/reports/health'),
  
  // 薪资分析
  // 其余分析接口如需扩展，请对齐 /reports 下的实际端点
  
  // 工作经验分布
  // 保留占位以便后续扩展
  
  // 学历要求分布
  // 保留占位以便后续扩展
  
  // 平台间数据对比
  getPlatformComparison: (params = {}) => request.get('/reports/platform-comparison', { params }),
  
  // 数据质量报告
  getDataQualityReport: (params = {}) => request.get('/reports/data-quality', { params }),
  
  // 导出数据报表
  // 导出报表暂未提供后端端点，前端页面将隐藏导出按钮


  // 数据清洗
  uploadCleaningFile: (formData) => request.post('/cleaning/upload', formData),
  getCleaningTasks: (params) => request.get('/cleaning/list', { params }),
  processCleaningTask: (id) => request.post(`/cleaning/process/${id}`),
  deleteCleaningTask: (params) => request.delete('/cleaning/delete', { params }),
  clearCleaningTasks: () => request.post('/cleaning/clear'),
  getCompanyCleaningStats: () => request.get('/cleaning/stats'),
  getCompanyCleaningList: (params) => request.get('/cleaning/companies', { params }),
  getCompanyCleaningDetail: (params) => request.get('/cleaning/company-detail', { params }),
  collectPendingCompanies: (data = {}) => request.post('/cleaning/collect-pending', data),
  runPendingCompanies: (data = {}) => request.post('/cleaning/run-pending', data),
  crawlExecutePending: (data = {}) => request.post('/cleaning/crawl-execute', data),
  runSingleCompanyCleaning: (data = {}) => request.post('/cleaning/process-company', data),

  // 通用数据查询
  queryPlatformData: (params) => request.get('/job/data', { params }),
}
