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
88477d18
Commit
88477d18
authored
Nov 24, 2019
by
dqjdda
Browse files
update
parent
40852235
Changes
11
Hide whitespace changes
Inline
Side-by-side
eladmin-system/src/main/java/me/zhengjie/modules/mnt/repository/ServerDeployRepository.java
View file @
88477d18
...
...
@@ -3,10 +3,16 @@ package me.zhengjie.modules.mnt.repository;
import
me.zhengjie.modules.mnt.domain.ServerDeploy
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.JpaSpecificationExecutor
;
import
org.springframework.data.jpa.repository.Modifying
;
import
org.springframework.data.jpa.repository.Query
;
/**
* @author zhanghouying
* @date 2019-08-24
*/
public
interface
ServerDeployRepository
extends
JpaRepository
<
ServerDeploy
,
String
>,
JpaSpecificationExecutor
{
@Modifying
@Query
(
value
=
"update mnt_server set account_id = null where account_id = ?1"
,
nativeQuery
=
true
)
void
changeByAccount
(
String
id
);
}
eladmin-system/src/main/java/me/zhengjie/modules/mnt/rest/DeployHistoryController.java
View file @
88477d18
...
...
@@ -34,23 +34,6 @@ public class DeployHistoryController {
return
new
ResponseEntity
(
deployhistoryService
.
queryAll
(
criteria
,
pageable
),
HttpStatus
.
OK
);
}
@Log
(
"新增DeployHistory"
)
@ApiOperation
(
value
=
"新增DeployHistory"
)
@PostMapping
@PreAuthorize
(
"@el.check('deployHistory:add')"
)
public
ResponseEntity
create
(
@Validated
@RequestBody
DeployHistory
resources
){
return
new
ResponseEntity
(
deployhistoryService
.
create
(
resources
),
HttpStatus
.
CREATED
);
}
@Log
(
"修改DeployHistory"
)
@ApiOperation
(
value
=
"修改DeployHistory"
)
@PutMapping
@PreAuthorize
(
"@el.check('deployHistory:edit')"
)
public
ResponseEntity
update
(
@Validated
@RequestBody
DeployHistory
resources
){
deployhistoryService
.
update
(
resources
);
return
new
ResponseEntity
(
HttpStatus
.
NO_CONTENT
);
}
@Log
(
"删除DeployHistory"
)
@ApiOperation
(
value
=
"删除DeployHistory"
)
@DeleteMapping
(
value
=
"/{id}"
)
...
...
eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/DeployHistoryService.java
View file @
88477d18
...
...
@@ -41,12 +41,6 @@ public interface DeployHistoryService {
*/
DeployHistoryDTO
create
(
DeployHistory
resources
);
/**
* update
* @param resources
*/
void
update
(
DeployHistory
resources
);
/**
* delete
* @param id
...
...
eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/dto/DeployHistoryQueryCriteria.java
View file @
88477d18
...
...
@@ -13,11 +13,6 @@ public class DeployHistoryQueryCriteria{
/**
* 精确
*/
@Query
private
String
deployId
;
/**
* 模糊
*/
@Query
(
type
=
Query
.
Type
.
INNER_LIKE
)
private
String
deployDate
;
@Query
(
blurry
=
"appName,ip,deployUser,deployId"
)
private
String
blurry
;
}
eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/dto/ServerDeployDTO.java
View file @
88477d18
package
me.zhengjie.modules.mnt.service.dto
;
import
lombok.Data
;
import
me.zhengjie.modules.mnt.service.ServerAccountService
;
import
me.zhengjie.modules.mnt.service.ServerDeployService
;
import
me.zhengjie.utils.SpringContextHolder
;
import
java.io.Serializable
;
...
...
@@ -20,4 +24,17 @@ public class ServerDeployDTO implements Serializable {
* 服务器账号
*/
private
String
accountId
;
/**
* 账号名称
*/
private
String
accountName
;
public
String
getAccountName
()
{
if
(
accountId
!=
null
){
ServerAccountService
serverAccountService
=
SpringContextHolder
.
getBean
(
ServerAccountService
.
class
);
return
serverAccountService
.
findById
(
accountId
).
getName
();
}
return
accountName
;
}
}
eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/impl/DeployHistoryServiceImpl.java
View file @
88477d18
...
...
@@ -58,16 +58,6 @@ public class DeployHistoryServiceImpl implements DeployHistoryService {
return
deployhistoryMapper
.
toDto
(
deployhistoryRepository
.
save
(
resources
));
}
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
update
(
DeployHistory
resources
)
{
Optional
<
DeployHistory
>
optionalDeployHistory
=
deployhistoryRepository
.
findById
(
resources
.
getId
());
ValidationUtil
.
isNull
(
optionalDeployHistory
,
"DeployHistory"
,
"id"
,
resources
.
getId
());
DeployHistory
deployhistory
=
optionalDeployHistory
.
get
();
deployhistory
.
copy
(
resources
);
deployhistoryRepository
.
save
(
deployhistory
);
}
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
delete
(
String
id
)
{
...
...
eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/impl/ServerAccountServiceImpl.java
View file @
88477d18
...
...
@@ -3,6 +3,7 @@ package me.zhengjie.modules.mnt.service.impl;
import
cn.hutool.core.util.IdUtil
;
import
me.zhengjie.modules.mnt.domain.ServerAccount
;
import
me.zhengjie.modules.mnt.repository.ServerAccountRepository
;
import
me.zhengjie.modules.mnt.repository.ServerDeployRepository
;
import
me.zhengjie.modules.mnt.service.ServerAccountService
;
import
me.zhengjie.modules.mnt.service.dto.ServerAccountDTO
;
import
me.zhengjie.modules.mnt.service.dto.ServerAccountQueryCriteria
;
...
...
@@ -10,6 +11,7 @@ import me.zhengjie.modules.mnt.service.mapper.ServerAccountMapper;
import
me.zhengjie.utils.PageUtil
;
import
me.zhengjie.utils.QueryHelp
;
import
me.zhengjie.utils.ValidationUtil
;
import
org.hibernate.mapping.IdGenerator
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Pageable
;
...
...
@@ -30,6 +32,9 @@ public class ServerAccountServiceImpl implements ServerAccountService {
@Autowired
private
ServerAccountRepository
serverAccountRepository
;
@Autowired
private
ServerDeployRepository
serverDeployRepository
;
@Autowired
private
ServerAccountMapper
serverAccountMapper
;
...
...
@@ -54,7 +59,7 @@ public class ServerAccountServiceImpl implements ServerAccountService {
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
ServerAccountDTO
create
(
ServerAccount
resources
)
{
resources
.
setId
(
IdUtil
.
simpleUUID
());
resources
.
setId
(
IdUtil
.
getSnowflake
(
0
,
0
).
toString
());
return
serverAccountMapper
.
toDto
(
serverAccountRepository
.
save
(
resources
));
}
...
...
@@ -72,5 +77,6 @@ public class ServerAccountServiceImpl implements ServerAccountService {
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
delete
(
String
id
)
{
serverAccountRepository
.
deleteById
(
id
);
serverDeployRepository
.
changeByAccount
(
id
);
}
}
eladmin-system/src/main/java/me/zhengjie/modules/monitor/domain/Server.java
View file @
88477d18
...
...
@@ -32,8 +32,8 @@ public class Server implements Serializable {
/**
* IP地址
*/
@Column
(
name
=
"
ip
"
,
nullable
=
false
)
private
String
ip
;
@Column
(
name
=
"
address
"
,
nullable
=
false
)
private
String
address
;
/**
* 访问端口
...
...
eladmin-system/src/main/java/me/zhengjie/modules/monitor/service/dto/ServerDTO.java
View file @
88477d18
...
...
@@ -18,7 +18,7 @@ public class ServerDTO implements Serializable {
private
String
name
;
// IP地址
private
String
ip
;
private
String
address
;
// 访问端口
private
Integer
port
;
...
...
eladmin-system/src/main/java/me/zhengjie/modules/monitor/service/dto/ServerQueryCriteria.java
View file @
88477d18
...
...
@@ -11,10 +11,6 @@ import me.zhengjie.annotation.Query;
public
class
ServerQueryCriteria
{
// 模糊
@Query
(
type
=
Query
.
Type
.
INNER_LIKE
)
private
String
name
;
// 模糊
@Query
(
type
=
Query
.
Type
.
INNER_LIKE
)
private
String
ip
;
}
@Query
(
blurry
=
"name,address"
)
private
String
blurry
;
}
\ No newline at end of file
eladmin-system/src/main/java/me/zhengjie/modules/monitor/service/impl/ServerServiceImpl.java
View file @
88477d18
...
...
@@ -43,7 +43,7 @@ public class ServerServiceImpl implements ServerService {
page
.
forEach
(
server
->
{
try
{
server
.
setState
(
"1"
);
String
url
=
String
.
format
(
"http://%s:%d/api/serverMonitor"
,
server
.
get
Ip
(),
server
.
getPort
());
String
url
=
String
.
format
(
"http://%s:%d/api/serverMonitor"
,
server
.
get
Address
(),
server
.
getPort
());
String
res
=
HttpUtil
.
get
(
url
,
1000
);
JSONObject
obj
=
JSONObject
.
parseObject
(
res
);
server
.
setCpuRate
(
obj
.
getDouble
(
"cpuRate"
));
...
...
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