Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
T
tcm-system
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
TCM
tcm-system
Commits
caa8b215
Commit
caa8b215
authored
May 10, 2019
by
Administrator
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
审核代码
parent
18eb1b3c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
120 additions
and
0 deletions
+120
-0
readme.md
readme.md
+120
-0
No files found.
readme.md
View file @
caa8b215
...
...
@@ -6,3 +6,123 @@ Table.add(CHECK_VALID,"select count(a.id) from pd_authority a where 1=1")
.
add
(
"url"
,
"and a.url = ?"
)
.
add
(
"id"
,
"and a.id <> ?"
);
```
# 参数请符合实体,而不是单独的参数
如:
```
java
public
List
<
String
>
getRoleTrightPKListByRoleId
(
String
roleId
)
{
return
this
.
query
(
String
.
class
,
GET_ROLE_TRIGHT_PKLIST_BY_ROLEID
,
roleId
);
}
```
# RoleDaoImpl
## 夏敏的函数请用load,可以删除
```
java
@Override
public
RoleVo
getRoleById
(
String
id
)
{
return
this
.
queryFirst
(
RoleVo
.
class
,
GET_ROLE_BY_ID
,
id
);
}
@Override
public
RoleVo
getRoleByName
(
String
name
)
{
return
this
.
queryFirst
(
RoleVo
.
class
,
GET_ROLE_BY_NAME
,
name
);
}
```
参见如下代码:
```
java
dao
.
load
({
id:
"1"
})
dao
.
load
({
name:
"1"
})
```
## 检测语句
```
java
table
.
add
(
CHECK_NAME_EXIST
,
"select count(r.id) from pd_role r where 1=1 "
)
.
add
(
"name"
,
"and r.name = ? "
)
.
add
(
"id"
,
"and r.id <> ?"
);
```
改成
```
java
table
.
addExist
(
CHECK_NAME_EXIST
,
"name"
);
```
调用时
# 请确定语句主表,比如说和 pd_role_authority表和pd_authority表的查询,请另外新建dao层,符合三层架构规范
```
java
table
.
add
(
GET_TRIGHTID_LIST
,
"select authority_id from pd_role_authority where 1=1 "
)
.
add
(
"roleId"
,
"and role_id = ?"
);
table
.
add
(
GET_TRIGHTNAME_BY_TRIGHTID
,
"select name from pd_authority where 1=1 "
)
.
add
(
"trightId"
,
"and id = ?"
);
```
# SQL语句合并
```
java
table
.
add
(
GET_ROLE_TRIGHT_PKLIST_BY_ROLEID
,
"select id from pd_role_authority where 1=1 "
)
.
add
(
"roleId"
,
"and role_id = ?"
);
table
.
add
(
GET_ROLE_TRIGHT_PKLIST_BY_TRIGHTID
,
"select id from pd_role_authority where 1=1 "
)
.
add
(
"trightId"
,
"and tright_id = ?"
);
```
可以合并为
```
java
table
.
add
(
GET_ROLE_TRIGHT_PKLIST_BY_ROLEID
,
"select id from pd_role_authority where 1=1 "
)
.
add
(
"roleId"
,
"and role_id = ?"
);
.
add
(
"trightId"
,
"and tright_id = ?"
);
```
# 更爱SQL语句
```
java
table
.
add
(
CHECK_VALID
,
"select count(a.id) from pd_authority a where 1=1 "
)
.
add
(
"name"
,
"and a.name = ? "
)
.
add
(
"url"
,
"and a.url = ? "
)
.
add
(
"id"
,
"and a.id <> ?"
);
```
改为:
```
java
table
.
add
(
CHECK_VALID
,
"name"
,
"url"
);
```
# 将如下SQL语句合并
```
java
table
.
add
(
GET_TRIGHT_BY_ID
,
"select * from pd_authority where 1=1 "
)
.
add
(
"id"
,
"and id = ?"
);
table
.
add
(
LIST_ALL
,
"select * from pd_authority where 1=1"
);
table
.
add
(
LIST_LEVEL_ONE
,
"select * from pd_authority where pid=null"
);
// 这句SQL语句可以去掉,本身没有意义
table
.
add
(
CHECK_CHILD
,
"select count(id) from pd_authority where 1=1 "
)
.
add
(
"id"
,
"and pid = ?"
);
table
.
add
(
GET_CHILDID_LIST
,
"select id from pd_authority where 1=1 "
)
.
add
(
"id"
,
"and pid = ?"
);
```
如:
```
java
table
.
add
(
GET_TRIGHT_BY_ID
,
"select * from pd_authority where 1=1 "
)
.
add
(
"id"
,
"and id = ?"
)
.
add
(
"top"
,
"and ifnull(pid,'')= ''"
)
.
add
(
"pid"
,
"and pid = ?"
);
```
# 将如下SQL语句合并
```
java
table
.
add
(
GET_USER
,
"SELECT id,account,phone,status,remark,create_time,creator FROM pd_user WHERE 1=1 "
)
.
add
(
"account"
,
" AND account = ?"
);
table
.
add
(
GET_ALL_USERS
,
"select id,account,phone,status,remark,create_time,creator from pd_user where 1=1"
);
table
.
add
(
GET_ROLE_IDS
,
"select role_id from pd_user_role where 1=1 "
)
.
add
(
"userId"
,
"and user_id = ?"
);
table
.
add
(
GET_USER_BY_ID
,
"select id,account,phone,status,remark,create_time,creator from pd_user where 1=1 "
)
.
add
(
"userId"
,
"and user_id = ?"
);
table
.
add
(
GET_ROLE_BY_ROLEID
,
"select name from pd_role where 1=1 "
)
.
add
(
"roleId"
,
"and id = ?"
);
```
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment