import request from '@/utils/http';
import { Project } from '@/enums/api'
import {
    ProjectListResParams,
    ProjectListReqParams,
    AddProjectReqParams,
    AddProjectResParams,
    ModifyProjectReqParams,
    OverviewProjectResParams,
    ProjectLogsReqParams,
    ProjectLogsResParams,
    ProjectMilestoneResParams,
    ProjectCheckersResParams,
    Checker
} from '@/types/project'

/**
 * 获取项目列表
 * @param params RequestProjectListParams
 */
export const getProjectList = (params: ProjectListReqParams) => {
    return request.post<ProjectListResParams>(
        Project.PROJECT_INFO_LIST,
        params
    )
}

/**
 * 添加项目信息
 * @param params
 * @returns
 */
export const addProject = (params: AddProjectReqParams) => {
    return request.post<AddProjectResParams>(
        Project.PROJECT_INFO_ADD,
        params
    )
}

/**
 * 修改项目信息
 * @param params
 * @returns
 */
export const modifyProject = (params: ModifyProjectReqParams) => {
    return request.post<BaseResParams>(
        Project.PROJECT_INFO_MODIFY,
        params
    )
}

/**
 * 删除项目信息
 * @param id 项目编号
 * @returns
 */
export const removeProject = (id: string) => {
    return request.post<BaseResParams>(
        Project.PROJECT_INFO_REMOVE,
        { id }
    )
}

/**
 * 获取项目概览
 * @param id 项目编号
 * @returns
 */
export const overviewProject = (id: string) => {
    return request.post<OverviewProjectResParams>(
        Project.PROJECT_INFO_OVERVIEW,
        { id }
    )
}

/**
 * 获取项目动态列表
 * @param params ProjectLogsReqParams
 * @returns
 */
export const getProjectLogs = (params: ProjectLogsReqParams) => {
    return request.post<ProjectLogsResParams>(
        Project.PROJECT_INFO_LOGS,
        params
    )
}

/**
 *
 * @param params
 * @returns
 */
export const getProjectMilestone = (params: { prj_id: string }) => {
    return request.post<ProjectMilestoneResParams>(
        Project.PROJECT_KANBAN_MILESTONE,
        params
    )
}

/**
 * 获取项目审核人列表
 * @param params
 * @returns
 */
export const getProjectCheckers = (params: { id: string }) => {
    return request.post<ProjectCheckersResParams>(
        Project.PROJECT_INFO_GET_CHECKERS,
        params
    )
}

/**
 * 获取项目审核人列表
 * @param params
 * @returns
 */
export const setProjectCheckers = (params: {
    id: string
    checkers: { id: string; name: string }[]
}) => {
    return request.post<BaseResParams>(
        Project.PROJECT_INFO_SET_CHECKERS,
        params
    )
}
