parent
81c352d376
commit
16cf6aadba
@ -1,15 +1,15 @@
|
||||
import serverHttp from '@/utils/request/client';
|
||||
|
||||
/**
|
||||
* @description 根据期刊号查询期刊信息
|
||||
* @id 期刊号
|
||||
*/
|
||||
export const apiGetSongsByJournalNo = async (params: {
|
||||
mobile: string;
|
||||
deviceId: string;
|
||||
countryCode?: string;
|
||||
imageCheckCode?: string;
|
||||
}) => {
|
||||
const result: FetchResponse<SongInfo[]> = await serverHttp.post('/luoo-music/song/getByJournalNo', params);
|
||||
return result;
|
||||
};
|
||||
// /**
|
||||
// * @description 根据期刊号查询期刊信息
|
||||
// * @id 期刊号
|
||||
// */
|
||||
// export const apiGetSongsByJournalNo = async (params: {
|
||||
// mobile: string;
|
||||
// deviceId: string;
|
||||
// countryCode?: string;
|
||||
// imageCheckCode?: string;
|
||||
// }) => {
|
||||
// const result: FetchResponse<SongInfo[]> = await serverHttp.post('/music/song/getByJournalNo', params);
|
||||
// return result;
|
||||
// };
|
||||
|
@ -1,18 +0,0 @@
|
||||
export type IAuthType = 'noToken' | 'default' | 'ai';
|
||||
|
||||
export interface IOptions {
|
||||
headers?: { [key: string]: string };
|
||||
body?: any;
|
||||
authType?: IAuthType;
|
||||
requestUrl: string;
|
||||
}
|
||||
|
||||
export interface IResponse<T> {
|
||||
code: number;
|
||||
data: T;
|
||||
message: string;
|
||||
}
|
||||
|
||||
export type IQueryParams = {
|
||||
[key: string]: any;
|
||||
};
|
@ -0,0 +1,52 @@
|
||||
'use server';
|
||||
|
||||
import { cookies } from 'next/headers';
|
||||
import { NextResponse } from 'next/server';
|
||||
|
||||
import { formatBody } from '@/utils/request/server/utils';
|
||||
import { IAuthType } from '@/utils/request/type';
|
||||
const host = process.env.NEXT_PUBLIC_HOST;
|
||||
|
||||
export const get = async (request: Request) => {
|
||||
try {
|
||||
const { search } = new URL(request.url);
|
||||
const token = cookies().get('token')?.value || '';
|
||||
const contentType =
|
||||
(request.headers.get('Content-Type') as string) || 'application/x-www-form-urlencoded;charset=UTF-8';
|
||||
const requestUrl = request.headers.get('requestUrl') as string;
|
||||
const res = await fetch(`${host}${requestUrl}${search}`, {
|
||||
headers: {
|
||||
'Content-Type': contentType,
|
||||
Authorization: token,
|
||||
},
|
||||
method: 'GET',
|
||||
// cache: "force-cache",
|
||||
});
|
||||
return res.json();
|
||||
} catch (error) {
|
||||
return NextResponse.error();
|
||||
}
|
||||
};
|
||||
|
||||
export const post = async (request: Request) => {
|
||||
try {
|
||||
const { search } = new URL(request.url);
|
||||
const contentType =
|
||||
(request.headers.get('Content-Type') as string) || 'application/x-www-form-urlencoded;charset=UTF-8';
|
||||
const requestUrl = request.headers.get('requestUrl') as string;
|
||||
const token = cookies().get('token')?.value || '';
|
||||
const data = await formatBody(request.body, contentType);
|
||||
const res = await fetch(`${host}${requestUrl}${search}`, {
|
||||
headers: {
|
||||
'Content-Type': contentType,
|
||||
Authorization: token,
|
||||
},
|
||||
method: 'POST',
|
||||
body: data,
|
||||
// cache: "force-cache",
|
||||
});
|
||||
return res.json();
|
||||
} catch (error) {
|
||||
return NextResponse.error();
|
||||
}
|
||||
};
|
Loading…
Reference in new issue