{"id":15196869,"url":"https://github.com/micyo202/yan","last_synced_at":"2025-04-06T22:09:55.169Z","repository":{"id":27888257,"uuid":"111865459","full_name":"micyo202/yan","owner":"micyo202","description":"使用Maven构建，整合Dubbo+Zookeeper+SpringMVC+Spring+MyBatis+Redis支持分布式的高效率便捷开发框架","archived":false,"fork":false,"pushed_at":"2022-06-21T00:27:56.000Z","size":4042,"stargazers_count":295,"open_issues_count":17,"forks_count":143,"subscribers_count":18,"default_branch":"master","last_synced_at":"2025-03-30T21:07:25.893Z","etag":null,"topics":["aspectj","bootstrap","distribution","dom4j","druid","dubbo","ehcache","jackson","java","jquery","logback","maven","mybatis","mybatis-generator","mybatis-pagehelper","shiro","spring-framework","spring-mvc","yan"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/micyo202.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-11-24T01:58:38.000Z","updated_at":"2025-02-10T14:40:22.000Z","dependencies_parsed_at":"2022-09-01T23:50:32.835Z","dependency_job_id":null,"html_url":"https://github.com/micyo202/yan","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/micyo202%2Fyan","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/micyo202%2Fyan/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/micyo202%2Fyan/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/micyo202%2Fyan/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/micyo202","download_url":"https://codeload.github.com/micyo202/yan/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247557767,"owners_count":20958047,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aspectj","bootstrap","distribution","dom4j","druid","dubbo","ehcache","jackson","java","jquery","logback","maven","mybatis","mybatis-generator","mybatis-pagehelper","shiro","spring-framework","spring-mvc","yan"],"created_at":"2024-09-28T00:05:12.240Z","updated_at":"2025-04-06T22:09:55.150Z","avatar_url":"https://github.com/micyo202.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Yan 项目简介（Instruction）\n\n### [English](https://github.com/micyo202/yan/blob/master/README_EN.md) [中文文档](https://github.com/micyo202/yan/blob/master/README.md)\n\n\u003cp align=\"center\" \u003e\n  \u003cimg src=\"https://github.com/micyo202/yan/raw/master/yan-web/src/main/webapp/resources/images/logo.png\" alt=\"Yan\" title=\"Yan\"\u003e\n\u003c/p\u003e\n\n[![Beta](https://img.shields.io/badge/beta-1.0.1-brightgreen.svg)](https://github.com/micyo202/yan)\n[![Downloads](https://img.shields.io/badge/downloads-3.9MB-yellow.svg)](https://github.com/micyo202/yan/archive/master.zip)\n[![Since](https://img.shields.io/badge/since-2017-blue.svg)](https://github.com/micyo202/yan)\n[![License MIT](https://img.shields.io/badge/license-MIT-lightgrey.svg)](https://github.com/micyo202/yan/blob/master/LICENSE)\n[![GitHub stars](https://img.shields.io/github/stars/micyo202/yan.svg?style=social\u0026label=Stars)](https://github.com/micyo202/yan)\n[![GitHub forks](https://img.shields.io/github/forks/micyo202/yan.svg?style=social\u0026label=Fork)](https://github.com/micyo202/yan)\n\n### 注：全新微服务项目**lion**已经逐步开发，基于SpringCloud的一整套方案，详情查看[https://github.com/micyo202/lion](https://github.com/micyo202/lion)\n\n本项目是一整套整合 **Dubbo+Zookeeper+SpringMVC+Spring+MyBatis** 支持**分布式**的高效率便捷开发**RPC**框架，使开发人员更专注于业务，达到面向业务开发。\u003cbr\u003e\n项目使用 **Maven** 构建，便于项目管理，可支持 **Oracle、MySql** 等主流数据库。\u003cbr\u003e\n项目模块化分层明确，代码规范，便于后期维护等工作。\u003cbr\u003e\n前端展示界面采用基于 **Boostrap** 实现的响应式布局，并集成了一系列的动画效果插件，整体界面简洁、美观大方并可优雅的与后台完成交互操作。\u003cbr\u003e\n项目目标是为中小型企业打造全方位的J2EE企业级开发解决方案，提高工作效率。\u003cbr\u003e\n该项目是[yan-demo](https://github.com/micyo202/yan-demo)单节点项目的**升级版**，支持**分布式**\n\n## 近期更新内容\n* **beta 1.0.1：添加spring-session+redis技术，用于解决负载均衡下session共享问题**\n* beta 1.0.0：项目整体改造，升级为RPC架构。（注：若想查看非RPC版请移步至[https://gitee.com/micyo202/yan](https://gitee.com/micyo202/yan)）\n* beta 0.1.0：模块优化，删除不必要的模块，优化代码（模块详情参考：三、项目结构）\n* beta 0.0.5：前端添加ECharts，便于图形化展示\n* beta 0.0.4：添加JMS（ActiveMQ）消息服务（目前仅测试方法，暂无业务流转，后期逐渐完善细化）\n* beta 0.0.3：添加Solr搜索引擎服务（基本的全文检索功能，可根据实际需求情况进行二次开发，后期本人再逐渐完善）\n* beta 0.0.2：优化整体代码、添加更多注释，结构更清晰、代码更易懂\n* beta 0.0.1：将原有[yan-demo](https://github.com/micyo202/yan-demo)项目重构，保留原有功能，模块拆分、优化项目结构\n\n## 项目所需工具及版本 *\n* zookeeper-3.4.11 [http://mirror.bit.edu.cn/apache/zookeeper/zookeeper-3.4.11](http://mirror.bit.edu.cn/apache/zookeeper/zookeeper-3.4.11)\n* apache-activemq-5.15.2 [http://activemq.apache.org/activemq-5152-release.html](http://activemq.apache.org/activemq-5152-release.html)\n* solr-7.1.0 [https://mirrors.tuna.tsinghua.edu.cn/apache/lucene/solr/7.1.0](https://mirrors.tuna.tsinghua.edu.cn/apache/lucene/solr/7.1.0)\n\n## 一、项目开发环境\u0026工具（Environment\u0026Tools）\n* MacOS Sierra / Windows 7\n* MySql 5.7\n* Redis 4.0.8\n* JDK 1.8\n* CentOS 7\n* IntelliJ IDEA 2017.2.5 / Eclipse 4.6.1\n* Navicat Premium 11.1.12\n* Maven 3.3.9\n* Jetty 9.4.6.v20170531 / Tomcat 9.0.1\n\n## 二、技术选型（Technology）\n#### 1.服务端技术（Server）\n名称 | 版本号 | 网址\n--- | --- | ---\nSpring Framework | 4.3.13.RELEASE  | [http://projects.spring.io/spring-framework/](http://projects.spring.io/spring-framework/)\nShiro | 1.4.0 | [http://shiro.apache.org](http://shiro.apache.org)\nAspectJ | 1.8.13 | [http://www.eclipse.org/aspectj/](http://www.eclipse.org/aspectj/)\nMyBatis | 3.4.5 | [http://www.mybatis.org/mybatis-3/zh/index.html](http://www.mybatis.org/mybatis-3/zh/index.html)\nMyBatis Generator | 1.3.5 | [http://www.mybatis.org/generator/index.html](http://www.mybatis.org/generator/index.html)\nPageHelper | 5.1.2 | [http://git.oschina.net/free/Mybatis_PageHelper](http://git.oschina.net/free/Mybatis_PageHelper)\nDubbo | 2.6.0 | [http://dubbo.io](http://dubbo.io)\nSolr | 7.1.0 | [https://lucene.apache.org/solr/](https://lucene.apache.org/solr/)\nActiveMQ | 5.15.2 | [http://activemq.apache.org](http://activemq.apache.org)\nDruid | 1.1.5 | [https://github.com/alibaba/druid](https://github.com/alibaba/druid)\nRedis | 4.0.8 | [https://redis.io](https://redis.io)\nJackson | 2.9.2 | [https://github.com/FasterXML/jackson](https://github.com/FasterXML/jackson)\nDom4j | 1.6.1 | [http://www.dom4j.org](http://www.dom4j.org)\nEhcache | 2.6.11| [http://www.ehcache.org/](http://www.ehcache.org/)\nLogback | 1.2.3 | [https://logback.qos.ch](https://logback.qos.ch)\nMaven | 3.3.9 | [http://maven.apache.org/](http://maven.apache.org/)\nZookeeper | 3.4.11 | [https://www.apache.org/dyn/closer.cgi/zookeeper/](https://www.apache.org/dyn/closer.cgi/zookeeper/)\n#### 2.前端技术（Web）\n名称 | 版本号 | 网址\n--- | --- | ---\nangular | - | [https://angularjs.org](https://angularjs.org)\nawesome-bootstrap-checkbox | - | [https://github.com/flatlogic/awesome-bootstrap-checkbox](https://github.com/flatlogic/awesome-bootstrap-checkbox)\nbootstrap | 3.3.7 | [http://www.bootcss.com](http://www.bootcss.com)\nbootstrap-datetimepicker | - | [http://www.bootcss.com/p/bootstrap-datetimepicker/](http://www.bootcss.com/p/bootstrap-datetimepicker/)\nbootstrap-select | 1.12.4 | [http://silviomoreto.github.io/bootstrap-select/](http://silviomoreto.github.io/bootstrap-select/)\nbootstrap-table | 1.11.1 | [http://bootstrap-table.wenzhixin.net.cn/zh-cn/documentation/](http://bootstrap-table.wenzhixin.net.cn/zh-cn/documentation/)\nbootstrapvalidator | 0.5.3 | [https://github.com/nghuuphuoc/bootstrapvalidator/](https://github.com/nghuuphuoc/bootstrapvalidator/)\nECharts | 3.8.4 | [http://echarts.baidu.com](http://echarts.baidu.com)\nfont-awesome | 4.7.0 | [http://fontawesome.io/icons/](http://fontawesome.io/icons/)\nfontIconPicker | 2.0.0 | [https://codeb.it/fonticonpicker/](https://codeb.it/fonticonpicker/)\nfullPage | - | [https://alvarotrigo.com/fullPage/](https://alvarotrigo.com/fullPage/)\njquery-confirm | 3.3.0 | [https://github.com/craftpip/jquery-confirm](https://github.com/craftpip/jquery-confirm)\nmalihu-custom-scrollbar-plugin | - | [https://github.com/videoMonkey/malihu-custom-scrollbar-plugin](https://github.com/videoMonkey/malihu-custom-scrollbar-plugin)\nmaterial-design-iconic-font | 2.2.0 | [https://github.com/zavoloklom/material-design-iconic-font](https://github.com/zavoloklom/material-design-iconic-font)\nwaves | 0.7.5 | [https://github.com/fians/Waves](https://github.com/fians/Waves)\nzTree_v3 | 3.5.26 | [http://www.treejs.cn/v3/main.php#_zTreeInfo](http://www.treejs.cn/v3/main.php#_zTreeInfo)\nBootstrapMenu | - | [https://mobirise.com/bootstrap-menu](https://mobirise.com/bootstrap-menu)\ndevice | - | [https://github.com/matthewhudson/device.js](https://github.com/matthewhudson/device.js)\njquery | 3.2.1 | [http://jquery.com](http://jquery.com)\njquery-cookie | - | [https://github.com/carhartl/jquery-cookie](https://github.com/carhartl/jquery-cookie)\n\n## 三、项目结构（Construction）\n```lua\nyan -- 根目录\n├── yan-api -- 接口模块（提供核心接口方法）\n|    ├── main -- 主模块路径\n|    |    ├── java -- java类路径\n|    |    |    ├── com.yan.api -- 核心接口包\n|    |    |    |    ├── jms -- 消息服务接口\n|    |    |    |    ├── persistence -- 持久化接口\n├── yan-common -- 公共模块\n|    ├── main -- 主模块路径\n|    |    ├── java -- java类路径\n|    |    |    ├── com.yan.common -- 公共类包\n|    |    |    |    ├── annotation -- 注解类\n|    |    |    |    ├── aspect -- 切面类\n|    |    |    |    ├── constant -- 常量定义类\n|    |    |    |    ├── model -- 通用模型\n|    |    |    |    ├── service -- 泛型对象服务\n|    |    |    |    ├── spring -- spring扩展类\n|    |    |    |    ├── support -- 基础支持类\n├── yan-core -- 核心模块（提供核心方法）\n|    ├── main -- 主模块路径\n|    |    ├── java -- java类路径\n|    |    |    ├── com.yan.core -- 核心类包\n|    |    |    |    ├── annotation -- 注解类\n|    |    |    |    ├── aspect -- 切面类\n|    |    |    |    ├── controller -- 控制器\n|    |    |    |    ├── injector -- 注入类\n|    |    |    |    ├── listener -- 消息消费者监听器\n|    |    |    |    ├── shiro -- 安全认证类\n├── yan-dao -- 数据库访问模块（该模块主要通过 mbg 插件生成相应的模型及接口映射）\n|    ├── main -- 主模块路径\n|    |    ├── java -- java类路径\n|    |    |    ├── com.yan.dao -- dao层包\n|    |    |    |    ├── mapper -- 接口映射类\n|    |    |    |    ├── model -- 数据库模型类\n|    |    ├── resources -- 资源配置路径\n|    |    |    ├── database -- 数据库sql文件\n|    |    |    ├── mybatis -- sqlMap映射文件\n|    |    |    ├── properties -- 配置文件\n├── yan-plugins -- 插件模块（自定义插件）\n|    ├── main -- 主模块路径\n|    |    ├── java -- java类路径\n|    |    |    ├── com.yan.plugins -- 插件包\n|    |    |    |    ├── mybatis.generator -- mbg插件类（包含注释插件、序列化插件）\n├── yan-service -- 服务模块（核心接口方法实现）\n|    ├── main -- 主模块路径\n|    |    ├── java -- java类路径\n|    |    |    ├── com.yan.service -- 服务包\n|    |    |    |    ├── jms -- 消息服务接口实现类\n|    |    |    |    ├── persistence -- 持久化接口实现类\n├── yan-web -- web模块\n|    ├── main -- 主模块路径\n|    |    ├── java -- java类路径\n|    |    |    ├── com.yan.web.controller -- 业务处理控制器包\n|    |    ├── resources -- 资源配置路径\n|    |    |    ├── properties -- 项目配置文件\n|    |    |    ├── spring -- spring的配置文件\n|    |    ├── webapp -- web应用根路径\n|    |    |    ├── common -- 公共路径\n|    |    |    ├── resources -- 静态资源路径\n|    |    |    ├── views -- 视图路径\n```\n\n## 四、项目入门（Introduction）\n\u003e 1. 下载项目，并且导入到IDE开发工具中（建议使用：IntelliJ IDEA）\n\u003e 2. 使用 **Maven** 构建项目\n\u003e 3. 创建数据库并执行 **yan-dao** 模块中 **resources/database** 路径下的 **yan.sql** 文件，创建整个项目必要的表（如：用户表、资源表、日志记录表等...）\n\u003e 4. 分别修改 **yan-dao、yan-service、yan-web** 模块中 **resources/properties** 路径下的 ***.properties** 配置文件（具体修改方法及对应属性解释，详见 - 五、配置说明）\n\u003e 5. 完成以上步骤就可以正常部署启动服务了：\u003cbr\u003e\n\u003e    a). 启动 **zookeeper** 服务，命令：**bin/zkServer.sh start**，端口：**2181**（*必要服务，不启动该服务导致项目无法正常运行）\u003cbr\u003e\n\u003e    b). 启动 **activemq** 服务，命令：**bin/activemq start**，端口：**8161 / 61616**（非必要服务，若不启动该服务，则项目运行中会有jms监听器异常，但不影响整体能）\u003cbr\u003e\n\u003e    c). 启动 **solr** 服务，命令：**bin/solr start**，端口：**8983**（非必要服务，若不启动该服务，则搜索引擎无法使用，但不影响整体功能）\u003cbr\u003e\n\u003e *[以上服务具体配置及启动命令，这里我不多做阐述了，不知道的可自行百度搜索]*\n\u003e 6. 启动完以上基础的服务后，就可以运行项目了\u003cbr\u003e\n\u003e    a). 首先启动 **yan-service**，直接运行该模块中的 **com.yan.service.ServiceApp.main()** 方法来启动\u003cbr\u003e\n\u003e    b). 其次启动 **yan-web** ，可（使用 **jetty / tomcat** 均可）*[详细部署过程在这里就不多做阐述了]*，启动成功后即可访问web应用界面。接下来进入开发阶段\n\u003e 7. 根据实际业务需求，在对应的数据库中创建业务表，表命名规范：“模块名_表名” 如：**SYS_RESOURCE**（系统模块资源表）\n\u003e 8. 修改 **yan-dao** 模块中 **resources** 路径下的 **generatorConfig.xml** 中的 *targetPackage* 包名及 *tableName* 表名，使用 **MyBatis generator** 插件生成对应的持久层模块代码（Maven 执行命令：**mvn mybatis-generator:generate**），具体配置请参考[MyBatis GeneratorXML Configuration](http://www.mybatis.org/generator/configreference/xmlconfig.html)\n\u003e 9. 在 **yan-api** 模块中 **src/main/java** 路径下创建对应的**接口**\n\u003e 10. 在 **yan-service** 模块中 **src/main/java** 路径下创建对应的**接口服务实现类**，并在 **src/main/resources/META-INF/spring** 路径下的 **spring-dubbo-provider.xml** 配置中添加声明暴露对应服务接口\n\u003e 11. 在 **yan-web** 模块中 **src/main/java** 路径下创建对应的 **controller** 控制器，该控制器类命名规范以 **Controller** 结尾，继承 **BaseController** 类，编写 **controller** 控制器业务处理代码（具体使用参考 - 七、示例代码），并在 **src/main/resources/spring/config** 路径下的 **spring-dubbo-customer.xml** 配置中添加声明暴露对应服务接口\n\u003e 12. 在 **yan-web** 模块中 **src/main/webapp/views** 路径下创建对应的jsp页面，并编写前端页面展示代码\n\n## 五、配置说明（Properties）\n\n\u003e **yan-dao** 模块 **resources/properties** 中配置文件说明\n\n| 名称（Key值）| 描述 |\n| --- | :--- |\n| **mbg.path** | mybatis generator 插件生成代码的路径（绝对路径） |\n| **mbg.db.username** | mybatis generator 插件连接数据库的用户名 |\n| **mbg.db.password** | mybatis generator 插件连接数据库的密码 |\n| **mbg.db.driverClassName** | mybatis generator 插件连接数据库的驱动 |\n| **mbg.db.url** | mybatis generator 插件连接数据库的地址 |\n\n\u003e **yan-service** 模块 **resources/properties** 中配置文件说明\n\n| 名称（Key值）| 描述 |\n| --- | :--- |\n| **default.datasource.username** | 默认数据库用户名 |\n| **default.datasource.password** | 默认数据库密码 |\n| **default.datasource.driverClassName** | 默认数据库驱动类 |\n| **default.datasource.url** | 默认数据库链接地址 |\n| **dextend.datasource.username** | 扩展数据库用户名（用于多数据源切换） |\n| **dextend.datasource.password** | 扩展数据库密码（用于多数据源切换） |\n| **dextend.datasource.driverClassName** | 扩展数据库驱动类（用于多数据源切换） |\n| **dextend.datasource.url** | 扩展数据库链接地址（用于多数据源切换） |\n| datasource.initialSize | 初始化时建立物理连接的个数 |\n| datasource.minIdle | 最小连接池数量 |\n| datasource.maxActive | 最大连接池数量 |\n| datasource.maxWait | 获取连接时最大等待时间，单位毫秒 |\n| datasource.timeBetweenEvictionRunsMillis | 配置间隔多久才进行一次检测，检测需要关闭的空闲连接，单位是毫秒 |\n| datasource.minEvictableIdleTimeMillis | 配置一个连接在池中最小生存的时间，单位是毫秒 |\n| datasource.validationQuery | 用来检测连接是否有效的sql |\n| datasource.testWhileIdle | 建议配置为true，不影响性能，并且保证安全性 |\n| datasource.testOnBorrow | 申请连接时执行validationQuery检测连接是否有效，做了这个配置会降低性能。 |\n| datasource.testOnReturn | 归还连接时执行validationQuery检测连接是否有效，做了这个配置会降低性能 |\n| datasource.poolPreparedStatements | 是否缓存preparedStatement，也就是PSCache |\n| datasource.maxPoolPreparedStatementPerConnectionSize | 每个连接上PSCache的大小 |\n| datasource.filters | 属性类型是字符串，通过别名的方式配置扩展插件，常用的插件有：监控统计用的filter:stat日志用的filter:log4j防御sql注入的filter:wall |\n|- |- |\n| dubbo.application.name | dubbo 应用服务提供者名称 |\n| **dubbo.protocol.port** | dubbo 协议暴露服务的端口 |\n| **dubbo.registry.address** | dubbo 使用 zookeeper 注册中心暴露服务的地址 |\n|- |- |\n| **jms.brokerURL** | activeMQ 服务地址 |\n| **jms.userName** | activeMQ 服务管理端用户名 |\n| **jms.password** | activeMQ 服务管理端密码 |\n\n\u003e **yan-web** 模块 **resources/properties** 中配置文件说明\n\n| 名称（Key值）| 描述 |\n| --- | :--- |\n| redis.maxIdle | redis最大空闲数 |\n| redis.maxTotal | 连接池的最大数据库连接数 |\n| redis.maxWaitMillis | 最大建立连接等待时间 |\n| redis.minEvictableIdleTimeMillis | 逐出连接的最小空闲时间 默认1800000毫秒(30分钟) |\n| redis.numTestsPerEvictionRun | 每次逐出检查时 逐出的最大数目 如果为负数就是 : 1/abs(n), 默认3 |\n| redis.timeBetweenEvictionRunsMillis | 逐出扫描的时间间隔(毫秒) 如果为负数,则不运行逐出线程, 默认-1 |\n| redis.testOnBorrow | 是否在从池中取出连接前进行检验,如果检验失败,则从池中去除连接并尝试取出另一个  |\n| redis.testWhileIdle | 空闲时检查有效性, 默认false  |\n| **redis.hostName** | redis 的主机名 |\n| **redis.port** | 端口号：默认6379 |\n| **redis.password** | 连接密码 |\n| redis.usePool | 是否使用连接池 |\n| redis.maxInactiveIntervalInSeconds | 设置缓存失效时间 |\n|- |- |\n| **jms.brokerURL** | activeMQ 服务地址 |\n| **jms.userName** | activeMQ 服务管理端用户名 |\n| **jms.password** | activeMQ 服务管理端密码 |\n|- |- |\n| logback.name | 日志文件前缀名称（一般使用项目名称，便于区分） |\n| **logback.path** | 日志存放路径（绝对路径） |\n| logback.maxHistory | 日志最大的历史天数 |\n| **logback.db.username** | 日志写入数据库时连接数据库的用户名 |\n| **logback.db.password** | 日志写入数据库时连接数据库的密码 |\n| **logback.db.driverClassName** | 日志写入数据库时连接数据库的驱动 |\n| **logback.db.url** | 日志写入数据库时连接数据库的url |\n|- |- |\n| **setting.upload** | 文件上传路径（绝对路径） |\n|- |- |\n| **solr.builder** | Solr搜索引擎服务地址 |\n\n## 六、常用方法（Methods）\n##### *方法均在继承于BaseController的controller类中使用this.metodName或直接使用methodName来进行调用（注：methodName代表需要调用的方法名称，方法名称见下表）*\n\n| 方法名 | 参数 | 返回值 | 描述 |\n| --- | :--- | :--- | :--- |\n| getSession | 无 | HttpSession 服务器会话 | 获取服务器会话 session 对象 |\n| setSession | session 服务器会话 | 无 | 设置服务器会话 session 对象 |\n| getRequest | 无 | HttpServletRequest 用户请求 | 获取用户请求 request 对象 |\n| setRequest | request 用户请求 | 无 | 设置用户请求 request 对象 |\n| getResponse | 无 | HttpServletResponse 服务器响应结果 | 获取服务器响应结果 response 对象 |\n| setResponse | response 服务器响应结果 | 无 | 设置服务器响应结果 response 对象 |\n| **getSessionUser** | 无 | TbSysUser 用户对象 | 获取登录成功后 session 中的存储的用户信息 |\n|- |- |- |- |\n| **getService** | 无 | DelegateService 通用 Service，查看自定义 sqlMap 的代理 service 对象 | 获取 delegateService 对象 |\n| **resultPage** | list 查询到的分页结果，为 Page 对象 | PageModel\u003cT\u003e 自定义的分页模型，T 为查询的对象 | 分页结果集对象 |\n| **resultMsg** | status 状态值（可根据需求任意设置，无强制标准）；msg 消息内容；res 返回的对象 | MsgModel 自定义消息模型 | 消息返回对象 |\n| **fileUpLoad** | request 上传方法中传递的 request 对象，并非父类中的 request 对象 | List\u003cString\u003e 上传文件成功后的新文件名称，以集合形式返回 | 文件上传方法，支持多个文件上传 |\n| **fileDownLoad** | fileName 需要下载的文件名称 | ResponseEntity\u003cbyte[]\u003e 下载的文件，在浏览器会进行下载 | 文件下载方法 |\n|- |- |- |- |\n| **isNull** | obj 需要进行判断的对象 | boolean 为null或空返回 true，否则返回 false | 判断对象是否为null，或空 |\n| **obj2Str** | obj 需要转换的对象 | String 对象的值（为null则返回\"\"） | 对象转换为 String，通常用于获取 Map 集合中的对象时使用 |\n| **getUUID** | 无 | String 32位主键字符串 | 生成 uuid 主键，长度为32位，且为大写模式 |\n| base64Encoder | str 需要进行编码的字符串 | String 进行编码后的结果字符串 | 对字符串进行 base64 编码 |\n| base64Decoder | str 已进行 base64 编码的编码字符串 | String 解码后的原字符串 | 对字符串进行 base64 解码 |\n| md5 | str 需要进行 md5 加密的字符串 | String 加密后的结果 | 对字符串进行 md5 加密算法 |\n| currentDate | pattern 获取系统时间的格式，如：yyyy-MM-dd HH:mm:ss | String 返回格式化后的当前时间 | 获取系统当前时间 |\n| timeStamp2Date | timestamp 需要进行转换的时间戳；pattern 转换后的格式 | String 格式化后的日期 | 时间戳转换成日期 |\n| date2TimeStamp | dateStr 需要进行转换的日期字符串；pattern 日期的格式 | String 转换后的时间戳 | 日期转换为时间戳 |\n| readFromFile | filePath 文件路径（绝对路径） | String 读取的文件内容 | 从指定文件中读取文件内容 |\n| writeToFile | content 需要写入文件中的内容 | filePath 文件路径（绝对路径） | 将内容写入到指定文件中（写入会覆盖文件原有内容，建议先读取，再写入，将读取的内容与需要写入的内容并在一起进行写入） |\n| generatePath | path 文件夹路径（绝对路径） | 无 | 生成指定路径文件夹，先进行判断文件夹是否存在，若不存在则创建对应目录的文件夹，若存在则不进行任何操作 |\n| generateFile | path 文件路径（绝对路径） | 无 | 生成指定路径的文件，先进行判断文件是否存在，若不存在则进行创建文件，若存在则不进行任何操作 |\n| propertiesValue | key 资源文件中的 key 值 | String 读取到的 key 对应的 value 值 | 读取 properties 文件中的值，读取 classpath 下 /properties/config.properties 配置文件 |\n| propertiesValue | resource 资源文件路径（对应 classpath 中的路径）；key 资源文件中的 key 值 | String 读取到的 key 对应的 value 值 | 读取指定路径 properties 文件中的值，会从 classpath 路径下进行查找资源文件 |\n\n## 七、示例代码（Codes）\n##### 创建一个继承与BaseController的控制器\n```java\n@Controller\npublic class XxxController extends BaseController {\n\t...\n}\n```\n##### 获取日志日志记录Logger对象\n\n```java\n// 方法一：使用注解获取\n@LogInject\nprivate static Logger log;\n\n// 方法二：使用工厂方法获取\nprivate static Logger log = LoggerFactory.getLogger(XxxController.class);\n```\n\n##### 获取service对象\n\n```java\n// 获取delegateService对象\n@Autowired\nprivate DelegateService delegateService;\n\n// 获取泛型Service对象\n@Autowired\nprivate XxxService xxxService;\n```\n\n##### 分页查询后台代码\n\n```java\n// 使用对象 service 分页查询数据\n@RequestMapping(\"/list\")\n@ResponseBody\npublic PageModel\u003cXxx\u003e list(int offset, int limit) {\n\tXxxExample example = new XxxExample();\n   PageModel\u003cXxx\u003e pageModel = xxxService.selectByExampleForOffsetPage(example, offset, limit);\n   return pageModel;\n}\n\n// 使用 delegateService 自定义 sqlMap 分页查询数据\n@RequestMapping(\"/list\")\n@ResponseBody\npublic PageModel\u003cXxx\u003e list(int offset, int limit) {\n\tString statement = \"com.yan.dao.mapper.xxx.XxxCustomMapper.getXxx\";\n\tPageModel\u003cXxx\u003e pageModel = delegateService.selectPagination(statement, offset, limit);\n   return pageModel;\n}\n\n```\n\n##### 分页查询前台代码\n\n```javascript\n\u003ctable id=\"table\"\u003e\u003ctable\u003e\n\n$('#table').bsTable({\n\t\turl: '${pageContext.request.contextPath}/xxx/list',\n\t\tidField: 'id',\n\t\tcolumns: [\n\t\t\t{field: 'state', checkbox: true},\n\t\t\t{field: 'id', title: 'id', align: 'center'},\n\t\t\t...\n\t\t\t]\n\t});\n```\n\n##### 文件上传\n\n```java\n@RequestMapping(\"/upload\")\npublic String upload(HttpServletRequest request) {\n\t// 调用父类的上传方法，在jsp中必须指定form为enctype=\"multipart/form-data\"\n\tList\u003cString\u003e fileNames = this.fileUpLoad(request);\n\treturn \"success\";\n}\n```\n\n##### 文件下载（在jsp页面使用通用的下载方法，使用restful风格）\n\n```html\n\u003ca href=\"${pageContext.request.contextPath}/文件名称/download\"\u003e文件下载\u003c/a\u003e\n```\n\n##### 自定义文件下载后台方法\n\n```java\n@RequestMapping(\"/download\")\npublic ResponseEntity\u003cbyte[]\u003e download(String fileName) {\n\t// 调用父类文件下载方法\n\treturn this.fileDownLoad(fileName);\n}\n```\n\n##### 常用 delegateService 方法\n\n```java\n// 使用自定义sql模板查询单个对象\nXxx xxx = delegateService.selectOne(statement);\nXxx xxx = delegateService.selectOne(statement, parameter);\n\t\t\n// 使用自定义sql模板查询对象集合\nList\u003cXxx\u003e list = delegateService.selectList(statement);\nList\u003cXxx\u003e list = delegateService.selectList(statement, parameter);\n\n// 使用自定义sql模板有范围的查询，（每次返回指定的对象条数集合）\nList\u003cXxx\u003e list = delegateService.selectList(statement, parameter, rowBounds);\n\n// 使用自定义sql模板进行分页查询\nPageModel\u003cXxx\u003e pageModel = delegateService.selectPagination(statement, offset, limit);\nPageModel\u003cXxx\u003e pageModel = delegateService.selectPagination(statement, parameter, offset, limit);\n\n// 使用自定义sql模板保存\nint res = delegateService.insert(statement);\nint res = delegateService.insert(statement, parameter);\n\n// 使用自定义sql模板修改\nint res = delegateService.update(statement);\nint res = delegateService.update(statement, parameter);\n\n// 使用自定义sql模板删除\nint res = delegateService.delete(statement);\nint res = delegateService.delete(statement, parameter);\n```\n\n##### 常用对象 service 方法\n\n```java\n// 使用对象方法根据主键查询\nXxx xxx = xxxService.selectByPrimaryKey(id);\n\n// 使用对象方法根据 criteria 查询\nList\u003cXxx\u003e list = xxxService.selectByExample(example);\n\n// 方法一：使用对象方法根据 criteria 分页查询（推荐）\nPageModel\u003cXxx\u003e pageModel = xxxService.selectByExampleForOffsetPage(example, offset, limit);\n// 方法二：使用对象方法根据criteria分页查询\nPageModel\u003cXxx\u003e pageModel = xxxService.selectByExampleForStartPage(example, pageNum, pageSize);\n\n// 使用对象方法添加\nint res = xxxService.insert(record);\nint res = xxxService.insertSelective(record);\n\n// 使用对象方法根据主键修改\nint res = xxxService.updateByPrimaryKey(record);\nint res = xxxService.updateByPrimaryKeySelective(record);\n\n// 使用对象方法根据 criteria 修改\nint res = xxxService.updateByExample(record, example);\nint res = xxxService.updateByExampleSelective(record, example);\n\n// 使用对象方法根据主键删除\nint res = xxxService.deleteByPrimaryKey(productCode);\n\n// 使用对象方法删除根据 criteria 删除\nint res = xxxService.deleteByExample(example);\n```\n\n*更多方法使用请参考项目中的示例代码*\n\n## 八、效果预览（Preview）\n\u003cimg src=\"https://github.com/micyo202/yan/raw/master/yan-web/src/main/webapp/resources/images/login_preview.png\" alt=\"login\" title=\"login\"\u003e\n\u003cimg src=\"https://github.com/micyo202/yan/raw/master/yan-web/src/main/webapp/resources/images/web_preview.png\" alt=\"web\" title=\"web\"\u003e\n\u003cimg src=\"https://github.com/micyo202/yan/raw/master/yan-web/src/main/webapp/resources/images/mobile_preview.png\" alt=\"mobile\" title=\"mobile\"\u003e\n\n## 九、许可证（License）\n[MIT License](https://github.com/micyo202/yan/blob/master/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicyo202%2Fyan","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmicyo202%2Fyan","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicyo202%2Fyan/lists"}