// 引入mockjs
import {MockMethod} from "vite-plugin-mock";

const MockJs = require('mockjs')
const {Random} = MockJs;

interface MockMethodResOpt {
    body: Record<string, any>,
    query: Record<string, any>
}

export default [
    {
        url: '/api/v1/user/login',
        method: 'post',
        response: ({query}: MockMethodResOpt) => {
            return {
                success: true,
                result: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.MTIz.5frDWv6bqXyHPXl3oZYOTnALMCGwfEYjQZbke2iyR3Y"
            };
        }
    },
    {
        url: '/api/v1/user/current',
        method: 'get',
        response: ({query}: MockMethodResOpt) => {
            return {
                success: true,
                result: {
                    id: Random.guid(),
                    name: Random.cname(2, 4),
                    user_role: 1,
                }
            };
        }
    },
] as MockMethod[];
