修改文档。
This commit is contained in:
parent
78b325cd29
commit
59932bcf29
128
README.md
128
README.md
|
|
@ -1,5 +1,125 @@
|
|||
# mi-assessment
|
||||
# 学业邑规划 - 多元智能测评小程序
|
||||
|
||||
多元智能测评
|
||||
设计图:
|
||||
https://www.figma.com/design/88edYGASUcyID6afiwILdf/%E9%A1%B9%E7%9B%AE?node-id=432-1991
|
||||
基于多元智能理论的学业规划测评系统,帮助学生发现自身优势智能,提供个性化学业规划建议。
|
||||
|
||||
## 项目概述
|
||||
|
||||
本项目包含微信小程序端和后台管理系统,提供完整的测评、报告生成、订单管理、分销等功能。
|
||||
|
||||
## 设计资源
|
||||
|
||||
- **Figma 设计图**: https://www.figma.com/design/88edYGASUcyID6afiwILdf/项目?node-id=432-1991
|
||||
- **切图资源**: `docs/切图/`
|
||||
- **设计图截图**: `docs/设计图/`
|
||||
|
||||
## 项目结构
|
||||
|
||||
```
|
||||
mi-assessment/
|
||||
├── docs/ # 文档资料
|
||||
│ ├── 需求文档.md # 产品需求说明
|
||||
│ ├── 数据库设计文档.md # 数据库设计
|
||||
│ ├── 开发文档.md # 开发指南
|
||||
│ ├── 开发规范/ # 编码规范
|
||||
│ │ ├── 1-编程规约/ # 命名、代码、注释规范
|
||||
│ │ └── 2-异常日志/ # 日志、异常处理规范
|
||||
│ ├── 设计图/ # UI 设计图截图
|
||||
│ ├── 切图/ # UI 切图资源
|
||||
│ └── 题库和结论/ # 测评题库与报告模板
|
||||
│ ├── 0.参考题库和结论/ # 参考资料
|
||||
│ ├── 1.各分析报告对应题目/ # 题目分类
|
||||
│ └── 2.分析报告/ # 各类分析报告模板
|
||||
│
|
||||
├── server/ # 后端服务
|
||||
│ ├── MiAssessment/ # .NET 10 后端项目
|
||||
│ │ ├── src/
|
||||
│ │ │ ├── MiAssessment.Api/ # 小程序 API
|
||||
│ │ │ ├── MiAssessment.Admin/ # 后台管理 API + 前端
|
||||
│ │ │ ├── MiAssessment.Admin.Business/# 后台业务模块
|
||||
│ │ │ ├── MiAssessment.Core/ # 核心业务逻辑
|
||||
│ │ │ ├── MiAssessment.Infrastructure/# 基础设施
|
||||
│ │ │ └── MiAssessment.Model/ # 数据模型
|
||||
│ │ ├── scripts/ # 数据库初始化脚本
|
||||
│ │ └── tests/ # 单元测试
|
||||
│ └── README.md
|
||||
│
|
||||
└── uniapp/ # 小程序前端 (UniApp + Vue 3)
|
||||
```
|
||||
|
||||
## 技术栈
|
||||
|
||||
| 端 | 技术 |
|
||||
|----|------|
|
||||
| 小程序前端 | UniApp + Vue 3 + TypeScript |
|
||||
| 后台管理前端 | Vue 3 + TypeScript + Vite |
|
||||
| 后端服务 | .NET 10 + Entity Framework Core |
|
||||
| 数据库 | SQL Server 2022 |
|
||||
| 缓存 | Redis |
|
||||
|
||||
## 核心功能
|
||||
|
||||
### 小程序端
|
||||
- 微信授权登录
|
||||
- 多元智能测评答题
|
||||
- 测评报告查看
|
||||
- 学业规划建议
|
||||
- 订单支付
|
||||
|
||||
### 后台管理
|
||||
- 用户管理
|
||||
- 测评管理 (题库、报告模板)
|
||||
- 订单管理
|
||||
- 分销管理
|
||||
- 规划师管理
|
||||
- 系统配置
|
||||
|
||||
## 快速开始
|
||||
|
||||
### 后端服务
|
||||
|
||||
```bash
|
||||
cd server/MiAssessment
|
||||
dotnet restore
|
||||
dotnet build
|
||||
|
||||
# 启动小程序 API
|
||||
dotnet run --project src/MiAssessment.Api
|
||||
|
||||
# 启动后台管理 API
|
||||
dotnet run --project src/MiAssessment.Admin
|
||||
```
|
||||
|
||||
详细说明请参考 [server/MiAssessment/TEMPLATE_README.md](server/MiAssessment/TEMPLATE_README.md)
|
||||
|
||||
### 后台管理前端
|
||||
|
||||
```bash
|
||||
cd server/MiAssessment/src/MiAssessment.Admin/admin-web
|
||||
npm install
|
||||
npm run dev
|
||||
```
|
||||
|
||||
### 小程序前端
|
||||
|
||||
```bash
|
||||
cd uniapp
|
||||
npm install
|
||||
# 使用 HBuilderX 或命令行运行
|
||||
```
|
||||
|
||||
## 文档索引
|
||||
|
||||
| 文档 | 说明 |
|
||||
|------|------|
|
||||
| [需求文档](docs/需求文档.md) | 产品功能需求说明 |
|
||||
| [数据库设计文档](docs/数据库设计文档.md) | 数据库表结构设计 |
|
||||
| [开发文档](docs/开发文档.md) | 开发指南与接口说明 |
|
||||
| [后端 README](server/MiAssessment/TEMPLATE_README.md) | 后端服务详细说明 |
|
||||
|
||||
## 开发规范
|
||||
|
||||
- [命名风格](docs/开发规范/1-编程规约/1.1-命名风格.md)
|
||||
- [代码风格](docs/开发规范/1-编程规约/1.2-代码风格.md)
|
||||
- [注释规约](docs/开发规范/1-编程规约/1.3-注释规约.md)
|
||||
- [日志规约](docs/开发规范/2-异常日志/2.1-日志规约.md)
|
||||
- [异常处理](docs/开发规范/2-异常日志/2.2-异常处理.md)
|
||||
|
|
|
|||
|
|
@ -1,328 +1,295 @@
|
|||
# Framework Template - Backend
|
||||
# 学业邑规划 (MiAssessment) - 后端服务
|
||||
|
||||
This is a .NET 10 backend framework template extracted from the MiAssessment project. It provides a clean architecture foundation with essential features for building mini-program backends.
|
||||
基于 .NET 10 的多元智能测评小程序后端服务,采用清洁架构设计,提供小程序 API 和后台管理系统。
|
||||
|
||||
## Features
|
||||
## 技术栈
|
||||
|
||||
- **Authentication & Authorization**: JWT + Refresh Token mechanism
|
||||
- **User Management**: Basic user info, login logs
|
||||
- **WeChat Integration**: Mini-program login, phone number retrieval
|
||||
- **WeChat Pay**: V3 payment, callback verification, refunds
|
||||
- **Address Management**: User shipping address CRUD
|
||||
- **Configuration Management**: System configuration read/write
|
||||
- **File Upload**: Local storage + Tencent Cloud COS dual mode
|
||||
- **Admin RBAC**: Complete role-based access control system
|
||||
- **Dictionary Management**: Static data + dynamic SQL query support
|
||||
- **Payment Orders**: Generic payment order with reward handler mechanism
|
||||
- **Redis Cache**: Cache service wrapper
|
||||
| 组件 | 技术 |
|
||||
|------|------|
|
||||
| 框架 | ASP.NET Core (.NET 10) |
|
||||
| ORM | Entity Framework Core |
|
||||
| 数据库 | SQL Server 2022 |
|
||||
| 缓存 | Redis |
|
||||
| 认证 | JWT Bearer + Refresh Token |
|
||||
| 日志 | Serilog |
|
||||
| 对象映射 | Mapster |
|
||||
| API 文档 | Scalar (OpenAPI) |
|
||||
| DI 容器 | Autofac |
|
||||
|
||||
## Project Structure
|
||||
## 功能特性
|
||||
|
||||
- **用户认证**: 微信小程序登录、JWT 认证、Token 刷新
|
||||
- **微信集成**: 小程序登录、手机号获取
|
||||
- **微信支付**: V3 支付、回调验签、退款
|
||||
- **用户管理**: 用户信息、登录日志、地址管理
|
||||
- **测评系统**: 题库管理、测评记录、报告生成
|
||||
- **订单系统**: 支付订单、分销佣金
|
||||
- **后台管理**: 完整的 RBAC 权限控制
|
||||
- **字典管理**: 静态数据 + 动态 SQL 查询
|
||||
|
||||
## 项目结构
|
||||
|
||||
```
|
||||
server/MiAssessment/
|
||||
├── MiAssessment.sln
|
||||
├── MiAssessment.sln # 解决方案文件
|
||||
├── scripts/ # 数据库脚本
|
||||
│ ├── init_admin_db.sql # 后台管理数据库初始化
|
||||
│ ├── init_business_db.sql # 业务数据库初始化
|
||||
│ ├── init_business_dict.sql # 业务字典数据
|
||||
│ └── seed_business_permissions.sql # 业务权限种子数据
|
||||
│
|
||||
├── src/
|
||||
│ ├── MiAssessment.Api/ # Web API Layer
|
||||
│ │ ├── Controllers/
|
||||
│ │ │ ├── AuthController.cs # Authentication
|
||||
│ │ │ ├── UserController.cs # User management
|
||||
│ │ │ ├── AddressController.cs # Address management
|
||||
│ │ │ ├── ConfigController.cs # Configuration
|
||||
│ │ │ ├── PayController.cs # Payment
|
||||
│ │ │ ├── NotifyController.cs # Payment callbacks
|
||||
│ │ │ └── HealthController.cs # Health check
|
||||
│ │ ├── Filters/
|
||||
│ │ └── Program.cs
|
||||
│ ├── MiAssessment.Api/ # 小程序 API 接口层
|
||||
│ │ ├── Controllers/ # API 控制器
|
||||
│ │ ├── Filters/ # 过滤器
|
||||
│ │ └── Program.cs # 程序入口
|
||||
│ │
|
||||
│ ├── MiAssessment.Core/ # Business Logic Layer
|
||||
│ │ ├── Interfaces/
|
||||
│ │ ├── Services/
|
||||
│ │ └── Mappings/
|
||||
│ ├── MiAssessment.Admin/ # 后台管理系统
|
||||
│ │ ├── admin-web/ # 前端代码 (Vue 3 + TypeScript)
|
||||
│ │ ├── Controllers/ # 管理 API 控制器
|
||||
│ │ ├── Services/ # 管理服务
|
||||
│ │ ├── Entities/ # 管理实体
|
||||
│ │ ├── Data/ # 数据库上下文
|
||||
│ │ ├── Filters/ # 权限过滤器
|
||||
│ │ └── Models/ # DTO 模型
|
||||
│ │
|
||||
│ ├── MiAssessment.Infrastructure/ # Infrastructure Layer
|
||||
│ │ ├── Cache/
|
||||
│ │ ├── External/
|
||||
│ │ └── Modules/
|
||||
│ ├── MiAssessment.Admin.Business/ # 后台业务模块 (主要开发区域)
|
||||
│ │ ├── Controllers/ # 业务管理控制器
|
||||
│ │ ├── Services/ # 业务服务
|
||||
│ │ │ └── Interfaces/ # 服务接口
|
||||
│ │ ├── Entities/ # 业务实体
|
||||
│ │ ├── Models/ # 请求/响应模型
|
||||
│ │ ├── Data/ # 业务数据库上下文
|
||||
│ │ └── Attributes/ # 自定义特性
|
||||
│ │
|
||||
│ ├── MiAssessment.Model/ # Data Model Layer
|
||||
│ │ ├── Entities/
|
||||
│ │ ├── Models/
|
||||
│ │ ├── Data/
|
||||
│ │ └── Base/
|
||||
│ ├── MiAssessment.Core/ # 核心业务逻辑层
|
||||
│ │ ├── Interfaces/ # 服务接口
|
||||
│ │ ├── Services/ # 服务实现
|
||||
│ │ ├── Mappings/ # 对象映射配置
|
||||
│ │ └── Constants/ # 常量定义
|
||||
│ │
|
||||
│ ├── MiAssessment.Admin/ # Admin RBAC
|
||||
│ │ ├── Controllers/
|
||||
│ │ ├── Services/
|
||||
│ │ ├── Entities/
|
||||
│ │ └── Data/
|
||||
│ ├── MiAssessment.Infrastructure/ # 基础设施层
|
||||
│ │ ├── Cache/ # Redis 缓存
|
||||
│ │ ├── External/ # 外部服务集成
|
||||
│ │ └── Modules/ # 功能模块
|
||||
│ │
|
||||
│ └── MiAssessment.Admin.Business/ # Admin Business Module
|
||||
│ ├── Controllers/
|
||||
│ └── Services/
|
||||
│ └── MiAssessment.Model/ # 数据模型层
|
||||
│ ├── Entities/ # 数据库实体
|
||||
│ ├── Models/ # DTO 模型
|
||||
│ ├── Data/ # 数据库上下文
|
||||
│ └── Base/ # 基类
|
||||
│
|
||||
├── scripts/ # Database Scripts
|
||||
│ ├── init_admin_db.sql # Admin database initialization
|
||||
│ └── init_business_db.sql # Business database initialization
|
||||
│
|
||||
├── tests/
|
||||
│ └── MiAssessment.Tests/ # Unit & Property Tests
|
||||
│
|
||||
└── README.md
|
||||
└── tests/
|
||||
└── MiAssessment.Tests/ # 单元测试 & 属性测试
|
||||
```
|
||||
|
||||
## Placeholder Locations
|
||||
## 后台管理前端
|
||||
|
||||
When generating a new project from this template, the following placeholders need to be replaced:
|
||||
前端代码位于 `src/MiAssessment.Admin/admin-web/`,技术栈:
|
||||
|
||||
### Project Name Placeholders
|
||||
- **框架**: Vue 3 + TypeScript
|
||||
- **构建工具**: Vite
|
||||
- **UI 组件**: Element Plus (或其他)
|
||||
- **状态管理**: Pinia
|
||||
- **HTTP 客户端**: Axios
|
||||
|
||||
| Placeholder | Description | Example |
|
||||
|-------------|-------------|---------|
|
||||
| `MiAssessment` | Project name (PascalCase) | `MyApp` |
|
||||
| `MiAssessment` | Original project name to replace | → `MyApp` |
|
||||
```bash
|
||||
# 进入前端目录
|
||||
cd src/MiAssessment.Admin/admin-web
|
||||
|
||||
### Files Requiring Project Name Replacement
|
||||
# 安装依赖
|
||||
npm install
|
||||
|
||||
#### Solution & Project Files
|
||||
- `MiAssessment.sln` → `MiAssessment.sln`
|
||||
- `src/MiAssessment.Api/MiAssessment.Api.csproj` → `src/MiAssessment.Api/MiAssessment.Api.csproj`
|
||||
- `src/MiAssessment.Core/MiAssessment.Core.csproj` → `src/MiAssessment.Core/MiAssessment.Core.csproj`
|
||||
- `src/MiAssessment.Infrastructure/MiAssessment.Infrastructure.csproj` → `src/MiAssessment.Infrastructure/MiAssessment.Infrastructure.csproj`
|
||||
- `src/MiAssessment.Model/MiAssessment.Model.csproj` → `src/MiAssessment.Model/MiAssessment.Model.csproj`
|
||||
- `src/MiAssessment.Admin/MiAssessment.Admin.csproj` → `src/MiAssessment.Admin/MiAssessment.Admin.csproj`
|
||||
- `src/MiAssessment.Admin.Business/MiAssessment.Admin.Business.csproj` → `src/MiAssessment.Admin.Business/MiAssessment.Admin.Business.csproj`
|
||||
- `tests/MiAssessment.Tests/MiAssessment.Tests.csproj` → `tests/MiAssessment.Tests/MiAssessment.Tests.csproj`
|
||||
# 开发模式
|
||||
npm run dev
|
||||
|
||||
#### Namespace Declarations (All .cs files)
|
||||
Replace in all C# source files:
|
||||
```csharp
|
||||
// From:
|
||||
namespace MiAssessment.Api.Controllers;
|
||||
using MiAssessment.Core.Services;
|
||||
|
||||
// To:
|
||||
namespace MiAssessment.Api.Controllers;
|
||||
using MiAssessment.Core.Services;
|
||||
# 构建生产版本
|
||||
npm run build
|
||||
```
|
||||
|
||||
#### Configuration Files
|
||||
- `src/MiAssessment.Api/appsettings.json`
|
||||
- Connection strings
|
||||
- JWT settings
|
||||
- WeChat configuration
|
||||
- `src/MiAssessment.Api/appsettings.Development.json`
|
||||
- `src/MiAssessment.Admin/appsettings.json`
|
||||
## 快速开始
|
||||
|
||||
### Database Placeholders
|
||||
### 1. 环境要求
|
||||
|
||||
| Placeholder | Description | Example |
|
||||
|-------------|-------------|---------|
|
||||
| `MiAssessment_Admin` | Admin database name | `MyApp_Admin` |
|
||||
| `MiAssessment_Business` | Business database name | `MyApp_Business` |
|
||||
- .NET 10 SDK
|
||||
- SQL Server 2022
|
||||
- Redis
|
||||
- Node.js 18+ (前端开发)
|
||||
|
||||
### Configuration Placeholders (appsettings.json)
|
||||
### 2. 配置数据库
|
||||
|
||||
| Placeholder | Description | Example |
|
||||
|-------------|-------------|---------|
|
||||
| `{{DB_SERVER}}` | SQL Server 地址 | `localhost` |
|
||||
| `{{DB_USER}}` | 数据库用户名 | `sa` |
|
||||
| `{{DB_PASSWORD}}` | 数据库密码 | `YourPassword123` |
|
||||
| `{{DB_NAME}}` | 业务数据库名 | `myapp_business` |
|
||||
| `{{ADMIN_DB_NAME}}` | 管理后台数据库名 | `myapp_admin` |
|
||||
| `{{REDIS_HOST}}` | Redis 地址 | `localhost` |
|
||||
| `{{REDIS_PORT}}` | Redis 端口 | `6379` |
|
||||
| `{{JWT_SECRET_AT_LEAST_32_CHARACTERS}}` | JWT 密钥 (至少32字符) | `MySecretKey123...` |
|
||||
| `{{PROJECT_NAME}}` | 项目名称 | `MyApp` |
|
||||
| `{{WECHAT_MCH_ID}}` | 微信支付商户号 | `1234567890` |
|
||||
| `{{WECHAT_APP_ID}}` | 小程序 AppId | `wx1234567890abcdef` |
|
||||
| `{{WECHAT_API_KEY}}` | 微信支付 API 密钥 | `your_api_key` |
|
||||
| `{{WECHAT_NOTIFY_URL}}` | 支付回调地址 | `https://api.example.com/api/notify/wechat` |
|
||||
| `{{API_BASE_URL}}` | API 基础地址 | `https://api.example.com` |
|
||||
| `{{AMAP_API_KEY}}` | 高德地图 API Key | `your_amap_key` |
|
||||
|
||||
## Database Initialization
|
||||
|
||||
### Admin Database
|
||||
|
||||
The `scripts/init_admin_db.sql` script creates:
|
||||
|
||||
**Tables:**
|
||||
- `departments` - Department hierarchy
|
||||
- `admin_users` - Admin accounts
|
||||
- `roles` - Role definitions
|
||||
- `permissions` - Permission definitions
|
||||
- `menus` - Menu configuration
|
||||
- `admin_user_roles` - Admin-Role associations
|
||||
- `role_menus` - Role-Menu associations
|
||||
- `role_permissions` - Role-Permission associations
|
||||
- `admin_user_menus` - User-specific menus
|
||||
- `department_menus` - Department-Menu associations
|
||||
- `operation_logs` - Operation audit logs
|
||||
- `refresh_tokens` - Admin refresh tokens
|
||||
- `admin_configs` - Admin configurations
|
||||
- `dict_types` - Dictionary types
|
||||
- `dict_items` - Dictionary items
|
||||
|
||||
**Default Data:**
|
||||
- Default department: 总部 (HQ)
|
||||
- Default roles: 超级管理员, 管理员
|
||||
- Default admin user: `admin` / `admin123`
|
||||
- Default permissions: System management, User management
|
||||
- Default menus: System management tree
|
||||
- Default dictionaries: user_status, gender, yes_no
|
||||
|
||||
### Business Database
|
||||
|
||||
The `scripts/init_business_db.sql` script creates:
|
||||
|
||||
**Tables:**
|
||||
- `users` - User accounts (simplified)
|
||||
- `user_details` - User extension fields
|
||||
- `user_addresses` - Shipping addresses
|
||||
- `user_refresh_tokens` - User refresh tokens
|
||||
- `user_login_logs` - Login audit logs
|
||||
- `payment_orders` - Generic payment orders
|
||||
- `order_notifies` - Payment callback records
|
||||
- `configs` - System configurations
|
||||
- `pictures` - Image management
|
||||
- `deliveries` - Delivery companies
|
||||
|
||||
**Default Data:**
|
||||
- Default configs: wechat, wechat_pay, sms, system
|
||||
- Default deliveries: SF, ZTO, YTO, YD, STO, JTSD, YZPY, JD, DBL
|
||||
|
||||
## Quick Start
|
||||
|
||||
### 1. Generate Project
|
||||
|
||||
Use the template generator script:
|
||||
|
||||
```powershell
|
||||
./create-project.ps1 `
|
||||
-ProjectName "MyApp" `
|
||||
-AdminDbName "MyApp_Admin" `
|
||||
-BusinessDbName "MyApp_Business" `
|
||||
-SqlServerHost "localhost" `
|
||||
-SqlServerUser "sa" `
|
||||
-SqlServerPassword "YourPassword"
|
||||
```
|
||||
|
||||
### 2. Configure Database
|
||||
|
||||
Update `appsettings.json` with your database connection strings:
|
||||
修改 `appsettings.json` 中的连接字符串:
|
||||
|
||||
```json
|
||||
{
|
||||
"ConnectionStrings": {
|
||||
"AdminConnection": "Server=localhost;Database=MyApp_Admin;User Id=sa;Password=YourPassword;TrustServerCertificate=True",
|
||||
"DefaultConnection": "Server=localhost;Database=MyApp_Business;User Id=sa;Password=YourPassword;TrustServerCertificate=True"
|
||||
"AdminConnection": "Server=localhost;Database=MiAssessment_Admin;User Id=sa;Password=YourPassword;TrustServerCertificate=True",
|
||||
"DefaultConnection": "Server=localhost;Database=MiAssessment_Business;User Id=sa;Password=YourPassword;TrustServerCertificate=True"
|
||||
},
|
||||
"Redis": {
|
||||
"Host": "localhost",
|
||||
"Port": 6379
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 3. Initialize Databases
|
||||
|
||||
Run the initialization scripts:
|
||||
### 3. 初始化数据库
|
||||
|
||||
```sql
|
||||
-- Create Admin database
|
||||
CREATE DATABASE [MyApp_Admin];
|
||||
-- 创建管理后台数据库
|
||||
CREATE DATABASE [MiAssessment_Admin];
|
||||
GO
|
||||
-- Run init_admin_db.sql
|
||||
-- 执行 scripts/init_admin_db.sql
|
||||
|
||||
-- Create Business database
|
||||
CREATE DATABASE [MyApp_Business];
|
||||
-- 创建业务数据库
|
||||
CREATE DATABASE [MiAssessment_Business];
|
||||
GO
|
||||
-- Run init_business_db.sql
|
||||
-- 执行 scripts/init_business_db.sql
|
||||
-- 执行 scripts/init_business_dict.sql
|
||||
-- 执行 scripts/seed_business_permissions.sql
|
||||
```
|
||||
|
||||
### 4. Build and Run
|
||||
### 4. 启动服务
|
||||
|
||||
```bash
|
||||
cd server/MyApp
|
||||
# 还原依赖
|
||||
dotnet restore
|
||||
|
||||
# 构建项目
|
||||
dotnet build
|
||||
dotnet run --project src/MyApp.Api
|
||||
|
||||
# 启动小程序 API (端口 5238)
|
||||
dotnet run --project src/MiAssessment.Api
|
||||
|
||||
# 启动后台管理 API (端口 5239)
|
||||
dotnet run --project src/MiAssessment.Admin
|
||||
```
|
||||
|
||||
The API will be available at `http://localhost:5238`
|
||||
### 5. 访问服务
|
||||
|
||||
### 5. Access Admin Panel
|
||||
| 服务 | 地址 |
|
||||
|------|------|
|
||||
| 小程序 API | http://localhost:5238 |
|
||||
| 小程序 API 文档 | http://localhost:5238/scalar/v1 |
|
||||
| 后台管理 API | http://localhost:5239 |
|
||||
| 后台管理前端 | http://localhost:5173 (开发模式) |
|
||||
|
||||
- URL: `http://localhost:5238/admin`
|
||||
- Username: `admin`
|
||||
- Password: `admin123`
|
||||
### 6. 默认管理员账号
|
||||
|
||||
## Extending the Template
|
||||
- 用户名: `admin`
|
||||
- 密码: `admin123`
|
||||
|
||||
### Adding Business Fields to User
|
||||
## 数据库说明
|
||||
|
||||
Add fields to `user_details` table:
|
||||
### 管理后台数据库 (MiAssessment_Admin)
|
||||
|
||||
```sql
|
||||
ALTER TABLE [dbo].[user_details]
|
||||
ADD [Balance] DECIMAL(10,2) NOT NULL DEFAULT 0,
|
||||
[Points] INT NOT NULL DEFAULT 0,
|
||||
[Level] INT NOT NULL DEFAULT 1;
|
||||
| 表名 | 说明 |
|
||||
|------|------|
|
||||
| departments | 部门层级 |
|
||||
| admin_users | 管理员账号 |
|
||||
| roles | 角色定义 |
|
||||
| permissions | 权限定义 |
|
||||
| menus | 菜单配置 |
|
||||
| admin_user_roles | 管理员-角色关联 |
|
||||
| role_menus | 角色-菜单关联 |
|
||||
| role_permissions | 角色-权限关联 |
|
||||
| operation_logs | 操作审计日志 |
|
||||
| refresh_tokens | 刷新令牌 |
|
||||
| dict_types | 字典类型 |
|
||||
| dict_items | 字典项 |
|
||||
|
||||
### 业务数据库 (MiAssessment_Business)
|
||||
|
||||
| 表名 | 说明 |
|
||||
|------|------|
|
||||
| users | 用户账号 |
|
||||
| user_details | 用户扩展信息 |
|
||||
| user_addresses | 收货地址 |
|
||||
| user_login_logs | 登录日志 |
|
||||
| payment_orders | 支付订单 |
|
||||
| order_notifies | 支付回调记录 |
|
||||
| configs | 系统配置 |
|
||||
| assessment_* | 测评相关表 |
|
||||
|
||||
## 配置项说明
|
||||
|
||||
| 配置项 | 说明 |
|
||||
|--------|------|
|
||||
| `ConnectionStrings:AdminConnection` | 管理后台数据库连接 |
|
||||
| `ConnectionStrings:DefaultConnection` | 业务数据库连接 |
|
||||
| `Redis:Host` | Redis 服务器地址 |
|
||||
| `Redis:Port` | Redis 端口 |
|
||||
| `Jwt:Secret` | JWT 密钥 (至少32字符) |
|
||||
| `Jwt:Issuer` | JWT 签发者 |
|
||||
| `Jwt:Audience` | JWT 受众 |
|
||||
| `WeChat:AppId` | 小程序 AppId |
|
||||
| `WeChat:AppSecret` | 小程序 AppSecret |
|
||||
| `WeChatPay:MchId` | 微信支付商户号 |
|
||||
| `WeChatPay:ApiKey` | 微信支付 API 密钥 |
|
||||
| `WeChatPay:NotifyUrl` | 支付回调地址 |
|
||||
|
||||
## API 接口规范
|
||||
|
||||
### 路由格式
|
||||
|
||||
```
|
||||
小程序 API: /api/{module}/{action}
|
||||
后台管理 API: /api/admin/{module}/{action}
|
||||
```
|
||||
|
||||
Update `UserDetail.cs` entity accordingly.
|
||||
### 请求方式
|
||||
|
||||
### Adding Payment Reward Handlers
|
||||
- **GET**: 查询操作,参数通过 Query String 传递
|
||||
- **POST**: 新增、修改、删除操作,参数通过 JSON Body 传递
|
||||
|
||||
Implement `IPaymentRewardHandler` interface:
|
||||
### 响应格式
|
||||
|
||||
```csharp
|
||||
public class VipPurchaseRewardHandler : IPaymentRewardHandler
|
||||
```json
|
||||
{
|
||||
public string OrderType => "vip_purchase";
|
||||
|
||||
public async Task<RewardResult> ProcessRewardAsync(PaymentOrder order)
|
||||
{
|
||||
// Implement VIP activation logic
|
||||
return new RewardResult { Success = true, Message = "VIP activated" };
|
||||
}
|
||||
"code": 0,
|
||||
"message": "success",
|
||||
"data": {}
|
||||
}
|
||||
```
|
||||
|
||||
Register in DI container:
|
||||
### 分页响应
|
||||
|
||||
```csharp
|
||||
services.AddScoped<IPaymentRewardHandler, VipPurchaseRewardHandler>();
|
||||
```json
|
||||
{
|
||||
"code": 0,
|
||||
"message": "success",
|
||||
"data": {
|
||||
"items": [],
|
||||
"total": 100,
|
||||
"page": 1,
|
||||
"pageSize": 20,
|
||||
"totalPages": 5
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Adding New Dictionary Types
|
||||
## Docker 部署
|
||||
|
||||
Insert via SQL or Admin panel:
|
||||
```bash
|
||||
# 构建小程序 API 镜像
|
||||
docker build -t miassessment-api -f src/MiAssessment.Api/Dockerfile .
|
||||
|
||||
```sql
|
||||
INSERT INTO [dict_types] ([code], [name], [source_type], [status])
|
||||
VALUES ('order_status', N'订单状态', 1, 1);
|
||||
# 构建后台管理 API 镜像
|
||||
docker build -t miassessment-admin -f src/MiAssessment.Admin/Dockerfile .
|
||||
|
||||
INSERT INTO [dict_items] ([type_id], [label], [value], [css_class], [status], [sort])
|
||||
VALUES
|
||||
(@type_id, N'待支付', '0', 'warning', 1, 1),
|
||||
(@type_id, N'已支付', '1', 'success', 1, 2),
|
||||
(@type_id, N'已取消', '2', 'info', 1, 3);
|
||||
# 构建后台管理前端镜像
|
||||
docker build -t miassessment-admin-web -f src/MiAssessment.Admin/admin-web/Dockerfile src/MiAssessment.Admin/admin-web
|
||||
```
|
||||
|
||||
## API Documentation
|
||||
## 开发规范
|
||||
|
||||
After starting the API, access Scalar documentation at:
|
||||
- `http://localhost:5238/scalar/v1`
|
||||
详细开发规范请参考 `docs/开发规范/` 目录下的文档:
|
||||
|
||||
## Technology Stack
|
||||
- 编程规约 (命名风格、代码风格、注释规约)
|
||||
- 异常日志 (日志规约、异常处理)
|
||||
|
||||
- **Framework**: ASP.NET Core (.NET 10)
|
||||
- **ORM**: Entity Framework Core 8.0
|
||||
- **Database**: SQL Server
|
||||
- **Architecture**: Clean Architecture
|
||||
- **DI Container**: Autofac
|
||||
- **Authentication**: JWT Bearer
|
||||
- **Logging**: Serilog
|
||||
- **Object Mapping**: Mapster
|
||||
- **API Documentation**: Scalar (OpenAPI)
|
||||
## 相关文档
|
||||
|
||||
## License
|
||||
|
||||
This template is provided as-is for internal use.
|
||||
- [需求文档](../docs/需求文档.md)
|
||||
- [数据库设计文档](../docs/数据库设计文档.md)
|
||||
- [开发文档](../docs/开发文档.md)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user