1 Star 0 Fork 724

云想软件有限公司 / anyline

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

代码已迁至https://github.com/anylineorg/anyline

AnyLine 是一个针对http/rpc环境的,基于spring-jdbc的,快捷数据库操作工具。

其核心是
1、提供了一个约定格式的函数,用来实现http/rpc参数到jdbc参数的转换。
2、提供了一对基础的service和dao,用来实现常规的数据库操作。
3、提供了一对标准的数据结构(DataSet/DataRow),用来实现MVC各层之间的数据传输,
并在其上附加了开发常用的计算函数(如求和、分组、交集、筛选,行转列等)。

- http参数到jdbc参数的转换

在实际开发中,业务开发人员经常需要大量的时间,不厌其烦的从http/rpc中提取参数,判断验证,生成jdbc要求格式的参数,
再把参数依次传到service、dao,最后返回一个实现bean。这整个过程中经常有各种小细节容易忽略而导致异常,如空值处理,IN条件生成等。
而在整个项目中这些过程又是大量重复或类似的。这不但影响开发速度与代码质量,更影响心情。
所以AnyLine提供了一个统一约定格式来实现这些繁琐的操作,格式大致如下

参数> code=0 code= code=0&code=1
&cd=2&user=5
cd=2&cd=3 code=0(密) cd=2(密)
&cd=3(密)
1 CODE:code CODE = 0 忽略 CODE = 0 忽略 忽略 忽略
2 CODE:%code% CODE LIKE '%0%' 忽略 CODE LIKE '%0%' 忽略 忽略 忽略
3 CODE:%code CODE LIKE '%0' 忽略 CODE LIKE '%0' 忽略 忽略 忽略
4 CODE:code% CODE LIKE '0%' 忽略 CODE LIKE '0%' 忽略 忽略 忽略
5 CODE:%code: cd% CODE LIKE '%0%' 忽略 CODE LIKE '%0%' CODE LIKE '%2%' 忽略 忽略
6 CODE:%code: cd:{9}% CODE LIKE '%0%' CODE LIKE '%9%' CODE LIKE '%0%' CODE LIKE '%2%' 忽略 忽略
7 CODE:%code: cd CODE LIKE '%0' 忽略 CODE LIKE '%0' CODE LIKE '%2' 忽略 忽略
8 CODE:%code: cd:{9} CODE LIKE '%0' CODE LIKE '%9' CODE LIKE '%0' CODE LIKE '%2' 忽略 忽略
9 CODE:[code] CODE = 0 忽略 CODE IN(0,1) 忽略 忽略 忽略
10 CODE:[code: cd] CODE = 0 忽略 CODE IN(0,1) CODE IN(2,3) 忽略 忽略
11 CODE:[cd+] 忽略 忽略 CODE = 2 CODE IN(2,3) 忽略 CODE IN(2,3)
12 CODE:[code: cd:{[6,7,8]}] CODE = 0 CODE IN(6,7,8) CODE IN(0,1) CODE IN(2,3) 忽略 忽略
13 CODE:[code: cd:{6,7,8}] CODE = 0 CODE IN(6,7,8) CODE IN(0,1) CODE IN(2,3) 忽略 忽略
14 +CODE:code CODE = 0 CODE IS NULL CODE = 0 CODE IS NULL 忽略 忽略
15 ++CODE:code CODE = 0 不执行 CODE = 0 不执行 忽略 忽略
16 CODE:>code CODE > 0 忽略 CODE > 0 忽略 忽略 忽略
17 CODE:>code: cd CODE > 0 忽略 CODE > 0 CODE > 2 忽略 忽略
18 CODE:>code:{9} CODE > 0 CODE > 9 CODE >0 CODE > 9 CODE > 9 CODE > 9
19 CODE:code: cd CODE = 0 忽略 CODE = 2 CODE = 2 忽略 忽略
20 CODE:code: cd:{9} CODE = 0 CODE = 9 CODE = 0 CODE = 2 忽略 忽略
21 CODE:code|cd CODE = 0 忽略 CODE =0 OR CODE = 2 忽略 忽略 忽略
22 CODE:code|{NULL} CODE = 0 OR CODE IS NULL 忽略 CODE = 0 OR CODE IS NULL 忽略 忽略 忽略
23 CODE:code|CODE: cd CODE = 0 忽略 CODE = 0 OR CODE = 1 CODE = 2 忽略 忽略
24 CODE:code|CD: cd CODE = 0 忽略 CODE = 0 OR CD = 2 CD = 2 忽略 忽略
25 CODE:code: cd|user CODE = 0 忽略 CODE = 0 OR CODE = 5 CODE = 2 忽略 忽略
26 CODE:code: cd|{9} CODE = 0 忽略 CODE = 0 OR CODE = 9 CODE = 2 OR CODE = 9 CODE = 9 CODE = 9
27 CODE:code+:{9} CODE = 9 CODE = 9 CODE = 9 CODE = 9 CODE = 0 CODE = 9
28 CODE:code+: cd:{9} CODE = 9 CODE = 9 CODE = 2 CODE = 2 CODE = 0 CODE = 9
29 CODE:code+: cd+ 忽略 忽略 忽略 忽略 CODE = 0 CODE = 2
30 CODE:code|CODE: cd|CD: cd|CD:code CODE = 0 OR CD = 0 忽略 CODE =0 OR CODE = 2 OR ID =0 OR ID = 2 CODE =2 OR CD =2 忽略 忽略
31 CODE:code:{9}|CD: cd:{9} CODE = 0 OR CD = 9 CODE = 9 OR CD = 9 CODE = 0 OR CD = 2 CODE = 9 OR CD = 2 CODE = 9 OR CD = 9 CODE = 9 OR CD = 9

详细参考:http://doc.anyline.org/s?id=1059

- 常规数据库操作

AnyLine提供了一对基础的service/dao。通过接收上一步约定好格式的参数,足以完成绝大部分的数据库操作。
在实际开发过程中,通常是用BaseController继承tAnylineController(适用于springmvc框架,如果是Struts2框架则继承AnylineAction)
AnylineController中已经注入AnylineService serive,并重载了大量condition函数。

或者在Controller中注入AnylineService,AnylineService已通过@Service("anyline.service")的形式注册到Spring上下文中。
对于更复杂的业务逻辑需要自己实现Serive,同样可以继承AnylineService,AnylineService中也已经注入AnylineDao dao,并重载了大量数据库操作函数。

Controller层操作过程大致如下:

DataSet set = service.querys("HR_USER(ID,NM)"
    , condition(true,"TYPE_CODE:[type]","NM:nm%","+ZIP_CODE:zip:","++DEPT_CODE:dept","POST_CODE:post:pt:{101}")
    , "IS_PUB:1");

实现功能: 根据TYPE_CODE,NM,IS_PUB列查询HR_USER表,并根据http参数自动分页 生成的SQL(以mysql为例):

SELECT
    ID,NM
FROM HR_USER  
WHERE
    TYPE_CODE IN (?,?,?)  
    AND NM LIKE CONCAT(?,'%')
    AND ZIP_CODE = ?
    AND DEPT_CODE = ?
    AND POST_CODE = ?
    AND IS_PUB = ?
LIMIT 0,10

以SQL根据http参数传递情况动态生成,如果http中没有相关的参数则相应的查询条件不生成。
IS_PUB值不是来自http
TYPE_CODE IN(?,?,?)中的占位符数量根据http中type参数数量生成
如果http中没有提供zip则生成ZIP_CODE IS NULL的查询条件
如果http中没有提供dept则整个SQL将不执行,当前querys函数返回长度为0的DataSet
如果http中没有提供post,则取根据pt取值,如果没有提供pt,则使用默认值101,其中的{}表示常量,而不是http中的参数key
注意IS_PUB的值是一个固定值1,也不是通过http参数中取值,所以不需要放在condition函数中转换

- 标准数据结构与计算函数

AnyLine默认提供DataRow (类似于Map)与DataSet(类似于Collection<datarow>)两种数据结构用来实现MVC各层之间的数据传输,
DataRow,DataSet一般是通过http参数直接构造,或AnylineSevice.query()函数返回,或通过json,xml等数据格式构造,也可以new实例后执行put,add等赋值操作。
AnyLine支持但不推荐实体Bean的形式
因为DataRow/DataSet上可以统一附加开发中常用的计算函数,但实体Bean不方便,如:
排序,求和,截取,清除空值,按列去重,最大最小值,交集合集差集,分组,行列转换,类SQL筛选(like,eq,in,less,between...),JSON,XML格式转换

- 附加功能

针对view层提供了大量的JSP自定义标签用来简化前端操作。
如<al:navi/>用来配合后台的condition函数快速实现ajax分页查询
<al:select/><al:checkbox/>用来根据DataSet数据源生成<select>/<input type="checkbox">标签,并根据条件设置默认选中值。
其他如 nvl,evl,date,escape,text,set,if,else等
以及对支付工具,阿里云,微信,QQ,高德,极光,环信等第三方平台或插件的集成。
同时提供了常用的图片,HTTP,FTP,加密解密,签名验签,压缩,File,Date,正则,反射等常用工具

anyline-core           : 基础包
anyline-web            : javaEE基础
anyline-net            : 多任务下载,下载进度,断点续传,网速计算,耗时预算,下载回调	
anyline-struts         : strtus2支持
anyline-springmvc      : springmvc支持
anyline-jdbc		: jdbc基础
anyline-jdbc-mysql     : mysql支持
anyline-jdbc-mssql     : sql server支持
anyline-jdbc-db2       : db2支持
anyline-jdbc-oracle    : oracle支持
anyline-jdbc-postgresql: PostgreSQL支持
anyline-jdbc-hgdb      :瀚高数据库支持
anyline-alipay         : 支付宝支付集成工具
anyline-aliyun         : 阿里云平台相关工具
anyline-weixin         : 微信支付,微信开放平台,公众平台集成工具
anyline-qq             : QQ支付,QQ开放平台,公众平台集成工具
anyline-jpush          : 极光推送集成工具
anyline-easemob        : 环信集成工具
anyline-amap           : 高德云图集成工具
anyline-sms            : 基于阿里云的短信发送工具
anyline-mail           : 邮件接收发送
anyline-video          : 视频处理
anyline-ext            : 水印,动画等扩展功能
anyline-redis          : redis
anyline-nc	       : netcdf解析
anyline-poi	       : 基于poi的msoffice文件操作
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 2015 anyline_core 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.

简介

一个针对web环境的,基于spring-jdbc的,快捷数据库操作工具 ,代码已迁至https://github.com/anylineorg/anyline 展开 收起
Java
Apache-2.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

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

搜索帮助