import request from "@/utils/request";
const { api } = process.env.CONFIG;

export interface GetProjectGroupsListProps {
    pageNum: number,
    pageSize: number,
    createTimeEnd?: string,
    createTimeStart?: string,
    name?: string
}

/**
 * 项目组列表
 * @param data 
 * @returns 
 */
export function getProjectGroupsListApi(data: GetProjectGroupsListProps) {
    return request({
        url: api + `/corpOperation/projectGroups/list`,
        method: 'POST',
        data
    })
}

/**
 * 全部项目组列表
 * @returns 
 */
export function getProjectGroupsAllListApi() {
    return request({
        url: api + `/corpOperation/projectGroups/listAll`,
        method: 'POST'
    })
}

export interface AddProjectGroupsProps {
    name: string,
    description?: string
    groupId?: number
}

/**
 * 新增项目组
 * @param data 
 * @returns 
 */
export function addProjectGroupsApi(data: AddProjectGroupsProps) {
    return request({
        url: api + `/corpOperation/projectGroups/create`,
        method: 'POST',
        data
    })
}

/**
 * 修改项目组
 * @param param0 
 * @returns 
 */
export function editProjectGroupsApi({ groupId, ...data }: AddProjectGroupsProps) {
    return request({
        url: api + `/corpOperation/projectGroups/edit/${groupId}`,
        method: 'POST',
        data
    })
}


/**
 * 删除项目组
 * @param param0 
 * @returns 
 */
export function delProjectGroupsApi(groupId: number) {
    return request({
        url: api + `/corpOperation/projectGroups/deleteGroup/${groupId}`,
        method: 'DELETE'
    })
}

export interface UpdateMembersProps {
    groupId: number,
    userIds: number[]
}
/**
 * 更新成员
 * @param param0 
 * @returns 
 */
export function updateMembersApi({ groupId, userIds }: UpdateMembersProps) {
    return request({
        url: api + `/corpOperation/projectGroups/updateMembers/${groupId}`,
        method: 'POST',
        data: userIds
    })
}