title: ChanSheen API Service 项目介绍
author: Justin Han
date: 2025-06-18 10:18:00
categories:
- 项目文档
tags:
- FastAPI
- SQLAlchemy
- GitHub
- 节假日接口
ChanSheen API Service / ChanSheen API 服务
📌 项目简介 | Project Introduction
本项目是一个基于 FastAPI 构建的轻量级 API 服务,支持令牌验证、节假日查询、用户认证等功能。适用于企业内部系统、HR 接口对接、日历服务等应用场景。
This project is a lightweight API service built with FastAPI, featuring token-based authentication, holiday queries, and user login functionality. It is suitable for enterprise systems, HR integrations, and calendar services.
## 🆚 版本变更 | Version History
🚀 快速开始 | Quick Start
🧱 安装依赖 | Install Dependencies
pip install -r requirements.txt
▶️ 运行项目 | Run the Project
uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload
或者使用 systemd 启动服务:
sudo systemctl start chansheenapi.service
🔐 用户认证 | User Authentication
通过 /api/auth/token
获取访问 Token:
请求 | Request
POST /api/auth/token
请求体 (表单格式):
username=admin&password=admin
响应 | Response
{
"access_token": "xxx.yyy.zzz",
"token_type": "bearer"
}
📅 节假日接口 | Holiday API
查询节假日 | Query Holiday
接口地址:
GET /api/calendar
支持查询参数:
year=2025
month=2025-06
date=2025-06-18
请求需附带认证 Token:
Authorization: Bearer <your_token>
示例响应 | Example Response
{
"data": [
{
"date": "2025-06-18",
"dateType": 1,
"weekName": "星期三",
"note": "工作日",
"lunar": "五月廿三"
}
]
}
⚙️ 配置说明 | Configuration
环境变量保存在 .env
文件中:
DB_USER=root
DB_PASSWORD=your_password
DB_HOST=localhost
DB_PORT=3306
DB_NAME=holiday_db
SECRET_KEY=your_secret_key
ALGORITHM=HS256
ACCESS_TOKEN_EXPIRE_MINUTES=120
🗃️ 数据库结构 | Database Schema
表:holidays
表:users
📦 接口文档 | API Documentation
FastAPI 自动生成的接口文档地址如下:
Swagger UI: http://localhost:8000/docs
ReDoc: http://localhost:8000/redoc
📬 联系方式 | Contact
如需支持或合作,请联系:
📧 邮箱:
hschenhan@gmail.com
🌐 GitHub: https://github.com/HSHanChen/chansheen-api-service
📄 许可证 | License
本项目采用 MIT 开源许可证。 This project is licensed under the MIT License.
详细信息请参见项目根目录下的 LICENSE
文件。 See the LICENSE
file for details.
评论