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
e6aeff22
Commit
e6aeff22
authored
Feb 24, 2018
by
李丛阳
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复冗余代码
parent
701b2b03
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
82 additions
and
12 deletions
+82
-12
AuthenticationController.java
...org/rcisoft/core/controller/AuthenticationController.java
+13
-3
CommonController.java
...in/java/org/rcisoft/core/controller/CommonController.java
+48
-0
FileController.java
...main/java/org/rcisoft/core/controller/FileController.java
+18
-5
controller.ftl
src/main/resources/templates/codeftl/controller.ftl
+3
-3
serviceimpl.ftl
src/main/resources/templates/codeftl/serviceimpl.ftl
+0
-1
No files found.
src/main/java/org/rcisoft/core/controller/AuthenticationController.java
View file @
e6aeff22
package
org
.
rcisoft
.
core
.
controller
;
package
org
.
rcisoft
.
core
.
controller
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParams
;
import
org.rcisoft.core.result.Result
;
import
org.rcisoft.core.result.Result
;
import
org.rcisoft.core.service.AuthenticationService
;
import
org.rcisoft.core.service.AuthenticationService
;
import
org.rcisoft.core.util.ResultGenerator
;
import
org.rcisoft.core.util.ResultGenerator
;
...
@@ -30,6 +32,9 @@ public class AuthenticationController {
...
@@ -30,6 +32,9 @@ public class AuthenticationController {
* @param password
* @param password
* @return
* @return
*/
*/
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"username"
,
value
=
"用户名"
,
required
=
true
,
dataType
=
"varchar"
),
@ApiImplicitParam
(
name
=
"password"
,
value
=
"密码"
,
required
=
true
,
dataType
=
"varchar"
),
@ApiImplicitParam
(
name
=
"userType"
,
value
=
"用户类型 (1 admin 2 client)"
,
required
=
true
,
dataType
=
"varchar"
)})
@PostMapping
(
value
=
"${jwt.route.authentication.path}"
)
@PostMapping
(
value
=
"${jwt.route.authentication.path}"
)
public
Result
login
(
@RequestParam
(
"username"
)
String
username
,
public
Result
login
(
@RequestParam
(
"username"
)
String
username
,
@RequestParam
(
"password"
)
String
password
,
@RequestParam
(
"password"
)
String
password
,
...
@@ -40,17 +45,22 @@ public class AuthenticationController {
...
@@ -40,17 +45,22 @@ public class AuthenticationController {
}
}
/**
/**
* 注册
* 注册
根据需要开放注册
* @param addedUser
* @param addedUser
* @return
* @return
*/
*/
@PostMapping
(
value
=
"${jwt.route.authentication.register}"
)
//
@PostMapping(value = "${jwt.route.authentication.register}")
public
Result
register
(
SysUser
addedUser
){
public
Result
register
(
SysUser
addedUser
){
authenticationServiceImpl
.
register
(
addedUser
);
authenticationServiceImpl
.
register
(
addedUser
);
return
ResultGenerator
.
genSuccessResult
();
return
ResultGenerator
.
genSuccessResult
();
}
}
@GetMapping
(
value
=
"${jwt.route.authentication.refresh}"
)
/**
* 刷新token 暂不开放
* @param request
* @return
*/
//@GetMapping(value = "${jwt.route.authentication.refresh}")
public
ResponseEntity
<?>
refreshAndGetAuthenticationToken
(
public
ResponseEntity
<?>
refreshAndGetAuthenticationToken
(
HttpServletRequest
request
){
HttpServletRequest
request
){
String
token
=
request
.
getHeader
(
tokenHeader
);
String
token
=
request
.
getHeader
(
tokenHeader
);
...
...
src/main/java/org/rcisoft/core/controller/CommonController.java
0 → 100644
View file @
e6aeff22
package
org
.
rcisoft
.
core
.
controller
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiOperation
;
import
org.rcisoft.common.component.Global
;
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.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.io.File
;
import
java.util.Date
;
/**
* Created by lcy on 18/2/24.
*
* common
*/
@Controller
(
"/common"
)
public
class
CommonController
<
T
>
extends
FileController
<
T
>
{
@Autowired
private
Global
global
;
/**
* 文件上传
* @param file
* @return
*/
@ApiOperation
(
value
=
"文件上传"
,
notes
=
"文件上传"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"file"
,
value
=
"文件"
,
required
=
true
,
dataType
=
"file"
)})
@PostMapping
(
value
=
"/upload"
)
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
),
MessageConstant
.
MESSAGE_ALERT_SUCCESS
,
MessageConstant
.
MESSAGE_ALERT_ERROR
,
filePath
);
}
}
src/main/java/org/rcisoft/core/controller/FileController.java
View file @
e6aeff22
...
@@ -21,12 +21,26 @@ import java.util.UUID;
...
@@ -21,12 +21,26 @@ import java.util.UUID;
public
class
FileController
<
T
>
extends
PaginationController
<
T
>
{
public
class
FileController
<
T
>
extends
PaginationController
<
T
>
{
protected
static
final
SimpleDateFormat
simpleDateFormat
=
new
SimpleDateFormat
(
"yyyyMMddHHmmss"
);
protected
static
final
SimpleDateFormat
simpleDateFormat
=
new
SimpleDateFormat
(
"yyyyMMddHHmmss"
);
protected
static
final
String
SEPARATOR
;
protected
static
final
String
SEPARATOR
;
/*date 格式*/
protected
static
final
String
SAVING_PATTERN_DATE
=
"DATE"
;
/*uuid 格式*/
protected
static
final
String
SAVING_PATTERN_UUID
=
"UUID"
;
Logger
logger
=
Logger
.
getLogger
(
FileController
.
class
);
Logger
logger
=
Logger
.
getLogger
(
FileController
.
class
);
static
{
static
{
SEPARATOR
=
File
.
separator
;
SEPARATOR
=
File
.
separator
;
}
}
/**
* gload 文件上传
* @param multipartFile
* @param savingPatternOrFullName
* @param savingAbsolutePath
* @return
*/
protected
String
globalCommonFileUpload
(
MultipartFile
multipartFile
,
String
savingPatternOrFullName
,
String
savingAbsolutePath
)
{
protected
String
globalCommonFileUpload
(
MultipartFile
multipartFile
,
String
savingPatternOrFullName
,
String
savingAbsolutePath
)
{
String
finalSavingPath
;
String
finalSavingPath
;
String
returnFinalFileName
;
String
returnFinalFileName
;
...
@@ -37,22 +51,21 @@ public class FileController<T> extends PaginationController<T> {
...
@@ -37,22 +51,21 @@ public class FileController<T> extends PaginationController<T> {
returnFinalFileName
=
""
;
returnFinalFileName
=
""
;
switch
(
savingPatternOrFullName
.
hashCode
())
{
switch
(
savingPatternOrFullName
.
hashCode
())
{
case
2090926
:
case
2090926
:
if
(
savingPatternOrFullName
.
equals
(
"DATE"
))
{
if
(
savingPatternOrFullName
.
equals
(
this
.
SAVING_PATTERN_DATE
))
{
returnFinalFileName
=
getCurrentDateTimeString
()
+
fileExtendsName
;
returnFinalFileName
=
getCurrentDateTimeString
()
+
fileExtendsName
;
finalSavingPath
=
savingAbsolutePath
+
SEPARATOR
+
getCurrentDateTimeString
()
+
fileExtendsName
;
finalSavingPath
=
savingAbsolutePath
+
SEPARATOR
+
getCurrentDateTimeString
()
+
fileExtendsName
;
break
label32
;
break
label32
;
}
}
break
;
break
;
case
2616251
:
case
2616251
:
if
(
savingPatternOrFullName
.
equals
(
"UUID"
))
{
if
(
savingPatternOrFullName
.
equals
(
this
.
SAVING_PATTERN_UUID
))
{
returnFinalFileName
=
getUUIDString
()
+
fileExtendsName
;
returnFinalFileName
=
getUUIDString
()
+
fileExtendsName
;
finalSavingPath
=
savingAbsolutePath
+
SEPARATOR
+
getUUIDString
()
+
fileExtendsName
;
finalSavingPath
=
savingAbsolutePath
+
SEPARATOR
+
getUUIDString
()
+
fileExtendsName
;
break
label32
;
break
label32
;
}
}
}
}
returnFinalFileName
=
savingPatternOrFullName
;
finalSavingPath
=
savingAbsolutePath
+
SEPARATOR
+
returnFinalFileName
;
finalSavingPath
=
savingAbsolutePath
+
SEPARATOR
+
savingPatternOrFullName
;
}
}
File
dir
=
new
File
(
savingAbsolutePath
);
File
dir
=
new
File
(
savingAbsolutePath
);
...
@@ -71,7 +84,7 @@ public class FileController<T> extends PaginationController<T> {
...
@@ -71,7 +84,7 @@ public class FileController<T> extends PaginationController<T> {
var11
.
printStackTrace
();
var11
.
printStackTrace
();
}
}
return
returnFinalFileName
;
return
finalSavingPath
;
}
}
...
...
src/main/resources/templates/codeftl/controller.ftl
View file @
e6aeff22
...
@@ -13,9 +13,9 @@ import org.rcisoft.core.result.Result;
...
@@ -13,9 +13,9 @@ import org.rcisoft.core.result.Result;
import
org
.
rcisoft
.
core
.
result
.
ResultServiceEnums
;
import
org
.
rcisoft
.
core
.
result
.
ResultServiceEnums
;
import
org
.
rcisoft
.
core
.
model
.
PersistModel
;
import
org
.
rcisoft
.
core
.
model
.
PersistModel
;
import
org
.
rcisoft
.
core
.
constant
.
MessageConstant
;
import
org
.
rcisoft
.
core
.
constant
.
MessageConstant
;
import
org
.
rcisoft
.
co
mmon
.
controller
.
PaginationController
;
import
org
.
rcisoft
.
co
re
.
controller
.
PaginationController
;
import
org
.
rcisoft
.
core
.
util
.
UserUtil
;
import
org
.
rcisoft
.
core
.
util
.
UserUtil
;
import
org
.
rcisoft
.
co
mmon
.
model
.
GridModel
;
import
org
.
rcisoft
.
co
re
.
model
.
GridModel
;
import
org
.
rcisoft
.
core
.
exception
.
ServiceException
;
import
org
.
rcisoft
.
core
.
exception
.
ServiceException
;
import
javax
.
validation
.
Valid
;
import
javax
.
validation
.
Valid
;
...
@@ -83,7 +83,7 @@ public class ${table.entityName}Controller extends PaginationController<${table.
...
@@ -83,7 +83,7 @@ public class ${table.entityName}Controller extends PaginationController<${table.
${
table
.
entityName
?
uncap_first
}
ServiceImpl
.
findById
(
id
));
${
table
.
entityName
?
uncap_first
}
ServiceImpl
.
findById
(
id
));
}
}
@
ApiOperation
(
value
=
"查看 ${table.tableRemark!} 集合"
,
notes
=
"查看
单
${table.tableRemark!} 集合"
)
@
ApiOperation
(
value
=
"查看 ${table.tableRemark!} 集合"
,
notes
=
"查看 ${table.tableRemark!} 集合"
)
@
GetMapping
(
value
=
"/query${table.entityName}ByPagination"
)
@
GetMapping
(
value
=
"/query${table.entityName}ByPagination"
)
public
GridModel
listByPagination
(${
table
.
entityName
}
${
table
.
entityName
?
uncap_first
})
{
public
GridModel
listByPagination
(${
table
.
entityName
}
${
table
.
entityName
?
uncap_first
})
{
${
table
.
entityName
?
uncap_first
}.
setCreateBy
(
UserUtil
.
getUserInfoProp
(
getToken
(),
UserUtil
.
USER_ID
));
${
table
.
entityName
?
uncap_first
}.
setCreateBy
(
UserUtil
.
getUserInfoProp
(
getToken
(),
UserUtil
.
USER_ID
));
...
...
src/main/resources/templates/codeftl/serviceimpl.ftl
View file @
e6aeff22
...
@@ -38,7 +38,6 @@ public class ${table.entityName}ServiceImpl implements ${table.entityName}Servic
...
@@ -38,7 +38,6 @@ public class ${table.entityName}ServiceImpl implements ${table.entityName}Servic
@
Transactional
(
propagation
=
Propagation
.
REQUIRED
,
isolation
=
Isolation
.
DEFAULT
)
@
Transactional
(
propagation
=
Propagation
.
REQUIRED
,
isolation
=
Isolation
.
DEFAULT
)
@
Override
@
Override
public
PersistModel
save
(${
table
.
entityName
}
${
table
.
entityName
?
uncap_first
}){
public
PersistModel
save
(${
table
.
entityName
}
${
table
.
entityName
?
uncap_first
}){
${
table
.
entityName
?
uncap_first
}.
setCommonBusinessId
();
//
增加操作
//
增加操作
UserUtil
.
setCurrentPersistOperation
(${
table
.
entityName
?
uncap_first
});
UserUtil
.
setCurrentPersistOperation
(${
table
.
entityName
?
uncap_first
});
int
line
=
${
table
.
entityName
?
uncap_first
}
Repository
.
insertSelective
(${
table
.
entityName
?
uncap_first
});
int
line
=
${
table
.
entityName
?
uncap_first
}
Repository
.
insertSelective
(${
table
.
entityName
?
uncap_first
});
...
...
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