# tworice-cloud **Repository Path**: StandFast/tworice-cloud ## Basic Information - **Project Name**: tworice-cloud - **Description**: 快速构建单服务及微服务项目。 单服务构建示例项目:https://gitee.com/StandFast/tworice - **Primary Language**: Java - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 4 - **Forks**: 0 - **Created**: 2022-09-19 - **Last Updated**: 2025-09-14 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 二饭微服务开发平台 ## 简介 本系统基于Spring Cloud Alibaba、MyBatis、Vue & Element实现的后台系统,支持PBAC动态菜单&权限; 请通过[二饭快速开发框架: 基于SpringBoot+Vue的单服务开发框架 (gitee.com)](https://gitee.com/StandFast/tworice)项目使用本仓库。 ## 1、技术选型 | 技术 | 说明 | 官网 | | ----------- | -------------------- | ------------------------------------------------- | | SpringBoot | v2.4.3,容器+MVC框架 | https://spring.io/projects/spring-boot | | MyBatis | v2.1.4,ORM框架 | http://www.mybatis.org/mybatis-3/zh/index.html | | RabbitMQ | 消息队列 | https://www.rabbitmq.com/ | | Redis | NoSql数据库、缓存 | https://redis.io/ | | MySQL | 关系型数据库 | https://www.oracle.com/kr/mysql/ | | Nginx | 静态资源服务器 | https://www.nginx.com/ | | Docker | 应用容器引擎 | [https://www.docker.com](https://www.docker.com/) | | Druid | 数据库连接池 | https://github.com/alibaba/druid | | JWT | JWT登录支持 | https://github.com/jwtk/jjwt | | Lombok | 简化对象封装工具 | https://github.com/rzwitserloot/lombok | | PageHelper | MyBatis物理分页插件 | http://git.oschina.net/free/Mybatis_PageHelper | | Swagger-UI | 文档生成工具 | https://github.com/swagger-api/swagger-ui | | zXing | 谷歌二维码生成技术 | https://github.com/*zxing*/zxing | | EasyCaptcha | Java图形验证码 | https://gitee.com/ele-user/EasyCaptcha | | wangEditor | 富文本编辑器 | https://www.wangeditor.com/ | ## 2、项目结构 | 模块 | 说明 | 是否必须 | | ------------------- | ------------------------------------------ | -------- | | `tworice-framework` | 基础组件,可针对方法重写 | 是 | | `tworice-system` | 系统启动所需组件 | 是 | | `tworice-verify` | 系统身份核验基础组件 | 是 | | `tworice-gateway` | 系统网关,微服务入口 | 否 | | `tworice-generate` | 代码生成模块,根据模板引擎生成 | 否 | | `tworice-user-vue` | 管理端前端,使用Vue2开发 | 否 | ## 3、微服务系统启动顺序 | 序号 | 模块服务 | 说明 | |----| ----------------- | --------------------------------- | | 1 | `tworice-system` | 系统模块 | | 2 | `tworice-verify` | 身份核验模块,所有操作都需要 | | 3 | `tworice-gateway` | 系统网关入口 | ## 4、日志 系统日志分为`操作日志`和`登录日志`两部分,由`tworice-log`模块编码实现 ### 4.1、操作日志 操作日志由`tworice-log`模块使用AOP实现,结合Swagger文档生成注解进行日志记录。 **记录过程** ① `LogHandleAspect`会捕获所有使用了`ApiOperation`注解的控制层接口 ```java @Pointcut("@annotation(io.swagger.annotations.ApiOperation)") public void pointCut() {} ``` ② 并在前置通知中获取该请求头中的`adminID`值是否为空,为空就直接跳过,不记录日志 ③ 继续获取当前`RequestMapping`类的`Api`注解是否存在,如果不存在就直接跳过,不记录日志 ④ 继续获取当前`Mapping`方法上是否使用了`GetMapping`,如果是GetMapping就跳过,不记录日志,否则就继续向下运行 ⑤ 继续获取当前`Mapping`方法上的`ApiOperation`内容,同时对`adminID`、`Api`、`ApiOperation`内容进行日志记录 **详细记录** 如果需要记录更加详细的日志内容,需要引入`LogService`,自定义日志的输出。 ### 4.2、登录日志 用户分为两类,一类是超级管理员,另一类是系统用户。 系统不会记录超级管理员的登录日志, ## 5、身份验证 当前版本仅会对用户登录状态进行效验,由`tworice-auth`模块实现,使用`JTW`+`拦截器`实现; ### 5.1、开发模式 在配置文件中设置`tworice.dev`项为`true`,可开启开发模式,在开发模式下无需进行身份认证,在生产环境下一定要关闭此开关。 ### 5.2、自定义认证 如果需要实现自定义的身份认证、权限验证可以实现`cn.tworice.auth.service.VerifyManger`接口,实现`auth`方法,该方法返回`true`表示验证通过,反之请求被拦截。 ### 5.3、认证有效期 默认生成的Token有效期为24小时,可通过设置配置项`tworice.token-timeout`改变Token有效期,单位是毫秒。