# go-random-image **Repository Path**: Twilight-Fanyi/go-random-image ## Basic Information - **Project Name**: go-random-image - **Description**: No description available - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2024-11-17 - **Last Updated**: 2024-11-24 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Go Random Image Service 一个基于 Go 语言开发的随机图片服务系统,支持多图库管理、图片上传、随机获取等功能。 ## 功能特性 - 📁 多图库管理(创建、更新、删除) - 🖼️ 图片上传与管理 - 🎲 随机获取指定图库的图片 - 📋 分页获取图库图片列表 - 🔄 支持跨域请求 - 💾 SQLite 数据持久化 ## 技术栈 - [Gin](https://github.com/gin-gonic/gin) - Web 框架 - [GORM](https://gorm.io/) - ORM 框架 - SQLite - 数据库 ## 快速开始 ### 前置要求 - Go 1.16 或更高版本 - GCC(用于 SQLite 支持) ### 安装 ```bash # 克隆项目 git clone https://github.com/yourusername/go-random-image.git # 进入项目目录 cd go-random-image # 安装依赖 go mod tidy ``` ### 运行 ```bash go run main.go ``` 服务将在 `http://localhost:8080` 启动 ## API 接口 ### 图库管理 - `POST /add-gallery` - 创建新图库 - `GET /get-galleries` - 获取所有图库 - `PUT /update-gallery` - 更新图库信息 - `DELETE /delete-gallery` - 删除图库 ### 图片管理 - `POST /upload-image` - 上传图片到指定图库 - `GET /random-image-by-gallery` - 获取指定图库的随机图片 - `POST /get-gallery-images` - 获取图库图片列表 - `DELETE /delete-image` - 删除指定图片 ## 项目结构 ``` . ├── config/ # 配置文件 ├── controllers/ # 控制器 ├── database/ # 数据库配置 ├── models/ # 数据模型 ├── images/ # 图片存储目录 ├── main.go # 主程序入口 └── README.md # 项目文档 ``` ## 配置说明 ### CORS 配置 跨域配置在 `config/cors.go` 中,默认允许所有域名访问。可根据需要修改以下配置: ```go AllowOrigins: []string{"*"} // 允许的域名 AllowMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"} // 允许的请求方法 ``` ### 数据库配置 数据库配置在 `database/database.go` 中,默认使用 SQLite。 ## 许可证 [MIT License](LICENSE)