Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
projectArtifacture
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
yangzhaojun
projectArtifacture
Commits
1b899395
Commit
1b899395
authored
Aug 31, 2018
by
xfxmcy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cy.code generator v2.0.0
parent
dce67f21
Changes
35
Hide whitespace changes
Inline
Side-by-side
Showing
35 changed files
with
420 additions
and
312 deletions
+420
-312
pom.xml
pom.xml
+1
-1
readMe.md
readMe.md
+32
-1
CodeController.java
...main/java/org/rcisoft/code/controller/CodeController.java
+14
-8
GeneratorRepository.java
src/main/java/org/rcisoft/code/dao/GeneratorRepository.java
+5
-2
CodeSchema.java
src/main/java/org/rcisoft/code/model/CodeSchema.java
+4
-89
DbColumnModel.java
src/main/java/org/rcisoft/code/model/DbColumnModel.java
+26
-0
DbTableModel.java
src/main/java/org/rcisoft/code/model/DbTableModel.java
+8
-0
CodeService.java
src/main/java/org/rcisoft/code/service/CodeService.java
+1
-1
CodeServiceImpl.java
...n/java/org/rcisoft/code/service/impl/CodeServiceImpl.java
+49
-39
Global.java
src/main/java/org/rcisoft/common/component/Global.java
+4
-2
CommonController.java
...in/java/org/rcisoft/core/controller/CommonController.java
+2
-1
ServiceException.java
...ain/java/org/rcisoft/core/exception/ServiceException.java
+2
-2
Result.java
src/main/java/org/rcisoft/core/result/Result.java
+1
-8
ResultCode.java
src/main/java/org/rcisoft/core/result/ResultCode.java
+7
-1
ResultServiceExceptionEnums.java
.../org/rcisoft/core/result/ResultServiceExceptionEnums.java
+11
-47
ResultSystemExceptionEnums.java
...a/org/rcisoft/core/result/ResultSystemExceptionEnums.java
+25
-1
AuthenticationServiceImpl.java
.../rcisoft/core/service/impl/AuthenticationServiceImpl.java
+4
-2
DbUtil.java
src/main/java/org/rcisoft/core/util/DbUtil.java
+35
-0
DecryptDBPasswordUtility.java
.../java/org/rcisoft/core/util/DecryptDBPasswordUtility.java
+3
-2
ExcelUtil.java
src/main/java/org/rcisoft/core/util/ExcelUtil.java
+2
-2
ResultGenerator.java
src/main/java/org/rcisoft/core/util/ResultGenerator.java
+11
-0
UserUtil.java
src/main/java/org/rcisoft/core/util/UserUtil.java
+3
-0
SysDeptController.java
...va/org/rcisoft/sys/dept/controller/SysDeptController.java
+4
-3
SysMenuController.java
...va/org/rcisoft/sys/menu/controller/SysMenuController.java
+6
-5
SysRoleController.java
...va/org/rcisoft/sys/role/controller/SysRoleController.java
+9
-8
SysUserServiceImpl.java
...org/rcisoft/sys/user/service/impl/SysUserServiceImpl.java
+3
-2
application-dev.yml
src/main/resources/application-dev.yml
+2
-2
controller.ftl
src/main/resources/templates/codeftl/controller.ftl
+50
-32
entity.ftl
src/main/resources/templates/codeftl/entity.ftl
+9
-4
entityNotCommon.ftl
src/main/resources/templates/codeftl/entityNotCommon.ftl
+10
-6
mapper.ftl
src/main/resources/templates/codeftl/mapper.ftl
+3
-3
repository.ftl
src/main/resources/templates/codeftl/repository.ftl
+4
-4
service.ftl
src/main/resources/templates/codeftl/service.ftl
+23
-11
serviceimpl.ftl
src/main/resources/templates/codeftl/serviceimpl.ftl
+45
-21
connect.ftl
src/main/resources/templates/connect.ftl
+2
-2
No files found.
pom.xml
View file @
1b899395
...
...
@@ -5,7 +5,7 @@
<modelVersion>
4.0.0
</modelVersion>
<groupId>
org.rcisoft
</groupId>
<artifactId>
education
</artifactId>
<artifactId>
projectArtifact
</artifactId>
<version>
2.0-SNAPSHOT
</version>
...
...
readMe.md
View file @
1b899395
...
...
@@ -43,4 +43,35 @@
## jwt简介
## spring-security 简介
\ No newline at end of file
## spring-security 简介
# 编码规范
| 版本 | 维护人员 | 维护时间 |
| ------------ | ------------ | ------------ |
| v0.1 | 李丛阳 | 2018-6-06 |
## 数据库设计规范
| 编号 | 类型 | 标题 | 描述 |
| ------------ | ------------ | ------------ | ------------ |
| 1 | 表 | 表名 | 小写,单词之间使用下划线 |
| 2 | 表 | 表名 | 中间表使用r_间隔 eg: b_r_teacher_course |
| 3 | 表 | 表结构 | 主表必须要有6+字段(创建时间,修改时间等),中间表不需要 |
| 4 | 列 | 列名 | 小写,单词之间使用下划线 |
| 5 | 列 | 列名 | 每一列必须要有备注 |
| 6 | 列 | 状态列 | char(1) 或 varchar(1),备注要描述清楚状态 |
## 微服务编码规范
| 编号 | 类型 | 标题 | 描述 |
| ------------ | ------------ | ------------ | ------------ |
| 0 | 结构 | 目录规范 | 详见 projectArtifacture|
| 1 | 接口 | 提供其它服务调用的接口要标明 | 模块要单独提出一个controller,requestMappeing使用/api/ 开头|
| 2 | 接口 | 返回值 | Result / GridModel|
| 3 | 接口 | 使用restful风格 | get post pust delete,/id/ |
| 4 | 接口 | requestMappeing命名规范 | queryUsers, queryUserByPagination, detail/businessId, delete/businessId, add, update/businessId |
| 5 | 接口 | swagger | controller api docs |
| 6 | 结构 | service dao | 注释,尽量复用 |
| 7 | 结构 | tcc | 分布式事务书写规范 |
| 8 | 结构 | entity | @Entity @Data @NoArgsConstructor @AllArgsConstructor @Table |
src/main/java/org/rcisoft/code/controller/CodeController.java
View file @
1b899395
package
org
.
rcisoft
.
code
.
controller
;
import
io.swagger.annotations.ApiOperation
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.collections4.ListUtils
;
import
org.rcisoft.code.model.CodeSchema
;
import
org.rcisoft.code.model.CodeTable
;
import
org.rcisoft.code.service.CodeService
;
import
org.rcisoft.core.constant.MessageConstant
;
import
org.rcisoft.core.controller.PaginationController
;
import
org.rcisoft.core.exception.ServiceException
;
import
org.rcisoft.core.model.PersistModel
;
import
org.rcisoft.core.result.Result
;
import
org.rcisoft.core.result.ResultSystemExceptionEnums
;
import
org.rcisoft.core.util.ResultGenerator
;
import
org.rcisoft.core.util.UserUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
...
...
@@ -41,13 +47,13 @@ public class CodeController extends PaginationController<CodeTable> {
@RequestMapping
(
"connectDb"
)
public
Result
connectDb
(
CodeSchema
codeSchema
){
List
<
CodeTable
>
result
=
codeServiceImpl
.
getCodeTablesBySchema
(
codeSchema
);
if
(
null
==
result
||
0
==
result
.
size
(
))
return
Result
.
builder
(
new
PersistModel
(
0
),
if
(
CollectionUtils
.
isEmpty
(
result
))
return
Result
Generator
.
builder
(
new
PersistModel
(
0
),
MessageConstant
.
MESSAGE_ALERT_SUCCESS
,
"数据库连接信息错误,或数据库不存在数据表!"
,
result
);
else
return
Result
.
builder
(
new
PersistModel
(
1
),
return
Result
Generator
.
builder
(
new
PersistModel
(
1
),
MessageConstant
.
MESSAGE_ALERT_SUCCESS
,
"数据库连接信息错误,或数据库不存在数据表!"
,
result
);
...
...
@@ -60,19 +66,19 @@ public class CodeController extends PaginationController<CodeTable> {
@ApiOperation
(
value
=
"构建 treeView"
,
notes
=
"构建 treeView"
)
@RequestMapping
(
value
=
"constructCode"
)
//@ResponseBody // springMVC 下载 报页面找不到
public
void
constructCode
(
CodeSchema
codeSchema
)
throws
IO
Exception
{
public
void
constructCode
(
CodeSchema
codeSchema
)
throws
Exception
{
ServletOutputStream
out
=
null
;
InputStream
fin
=
null
;
File
file
=
null
;
//codeSchema.setUserId(UserUtil.getUserInfoProp(getToken(),UserUtil.USER_ID));
String
path
=
codeServiceImpl
.
generateCode
(
codeSchema
);
codeSchema
.
setUserId
(
UserUtil
.
getUserInfoProp
(
getToken
(),
UserUtil
.
USER_ID
));
try
{
String
path
=
codeServiceImpl
.
generateCode
(
codeSchema
);
if
(
null
==
path
)
return
;
file
=
new
File
(
path
);
//不存在
if
(
null
==
file
||
!
file
.
exists
())
return
;
throw
new
ServiceException
(
ResultSystemExceptionEnums
.
ERROR
)
;
// response
response
.
setCharacterEncoding
(
"utf-8"
);
response
.
setContentType
(
"application/force-download"
);
...
...
@@ -86,7 +92,7 @@ public class CodeController extends PaginationController<CodeTable> {
out
.
write
(
buffer
,
0
,
bytesToRead
);
}
}
catch
(
Exception
ex
){
ex
.
printStackTrace
()
;
throw
ex
;
}
finally
{
if
(
fin
!=
null
)
fin
.
close
();
if
(
out
!=
null
)
out
.
close
();
...
...
src/main/java/org/rcisoft/code/dao/GeneratorRepository.java
View file @
1b899395
package
com
.
github
.
wxiaoqi
.
security
.
generator
.
mapper
;
package
org
.
rcisoft
.
code
.
dao
;
import
org.springframework.stereotype.Repository
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -10,7 +12,8 @@ import java.util.Map;
* @email 463540703@qq.com
* @date 2017年08月25日
*/
public
interface
GeneratorMapper
{
@Repository
public
interface
GeneratorRepository
{
List
<
Map
<
String
,
Object
>>
queryList
(
Map
<
String
,
Object
>
map
);
...
...
src/main/java/org/rcisoft/code/model/CodeSchema.java
View file @
1b899395
package
org
.
rcisoft
.
code
.
model
;
import
lombok.Data
;
import
java.io.Serializable
;
/**
...
...
@@ -8,6 +10,7 @@ import java.io.Serializable;
*
* code schema
*/
@Data
public
class
CodeSchema
implements
Serializable
{
...
...
@@ -24,38 +27,6 @@ public class CodeSchema implements Serializable {
private
String
author
;
public
String
getAuthor
()
{
return
author
;
}
public
void
setAuthor
(
String
author
)
{
this
.
author
=
author
;
}
public
String
getIp
()
{
return
ip
;
}
public
void
setIp
(
String
ip
)
{
this
.
ip
=
ip
;
}
public
String
getDb
()
{
return
db
;
}
public
void
setDb
(
String
db
)
{
this
.
db
=
db
;
}
public
String
getPort
()
{
return
port
;
}
public
void
setPort
(
String
port
)
{
this
.
port
=
port
;
}
private
String
port
;
private
String
dbProduct
;
...
...
@@ -64,13 +35,6 @@ public class CodeSchema implements Serializable {
private
String
basePackage
;
public
String
getBasePackage
()
{
return
basePackage
;
}
public
void
setBasePackage
(
String
basePackage
)
{
this
.
basePackage
=
basePackage
;
}
public
CodeSchema
()
{
}
...
...
@@ -81,41 +45,6 @@ public class CodeSchema implements Serializable {
return
url
;
}
public
void
setUrl
(
String
url
)
{
this
.
url
=
url
;
}
public
String
getDbName
()
{
return
dbName
;
}
public
void
setDbName
(
String
dbName
)
{
this
.
dbName
=
dbName
;
}
public
String
getUsername
()
{
return
username
;
}
public
void
setUsername
(
String
username
)
{
this
.
username
=
username
;
}
public
String
getPassword
()
{
return
password
;
}
public
void
setPassword
(
String
password
)
{
this
.
password
=
password
;
}
public
String
getDbProduct
()
{
return
dbProduct
;
}
public
void
setDbProduct
(
String
dbProduct
)
{
this
.
dbProduct
=
dbProduct
;
}
public
String
getDriverClass
()
{
if
(
DbModel
.
MYSQL
.
getType
().
equals
(
getDb
()))
...
...
@@ -129,22 +58,8 @@ public class CodeSchema implements Serializable {
private
String
tables
;
public
String
getTables
()
{
return
tables
;
}
public
void
setTables
(
String
tables
)
{
this
.
tables
=
tables
;
}
private
String
userId
;
public
String
getUserId
()
{
return
userId
;
}
public
void
setUserId
(
String
userId
)
{
this
.
userId
=
userId
;
}
private
String
mapperLocations
;
}
src/main/java/org/rcisoft/code/model/DbColumnModel.java
View file @
1b899395
...
...
@@ -7,6 +7,7 @@ import lombok.NoArgsConstructor;
import
java.io.Serializable
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.util.Map
;
/**
* Created by lcy on 17/7/5.
...
...
@@ -18,6 +19,14 @@ public class DbColumnModel implements Serializable{
private
static
final
long
serialVersionUID
=
-
7808860348918160912L
;
/*mybatis 映射*/
public
static
final
String
CONS_COLUMN_NAME
=
"columnName"
;
public
static
final
String
CONS_COLUMN_COMMENT
=
"columnComment"
;
public
static
final
String
CONS_COLUMN_DATATYPE
=
"dataType"
;
public
static
final
String
CONS_COLUMN_KEY
=
"columnKey"
;
public
static
final
String
CONS_COLUMN_EXTRA
=
"extra"
;
public
static
final
String
CONS_COLUMN_NULLABLE
=
"isnullAble"
;
public
static
final
String
CONS_COLUMN_DEFAULT
=
"columnDefault"
;
private
String
colName
;
//列名
...
...
@@ -216,4 +225,21 @@ public class DbColumnModel implements Serializable{
return
typeNameUpper
;
}
/**
* 根据mybatis sql map 转换
* @param col
*/
public
void
copyColumnFromSqlMap
(
Map
<
String
,
String
>
col
)
{
this
.
setColName
(
col
.
get
(
CONS_COLUMN_NAME
));
//列名
this
.
setIsNull
((
"true"
.
equals
(
col
.
get
(
CONS_COLUMN_NULLABLE
))?
1
:
0
));
//是否允许为空
this
.
setTypeName
(
col
.
get
(
CONS_COLUMN_DATATYPE
));
//数据类型
this
.
setRemarks
(
col
.
get
(
CONS_COLUMN_COMMENT
));
//备注
this
.
setDefaultValue
(
col
.
get
(
CONS_COLUMN_DEFAULT
));
String
columnKey
=
col
.
get
(
CONS_COLUMN_KEY
);
if
(
"PRI"
.
equalsIgnoreCase
(
columnKey
))
{
this
.
setKey
(
true
);
}
}
}
src/main/java/org/rcisoft/code/model/DbTableModel.java
View file @
1b899395
...
...
@@ -3,6 +3,7 @@ package org.rcisoft.code.model;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
org.apache.commons.lang3.StringUtils
;
import
java.io.Serializable
;
import
java.util.List
;
...
...
@@ -15,8 +16,13 @@ import java.util.List;
@AllArgsConstructor
@NoArgsConstructor
public
class
DbTableModel
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1803273420552584045L
;
/*mybatis 映射*/
public
static
final
String
CONS_TABLE_NAME
=
"tableName"
;
public
static
final
String
CONS_TABLE_COMMENT
=
"tableComment"
;
private
List
<
DbColumnModel
>
columnModels
;
...
...
@@ -37,6 +43,8 @@ public class DbTableModel implements Serializable{
private
boolean
isIdEntity
;
//是否都存在 create_by update_by .. 7个字段
public
String
getEntityName
()
{
if
(
StringUtils
.
isBlank
(
tableName
))
return
""
;
StringBuffer
simpleEntity
=
new
StringBuffer
();
boolean
upPower
=
true
;
for
(
int
i
=
0
;
i
<
tableName
.
length
()
;
i
++){
...
...
src/main/java/org/rcisoft/code/service/CodeService.java
View file @
1b899395
...
...
@@ -24,5 +24,5 @@ public interface CodeService {
* @param codeSchema
* @return
*/
String
generateCode
(
CodeSchema
codeSchema
);
String
generateCode
(
CodeSchema
codeSchema
)
throws
Exception
;
}
src/main/java/org/rcisoft/code/service/impl/CodeServiceImpl.java
View file @
1b899395
package
org
.
rcisoft
.
code
.
service
.
impl
;
import
com.alibaba.druid.pool.DruidDataSource
;
import
freemarker.template.Configuration
;
import
freemarker.template.Template
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.lang3.ArrayUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.ibatis.mapping.Environment
;
import
org.apache.ibatis.session.SqlSession
;
import
org.apache.ibatis.session.SqlSessionFactory
;
import
org.apache.ibatis.session.SqlSessionFactoryBuilder
;
import
org.apache.ibatis.transaction.TransactionFactory
;
import
org.apache.ibatis.transaction.jdbc.JdbcTransactionFactory
;
import
org.mybatis.spring.SqlSessionFactoryBean
;
import
org.rcisoft.code.dao.GeneratorRepository
;
import
org.rcisoft.code.model.CodeSchema
;
import
org.rcisoft.code.model.CodeTable
;
import
org.rcisoft.code.service.CodeService
;
...
...
@@ -10,17 +22,23 @@ import org.rcisoft.common.component.FamilyDbUtils;
import
org.rcisoft.common.component.Global
;
import
org.rcisoft.code.model.DbColumnModel
;
import
org.rcisoft.code.model.DbTableModel
;
import
org.rcisoft.core.exception.ServiceException
;
import
org.rcisoft.core.result.ResultSystemExceptionEnums
;
import
org.rcisoft.core.service.BaseService
;
import
org.rcisoft.core.util.DateUtil
;
import
org.rcisoft.core.util.DbUtil
;
import
org.rcisoft.core.util.ZipCompress
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.core.io.support.PathMatchingResourcePatternResolver
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.sql.DataSource
;
import
java.io.File
;
import
java.io.FileWriter
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.sql.Connection
;
import
java.sql.DatabaseMetaData
;
import
java.sql.ResultSet
;
...
...
@@ -72,67 +90,60 @@ public class CodeServiceImpl extends BaseService implements CodeService {
}
@Override
public
String
generateCode
(
CodeSchema
codeSchema
)
{
public
String
generateCode
(
CodeSchema
codeSchema
)
throws
Exception
{
String
filePath
=
null
;
if
(
null
==
codeSchema
.
getTables
()
&&
""
.
equals
(
codeSchema
.
getTables
().
trim
()))
return
null
;
/*blank*/
if
(
StringUtils
.
isBlank
(
codeSchema
.
getTables
()))
throw
new
ServiceException
(
ResultSystemExceptionEnums
.
PARAMETER_ERROR
);
codeSchema
.
setMapperLocations
(
global
.
getMAPPER_LOCATIONS
());
List
<
DbTableModel
>
tableModels
=
new
ArrayList
<
DbTableModel
>();
List
<
DbColumnModel
>
models
=
null
;
/*tables*/
String
[]
tables
=
codeSchema
.
getTables
().
split
(
","
);
Connection
conn
=
familyDbUtils
.
getConnection
(
codeSchema
);;
ResultSet
rs
=
null
;
DatabaseMetaData
dbmd
=
null
;
CodeTable
ct
=
null
;
if
(
ArrayUtils
.
isEmpty
(
tables
))
throw
new
ServiceException
(
ResultSystemExceptionEnums
.
PARAMETER_ERROR
);
DbTableModel
tableModel
=
null
;
DbColumnModel
model
=
null
;
SqlSession
session
=
null
;
/*表描述*/
Map
tableRemarks
=
new
HashMap
<>();
try
{
dbmd
=
(
DatabaseMetaData
)
conn
.
getMetaData
(
);
ResultSet
resultSet
=
dbmd
.
getTables
(
null
,
"%"
,
"%"
,
new
String
[]
{
"TABLE"
});
while
(
resultSet
.
next
())
{
tableRemarks
.
put
(
resultSet
.
getString
(
"TABLE_NAME"
),
resultSet
.
getString
(
"REMARKS"
));
}
session
=
DbUtil
.
getMybatisSqlSessionByCodeSchema
(
codeSchema
);
//获取对象
GeneratorRepository
dao
=
session
.
getMapper
(
GeneratorRepository
.
class
);
if
(
null
==
dao
)
throw
new
ServiceException
(
ResultSystemExceptionEnums
.
ERROR
);
for
(
String
table
:
tables
)
{
// table
tableModel
=
new
DbTableModel
();
// table query
Map
<
String
,
String
>
result
=
dao
.
queryTable
(
table
.
toLowerCase
());
String
tableName
=
(
null
==
result
.
get
(
DbTableModel
.
CONS_TABLE_NAME
)?
""
:
result
.
get
(
DbTableModel
.
CONS_TABLE_NAME
).
toLowerCase
());
tableModel
.
setTableName
(
tableName
);
tableModel
.
setTableRemark
(
result
.
get
(
DbTableModel
.
CONS_TABLE_COMMENT
));
models
=
new
ArrayList
<
DbColumnModel
>();
tableModel
.
setTableName
(
table
.
toLowerCase
());
tableModel
.
setTableRemark
(
tableRemarks
.
get
(
table
).
toString
());
List
<
Map
<
String
,
String
>>
cols
=
dao
.
queryColumns
(
tableName
);
//column
rs
=
(
ResultSet
)
dbmd
.
getColumns
(
null
,
codeSchema
.
getDbName
(),
table
.
toLowerCase
(),
null
);
dbmd
.
getPrimaryKeys
(
null
,
null
,
tables
[
0
].
toLowerCase
())
;
if
(
CollectionUtils
.
isEmpty
(
cols
))
continue
;
boolean
flag
=
false
;
while
(
rs
.
next
())
{
for
(
Map
<
String
,
String
>
col
:
cols
)
{
model
=
new
DbColumnModel
();
/* 根据 CREATE_BY 判断是否存在7个字段 */
if
(
"CREATE_BY"
.
equals
(
rs
.
getString
(
"COLUMN_NAME"
).
toUpperCase
()))
if
(
"CREATE_BY"
.
equals
(
col
.
get
(
DbColumnModel
.
CONS_COLUMN_NAME
).
toUpperCase
()))
flag
=
true
;
model
.
copyColumnFromSql
Result
(
rs
);
model
.
copyColumnFromSql
Map
(
col
);
models
.
add
(
model
);
}
rs
=
(
ResultSet
)
dbmd
.
getPrimaryKeys
(
null
,
codeSchema
.
getDbName
(),
table
.
toLowerCase
());
while
(
rs
.
next
())
{
String
column
=
rs
.
getString
(
"COLUMN_NAME"
);
for
(
DbColumnModel
cm
:
models
){
if
(
column
.
equals
(
cm
.
getColName
())){
cm
.
setKey
(
true
);
break
;
}
}
}
tableModel
.
setIdEntity
(
flag
);
//table -> column
tableModel
.
setColumnModels
(
models
);
tableModels
.
add
(
tableModel
);
}
filePath
=
this
.
productCodeFromTable
(
codeSchema
.
getAuthor
(),
codeSchema
.
getUserId
(),
codeSchema
.
getBasePackage
(),
tableModels
);
filePath
=
this
.
productCodeFromTable
(
codeSchema
.
getAuthor
(),
codeSchema
.
getBasePackage
(),
tableModels
);
}
catch
(
Exception
e
){
log
.
error
(
e
.
getMessage
());
throw
new
ServiceException
(
ResultSystemExceptionEnums
.
ERROR
);
}
finally
{
this
.
killConnection
(
rs
,
conn
);
session
.
close
(
);
}
return
filePath
;
}
...
...
@@ -142,19 +153,19 @@ public class CodeServiceImpl extends BaseService implements CodeService {
* @param tableModels
* @return
*/
private
String
productCodeFromTable
(
String
author
,
String
userId
,
String
packageName
,
List
<
DbTableModel
>
tableModels
)
{
private
String
productCodeFromTable
(
String
author
,
String
packageName
,
List
<
DbTableModel
>
tableModels
)
{
Map
root
=
null
;
List
<
File
>
fileList
=
new
ArrayList
<
File
>();
File
file
=
null
;
String
dirPath
=
global
.
getBaseUploadLocation
()
+
global
.
getCodeGenerateLocation
()
+
File
.
separator
+
userId
+
File
.
separator
+
DateUtil
.
getSimepleDate
(
"yyyyMMddHHmmss"
,
new
Date
());
String
zipPath
=
dirPath
+
".zip"
;
String
zipDirPath
=
dirPath
;
//将. 换/
String
pathPattern
=
"org.rcisoft.business"
.
replaceAll
(
"\\."
,
"\\"
+
File
.
separator
);
packageName
=
StringUtils
.
isBlank
(
packageName
)?
"org.rcisoft.business"
:
packageName
;
String
pathPattern
=
packageName
.
replaceAll
(
"\\."
,
"\\"
+
File
.
separator
);
//存在删除
dirPath
=
dirPath
+
File
.
separator
+
pathPattern
;
//!! 此行一定要在 zipPath 生成后
File
dirF
=
new
File
(
dirPath
);
...
...
@@ -190,7 +201,6 @@ public class CodeServiceImpl extends BaseService implements CodeService {
//5.controller
file
=
this
.
generateEntityModel
(
newPath
,
dbTableModel
,
root
,
"Controller"
);
fileList
.
add
(
file
);
}
ZipCompress
.
compressExe
(
zipDirPath
,
zipPath
);
}
catch
(
Exception
e
)
{
...
...
src/main/java/org/rcisoft/common/component/Global.java
View file @
1b899395
...
...
@@ -41,7 +41,7 @@ public class Global implements Serializable{
private
String
adminCode
;
/*client Code*/
@Value
(
"${global.code.client}"
)
//
@Value("${global.code.client}")
private
String
clientCode
;
/**
...
...
@@ -72,5 +72,7 @@ public class Global implements Serializable{
@Value
(
"${global.path.images_location}"
)
private
String
IMAGES_LOCATION
;
/*mapper 路径*/
@Value
(
"${mybatis.mapper-locations}"
)
private
String
MAPPER_LOCATIONS
;
}
src/main/java/org/rcisoft/core/controller/CommonController.java
View file @
1b899395
...
...
@@ -8,6 +8,7 @@ import org.rcisoft.core.constant.MessageConstant;
import
org.rcisoft.core.model.PersistModel
;
import
org.rcisoft.core.result.Result
;
import
org.rcisoft.core.util.DateUtil
;
import
org.rcisoft.core.util.ResultGenerator
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.PostMapping
;
...
...
@@ -40,7 +41,7 @@ public class CommonController<T> extends FileController<T> {
public
Result
commonFileUpload
(
@RequestParam
(
"file"
)
MultipartFile
file
){
String
filePath
=
super
.
globalCommonFileUpload
(
file
,
super
.
SAVING_PATTERN_UUID
,
global
.
getBaseUploadLocation
()
+
global
.
getTEMP_LOCATION
()
+
File
.
separator
+
DateUtil
.
getSimepleDate
(
"yyyyMMdd"
,
new
Date
()));
return
Result
.
builder
(
new
PersistModel
(
1
),
return
Result
Generator
.
builder
(
new
PersistModel
(
1
),
MessageConstant
.
MESSAGE_ALERT_SUCCESS
,
MessageConstant
.
MESSAGE_ALERT_ERROR
,
filePath
);
...
...
src/main/java/org/rcisoft/core/exception/ServiceException.java
View file @
1b899395
...
...
@@ -2,7 +2,7 @@ package org.rcisoft.core.exception;
import
org.rcisoft.core.result.ResultExceptionEnum
;
import
org.rcisoft.core.result.ResultServiceEnums
;
import
org.rcisoft.core.result.ResultServiceE
xceptionE
nums
;
/**
* Created by lcy on 17/11/24.
...
...
@@ -20,7 +20,7 @@ public class ServiceException extends RuntimeException {
code
=
resultEnum
.
getCode
();
}
public
ServiceException
(
ResultServiceEnums
resultEnums
)
{
public
ServiceException
(
ResultServiceE
xceptionE
nums
resultEnums
)
{
super
(
resultEnums
.
getMessage
());
this
.
code
=
resultEnums
.
getCode
();
}
...
...
src/main/java/org/rcisoft/core/result/Result.java
View file @
1b899395
...
...
@@ -21,14 +21,7 @@ public class Result {
* @param data
* @return
*/
public
static
Result
builder
(
PersistModel
dataModel
,
String
sucMessage
,
String
errMessage
,
Object
data
){
Result
result
=
new
Result
();
if
(
dataModel
.
isSuccessBySinglePersist
())
result
.
setSucessMessage
(
sucMessage
,
data
);
else
result
.
setErrorMessage
(
errMessage
,
data
);
return
result
;
}
...
...
src/main/java/org/rcisoft/core/result/ResultCode.java
View file @
1b899395
...
...
@@ -4,12 +4,18 @@ package org.rcisoft.core.result;
* 响应码枚举,参考HTTP状态码的语义
*/
public
enum
ResultCode
{
SUCCESS
(
200
),
//成功
FAIL
(
400
),
//失败
UNAUTHORIZED
(
401
),
//未认证(签名错误)
UNAUTHENTICATED
(
402
),
//未授权(权限不够)
NOT_FOUND
(
404
),
//接口不存在
INTERNAL_SERVER_ERROR
(
500
);
//服务器内部错误
INTERNAL_SERVER_ERROR
(
500
),
//服务器内部错误
PARAMETER_ERROR
(
601
),
//参数错误
DATA_EXISTS
(
602
);
//数据已存在
public
int
code
;
...
...
src/main/java/org/rcisoft/core/result/ResultServiceExceptionEnums.java
View file @
1b899395
package
org
.
rcisoft
.
core
.
result
;
import
lombok.AllArgsConstructor
;
import
lombok.Getter
;
import
lombok.NoArgsConstructor
;
/**
* Created by Administrator on 2017/11/27.
*/
public
enum
ResultServiceExceptionEnums
{
SUCCESS
(
0
,
"操作成功"
),
EXCEL_IMPORT_DATA_NOT_EXIST
(
11
,
"Excel中没有找到任何完整有效的数据"
),
EXCEL_IMPORT_HEADER_ERROR
(
12
,
"excel表头信息错误,导入失败"
),
EXCEL_IMPORT_DB_INSERT_ERROR
(
13
,
"数据库插入失败"
),
INSERT_DATA_EXIST
(
14
,
"该信息已经存在"
),
ADD_ERROR
(
15
,
"添加异常"
),
UPDATE_PASSWORD_ERROR
(
16
,
"修改密码异常"
),
LOGIN_PARAMETER_ERROR
(
17
,
"用户名或者密码不正确"
),
LOGIN_AUTHORIZATION_ERROR
(
18
,
"不合法的token值"
),
LOGIN_HEADER_ERROR
(
19
,
"不合法的Authorization header"
),
@Getter
@NoArgsConstructor
@AllArgsConstructor
public
enum
ResultServiceExceptionEnums
implements
ResultExceptionEnum
{
PARAMETER_ERROR
(
20
,
"参数错误"
),
/*-----------4000起-----*/
EXCEL_IMPORT_HEADER_ERROR
(
4002
,
"excel表头信息错误,导入失败"
),
UPLOAD_FILE_ERROR
(
26
,
"上传图片失败"
),
INSERT_ERROR
(
33
,
"添加失败"
),
PASSWORD_ENCODE
(
35
,
"密码加密异常"
),
UPDATE_ERROR
(
36
,
"操作失败"
),
ROLE_ERROR
(
46
,
"权限错误"
),
PASSWORD_ERROR
(
63
,
"原密码错误"
),
PASSWORD_LENGTH_ERROR
(
65
,
"密码长度必须在6到16位之间"
);
USER_EXISTS
(
4003
,
"用户已存储"
);
private
Integer
code
;
private
String
message
;
ResultServiceEnums
(
Integer
code
,
String
message
)
{
this
.
code
=
code
;
this
.
message
=
message
;
}
public
Integer
getCode
()
{
return
code
;
}
public
String
getMessage
()
{
return
message
;
}
}
src/main/java/org/rcisoft/core/result/ResultSystemExceptionEnums.java
View file @
1b899395
package
org
.
rcisoft
.
core
.
result
;
import
lombok.AllArgsConstructor
;
import
lombok.Getter
;
import
lombok.NoArgsConstructor
;
/**
* Created with family.
* author: cy
...
...
@@ -7,5 +11,25 @@ package org.rcisoft.core.result;
* Time: 下午2:54
* description:
*/
public
class
ResultSystemExceptionEnum
{
@Getter
@NoArgsConstructor
@AllArgsConstructor
public
enum
ResultSystemExceptionEnums
implements
ResultExceptionEnum
{
ERROR
(
ResultCode
.
INTERNAL_SERVER_ERROR
.
code
,
"系统错误"
),
FAIL
(
ResultCode
.
FAIL
.
code
,
"操作失败"
),
PARAMETER_ERROR
(
ResultCode
.
PARAMETER_ERROR
.
code
,
"参数错误"
),
DATA_EXISTS
(
ResultCode
.
DATA_EXISTS
.
code
,
"数据已存在"
),
/**
* 系统常用 1000起
*/
EXCEL_IMPORT_HEADER_ERROR
(
1001
,
"excel表头信息错误,导入失败"
),
;
private
Integer
code
;
private
String
message
;
}
src/main/java/org/rcisoft/core/service/impl/AuthenticationServiceImpl.java
View file @
1b899395
...
...
@@ -3,6 +3,8 @@ package org.rcisoft.core.service.impl;
import
org.rcisoft.common.component.Global
;
import
org.rcisoft.core.exception.ServiceException
;
import
org.rcisoft.core.result.ResultExceptionEnum
;
import
org.rcisoft.core.result.ResultServiceExceptionEnums
;
import
org.rcisoft.core.result.ResultSystemExceptionEnums
;
import
org.rcisoft.core.service.AuthenticationService
;
import
org.rcisoft.core.util.JwtUtil
;
import
org.rcisoft.sys.role.dao.SysRoleRepository
;
...
...
@@ -57,11 +59,11 @@ public class AuthenticationServiceImpl implements AuthenticationService {
Example
.
Criteria
criteria
=
example
.
createCriteria
();
List
<
SysUser
>
sysUser
=
sysUserMapper
.
selectByExample
(
example
);
if
(
sysUser
.
size
()
>
0
)
throw
new
ServiceException
(
Result
ExceptionEnum
.
USER_EXISTS
);
throw
new
ServiceException
(
Result
ServiceExceptionEnums
.
USER_EXISTS
);
userToAdd
.
setPassword
(
passwordEncoder
.
encode
(
userToAdd
.
getPassword
()));
int
result
=
sysUserMapper
.
insertSelective
(
userToAdd
);
if
(
result
==
0
)
throw
new
ServiceException
(
Result
ExceptionEnum
.
SAVE_ERROR
);
throw
new
ServiceException
(
Result
SystemExceptionEnums
.
FAIL
);
}
@Override
...
...
src/main/java/org/rcisoft/core/util/DbUtil.java
View file @
1b899395
package
org
.
rcisoft
.
core
.
util
;
import
com.alibaba.druid.pool.DruidDataSource
;
import
org.apache.ibatis.session.SqlSession
;
import
org.apache.ibatis.session.SqlSessionFactory
;
import
org.mybatis.spring.SqlSessionFactoryBean
;
import
org.rcisoft.code.model.CodeSchema
;
import
org.springframework.core.io.support.PathMatchingResourcePatternResolver
;
import
java.io.IOException
;
import
java.util.Properties
;
/**
* Created with family.
* author: cy
...
...
@@ -8,4 +18,29 @@ package org.rcisoft.core.util;
* description:
*/
public
class
DbUtil
{
/**
* 根据 schema 获取 mybatis sqlsession
* @return
*/
public
static
SqlSession
getMybatisSqlSessionByCodeSchema
(
CodeSchema
codeSchema
)
throws
Exception
{
if
(
null
==
codeSchema
)
return
null
;
Properties
properties
=
new
Properties
();
properties
.
setProperty
(
"useSSL"
,
"false"
);
/*druid*/
DruidDataSource
druidDataSource
=
new
DruidDataSource
();
druidDataSource
.
setUrl
(
codeSchema
.
getUrl
());
druidDataSource
.
setUsername
(
codeSchema
.
getUsername
());
druidDataSource
.
setPassword
(
codeSchema
.
getPassword
());
druidDataSource
.
setDriverClassName
(
codeSchema
.
getDriverClass
());
druidDataSource
.
setConnectProperties
(
properties
);
/*sqlsession*/
SqlSessionFactoryBean
factoryBean
=
new
SqlSessionFactoryBean
();
factoryBean
.
setDataSource
(
druidDataSource
);
PathMatchingResourcePatternResolver
resolver
=
new
PathMatchingResourcePatternResolver
();
factoryBean
.
setMapperLocations
(
resolver
.
getResources
(
codeSchema
.
getMapperLocations
()));
SqlSessionFactory
factory
=
factoryBean
.
getObject
();
return
factory
.
openSession
();
}
}
src/main/java/org/rcisoft/core/util/DecryptDBPasswordUtility.java
View file @
1b899395
...
...
@@ -4,7 +4,8 @@ package org.rcisoft.core.util;
import
com.alibaba.druid.util.Base64
;
import
com.alibaba.druid.util.JdbcUtils
;
import
org.rcisoft.core.exception.ServiceException
;
import
org.rcisoft.core.result.ResultServiceEnums
;
import
org.rcisoft.core.result.ResultServiceExceptionEnums
;
import
org.rcisoft.core.result.ResultSystemExceptionEnums
;
import
javax.crypto.Cipher
;
import
java.io.ByteArrayOutputStream
;
...
...
@@ -139,7 +140,7 @@ public class DecryptDBPasswordUtility {
return
encrypt
((
String
)
null
,
plainText
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
new
ServiceException
(
ResultS
erviceEnums
.
PASSWORD_ENCODE
);
throw
new
ServiceException
(
ResultS
ystemExceptionEnums
.
PARAMETER_ERROR
);
}
}
...
...
src/main/java/org/rcisoft/core/util/ExcelUtil.java
View file @
1b899395
...
...
@@ -6,7 +6,7 @@ import org.apache.poi.hssf.usermodel.HSSFSheet;
import
org.apache.poi.hssf.usermodel.HSSFWorkbook
;
import
org.apache.poi.ss.usermodel.CellType
;
import
org.rcisoft.core.exception.ServiceException
;
import
org.rcisoft.core.result.ResultServiceEnums
;
import
org.rcisoft.core.result.ResultServiceE
xceptionE
nums
;
import
java.text.DecimalFormat
;
import
java.util.ArrayList
;
...
...
@@ -69,7 +69,7 @@ public class ExcelUtil {
if
(
j
==
firstrownum
+
1
){
for
(
int
h
=
0
;
h
<
headers
.
length
;
h
++){
if
(!
value
[
h
].
trim
().
equals
(
headers
[
h
]))
throw
new
ServiceException
(
ResultServiceEnums
.
EXCEL_IMPORT_HEADER_ERROR
);
throw
new
ServiceException
(
ResultServiceE
xceptionE
nums
.
EXCEL_IMPORT_HEADER_ERROR
);
}
}
else
{
if
(!
hasEmpty
)
{
...
...
src/main/java/org/rcisoft/core/util/ResultGenerator.java
View file @
1b899395
package
org
.
rcisoft
.
core
.
util
;
import
org.rcisoft.core.model.PersistModel
;
import
org.rcisoft.core.result.Result
;
import
org.rcisoft.core.result.ResultCode
;
...
...
@@ -10,6 +11,16 @@ import org.rcisoft.core.result.ResultCode;
public
class
ResultGenerator
{
private
static
final
String
DEFAULT_SUCCESS_MESSAGE
=
"SUCCESS"
;
public
static
Result
builder
(
PersistModel
dataModel
,
String
sucMessage
,
String
errMessage
,
Object
data
){
Result
result
=
new
Result
();
if
(
dataModel
.
isSuccessBySinglePersist
())
result
.
setSucessMessage
(
sucMessage
,
data
);
else
result
.
setErrorMessage
(
errMessage
,
data
);
return
result
;
}
public
static
Result
genSuccessResult
()
{
return
new
Result
()
.
setCode
(
ResultCode
.
SUCCESS
)
...
...
src/main/java/org/rcisoft/core/util/UserUtil.java
View file @
1b899395
package
org
.
rcisoft
.
core
.
util
;
import
io.jsonwebtoken.Claims
;
import
org.apache.commons.lang3.StringUtils
;
import
org.rcisoft.core.entity.IdEntity
;
import
org.rcisoft.core.model.JwtUser
;
import
org.springframework.security.core.Authentication
;
...
...
@@ -29,6 +30,8 @@ public class UserUtil {
* @return
*/
public
static
String
getUserInfoProp
(
String
token
,
String
prop
){
if
(
StringUtils
.
isBlank
(
token
))
return
null
;
Claims
claims
=
JwtUtil
.
getUserClaimsFromToken
(
token
);
return
claims
.
get
(
prop
).
toString
();
}
...
...
src/main/java/org/rcisoft/sys/dept/controller/SysDeptController.java
View file @
1b899395
...
...
@@ -9,6 +9,7 @@ import org.rcisoft.core.constant.MessageConstant;
import
org.rcisoft.core.controller.ResponseController
;
import
org.rcisoft.core.model.PersistModel
;
import
org.rcisoft.core.result.Result
;
import
org.rcisoft.core.util.ResultGenerator
;
import
org.rcisoft.sys.dept.entity.SysDept
;
import
org.rcisoft.sys.dept.service.SysDeptService
;
import
org.rcisoft.sys.role.entity.SysRole
;
...
...
@@ -86,7 +87,7 @@ public class SysDeptController extends ResponseController {
@PostMapping
(
"adminLog/deptAdd"
)
public
Result
deptAdd
(
@Valid
SysDept
dept
,
BindingResult
br
){
PersistModel
persistModel
=
sysDeptServiceImpl
.
persistDept
(
dept
,
getToken
());
return
Result
.
builder
(
persistModel
,
return
Result
Generator
.
builder
(
persistModel
,
MessageConstant
.
MESSAGE_ALERT_SUCCESS
,
MessageConstant
.
MESSAGE_ALERT_ERROR
,
dept
);
...
...
@@ -108,7 +109,7 @@ public class SysDeptController extends ResponseController {
public
Result
deptUpdate
(
@Valid
SysDept
dept
,
BindingResult
br
){
PersistModel
persistModel
=
sysDeptServiceImpl
.
mergeDept
(
dept
,
getToken
());
return
Result
.
builder
(
persistModel
,
return
Result
Generator
.
builder
(
persistModel
,
MessageConstant
.
MESSAGE_ALERT_SUCCESS
,
MessageConstant
.
MESSAGE_ALERT_ERROR
,
dept
);
...
...
@@ -119,7 +120,7 @@ public class SysDeptController extends ResponseController {
@PostMapping
(
"adminLog/deptDelete/{id}"
)
public
Result
deptDelete
(
@PathVariable
(
"id"
)
String
id
){
PersistModel
persistModel
=
sysDeptServiceImpl
.
removeDept
(
id
,
getToken
());
return
Result
.
builder
(
persistModel
,
return
Result
Generator
.
builder
(
persistModel
,
MessageConstant
.
MESSAGE_ALERT_SUCCESS
,
MessageConstant
.
MESSAGE_ALERT_ERROR
,
id
);
...
...
src/main/java/org/rcisoft/sys/menu/controller/SysMenuController.java
View file @
1b899395
...
...
@@ -10,6 +10,7 @@ import org.rcisoft.core.constant.MessageConstant;
import
org.rcisoft.core.controller.ResponseController
;
import
org.rcisoft.core.model.PersistModel
;
import
org.rcisoft.core.result.Result
;
import
org.rcisoft.core.util.ResultGenerator
;
import
org.rcisoft.sys.menu.entity.SysMenu
;
import
org.rcisoft.sys.menu.service.SysMenuService
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -50,7 +51,7 @@ public class SysMenuController extends ResponseController {
public
Result
queryMenuById
(
@PathVariable
(
"id"
)
String
id
){
SysMenu
menu
=
sysMenuServiceImpl
.
queryMenuById
(
id
);
return
Result
.
builder
(
new
PersistModel
(
1
),
return
Result
Generator
.
builder
(
new
PersistModel
(
1
),
MessageConstant
.
MESSAGE_ALERT_SUCCESS
,
MessageConstant
.
MESSAGE_ALERT_ERROR
,
menu
);
...
...
@@ -83,7 +84,7 @@ public class SysMenuController extends ResponseController {
@PostMapping
(
"adminLog/menuAdd"
)
public
Result
menuAdd
(
@Valid
SysMenu
menu
,
BindingResult
br
){
PersistModel
persistModel
=
sysMenuServiceImpl
.
persistMenu
(
menu
,
getToken
());
return
Result
.
builder
(
persistModel
,
return
Result
Generator
.
builder
(
persistModel
,
MessageConstant
.
MESSAGE_ALERT_SUCCESS
,
MessageConstant
.
MESSAGE_ALERT_ERROR
,
menu
);
...
...
@@ -107,7 +108,7 @@ public class SysMenuController extends ResponseController {
@PostMapping
(
"adminLog/menuUpdate"
)
public
Result
menuUpdate
(
@Valid
SysMenu
menu
,
BindingResult
br
){
PersistModel
persistModel
=
sysMenuServiceImpl
.
mergeMenu
(
menu
,
getToken
());
return
Result
.
builder
(
persistModel
,
return
Result
Generator
.
builder
(
persistModel
,
MessageConstant
.
MESSAGE_ALERT_SUCCESS
,
MessageConstant
.
MESSAGE_ALERT_ERROR
,
menu
);
...
...
@@ -119,7 +120,7 @@ public class SysMenuController extends ResponseController {
public
Result
menuDelete
(
@PathVariable
(
"id"
)
String
id
){
PersistModel
persistModel
=
sysMenuServiceImpl
.
removeMenu
(
id
,
getToken
());
return
Result
.
builder
(
persistModel
,
return
Result
Generator
.
builder
(
persistModel
,
MessageConstant
.
MESSAGE_ALERT_SUCCESS
,
MessageConstant
.
MESSAGE_ALERT_ERROR
,
id
);
...
...
@@ -132,7 +133,7 @@ public class SysMenuController extends ResponseController {
public
Result
menusByModels
(
@PathVariable
(
"model"
)
String
model
,
String
selectId
){
CommonMenuModel
menuModel
=
sysMenuServiceImpl
.
queryMenusListByModels
(
model
,
selectId
);
return
Result
.
builder
(
new
PersistModel
(
1
),
return
Result
Generator
.
builder
(
new
PersistModel
(
1
),
"查询成功"
,
MessageConstant
.
MESSAGE_ALERT_ERROR
,
menuModel
);
...
...
src/main/java/org/rcisoft/sys/role/controller/SysRoleController.java
View file @
1b899395
...
...
@@ -8,6 +8,7 @@ import org.rcisoft.core.controller.PaginationController;
import
org.rcisoft.core.model.GridModel
;
import
org.rcisoft.core.model.PersistModel
;
import
org.rcisoft.core.result.Result
;
import
org.rcisoft.core.util.ResultGenerator
;
import
org.rcisoft.sys.role.entity.SysRole
;
import
org.rcisoft.sys.role.service.SysRoleService
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -79,13 +80,13 @@ public class SysRoleController extends PaginationController<SysRole> {
public
Result
roleAdd
(
@Valid
SysRole
sysRole
,
BindingResult
br
){
PersistModel
persistModel
=
sysRoleServiceImpl
.
persistRole
(
sysRole
,
getToken
());
if
(
persistModel
.
isSuccessBySinglePersist
())
return
Result
.
builder
(
new
PersistModel
(
1
),
return
Result
Generator
.
builder
(
new
PersistModel
(
1
),
MessageConstant
.
MESSAGE_ALERT_SUCCESS
,
MessageConstant
.
MESSAGE_ALERT_ERROR
,
sysRole
);
else
return
Result
.
builder
(
new
PersistModel
(
2
),
return
Result
Generator
.
builder
(
new
PersistModel
(
2
),
MessageConstant
.
MESSAGE_ALERT_SUCCESS
,
MessageConstant
.
MESSAGE_ALERT_ERROR
,
sysRole
);
...
...
@@ -109,7 +110,7 @@ public class SysRoleController extends PaginationController<SysRole> {
@PostMapping
(
value
=
"adminLog/roleUpdate"
)
public
Result
roleUpdate
(
@Valid
SysRole
sysRole
,
BindingResult
br
){
PersistModel
persistModel
=
sysRoleServiceImpl
.
mergeRole
(
sysRole
,
getToken
());
return
Result
.
builder
(
persistModel
,
return
Result
Generator
.
builder
(
persistModel
,
MessageConstant
.
MESSAGE_ALERT_SUCCESS
,
MessageConstant
.
MESSAGE_ALERT_ERROR
,
null
);
...
...
@@ -122,12 +123,12 @@ public class SysRoleController extends PaginationController<SysRole> {
PersistModel
persistModel
=
sysRoleServiceImpl
.
removeRole
(
id
,
getToken
());
if
(
persistModel
.
isSuccessBySinglePersist
())
return
Result
.
builder
(
new
PersistModel
(
1
),
return
Result
Generator
.
builder
(
new
PersistModel
(
1
),
MessageConstant
.
MESSAGE_ALERT_SUCCESS
,
MessageConstant
.
MESSAGE_ALERT_ERROR
,
id
);
else
return
Result
.
builder
(
new
PersistModel
(
2
),
return
Result
Generator
.
builder
(
new
PersistModel
(
2
),
MessageConstant
.
MESSAGE_ALERT_SUCCESS
,
MessageConstant
.
MESSAGE_ALERT_ERROR
,
id
);
...
...
@@ -141,12 +142,12 @@ public class SysRoleController extends PaginationController<SysRole> {
PersistModel
persistModel
=
sysRoleServiceImpl
.
doAuthorization
(
roleId
,
role_menus
,
getToken
());
if
(
persistModel
.
isSuccessBySinglePersist
())
return
Result
.
builder
(
new
PersistModel
(
1
),
return
Result
Generator
.
builder
(
new
PersistModel
(
1
),
MessageConstant
.
MESSAGE_ALERT_SUCCESS
,
MessageConstant
.
MESSAGE_ALERT_ERROR
,
roleId
);
else
return
Result
.
builder
(
new
PersistModel
(
2
),
return
Result
Generator
.
builder
(
new
PersistModel
(
2
),
MessageConstant
.
MESSAGE_ALERT_ERROR
,
MessageConstant
.
MESSAGE_ALERT_ERROR
,
roleId
);
...
...
@@ -158,7 +159,7 @@ public class SysRoleController extends PaginationController<SysRole> {
@PostMapping
(
value
=
"adminLog/deptPermission"
)
public
Result
deptPermission
(
@RequestParam
(
"roleId"
)
String
roleId
,
@RequestParam
(
"role_depts"
)
String
role_depts
){
PersistModel
persistModel
=
sysRoleServiceImpl
.
doAuthorizationDept
(
roleId
,
role_depts
,
getToken
());
return
Result
.
builder
(
persistModel
,
return
Result
Generator
.
builder
(
persistModel
,
MessageConstant
.
MESSAGE_ALERT_SUCCESS
,
MessageConstant
.
MESSAGE_ALERT_ERROR
,
roleId
);
...
...
src/main/java/org/rcisoft/sys/user/service/impl/SysUserServiceImpl.java
View file @
1b899395
...
...
@@ -3,7 +3,8 @@ package org.rcisoft.sys.user.service.impl;
import
org.rcisoft.core.constant.UserConstant
;
import
org.rcisoft.core.exception.ServiceException
;
import
org.rcisoft.core.model.PersistModel
;
import
org.rcisoft.core.result.ResultServiceEnums
;
import
org.rcisoft.core.result.ResultServiceExceptionEnums
;
import
org.rcisoft.core.result.ResultSystemExceptionEnums
;
import
org.rcisoft.core.util.UserUtil
;
import
org.rcisoft.sys.user.dao.SysUserMapper
;
import
org.rcisoft.sys.user.entity.SysUser
;
...
...
@@ -45,7 +46,7 @@ public class SysUserServiceImpl implements SysUserService {
user
.
setBusinessId
(
uid
);
int
l1
=
sysUserMapper
.
updateByPrimaryKeySelective
(
user
);
if
(
l1
!=
line
)
throw
new
ServiceException
(
ResultS
erviceEnums
.
UPDATE_ERROR
);
throw
new
ServiceException
(
ResultS
ystemExceptionEnums
.
FAIL
);
}
}
}
src/main/resources/application-dev.yml
View file @
1b899395
server
:
port
:
8082
context-path
:
/
project
#ContextPath must start with '/' and not end with '/'
context-path
:
/
#ContextPath must start with '/' and not end with '/'
tomcat
:
max-threads
:
300
#uri-encoding: UTF-8
...
...
@@ -21,7 +21,7 @@ druid:
mybatis
:
mapper-locations
:
classpath:mapper/**/**/*.xml
mapper-locations
:
"
classpath*:mapper/**/**/*.xml"
mapper
:
...
...
src/main/resources/templates/codeftl/controller.ftl
View file @
1b899395
package
org
.
rcisoft
.
business
.${
table
.
entityName
?
lower_case
}.
controller
;
package
${
basePackage
!
}.controller;
/*
固定导入
*/
...
...
@@ -10,7 +10,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org
.
springframework
.
web
.
bind
.
annotation
.*;
import
org
.
rcisoft
.
core
.
result
.
Result
;
import
org
.
rcisoft
.
core
.
result
.
ResultServiceEnums
;
import
org
.
rcisoft
.
core
.
util
.
ResultGenerator
;
import
org
.
rcisoft
.
core
.
model
.
PersistModel
;
import
org
.
rcisoft
.
core
.
constant
.
MessageConstant
;
import
org
.
rcisoft
.
core
.
controller
.
PaginationController
;
...
...
@@ -20,73 +20,91 @@ import org.rcisoft.core.exception.ServiceException;
import
javax
.
validation
.
Valid
;
import
org
.
rcisoft
.
business
.${
table
.
entityName
?
lower_case
}.
entity
.${
table
.
entityName
};
import
org
.
rcisoft
.
business
.${
table
.
entityName
?
lower_case
}.
service
.${
table
.
entityName
}
Service
;
import
${
basePackage
!}.entity.${table.entityName!
};
import
${
basePackage
!}.service.${table.entityName!
}Service;
import
java
.
util
.
List
;
/**
*
Created
by
${
author
}
on
${.
now
}.
*
Created
by
${
author
!
} on ${.now}.
*/
@
RestController
@
RequestMapping
(
"${table.entityName?lower_case}"
)
public
class
${
table
.
entityName
}
Controller
extends
PaginationController
<${
table
.
entityName
}>
{
@
RequestMapping
(
"
/
${table.entityName?lower_case}"
)
public
class
${
table
.
entityName
!}Controller extends PaginationController<${table.entityName!
}> {
@
Autowired
private
${
table
.
entityName
}
Service
${
table
.
entityName
?
uncap_first
}
ServiceImpl
;
private
${
table
.
entityName
!
}Service ${table.entityName?uncap_first}ServiceImpl;
@
ApiOperation
(
value
=
"添加${table.tableRemark!}"
,
notes
=
"添加${table.tableRemark!}"
)
//@
ApiImplicitParams
({@
ApiImplicitParam
(
name
=
"businessId"
,
value
=
"businessId"
,
required
=
false
,
dataType
=
"varchar"
)})
@
PostMapping
(
value
=
"/add"
)
public
Result
add
(@
Valid
${
table
.
entityName
}
${
table
.
entityName
?
uncap_first
},
BindingResult
bindingResult
)
{
${
table
.
entityName
?
uncap_first
}.
setToken
(
getToken
());
public
Result
add
(@
Valid
${
table
.
entityName
!} ${table.entityName?uncap_first}, BindingResult bindingResult) {
PersistModel
data
=
${
table
.
entityName
?
uncap_first
}
ServiceImpl
.
save
(${
table
.
entityName
?
uncap_first
});
return
Result
.
builder
(
data
,
return
Result
Generator
.
builder
(
data
,
MessageConstant
.
MESSAGE_ALERT_SUCCESS
,
MessageConstant
.
MESSAGE_ALERT_ERROR
,
${
table
.
entityName
?
uncap_first
});
}
@
ApiOperation
(
value
=
"逻辑删除${table.tableRemark!}"
,
notes
=
"逻辑删除${table.tableRemark!}"
)
@
ApiImplicitParams
({@
ApiImplicitParam
(
name
=
"id"
,
value
=
"id"
,
required
=
false
,
dataType
=
"varchar"
)})
@
DeleteMapping
(
"/delete/{id:
\\
w+}"
)
public
Result
delete
(@
PathVariable
String
id
)
{
${
table
.
entityName
}
${
table
.
entityName
?
uncap_first
}
=
new
${
table
.
entityName
}();
${
table
.
entityName
?
uncap_first
}.
setBusinessId
(
id
);
${
table
.
entityName
?
uncap_first
}.
setToken
(
getToken
());
@
ApiImplicitParams
({@
ApiImplicitParam
(
name
=
"businessId"
,
value
=
"businessId"
,
required
=
true
,
dataType
=
"varchar"
)})
@
DeleteMapping
(
"/deleteLogical/{businessId:
\\
w+}"
)
public
Result
deleteLogical
(@
PathVariable
String
businessId
,${
table
.
entityName
!} ${table.entityName?uncap_first}) {
${
table
.
entityName
?
uncap_first
}.
setBusinessId
(
businessId
);
PersistModel
data
=
${
table
.
entityName
?
uncap_first
}
ServiceImpl
.
removeLogical
(${
table
.
entityName
?
uncap_first
});
return
ResultGenerator
.
builder
(
data
,
MessageConstant
.
MESSAGE_ALERT_SUCCESS
,
MessageConstant
.
MESSAGE_ALERT_ERROR
,
businessId
);
}
@
ApiOperation
(
value
=
"删除${table.tableRemark!}"
,
notes
=
"删除${table.tableRemark!}"
)
@
ApiImplicitParams
({@
ApiImplicitParam
(
name
=
"businessId"
,
value
=
"businessId"
,
required
=
true
,
dataType
=
"varchar"
)})
@
DeleteMapping
(
"/delete/{businessId:
\\
w+}"
)
public
Result
delete
(@
PathVariable
String
businessId
,${
table
.
entityName
!} ${table.entityName?uncap_first}) {
${
table
.
entityName
?
uncap_first
}.
setBusinessId
(
businessId
);
PersistModel
data
=
${
table
.
entityName
?
uncap_first
}
ServiceImpl
.
remove
(${
table
.
entityName
?
uncap_first
});
return
Result
.
builder
(
data
,
return
Result
Generator
.
builder
(
data
,
MessageConstant
.
MESSAGE_ALERT_SUCCESS
,
MessageConstant
.
MESSAGE_ALERT_ERROR
,
i
d
);
businessI
d
);
}
@
ApiOperation
(
value
=
"修改${table.tableRemark!}"
,
notes
=
"修改${table.tableRemark!}"
)
@
ApiImplicitParams
({@
ApiImplicitParam
(
name
=
"businessId"
,
value
=
"businessId"
,
required
=
false
,
dataType
=
"varchar"
)})
@
PutMapping
(
"/update/{
i
d:
\\
w+}"
)
public
Result
update
(@
Valid
${
table
.
entityName
}
${
table
.
entityName
?
uncap_first
},
BindingResult
bindingResult
)
{
${
table
.
entityName
?
uncap_first
}.
set
Token
(
getToken
()
);
@
PutMapping
(
"/update/{
businessI
d:
\\
w+}"
)
public
Result
update
(@
PathVariable
String
businessId
,
@
Valid
${
table
.
entityName
!
} ${table.entityName?uncap_first}, BindingResult bindingResult) {
${
table
.
entityName
?
uncap_first
}.
set
BusinessId
(
businessId
);
PersistModel
data
=
${
table
.
entityName
?
uncap_first
}
ServiceImpl
.
merge
(${
table
.
entityName
?
uncap_first
});
return
Result
.
builder
(
data
,
return
Result
Generator
.
builder
(
data
,
MessageConstant
.
MESSAGE_ALERT_SUCCESS
,
MessageConstant
.
MESSAGE_ALERT_ERROR
,
${
table
.
entityName
?
uncap_first
});
}
@
ApiOperation
(
value
=
"查看单 ${table.tableRemark!}"
,
notes
=
"查看单 ${table.tableRemark!}"
)
@
GetMapping
(
"/detail/{id:
\\
w+}"
)
public
Result
detail
(@
PathVariable
String
id
)
{
return
Result
.
builder
(
new
PersistModel
(
1
),
@
ApiOperation
(
value
=
"查询单一${table.tableRemark!}"
,
notes
=
"查询单一${table.tableRemark!}"
)
@
ApiImplicitParams
({@
ApiImplicitParam
(
name
=
"businessId"
,
value
=
"businessId"
,
required
=
true
,
dataType
=
"varchar"
)})
@
GetMapping
(
"/detail/{businessId:
\\
w+}"
)
public
Result
detail
(@
PathVariable
String
businessId
)
{
return
ResultGenerator
.
builder
(
new
PersistModel
(
1
),
MessageConstant
.
MESSAGE_ALERT_SUCCESS
,
MessageConstant
.
MESSAGE_ALERT_ERROR
,
${
table
.
entityName
?
uncap_first
}
ServiceImpl
.
findById
(
businessId
));
}
@
ApiOperation
(
value
=
"查询${table.tableRemark!}集合"
,
notes
=
"查询${table.tableRemark!}集合"
)
@
GetMapping
(
value
=
"/query${table.entityName!}s"
)
public
Result
query
${
table
.
entityName
!}s(${table.entityName!} ${table.entityName?uncap_first}) {
return
ResultGenerator
.
builder
(
new
PersistModel
(
1
),
MessageConstant
.
MESSAGE_ALERT_SUCCESS
,
MessageConstant
.
MESSAGE_ALERT_ERROR
,
${
table
.
entityName
?
uncap_first
}
ServiceImpl
.
findById
(
id
));
${
table
.
entityName
?
uncap_first
}
ServiceImpl
.
findAll
(${
table
.
entityName
?
uncap_first
}
));
}
@
ApiOperation
(
value
=
"查看 ${table.tableRemark!} 集合"
,
notes
=
"查看 ${table.tableRemark!} 集合"
)
@
GetMapping
(
value
=
"/query${table.entityName}ByPagination"
)
public
GridModel
listByPagination
(${
table
.
entityName
}
${
table
.
entityName
?
uncap_first
})
{
${
table
.
entityName
?
uncap_first
}.
setCreateBy
(
UserUtil
.
getUserInfoProp
(
getToken
(),
UserUtil
.
USER_ID
));
@
ApiOperation
(
value
=
"分页查询${table.tableRemark!}集合"
,
notes
=
"分页查询${table.tableRemark!}集合"
)
@
GetMapping
(
value
=
"/query${table.entityName!}ByPagination"
)
public
GridModel
listByPagination
(${
table
.
entityName
!} ${table.entityName?uncap_first}) {
${
table
.
entityName
?
uncap_first
}
ServiceImpl
.
findAllByPagination
(
getPaginationUtility
(),
${
table
.
entityName
?
uncap_first
});
return
getGridModelResponse
();
}
...
...
src/main/resources/templates/codeftl/entity.ftl
View file @
1b899395
package
org
.
rcisoft
.
business
.${
table
.
entityName
?
lower_case
}.
entity
;
package
${
basePackage
!
}.entity;
import
lombok
.*;
...
...
@@ -17,8 +17,8 @@ import java.util.List;
@
Data
@
NoArgsConstructor
@
AllArgsConstructor
@
Table
(
name
=
"${table.tableName}"
)
public
class
${
table
.
entityName
}
extends
IdEntity
<${
table
.
entityName
}>
{
@
Table
(
name
=
"${table.tableName
!
}"
)
public
class
${
table
.
entityName
!} extends IdEntity<${table.entityName!
}> {
<#
list
table
.
columnModels
as
item
>
...
...
@@ -31,7 +31,12 @@ public class ${table.entityName} extends IdEntity<${table.entityName}> {
item
.
columnNameLowerCamel
!='delFlag'&&
item
.
columnNameLowerCamel
!='flag'>
private
${
item
.
javaType
}
${
item
.
columnNameLowerCamel
};
/**
*
@
desc
${
item
.
remarks
!}
*
@
column
${
item
.
colName
!}
*
@
default
${
item
.
defaultValue
!}
*/
private
${
item
.
javaType
!} ${item.columnNameLowerCamel!};
</#
if
>
</#
list
>
...
...
src/main/resources/templates/codeftl/entityNotCommon.ftl
View file @
1b899395
package
org
.
rcisoft
.
business
.${
table
.
entityName
?
lower_case
}.
entity
;
package
${
basePackage
!
}.entity;
import
lombok
.*;
...
...
@@ -11,20 +11,24 @@ import java.util.Date;
import
java
.
util
.
List
;
/**
*
Created
with
${
author
}
on
${.
now
}.
*
Created
with
${
author
!
} on ${.now}.
*/
@
Entity
@
Data
@
NoArgsConstructor
@
AllArgsConstructor
@
Table
(
name
=
"${table.tableName}"
)
public
class
${
table
.
entityName
}
extends
IdNotDataEntity
<${
table
.
entityName
}>
{
@
Table
(
name
=
"${table.tableName
!
}"
)
public
class
${
table
.
entityName
!} extends IdNotDataEntity<${table.entityName!
}> {
<#
list
table
.
columnModels
as
item
>
<#
if
item
.
columnNameLowerCamel
!='businessId'>
private
${
item
.
javaType
}
${
item
.
columnNameLowerCamel
};
/**
*
@
desc
${
item
.
remarks
!}
*
@
column
${
item
.
colName
!}
*
@
default
${
item
.
defaultValue
!}
*/
private
${
item
.
javaType
!} ${item.columnNameLowerCamel!};
</#
if
>
</#
list
>
...
...
src/main/resources/templates/codeftl/mapper.ftl
View file @
1b899395
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"
org.rcisoft.business.${table.entityName?lower_case}.dao.${table.entityName
}Repository"
>
<mapper
namespace=
"
${basePackage!}.dao.${table.entityName!
}Repository"
>
<resultMap
id=
"BaseResultMap"
type=
"org.rcisoft.business.${table.entityName?lower_case}.entity.${table.entityName}"
>
<
#list table.columnModels as item>
<
#if item.isKey>
<id
column=
"${item.colName}"
jdbcType=
"${item.typeNameUpper}"
property=
"${item.columnNameLowerCamel}"
/>
<id
column=
"${item.colName
!
}"
jdbcType=
"${item.typeNameUpper}"
property=
"${item.columnNameLowerCamel}"
/>
<
/#if>
<
#if !item.isKey>
<result
column=
"${item.colName}"
jdbcType=
"${item.typeNameUpper}"
property=
"${item.columnNameLowerCamel}"
/>
<result
column=
"${item.colName
!
}"
jdbcType=
"${item.typeNameUpper}"
property=
"${item.columnNameLowerCamel}"
/>
<
/#if>
<
/#list>
</resultMap>
...
...
src/main/resources/templates/codeftl/repository.ftl
View file @
1b899395
package
org
.
rcisoft
.
business
.${
table
.
entityName
?
lower_case
}.
dao
;
package
${
basePackage
!
}.dao;
import
org
.
rcisoft
.
core
.
base
.
BaseMapper
;
import
org
.
rcisoft
.
business
.${
table
.
entityName
?
lower_case
}.
entity
.${
table
.
entityName
};
import
${
basePackage
!
}.entity.${table.entityName};
import
org
.
apache
.
ibatis
.
annotations
.
ResultMap
;
import
org
.
apache
.
ibatis
.
annotations
.
Select
;
import
org
.
springframework
.
stereotype
.
Repository
;
...
...
@@ -13,7 +13,7 @@ import java.util.List;
*
Created
with
${
author
}
on
${.
now
}.
*/
@
Repository
public
interface
${
table
.
entityName
}
Repository
extends
BaseMapper
<${
table
.
entityName
}>
{
public
interface
${
table
.
entityName
!}Repository extends BaseMapper<${table.entityName!
}> {
/**
*
分页查询
${
table
.
entityName
?
uncap_first
}
...
...
@@ -24,6 +24,6 @@ public interface ${table.entityName}Repository extends BaseMapper<${table.entity
+
"<if test=
\"
flag !=null and flag != ''
\"
>and flag = ${r'#{flag}'} </if> "
+
"</script>"
)
@
ResultMap
(
value
=
"BaseResultMap"
)
List
<${
table
.
entityName
}>
query
${
table
.
entityName
}
s
(${
table
.
entityName
}
${
table
.
entityName
?
uncap_first
});
List
<${
table
.
entityName
!}> query${table.entityName!}s(${table.entityName!
} ${table.entityName?uncap_first});
}
src/main/resources/templates/codeftl/service.ftl
View file @
1b899395
package
org
.
rcisoft
.
business
.${
table
.
entityName
?
lower_case
}.
service
;
package
${
basePackage
!
}.service;
import
org
.
rcisoft
.
business
.${
table
.
entityName
?
lower_case
}.
entity
.${
table
.
entityName
};
import
${
basePackage
!
}.entity.${table.entityName};
import
org
.
rcisoft
.
core
.
model
.
PersistModel
;
import
org
.
rcisoft
.
core
.
aop
.
PageUtil
;
import
java
.
util
.
List
;
/**
*
Created
by
${
author
}
on
${.
now
}.
*
Created
by
${
author
!
} on ${.now}.
*/
public
interface
${
table
.
entityName
}
Service
{
public
interface
${
table
.
entityName
!
}Service {
/**
*
保存
${
table
.
tableRemark
!}
*
@
param
${
table
.
entityName
?
uncap_first
}
*
@
return
*/
PersistModel
save
(${
table
.
entityName
}
${
table
.
entityName
?
uncap_first
});
PersistModel
save
(${
table
.
entityName
!} ${table.entityName?uncap_first});
/**
*
删除
${
table
.
tableRemark
!}
*
@
param
${
table
.
entityName
?
uncap_first
}
*
@
return
*/
PersistModel
remove
(${
table
.
entityName
!} ${table.entityName?uncap_first});
/**
*
逻辑删除
${
table
.
tableRemark
!}
*
@
param
${
table
.
entityName
?
uncap_first
}
*
@
return
*/
PersistModel
remove
(${
table
.
entityName
}
${
table
.
entityName
?
uncap_first
});
PersistModel
removeLogical
(${
table
.
entityName
!
} ${table.entityName?uncap_first});
/**
*
修改
${
table
.
tableRemark
!}
*
@
param
${
table
.
entityName
?
uncap_first
}
*
@
return
*/
PersistModel
merge
(${
table
.
entityName
}
${
table
.
entityName
?
uncap_first
});
PersistModel
merge
(${
table
.
entityName
!
} ${table.entityName?uncap_first});
/**
*
根据
id
查询
${
table
.
tableRemark
!}
*
@
param
id
*
@
return
*/
${
table
.
entityName
}
findById
(
String
id
);
${
table
.
entityName
!
} findById(String id);
/**
*
分页查询
${
table
.
tableRemark
!}
*
@
param
${
table
.
entityName
?
uncap_first
}
*
@
return
*/
List
<${
table
.
entityName
}>
findAllByPagination
(
PageUtil
<${
table
.
entityName
}>
paginationUtility
,
${
table
.
entityName
}
${
table
.
entityName
?
uncap_first
});
List
<${
table
.
entityName
!}> findAllByPagination(PageUtil<${table.entityName!}> paginationUtility,
${
table
.
entityName
!} ${table.entityName?uncap_first});
/**
*
查询
list
${
table
.
tableRemark
!}
*
@
param
${
table
.
entityName
?
uncap_first
}
*
@
return
*/
List
<${
table
.
entityName
!}> findAll(${table.entityName!} ${table.entityName?uncap_first});
}
src/main/resources/templates/codeftl/serviceimpl.ftl
View file @
1b899395
package
org
.
rcisoft
.
business
.${
table
.
entityName
?
lower_case
}.
service
.
impl
;
package
${
basePackage
!
}.service.impl;
import
org
.
rcisoft
.
core
.
util
.
UserUtil
;
import
org
.
rcisoft
.
core
.
aop
.
PageUtil
;
import
org
.
rcisoft
.
core
.
model
.
PersistModel
;
import
org
.
rcisoft
.
business
.${
table
.
entityName
?
lower_case
}.
dao
.${
table
.
entityName
}
Repository
;
import
org
.
rcisoft
.
business
.${
table
.
entityName
?
lower_case
}.
entity
.${
table
.
entityName
};
import
org
.
rcisoft
.
business
.${
table
.
entityName
?
lower_case
}.
service
.${
table
.
entityName
}
Service
;
import
${
basePackage
!}.dao.${table.entityName!
}Repository;
import
${
basePackage
!}.entity.${table.entityName!
};
import
${
basePackage
!}.service.${table.entityName!
}Service;
import
org
.
springframework
.
beans
.
factory
.
annotation
.
Autowired
;
...
...
@@ -19,83 +19,107 @@ import java.util.List;
import
lombok
.
extern
.
slf4j
.
Slf4j
;
/**
*
Created
by
${
author
}
on
${.
now
}.
*
Created
by
${
author
!
} on ${.now}.
*/
@
Service
@
Transactional
(
readOnly
=
true
,
propagation
=
Propagation
.
NOT_SUPPORTED
)
@
Slf4j
public
class
${
table
.
entityName
}
ServiceImpl
implements
${
table
.
entityName
}
Service
{
public
class
${
table
.
entityName
!}ServiceImpl implements ${table.entityName!
}Service {
@
Autowired
private
${
table
.
entityName
}
Repository
${
table
.
entityName
?
uncap_first
}
Repository
;
/**
*
保存
${
table
.
entityName
?
uncap_first
}
*
保存
${
table
.
tableRemark
!
}
*
@
param
${
table
.
entityName
?
uncap_first
}
*
@
return
*/
@
Transactional
(
propagation
=
Propagation
.
REQUIRED
,
isolation
=
Isolation
.
DEFAULT
)
@
Override
public
PersistModel
save
(${
table
.
entityName
}
${
table
.
entityName
?
uncap_first
}){
public
PersistModel
save
(${
table
.
entityName
!
} ${table.entityName?uncap_first}){
//
增加操作
UserUtil
.
setCurrentPersistOperation
(${
table
.
entityName
?
uncap_first
});
int
line
=
${
table
.
entityName
?
uncap_first
}
Repository
.
insertSelective
(${
table
.
entityName
?
uncap_first
});
log
.
info
(
UserUtil
.
getUserInfoProp
(${
table
.
entityName
?
uncap_first
}.
getToken
(),
UserUtil
.
USER_USERNAME
)+
"新增了ID为"
+
${
table
.
entityName
?
uncap_first
}.
getBusinessId
()+
"的信息"
);
${
table
.
entityName
?
uncap_first
}.
getBusinessId
()+
"的
${table.tableRemark!}
信息"
);
return
new
PersistModel
(
line
);
}
/**
*
逻辑删除
*
删除
${
table
.
tableRemark
!}
*
@
param
${
table
.
entityName
?
uncap_first
}
*
@
return
*/
@
Transactional
(
propagation
=
Propagation
.
REQUIRED
,
isolation
=
Isolation
.
DEFAULT
)
@
Override
public
PersistModel
remove
(${
table
.
entityName
}
${
table
.
entityName
?
uncap_first
}){
public
PersistModel
remove
(${
table
.
entityName
!} ${table.entityName?uncap_first}){
int
line
=
${
table
.
entityName
?
uncap_first
}
Repository
.
deleteByPrimaryKey
(${
table
.
entityName
?
uncap_first
}.
getBusinessId
());
log
.
info
(
UserUtil
.
getUserInfoProp
(${
table
.
entityName
?
uncap_first
}.
getToken
(),
UserUtil
.
USER_USERNAME
)+
"删除了ID为"
+
${
table
.
entityName
?
uncap_first
}.
getBusinessId
()+
"的${table.tableRemark!}信息"
);
return
new
PersistModel
(
line
);
}
/**
*
逻辑删除
${
table
.
tableRemark
!}
*
@
param
${
table
.
entityName
?
uncap_first
}
*
@
return
*/
@
Transactional
(
propagation
=
Propagation
.
REQUIRED
,
isolation
=
Isolation
.
DEFAULT
)
@
Override
public
PersistModel
removeLogical
(${
table
.
entityName
!} ${table.entityName?uncap_first}){
UserUtil
.
setCurrentMergeOperation
(${
table
.
entityName
?
uncap_first
});
${
table
.
entityName
?
uncap_first
}.
setDeleted
();
int
line
=
${
table
.
entityName
?
uncap_first
}
Repository
.
logicalDelete
(${
table
.
entityName
?
uncap_first
});
log
.
info
(
UserUtil
.
getUserInfoProp
(${
table
.
entityName
?
uncap_first
}.
getToken
(),
UserUtil
.
USER_USERNAME
)+
"逻辑删除了ID为"
+
${
table
.
entityName
?
uncap_first
}.
getBusinessId
()+
"的
信息"
);
${
table
.
entityName
?
uncap_first
}.
getBusinessId
()+
"的${table.tableRemark!}
信息"
);
return
new
PersistModel
(
line
);
}
/**
*
修改
${
table
.
entityName
?
uncap_first
}
*
修改
${
table
.
tableRemark
!
}
*
@
param
${
table
.
entityName
?
uncap_first
}
*
@
return
*/
@
Transactional
(
propagation
=
Propagation
.
REQUIRED
,
isolation
=
Isolation
.
DEFAULT
)
@
Override
public
PersistModel
merge
(${
table
.
entityName
}
${
table
.
entityName
?
uncap_first
}){
public
PersistModel
merge
(${
table
.
entityName
!
} ${table.entityName?uncap_first}){
UserUtil
.
setCurrentMergeOperation
(${
table
.
entityName
?
uncap_first
});
int
line
=
${
table
.
entityName
?
uncap_first
}
Repository
.
updateByPrimaryKeySelective
(${
table
.
entityName
?
uncap_first
});
log
.
info
(
UserUtil
.
getUserInfoProp
(${
table
.
entityName
?
uncap_first
}.
getToken
(),
UserUtil
.
USER_USERNAME
)+
"修改了ID为"
+
${
table
.
entityName
?
uncap_first
}.
getBusinessId
()+
"的信息"
);
${
table
.
entityName
?
uncap_first
}.
getBusinessId
()+
"的
${table.tableRemark!}
信息"
);
return
new
PersistModel
(
line
);
}
/**
*
根据
id
查询
${
table
.
entityName
?
uncap_first
}
*
根据
id
查询
${
table
.
tableRemark
!
}
*
@
param
id
*
@
return
*/
public
${
table
.
entityName
}
findById
(
String
id
){
public
${
table
.
entityName
!
} findById(String id){
return
${
table
.
entityName
?
uncap_first
}
Repository
.
selectByPrimaryKey
(
id
);
}
/**
*
分页查询
${
table
.
entityName
?
uncap_first
}
*
分页查询
${
table
.
tableRemark
!}
*
@
param
${
table
.
entityName
?
uncap_first
}
*
@
return
*/
public
List
<${
table
.
entityName
!}> findAllByPagination(PageUtil<${table.entityName!}> paginationUtility,
${
table
.
entityName
!} ${table.entityName?uncap_first}){
${
table
.
entityName
?
uncap_first
}.
setStart
();
${
table
.
entityName
?
uncap_first
}.
setNotDeleted
();
return
${
table
.
entityName
?
uncap_first
}
Repository
.
query
${
table
.
entityName
!}s(${table.entityName?uncap_first});
}
/**
*
查询
list
${
table
.
tableRemark
!}
*
@
param
${
table
.
entityName
?
uncap_first
}
*
@
return
*/
public
List
<${
table
.
entityName
}>
findAllByPagination
(
PageUtil
<${
table
.
entityName
}>
paginationUtility
,
${
table
.
entityName
}
${
table
.
entityName
?
uncap_first
}){
public
List
<${
table
.
entityName
!}> findAll(${table.entityName!} ${table.entityName?uncap_first}){
${
table
.
entityName
?
uncap_first
}.
setStart
();
${
table
.
entityName
?
uncap_first
}.
setNotDeleted
();
return
${
table
.
entityName
?
uncap_first
}
Repository
.
query
${
table
.
entityName
}
s
(${
table
.
entityName
?
uncap_first
});
return
${
table
.
entityName
?
uncap_first
}
Repository
.
query
${
table
.
entityName
!
}s(${table.entityName?uncap_first});
}
}
src/main/resources/templates/connect.ftl
View file @
1b899395
...
...
@@ -16,8 +16,8 @@ password:<input type="text" id="password" /><br></br>
<button
onclick=
"connect()"
>
连接
</button>
<hr/>
<div
id=
"tableDiv"
>
basepackage:
<input
type=
"text"
id=
"basepackage"
/><br></br>
author:
<input
type=
"text"
id=
"author"
/><br></br>
basepackage:
<input
type=
"text"
id=
"basepackage"
value=
"org.rcisoft.business"
/><br></br>
author:
<input
type=
"text"
id=
"author"
value=
"cy"
/><br></br>
</div>
<button
onclick=
"generate()"
>
生成
</button>
<script
src=
"../static/jquery-1.7.2.min.js"
></script>
...
...
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