# backend_test_problem **Repository Path**: pengfei08_admin/backend_test_problem ## Basic Information - **Project Name**: backend_test_problem - **Description**: 后端面试问题 - **Primary Language**: Go - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-08-11 - **Last Updated**: 2025-08-12 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Backend Test Problem 后端面试题目实现 - Go语言 ## 功能列表 1. **任务管理API** - 增删查改任务 2. **分页查询API** - 支持分页的数据查询 3. **JWT登录认证** - 用户登录和权限验证 4. **文件上传API** - 文件上传和存储 5. **搜索过滤API** - 关键词搜索功能 6. **统计API** - 数据统计和分析 ## 快速开始 ### 1. 安装依赖 ```bash go mod tidy ``` ### 2. 运行服务 ```bash go run main.go ``` ### 3. 测试API #### 健康检查 ```bash curl http://localhost:8080/health ``` #### 任务管理 ```bash # 获取任务列表 curl http://localhost:8080/tasks # 创建任务 curl -X POST http://localhost:8080/tasks \ -H "Content-Type: application/json" \ -d '{"title":"测试任务","description":"描述","status":"pending"}' ``` #### 分页查询 ```bash curl "http://localhost:8080/items?page=1&limit=5" ``` #### 用户认证 ```bash # 登录 curl -X POST http://localhost:8080/login \ -H "Content-Type: application/json" \ -d '{"username":"admin","password":"123456"}' # 获取用户信息(需要token) curl http://localhost:8080/profile \ -H "Authorization: Bearer YOUR_TOKEN" ``` #### 文件上传 ```bash curl -X POST http://localhost:8080/upload \ -F "file=@test.txt" ``` #### 搜索功能 ```bash curl "http://localhost:8080/search?keyword=go" ``` #### 统计信息 ```bash curl http://localhost:8080/stats ``` ## 项目结构 ``` backend_test/ ├── main.go # 主程序入口 ├── go.mod # Go模块文件 ├── models/ # 数据模型 │ └── models.go ├── handlers/ # 处理器 │ ├── tasks.go │ ├── items.go │ ├── auth.go │ ├── upload.go │ ├── search.go │ └── stats.go ├── middleware/ # 中间件 │ └── auth.go ├── uploads/ # 上传文件目录 └── README.md # 说明文档 ``` ## 技术栈 - **框架**: Gin - **认证**: JWT - **语言**: Go 1.21+ ## 默认用户 - 用户名: `admin` - 密码: `123456`