|
|
@@ -1,25 +1,25 @@
|
|
|
-import type { SearchHistoryRecord, UserLoginRequest, CurrentUser } from "@/types/user.types";
|
|
|
-import type { Page } from "@/types/pagination.types"
|
|
|
-import type { Response } from "@/types/response.types";
|
|
|
-import type { AxiosResponse } from "axios";
|
|
|
+import type {SearchHistoryRecord, UserLoginRequest, CurrentUser} from "@/types/user.types";
|
|
|
+import type {Page} from "@/types/pagination.types"
|
|
|
+import type {Response} from "@/types/response.types";
|
|
|
+import type {AxiosResponse} from "axios";
|
|
|
import httpClient from "./httpClient";
|
|
|
|
|
|
const urlPrefix = "/gw/user";
|
|
|
|
|
|
function _url(path: string): string {
|
|
|
- return `${urlPrefix}${path}`;
|
|
|
+ return `${urlPrefix}${path}`;
|
|
|
}
|
|
|
|
|
|
function login(param: UserLoginRequest): Promise<AxiosResponse<Response<CurrentUser>>> {
|
|
|
- return httpClient.post<Response<CurrentUser>>(_url("/login"), param);
|
|
|
+ return httpClient.post<Response<CurrentUser>>(_url("/login"), param);
|
|
|
}
|
|
|
|
|
|
async function checkLogin(): Promise<boolean> {
|
|
|
- const resp = await httpClient.get("/gw/user/user/checkLogin");
|
|
|
- if (resp) {
|
|
|
- return true;
|
|
|
- }
|
|
|
- return false;
|
|
|
+ const resp = await httpClient.get("/gw/user/user/checkLogin");
|
|
|
+ if (resp) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -29,15 +29,52 @@ async function checkLogin(): Promise<boolean> {
|
|
|
* @param size 每页数量
|
|
|
* @returns Promise
|
|
|
*/
|
|
|
-export function fetchHistory(currentUser: string, page: number, size: number) {
|
|
|
- const url = _url("/searchHistory/getMySearchHistory");
|
|
|
- const headers = { currentUser };
|
|
|
- const params = { page, size };
|
|
|
- return httpClient.get<Response<Page<SearchHistoryRecord>>>(url, { params, headers });
|
|
|
+export function fetchHistory(currentUser: string, page: number, size: number, dateNum: number) {
|
|
|
+ const url = _url("/searchHistory/getMySearchHistory");
|
|
|
+ const headers = {currentUser};
|
|
|
+ const params = {page, size, dateNum};
|
|
|
+ return httpClient.get<Response<Page<SearchHistoryRecord>>>(url, {params, headers});
|
|
|
+}
|
|
|
+
|
|
|
+export function delHistory(currentUser: string, id: number) {
|
|
|
+ const url = _url("/searchHistory/delById/" + id);
|
|
|
+ const headers = {currentUser};
|
|
|
+ return httpClient.delete<Response<Object>>(url, {headers});
|
|
|
+}
|
|
|
+
|
|
|
+export function delAllHistory(currentUser: string) {
|
|
|
+ const url = _url("/searchHistory/delAllByUserId");
|
|
|
+ const headers = {currentUser};
|
|
|
+ return httpClient.delete<Response<Object>>(url, {headers});
|
|
|
+}
|
|
|
+
|
|
|
+export function fetchBrowsing(currentUser: string, page: number, size: number, dateNum: number) {
|
|
|
+ const url = _url("/browsing/getPage");
|
|
|
+ const headers = {currentUser};
|
|
|
+ const params = {page, size, dateNum};
|
|
|
+ return httpClient.get<Response<Page<SearchHistoryRecord>>>(url, {params, headers});
|
|
|
+}
|
|
|
+
|
|
|
+export function delBrowsingById(currentUser: string, id: number) {
|
|
|
+ const url = _url("/browsing/delById/" + id);
|
|
|
+ const headers = {currentUser};
|
|
|
+ return httpClient.delete<Response<Object>>(url, {headers});
|
|
|
+}
|
|
|
+
|
|
|
+export function delAllBrowsing(currentUser: string) {
|
|
|
+ const url = _url("/browsing/delByUserId");
|
|
|
+ const headers = {currentUser};
|
|
|
+ return httpClient.delete<Response<Object>>(url, {headers});
|
|
|
}
|
|
|
|
|
|
export default {
|
|
|
- login,
|
|
|
- checkLogin,
|
|
|
- fetchHistory,
|
|
|
+ login,
|
|
|
+ checkLogin,
|
|
|
+ fetchHistory,
|
|
|
+ delHistory,
|
|
|
+ delAllHistory,
|
|
|
+
|
|
|
+ fetchBrowsing,
|
|
|
+ delBrowsingById,
|
|
|
+ delAllBrowsing
|
|
|
}
|