项目结构
介绍 ContiNew Admin 后端 Maven 多模块划分、业务分层子包约定与前端 src 目录组织,帮助你在改代码前找对位置。
ContiNew Admin 前后端同仓库。后端是 Maven 多模块工程,前端在本仓库的 continew-ui/ 目录(React 19 单页应用)。本页分别说明两边的目录组织,读完后能回答「这段代码该放哪」这类问题。
后端 Maven 模块
根 pom.xml 用 ${revision}(当前 5.0.0-SNAPSHOT)统一管理版本,flatten-maven-plugin 在打包时展开。模块间依赖自上而下:continew-server → continew-system → continew-common,插件与扩展模块独立挂载。
| 模块 | 职责 |
|---|---|
continew-server | 打包部署入口:启动类 top.continew.admin.ContiNewAdminApplication、通用 Controller(验证码、工作台)、Liquibase 脚本、全部环境配置文件。dev 端口 8000,prod 端口 18000 |
continew-system | 核心业务:auth(系统认证)+ system(部门、角色、用户、菜单、字典、文件、公告、系统配置等) |
continew-common | 公共基类、工具与配置:CRUD 基类(base)、MyBatis、接口文档、Excel、全局异常(config 下对应子包) |
continew-plugin | 可插拔插件:continew-plugin-open(能力开放 AK/SK)、continew-plugin-tenant(多租户)、continew-plugin-schedule(任务调度) |
整体目录骨架如下。
continew-admin
├─ continew-server
│ └─ src/main
│ ├─ java/top/continew/admin
│ │ ├─ config(log 操作日志、satoken 认证配置)
│ │ ├─ controller(CaptchaController、DashboardController)
│ │ ├─ job(定时任务,如 NoticePublishJob)
│ │ └─ ContiNewAdminApplication.java
│ └─ resources
│ ├─ config(application.yml、application-dev.yml、application-prod.yml)
│ ├─ db/changelog(mysql/ 与 postgresql/ 脚本、db.changelog-master.yaml)
│ ├─ templates(邮件等模板)
│ ├─ banner.txt
│ └─ logback-spring.xml
├─ continew-system
│ └─ src/main
│ ├─ java/top/continew/admin
│ │ ├─ auth(系统认证)
│ │ └─ system(系统管理)
│ └─ resources/mapper(Mapper XML)
├─ continew-plugin
│ ├─ continew-plugin-open
│ ├─ continew-plugin-tenant
│ └─ continew-plugin-schedule
├─ continew-common
│ └─ src/main/java/top/continew/admin/common
│ ├─ api(公共业务 API 接口)
│ ├─ base(controller/mapper/service/model 公共基类)
│ ├─ config(crud、doc、excel、exception、mybatis)
│ └─ context、enums、constant、model、util
└─ docker(Dockerfile、docker-compose.yml、nginx 与 redis 配置)业务分层子包
continew-system 的 auth 与 system 两个包按同一套分层约定组织,continew-plugin 下各插件也沿用。加一个业务功能时对照下表落位。
| 子包 | 放什么 |
|---|---|
controller | REST 接口,CRUD 类继承 common 的 BaseController 并用 @CrudRequestMapping 声明 |
service(含 impl) | 业务接口与实现 |
mapper | MyBatis Mapper 接口,XML 放 resources/mapper |
model.entity / model.query / model.req / model.resp | 实体、查询条件、请求参数、响应参数 |
enums / constant | 枚举与常量 |
config | Spring 配置类 |
util / validation | 工具类与参数校验 |
container | Crane4j 数据填充容器(system 包) |
handler | 登录处理器(auth 包,如 AccountLoginHandler、SocialLoginHandler) |
api | 对外公共 API 的实现,配合 common 的 top.continew.admin.common.api 接口包 |
跨模块调用走「内部 API」模式:被调方在 common 的 api 包定义接口,业务模块在自己的 api/ 子包提供实现。调用方只依赖接口,模块之间不出现循环依赖。
前端 continew-ui 目录
前端 continew-ui/ 基于 React 19 + TypeScript + Vite + Tailwind CSS 4,组件层是 shadcn/ui(base-nova 风格)。包管理器为 pnpm。路径别名 @ 指向 src(tsconfig.json 的 paths 定义,vite.config.ts 的 resolve.tsconfigPaths 生效)。项目未接入 i18n,没有 locale 目录;站点标题从后端「网站配置」接口动态获取。
continew-ui
├─ package.json # 依赖与脚本声明(pnpm install / dev / build / typecheck / lint / test)
├─ vite.config.ts # dev 代理(/api 前缀)、TanStack Router 插件、首帧主题注入脚本
├─ components.json # shadcn CLI 配置(base-nova 风格、lucide 图标、@/ 别名)
├─ tests # 单元测试(vitest,tests/*.test.ts)
└─ src
├─ components # 业务组件(data-table、entity-drawer、dept-tree-select 等)+ ui/(shadcn/ui 拷贝源码)
├─ hooks # 组合式函数(use-list-table、use-menu、use-permission、use-export 等)
├─ layouts # 布局壳(BaseLayout)、头部、侧栏、页签栏、设置面板与页面效果
├─ lib # 基础库:http(请求封装)、auth-session(会话)、route-access(路由守卫)、permission、
│ # query-client / query-keys(查询缓存)、api/(按后端模块分文件)、preferences/(外观偏好)
├─ navigation # 菜单树到侧边栏分组的转换、菜单图标解析、静态路由标题
├─ routes # TanStack 文件路由:目录即路由表,业务页 <模块>/route.tsx + -components/ 私有组件
├─ stores # zustand 仓库(auth、tabs、preferences)
├─ styles # Tailwind CSS 入口与主题变量(globals.css、theme-colors.css)
├─ scripts # 偏好/主题首帧注入脚本(theme-boot-script.ts)
├─ router.tsx # Router 实例
└─ routeTree.gen.ts # Vite 插件生成的路由树,不要手改路由由文件目录决定,菜单由后端下发:src/routes/(main)/(app)/ 下的目录与业务菜单一一对应,新页面在对应路径下建 route.tsx;菜单数据来自 GET /auth/user/route(后端已按权限过滤),菜单里配了入口而页面文件还没建时显示占位卡片。机制细节见路由与页签。
| 目录 | 页面 |
|---|---|
dashboard | 仪表盘、个人中心(dashboard/profile) |
system | 用户、角色、菜单、部门、字典、通知公告、文件、短信(sms 与 sms/log)、系统配置(config) |
monitor | 在线用户(online)、登录与操作日志(log) |
tenant | 租户管理(management)、套餐管理(package) |
schedule | 任务管理(job)、任务日志(log) |
open/app | 应用管理(AK/SK) |
(main)/auth | 登录页 |
(main)/social/callback | 第三方登录回调 |
(main)/unauthorized.tsx | 无权限页 |
相关源码
- 后端模块定义 pom.xml
- 后端仓库 continew-org/continew-admin
- 前端工程 continew-ui/(本仓库内,
src/目录)