123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- import axios from "axios";
- import { converObj } from "@/helper";
- import { COMMENT_API } from "@/components/comment/config/constant";
-
- type CommonListResponse = {
- list: Array<any>;
- total: number;
- page: number;
- };
-
- interface CommonResponse {
- config: any;
- data: CommonListResponse;
- headers: any;
- request: any;
- status: number;
- statusText: string;
- }
-
- export const getComment = async ({
- type,
- businessId,
- isSpeak,
- page,
- limit,
- }: {
- type: string;
- businessId: string;
- isSpeak?: boolean;
- page: string;
- limit: string;
- }): Promise<any> => {
- const r: CommonResponse = await axios.get(
- `${COMMENT_API}/comments?${converObj({
- type,
- business_id: businessId,
- page,
- limit,
- })}`,
- { withCredentials: true }
- );
- return r.data;
- };
-
- export const createComment = async ({
- type,
- businessId,
- businessUserId,
- content,
- }: {
- type: string;
- businessId: string;
- businessUserId: string;
- content: string;
- }): Promise<any> => {
- const r = await axios.post(`${COMMENT_API}/comments`, {
- method: "post",
- withCredentials: true,
- data: {
- type,
- businessId,
- businessUserId,
- content,
- },
- });
- return r;
- };
-
- export const updateComment = async ({
- id,
- content,
- }: {
- id: string;
- content: string;
- }) => {
- const r = await axios.post(`${COMMENT_API}/comments/${id}`, {
- method: "post",
- withCredentials: true,
- data: {
- content,
- },
- });
- return r;
- };
-
- export const deleteComment = async ({ id }: { id: string }) => {
- const r = await axios.delete(`${COMMENT_API}/comments/${id}`);
- return r;
- };
-
- export const favorComment = async ({
- id,
- commentId,
- userId,
- }: {
- id: string;
- commentId: string;
- userId: number;
- }) => {
- const r = await axios(`${COMMENT_API}/comments/${id}/favor`, {
- method: "put",
- withCredentials: true,
- data: {
- commentID: commentId,
- userID: userId,
- },
- });
- return r;
- };
-
- export const unFavorComment = async ({
- id,
- commentId,
- userId,
- }: {
- id: string;
- commentId: string;
- userId: number;
- }) => {
- const r = await axios(`${COMMENT_API}/comments/${id}/favor`, {
- method: "delete",
- withCredentials: true,
- data: {
- commentID: commentId,
- userID: userId,
- },
- });
- return r;
- };
-
- // export const getFavorUserList = async () => {}
|