Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
SpringBlade
提交
28e19488
S
SpringBlade
项目概览
int
/
SpringBlade
12 个月 前同步成功
通知
16
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
SpringBlade
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
28e19488
编写于
9月 17, 2016
作者:
Z
zhuangqian
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
增加Md类和MdManager类
上级
d88e95b3
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
384 addition
and
33 deletion
+384
-33
src/main/java/com/smallchill/core/plugins/dao/Db.java
src/main/java/com/smallchill/core/plugins/dao/Db.java
+1
-14
src/main/java/com/smallchill/core/plugins/dao/DbManager.java
src/main/java/com/smallchill/core/plugins/dao/DbManager.java
+0
-19
src/main/java/com/smallchill/core/plugins/dao/Md.java
src/main/java/com/smallchill/core/plugins/dao/Md.java
+173
-0
src/main/java/com/smallchill/core/plugins/dao/MdManager.java
src/main/java/com/smallchill/core/plugins/dao/MdManager.java
+210
-0
未找到文件。
src/main/java/com/smallchill/core/plugins/dao/Db.java
浏览文件 @
28e19488
...
...
@@ -347,20 +347,7 @@ public class Db {
public
static
<
T
>
BladePage
<
T
>
paginate
(
String
sqlTemplate
,
Class
<?>
clazz
,
Object
paras
,
int
pageNum
,
int
pageSize
){
return
getDbManager
().
paginate
(
sqlTemplate
,
clazz
,
paras
,
pageNum
,
pageSize
);
}
/**
* 分页
* @param sqlId sqlId
* @param clazz 返回类型
* @param paras 参数
* @param pageNum 页号
* @param pageSize 数量
* @return
*/
public
static
<
T
>
BladePage
<
T
>
paginateById
(
String
sqlId
,
Class
<?>
clazz
,
Object
paras
,
int
pageNum
,
int
pageSize
){
return
getDbManager
().
paginateById
(
sqlId
,
clazz
,
paras
,
pageNum
,
pageSize
);
}
/**
* 是否存在
*
...
...
src/main/java/com/smallchill/core/plugins/dao/DbManager.java
浏览文件 @
28e19488
...
...
@@ -22,7 +22,6 @@ import java.util.concurrent.ConcurrentHashMap;
import
org.beetl.sql.core.SQLManager
;
import
org.beetl.sql.core.SQLReady
;
import
org.beetl.sql.core.SQLResult
;
import
org.beetl.sql.core.engine.PageQuery
;
import
com.smallchill.core.aop.AopContext
;
import
com.smallchill.core.constant.Cst
;
...
...
@@ -511,24 +510,6 @@ public class DbManager {
return
page
;
}
/**
* 分页
* @param sqlId sqlId
* @param clazz 返回类型
* @param paras 参数
* @param pageNum 页号
* @param pageSize 数量
* @return
*/
public
<
T
>
BladePage
<
T
>
paginateById
(
String
sqlId
,
Class
<?>
clazz
,
Object
paras
,
int
pageNum
,
int
pageSize
){
PageQuery
query
=
new
PageQuery
();
query
.
setPageNumber
(
pageNum
);
query
.
setPageSize
(
pageSize
);
getSqlManager
().
pageQuery
(
sqlId
,
clazz
,
query
);
BladePage
<
T
>
page
=
new
BladePage
<>(
query
.
getList
(),
pageNum
,
pageSize
,
query
.
getTotalRow
());
return
page
;
}
/**
* 是否存在
*
...
...
src/main/java/com/smallchill/core/plugins/dao/Md.java
0 → 100644
浏览文件 @
28e19488
/**
* Copyright (c) 2015-2016, Chill Zhuang 庄骞 (smallchill@163.com).
*
* 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.
*/
package
com.smallchill.core.plugins.dao
;
import
java.math.BigDecimal
;
import
java.util.List
;
import
org.beetl.sql.core.db.KeyHolder
;
import
com.smallchill.core.toolbox.support.BladePage
;
public
class
Md
{
private
static
volatile
MdManager
mdManager
=
null
;
public
static
MdManager
init
(
String
name
)
{
return
MdManager
.
init
(
name
);
}
private
Md
()
{}
private
static
MdManager
getMdManager
()
{
if
(
null
==
mdManager
)
{
synchronized
(
Md
.
class
)
{
mdManager
=
MdManager
.
init
();
}
}
return
mdManager
;
}
/************ ↓↓↓ ******** 通用 ********* ↓↓↓ ****************/
/**
* 获取一条数据
* @param sqlId sqlId
* @param paras 参数
* @param clazz 返回类型
* @return
*/
public
static
<
T
>
T
selectOne
(
String
sqlId
,
Object
paras
,
Class
<
T
>
clazz
){
return
getMdManager
().
selectOne
(
sqlId
,
paras
,
clazz
);
}
/**
* 获取一条数据
* @param sqlId sqlId
* @param paras 参数
* @param clazz 返回类型
* @return
*/
public
static
<
T
>
T
selectUnique
(
String
sqlId
,
Object
paras
,
Class
<
T
>
clazz
){
return
getMdManager
().
selectUnique
(
sqlId
,
paras
,
clazz
);
}
/**
* 获取多条数据
* @param sqlId sqlId
* @param paras 参数
* @param clazz 返回类型
* @return
*/
public
static
<
T
>
List
<
T
>
selectList
(
String
sqlId
,
Object
paras
,
Class
<
T
>
clazz
){
return
getMdManager
().
selectList
(
sqlId
,
paras
,
clazz
);
}
/**
* 获取str
* @param sqlId sqlId
* @param paras 参数
* @return
*/
public
static
String
queryStr
(
String
sqlId
,
Object
paras
){
return
getMdManager
().
selectOne
(
sqlId
,
paras
,
String
.
class
);
}
/**
* 获取integer
* @param sqlId sqlId
* @param paras 参数
* @return
*/
public
static
Integer
queryInt
(
String
sqlId
,
Object
paras
){
return
getMdManager
().
selectOne
(
sqlId
,
paras
,
Integer
.
class
);
}
/**
* 获取long
* @param sqlId sqlId
* @param paras 参数
* @return
*/
public
static
Long
queryLong
(
String
sqlId
,
Object
paras
){
return
getMdManager
().
selectOne
(
sqlId
,
paras
,
Long
.
class
);
}
/**
* 获取decimal
* @param sqlId sqlId
* @param paras 参数
* @return
*/
public
static
BigDecimal
queryDecimal
(
String
sqlId
,
Object
paras
){
return
getMdManager
().
selectOne
(
sqlId
,
paras
,
BigDecimal
.
class
);
}
/**
* 分页
* @param sqlId sqlId
* @param clazz 返回类型
* @param paras 参数
* @param pageNum 页号
* @param pageSize 数量
* @return
*/
public
static
<
T
>
BladePage
<
T
>
paginate
(
String
sqlId
,
Class
<?>
clazz
,
Object
paras
,
int
pageNum
,
int
pageSize
){
return
getMdManager
().
paginate
(
sqlId
,
clazz
,
paras
,
pageNum
,
pageSize
);
}
/**
* 新增
* @param sqlId sqlId
* @param paras 参数
* @return
*/
public
static
int
insert
(
String
sqlId
,
Object
paras
){
return
getMdManager
().
insert
(
sqlId
,
paras
);
}
/**
* 新增
* @param sqlId sqlId
* @param paras 参数
* @param keyName 主键名
* @return
*/
public
static
KeyHolder
insert
(
String
sqlId
,
Object
paras
,
String
keyName
)
{
return
getMdManager
().
insert
(
sqlId
,
paras
,
keyName
);
}
/**修改
* @param sqlId sqlId
* @param paras 参数
* @return
*/
public
static
int
update
(
String
sqlId
,
Object
paras
){
return
getMdManager
().
update
(
sqlId
,
paras
);
}
/**删除
* @param sqlId sqlId
* @param paras 参数
* @return
*/
public
static
int
delete
(
String
sqlId
,
Object
paras
){
return
getMdManager
().
delete
(
sqlId
,
paras
);
}
}
src/main/java/com/smallchill/core/plugins/dao/MdManager.java
0 → 100644
浏览文件 @
28e19488
/**
* Copyright (c) 2015-2016, Chill Zhuang 庄骞 (smallchill@163.com).
*
* 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.
*/
package
com.smallchill.core.plugins.dao
;
import
java.math.BigDecimal
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.concurrent.ConcurrentHashMap
;
import
org.beetl.sql.core.SQLManager
;
import
org.beetl.sql.core.db.KeyHolder
;
import
org.beetl.sql.core.engine.PageQuery
;
import
com.smallchill.core.plugins.connection.ConnectionPlugin
;
import
com.smallchill.core.toolbox.kit.StrKit
;
import
com.smallchill.core.toolbox.support.BladePage
;
public
class
MdManager
{
private
static
Map
<
String
,
MdManager
>
pool
=
new
ConcurrentHashMap
<
String
,
MdManager
>();
private
volatile
SQLManager
sql
=
null
;
public
static
MdManager
init
()
{
return
init
(
ConnectionPlugin
.
init
().
MASTER
);
}
public
static
MdManager
init
(
String
name
)
{
MdManager
db
=
pool
.
get
(
name
);
if
(
null
==
db
)
{
synchronized
(
MdManager
.
class
)
{
db
=
pool
.
get
(
name
);
if
(
null
==
db
)
{
db
=
new
MdManager
(
name
);
pool
.
put
(
name
,
db
);
}
}
}
return
db
;
}
private
MdManager
(
String
dbName
)
{
this
.
sql
=
ConnectionPlugin
.
init
().
getPool
().
get
(
dbName
);
}
private
MdManager
()
{}
private
SQLManager
getSqlManager
()
{
if
(
null
==
sql
)
{
synchronized
(
MdManager
.
class
)
{
sql
=
ConnectionPlugin
.
init
().
getPool
().
get
(
ConnectionPlugin
.
init
().
MASTER
);
}
}
return
sql
;
}
/************ ↓↓↓ ******** 通用 ********* ↓↓↓ ****************/
/**
* 获取一条数据
* @param sqlId sqlId
* @param paras 参数
* @param clazz 返回类型
* @return
*/
public
<
T
>
T
selectOne
(
String
sqlId
,
Object
paras
,
Class
<
T
>
clazz
){
return
getSqlManager
().
selectSingle
(
sqlId
,
paras
,
clazz
);
}
/**
* 获取一条数据
* @param sqlId sqlId
* @param paras 参数
* @param clazz 返回类型
* @return
*/
public
<
T
>
T
selectUnique
(
String
sqlId
,
Object
paras
,
Class
<
T
>
clazz
){
return
getSqlManager
().
selectUnique
(
sqlId
,
paras
,
clazz
);
}
/**
* 获取多条数据
* @param sqlId sqlId
* @param paras 参数
* @param clazz 返回类型
* @return
*/
public
<
T
>
List
<
T
>
selectList
(
String
sqlId
,
Object
paras
,
Class
<
T
>
clazz
){
return
getSqlManager
().
select
(
sqlId
,
clazz
,
paras
);
}
/**
* 获取str
* @param sqlId sqlId
* @param paras 参数
* @return
*/
public
String
queryStr
(
String
sqlId
,
Object
paras
){
return
selectOne
(
sqlId
,
paras
,
String
.
class
);
}
/**
* 获取integer
* @param sqlId sqlId
* @param paras 参数
* @return
*/
public
Integer
queryInt
(
String
sqlId
,
Object
paras
){
return
selectOne
(
sqlId
,
paras
,
Integer
.
class
);
}
/**
* 获取long
* @param sqlId sqlId
* @param paras 参数
* @return
*/
public
Long
queryLong
(
String
sqlId
,
Object
paras
){
return
selectOne
(
sqlId
,
paras
,
Long
.
class
);
}
/**
* 获取decimal
* @param sqlId sqlId
* @param paras 参数
* @return
*/
public
BigDecimal
queryDecimal
(
String
sqlId
,
Object
paras
){
return
selectOne
(
sqlId
,
paras
,
BigDecimal
.
class
);
}
/**
* 分页
* @param sqlId sqlId
* @param clazz 返回类型
* @param paras 参数
* @param pageNum 页号
* @param pageSize 数量
* @return
*/
@SuppressWarnings
(
"unchecked"
)
public
<
T
>
BladePage
<
T
>
paginate
(
String
sqlId
,
Class
<?>
clazz
,
Object
paras
,
int
pageNum
,
int
pageSize
){
PageQuery
query
=
new
PageQuery
();
query
.
setPageNumber
(
pageNum
);
query
.
setPageSize
(
pageSize
);
getSqlManager
().
pageQuery
(
sqlId
,
clazz
,
query
);
BladePage
<
T
>
page
=
new
BladePage
<>(
query
.
getList
(),
pageNum
,
pageSize
,
query
.
getTotalRow
());
return
page
;
}
/**
* 新增
* @param sqlId sqlId
* @param paras 参数
* @return
*/
public
int
insert
(
String
sqlId
,
Object
paras
){
return
getSqlManager
().
insert
(
sqlId
,
paras
,
null
,
null
);
}
/**
* 新增
* @param sqlId sqlId
* @param paras 参数
* @param keyName 主键名
* @return
*/
public
KeyHolder
insert
(
String
sqlId
,
Object
paras
,
String
keyName
)
{
if
(
StrKit
.
isBlank
(
keyName
))
return
null
;
KeyHolder
holder
=
new
KeyHolder
();
int
cnt
=
getSqlManager
().
insert
(
sqlId
,
paras
,
holder
,
keyName
);
if
(
cnt
>
0
)
return
holder
;
else
return
null
;
}
/**修改
* @param sqlId sqlId
* @param paras 参数
* @return
*/
public
int
update
(
String
sqlId
,
Object
paras
){
return
getSqlManager
().
update
(
sqlId
,
paras
);
}
/**删除
* @param sqlId sqlId
* @param paras 参数
* @return
*/
public
int
delete
(
String
sqlId
,
Object
paras
){
return
getSqlManager
().
update
(
sqlId
,
paras
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录