Appearance
LFPay 模块结构详细说明
目录结构
pay/
├── infrastructure/ # 基础设施层
│ ├── infra-common # 通用工具
│ ├── infra-security # 安全框架
│ ├── infra-mybatisplus # MyBatis Plus
│ ├── infra-redis # Redis缓存
│ ├── infra-captcha # 验证码
│ ├── infra-spring-task # 定时任务
│ └── infra-log # 日志处理
├── dao/ # 数据访问层
│ ├── system-dao # 系统DAO
│ └── app-dao # APP DAO
├── module/ # 业务模块层
│ ├── system-module # 系统业务
│ ├── system-generator # 代码生成器
│ └── app-module # APP业务(待创建)
├── interface/ # 接口启动层
│ ├── system-start # 系统服务(6666)
│ └── app-start # APP服务(8888)
├── core/ # 核心模块(预留)
├── data/ # 文档数据
└── .logs/ # 日志目录(已忽略)Infrastructure(基础设施层)
infra-common
功能: 通用工具类和基础组件
依赖: 无
提供:
- 工具类
- 常量定义
- 异常处理
- 基础配置
infra-security
功能: 安全框架集成
依赖: infra-common
提供:
- Sa-Token集成
- 权限控制
- 认证拦截器
infra-mybatisplus
功能: MyBatis Plus配置
依赖: infra-common
提供:
- MyBatis Plus 3.5.14
- 分页插件
- ID生成器
- 通用Mapper
infra-redis
功能: Redis缓存和Redisson
依赖: 无
提供:
- RedisTemplate配置
- Redisson客户端
- RedisUtils工具类
- 命名空间管理
关键类:
RedisConfig- Redis配置RedisCache- 缓存操作RedisUtils- 工具方法
infra-captcha
功能: 验证码生成
依赖: infra-common
提供:
- 图形验证码
- 验证码校验
infra-spring-task
功能: 定时任务
依赖: infra-common
提供:
- 定时任务配置
- 任务调度
infra-log
功能: 日志处理
依赖: infra-common
提供:
- 日志切面
- 操作日志记录
DAO(数据访问层)
system-dao
功能: 系统数据访问
依赖: infra-mybatisplus, infra-common
包结构:
la.lfpay.system.dao/
├── mapper/ # MyBatis Mapper接口
├── domain/
│ ├── entity/ # 实体类
│ └── dto/ # 数据传输对象
└── resources/
└── mapper/ # MyBatis XML映射提供:
- 用户管理Mapper
- 角色管理Mapper
- 菜单管理Mapper
- 部门管理Mapper
- 其他系统表Mapper
app-dao
功能: APP数据访问
依赖: infra-mybatisplus, infra-common
状态: 已创建基础结构
包结构: 同system-dao
Module(业务模块层)
system-module
功能: 系统业务逻辑
依赖: system-dao, infra-security, infra-common
包结构:
la.lfpay.system.service/
├── controller/ # 控制器
├── service/ # 业务接口
│ └── impl/ # 业务实现
└── config/ # 配置类提供:
- 用户管理
- 角色管理
- 菜单管理
- 部门管理
- 权限控制
system-generator
功能: 代码生成器
依赖: infra-mybatisplus, infra-common
包结构:
la.lfpay.generator/
├── controller/ # REST接口
├── service/ # 业务逻辑
│ └── impl/
├── domain/ # 实体类
├── mapper/ # Mapper接口
├── config/ # 配置类
├── util/ # 工具类
└── resources/
├── mapper/ # XML映射
├── vm/ # Velocity模板
└── sql/ # 初始化脚本核心类:
GenController- REST接口GenTableServiceImpl- 业务实现DatabaseMetadataService- 数据库元数据查询VelocityInitializer- 模板引擎初始化VelocityUtils- 模板工具
模板文件:
vm/java/domain.java.vm- 实体类模板vm/java/mapper.java.vm- Mapper接口模板vm/java/service.java.vm- Service接口模板vm/java/serviceImpl.java.vm- Service实现模板vm/java/controller.java.vm- Controller模板vm/xml/mapper.xml.vm- MyBatis XML模板
app-module
功能: APP业务逻辑
依赖: app-dao, infra-security, infra-common
状态: 待创建
预期包结构: 同system-module
Interface(接口启动层)
system-start
功能: 系统服务启动入口
端口: 6666
依赖: system-module, system-generator, infra-*
包结构:
la.lfpay.start/
├── SystemServiceApplication.java # 启动类
└── resources/
├── application.yml # 主配置
├── application-dev.yml # 开发环境
├── application-prod.yml # 生产环境
└── application-test.yml # 测试环境启动类配置:
java
@Slf4j
@MapperScan("la.lfpay.**.mapper")
@SpringBootApplication(scanBasePackages = "la.lfpay")
public class SystemServiceApplication {
// 启动日志输出
}测试目录:
src/test/
├── java/
│ └── la/lfpay/generator/
│ └── GeneratorTest.java # 代码生成器测试
└── resources/
└── application-test.yml # 测试配置app-start
功能: APP服务启动入口
端口: 8888
依赖: app-module(待创建), infra-*
包结构:
la.lfpay.app/
├── config/ # 配置类
│ ├── AppSecurityProperties.java # 安全配置属性
│ ├── FilterConfig.java # 过滤器配置
│ └── WebAppConfigurer.java # Web配置
├── filter/ # 过滤器
│ └── RequestBodyCachingFilter.java
├── interceptor/ # 拦截器
│ └── SignatureInterceptor.java # 签名验证
└── resources/
└── application.yml # 配置文件防重放攻击组件:
AppSecurityProperties- 配置属性RequestBodyCachingFilter- 请求体缓存SignatureInterceptor- 签名验证FilterConfig- 过滤器注册WebAppConfigurer- 拦截器注册
Core(核心模块)
状态: 预留
用途: 核心业务逻辑和领域模型
依赖关系图
┌─────────────────────────────────────────────────────────┐
│ Interface Layer │
│ ┌──────────────┐ ┌──────────────┐ │
│ │ system-start │ │ app-start │ │
│ │ (port 6666) │ │ (port 8888) │ │
│ └──────┬───────┘ └──────┬───────┘ │
└─────────┼──────────────────────────────┼────────────────┘
│ │
┌─────────┼──────────────────────────────┼────────────────┐
│ │ Module Layer │ │
│ ┌──────▼───────┐ ┌─────────────┐ ┌─▼──────────┐ │
│ │system-module │ │ system- │ │app-module │ │
│ │ │ │ generator │ │ (待创建) │ │
│ └──────┬───────┘ └─────┬───────┘ └─┬──────────┘ │
└─────────┼──────────────────┼────────────┼───────────────┘
│ │ │
┌─────────┼──────────────────┼────────────┼───────────────┐
│ │ DAO Layer│ │ │
│ ┌──────▼───────┐ │ ┌──────▼───────┐ │
│ │ system-dao │ │ │ app-dao │ │
│ └──────┬───────┘ │ └──────┬───────┘ │
└─────────┼──────────────────┼────────────┼───────────────┘
│ │ │
┌─────────┼──────────────────┼────────────┼───────────────┐
│ │ Infrastructure Layer │ │
│ ┌──────▼───────┐ ┌──────▼───────┐ ┌─▼──────────┐ │
│ │infra- │ │infra- │ │infra- │ │
│ │mybatisplus │ │common │ │redis │ │
│ └──────────────┘ └──────────────┘ └────────────┘ │
│ ┌──────────────┐ ┌──────────────┐ ┌────────────┐ │
│ │infra- │ │infra- │ │infra- │ │
│ │security │ │captcha │ │log │ │
│ └──────────────┘ └──────────────┘ └────────────┘ │
└────────────────────────────────────────────────────────┘包名规范
统一前缀
- 所有包名以
la.lfpay开头
分层规范
- DAO层:
la.lfpay.{module}.dao.* - Module层:
la.lfpay.{module}.service.* - Interface层:
la.lfpay.start.*或la.lfpay.app.* - Infrastructure层:
la.lfpay.infra.{name}.*
示例
la.lfpay.system.dao.mapper.SysUserMapper
la.lfpay.system.dao.domain.entity.SysUser
la.lfpay.system.service.controller.SysUserController
la.lfpay.system.service.service.ISysUserService
la.lfpay.generator.controller.GenController
la.lfpay.infra.redis.utils.RedisUtilsMaven坐标
GroupId
- 统一使用:
la.lfpay
ArtifactId规范
- Infrastructure:
infra-{name} - DAO:
{module}-dao - Module:
{module}-module - Interface:
{module}-start
Version
- 统一版本:
1.0.0
配置文件位置
启动模块配置
interface/system-start/src/main/resources/interface/app-start/src/main/resources/
功能模块配置
module/system-generator/src/main/resources/generator.yml- 代码生成器配置sql/- 初始化脚本
基础设施配置
- 各
infra-*模块的resources目录
编译顺序
- Infrastructure - 基础设施层
- DAO - 数据访问层
- Module - 业务模块层
- Interface - 接口启动层
命令:
bash
mvn clean install -DskipTests -T 4最后更新: 2025-11-13
维护者: lfpay.la