FavoriteController.ts 1.61 KB
import {AxiosResponse, AxiosStatic} from 'axios';
import dayjs, {Dayjs} from 'dayjs';
// region 前端扩展导入包
import {Favorite} from "lib/src/entity/account/entity/Favorite";
import {Page} from "lib/src/core/page/Page";
import {Pagination} from "lib/src/core/page/Pagination";

// endregion

/**
 * 收藏(Favorite) PI接口
 * @since 2025-10-13 12:18:11
 */
export class FavoriteController {

    /**
     * 根据id查询收藏
     * @param aucvehId
     * @return int
     */
    static getFavoriteCountByAucvehId(axios: AxiosStatic, aucvehId: number): Promise<AxiosResponse<number>> {
        return axios.get('favorite/getFavoriteCountByAucvehId', {params: {aucvehId: aucvehId}});
    }

    /**
     * 分页查询收藏
     * @param pagination
     * @return Page
     */
    static pageFavorite(axios: AxiosStatic, pagination: Pagination<Favorite>): Promise<AxiosResponse<Page<Favorite>>> {
        return axios.post('favorite/pageFavorite', pagination);
    }

    static PAGE_FAVORITE = 'favorite/pageFavorite';

    /**
     * 删除收藏
     * @param aucvehId
     * @return int
     */
    static removeFavoriteById(axios: AxiosStatic, aucvehId: number): Promise<AxiosResponse<number>> {
        return axios.delete('favorite/removeFavoriteById', {params: {aucvehId: aucvehId}});
    }

    /**
     * 新增收藏
     * @param aucvehId
     * @return boolean
     */
    static toggleFavorite(axios: AxiosStatic, aucvehId: number): Promise<AxiosResponse<boolean>> {
        return axios.post('favorite/toggleFavorite', null, {params: {aucvehId: aucvehId}});
    }

    // region 前端扩展代码区
    // endregion
}