pull/872/head
Jie Zheng 2025-01-15 10:37:18 +08:00
parent 008181b079
commit 13ae86ad15
5 changed files with 43 additions and 43 deletions

View File

@ -37,24 +37,24 @@ public class DeployHistory implements Serializable {
@Id @Id
@Column(name = "history_id") @Column(name = "history_id")
@ApiModelProperty(value = "ID", hidden = true) @ApiModelProperty(value = "ID", hidden = true)
private String id; private String id;
@ApiModelProperty(value = "应用名称") @ApiModelProperty(value = "应用名称")
private String appName; private String appName;
@ApiModelProperty(value = "IP") @ApiModelProperty(value = "IP")
private String ip; private String ip;
@CreationTimestamp @CreationTimestamp
@ApiModelProperty(value = "部署时间") @ApiModelProperty(value = "部署时间")
private Timestamp deployDate; private Timestamp deployDate;
@ApiModelProperty(value = "部署者") @ApiModelProperty(value = "部署者")
private String deployUser; private String deployUser;
@ApiModelProperty(value = "部署ID") @ApiModelProperty(value = "部署ID")
private Long deployId; private Long deployId;
public void copy(DeployHistory source){ public void copy(DeployHistory source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));

View File

@ -55,7 +55,7 @@ public class AppController {
@ApiOperation(value = "查询应用") @ApiOperation(value = "查询应用")
@GetMapping @GetMapping
@PreAuthorize("@el.check('app:list')") @PreAuthorize("@el.check('app:list')")
public ResponseEntity<PageResult<AppDto>> queryApp(AppQueryCriteria criteria, Pageable pageable){ public ResponseEntity<PageResult<AppDto>> queryApp(AppQueryCriteria criteria, Pageable pageable){
return new ResponseEntity<>(appService.queryAll(criteria,pageable),HttpStatus.OK); return new ResponseEntity<>(appService.queryAll(criteria,pageable),HttpStatus.OK);
} }
@ -63,7 +63,7 @@ public class AppController {
@Log("新增应用") @Log("新增应用")
@ApiOperation(value = "新增应用") @ApiOperation(value = "新增应用")
@PostMapping @PostMapping
@PreAuthorize("@el.check('app:add')") @PreAuthorize("@el.check('app:add')")
public ResponseEntity<Object> createApp(@Validated @RequestBody App resources){ public ResponseEntity<Object> createApp(@Validated @RequestBody App resources){
appService.create(resources); appService.create(resources);
return new ResponseEntity<>(HttpStatus.CREATED); return new ResponseEntity<>(HttpStatus.CREATED);
@ -72,7 +72,7 @@ public class AppController {
@Log("修改应用") @Log("修改应用")
@ApiOperation(value = "修改应用") @ApiOperation(value = "修改应用")
@PutMapping @PutMapping
@PreAuthorize("@el.check('app:edit')") @PreAuthorize("@el.check('app:edit')")
public ResponseEntity<Object> updateApp(@Validated @RequestBody App resources){ public ResponseEntity<Object> updateApp(@Validated @RequestBody App resources){
appService.update(resources); appService.update(resources);
return new ResponseEntity<>(HttpStatus.NO_CONTENT); return new ResponseEntity<>(HttpStatus.NO_CONTENT);
@ -80,8 +80,8 @@ public class AppController {
@Log("删除应用") @Log("删除应用")
@ApiOperation(value = "删除应用") @ApiOperation(value = "删除应用")
@DeleteMapping @DeleteMapping
@PreAuthorize("@el.check('app:del')") @PreAuthorize("@el.check('app:del')")
public ResponseEntity<Object> deleteApp(@RequestBody Set<Long> ids){ public ResponseEntity<Object> deleteApp(@RequestBody Set<Long> ids){
appService.delete(ids); appService.delete(ids);
return new ResponseEntity<>(HttpStatus.OK); return new ResponseEntity<>(HttpStatus.OK);

View File

@ -53,14 +53,14 @@ public class DeployHistoryController {
@ApiOperation(value = "查询部署历史") @ApiOperation(value = "查询部署历史")
@GetMapping @GetMapping
@PreAuthorize("@el.check('deployHistory:list')") @PreAuthorize("@el.check('deployHistory:list')")
public ResponseEntity<PageResult<DeployHistoryDto>> queryDeployHistory(DeployHistoryQueryCriteria criteria, Pageable pageable){ public ResponseEntity<PageResult<DeployHistoryDto>> queryDeployHistory(DeployHistoryQueryCriteria criteria, Pageable pageable){
return new ResponseEntity<>(deployhistoryService.queryAll(criteria,pageable),HttpStatus.OK); return new ResponseEntity<>(deployhistoryService.queryAll(criteria,pageable),HttpStatus.OK);
} }
@Log("删除DeployHistory") @Log("删除DeployHistory")
@ApiOperation(value = "删除部署历史") @ApiOperation(value = "删除部署历史")
@DeleteMapping @DeleteMapping
@PreAuthorize("@el.check('deployHistory:del')") @PreAuthorize("@el.check('deployHistory:del')")
public ResponseEntity<Object> deleteDeployHistory(@RequestBody Set<String> ids){ public ResponseEntity<Object> deleteDeployHistory(@RequestBody Set<String> ids){
deployhistoryService.delete(ids); deployhistoryService.delete(ids);

View File

@ -55,15 +55,15 @@ public class ServerDeployController {
@ApiOperation(value = "查询服务器") @ApiOperation(value = "查询服务器")
@GetMapping @GetMapping
@PreAuthorize("@el.check('serverDeploy:list')") @PreAuthorize("@el.check('serverDeploy:list')")
public ResponseEntity<PageResult<ServerDeployDto>> queryServerDeploy(ServerDeployQueryCriteria criteria, Pageable pageable){ public ResponseEntity<PageResult<ServerDeployDto>> queryServerDeploy(ServerDeployQueryCriteria criteria, Pageable pageable){
return new ResponseEntity<>(serverDeployService.queryAll(criteria,pageable),HttpStatus.OK); return new ResponseEntity<>(serverDeployService.queryAll(criteria,pageable),HttpStatus.OK);
} }
@Log("新增服务器") @Log("新增服务器")
@ApiOperation(value = "新增服务器") @ApiOperation(value = "新增服务器")
@PostMapping @PostMapping
@PreAuthorize("@el.check('serverDeploy:add')") @PreAuthorize("@el.check('serverDeploy:add')")
public ResponseEntity<Object> createServerDeploy(@Validated @RequestBody ServerDeploy resources){ public ResponseEntity<Object> createServerDeploy(@Validated @RequestBody ServerDeploy resources){
serverDeployService.create(resources); serverDeployService.create(resources);
return new ResponseEntity<>(HttpStatus.CREATED); return new ResponseEntity<>(HttpStatus.CREATED);
@ -72,7 +72,7 @@ public class ServerDeployController {
@Log("修改服务器") @Log("修改服务器")
@ApiOperation(value = "修改服务器") @ApiOperation(value = "修改服务器")
@PutMapping @PutMapping
@PreAuthorize("@el.check('serverDeploy:edit')") @PreAuthorize("@el.check('serverDeploy:edit')")
public ResponseEntity<Object> updateServerDeploy(@Validated @RequestBody ServerDeploy resources){ public ResponseEntity<Object> updateServerDeploy(@Validated @RequestBody ServerDeploy resources){
serverDeployService.update(resources); serverDeployService.update(resources);
return new ResponseEntity<>(HttpStatus.NO_CONTENT); return new ResponseEntity<>(HttpStatus.NO_CONTENT);
@ -80,18 +80,18 @@ public class ServerDeployController {
@Log("删除服务器") @Log("删除服务器")
@ApiOperation(value = "删除Server") @ApiOperation(value = "删除Server")
@DeleteMapping @DeleteMapping
@PreAuthorize("@el.check('serverDeploy:del')") @PreAuthorize("@el.check('serverDeploy:del')")
public ResponseEntity<Object> deleteServerDeploy(@RequestBody Set<Long> ids){ public ResponseEntity<Object> deleteServerDeploy(@RequestBody Set<Long> ids){
serverDeployService.delete(ids); serverDeployService.delete(ids);
return new ResponseEntity<>(HttpStatus.OK); return new ResponseEntity<>(HttpStatus.OK);
} }
@Log("测试连接服务器") @Log("测试连接服务器")
@ApiOperation(value = "测试连接服务器") @ApiOperation(value = "测试连接服务器")
@PostMapping("/testConnect") @PostMapping("/testConnect")
@PreAuthorize("@el.check('serverDeploy:add')") @PreAuthorize("@el.check('serverDeploy:add')")
public ResponseEntity<Object> testConnectServerDeploy(@Validated @RequestBody ServerDeploy resources){ public ResponseEntity<Object> testConnectServerDeploy(@Validated @RequestBody ServerDeploy resources){
return new ResponseEntity<>(serverDeployService.testConnect(resources),HttpStatus.CREATED); return new ResponseEntity<>(serverDeployService.testConnect(resources),HttpStatus.CREATED);
} }
} }

View File

@ -67,22 +67,22 @@ public class ServerDeployServiceImpl implements ServerDeployService {
return serverDeployMapper.toDto(deploy); return serverDeployMapper.toDto(deploy);
} }
@Override @Override
public Boolean testConnect(ServerDeploy resources) { public Boolean testConnect(ServerDeploy resources) {
ExecuteShellUtil executeShellUtil = null; ExecuteShellUtil executeShellUtil = null;
try { try {
executeShellUtil = new ExecuteShellUtil(resources.getIp(), resources.getAccount(), resources.getPassword(),resources.getPort()); executeShellUtil = new ExecuteShellUtil(resources.getIp(), resources.getAccount(), resources.getPassword(),resources.getPort());
return executeShellUtil.execute("ls")==0; return executeShellUtil.execute("ls")==0;
} catch (Exception e) { } catch (Exception e) {
return false; return false;
}finally { }finally {
if (executeShellUtil != null) { if (executeShellUtil != null) {
executeShellUtil.close(); executeShellUtil.close();
} }
} }
} }
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void create(ServerDeploy resources) { public void create(ServerDeploy resources) {
serverDeployRepository.save(resources); serverDeployRepository.save(resources);
@ -93,7 +93,7 @@ public class ServerDeployServiceImpl implements ServerDeployService {
public void update(ServerDeploy resources) { public void update(ServerDeploy resources) {
ServerDeploy serverDeploy = serverDeployRepository.findById(resources.getId()).orElseGet(ServerDeploy::new); ServerDeploy serverDeploy = serverDeployRepository.findById(resources.getId()).orElseGet(ServerDeploy::new);
ValidationUtil.isNull( serverDeploy.getId(),"ServerDeploy","id",resources.getId()); ValidationUtil.isNull( serverDeploy.getId(),"ServerDeploy","id",resources.getId());
serverDeploy.copy(resources); serverDeploy.copy(resources);
serverDeployRepository.save(serverDeploy); serverDeployRepository.save(serverDeploy);
} }