开箱即用的智慧城市一网统管 AI 平台——项目目录结构及前端结构(7-9)

七、项目目录结构

后端采用模块化的架构,按照功能拆分成多个 Maven Module,提升开发与研发的效率,带来更好的可维护性。

一共有类 Maven Module:

Maven Module 作用
yudao-dependencies Maven 依赖版本管理
yudao-framework Java 框架拓展
gc-module-xxx` XXX 功能的 Module 模块
yudao-server 管理后台 + 用户 App 的服务端

1. yudao-dependencies

该模块是一个 Maven Bom,只有一个 pom.xml(opens new window)文件,定义项目中所有 Maven 依赖的版本号,解决依赖冲突问题。

详细的解释,可见 《微服务中使用 Maven BOM 来管理你的版本依赖 》 (opens new window)文章。

从定位上来说,它和 Spring Boot 的 spring-boot-starter-parent(opens new window)和 Spring Cloud 的 spring-cloud-dependencies(opens new window)是一致的。

虽然说,直接在根目录 pom.xml(opens new window)管理依赖版本会更加方便,也符合绝大多数程序员的认知。但是要额外考虑一个场景,如果每个 yudao-module-xxx 模块都维护在一个独立的 Git 仓库,那么 yudao-dependencies 就可以在多个 yudao-module-xxx 模块下复用。

2. yudao-framework

该模块是 yudao-cloud 项目的框架封装,其下的每个 Maven Module 都是一个组件,分成两种类型:

① 技术组件:技术相关的组件封装,例如说 MyBatis、Redis 等等。

Maven Module 作用
yudao-common 定义基础 pojo 类、枚举、工具类等
yudao-spring-boot-starter-web Web 封装,提供全局异常、访问日志等
yudao-spring-boot-starter-websocket WebSocket 封装,提供 Token 认证、WebSocket 集群广播、Message 监听
yudao-spring-boot-starter-security 认证授权,基于 Spring Security 实现
yudao-spring-boot-starter-mybatis 数据库操作,基于 MyBatis Plus 实现
yudao-spring-boot-starter-redis 缓存操作,基于 Spring Data Redis + Redisson 实现
yudao-spring-boot-starter-mq 消息队列,基于 Redis 实现,支持集群消费和广播消费
yudao-spring-boot-starter-job 定时任务,基于 Quartz 实现,支持集群模式
yudao-spring-boot-starter-protection 服务保障,提供幂等、分布式锁、限流、熔断等功能
yudao-spring-boot-starter-excel Excel 导入导出,基于 EasyExcel 实现
yudao-spring-boot-starter-monitor 服务监控,提供链路追踪、日志服务、指标收集等功能
yudao-spring-boot-starter-test 单元测试,基于 Junit + Mockito 实现
yudao-spring-boot-starter-file 【已合并】 文件客户端,支持将文件存储到 S3(MinIO、阿里云、腾讯云、七牛云)、本地、FTP、SFTP、数据库等
yudao-spring-boot-starter-captcha 【已合并】 验证码 Captcha,提供滑块验证码
yudao-spring-boot-starter-flowable 【已合并】 工作流,基于 Flowable 实现

友情提示:

  • yudao-spring-boot-starter-file

    组件:自 2.0.1 版本,合并到 yudao-module-infra-server 模块的 framework/file 包下,一方面减少 starter 提升编译速度,一方面只有 infra 模块使用到

  • yudao-spring-boot-starter-captcha

    组件:自 2.0.1 版本,合并到 yudao-module-system-server 模块的 framework/captcha 包下,一方面减少 starter 提升编译速度,一方面只有 system 模块使用到

  • yudao-spring-boot-starter-flowable

    组件:自 2.0.1 版本,合并到 yudao-module-bpm-server 模块的 framework/flowable 包下,一方面减少 starter 提升编译速度,一方面只有 bpm 模块使用到

② 业务组件:业务相关的组件封装,例如说数据字典、操作日志等等。如果是业务组件,名字会包含 biz 关键字。

Maven Module 作用
yudao-spring-boot-starter-biz-tenant SaaS 多租户
yudao-spring-boot-starter-biz-data-permission 数据权限
yudao-spring-boot-starter-biz-operatelog 【已合并】 操作日志
yudao-spring-boot-starter-biz-pay 【已合并】 支付客户端,对接微信支付、支付宝等支付平台
yudao-spring-boot-starter-biz-ip 地区 & IP 库

友情提示:

  • yudao-spring-boot-starter-biz-operatelog

    组件:自 2.1.0 版本,合并到 yudao-spring-boot-starter-security 组件的 operatelog 包下,主要减少 starter 提升编译速度

  • yudao-spring-boot-starter-biz-pay

    组件:自 2.5.1 版本,合并到 yudao-module-pay 模块的 framework/pay 包下,因为只有它会使用到,更加聚焦收敛

每个组件,包含两部分:

  1. core

    包:组件的核心封装,拓展相关的功能。

  2. config

    包:组件的 Spring Boot 自动配置。

3.1 整体结构

每个模块包含两个 Maven Module,分别是:

Maven Module 作用
yudao-module-xxx-api 提供给其它模块的 API 定义
yudao-module-xxx-server 模块的功能的具体实现(服务提供者)

总结来说,每个模块采用三层 架构 + 非严格分层,如下图所示:

3.2 Controller 包
所在包 作用 示例
controller.admin Controller 类 提供给管理后台的 RESTful API,默认以admin-api/ 作为前缀。 例如 admin-api/system/auth/login 登录接口 AuthController
controller.admin VO 类 Admin Controller 接口的入参 ReqVO、出参 RespVO AuthLoginReqVO、AuthLoginRespVO
controller.app Controller 类,以 App 为前缀 提供给用户 App 的 RESTful API,默认以app-api/ 作为前缀。 例如 app-api/member/auth/login 登录接口 AppAuthController
controller.app VO 类,以 App 为前缀 App Controller 接口的入参 ReqVO、出参 RespVO AppAuthLoginReqVO、AppAuthLoginRespVO
controller .http 文件 IDEA Http Client 插件 (opens new window),模拟请求 RESTful 接口 AuthController.http
3.3 Service 包
所在包 作用 示例
service Service 接口 业务逻辑的接口定义 AdminUserService
service ServiceImpl 类 业务逻辑的实现类 AdminUserServiceImpl
3.4 DAL 包
所在包 作用 示例
dal - Data Access Layer,数据访问层
dal.dataobject DO 类 Data Object,映射数据库表、或者 Redis 对象 AdminUserDO
dal.mysql Mapper 接口 数据库的操作 AdminUserMapper
dal.redis RedisDAO 类 Redis 的操作 OAuth2AccessTokenRedisDAO
3.5 API 包
所在包 作用 示例
api Api 接口 提供给其它模块的 API 接口 AdminUserApi
api ApiImpl 类 提供给其它模块的 API 实现类 AdminUserApiImpl
api DTO 类 Api 接口的入参 ReqDTO、出参 RespDTO AdminUserRespDTO、SocialUserBindReqDTO
3.6 MQ 包
所在包 作用 示例
mq - Message Queue,消息队列
mq.message Message 类 发送和消费的消息 SmsSendMessage
mq.producer Producer 类 消息的生产者 SmsProducer
mq.consumer Consumer 类 消息的消费者 SmsSendConsumer
3.7 Job 包
所在包 作用 示例
job Job 类 定时任务 DemoJob
3.8 Enum 包
所在包 作用 示例
enums Enum 类 字段的枚举 SocialTypeEnum
enums DictTypeConstants 类 数据字典的枚举 DictTypeConstants
enums ErrorCodeConstants 类 错误码的枚举 ErrorCodeConstants
3.9 其它
所在包 作用 示例
convert Convert 接口 DTO / VO / DO 等对象之间的转换器 UserConvert
framework - 模块自身的框架封装 YudaoCaptchaConfiguration

👾 前端结构

复制代码
.
├── .github # github workflows 相关
├── .husky # husky 配置
├── .vscode # vscode 配置
├── mock # 自定义 mock 数据及配置
├── public # 静态资源
├── src # 项目代码
│   ├── api # api接口管理
│   ├── assets # 静态资源
│   ├── components # 公用组件
│   ├── hooks # 常用hooks
│   ├── layout # 布局组件
│   ├── locales # 语言文件
│   ├── plugins # 外部插件
│   ├── router # 路由配置
│   ├── store # 状态管理
│   ├── styles # 全局样式
│   ├── utils # 全局工具类
│   ├── views # 路由页面
│   ├── App.vue # 入口vue文件
│   ├── main.ts # 主入口文件
│   └── permission.ts # 路由拦截
├── types # 全局类型
├── .env.base # 本地开发环境 环境变量配置
├── .env.dev # 打包到开发环境 环境变量配置
├── .env.gitee # 针对 gitee 的环境变量 可忽略
├── .env.pro # 打包到生产环境 环境变量配置
├── .env.test # 打包到测试环境 环境变量配置
├── .eslintignore # eslint 跳过检测配置
├── .eslintrc.js # eslint 配置
├── .gitignore # git 跳过配置
├── .prettierignore # prettier 跳过检测配置
├── .stylelintignore # stylelint 跳过检测配置
├── .versionrc 自动生成版本号及更新记录配置
├── CHANGELOG.md # 更新记录
├── commitlint.config.js # git commit 提交规范配置
├── index.html # 入口页面
├── package.json
├── .postcssrc.js # postcss 配置
├── prettier.config.js # prettier 配置
├── README.md # 英文 README
├── README.zh-CN.md # 中文 README
├── stylelint.config.js # stylelint 配置
├── tsconfig.json # typescript 配置
├── vite.config.ts # vite 配置
└── windi.config.ts # windicss 配置

八、贡献说明

  1. 分支管理:
  • main

    :稳定版本分支,仅合并 release 分支;

  • develop

    :开发分支,日常开发提交;

  • feature/xxx

    :功能分支(如feature/urban-noise-mon);

  1. 提交规范
  • 格式:type(scope): description,如feat(water): 新增河湖水质监测功能

  • 类型:feat(新功能)、fix(修复)、docs(文档)、refactor(重构);

  1. PR 流程:
  • feature分支提交 PR 到develop

  • 需 2 名开发人员 Code Review 通过;

  • 自动化测试(单元测试 + 接口测试)通过后合并。

九、许可证

本项目开源版本采用Apache License 2.0,允许商业使用,但需保留版权声明。

相关推荐
工业机器视觉设计和实现1 小时前
一个极简cnn推导
人工智能
水木姚姚1 小时前
PyTorch在Microsft windows 11下的使用
人工智能·pytorch·windows
多多1531 小时前
基于大模型的文档自动化测试用户提交文件进行文档测试
前端
张风捷特烈1 小时前
Flutter TolyUI 框架#11 | 标签 tolyui_tag
前端·flutter·ui kit
Mintopia1 小时前
🧠 AIGC技术人才缺口:Web行业的技能培养与技术传承
人工智能·aigc·trae
shayudiandian1 小时前
用FastAPI部署深度学习模型
人工智能·深度学习·fastapi
Yan-英杰1 小时前
openEuler 数据库性能深度评测:PostgreSQL 全方位压测
网络·人工智能·网络协议·tcp/ip·http
梵得儿SHI1 小时前
Vue 核心语法深度解析:生命周期与响应式之计算属性(computed)与侦听器(watch/watchEffect)
前端·javascript·vue.js·计算属性·侦听器·缓存机制·数据派生
anuoua1 小时前
歼20居然是个框架-基于 Signals 信号的前端框架设计
前端·javascript·前端框架