0 Star 0 Fork 0

一心一教 / SpringAS

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

spring A.S

更专注于业务层及复杂SQL的开发的Spring boot框架
  • 融合graphql的理念,不必再为修改几个字段就大费周章重新部署
  • 现在对于这些,你只需前端入参便可一步到位,极大程度减少后台代码业务量,将重复性无意义的包袱通通甩掉
  • SQL引擎简化业务层开发所需时间,提升业务开发效率
  • 全项目架构简洁轻便,提升代码开发效率

A.S入门-如何运行我的Spring-A.S项目?

  • 准备pdm数据文件(框架会提供一个test.pdm文件供您测试使用,后期就需要您自行准备了哦)
  • 运行test.generate.generateTest文件生成对应的config/dao及sql文件
    • 将生成的BaseTableCfg.java文件复制粘贴至src.main.java.com.prism.springas.utils文件目录下(您也可以将已有的文件增加.bat后缀留做备份文件)
    • 将生成的BaseDao.java文件复制粘贴至src.main.java.com.prism.springas.dao文件目录下(您也可以将已有的文件增加.bat后缀留做备份文件)
    • 将生成的可执行sql文件打开后复制语句在sql工具内执行查询创建库表
  • 打开src.main.resource.application.yml文件修改对应的数据库连接配置信息
  • 打开src.main.java.SpringasApplication.java文件,右键运行
  • 启动成功! 恭喜您,您已经完成了Spring A.S的前期准备工作流程 ~

A.S进阶-Spring-A.S使用手册

  • api层:底层数据交换映射层,主要与DAO层做数据交互
    • impl:BaseApi的实现类,初步封装了简单的数据逻辑,以简化schema业务层的调用
    • tools:BaseApi核心配置类以及DAO层映射核心代码
  • controller层:前台与后台数据交换层(对外数据交互接口层),主要与schema层做数据交互
    • config:controller核心配置类/schema层映射核心代码及sqlEngine对前台JSON数据的校验及处理
  • dao层:mapper层,Mybatis数据交互层
    • BaseDAO:通过test.generate.generateTest执行后的源生DAO.java文件
    • exPand :拓展dao包
      • xxExDAO:BaseDAO(源生DAO)无法实现的复杂逻辑SQL
      • 拓展DAO层命名规范:xxx(业务名称)+ExDAO【不强制,仅做建议】
  • schema层:核心业务逻辑处理层,主要从API层获取数据并为Controller层提供数据
    • BaseSchema:基础业务逻辑层(核心业务类)
    • exPand :拓展schema包
      • xxExSchema:BaseSchema(源生DAO)无法实现的复杂业务逻辑
      • 拓展Schema层命名规范:xxx(业务名称)+ExSchema【不强制,仅做建议】
  • tools层:插件工具层(--目前只有比较简单的tools插件,后期版本会以拓展包形式发布提供给您使用,敬请关注。)
  • utils层:核心工具层,为框架提供核心工具类
    • cache:缓存工具类(目前相对简陋一些,仅以支持框架为基础)
    • pdmHelper:pdm-核心代码生成工具类
    • sqlEngine:*框架核心SQL引擎工具类
    • BaseCoreCfg:拓展DAO及Schema核心配置类(Ver1.1会优化为注解实现,进一步提升开发效率,相关更新敬请关注!)
    • BasePage:*核心实体映射类
    • BaseTableCfg:**pdm生成工具生成的核心源生表配置类(sqlEngine相关连表表名信息查询及表全查询字段功能)
    • BasicConfigUtil:yml配置中的全局配参字段
  • SpringasApplication:spring boot框架启动类

Spring A.S注意事项及常见问题

  • 我应该如何配置我的拓展dao和schema业务类?
    • ver1.0版本请您打开com.prism.springas.util.BaseCoreCfg
    • 1.将您的拓展DAO及Schema通过@Autowired自动注入
    • 2.在parseRefObject方法中配置您的拓展类名称(*唯一标识)
    • 具体代码详参com.prism.springas.util.BaseCoreCfg给出的测试用例
  • sqlEngine应该如何使用和配置?
    • 您可以打开src.test.java.com.prism.springas路径,下面的3个测试类将通过实际代码为您演示sqlEngine的使用
    • apiTests:API层接口测试
    • schemaTests:SCHEMA层接口(方法)测试
    • testThreadJunit:针对schema层在多线程下的更新及查询接口(方法)测试
  • pdm数据字段规范?
    • 为了您的正常使用,建议您在设计表名及字段时使用大写英文字母(*由pdm生成的所有相关配置均为大写)
    • 表内核心字段:
      • ID:主键,varchar(128),请注意勾选pk选项,否则生成代码时会报错(*A.S全部主键均为UUID,还请注意)*核心字段!
      • VERSION:数据版本号,int,必须要有的字段,*乐观锁核心匹配字段!
      • CREATETIME:数据生成时间(首次创建时间),datetime,可选字段
      • DATATIME:数据最后更新时间,datetime,可选字段
      • ISDELETE:数据软删除状态,int,可选字段(如果您用到了数据软删除,建议您在设计表时加上该字段)

sqlEngine(ver 1.0)-SQL引擎使用说明(Schema业务逻辑层)

  • SELECT相关方法
    • getSelById(String id):根据ID检索数据的匹配条件
    • getSelTable(String tables):需要查询的数据表(支持多表,多个间以','隔开)
      • 注意:连表表名需要从BaseTableCfg获取,*且对应关联表必须在(如://=对应关联表:SPORTSINFO,TEACHERINFO,TYPEINFO0)中!
      • 等效于: select * from a a left join b on a.id = b.id
    • getSelCols(String tables):指定需要查询的数据字段(多个间以','隔开)
      • tables-查询符合入参值的数据表全字段
      • 等效于:select a.* from a
    • getSelCols(String tables,String cols):指定需要查询的数据字段(多个间以','隔开)
      • tables-查询符合入参值的数据表全字段
      • cols-查询符合入参值的字段,数据格式为 table_colname(数据表名_数据列名) / table_colname#alias(数据表名_数据列名#别名)
      • 等效于: select a.*,b.name AS 'bname' from a a left join b on a.id = b.id
    • getPage(Integer pageNo,Integer pageSize):数据分页
      • pageNo:当前第X页
      • pageSize:每页Y条
      • 等效于:select * from a where 1=1 limit x,y
    • getSort(String keys,String sortTypes):执行数据排序(多个间以','隔开)
      • keys:需要执行排序的字段
      • sortTypes:需要的排序类型,*sortTypes值需要与keys值一一对应
        • sortTypes允许的参数如下:
          • 0 : 正常倒叙排序 order by a DESC
          • 1 : 根据汉语拼音正序排序 order by CONVERT(a) USING GBK ASC
          • 2 : 正常正叙排序 order by ASC
          • 3 : 根据汉语拼音倒叙排序 order by CONVERT(a) USING GBK DESC
    • getWhereAnd(String key,String condition,Object val)/getWhereOr(String key,String condition,Object val):数据查询条件(and/or)
      • key:执行查询的数据字段,格式为:table_Cols(表名_列名)
      • condition:参数匹配条件(sqlEngineEnum)
        • EQ:等于
        • LIKE:模糊查询(使用时需要自行指定模糊查询条件,如'%老刘')
        • GT:大于
        • GTEQ:大于等于
        • LT:小于
        • LTEQ:小于等于
        • NEQ:不等于
        • NOTIN:不包含于(使用时,多个值需要以','隔开,如'1,2,3,4'..)
        • IN:包含于(使用时,多个值需要以','隔开,如'1,2,3,4'..)
        • ISNULL:为空(使用时,val入参为"n"即可)
        • NOTNULL:不为空(使用时,val入参为"n"即可)
        • BET:在a...b区间(使用时,val入参格式如下:'08:00:00**,**09:00:00',等效于查询8点-9点内产生的数据)
      • val:对应数据查段查询值(请严格参照上述表格格式进行入参,否则数据不会正常返回(报错))
    • getCount():计算数据总条数(total值)
  • DELETE相关方法
    • getDelTables(String tables):需要执行删除的数据表
    • getDeleteById(String id):以ID主键作为删除条件执行删除
    • getNeedDelTable(String tables):指定需要删除的数据表(多表复合删除专属方法)
    • 同样的,DELETE如果需要根据指定条件批量删除数据时,可以使用getWhereAnd/getWhereOr来指定删除条件^_^
    • 请注意一点:getWhereAnd/getWhereOr与getDeleteById并不共存,sqlEngine会以最后的调用的方法为最终标准执行!
  • INSERT相关方法
    • getAddData(String key,Object val):需要入库的字段及其对应值
      • key:入库字段(直接使用列名即可,如NAME,ID等)
      • val:入库值
  • UPDATE相关方法
    • getUpdateTables(String tables):需要执行更新的数据主表
    • getUpdateCols(String colKey,Object colValue):需要执行更新的字段及字段值
      • colKey:需要执行更新的字段
      • colValue:需要执行更新的字段值
    • getUpdateWhereAnd(String key,String condition,Object val)/getUpdateWhereOr(String key,String condition,Object val):数据更新条件(and/or)
      • 具体使用可参考getWhereAnd/getWhereOr
    • getUpdCurrentVersion(String tableName,Integer value):数据版本验证/需要配合getUpdateById使用(*不适用于批量更新)
      • tableName:需要执行校验的数据表表名
      • value:当前数据版本
    • getUpdateById(String id):需要执行更新的数据主键ID
  • FETCH批量录入相关方法
    • getAddFetchCols(String cols):需要执行批量录入的数据列(ID/ISDELETE/VERSION/CREATETIME/DATETIME除外),多个列名间以','隔开
    • getAddFetchVals(List<BasePage fetchList):需要执行批量录入的数据值List

开发进度(版本更新日志) Version 0.X: 更新时间:2018-03-28

版本功能:

  • PDM自生成相关代码
  • 完成了A.S框架的底层初步搭建

Version 1.0: 更新时间:2019-01-08

版本功能:

  • 优化PDM自生成相关代码
  • SQL引擎提出,进一步简化开发逻辑(*现版本仅支持Mysql数据库)
  • 优化异常抛出,更加精准定位exception异常点位,提升bug修复及代码维护的效率
  • 进一步提升了SQL引擎的数据安全性(2019-01-09)

PS 如果您有什么好的建议和意见可以直接评论给我,感谢您的支持~ Ver 2.0预计更新时间为1月16日~

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: You must give any other recipients of the Work or Derivative Works a copy of this License; and You must cause any modified files to carry prominent notices stating that You changed the files; and 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 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 2019 一心一教 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.

简介

更专注于业务层及复杂SQL的开发的Spring boot框架 展开 收起
Java
Apache-2.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/oneHeartoneSimple/SpringAS.git
git@gitee.com:oneHeartoneSimple/SpringAS.git
oneHeartoneSimple
SpringAS
SpringAS
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891