# backend **Repository Path**: PromiseCatch/backend ## Basic Information - **Project Name**: backend - **Description**: 第六届传智杯”我许下了Promise,你从不catch 队“项目后端 - **Primary Language**: C# - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2023-09-24 - **Last Updated**: 2024-10-09 ## Categories & Tags **Categories**: Uncategorized **Tags**: dotNET, Csharp ## README # 项目后端 ## 架构 ### 文件层次结构 ```text . ├── 功能需求.md ├── 功能需求.xmind ├── ControllerTest --- 接口测试 --- │   ├── ControllerTest.csproj │   ├── GlobalUsings.cs │   └── UnitTest1.cs ├── EntitySync --- 数据库实体同步 --- │   ├── EntitySync.csproj │   └── Program.cs ├── LearnWorryFree.Api --- Api 接口 --- │   ├── appsettings.Development.json │   ├── appsettings.json -- 环境变量配置文件 │   ├── Attributes │   │   └── NoLogAttribute.cs │   ├── Authorize --- 鉴权 --- │   │   ├── Impl │   │   │   ├── JwtTokenProvider.cs │   │   │   └── PermissionRequirement.cs │   │   ├── Interface │   │   │   ├── IJwtTokenProvider.cs │   │   │   └── IPermissionRequirement.cs │   │   └── PermissionHandler.cs │   ├── Configs --- 配置 --- │   │   ├── CosConfig.cs │   │   ├── JwtConfig.cs │   │   └── SqlSugarConfig.cs │   ├── Const --- 常量和枚举 --- │   │   ├── CacheConst.cs │   │   ├── ...... │   │   └── SecretKeySize.cs │   ├── Controllers --- 接口 --- │   │   ├── AnnouncementController.cs │   │   ├── ...... │   │   └── UserController.cs │   ├── Extension --- 插件/中间件 --- │   │   ├── AuthExtension.cs │   │   ├── ...... │   │   └── SwaggerExtension.cs │   ├── Files --- 静态资源 --- │   │   ├── alipay.jpg │   │   ├── img.jpg │   │   └── wxpay.jpg │   ├── Filters --- 全局日志/异常处理 --- │   │   ├── GlobalExceptionFilter.cs │   │   └── LogActionFilter.cs │   ├── GlobalUsings.cs -- 全局引用 │   ├── LearnWorryFree.Api.csproj │   ├── LearnWorryFree.Api.csproj.user │   ├── Program.cs -- 程序主入口 │   ├── Properties -- 程序启动配置 │   │   └── launchSettings.json │   ├── Services --- 服务 --- │   │   ├── IAuthService.cs │   │   ├── IBucketClient.cs │   │   ├── ICosClient.cs │   │   ├── Impl │   │   │   ├── AuthService.cs │   │   │   ├── BucketClient.cs │   │   │   ├── CosClient.cs │   │   │   ├── RoleService.cs │   │   │   ├── TimerService.cs │   │   │   └── UserService.cs │   │   ├── IRoleService.cs │   │   └── IUserService.cs │   ├── Subscribers --- 订阅/监听 --- │   │   ├── LoginSubscriber.cs │   │   ├── LogSubscriber.cs │   │   └── RedisEventSourceStorer.cs │   └── Utils --- 工具 --- │   ├── CommonUtil.cs │   ├── CosBuilder.cs │   └── SqlSugarUtil.cs ├── LearnWorryFree.Domain --- 实体集/Dto/映射 --- │   ├── AutoMappers --- 自动映射 --- │   │   ├── AutoMapperExtension.cs │   │   └── _MapConfig.cs │   ├── Dtos --- Dto --- │   │   ├── AnnouncementDto.cs │   │   ├── ...... │   │   └── UserDto.cs │   ├── Entities --- 实体 --- │   │   ├── Account.cs │   │   ├── ...... │   │   └── User.cs │   ├── Enums --- 枚举 --- │   │   ├── CacheEnum.cs │   │   ├── ...... │   │   └── UserTypeEnum.cs │   ├── LearnWorryFree.Domain.csproj │   └── ViewModels --- 视图 --- │   ├── AnnouncementView.cs │   ├── ...... │   └── WeChatViews.cs ├── LearnWorryFree.Infrastructure --- 仓储/工具 --- │   ├── Fleck --- Fleck Web Socket 服务 --- │   │   └── FleckServer.cs │   ├── LearnWorryFree.Infrastructure.csproj │   ├── Repositories --- 仓储 --- │   │   ├── AnnouncementRepository.cs │   │   ├── ...... │   │   └── UserRepository.cs │   └── Tools --- 工具 --- │   ├── AppSettingsHelper.cs │   ├── ...... │   └── WeChatTools.cs ├── LearnWorryFree.sln -- dotNet 解决方案文件 ├── LICENSE -- 开源许可证 └── README.md -- *你在这* ``` ### 项目结构 ```mermaid flowchart LR %% 声明节点 app([Wechat mini program]) log(Logs) db1[(MySQL database)] subgraph web_server[Web server] direction TB subgraph filter[Filter] direction TB global_exception_filter[Global exception filter] log_action_filter[Log action filter] end subgraph extension[Extension] direction TB jwt_extension[JWT extension] auth_extension[Auth extension] end subgraph business[Bussiness] direction LR subgraph controller[Controller] direction TB interface_1[Interface 1] interface_2[Interface 2] interface_3[Interface 3] end subgraph service[Service] direction TB service_1[Service 1] service_2[Service 2] end subgraph repository[Repository] direction TB repository_1[Entity 1] repository_2[Entity 2] repository_3[Entity 3] end end end %% 连接节点 app -- "请求(携带 token)" ---> jwt_extension jwt_extension -- 验证失败 --> app jwt_extension -- 验证通过 --> auth_extension auth_extension -- 鉴权失败 --> app auth_extension -- 鉴权成功 --> controller controller -- 返回响应 --> app business -- 收集日志 --> log_action_filter -- 存储日志 ---> log business -- 抛出异常 --> global_exception_filter -- 返回响应 --> app interface_2 -- 调用 --> repository_1 interface_1 -- 调用 --> service_1 interface_3 -- 调用 --> service_1 & service_2 service_1 -- 调用 --> repository_1 & repository_3 service_2 -- 调用 --> repository_2 & repository_3 repository -- 增删改查 --- db1 ``` ### 实体关系图 ```mermaid erDiagram %% 声明实体 %% 弃用,Gitee 的mermaid版本太旧,不能支持渲染 PK UK FK 和描述 %% user { %% int id PK, UK %% int state "用户状态,0启用,1禁用" %% string name "用户名" %% string img_url "用户头像url" %% string salt "用户密码加盐" %% string password "用户密码" %% int role_id "角色外键" %% int student_id "学生外键" %% } %% role { %% int id %% string name "身份名" %% string intro "身份简介" %% } %% student { %% int id PK %% string sno "学号" %% string name "学生名" %% string synopsis "学生简介" %% string address "学生地址" %% string email "学生邮箱" %% string telephone "学生电话号码" %% int gender "学生性别" %% int class_schedule_id FK "班级外键" %% int user_id FK "用户外键" %% } %% teacher { %% int id PK %% string name "教师名" %% int gender "教师性别" %% int course_id FK "课程外键" %% } %% course { %% int id PK %% string course_name "课程名称" %% int credit "课程学分" %% string week_name "课程上课时间" %% int class_schedule_id FK "班级外键" %% int classroom_id FK "课室外键" %% int teacher_id FK "教师外键" %% } %% class_schedule { %% int id PK %% string clazz_name "班级名称" %% int grade_id FK "年级外键" %% } %% grade { %% int id PK %% int grader_group "年级编号(大一、大二、大三、大四)" %% string name "年级名称" %% string grade_description "年纪介绍" %% } %% classroom { %% int id PK %% string location "课室地点" %% } user { int id int state string name string img_url string salt string password int role_id int student_id } role { int id string name string intro } student { int id string sno string name string synopsis string address string email string telephone int gender int class_schedule_id int user_id } teacher { int id string name int gender int course_id } course { int id string course_name int credit string week_name int class_schedule_id int classroom_id int teacher_id } class_schedule { int id string clazz_name int grade_id } grade { int id int grader_group string name string grade_description } classroom { int id string location } %% 连接实体 user ||--|{ role: "has" user ||--|| student: "is" student }|--|| class_schedule: "are in" class_schedule ||--|{ grade: "are" teacher }|--|| course: "teach at" class_schedule ||--|{ course: "have" course ||--|{ classroom: "take place in" ``` ## 其它 [项目前端](https://gitee.com/PromiseCatch/frontend) [后端需求文档](https://gitee.com/PromiseCatch/backend/blob/master/%E5%8A%9F%E8%83%BD%E9%9C%80%E6%B1%82.md) [前端需求文档](https://gitee.com/PromiseCatch/frontend/blob/master/%E9%9C%80%E6%B1%82%E6%96%87%E6%A1%A3.md)