Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
Eladmin
Commits
e4ca7afc
Commit
e4ca7afc
authored
Nov 25, 2019
by
dqjdda
Browse files
阿里巴巴代码规范
parent
6d941c09
Changes
160
Hide whitespace changes
Inline
Side-by-side
eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/ServerDeployService.java
View file @
e4ca7afc
package
me.zhengjie.modules.mnt.service
;
package
me.zhengjie.modules.mnt.service
;
import
me.zhengjie.modules.mnt.domain.ServerDeploy
;
import
me.zhengjie.modules.mnt.domain.ServerDeploy
;
import
me.zhengjie.modules.mnt.service.dto.ServerDeployD
TO
;
import
me.zhengjie.modules.mnt.service.dto.ServerDeployD
to
;
import
me.zhengjie.modules.mnt.service.dto.ServerDeployQueryCriteria
;
import
me.zhengjie.modules.mnt.service.dto.ServerDeployQueryCriteria
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.domain.Pageable
;
...
@@ -11,17 +11,51 @@ import org.springframework.data.domain.Pageable;
...
@@ -11,17 +11,51 @@ import org.springframework.data.domain.Pageable;
*/
*/
public
interface
ServerDeployService
{
public
interface
ServerDeployService
{
/**
* 分页查询
* @param criteria 条件
* @param pageable 分页参数
* @return /
*/
Object
queryAll
(
ServerDeployQueryCriteria
criteria
,
Pageable
pageable
);
Object
queryAll
(
ServerDeployQueryCriteria
criteria
,
Pageable
pageable
);
/**
* 查询全部数据
* @param criteria 条件
* @return /
*/
Object
queryAll
(
ServerDeployQueryCriteria
criteria
);
Object
queryAll
(
ServerDeployQueryCriteria
criteria
);
ServerDeployDTO
findById
(
Long
id
);
/**
* 根据ID查询
ServerDeployDTO
create
(
ServerDeploy
resources
);
* @param id /
* @return /
*/
ServerDeployDto
findById
(
Long
id
);
/**
* 创建
* @param resources /
* @return /
*/
ServerDeployDto
create
(
ServerDeploy
resources
);
/**
* 编辑
* @param resources /
*/
void
update
(
ServerDeploy
resources
);
void
update
(
ServerDeploy
resources
);
/**
* 删除
* @param id /
*/
void
delete
(
Long
id
);
void
delete
(
Long
id
);
ServerDeployDTO
findByIp
(
String
ip
);
/**
* 根据IP查询
* @param ip /
* @return /
*/
ServerDeployDto
findByIp
(
String
ip
);
}
}
eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/dto/AppD
TO
.java
→
eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/dto/AppD
to
.java
View file @
e4ca7afc
...
@@ -11,7 +11,7 @@ import java.sql.Timestamp;
...
@@ -11,7 +11,7 @@ import java.sql.Timestamp;
* @date 2019-08-24
* @date 2019-08-24
*/
*/
@Data
@Data
public
class
AppD
TO
implements
Serializable
{
public
class
AppD
to
implements
Serializable
{
/**
/**
* 应用编号
* 应用编号
...
@@ -26,7 +26,7 @@ public class AppDTO implements Serializable {
...
@@ -26,7 +26,7 @@ public class AppDTO implements Serializable {
/**
/**
* 端口
* 端口
*/
*/
private
i
nt
port
;
private
I
nt
eger
port
;
/**
/**
* 上传目录
* 上传目录
...
...
eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/dto/DatabaseD
TO
.java
→
eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/dto/DatabaseD
to
.java
View file @
e4ca7afc
...
@@ -9,7 +9,7 @@ import java.io.Serializable;
...
@@ -9,7 +9,7 @@ import java.io.Serializable;
* @date 2019-08-24
* @date 2019-08-24
*/
*/
@Data
@Data
public
class
DatabaseD
TO
implements
Serializable
{
public
class
DatabaseD
to
implements
Serializable
{
/**
/**
* id
* id
...
...
eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/dto/DeployD
TO
.java
→
eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/dto/DeployD
to
.java
View file @
e4ca7afc
...
@@ -13,19 +13,19 @@ import java.util.stream.Collectors;
...
@@ -13,19 +13,19 @@ import java.util.stream.Collectors;
* @date 2019-08-24
* @date 2019-08-24
*/
*/
@Data
@Data
public
class
DeployD
TO
implements
Serializable
{
public
class
DeployD
to
implements
Serializable
{
/**
/**
* 部署编号
* 部署编号
*/
*/
private
String
id
;
private
String
id
;
private
AppD
TO
app
;
private
AppD
to
app
;
/**
/**
* 服务器
* 服务器
*/
*/
private
Set
<
ServerDeployD
TO
>
deploys
;
private
Set
<
ServerDeployD
to
>
deploys
;
private
String
servers
;
private
String
servers
;
...
@@ -38,7 +38,7 @@ public class DeployDTO implements Serializable {
...
@@ -38,7 +38,7 @@ public class DeployDTO implements Serializable {
public
String
getServers
()
{
public
String
getServers
()
{
if
(
CollectionUtil
.
isNotEmpty
(
deploys
)){
if
(
CollectionUtil
.
isNotEmpty
(
deploys
)){
return
deploys
.
stream
().
map
(
ServerDeployD
TO
:
:
getName
).
collect
(
Collectors
.
joining
(
","
));
return
deploys
.
stream
().
map
(
ServerDeployD
to
:
:
getName
).
collect
(
Collectors
.
joining
(
","
));
}
}
return
servers
;
return
servers
;
}
}
...
...
eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/dto/DeployHistoryD
TO
.java
→
eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/dto/DeployHistoryD
to
.java
View file @
e4ca7afc
...
@@ -10,7 +10,7 @@ import java.sql.Timestamp;
...
@@ -10,7 +10,7 @@ import java.sql.Timestamp;
* @date 2019-08-24
* @date 2019-08-24
*/
*/
@Data
@Data
public
class
DeployHistoryD
TO
implements
Serializable
{
public
class
DeployHistoryD
to
implements
Serializable
{
/**
/**
* 编号
* 编号
...
...
eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/dto/ServerDeployD
TO
.java
→
eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/dto/ServerDeployD
to
.java
View file @
e4ca7afc
...
@@ -10,7 +10,7 @@ import java.sql.Timestamp;
...
@@ -10,7 +10,7 @@ import java.sql.Timestamp;
* @date 2019-08-24
* @date 2019-08-24
*/
*/
@Data
@Data
public
class
ServerDeployD
TO
implements
Serializable
{
public
class
ServerDeployD
to
implements
Serializable
{
private
Long
id
;
private
Long
id
;
...
...
eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/impl/AppServiceImpl.java
View file @
e4ca7afc
...
@@ -3,7 +3,7 @@ package me.zhengjie.modules.mnt.service.impl;
...
@@ -3,7 +3,7 @@ package me.zhengjie.modules.mnt.service.impl;
import
me.zhengjie.modules.mnt.domain.App
;
import
me.zhengjie.modules.mnt.domain.App
;
import
me.zhengjie.modules.mnt.repository.AppRepository
;
import
me.zhengjie.modules.mnt.repository.AppRepository
;
import
me.zhengjie.modules.mnt.service.AppService
;
import
me.zhengjie.modules.mnt.service.AppService
;
import
me.zhengjie.modules.mnt.service.dto.AppD
TO
;
import
me.zhengjie.modules.mnt.service.dto.AppD
to
;
import
me.zhengjie.modules.mnt.service.dto.AppQueryCriteria
;
import
me.zhengjie.modules.mnt.service.dto.AppQueryCriteria
;
import
me.zhengjie.modules.mnt.service.mapper.AppMapper
;
import
me.zhengjie.modules.mnt.service.mapper.AppMapper
;
import
me.zhengjie.utils.PageUtil
;
import
me.zhengjie.utils.PageUtil
;
...
@@ -44,7 +44,7 @@ public class AppServiceImpl implements AppService {
...
@@ -44,7 +44,7 @@ public class AppServiceImpl implements AppService {
}
}
@Override
@Override
public
AppD
TO
findById
(
Long
id
)
{
public
AppD
to
findById
(
Long
id
)
{
App
app
=
appRepository
.
findById
(
id
).
orElseGet
(
App:
:
new
);
App
app
=
appRepository
.
findById
(
id
).
orElseGet
(
App:
:
new
);
ValidationUtil
.
isNull
(
app
.
getId
(),
"App"
,
"id"
,
id
);
ValidationUtil
.
isNull
(
app
.
getId
(),
"App"
,
"id"
,
id
);
return
appMapper
.
toDto
(
app
);
return
appMapper
.
toDto
(
app
);
...
@@ -52,7 +52,7 @@ public class AppServiceImpl implements AppService {
...
@@ -52,7 +52,7 @@ public class AppServiceImpl implements AppService {
@Override
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
AppD
TO
create
(
App
resources
)
{
public
AppD
to
create
(
App
resources
)
{
return
appMapper
.
toDto
(
appRepository
.
save
(
resources
));
return
appMapper
.
toDto
(
appRepository
.
save
(
resources
));
}
}
...
...
eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/impl/DatabaseServiceImpl.java
View file @
e4ca7afc
...
@@ -4,7 +4,7 @@ import cn.hutool.core.util.IdUtil;
...
@@ -4,7 +4,7 @@ import cn.hutool.core.util.IdUtil;
import
me.zhengjie.modules.mnt.domain.Database
;
import
me.zhengjie.modules.mnt.domain.Database
;
import
me.zhengjie.modules.mnt.repository.DatabaseRepository
;
import
me.zhengjie.modules.mnt.repository.DatabaseRepository
;
import
me.zhengjie.modules.mnt.service.DatabaseService
;
import
me.zhengjie.modules.mnt.service.DatabaseService
;
import
me.zhengjie.modules.mnt.service.dto.DatabaseD
TO
;
import
me.zhengjie.modules.mnt.service.dto.DatabaseD
to
;
import
me.zhengjie.modules.mnt.service.dto.DatabaseQueryCriteria
;
import
me.zhengjie.modules.mnt.service.dto.DatabaseQueryCriteria
;
import
me.zhengjie.modules.mnt.service.mapper.DatabaseMapper
;
import
me.zhengjie.modules.mnt.service.mapper.DatabaseMapper
;
import
me.zhengjie.utils.PageUtil
;
import
me.zhengjie.utils.PageUtil
;
...
@@ -45,7 +45,7 @@ public class DatabaseServiceImpl implements DatabaseService {
...
@@ -45,7 +45,7 @@ public class DatabaseServiceImpl implements DatabaseService {
}
}
@Override
@Override
public
DatabaseD
TO
findById
(
String
id
)
{
public
DatabaseD
to
findById
(
String
id
)
{
Database
database
=
databaseRepository
.
findById
(
id
).
orElseGet
(
Database:
:
new
);
Database
database
=
databaseRepository
.
findById
(
id
).
orElseGet
(
Database:
:
new
);
ValidationUtil
.
isNull
(
database
.
getId
(),
"Database"
,
"id"
,
id
);
ValidationUtil
.
isNull
(
database
.
getId
(),
"Database"
,
"id"
,
id
);
return
databaseMapper
.
toDto
(
database
);
return
databaseMapper
.
toDto
(
database
);
...
@@ -53,7 +53,7 @@ public class DatabaseServiceImpl implements DatabaseService {
...
@@ -53,7 +53,7 @@ public class DatabaseServiceImpl implements DatabaseService {
@Override
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
DatabaseD
TO
create
(
Database
resources
)
{
public
DatabaseD
to
create
(
Database
resources
)
{
resources
.
setId
(
IdUtil
.
simpleUUID
());
resources
.
setId
(
IdUtil
.
simpleUUID
());
return
databaseMapper
.
toDto
(
databaseRepository
.
save
(
resources
));
return
databaseMapper
.
toDto
(
databaseRepository
.
save
(
resources
));
}
}
...
...
eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/impl/DeployHistoryServiceImpl.java
View file @
e4ca7afc
...
@@ -4,7 +4,7 @@ import cn.hutool.core.util.IdUtil;
...
@@ -4,7 +4,7 @@ import cn.hutool.core.util.IdUtil;
import
me.zhengjie.modules.mnt.domain.DeployHistory
;
import
me.zhengjie.modules.mnt.domain.DeployHistory
;
import
me.zhengjie.modules.mnt.repository.DeployHistoryRepository
;
import
me.zhengjie.modules.mnt.repository.DeployHistoryRepository
;
import
me.zhengjie.modules.mnt.service.DeployHistoryService
;
import
me.zhengjie.modules.mnt.service.DeployHistoryService
;
import
me.zhengjie.modules.mnt.service.dto.DeployHistoryD
TO
;
import
me.zhengjie.modules.mnt.service.dto.DeployHistoryD
to
;
import
me.zhengjie.modules.mnt.service.dto.DeployHistoryQueryCriteria
;
import
me.zhengjie.modules.mnt.service.dto.DeployHistoryQueryCriteria
;
import
me.zhengjie.modules.mnt.service.mapper.DeployHistoryMapper
;
import
me.zhengjie.modules.mnt.service.mapper.DeployHistoryMapper
;
import
me.zhengjie.utils.PageUtil
;
import
me.zhengjie.utils.PageUtil
;
...
@@ -45,7 +45,7 @@ public class DeployHistoryServiceImpl implements DeployHistoryService {
...
@@ -45,7 +45,7 @@ public class DeployHistoryServiceImpl implements DeployHistoryService {
}
}
@Override
@Override
public
DeployHistoryD
TO
findById
(
String
id
)
{
public
DeployHistoryD
to
findById
(
String
id
)
{
DeployHistory
deployhistory
=
deployhistoryRepository
.
findById
(
id
).
orElseGet
(
DeployHistory:
:
new
);
DeployHistory
deployhistory
=
deployhistoryRepository
.
findById
(
id
).
orElseGet
(
DeployHistory:
:
new
);
ValidationUtil
.
isNull
(
deployhistory
.
getId
(),
"DeployHistory"
,
"id"
,
id
);
ValidationUtil
.
isNull
(
deployhistory
.
getId
(),
"DeployHistory"
,
"id"
,
id
);
return
deployhistoryMapper
.
toDto
(
deployhistory
);
return
deployhistoryMapper
.
toDto
(
deployhistory
);
...
@@ -53,7 +53,7 @@ public class DeployHistoryServiceImpl implements DeployHistoryService {
...
@@ -53,7 +53,7 @@ public class DeployHistoryServiceImpl implements DeployHistoryService {
@Override
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
DeployHistoryD
TO
create
(
DeployHistory
resources
)
{
public
DeployHistoryD
to
create
(
DeployHistory
resources
)
{
resources
.
setId
(
IdUtil
.
simpleUUID
());
resources
.
setId
(
IdUtil
.
simpleUUID
());
return
deployhistoryMapper
.
toDto
(
deployhistoryRepository
.
save
(
resources
));
return
deployhistoryMapper
.
toDto
(
deployhistoryRepository
.
save
(
resources
));
}
}
...
...
eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/impl/DeployServiceImpl.java
View file @
e4ca7afc
...
@@ -67,30 +67,30 @@ public class DeployServiceImpl implements DeployService {
...
@@ -67,30 +67,30 @@ public class DeployServiceImpl implements DeployService {
}
}
@Override
@Override
public
List
<
DeployD
TO
>
queryAll
(
DeployQueryCriteria
criteria
)
{
public
List
<
DeployD
to
>
queryAll
(
DeployQueryCriteria
criteria
)
{
return
deployMapper
.
toDto
(
deployRepository
.
findAll
((
root
,
criteriaQuery
,
criteriaBuilder
)
->
QueryHelp
.
getPredicate
(
root
,
criteria
,
criteriaBuilder
)));
return
deployMapper
.
toDto
(
deployRepository
.
findAll
((
root
,
criteriaQuery
,
criteriaBuilder
)
->
QueryHelp
.
getPredicate
(
root
,
criteria
,
criteriaBuilder
)));
}
}
@Override
@Override
public
DeployD
TO
findById
(
Long
id
)
{
public
DeployD
to
findById
(
Long
id
)
{
Deploy
D
eploy
=
deployRepository
.
findById
(
id
).
orElseGet
(
Deploy:
:
new
);
Deploy
d
eploy
=
deployRepository
.
findById
(
id
).
orElseGet
(
Deploy:
:
new
);
ValidationUtil
.
isNull
(
D
eploy
.
getId
(),
"Deploy"
,
"id"
,
id
);
ValidationUtil
.
isNull
(
d
eploy
.
getId
(),
"Deploy"
,
"id"
,
id
);
return
deployMapper
.
toDto
(
D
eploy
);
return
deployMapper
.
toDto
(
d
eploy
);
}
}
@Override
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
DeployD
TO
create
(
Deploy
resources
)
{
public
DeployD
to
create
(
Deploy
resources
)
{
return
deployMapper
.
toDto
(
deployRepository
.
save
(
resources
));
return
deployMapper
.
toDto
(
deployRepository
.
save
(
resources
));
}
}
@Override
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
update
(
Deploy
resources
)
{
public
void
update
(
Deploy
resources
)
{
Deploy
D
eploy
=
deployRepository
.
findById
(
resources
.
getId
()).
orElseGet
(
Deploy:
:
new
);
Deploy
d
eploy
=
deployRepository
.
findById
(
resources
.
getId
()).
orElseGet
(
Deploy:
:
new
);
ValidationUtil
.
isNull
(
D
eploy
.
getId
(),
"Deploy"
,
"id"
,
resources
.
getId
());
ValidationUtil
.
isNull
(
d
eploy
.
getId
(),
"Deploy"
,
"id"
,
resources
.
getId
());
D
eploy
.
copy
(
resources
);
d
eploy
.
copy
(
resources
);
deployRepository
.
save
(
D
eploy
);
deployRepository
.
save
(
d
eploy
);
}
}
@Override
@Override
...
@@ -100,8 +100,8 @@ public class DeployServiceImpl implements DeployService {
...
@@ -100,8 +100,8 @@ public class DeployServiceImpl implements DeployService {
}
}
@Override
@Override
public
String
deploy
(
String
fileSavePath
,
Long
id
)
{
public
void
deploy
(
String
fileSavePath
,
Long
id
)
{
return
deployApp
(
fileSavePath
,
id
);
deployApp
(
fileSavePath
,
id
);
}
}
/**
/**
...
@@ -111,12 +111,12 @@ public class DeployServiceImpl implements DeployService {
...
@@ -111,12 +111,12 @@ public class DeployServiceImpl implements DeployService {
*/
*/
private
String
deployApp
(
String
fileSavePath
,
Long
id
)
{
private
String
deployApp
(
String
fileSavePath
,
Long
id
)
{
DeployD
TO
deploy
=
findById
(
id
);
DeployD
to
deploy
=
findById
(
id
);
if
(
deploy
==
null
)
{
if
(
deploy
==
null
)
{
sendMsg
(
"部署信息不存在"
,
MsgType
.
ERROR
);
sendMsg
(
"部署信息不存在"
,
MsgType
.
ERROR
);
throw
new
BadRequestException
(
"部署信息不存在"
);
throw
new
BadRequestException
(
"部署信息不存在"
);
}
}
AppD
TO
app
=
deploy
.
getApp
();
AppD
to
app
=
deploy
.
getApp
();
if
(
app
==
null
)
{
if
(
app
==
null
)
{
sendMsg
(
"包对应应用信息不存在"
,
MsgType
.
ERROR
);
sendMsg
(
"包对应应用信息不存在"
,
MsgType
.
ERROR
);
throw
new
BadRequestException
(
"包对应应用信息不存在"
);
throw
new
BadRequestException
(
"包对应应用信息不存在"
);
...
@@ -126,8 +126,8 @@ public class DeployServiceImpl implements DeployService {
...
@@ -126,8 +126,8 @@ public class DeployServiceImpl implements DeployService {
String
uploadPath
=
app
.
getUploadPath
();
String
uploadPath
=
app
.
getUploadPath
();
StringBuilder
sb
=
new
StringBuilder
();
StringBuilder
sb
=
new
StringBuilder
();
String
msg
;
String
msg
;
Set
<
ServerDeployD
TO
>
deploys
=
deploy
.
getDeploys
();
Set
<
ServerDeployD
to
>
deploys
=
deploy
.
getDeploys
();
for
(
ServerDeployD
TO
deployDTO
:
deploys
)
{
for
(
ServerDeployD
to
deployDTO
:
deploys
)
{
String
ip
=
deployDTO
.
getIp
();
String
ip
=
deployDTO
.
getIp
();
ExecuteShellUtil
executeShellUtil
=
getExecuteShellUtil
(
ip
);
ExecuteShellUtil
executeShellUtil
=
getExecuteShellUtil
(
ip
);
//判断是否第一次部署
//判断是否第一次部署
...
@@ -252,7 +252,7 @@ public class DeployServiceImpl implements DeployService {
...
@@ -252,7 +252,7 @@ public class DeployServiceImpl implements DeployService {
return
"执行完毕"
;
return
"执行完毕"
;
}
}
private
boolean
checkFile
(
ExecuteShellUtil
executeShellUtil
,
AppD
TO
appDTO
)
{
private
boolean
checkFile
(
ExecuteShellUtil
executeShellUtil
,
AppD
to
appDTO
)
{
String
sb
=
"find "
+
String
sb
=
"find "
+
appDTO
.
getDeployPath
()
+
appDTO
.
getDeployPath
()
+
" -name "
+
" -name "
+
...
@@ -346,7 +346,8 @@ public class DeployServiceImpl implements DeployService {
...
@@ -346,7 +346,8 @@ public class DeployServiceImpl implements DeployService {
//删除原来应用
//删除原来应用
sendMsg
(
"删除应用"
,
MsgType
.
INFO
);
sendMsg
(
"删除应用"
,
MsgType
.
INFO
);
//考虑到系统安全性,必须限制下操作目录
//考虑到系统安全性,必须限制下操作目录
if
(!
deployPath
.
startsWith
(
"/opt"
))
{
String
path
=
"/opt"
;
if
(!
deployPath
.
startsWith
(
path
))
{
throw
new
BadRequestException
(
"部署路径必须在opt目录下:"
+
deployPath
);
throw
new
BadRequestException
(
"部署路径必须在opt目录下:"
+
deployPath
);
}
}
executeShellUtil
.
execute
(
"rm -rf "
+
deployPath
+
FILE_SEPARATOR
+
resources
.
getAppName
());
executeShellUtil
.
execute
(
"rm -rf "
+
deployPath
+
FILE_SEPARATOR
+
resources
.
getAppName
());
...
@@ -366,7 +367,7 @@ public class DeployServiceImpl implements DeployService {
...
@@ -366,7 +367,7 @@ public class DeployServiceImpl implements DeployService {
}
}
private
ExecuteShellUtil
getExecuteShellUtil
(
String
ip
)
{
private
ExecuteShellUtil
getExecuteShellUtil
(
String
ip
)
{
ServerDeployD
TO
serverDeployDTO
=
serverDeployService
.
findByIp
(
ip
);
ServerDeployD
to
serverDeployDTO
=
serverDeployService
.
findByIp
(
ip
);
if
(
serverDeployDTO
==
null
)
{
if
(
serverDeployDTO
==
null
)
{
sendMsg
(
"IP对应服务器信息不存在:"
+
ip
,
MsgType
.
ERROR
);
sendMsg
(
"IP对应服务器信息不存在:"
+
ip
,
MsgType
.
ERROR
);
throw
new
BadRequestException
(
"IP对应服务器信息不存在:"
+
ip
);
throw
new
BadRequestException
(
"IP对应服务器信息不存在:"
+
ip
);
...
@@ -375,7 +376,7 @@ public class DeployServiceImpl implements DeployService {
...
@@ -375,7 +376,7 @@ public class DeployServiceImpl implements DeployService {
}
}
private
ScpClientUtil
getScpClientUtil
(
String
ip
)
{
private
ScpClientUtil
getScpClientUtil
(
String
ip
)
{
ServerDeployD
TO
serverDeployDTO
=
serverDeployService
.
findByIp
(
ip
);
ServerDeployD
to
serverDeployDTO
=
serverDeployService
.
findByIp
(
ip
);
if
(
serverDeployDTO
==
null
)
{
if
(
serverDeployDTO
==
null
)
{
sendMsg
(
"IP对应服务器信息不存在:"
+
ip
,
MsgType
.
ERROR
);
sendMsg
(
"IP对应服务器信息不存在:"
+
ip
,
MsgType
.
ERROR
);
throw
new
BadRequestException
(
"IP对应服务器信息不存在:"
+
ip
);
throw
new
BadRequestException
(
"IP对应服务器信息不存在:"
+
ip
);
...
...
eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/impl/ServerDeployServiceImpl.java
View file @
e4ca7afc
...
@@ -3,7 +3,7 @@ package me.zhengjie.modules.mnt.service.impl;
...
@@ -3,7 +3,7 @@ package me.zhengjie.modules.mnt.service.impl;
import
me.zhengjie.modules.mnt.domain.ServerDeploy
;
import
me.zhengjie.modules.mnt.domain.ServerDeploy
;
import
me.zhengjie.modules.mnt.repository.ServerDeployRepository
;
import
me.zhengjie.modules.mnt.repository.ServerDeployRepository
;
import
me.zhengjie.modules.mnt.service.ServerDeployService
;
import
me.zhengjie.modules.mnt.service.ServerDeployService
;
import
me.zhengjie.modules.mnt.service.dto.ServerDeployD
TO
;
import
me.zhengjie.modules.mnt.service.dto.ServerDeployD
to
;
import
me.zhengjie.modules.mnt.service.dto.ServerDeployQueryCriteria
;
import
me.zhengjie.modules.mnt.service.dto.ServerDeployQueryCriteria
;
import
me.zhengjie.modules.mnt.service.mapper.ServerDeployMapper
;
import
me.zhengjie.modules.mnt.service.mapper.ServerDeployMapper
;
import
me.zhengjie.utils.PageUtil
;
import
me.zhengjie.utils.PageUtil
;
...
@@ -44,21 +44,21 @@ public class ServerDeployServiceImpl implements ServerDeployService {
...
@@ -44,21 +44,21 @@ public class ServerDeployServiceImpl implements ServerDeployService {
}
}
@Override
@Override
public
ServerDeployD
TO
findById
(
Long
id
)
{
public
ServerDeployD
to
findById
(
Long
id
)
{
ServerDeploy
server
=
serverDeployRepository
.
findById
(
id
).
orElseGet
(
ServerDeploy:
:
new
);
ServerDeploy
server
=
serverDeployRepository
.
findById
(
id
).
orElseGet
(
ServerDeploy:
:
new
);
ValidationUtil
.
isNull
(
server
.
getId
(),
"ServerDeploy"
,
"id"
,
id
);
ValidationUtil
.
isNull
(
server
.
getId
(),
"ServerDeploy"
,
"id"
,
id
);
return
serverDeployMapper
.
toDto
(
server
);
return
serverDeployMapper
.
toDto
(
server
);
}
}
@Override
@Override
public
ServerDeployD
TO
findByIp
(
String
ip
)
{
public
ServerDeployD
to
findByIp
(
String
ip
)
{
ServerDeploy
deploy
=
serverDeployRepository
.
findByIp
(
ip
);
ServerDeploy
deploy
=
serverDeployRepository
.
findByIp
(
ip
);
return
serverDeployMapper
.
toDto
(
deploy
);
return
serverDeployMapper
.
toDto
(
deploy
);
}
}
@Override
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
ServerDeployD
TO
create
(
ServerDeploy
resources
)
{
public
ServerDeployD
to
create
(
ServerDeploy
resources
)
{
return
serverDeployMapper
.
toDto
(
serverDeployRepository
.
save
(
resources
));
return
serverDeployMapper
.
toDto
(
serverDeployRepository
.
save
(
resources
));
}
}
...
...
eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/mapper/AppMapper.java
View file @
e4ca7afc
...
@@ -2,7 +2,7 @@ package me.zhengjie.modules.mnt.service.mapper;
...
@@ -2,7 +2,7 @@ package me.zhengjie.modules.mnt.service.mapper;
import
me.zhengjie.base.BaseMapper
;
import
me.zhengjie.base.BaseMapper
;
import
me.zhengjie.modules.mnt.domain.App
;
import
me.zhengjie.modules.mnt.domain.App
;
import
me.zhengjie.modules.mnt.service.dto.AppD
TO
;
import
me.zhengjie.modules.mnt.service.dto.AppD
to
;
import
org.mapstruct.Mapper
;
import
org.mapstruct.Mapper
;
import
org.mapstruct.ReportingPolicy
;
import
org.mapstruct.ReportingPolicy
;
...
@@ -11,6 +11,6 @@ import org.mapstruct.ReportingPolicy;
...
@@ -11,6 +11,6 @@ import org.mapstruct.ReportingPolicy;
* @date 2019-08-24
* @date 2019-08-24
*/
*/
@Mapper
(
componentModel
=
"spring"
,
uses
=
{},
unmappedTargetPolicy
=
ReportingPolicy
.
IGNORE
)
@Mapper
(
componentModel
=
"spring"
,
uses
=
{},
unmappedTargetPolicy
=
ReportingPolicy
.
IGNORE
)
public
interface
AppMapper
extends
BaseMapper
<
AppD
TO
,
App
>
{
public
interface
AppMapper
extends
BaseMapper
<
AppD
to
,
App
>
{
}
}
eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/mapper/DatabaseMapper.java
View file @
e4ca7afc
...
@@ -2,7 +2,7 @@ package me.zhengjie.modules.mnt.service.mapper;
...
@@ -2,7 +2,7 @@ package me.zhengjie.modules.mnt.service.mapper;
import
me.zhengjie.base.BaseMapper
;
import
me.zhengjie.base.BaseMapper
;
import
me.zhengjie.modules.mnt.domain.Database
;
import
me.zhengjie.modules.mnt.domain.Database
;
import
me.zhengjie.modules.mnt.service.dto.DatabaseD
TO
;
import
me.zhengjie.modules.mnt.service.dto.DatabaseD
to
;
import
org.mapstruct.Mapper
;
import
org.mapstruct.Mapper
;
import
org.mapstruct.ReportingPolicy
;
import
org.mapstruct.ReportingPolicy
;
...
@@ -11,6 +11,6 @@ import org.mapstruct.ReportingPolicy;
...
@@ -11,6 +11,6 @@ import org.mapstruct.ReportingPolicy;
* @date 2019-08-24
* @date 2019-08-24
*/
*/
@Mapper
(
componentModel
=
"spring"
,
unmappedTargetPolicy
=
ReportingPolicy
.
IGNORE
)
@Mapper
(
componentModel
=
"spring"
,
unmappedTargetPolicy
=
ReportingPolicy
.
IGNORE
)
public
interface
DatabaseMapper
extends
BaseMapper
<
DatabaseD
TO
,
Database
>
{
public
interface
DatabaseMapper
extends
BaseMapper
<
DatabaseD
to
,
Database
>
{
}
}
eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/mapper/DeployHistoryMapper.java
View file @
e4ca7afc
...
@@ -2,7 +2,7 @@ package me.zhengjie.modules.mnt.service.mapper;
...
@@ -2,7 +2,7 @@ package me.zhengjie.modules.mnt.service.mapper;
import
me.zhengjie.base.BaseMapper
;
import
me.zhengjie.base.BaseMapper
;
import
me.zhengjie.modules.mnt.domain.DeployHistory
;
import
me.zhengjie.modules.mnt.domain.DeployHistory
;
import
me.zhengjie.modules.mnt.service.dto.DeployHistoryD
TO
;
import
me.zhengjie.modules.mnt.service.dto.DeployHistoryD
to
;
import
org.mapstruct.Mapper
;
import
org.mapstruct.Mapper
;
import
org.mapstruct.ReportingPolicy
;
import
org.mapstruct.ReportingPolicy
;
...
@@ -11,6 +11,6 @@ import org.mapstruct.ReportingPolicy;
...
@@ -11,6 +11,6 @@ import org.mapstruct.ReportingPolicy;
* @date 2019-08-24
* @date 2019-08-24
*/
*/
@Mapper
(
componentModel
=
"spring"
,
uses
=
{},
unmappedTargetPolicy
=
ReportingPolicy
.
IGNORE
)
@Mapper
(
componentModel
=
"spring"
,
uses
=
{},
unmappedTargetPolicy
=
ReportingPolicy
.
IGNORE
)
public
interface
DeployHistoryMapper
extends
BaseMapper
<
DeployHistoryD
TO
,
DeployHistory
>
{
public
interface
DeployHistoryMapper
extends
BaseMapper
<
DeployHistoryD
to
,
DeployHistory
>
{
}
}
eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/mapper/DeployMapper.java
View file @
e4ca7afc
...
@@ -2,7 +2,7 @@ package me.zhengjie.modules.mnt.service.mapper;
...
@@ -2,7 +2,7 @@ package me.zhengjie.modules.mnt.service.mapper;
import
me.zhengjie.base.BaseMapper
;
import
me.zhengjie.base.BaseMapper
;
import
me.zhengjie.modules.mnt.domain.Deploy
;
import
me.zhengjie.modules.mnt.domain.Deploy
;
import
me.zhengjie.modules.mnt.service.dto.DeployD
TO
;
import
me.zhengjie.modules.mnt.service.dto.DeployD
to
;
import
org.mapstruct.Mapper
;
import
org.mapstruct.Mapper
;
import
org.mapstruct.ReportingPolicy
;
import
org.mapstruct.ReportingPolicy
;
...
@@ -11,6 +11,6 @@ import org.mapstruct.ReportingPolicy;
...
@@ -11,6 +11,6 @@ import org.mapstruct.ReportingPolicy;
* @date 2019-08-24
* @date 2019-08-24
*/
*/
@Mapper
(
componentModel
=
"spring"
,
uses
=
{
AppMapper
.
class
,
ServerDeployMapper
.
class
},
unmappedTargetPolicy
=
ReportingPolicy
.
IGNORE
)
@Mapper
(
componentModel
=
"spring"
,
uses
=
{
AppMapper
.
class
,
ServerDeployMapper
.
class
},
unmappedTargetPolicy
=
ReportingPolicy
.
IGNORE
)
public
interface
DeployMapper
extends
BaseMapper
<
DeployD
TO
,
Deploy
>
{
public
interface
DeployMapper
extends
BaseMapper
<
DeployD
to
,
Deploy
>
{
}
}
eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/mapper/ServerDeployMapper.java
View file @
e4ca7afc
...
@@ -2,7 +2,7 @@ package me.zhengjie.modules.mnt.service.mapper;
...
@@ -2,7 +2,7 @@ package me.zhengjie.modules.mnt.service.mapper;
import
me.zhengjie.base.BaseMapper
;
import
me.zhengjie.base.BaseMapper
;
import
me.zhengjie.modules.mnt.domain.ServerDeploy
;
import
me.zhengjie.modules.mnt.domain.ServerDeploy
;
import
me.zhengjie.modules.mnt.service.dto.ServerDeployD
TO
;
import
me.zhengjie.modules.mnt.service.dto.ServerDeployD
to
;
import
org.mapstruct.Mapper
;
import
org.mapstruct.Mapper
;
import
org.mapstruct.ReportingPolicy
;
import
org.mapstruct.ReportingPolicy
;
...
@@ -11,6 +11,6 @@ import org.mapstruct.ReportingPolicy;
...
@@ -11,6 +11,6 @@ import org.mapstruct.ReportingPolicy;
* @date 2019-08-24
* @date 2019-08-24
*/
*/
@Mapper
(
componentModel
=
"spring"
,
uses
=
{},
unmappedTargetPolicy
=
ReportingPolicy
.
IGNORE
)
@Mapper
(
componentModel
=
"spring"
,
uses
=
{},
unmappedTargetPolicy
=
ReportingPolicy
.
IGNORE
)
public
interface
ServerDeployMapper
extends
BaseMapper
<
ServerDeployD
TO
,
ServerDeploy
>
{
public
interface
ServerDeployMapper
extends
BaseMapper
<
ServerDeployD
to
,
ServerDeploy
>
{
}
}
eladmin-system/src/main/java/me/zhengjie/modules/mnt/util/ScpClientUtil.java
View file @
e4ca7afc
...
@@ -16,15 +16,15 @@ public class ScpClientUtil {
...
@@ -16,15 +16,15 @@ public class ScpClientUtil {
static
private
ScpClientUtil
instance
;
static
private
ScpClientUtil
instance
;
static
synchronized
public
ScpClientUtil
getInstance
(
String
IP
,
int
port
,
String
username
,
String
passward
)
{
static
synchronized
public
ScpClientUtil
getInstance
(
String
ip
,
int
port
,
String
username
,
String
passward
)
{
if
(
instance
==
null
)
{
if
(
instance
==
null
)
{
instance
=
new
ScpClientUtil
(
IP
,
port
,
username
,
passward
);
instance
=
new
ScpClientUtil
(
ip
,
port
,
username
,
passward
);
}
}
return
instance
;
return
instance
;
}
}
public
ScpClientUtil
(
String
IP
,
int
port
,
String
username
,
String
passward
)
{
public
ScpClientUtil
(
String
ip
,
int
port
,
String
username
,
String
passward
)
{
this
.
ip
=
IP
;
this
.
ip
=
ip
;
this
.
port
=
port
;
this
.
port
=
port
;
this
.
username
=
username
;
this
.
username
=
username
;
this
.
password
=
passward
;
this
.
password
=
passward
;
...
...
eladmin-system/src/main/java/me/zhengjie/modules/mnt/websocket/MsgType.java
View file @
e4ca7afc
...
@@ -5,5 +5,12 @@ package me.zhengjie.modules.mnt.websocket;
...
@@ -5,5 +5,12 @@ package me.zhengjie.modules.mnt.websocket;
* @date: 2019-08-10 9:56
* @date: 2019-08-10 9:56
*/
*/
public
enum
MsgType
{
public
enum
MsgType
{
CONNECT
,
CLOSE
,
INFO
,
ERROR
/** 连接 */
CONNECT
,
/** 关闭 */
CLOSE
,
/** 信息 */
INFO
,
/** 错误 */
ERROR
}
}
eladmin-system/src/main/java/me/zhengjie/modules/mnt/websocket/WebSocketServer.java
View file @
e4ca7afc
...
@@ -8,6 +8,7 @@ import javax.websocket.*;
...
@@ -8,6 +8,7 @@ import javax.websocket.*;
import
javax.websocket.server.PathParam
;
import
javax.websocket.server.PathParam
;
import
javax.websocket.server.ServerEndpoint
;
import
javax.websocket.server.ServerEndpoint
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.util.Objects
;
import
java.util.concurrent.CopyOnWriteArraySet
;
import
java.util.concurrent.CopyOnWriteArraySet
;
/**
/**
* @author: ZhangHouYing
* @author: ZhangHouYing
...
@@ -58,7 +59,6 @@ public class WebSocketServer {
...
@@ -58,7 +59,6 @@ public class WebSocketServer {
/**
/**
* 收到客户端消息后调用的方法
* 收到客户端消息后调用的方法
*
* @param message 客户端发送过来的消息*/
* @param message 客户端发送过来的消息*/
@OnMessage
@OnMessage
public
void
onMessage
(
String
message
,
Session
session
)
{
public
void
onMessage
(
String
message
,
Session
session
)
{
...
@@ -73,11 +73,6 @@ public class WebSocketServer {
...
@@ -73,11 +73,6 @@ public class WebSocketServer {
}
}
}
}
/**
*
* @param session
* @param error
*/
@OnError
@OnError
public
void
onError
(
Session
session
,
Throwable
error
)
{
public
void
onError
(
Session
session
,
Throwable
error
)
{
log
.
error
(
"发生错误"
);
log
.
error
(
"发生错误"
);
...
@@ -86,7 +81,7 @@ public class WebSocketServer {
...
@@ -86,7 +81,7 @@ public class WebSocketServer {
/**
/**
* 实现服务器主动推送
* 实现服务器主动推送
*/
*/
p
ublic
void
sendMessage
(
String
message
)
throws
IOException
{
p
rivate
void
sendMessage
(
String
message
)
throws
IOException
{
this
.
session
.
getBasicRemote
().
sendText
(
message
);
this
.
session
.
getBasicRemote
().
sendText
(
message
);
}
}
...
@@ -105,9 +100,25 @@ public class WebSocketServer {
...
@@ -105,9 +100,25 @@ public class WebSocketServer {
}
else
if
(
item
.
sid
.
equals
(
sid
)){
}
else
if
(
item
.
sid
.
equals
(
sid
)){
item
.
sendMessage
(
message
);
item
.
sendMessage
(
message
);
}
}
}
catch
(
IOException
e
)
{
}
catch
(
IOException
ignored
)
{
}
continue
;
}
}
}
@Override
public
boolean
equals
(
Object
o
)
{
if
(
this
==
o
)
{
return
true
;
}
if
(
o
==
null
||
getClass
()
!=
o
.
getClass
())
{
return
false
;
}
}
WebSocketServer
that
=
(
WebSocketServer
)
o
;
return
Objects
.
equals
(
session
,
that
.
session
)
&&
Objects
.
equals
(
sid
,
that
.
sid
);
}
@Override
public
int
hashCode
()
{
return
Objects
.
hash
(
session
,
sid
);
}
}
}
}
eladmin-system/src/main/java/me/zhengjie/modules/monitor/rest/LimitController.java
View file @
e4ca7afc
...
@@ -12,7 +12,7 @@ import org.springframework.web.bind.annotation.RestController;
...
@@ -12,7 +12,7 @@ import org.springframework.web.bind.annotation.RestController;
import
java.util.concurrent.atomic.AtomicInteger
;
import
java.util.concurrent.atomic.AtomicInteger
;
/**
/**
*
*
@author /
* 接口限流测试类
* 接口限流测试类
*/
*/
@RestController
@RestController
...
...
Prev
1
2
3
4
5
6
7
8
Next
Write
Preview
Supports
Markdown
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