import http from '@/request/http.js' // 引入封装之后的http中创建的axios实例
import store from '@/store'
// import qs from 'qs'

// BasicData
const BASE_DATA = {
    // 获取学期列表
    getTermInfoList: () => http.get('/api/SystemAdmin/TermInfo/GetList'),
    // 获取请求用户信息
    getCurrentUserInfo: () => http.get('/api/SystemAdmin/BasicData/GetCurrentUserInfo'),
    // 获取当前时间是当前学期的第几周
    getCurrentWeekIndex: () => http.get('/api/SystemAdmin/BasicData/GetCurrentWeekIndex'),
    // 获取验证码
    sendVerifyCode: params => http.get(`/api/SystemAdmin/BasicData/SendVerifyCode/${params}`),
    // 获取移动端模块 1- Teacher 2-Student 3-Parent 4-ClassManager
    getSchoolMobileModules: moduleType => http.get(`/api/SystemAdmin/BasicData/GetSchoolMobileModules/${moduleType}`),
    // 根据字典分类代码获取数据字典明细项
    getItemDetailByCode: params => http.get(`/api/SystemAdmin/BasicData/GetItemDetailByCode/${params.code}`),
    // 根据字典分类代码获取数据字典递归明细项
    getItemDetailRecursionByCode: params => http.get(`/api/SystemAdmin/BasicData/GetItemDetailRecursionByCode/${params.code}`),
    // 获取学校信息
    getFamilySchoolInfo: () => http.get(`/api/SystemAdmin/BasicData/GetFamilySchoolInfo/${store.state.companyId}/${store.state.openId}`),
    // 根据账号获取验证码
    sendSMSVerifyCodeByUserName: params => http.get('/api/SystemAdmin/BasicData/SendSMSVerifyCodeByUserName/' + params)
}
// PlatBaseApi
const PALT_BASE_API = {
    call: params => http.post('/api/PlatBaseApi/Call', JSON.stringify(params))
}

// Organize
const ORGANIZE = {
    // 获取组织架构
    getOrganizeTreeWithUser: () => http.post('/api/Organize/OrganizeTreeWithUser'),
    // 用户选择控件接口
    getChooseUser: params => http.post('/api/User/ChooseUser', JSON.stringify(params))
}

// CustomGroup

const CUSTOM_GROUP = {
    // 获取自定义分组
    getCustomGroupList: () => http.get('/api/CustomGroup/GetCustomGroupList'),
    // 通过groupId获取自定义分组
    getPeopleByGroupID: params => http.get('/api/CustomGroup/GetPeopleByGroupID', {params}),
    // 获取自定义分组的树形结构数据
    getCustomGroupWithPeople: () => http.get('/api/CustomGroup/GetCustomGroupWithPeople')
}

// Teacher
const TEACHER = {
    // 获取学校教师列表
    getSchoolTeachers: () => http.get('/api/SystemAdmin/Teacher/GetSchoolTeachers'),
    // 获取教师信息
    fetchTeacherInfo: params => http.get('/api/SystemAdmin/TeacherInfo/Get', { params })

}
// PiStudent
const PI_STUDENT = {
    // 通过id获取学生信息
    getStudentInfoById: ({ studentId }) => http.get(`/api/SystemAdmin/PiStudent/GetStudentInfoById/${studentId}`)
}

// Student
const STUDENT = {
    //  获取学生端组织架构
    getGradeStructureWithStudent: () => http.post('/api/Student/GradeStructureWithStudent'),
    //  获取学生端组织架构，选择任课教师的学生
    gradeStructureWithStudentByPermission: params => http.post('/api/Student/GradeStructureWithStudentByPermission', JSON.stringify(params)),
    // 学生选择控件接口
    getStudentList: params => http.post('/api/Student/ChooseStudent', JSON.stringify(params))
}

// Subject
const SUBJECT = {
    // 获取当前学校的已开课科目
    getOpenSubject: () => http.get('/api/Subject/GetOpenSubject'),
    // 根据年级获取关联科目
    getGradeSubject: params => http.get('/api/Subject/GetGradeSubject', { params })
}

// BSGradeClass 班级年级管理
const BS_GRADE_CLASS = {
    // 获取年级班级列表
    getGradeClassList: () => http.get('/api/SystemAdmin/BSGradeClass/GetGradeClassList'),
    // 获取当前班级所有学生信息
    getStudentInfoByClassId: params => http.get(`/api/SystemAdmin/BSGradeClass/GetStudentInfoByClassId/${params}`),
    // 获取当前用户班级信息
    getCurrentUserClassInfo: ({ isSelectAll, isResponseTree, roleCode }) => http.get(`/api/SystemAdmin/BSGradeClass/GetCurrentUserClassInfo/${isSelectAll}/${isResponseTree}/${roleCode}`),
    // 获取微信端年级、班级信息
    getWechatGradeClassInfo: params => http.get(`/api/SystemAdmin/BSGradeClass/GetWechatGradeClassInfo/${params.roleCode}`),
    // 获取当前班级所有学生信息，排序
    getStudentInfoByClassIdSort: params => http.get('/api/SystemAdmin/BSGradeClass/GetStudentInfoByClassIdSort', { params }),
    // 获取当前学校年级
    getCompanyGrades: () => http.get('/api/SystemAdmin/BSGradeClass/GetCompanyGrades')
}

// PIPERMISSIONITEM 平台操作权限
const PIPERMISSIONITEM = {
    // 判断用户是否是超管和是否是某个角色管理员，传字符串code值
    getUserCheckRole ({ roleCode }) {
        return http.get(`/api/PIPERMISSIONITEM/UserCheckRole/${roleCode}`)
    },
    // 判断用户是否是超管和是否存在某个角色，传数字code值
    getUserCheckRoles ({ roleCode }) {
        return http.get(`/api/PIPERMISSIONITEM/UserCheckRoles/${roleCode}`)
    }
}

// 班级管理
const CLASS_INFO = {
    //  判断是否是班主任
    getIsHeadTeacher: () => http.get('/api/SystemAdmin/ClassInfo/IsHeadTeacher'),
    // 根据userId 判断是否是班主任
    getIsHeadTeacherByUserId: params => http.get('/api/SystemAdmin/ClassInfo/IsHeadTeacherByUserId', { params }),
    // 通过班主任id获取所负责班级
    getClassInfoByTeacherId: params => http.get('/api/SystemAdmin/ClassInfo/GetClassInfoByTeacherId', { params }),
    // 获取当前用户所负责班级
    getClassInfoByCurrentUser: () => http.get('/api/SystemAdmin/ClassInfo/GetClassInfoByCurrentUser')
}

export default {
    ...BASE_DATA,
    ...PALT_BASE_API,
    ...ORGANIZE,
    ...CUSTOM_GROUP,
    ...TEACHER,
    ...PI_STUDENT,
    ...STUDENT,
    ...SUBJECT,
    ...BS_GRADE_CLASS,
    ...PIPERMISSIONITEM,
    ...CLASS_INFO
}
