Commit 6d941c09 authored by dqjdda's avatar dqjdda
Browse files

代码优化

parent 2853f394
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>eladmin-monitor</artifactId> <artifactId>eladmin-monitor</artifactId>
<version>2.2</version> <version>2.3</version>
<name>客户端监控模块</name> <name>客户端监控模块</name>
......
...@@ -3,8 +3,11 @@ package me.zhengjie.modules.mnt.domain; ...@@ -3,8 +3,11 @@ package me.zhengjie.modules.mnt.domain;
import lombok.Data; import lombok.Data;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions; import cn.hutool.core.bean.copier.CopyOptions;
import org.hibernate.annotations.CreationTimestamp;
import javax.persistence.*; import javax.persistence.*;
import java.io.Serializable; import java.io.Serializable;
import java.sql.Timestamp;
import java.util.Set; import java.util.Set;
/** /**
...@@ -37,6 +40,9 @@ public class Deploy implements Serializable { ...@@ -37,6 +40,9 @@ public class Deploy implements Serializable {
@JoinTable(name = "mnt_deploy_server", joinColumns = {@JoinColumn(name = "deploy_id",referencedColumnName = "id")}, inverseJoinColumns = {@JoinColumn(name = "server_id",referencedColumnName = "id")}) @JoinTable(name = "mnt_deploy_server", joinColumns = {@JoinColumn(name = "deploy_id",referencedColumnName = "id")}, inverseJoinColumns = {@JoinColumn(name = "server_id",referencedColumnName = "id")})
private Set<ServerDeploy> deploys; private Set<ServerDeploy> deploys;
@CreationTimestamp
private Timestamp createTime;
public void copy(Deploy source){ public void copy(Deploy source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
} }
......
...@@ -3,8 +3,11 @@ package me.zhengjie.modules.mnt.domain; ...@@ -3,8 +3,11 @@ package me.zhengjie.modules.mnt.domain;
import lombok.Data; import lombok.Data;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions; import cn.hutool.core.bean.copier.CopyOptions;
import org.hibernate.annotations.CreationTimestamp;
import javax.persistence.*; import javax.persistence.*;
import java.io.Serializable; import java.io.Serializable;
import java.sql.Timestamp;
/** /**
* @author zhanghouying * @author zhanghouying
...@@ -37,8 +40,9 @@ public class DeployHistory implements Serializable { ...@@ -37,8 +40,9 @@ public class DeployHistory implements Serializable {
/** /**
* 部署时间 * 部署时间
*/ */
@Column(name = "deploy_date",nullable = false) @Column(name = "deploy_date")
private String deployDate; @CreationTimestamp
private Timestamp deployDate;
/** /**
* 部署人员 * 部署人员
......
...@@ -8,5 +8,5 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor; ...@@ -8,5 +8,5 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
* @author zhanghouying * @author zhanghouying
* @date 2019-08-24 * @date 2019-08-24
*/ */
public interface DatabaseRepository extends JpaRepository<Database, String>, JpaSpecificationExecutor { public interface DatabaseRepository extends JpaRepository<Database, String>, JpaSpecificationExecutor<Database> {
} }
...@@ -8,5 +8,5 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor; ...@@ -8,5 +8,5 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
* @author zhanghouying * @author zhanghouying
* @date 2019-08-24 * @date 2019-08-24
*/ */
public interface DeployHistoryRepository extends JpaRepository<DeployHistory, String>, JpaSpecificationExecutor { public interface DeployHistoryRepository extends JpaRepository<DeployHistory, String>, JpaSpecificationExecutor<DeployHistory> {
} }
...@@ -12,9 +12,5 @@ import org.springframework.data.jpa.repository.Query; ...@@ -12,9 +12,5 @@ import org.springframework.data.jpa.repository.Query;
*/ */
public interface ServerDeployRepository extends JpaRepository<ServerDeploy, Long>, JpaSpecificationExecutor<ServerDeploy> { public interface ServerDeployRepository extends JpaRepository<ServerDeploy, Long>, JpaSpecificationExecutor<ServerDeploy> {
@Modifying
@Query(value = "update mnt_server set account_id = null where account_id = ?1", nativeQuery = true)
void changeByAccount(String id);
ServerDeploy findByIp(String ip); ServerDeploy findByIp(String ip);
} }
...@@ -6,7 +6,6 @@ import me.zhengjie.aop.log.Log; ...@@ -6,7 +6,6 @@ import me.zhengjie.aop.log.Log;
import me.zhengjie.modules.mnt.domain.App; import me.zhengjie.modules.mnt.domain.App;
import me.zhengjie.modules.mnt.service.AppService; import me.zhengjie.modules.mnt.service.AppService;
import me.zhengjie.modules.mnt.service.dto.AppQueryCriteria; import me.zhengjie.modules.mnt.service.dto.AppQueryCriteria;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
...@@ -23,31 +22,30 @@ import org.springframework.web.bind.annotation.*; ...@@ -23,31 +22,30 @@ import org.springframework.web.bind.annotation.*;
@RequestMapping("/api/app") @RequestMapping("/api/app")
public class AppController { public class AppController {
@Autowired private final AppService appService;
private AppService appService;
public AppController(AppService appService){ public AppController(AppService appService){
this.appService = this.appService; this.appService = appService;
} }
@Log("查询App") @Log("查询应用")
@ApiOperation(value = "查询App") @ApiOperation(value = "查询应用")
@GetMapping @GetMapping
@PreAuthorize("@el.check('app:list')") @PreAuthorize("@el.check('app:list')")
public ResponseEntity getApps(AppQueryCriteria criteria, Pageable pageable){ public ResponseEntity getApps(AppQueryCriteria criteria, Pageable pageable){
return new ResponseEntity(appService.queryAll(criteria,pageable),HttpStatus.OK); return new ResponseEntity<>(appService.queryAll(criteria,pageable),HttpStatus.OK);
} }
@Log("新增App") @Log("新增应用")
@ApiOperation(value = "新增App") @ApiOperation(value = "新增应用")
@PostMapping @PostMapping
@PreAuthorize("@el.check('app:add')") @PreAuthorize("@el.check('app:add')")
public ResponseEntity create(@Validated @RequestBody App resources){ public ResponseEntity create(@Validated @RequestBody App resources){
return new ResponseEntity(appService.create(resources),HttpStatus.CREATED); return new ResponseEntity<>(appService.create(resources),HttpStatus.CREATED);
} }
@Log("修改App") @Log("修改应用")
@ApiOperation(value = "修改App") @ApiOperation(value = "修改应用")
@PutMapping @PutMapping
@PreAuthorize("@el.check('app:edit')") @PreAuthorize("@el.check('app:edit')")
public ResponseEntity update(@Validated @RequestBody App resources){ public ResponseEntity update(@Validated @RequestBody App resources){
...@@ -55,8 +53,8 @@ public class AppController { ...@@ -55,8 +53,8 @@ public class AppController {
return new ResponseEntity(HttpStatus.NO_CONTENT); return new ResponseEntity(HttpStatus.NO_CONTENT);
} }
@Log("删除App") @Log("删除应用")
@ApiOperation(value = "删除App") @ApiOperation(value = "删除应用")
@DeleteMapping(value = "/{id}") @DeleteMapping(value = "/{id}")
@PreAuthorize("@el.check('app:del')") @PreAuthorize("@el.check('app:del')")
public ResponseEntity delete(@PathVariable Long id){ public ResponseEntity delete(@PathVariable Long id){
......
...@@ -6,7 +6,6 @@ import me.zhengjie.aop.log.Log; ...@@ -6,7 +6,6 @@ import me.zhengjie.aop.log.Log;
import me.zhengjie.modules.mnt.domain.Database; import me.zhengjie.modules.mnt.domain.Database;
import me.zhengjie.modules.mnt.service.DatabaseService; import me.zhengjie.modules.mnt.service.DatabaseService;
import me.zhengjie.modules.mnt.service.dto.DatabaseQueryCriteria; import me.zhengjie.modules.mnt.service.dto.DatabaseQueryCriteria;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
...@@ -23,27 +22,30 @@ import org.springframework.web.bind.annotation.*; ...@@ -23,27 +22,30 @@ import org.springframework.web.bind.annotation.*;
@RequestMapping("/api/database") @RequestMapping("/api/database")
public class DatabaseController { public class DatabaseController {
@Autowired private final DatabaseService databaseService;
private DatabaseService databaseService;
@Log("查询Database") public DatabaseController(DatabaseService databaseService) {
@ApiOperation(value = "查询Database") this.databaseService = databaseService;
}
@Log("查询数据库")
@ApiOperation(value = "查询数据库")
@GetMapping @GetMapping
@PreAuthorize("@el.check('database:list')") @PreAuthorize("@el.check('database:list')")
public ResponseEntity getDatabases(DatabaseQueryCriteria criteria, Pageable pageable){ public ResponseEntity getDatabases(DatabaseQueryCriteria criteria, Pageable pageable){
return new ResponseEntity(databaseService.queryAll(criteria,pageable),HttpStatus.OK); return new ResponseEntity<>(databaseService.queryAll(criteria,pageable),HttpStatus.OK);
} }
@Log("新增Database") @Log("新增数据库")
@ApiOperation(value = "新增Database") @ApiOperation(value = "新增数据库")
@PostMapping @PostMapping
@PreAuthorize("@el.check('database:add')") @PreAuthorize("@el.check('database:add')")
public ResponseEntity create(@Validated @RequestBody Database resources){ public ResponseEntity create(@Validated @RequestBody Database resources){
return new ResponseEntity(databaseService.create(resources),HttpStatus.CREATED); return new ResponseEntity<>(databaseService.create(resources),HttpStatus.CREATED);
} }
@Log("修改Database") @Log("修改数据库")
@ApiOperation(value = "修改Database") @ApiOperation(value = "修改数据库")
@PutMapping @PutMapping
@PreAuthorize("@el.check('database:edit')") @PreAuthorize("@el.check('database:edit')")
public ResponseEntity update(@Validated @RequestBody Database resources){ public ResponseEntity update(@Validated @RequestBody Database resources){
...@@ -51,8 +53,8 @@ public class DatabaseController { ...@@ -51,8 +53,8 @@ public class DatabaseController {
return new ResponseEntity(HttpStatus.NO_CONTENT); return new ResponseEntity(HttpStatus.NO_CONTENT);
} }
@Log("删除Database") @Log("删除数据库")
@ApiOperation(value = "删除Database") @ApiOperation(value = "删除数据库")
@DeleteMapping(value = "/{id}") @DeleteMapping(value = "/{id}")
@PreAuthorize("@el.check('database:del')") @PreAuthorize("@el.check('database:del')")
public ResponseEntity delete(@PathVariable String id){ public ResponseEntity delete(@PathVariable String id){
......
...@@ -8,7 +8,6 @@ import me.zhengjie.modules.mnt.domain.DeployHistory; ...@@ -8,7 +8,6 @@ import me.zhengjie.modules.mnt.domain.DeployHistory;
import me.zhengjie.modules.mnt.service.DeployService; import me.zhengjie.modules.mnt.service.DeployService;
import me.zhengjie.modules.mnt.service.dto.DeployQueryCriteria; import me.zhengjie.modules.mnt.service.dto.DeployQueryCriteria;
import me.zhengjie.utils.FileUtil; import me.zhengjie.utils.FileUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
...@@ -16,12 +15,11 @@ import org.springframework.security.access.prepost.PreAuthorize; ...@@ -16,12 +15,11 @@ import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File; import java.io.File;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Objects;
/** /**
* @author zhanghouying * @author zhanghouying
...@@ -34,27 +32,30 @@ public class DeployController { ...@@ -34,27 +32,30 @@ public class DeployController {
private String fileSavePath = System.getProperty("java.io.tmpdir"); private String fileSavePath = System.getProperty("java.io.tmpdir");
@Autowired private final DeployService deployService;
private DeployService deployService;
public DeployController(DeployService deployService) {
this.deployService = deployService;
}
@Log("查询Deploy") @Log("查询部署")
@ApiOperation(value = "查询Deploy") @ApiOperation(value = "查询部署")
@GetMapping @GetMapping
@PreAuthorize("@el.check('deploy:list')") @PreAuthorize("@el.check('deploy:list')")
public ResponseEntity getDeploys(DeployQueryCriteria criteria, Pageable pageable){ public ResponseEntity getDeploys(DeployQueryCriteria criteria, Pageable pageable){
return new ResponseEntity(deployService.queryAll(criteria,pageable),HttpStatus.OK); return new ResponseEntity<>(deployService.queryAll(criteria,pageable),HttpStatus.OK);
} }
@Log("新增Deploy") @Log("新增部署")
@ApiOperation(value = "新增Deploy") @ApiOperation(value = "新增部署")
@PostMapping @PostMapping
@PreAuthorize("@el.check('deploy:add')") @PreAuthorize("@el.check('deploy:add')")
public ResponseEntity create(@Validated @RequestBody Deploy resources){ public ResponseEntity create(@Validated @RequestBody Deploy resources){
return new ResponseEntity(deployService.create(resources),HttpStatus.CREATED); return new ResponseEntity<>(deployService.create(resources),HttpStatus.CREATED);
} }
@Log("修改Deploy") @Log("修改部署")
@ApiOperation(value = "修改Deploy") @ApiOperation(value = "修改部署")
@PutMapping @PutMapping
@PreAuthorize("@el.check('deploy:edit')") @PreAuthorize("@el.check('deploy:edit')")
public ResponseEntity update(@Validated @RequestBody Deploy resources){ public ResponseEntity update(@Validated @RequestBody Deploy resources){
...@@ -62,8 +63,8 @@ public class DeployController { ...@@ -62,8 +63,8 @@ public class DeployController {
return new ResponseEntity(HttpStatus.NO_CONTENT); return new ResponseEntity(HttpStatus.NO_CONTENT);
} }
@Log("删除Deploy") @Log("删除部署")
@ApiOperation(value = "删除Deploy") @ApiOperation(value = "删除部署")
@DeleteMapping(value = "/{id}") @DeleteMapping(value = "/{id}")
@PreAuthorize("@el.check('deploy:del')") @PreAuthorize("@el.check('deploy:del')")
public ResponseEntity delete(@PathVariable Long id){ public ResponseEntity delete(@PathVariable Long id){
...@@ -71,11 +72,11 @@ public class DeployController { ...@@ -71,11 +72,11 @@ public class DeployController {
return new ResponseEntity(HttpStatus.OK); return new ResponseEntity(HttpStatus.OK);
} }
@Log("上传文件Deploy") @Log("上传文件部署")
@ApiOperation(value = "上传文件Deploy") @ApiOperation(value = "上传文件部署")
@PostMapping(value = "/upload") @PostMapping(value = "/upload")
@PreAuthorize("@el.check('deploy:edit')") @PreAuthorize("@el.check('deploy:edit')")
public ResponseEntity upload(@RequestBody MultipartFile file, HttpServletRequest request, HttpServletResponse response)throws Exception{ public ResponseEntity upload(@RequestBody MultipartFile file, HttpServletRequest request)throws Exception{
Long id = Long.valueOf(request.getParameter("id")); Long id = Long.valueOf(request.getParameter("id"));
String fileName = ""; String fileName = "";
if(file != null){ if(file != null){
...@@ -88,42 +89,42 @@ public class DeployController { ...@@ -88,42 +89,42 @@ public class DeployController {
}else{ }else{
System.out.println("没有找到相对应的文件"); System.out.println("没有找到相对应的文件");
} }
System.out.println("文件上传的原名称为:"+file.getOriginalFilename()); System.out.println("文件上传的原名称为:"+ Objects.requireNonNull(file).getOriginalFilename());
Map map = new HashMap(2); Map<String,Object> map = new HashMap<>(2);
map.put("errno",0); map.put("errno",0);
map.put("id",fileName); map.put("id",fileName);
return new ResponseEntity(map,HttpStatus.OK); return new ResponseEntity<>(map,HttpStatus.OK);
} }
@Log("系统还原") @Log("系统还原")
@ApiOperation(value = "系统还原") @ApiOperation(value = "系统还原")
@PostMapping(value = "/serverReduction") @PostMapping(value = "/serverReduction")
@PreAuthorize("@el.check('deploy:edit')") @PreAuthorize("@el.check('deploy:edit')")
public ResponseEntity serverReduction(@Validated @RequestBody DeployHistory resources, HttpServletRequest request, HttpServletResponse response)throws Exception{ public ResponseEntity serverReduction(@Validated @RequestBody DeployHistory resources){
String result = deployService.serverReduction(resources); String result = deployService.serverReduction(resources);
return new ResponseEntity(result,HttpStatus.OK); return new ResponseEntity<>(result,HttpStatus.OK);
} }
@Log("服务运行状态") @Log("服务运行状态")
@ApiOperation(value = "服务运行状态") @ApiOperation(value = "服务运行状态")
@PostMapping(value = "/serverStatus") @PostMapping(value = "/serverStatus")
@PreAuthorize("@el.check('deploy:edit')") @PreAuthorize("@el.check('deploy:edit')")
public ResponseEntity serverStatus(@Validated @RequestBody Deploy resources, HttpServletRequest request, HttpServletResponse response)throws Exception{ public ResponseEntity serverStatus(@Validated @RequestBody Deploy resources){
String result = deployService.serverStatus(resources); String result = deployService.serverStatus(resources);
return new ResponseEntity(result,HttpStatus.OK); return new ResponseEntity<>(result,HttpStatus.OK);
} }
@Log("启动服务") @Log("启动服务")
@ApiOperation(value = "启动服务") @ApiOperation(value = "启动服务")
@PostMapping(value = "/startServer") @PostMapping(value = "/startServer")
@PreAuthorize("@el.check('deploy:edit')") @PreAuthorize("@el.check('deploy:edit')")
public ResponseEntity startServer(@Validated @RequestBody Deploy resources, HttpServletRequest request, HttpServletResponse response)throws Exception{ public ResponseEntity startServer(@Validated @RequestBody Deploy resources){
String result = deployService.startServer(resources); String result = deployService.startServer(resources);
return new ResponseEntity(result,HttpStatus.OK); return new ResponseEntity<>(result,HttpStatus.OK);
} }
@Log("停止服务") @Log("停止服务")
@ApiOperation(value = "停止服务") @ApiOperation(value = "停止服务")
@PostMapping(value = "/stopServer") @PostMapping(value = "/stopServer")
@PreAuthorize("@el.check('deploy:edit')") @PreAuthorize("@el.check('deploy:edit')")
public ResponseEntity stopServer(@Validated @RequestBody Deploy resources, HttpServletRequest request, HttpServletResponse response)throws Exception{ public ResponseEntity stopServer(@Validated @RequestBody Deploy resources){
String result = deployService.stopServer(resources); String result = deployService.stopServer(resources);
return new ResponseEntity(result,HttpStatus.OK); return new ResponseEntity<>(result,HttpStatus.OK);
} }
} }
...@@ -23,19 +23,22 @@ import org.springframework.web.bind.annotation.*; ...@@ -23,19 +23,22 @@ import org.springframework.web.bind.annotation.*;
@RequestMapping("/api/deployHistory") @RequestMapping("/api/deployHistory")
public class DeployHistoryController { public class DeployHistoryController {
@Autowired private final DeployHistoryService deployhistoryService;
private DeployHistoryService deployhistoryService;
@Log("查询DeployHistory") public DeployHistoryController(DeployHistoryService deployhistoryService) {
@ApiOperation(value = "查询DeployHistory") this.deployhistoryService = deployhistoryService;
}
@Log("查询部署历史")
@ApiOperation(value = "查询部署历史")
@GetMapping @GetMapping
@PreAuthorize("@el.check('deployHistory:list')") @PreAuthorize("@el.check('deployHistory:list')")
public ResponseEntity getDeployHistorys(DeployHistoryQueryCriteria criteria, Pageable pageable){ public ResponseEntity getDeployHistorys(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 = "删除DeployHistory") @ApiOperation(value = "删除部署历史")
@DeleteMapping(value = "/{id}") @DeleteMapping(value = "/{id}")
@PreAuthorize("hasAnyRole('deployHistory:del')") @PreAuthorize("hasAnyRole('deployHistory:del')")
public ResponseEntity delete(@PathVariable String id){ public ResponseEntity delete(@PathVariable String id){
......
...@@ -6,7 +6,6 @@ import me.zhengjie.aop.log.Log; ...@@ -6,7 +6,6 @@ import me.zhengjie.aop.log.Log;
import me.zhengjie.modules.mnt.domain.ServerDeploy; import me.zhengjie.modules.mnt.domain.ServerDeploy;
import me.zhengjie.modules.mnt.service.ServerDeployService; import me.zhengjie.modules.mnt.service.ServerDeployService;
import me.zhengjie.modules.mnt.service.dto.ServerDeployQueryCriteria; import me.zhengjie.modules.mnt.service.dto.ServerDeployQueryCriteria;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
...@@ -18,32 +17,35 @@ import org.springframework.web.bind.annotation.*; ...@@ -18,32 +17,35 @@ import org.springframework.web.bind.annotation.*;
* @author zhanghouying * @author zhanghouying
* @date 2019-08-24 * @date 2019-08-24
*/ */
@Api(tags = "服务器部署管理") @Api(tags = "服务器管理")
@RestController @RestController
@RequestMapping("/api/serverDeploy") @RequestMapping("/api/serverDeploy")
public class ServerDeployController { public class ServerDeployController {
@Autowired private final ServerDeployService serverDeployService;
private ServerDeployService serverDeployService;
@Log("查询Server") public ServerDeployController(ServerDeployService serverDeployService) {
@ApiOperation(value = "查询Server") this.serverDeployService = serverDeployService;
}
@Log("查询服务器")
@ApiOperation(value = "查询服务器")
@GetMapping @GetMapping
@PreAuthorize("@el.check('serverDeploy:list')") @PreAuthorize("@el.check('serverDeploy:list')")
public ResponseEntity getServers(ServerDeployQueryCriteria criteria, Pageable pageable){ public ResponseEntity getServers(ServerDeployQueryCriteria criteria, Pageable pageable){
return new ResponseEntity(serverDeployService.queryAll(criteria,pageable),HttpStatus.OK); return new ResponseEntity<>(serverDeployService.queryAll(criteria,pageable),HttpStatus.OK);
} }
@Log("新增Server") @Log("新增服务器")
@ApiOperation(value = "新增Server") @ApiOperation(value = "新增服务器")
@PostMapping @PostMapping
@PreAuthorize("@el.check('serverDeploy:add')") @PreAuthorize("@el.check('serverDeploy:add')")
public ResponseEntity create(@Validated @RequestBody ServerDeploy resources){ public ResponseEntity create(@Validated @RequestBody ServerDeploy resources){
return new ResponseEntity(serverDeployService.create(resources),HttpStatus.CREATED); return new ResponseEntity<>(serverDeployService.create(resources),HttpStatus.CREATED);
} }
@Log("修改Server") @Log("修改服务器")
@ApiOperation(value = "修改Server") @ApiOperation(value = "修改服务器")
@PutMapping @PutMapping
@PreAuthorize("@el.check('serverDeploy:edit')") @PreAuthorize("@el.check('serverDeploy:edit')")
public ResponseEntity update(@Validated @RequestBody ServerDeploy resources){ public ResponseEntity update(@Validated @RequestBody ServerDeploy resources){
...@@ -51,7 +53,7 @@ public class ServerDeployController { ...@@ -51,7 +53,7 @@ public class ServerDeployController {
return new ResponseEntity(HttpStatus.NO_CONTENT); return new ResponseEntity(HttpStatus.NO_CONTENT);
} }
@Log("删除Server") @Log("删除服务器")
@ApiOperation(value = "删除Server") @ApiOperation(value = "删除Server")
@DeleteMapping(value = "/{id:.+}") @DeleteMapping(value = "/{id:.+}")
@PreAuthorize("@el.check('serverDeploy:del')") @PreAuthorize("@el.check('serverDeploy:del')")
......
...@@ -11,44 +11,15 @@ import org.springframework.data.domain.Pageable; ...@@ -11,44 +11,15 @@ import org.springframework.data.domain.Pageable;
*/ */
public interface AppService { public interface AppService {
/**
* queryAll 分页
* @param criteria
* @param pageable
* @return
*/
Object queryAll(AppQueryCriteria criteria, Pageable pageable); Object queryAll(AppQueryCriteria criteria, Pageable pageable);
/** Object queryAll(AppQueryCriteria criteria);
* queryAll 不分页
* @param criteria
* @return
*/
public Object queryAll(AppQueryCriteria criteria);
/**
* findById
* @param id
* @return
*/
AppDTO findById(Long id); AppDTO findById(Long id);
/**
* create
* @param resources
* @return
*/
AppDTO create(App resources); AppDTO create(App resources);
/**
* update
* @param resources
*/
void update(App resources); void update(App resources);
/**
* delete
* @param id
*/
void delete(Long id); void delete(Long id);
} }
...@@ -6,49 +6,20 @@ import me.zhengjie.modules.mnt.service.dto.DatabaseQueryCriteria; ...@@ -6,49 +6,20 @@ import me.zhengjie.modules.mnt.service.dto.DatabaseQueryCriteria;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
/** /**
* @author: ZhangHouYing * @author ZhangHouYing
* @date 2019-08-24 * @date 2019-08-24
*/ */
public interface DatabaseService { public interface DatabaseService {
/**
* queryAll 分页
* @param criteria
* @param pageable
* @return
*/
Object queryAll(DatabaseQueryCriteria criteria, Pageable pageable); Object queryAll(DatabaseQueryCriteria criteria, Pageable pageable);
/** Object queryAll(DatabaseQueryCriteria criteria);
* queryAll 不分页
* @param criteria
* @return
*/
public Object queryAll(DatabaseQueryCriteria criteria);
/**
* findById
* @param id
* @return
*/
DatabaseDTO findById(String id); DatabaseDTO findById(String id);
/**
* create
* @param resources
* @return
*/
DatabaseDTO create(Database resources); DatabaseDTO create(Database resources);
/**
* update
* @param resources
*/
void update(Database resources); void update(Database resources);
/**
* delete
* @param id
*/
void delete(String id); void delete(String id);
} }
...@@ -5,45 +5,15 @@ import me.zhengjie.modules.mnt.service.dto.DeployHistoryDTO; ...@@ -5,45 +5,15 @@ import me.zhengjie.modules.mnt.service.dto.DeployHistoryDTO;
import me.zhengjie.modules.mnt.service.dto.DeployHistoryQueryCriteria; import me.zhengjie.modules.mnt.service.dto.DeployHistoryQueryCriteria;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
/**
*
* @author: ZhangHouYing
* @date 2019-08-24
*/
public interface DeployHistoryService { public interface DeployHistoryService {
/**
* queryAll 分页
* @param criteria
* @param pageable
* @return
*/
Object queryAll(DeployHistoryQueryCriteria criteria, Pageable pageable); Object queryAll(DeployHistoryQueryCriteria criteria, Pageable pageable);
/** Object queryAll(DeployHistoryQueryCriteria criteria);
* queryAll 不分页
* @param criteria
* @return
*/
public Object queryAll(DeployHistoryQueryCriteria criteria);
/**
* findById
* @param id
* @return
*/
DeployHistoryDTO findById(String id); DeployHistoryDTO findById(String id);
/**
* create
* @param resources
* @return
*/
DeployHistoryDTO create(DeployHistory resources); DeployHistoryDTO create(DeployHistory resources);
/**
* delete
* @param id
*/
void delete(String id); void delete(String id);
} }
...@@ -12,81 +12,49 @@ import org.springframework.data.domain.Pageable; ...@@ -12,81 +12,49 @@ import org.springframework.data.domain.Pageable;
*/ */
public interface DeployService { public interface DeployService {
/**
* queryAll 分页
* @param criteria
* @param pageable
* @return
*/
Object queryAll(DeployQueryCriteria criteria, Pageable pageable); Object queryAll(DeployQueryCriteria criteria, Pageable pageable);
/** Object queryAll(DeployQueryCriteria criteria);
* queryAll 不分页
* @param criteria
* @return
*/
public Object queryAll(DeployQueryCriteria criteria);
/**
* findById
* @param id
* @return
*/
DeployDTO findById(Long id); DeployDTO findById(Long id);
/**
* create
* @CacheEvict(allEntries = true)
* @param resources
* @return
*/
DeployDTO create(Deploy resources); DeployDTO create(Deploy resources);
/**
* update
* @CacheEvict(allEntries = true)
* @param resources
*/
void update(Deploy resources); void update(Deploy resources);
/**
* delete
* @CacheEvict(allEntries = true)
* @param id
*/
void delete(Long id); void delete(Long id);
/** /**
* 部署文件到服务器 * 部署文件到服务器
* @param fileSavePath * @param fileSavePath 文件路径
* @param appId * @param appId 应用ID
* @return * @return /
*/ */
public String deploy(String fileSavePath, Long appId); String deploy(String fileSavePath, Long appId);
/** /**
* 查询部署状态 * 查询部署状态
* @param resources * @param resources /
* @return * @return /
*/ */
public String serverStatus(Deploy resources); String serverStatus(Deploy resources);
/** /**
* 启动服务 * 启动服务
* @param resources * @param resources /
* @return * @return /
*/ */
public String startServer(Deploy resources); String startServer(Deploy resources);
/** /**
* 停止服务 * 停止服务
* @param resources * @param resources /
* @return * @return /
*/ */
public String stopServer(Deploy resources); String stopServer(Deploy resources);
/** /**
* 停止服务 * 停止服务
* @param resources * @param resources /
* @return * @return /
*/ */
public String serverReduction(DeployHistory resources); String serverReduction(DeployHistory resources);
} }
...@@ -11,45 +11,16 @@ import org.springframework.data.domain.Pageable; ...@@ -11,45 +11,16 @@ import org.springframework.data.domain.Pageable;
*/ */
public interface ServerDeployService { public interface ServerDeployService {
/**
* queryAll 分页
* @param criteria
* @param pageable
* @return
*/
Object queryAll(ServerDeployQueryCriteria criteria, Pageable pageable); Object queryAll(ServerDeployQueryCriteria criteria, Pageable pageable);
/** Object queryAll(ServerDeployQueryCriteria criteria);
* queryAll 不分页
* @param criteria
* @return
*/
public Object queryAll(ServerDeployQueryCriteria criteria);
/**
* findById
* @param id
* @return
*/
ServerDeployDTO findById(Long id); ServerDeployDTO findById(Long id);
/**
* create
* @param resources
* @return
*/
ServerDeployDTO create(ServerDeploy resources); ServerDeployDTO create(ServerDeploy resources);
/**
* update
* @param resources
*/
void update(ServerDeploy resources); void update(ServerDeploy resources);
/**
* delete
* @param id
*/
void delete(Long id); void delete(Long id);
ServerDeployDTO findByIp(String ip); ServerDeployDTO findByIp(String ip);
......
...@@ -16,7 +16,7 @@ public class AppDTO implements Serializable { ...@@ -16,7 +16,7 @@ public class AppDTO implements Serializable {
/** /**
* 应用编号 * 应用编号
*/ */
private String id; private Long id;
/** /**
* 应用名称 * 应用名称
......
package me.zhengjie.modules.mnt.service.dto; package me.zhengjie.modules.mnt.service.dto;
import cn.hutool.core.collection.CollectionUtil;
import lombok.Data; import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
import java.sql.Timestamp;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
/** /**
...@@ -24,9 +27,19 @@ public class DeployDTO implements Serializable { ...@@ -24,9 +27,19 @@ public class DeployDTO implements Serializable {
*/ */
private Set<ServerDeployDTO> deploys; private Set<ServerDeployDTO> deploys;
private String servers;
/** /**
* 服务状态 * 服务状态
*/ */
private String status; private String status;
private Timestamp createTime;
public String getServers() {
if(CollectionUtil.isNotEmpty(deploys)){
return deploys.stream().map(ServerDeployDTO::getName).collect(Collectors.joining(","));
}
return servers;
}
} }
...@@ -2,6 +2,7 @@ package me.zhengjie.modules.mnt.service.dto; ...@@ -2,6 +2,7 @@ package me.zhengjie.modules.mnt.service.dto;
import lombok.Data; import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
import java.sql.Timestamp;
/** /**
...@@ -29,7 +30,7 @@ public class DeployHistoryDTO implements Serializable { ...@@ -29,7 +30,7 @@ public class DeployHistoryDTO implements Serializable {
/** /**
* 部署时间 * 部署时间
*/ */
private String deployDate; private Timestamp deployDate;
/** /**
* 部署人员 * 部署人员
......
...@@ -2,6 +2,8 @@ package me.zhengjie.modules.mnt.service.dto; ...@@ -2,6 +2,8 @@ package me.zhengjie.modules.mnt.service.dto;
import lombok.Data; import lombok.Data;
import me.zhengjie.annotation.Query; import me.zhengjie.annotation.Query;
import java.sql.Timestamp;
import java.util.List;
/** /**
* @author zhanghouying * @author zhanghouying
...@@ -15,4 +17,7 @@ public class DeployHistoryQueryCriteria{ ...@@ -15,4 +17,7 @@ public class DeployHistoryQueryCriteria{
*/ */
@Query(blurry = "appName,ip,deployUser,deployId") @Query(blurry = "appName,ip,deployUser,deployId")
private String blurry; private String blurry;
@Query(type = Query.Type.BETWEEN)
private List<Timestamp> deployDate;
} }
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment