You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
103 lines
4.1 KiB
103 lines
4.1 KiB
import req1 from '@/utils/requset' |
|
import { AxiosInstance } from 'axios' |
|
function copyRequest(req1: AxiosInstance, instanceConfig = {}) { |
|
let request: AxiosInstance, copyStatus: boolean |
|
try { |
|
// @ts-ignore |
|
const req2 = req1.create(instanceConfig) |
|
function acopyInterceptors(target: any, interceptorManager: any) { |
|
const handlers = interceptorManager.handlers |
|
for (let index = 0; index < handlers?.length; index++) { |
|
const { fulfilled, rejected, runWhen, synchronous } = handlers[index] |
|
let options |
|
if (synchronous !== false || runWhen !== null) |
|
options = { synchronous, runWhen } |
|
target.use(fulfilled, rejected, options) |
|
} |
|
} |
|
acopyInterceptors(req2.interceptors.request, req1.interceptors.request) |
|
acopyInterceptors(req2.interceptors.response, req1.interceptors.response) |
|
request = req2 |
|
copyStatus = true |
|
} catch (error) { |
|
console.warn('拷贝失败,私有拦截器可能失效:\n', error) |
|
request = req1 |
|
copyStatus = false |
|
} |
|
|
|
return { request, copyStatus } |
|
} |
|
|
|
const { request, copyStatus } = copyRequest(req1) |
|
|
|
// 若拷贝成功,添加自己独有的拦截器 |
|
if (copyStatus) { |
|
request.interceptors.response.use((response: any) => { |
|
if (response.code >= 200 && response.code < 300) return response |
|
else return Promise.reject(response) |
|
}) |
|
} |
|
|
|
// ============================================================================= |
|
enum api { |
|
liststu = '/abilityEvaluation/personalAbilityEvaluationCollect/liststu', // 个人能力评价列表 |
|
integral = '/annualScore/personalCompTotalScore/liststu', // 个人积分列表 |
|
PAGE_XSFXBG = '/annualcompetitionprojectregistration/annualCompetitionProjectRegistration/xsfxbg', // 个人能力报告 |
|
competition = '/AnnualCompPoint/annualCompPoint/findcompp', // 比赛项目列表 |
|
competitionOne = '/AnnualCompPoint/annualCompPoint/findcomppxq', // 比赛项目单个 |
|
signUp = '/annualcompetitionprojectregistration/annualCompetitionProjectRegistration/edit', // 年度比赛项目报名 POST |
|
membersList = '/online/cgreport/api/getData/1696139786651197442', // 团队成员列表 |
|
adviserList = '/online/cgreport/api/getData/1828357196360998913', // 指导老师列表 |
|
listStudent = '/AnnualCompPoint/annualCompPoint/listStudent', // 比赛项目报名表 |
|
findndbswxq = '/annualcomp/annualComp/findndbswxq', // 年度比赛详情 |
|
findcomppxq = '/AnnualCompPoint/annualCompPoint/findcomppxq', // 年度比赛项目详情 |
|
} |
|
|
|
// http://10.115.2.247:3300/jeecgboot/AnnualCompPoint/annualCompPoint/listStudent?column=createTime&order=desc&pageNo=1&pageSize=10&_t=1727422864387 |
|
interface SignUpData { |
|
annualCompid: string |
|
entryFormat: '团队' | '个人' |
|
id: string |
|
instructorSheetList?: any[] |
|
teamManagementList?: any[] |
|
} |
|
|
|
interface MembersOrAdviser { |
|
pageNo: number |
|
pageSize: number |
|
onlRepUrlParamStr: `annualCompid=${string}` |
|
entryFormat: '团队' | '个人' |
|
id: string |
|
column?: string |
|
order?: 'asc' | 'desc' |
|
} |
|
|
|
export const getlEvaluateApi = ( |
|
params: Record<'pageNo' | 'pageSize', number>, |
|
) => request.get(api.liststu, { params }) |
|
export const getlIntegralApi = ( |
|
params: Record<'pageNo' | 'pageSize', number>, |
|
) => request.get(api.integral, { params }) |
|
|
|
export const getXsfxbgApi = (params = {}) => { |
|
const par = { recreateFlag: false, annualid: '' } |
|
Object.assign(par, params) |
|
return request.get(api.PAGE_XSFXBG, { params: par }) |
|
} |
|
|
|
export const getCompetitionApi = (id: string) => |
|
request.get(api.competition, { params: { id } }) |
|
export const getCompetitionOneApi = (id: string) => |
|
request.get(api.competitionOne, { params: { id } }) |
|
|
|
export const getSignUpApi = (data: SignUpData) => request.post(api.signUp, data) |
|
|
|
export const getMembersList = (params: MembersOrAdviser) => |
|
request.get(api.membersList, { params }) |
|
export const getAdviserList = (params: MembersOrAdviser) => |
|
request.get(api.adviserList, { params }) |
|
|
|
export const getNdbswxqList = (id: string) => |
|
request.get(api.findndbswxq, { params: { id } }) |
|
export const getComppxqList = (id: string) => |
|
request.get(api.findcomppxq, { params: { id } })
|
|
|