import { Request, Response } from 'express'; /** * @author bianlanzhou * @since 2024-10-15 * @desc mock数据 */ /** 等待时间 */ const waitTime = (time = 100) => { return new Promise((resolve) => { setTimeout(() => { resolve(true); }, time); }); }; /** 图片验证码响应数据 */ const imageCaptchaRespData = { "success": true, "errCode": null, "errMessage": null, "data": { "uuid": "387b2e19-ede2-457f-8094-cdd1e811fa86", "img": "/9j/4AAQSkZJRgABAgAAAQABAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAARCAAjAGQDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwD0JRUqimKKczBFyaAJRiiOeF5WiWRTIv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IOlFFFAH//2Q==", "type": "IMAGE", "code": "5", } } /** 用户名密码登录响应数据 */ const loginRespData = { "success": true, "errCode": null, "errMessage": null, "data": "eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6ImFmZmZiMmExLTc2ZTYtNGM0My05Y2E4LTI0MjJkYzMyYjUyYyJ9.KvzhtlNE0e4jm_L3tEVB6euN0PWu3eX1uHNjrRYYJ6oHhd8AAvxxejG19arsY0PgV4dkN85SI61TkGFAHrH7tw" } /** otp登录响应数据 */ const otpLoginRespData = { "success": true, "errCode": null, "errMessage": null, } /** 获取当前登录用户响应数据 */ const fetchCurrentUserRespData = { "success": false, "errCode": null, "errMessage": null, "data": { "id": 1, "username": "admin", "nickName": "管理员", "deptId": null, "avatar": '/icons/user.svg', "loginIp": "127.0.0.1", "permissions": [ "*:*:*" ], "sysDept": null, "roles": null } } /** 获取图片验证码 */ const getImageCaptcha = async (req: Request, res: Response) => { await waitTime(2000); res.json(imageCaptchaRespData); } /** 用户名密码登录 */ const handleLogin = async (req: Request, res: Response) => { await waitTime(2000); res.json(loginRespData); } /** otp登录 */ const handleOtpLogin = async (req: Request, res: Response) => { await waitTime(2000); res.json(otpLoginRespData); } /** 获取当前用户 */ const handleFetchCurrentUser = async (req: Request, res: Response) => { await waitTime(2000); res.json(fetchCurrentUserRespData); } export default { 'GET /auth/captcha/image': getImageCaptcha, 'POST /auth/login': handleLogin, 'POST /auth/otp-login': handleOtpLogin, 'GET /auth/current-user': handleFetchCurrentUser, };