1 Star 1 Fork 0

刀脊 / easfr5

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
Apache-2.0

Easfr5

一、介绍

  • Easfr是一套以快速、规范开发为目的的开源框架,它把security、mysql、redis通过后台文件自动生成,有效的结合起来。

1.1、为什么开发easfr

  • 2010下半年,我开始在思睿鸿奇上班,发现这里要开发各种小项目,需要开发速度快、运行速度也要快;
  • 当时springMVC还没有出,正在流行用spring + struts(2),因为我之前用过一段时间.net,就明显发现struts开发的网站,访问速度上要慢上个好几拍;
  • 为了不忍受struts的xml配置和迟钝,我就利用Serverlet,实现了访问路径与java类方法的动态绑定,其实与springMVC的实现方式很像了;
  • 目前的easfr已经是第5代了,把重心从解决访问问题上,转移到了安全认证、快速开发和规范代码方面了。

1.2、名字的含义

当年也没写设计文档,只在年终总结报告中提过,已经找不到最原始的说明了
  • expansile (可)增大的:因为是从Serverlet扩展而来,可以处理当时全部的业务需求,所以我最为看重这点;
  • active 积极的:当时写了简单的代码生成方法,大大提高了开发速度;
  • small 小的:第一版核心就是个反射类,再加上几个工具类,真的很小巧;
  • facile 容易的:就是把访问连接分成:类名_方法名_参数3部分,不用xml配置,会写java就会用;
  • rapid 迅速的:感觉真的比struts的过滤驱动方式快多了。

1.3、适用用场景

  • 后台管理平台;
  • 需要快速定制开发的小网站。

1.4、存在的问题

  • 涉及运维的技术体系暂时被去掉了(pinpoin、sentinel、els);
  • 没有搭建起完整的集群实例,无法预知此场景下可能存在那些问题;
  • 微服务内部可实现负载均衡,外部的负载均衡由谁来控制,还没有实例(暂定nginx);
  • 对于高可用情况下,如何实现升级、故障解除,还没有具体的操作实例和具体的实施方案;
  • 字段配置文件是json格式的,且每个版本号生成一个文件,使得表字段更新时,设置配置的工作量较大;
  • 没有消息队列的应用实例,对此涉及的技术体系也是空白;
  • vue打包时,需要把环境变量参数设置到build命令的环境变量中,而设在docker的environment中,会出现读取不到的问题。

1.5、功能特色

1.5.1、可根据已有mysql数据库,进行后台代码自动生成

  • 可根据此表的所有字段,自动生成数据库表版本号,此版本号是redis缓存key的一部分,解决升级后缓存反序列化问题;
  • 根据数据库表版本号,生成字段配置文件,可对视图、数据验证、映射方法(字典对应值)进行详细的二次生成设置;
  • 生成的各部分后台文件,都分为基本和扩展两类,其中基本类型的文件,每次生成都会被覆盖,所以自定义信息需要放到扩展文件或aop中;
  • redis缓存存储内容都是json格式,反序列化安全可靠;
  • redis缓存已实现读取自动延期功能,减少数据读取频率,可在缓存key中增加特定标识,实现不自动延期控制;
  • 根据单一使用性原则,会自动生成实体类的分支,条件类;
  • 根据主键类型,会自动选择使用int或long雪花算法主键生成器。
  • int雪花算法:适用于不考虑集群环境、每30秒最多生成63个主键的情况(可用至2051年)
  • long雪花算法:适用于集群环境(需要GROUP_WORKER_NUM环境变量参数,默认值1.1)、每毫秒最多生成4095个主键的情况(可用至2089年)

1.5.2、自定义了oauth2的jwt认证方式

  • 图片验证码认证:用户名和密码错误3次,必需输入图片验证码;
  • 短信验证码认证:向手机号发送短信验证码(目前没有连接短信接口,只是在后台打印了短信验证码),实现登录;
  • 微信小程序认证:通过绑定小程序openid(或开放平台的unionid),实现登录(如果后绑定开放平台,目前没有实现把unionid和原openid的账号绑到一起的功能);
  • 微信小程序扫码认证:通过微信直接扫码,实现网站登录(微信的H5页面中,识别二维码的方式还没测试);
  • 微信开放平台认证:通过微信开放平台,实现网站扫码登录(只支持摄像头扫码形式);
  • QQ互联认证:通过后台直接调QQ互联接口,实现网站登录(可支持H5页面),就是取openid需要多1个步骤,导致略慢!

二、架构

2.1、架构图

Image text

2.2、核心依赖

名称 版本
Spring Boot 2.3.9.RELEASE
Spring Cloud Hoxton.SR9
Spring Cloud Alibaba 2.2.5.RELEASE
Spring Security OAuth2 2.2.4.RELEASE
Mybatis Plus 3.4.1
hutool 5.5.8
swagger2 3.0.0

2.3、模块说明

easfr-paren(根模块)

┣ easfr-core(核心模块)
  ┣ asfr-core-starter(核心依赖模块,提供基础类、核心工具类,如:RedisUtil)
  ┣ easfr-core-web(网站依赖模块,提供网站异常处理器、网站工具类,如:IpUtil)
  ┣ asfr-core-datasource(数据源依赖模块)
  ┣ easfr-core-security(安全依赖模块,提供安全认证相关的实体类、接口、实体类)
  ┣ easfr-core-mybatis(mysql持久化依赖模块,提供通过mysql表自动生成后台文件相关的工具类)
┣ easfr-gateway(网关模块,提供接口转发、权限认证服务)
┣ easfr-server(服务模块,提供安全认证相关服务)
  ┣ easfr-server-oauth(提供认证服务)
  ┣ easfr-server-user(提供用户服务)
  ┣ easfr-server-setcenter(提供设置服务)
┣ easfr-demo(演示业务模块)
  ┣ easfr-demo-api(提供演示业务接口)
  ┣ easfr-demo-inner(提供演示内部接口)
┣ easfr-client(客户端模块)
  ┣ easfr-client-vue(vue客户端,演示:图片验证码登录、短信验证码登录、微信小程序扫码登录、微信开放平台登录、QQ互联登录和登录后调用接口)
  ┣ easfr-client-xcx(提供演示内部接口,演示:小程序登录和微信小程序扫码登录)

三、使用

虽然已经去掉不必要的运维技术体系了,在不了解情况下,想把它跑起来,还是有点困难的,请注意一下几点:

  • 请使用jdk8_192,因为之后的版本要收费了;
  • 请使用ideaIU-2020.x,没正版的话,试用就行;
  • 请安装个本地docker,win10安装Docker Desktop就行;
  • 先把.docker的nacos-1.3.2(需要创建mysql用户和表)和nginx-latest(需要在本地hosts中增映射)跑起来;
  • nacos的数据库脚本中虽然已经初始了数据,但可能不是最新的,请把.nacos目录中的导出文件,更新到nacos中(访问http://nacos:8848/nacos/ 用户名和密码都是nacos);
  • 再把.mysql的脚本跑一下;
  • 请先启动G1-ServerOauth,再启动其它模块,因为需要获取安全认证key;
  • 如果想正式用,需要把VUE_APP_WXKFPT_APP_ID(包括nacos中的设置)换成你自己的;
  • 如果想正式用,需要把VUE_APP_QQ_APP_ID(包括nacos中的设置)换成你自己的。
Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

简介

暂无描述 展开 收起
Apache-2.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Java
1
https://gitee.com/pioneerdk/easfr5.git
git@gitee.com:pioneerdk/easfr5.git
pioneerdk
easfr5
easfr5
master

搜索帮助