All Projects → micyo202 → Yan

micyo202 / Yan

Licence: mit
使用Maven构建,整合Dubbo+Zookeeper+SpringMVC+Spring+MyBatis+Redis支持分布式的高效率便捷开发框架

Programming Languages

javascript
184084 projects - #8 most used programming language
java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Yan

Highdsa
2018年本科毕设项目,已更新所有开发和部署文档。基于Dubbo、SSM、Shiro、ELK、ActiveMQ、Redis等实现的一套高可用、高性能、高可扩展的分布式系统架构,实现可支持业务的基础公共服务,API使用Restful风格对外暴露。已经实现的包括:发送邮件服务、FastDFS文件存储服务、ELK实时日志查询服务、Redis缓存服务、Mybatis数据库、阿里短信推送、Goeasy消息推送、Druid监控、ActiveMQ消息队列、shiro权限认证、cas单点登录、权限配置web系统、移动端后台系统。持续更新中......
Stars: ✭ 385 (+31.4%)
Mutual labels:  dubbo, mybatis, jackson, druid, spring-mvc, maven, shiro
Eshop Soa
EShop基于Dubbo实现SOA服务化拆分,并基于RocketMQ解决了分布式事务(新版SpringBootSOASkeleton)
Stars: ✭ 65 (-77.82%)
Mutual labels:  dubbo, mybatis, druid, spring-mvc, mybatis-generator
Ruoyi Oracle
(RuoYi)官方仓库 基于SpringBoot的权限管理系统 易读易懂、界面简洁美观。 核心技术采用Spring、MyBatis、Shiro没有任何其它重度依赖。直接运行即可用
Stars: ✭ 134 (-54.27%)
Mutual labels:  mybatis, druid, shiro, bootstrap, jquery
Spring Dubbo Service
微服务 spring dubbo项目:dubbo rpc;druid数据源连接池;mybatis配置集成,多数据源;jmx监控MBean;定时任务;aop;ftp;测试;Metrics监控;参数验证;跨域处理;shiro权限控制;consul服务注册,发现;redis分布式锁;SPI服务机制;cat监控;netty服务代理;websocket;disconf;mongodb集成;rest;docker;fescar
Stars: ✭ 224 (-23.55%)
Mutual labels:  dubbo, mybatis, druid, maven, shiro
Zheng
基于Spring+SpringMVC+Mybatis分布式敏捷开发系统架构,提供整套公共微服务服务模块:集中权限管理(单点登录)、内容管理、支付中心、用户管理(支持第三方登录)、微信平台、存储系统、配置中心、日志分析、任务和通知等,支持服务治理、监控和追踪,努力为中小型企业打造全方位J2EE企业级开发解决方案。
Stars: ✭ 16,163 (+5416.38%)
Mutual labels:  dubbo, mybatis, druid, shiro, mybatis-generator
Ssm booksystem
ssm demo,ssm详细教程,SSM简明教程:简单的十步教你搭建人生第一个SSM框架[ SSM框架整合教程(spring+spring mvc+mybatis+redis+maven+idea+bootstrap) ]
Stars: ✭ 355 (+21.16%)
Mutual labels:  mybatis, spring-mvc, logback, maven, bootstrap
vacomall
☀️☀️ 基于 dubbo 实现的分布式电商平台。
Stars: ✭ 42 (-85.67%)
Mutual labels:  maven, mybatis, spring-mvc, shiro, dubbo
Roothub
使用 SSM 和 MySQL 开发的论坛系统
Stars: ✭ 131 (-55.29%)
Mutual labels:  mybatis, spring-mvc, shiro, bootstrap, jquery
Ibase4j
Spring,SpringBoot 2.0,SpringMVC,Mybatis,mybatis-plus,motan/dubbo分布式,Redis缓存,Shiro权限管理,Spring-Session单点登录,Quartz分布式集群调度,Restful服务,QQ/微信登录,App token登录,微信/支付宝支付;日期转换、数据类型转换、序列化、汉字转拼音、身份证号码验证、数字转人民币、发送短信、发送邮件、加密解密、图片处理、excel导入导出、FTP/SFTP/fastDFS上传下载、二维码、XML读写、高精度计算、系统配置工具类等等。
Stars: ✭ 1,548 (+428.33%)
Mutual labels:  dubbo, mybatis, spring-mvc, maven, shiro
Webside
基于RBAC的完全响应式权限管理系统
Stars: ✭ 19 (-93.52%)
Mutual labels:  mybatis, druid, logback, shiro, bootstrap
Ruoyi
(RuoYi)官方仓库 基于SpringBoot的权限管理系统 易读易懂、界面简洁美观。 核心技术采用Spring、MyBatis、Shiro没有任何其它重度依赖。直接运行即可用
Stars: ✭ 905 (+208.87%)
Mutual labels:  mybatis, druid, shiro, bootstrap, jquery
Jeeplatform
一款企业信息化开发基础平台,拟集成OA(办公自动化)、CMS(内容管理系统)等企业系统的通用业务功能 JeePlatform项目是一款以SpringBoot为核心框架,集ORM框架Mybatis,Web层框架SpringMVC和多种开源组件框架而成的一款通用基础平台,代码已经捐赠给开源中国社区
Stars: ✭ 1,285 (+338.57%)
Mutual labels:  dubbo, mybatis, druid, shiro, jquery
Okhelper Service
OK帮 云进销存 (SpringBoot Restful 全家桶)
Stars: ✭ 146 (-50.17%)
Mutual labels:  mybatis, druid, logback, shiro
Crown
Based on SpringBoot2, Crown builds a rapidly developed web application scaffolding.
Stars: ✭ 161 (-45.05%)
Mutual labels:  mybatis, shiro, bootstrap, jquery
IDEAPractice
Java练习 - Java基础知识,面试题,小demo,长期积累 | intellij idea + maven + tomcat
Stars: ✭ 45 (-84.64%)
Mutual labels:  maven, mybatis, spring-mvc, mybatis-generator
wislove
Java 服务端api解决方案,处理部分通用业务逻辑。包括用户中心,支付,订单,IM相关,内容管理,角色权限授权。以及分库分表的处理,RPC分布式的解决方案等。一个人慢慢做
Stars: ✭ 14 (-95.22%)
Mutual labels:  maven, mybatis, spring-mvc, dubbo
Jeesite4
Java EE 企业级快速开发平台,基于经典技术组合(Spring Boot、Spring MVC、Apache Shiro、MyBatis、Beetl、Bootstrap、AdminLTE),在线代码生成功能,包括核心模块如:组织机构、角色用户、菜单及按钮授权、数据权限、系统参数、内容管理、工作流等。采用松耦合设计;界面无刷新,一键换肤;众多账号安全设置,密码策略;在线定时任务配置;支持集群,支持SAAS;支持多数据源
Stars: ✭ 1,563 (+433.45%)
Mutual labels:  mybatis, spring-mvc, shiro, jquery
Wms
一个基于Spring MVC、Spring、MyBatis、Shiro框架的仓库管理系统Demo。A warehouse management system implement with Spring MVC, Spring Framework,MyBstis,Shiro and MySQL
Stars: ✭ 248 (-15.36%)
Mutual labels:  mybatis, spring-mvc, shiro, bootstrap
Perfect Ssm
🍇更完善的Spring+SpringMVC+Mybatis+easyUI后台管理系统(RESTful API+redis)
Stars: ✭ 606 (+106.83%)
Mutual labels:  dubbo, mybatis, spring-mvc, maven
Ssm Demo
🍌Spring+SpringMVC+Mybatis+easyUI实现简单的后台管理系统
Stars: ✭ 1,639 (+459.39%)
Mutual labels:  dubbo, mybatis, spring-mvc, maven

Yan 项目简介(Instruction)

English 中文文档

Yan

Beta Downloads Since License MIT GitHub stars GitHub forks

注:全新微服务项目lion已经逐步开发,基于SpringCloud的一整套方案,详情查看https://github.com/micyo202/lion

本项目是一整套整合 Dubbo+Zookeeper+SpringMVC+Spring+MyBatis 支持分布式的高效率便捷开发RPC框架,使开发人员更专注于业务,达到面向业务开发。
项目使用 Maven 构建,便于项目管理,可支持 Oracle、MySql 等主流数据库。
项目模块化分层明确,代码规范,便于后期维护等工作。
前端展示界面采用基于 Boostrap 实现的响应式布局,并集成了一系列的动画效果插件,整体界面简洁、美观大方并可优雅的与后台完成交互操作。
项目目标是为中小型企业打造全方位的J2EE企业级开发解决方案,提高工作效率。
该项目是yan-demo单节点项目的升级版,支持分布式

近期更新内容

  • beta 1.0.1:添加spring-session+redis技术,用于解决负载均衡下session共享问题
  • beta 1.0.0:项目整体改造,升级为RPC架构。(注:若想查看非RPC版请移步至https://gitee.com/micyo202/yan
  • beta 0.1.0:模块优化,删除不必要的模块,优化代码(模块详情参考:三、项目结构)
  • beta 0.0.5:前端添加ECharts,便于图形化展示
  • beta 0.0.4:添加JMS(ActiveMQ)消息服务(目前仅测试方法,暂无业务流转,后期逐渐完善细化)
  • beta 0.0.3:添加Solr搜索引擎服务(基本的全文检索功能,可根据实际需求情况进行二次开发,后期本人再逐渐完善)
  • beta 0.0.2:优化整体代码、添加更多注释,结构更清晰、代码更易懂
  • beta 0.0.1:将原有yan-demo项目重构,保留原有功能,模块拆分、优化项目结构

项目所需工具及版本 *

一、项目开发环境&工具(Environment&Tools)

  • MacOS Sierra / Windows 7
  • MySql 5.7
  • Redis 4.0.8
  • JDK 1.8
  • CentOS 7
  • IntelliJ IDEA 2017.2.5 / Eclipse 4.6.1
  • Navicat Premium 11.1.12
  • Maven 3.3.9
  • Jetty 9.4.6.v20170531 / Tomcat 9.0.1

二、技术选型(Technology)

1.服务端技术(Server)

名称 版本号 网址
Spring Framework 4.3.13.RELEASE http://projects.spring.io/spring-framework/
Shiro 1.4.0 http://shiro.apache.org
AspectJ 1.8.13 http://www.eclipse.org/aspectj/
MyBatis 3.4.5 http://www.mybatis.org/mybatis-3/zh/index.html
MyBatis Generator 1.3.5 http://www.mybatis.org/generator/index.html
PageHelper 5.1.2 http://git.oschina.net/free/Mybatis_PageHelper
Dubbo 2.6.0 http://dubbo.io
Solr 7.1.0 https://lucene.apache.org/solr/
ActiveMQ 5.15.2 http://activemq.apache.org
Druid 1.1.5 https://github.com/alibaba/druid
Redis 4.0.8 https://redis.io
Jackson 2.9.2 https://github.com/FasterXML/jackson
Dom4j 1.6.1 http://www.dom4j.org
Ehcache 2.6.11 http://www.ehcache.org/
Logback 1.2.3 https://logback.qos.ch
Maven 3.3.9 http://maven.apache.org/
Zookeeper 3.4.11 https://www.apache.org/dyn/closer.cgi/zookeeper/

2.前端技术(Web)

名称 版本号 网址
angular - https://angularjs.org
awesome-bootstrap-checkbox - https://github.com/flatlogic/awesome-bootstrap-checkbox
bootstrap 3.3.7 http://www.bootcss.com
bootstrap-datetimepicker - http://www.bootcss.com/p/bootstrap-datetimepicker/
bootstrap-select 1.12.4 http://silviomoreto.github.io/bootstrap-select/
bootstrap-table 1.11.1 http://bootstrap-table.wenzhixin.net.cn/zh-cn/documentation/
bootstrapvalidator 0.5.3 https://github.com/nghuuphuoc/bootstrapvalidator/
ECharts 3.8.4 http://echarts.baidu.com
font-awesome 4.7.0 http://fontawesome.io/icons/
fontIconPicker 2.0.0 https://codeb.it/fonticonpicker/
fullPage - https://alvarotrigo.com/fullPage/
jquery-confirm 3.3.0 https://github.com/craftpip/jquery-confirm
malihu-custom-scrollbar-plugin - https://github.com/videoMonkey/malihu-custom-scrollbar-plugin
material-design-iconic-font 2.2.0 https://github.com/zavoloklom/material-design-iconic-font
waves 0.7.5 https://github.com/fians/Waves
zTree_v3 3.5.26 http://www.treejs.cn/v3/main.php#_zTreeInfo
BootstrapMenu - https://mobirise.com/bootstrap-menu
device - https://github.com/matthewhudson/device.js
jquery 3.2.1 http://jquery.com
jquery-cookie - https://github.com/carhartl/jquery-cookie

三、项目结构(Construction)

yan -- 根目录
├── yan-api -- 接口模块(提供核心接口方法)
|    ├── main -- 主模块路径
|    |    ├── java -- java类路径
|    |    |    ├── com.yan.api -- 核心接口包
|    |    |    |    ├── jms -- 消息服务接口
|    |    |    |    ├── persistence -- 持久化接口
├── yan-common -- 公共模块
|    ├── main -- 主模块路径
|    |    ├── java -- java类路径
|    |    |    ├── com.yan.common -- 公共类包
|    |    |    |    ├── annotation -- 注解类
|    |    |    |    ├── aspect -- 切面类
|    |    |    |    ├── constant -- 常量定义类
|    |    |    |    ├── model -- 通用模型
|    |    |    |    ├── service -- 泛型对象服务
|    |    |    |    ├── spring -- spring扩展类
|    |    |    |    ├── support -- 基础支持类
├── yan-core -- 核心模块(提供核心方法)
|    ├── main -- 主模块路径
|    |    ├── java -- java类路径
|    |    |    ├── com.yan.core -- 核心类包
|    |    |    |    ├── annotation -- 注解类
|    |    |    |    ├── aspect -- 切面类
|    |    |    |    ├── controller -- 控制器
|    |    |    |    ├── injector -- 注入类
|    |    |    |    ├── listener -- 消息消费者监听器
|    |    |    |    ├── shiro -- 安全认证类
├── yan-dao -- 数据库访问模块(该模块主要通过 mbg 插件生成相应的模型及接口映射)
|    ├── main -- 主模块路径
|    |    ├── java -- java类路径
|    |    |    ├── com.yan.dao -- dao层包
|    |    |    |    ├── mapper -- 接口映射类
|    |    |    |    ├── model -- 数据库模型类
|    |    ├── resources -- 资源配置路径
|    |    |    ├── database -- 数据库sql文件
|    |    |    ├── mybatis -- sqlMap映射文件
|    |    |    ├── properties -- 配置文件
├── yan-plugins -- 插件模块(自定义插件)
|    ├── main -- 主模块路径
|    |    ├── java -- java类路径
|    |    |    ├── com.yan.plugins -- 插件包
|    |    |    |    ├── mybatis.generator -- mbg插件类(包含注释插件、序列化插件)
├── yan-service -- 服务模块(核心接口方法实现)
|    ├── main -- 主模块路径
|    |    ├── java -- java类路径
|    |    |    ├── com.yan.service -- 服务包
|    |    |    |    ├── jms -- 消息服务接口实现类
|    |    |    |    ├── persistence -- 持久化接口实现类
├── yan-web -- web模块
|    ├── main -- 主模块路径
|    |    ├── java -- java类路径
|    |    |    ├── com.yan.web.controller -- 业务处理控制器包
|    |    ├── resources -- 资源配置路径
|    |    |    ├── properties -- 项目配置文件
|    |    |    ├── spring -- spring的配置文件
|    |    ├── webapp -- web应用根路径
|    |    |    ├── common -- 公共路径
|    |    |    ├── resources -- 静态资源路径
|    |    |    ├── views -- 视图路径

四、项目入门(Introduction)

  1. 下载项目,并且导入到IDE开发工具中(建议使用:IntelliJ IDEA)
  2. 使用 Maven 构建项目
  3. 创建数据库并执行 yan-dao 模块中 resources/database 路径下的 yan.sql 文件,创建整个项目必要的表(如:用户表、资源表、日志记录表等...)
  4. 分别修改 yan-dao、yan-service、yan-web 模块中 resources/properties 路径下的 *.properties 配置文件(具体修改方法及对应属性解释,详见 - 五、配置说明)
  5. 完成以上步骤就可以正常部署启动服务了:
    a). 启动 zookeeper 服务,命令:bin/zkServer.sh start,端口:2181(*必要服务,不启动该服务导致项目无法正常运行)
    b). 启动 activemq 服务,命令:bin/activemq start,端口:8161 / 61616(非必要服务,若不启动该服务,则项目运行中会有jms监听器异常,但不影响整体能)
    c). 启动 solr 服务,命令:bin/solr start,端口:8983(非必要服务,若不启动该服务,则搜索引擎无法使用,但不影响整体功能)
    [以上服务具体配置及启动命令,这里我不多做阐述了,不知道的可自行百度搜索]
  6. 启动完以上基础的服务后,就可以运行项目了
    a). 首先启动 yan-service,直接运行该模块中的 com.yan.service.ServiceApp.main() 方法来启动
    b). 其次启动 yan-web ,可(使用 jetty / tomcat 均可)[详细部署过程在这里就不多做阐述了],启动成功后即可访问web应用界面。接下来进入开发阶段
  7. 根据实际业务需求,在对应的数据库中创建业务表,表命名规范:“模块名_表名” 如:SYS_RESOURCE(系统模块资源表)
  8. 修改 yan-dao 模块中 resources 路径下的 generatorConfig.xml 中的 targetPackage 包名及 tableName 表名,使用 MyBatis generator 插件生成对应的持久层模块代码(Maven 执行命令:mvn mybatis-generator:generate),具体配置请参考MyBatis GeneratorXML Configuration
  9. yan-api 模块中 src/main/java 路径下创建对应的接口
  10. yan-service 模块中 src/main/java 路径下创建对应的接口服务实现类,并在 src/main/resources/META-INF/spring 路径下的 spring-dubbo-provider.xml 配置中添加声明暴露对应服务接口
  11. yan-web 模块中 src/main/java 路径下创建对应的 controller 控制器,该控制器类命名规范以 Controller 结尾,继承 BaseController 类,编写 controller 控制器业务处理代码(具体使用参考 - 七、示例代码),并在 src/main/resources/spring/config 路径下的 spring-dubbo-customer.xml 配置中添加声明暴露对应服务接口
  12. yan-web 模块中 src/main/webapp/views 路径下创建对应的jsp页面,并编写前端页面展示代码

五、配置说明(Properties)

yan-dao 模块 resources/properties 中配置文件说明

名称(Key值) 描述
mbg.path mybatis generator 插件生成代码的路径(绝对路径)
mbg.db.username mybatis generator 插件连接数据库的用户名
mbg.db.password mybatis generator 插件连接数据库的密码
mbg.db.driverClassName mybatis generator 插件连接数据库的驱动
mbg.db.url mybatis generator 插件连接数据库的地址

yan-service 模块 resources/properties 中配置文件说明

名称(Key值) 描述
default.datasource.username 默认数据库用户名
default.datasource.password 默认数据库密码
default.datasource.driverClassName 默认数据库驱动类
default.datasource.url 默认数据库链接地址
dextend.datasource.username 扩展数据库用户名(用于多数据源切换)
dextend.datasource.password 扩展数据库密码(用于多数据源切换)
dextend.datasource.driverClassName 扩展数据库驱动类(用于多数据源切换)
dextend.datasource.url 扩展数据库链接地址(用于多数据源切换)
datasource.initialSize 初始化时建立物理连接的个数
datasource.minIdle 最小连接池数量
datasource.maxActive 最大连接池数量
datasource.maxWait 获取连接时最大等待时间,单位毫秒
datasource.timeBetweenEvictionRunsMillis 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
datasource.minEvictableIdleTimeMillis 配置一个连接在池中最小生存的时间,单位是毫秒
datasource.validationQuery 用来检测连接是否有效的sql
datasource.testWhileIdle 建议配置为true,不影响性能,并且保证安全性
datasource.testOnBorrow 申请连接时执行validationQuery检测连接是否有效,做了这个配置会降低性能。
datasource.testOnReturn 归还连接时执行validationQuery检测连接是否有效,做了这个配置会降低性能
datasource.poolPreparedStatements 是否缓存preparedStatement,也就是PSCache
datasource.maxPoolPreparedStatementPerConnectionSize 每个连接上PSCache的大小
datasource.filters 属性类型是字符串,通过别名的方式配置扩展插件,常用的插件有:监控统计用的filter:stat日志用的filter:log4j防御sql注入的filter:wall
- -
dubbo.application.name dubbo 应用服务提供者名称
dubbo.protocol.port dubbo 协议暴露服务的端口
dubbo.registry.address dubbo 使用 zookeeper 注册中心暴露服务的地址
- -
jms.brokerURL activeMQ 服务地址
jms.userName activeMQ 服务管理端用户名
jms.password activeMQ 服务管理端密码

yan-web 模块 resources/properties 中配置文件说明

名称(Key值) 描述
redis.maxIdle redis最大空闲数
redis.maxTotal 连接池的最大数据库连接数
redis.maxWaitMillis 最大建立连接等待时间
redis.minEvictableIdleTimeMillis 逐出连接的最小空闲时间 默认1800000毫秒(30分钟)
redis.numTestsPerEvictionRun 每次逐出检查时 逐出的最大数目 如果为负数就是 : 1/abs(n), 默认3
redis.timeBetweenEvictionRunsMillis 逐出扫描的时间间隔(毫秒) 如果为负数,则不运行逐出线程, 默认-1
redis.testOnBorrow 是否在从池中取出连接前进行检验,如果检验失败,则从池中去除连接并尝试取出另一个
redis.testWhileIdle 空闲时检查有效性, 默认false
redis.hostName redis 的主机名
redis.port 端口号:默认6379
redis.password 连接密码
redis.usePool 是否使用连接池
redis.maxInactiveIntervalInSeconds 设置缓存失效时间
- -
jms.brokerURL activeMQ 服务地址
jms.userName activeMQ 服务管理端用户名
jms.password activeMQ 服务管理端密码
- -
logback.name 日志文件前缀名称(一般使用项目名称,便于区分)
logback.path 日志存放路径(绝对路径)
logback.maxHistory 日志最大的历史天数
logback.db.username 日志写入数据库时连接数据库的用户名
logback.db.password 日志写入数据库时连接数据库的密码
logback.db.driverClassName 日志写入数据库时连接数据库的驱动
logback.db.url 日志写入数据库时连接数据库的url
- -
setting.upload 文件上传路径(绝对路径)
- -
solr.builder Solr搜索引擎服务地址

六、常用方法(Methods)

方法均在继承于BaseController的controller类中使用this.metodName或直接使用methodName来进行调用(注:methodName代表需要调用的方法名称,方法名称见下表)
方法名 参数 返回值 描述
getSession HttpSession 服务器会话 获取服务器会话 session 对象
setSession session 服务器会话 设置服务器会话 session 对象
getRequest HttpServletRequest 用户请求 获取用户请求 request 对象
setRequest request 用户请求 设置用户请求 request 对象
getResponse HttpServletResponse 服务器响应结果 获取服务器响应结果 response 对象
setResponse response 服务器响应结果 设置服务器响应结果 response 对象
getSessionUser TbSysUser 用户对象 获取登录成功后 session 中的存储的用户信息
- - - -
getService DelegateService 通用 Service,查看自定义 sqlMap 的代理 service 对象 获取 delegateService 对象
resultPage list 查询到的分页结果,为 Page 对象 PageModel 自定义的分页模型,T 为查询的对象 分页结果集对象
resultMsg status 状态值(可根据需求任意设置,无强制标准);msg 消息内容;res 返回的对象 MsgModel 自定义消息模型 消息返回对象
fileUpLoad request 上传方法中传递的 request 对象,并非父类中的 request 对象 List 上传文件成功后的新文件名称,以集合形式返回 文件上传方法,支持多个文件上传
fileDownLoad fileName 需要下载的文件名称 ResponseEntity<byte[]> 下载的文件,在浏览器会进行下载 文件下载方法
- - - -
isNull obj 需要进行判断的对象 boolean 为null或空返回 true,否则返回 false 判断对象是否为null,或空
obj2Str obj 需要转换的对象 String 对象的值(为null则返回"") 对象转换为 String,通常用于获取 Map 集合中的对象时使用
getUUID String 32位主键字符串 生成 uuid 主键,长度为32位,且为大写模式
base64Encoder str 需要进行编码的字符串 String 进行编码后的结果字符串 对字符串进行 base64 编码
base64Decoder str 已进行 base64 编码的编码字符串 String 解码后的原字符串 对字符串进行 base64 解码
md5 str 需要进行 md5 加密的字符串 String 加密后的结果 对字符串进行 md5 加密算法
currentDate pattern 获取系统时间的格式,如:yyyy-MM-dd HH:mm:ss String 返回格式化后的当前时间 获取系统当前时间
timeStamp2Date timestamp 需要进行转换的时间戳;pattern 转换后的格式 String 格式化后的日期 时间戳转换成日期
date2TimeStamp dateStr 需要进行转换的日期字符串;pattern 日期的格式 String 转换后的时间戳 日期转换为时间戳
readFromFile filePath 文件路径(绝对路径) String 读取的文件内容 从指定文件中读取文件内容
writeToFile content 需要写入文件中的内容 filePath 文件路径(绝对路径) 将内容写入到指定文件中(写入会覆盖文件原有内容,建议先读取,再写入,将读取的内容与需要写入的内容并在一起进行写入)
generatePath path 文件夹路径(绝对路径) 生成指定路径文件夹,先进行判断文件夹是否存在,若不存在则创建对应目录的文件夹,若存在则不进行任何操作
generateFile path 文件路径(绝对路径) 生成指定路径的文件,先进行判断文件是否存在,若不存在则进行创建文件,若存在则不进行任何操作
propertiesValue key 资源文件中的 key 值 String 读取到的 key 对应的 value 值 读取 properties 文件中的值,读取 classpath 下 /properties/config.properties 配置文件
propertiesValue resource 资源文件路径(对应 classpath 中的路径);key 资源文件中的 key 值 String 读取到的 key 对应的 value 值 读取指定路径 properties 文件中的值,会从 classpath 路径下进行查找资源文件

七、示例代码(Codes)

创建一个继承与BaseController的控制器
@Controller
public class XxxController extends BaseController {
	...
}
获取日志日志记录Logger对象
// 方法一:使用注解获取
@LogInject
private static Logger log;

// 方法二:使用工厂方法获取
private static Logger log = LoggerFactory.getLogger(XxxController.class);
获取service对象
// 获取delegateService对象
@Autowired
private DelegateService delegateService;

// 获取泛型Service对象
@Autowired
private XxxService xxxService;
分页查询后台代码
// 使用对象 service 分页查询数据
@RequestMapping("/list")
@ResponseBody
public PageModel<Xxx> list(int offset, int limit) {
	XxxExample example = new XxxExample();
   PageModel<Xxx> pageModel = xxxService.selectByExampleForOffsetPage(example, offset, limit);
   return pageModel;
}

// 使用 delegateService 自定义 sqlMap 分页查询数据
@RequestMapping("/list")
@ResponseBody
public PageModel<Xxx> list(int offset, int limit) {
	String statement = "com.yan.dao.mapper.xxx.XxxCustomMapper.getXxx";
	PageModel<Xxx> pageModel = delegateService.selectPagination(statement, offset, limit);
   return pageModel;
}

分页查询前台代码
<table id="table"><table>

$('#table').bsTable({
		url: '${pageContext.request.contextPath}/xxx/list',
		idField: 'id',
		columns: [
			{field: 'state', checkbox: true},
			{field: 'id', title: 'id', align: 'center'},
			...
			]
	});
文件上传
@RequestMapping("/upload")
public String upload(HttpServletRequest request) {
	// 调用父类的上传方法,在jsp中必须指定form为enctype="multipart/form-data"
	List<String> fileNames = this.fileUpLoad(request);
	return "success";
}
文件下载(在jsp页面使用通用的下载方法,使用restful风格)
<a href="${pageContext.request.contextPath}/文件名称/download">文件下载</a>
自定义文件下载后台方法
@RequestMapping("/download")
public ResponseEntity<byte[]> download(String fileName) {
	// 调用父类文件下载方法
	return this.fileDownLoad(fileName);
}
常用 delegateService 方法
// 使用自定义sql模板查询单个对象
Xxx xxx = delegateService.selectOne(statement);
Xxx xxx = delegateService.selectOne(statement, parameter);
		
// 使用自定义sql模板查询对象集合
List<Xxx> list = delegateService.selectList(statement);
List<Xxx> list = delegateService.selectList(statement, parameter);

// 使用自定义sql模板有范围的查询,(每次返回指定的对象条数集合)
List<Xxx> list = delegateService.selectList(statement, parameter, rowBounds);

// 使用自定义sql模板进行分页查询
PageModel<Xxx> pageModel = delegateService.selectPagination(statement, offset, limit);
PageModel<Xxx> pageModel = delegateService.selectPagination(statement, parameter, offset, limit);

// 使用自定义sql模板保存
int res = delegateService.insert(statement);
int res = delegateService.insert(statement, parameter);

// 使用自定义sql模板修改
int res = delegateService.update(statement);
int res = delegateService.update(statement, parameter);

// 使用自定义sql模板删除
int res = delegateService.delete(statement);
int res = delegateService.delete(statement, parameter);
常用对象 service 方法
// 使用对象方法根据主键查询
Xxx xxx = xxxService.selectByPrimaryKey(id);

// 使用对象方法根据 criteria 查询
List<Xxx> list = xxxService.selectByExample(example);

// 方法一:使用对象方法根据 criteria 分页查询(推荐)
PageModel<Xxx> pageModel = xxxService.selectByExampleForOffsetPage(example, offset, limit);
// 方法二:使用对象方法根据criteria分页查询
PageModel<Xxx> pageModel = xxxService.selectByExampleForStartPage(example, pageNum, pageSize);

// 使用对象方法添加
int res = xxxService.insert(record);
int res = xxxService.insertSelective(record);

// 使用对象方法根据主键修改
int res = xxxService.updateByPrimaryKey(record);
int res = xxxService.updateByPrimaryKeySelective(record);

// 使用对象方法根据 criteria 修改
int res = xxxService.updateByExample(record, example);
int res = xxxService.updateByExampleSelective(record, example);

// 使用对象方法根据主键删除
int res = xxxService.deleteByPrimaryKey(productCode);

// 使用对象方法删除根据 criteria 删除
int res = xxxService.deleteByExample(example);

更多方法使用请参考项目中的示例代码

八、效果预览(Preview)

login web mobile

九、许可证(License)

MIT License

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].