From 468a092d217150f5c85c262355302828b7fd5c9d Mon Sep 17 00:00:00 2001 From: dqjdda <201507802@qq.com> Date: Sun, 24 Nov 2019 20:48:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/mnt/domain/ServerAccount.java | 46 ----------- .../modules/mnt/domain/ServerDeploy.java | 24 ++++-- .../repository/ServerAccountRepository.java | 12 --- .../repository/ServerDeployRepository.java | 4 +- .../mnt/rest/ServerAccountController.java | 61 -------------- .../mnt/rest/ServerDeployController.java | 2 +- .../mnt/service/ServerAccountService.java | 54 ------------ .../mnt/service/ServerDeployService.java | 6 +- .../mnt/service/dto/ServerAccountDTO.java | 33 -------- .../dto/ServerAccountQueryCriteria.java | 25 ------ .../mnt/service/dto/ServerDeployDTO.java | 34 +++----- .../dto/ServerDeployQueryCriteria.java | 9 +- .../mnt/service/impl/DeployServiceImpl.java | 32 +------- .../impl/ServerAccountServiceImpl.java | 82 ------------------- .../service/impl/ServerDeployServiceImpl.java | 10 ++- .../service/mapper/ServerAccountMapper.java | 16 ---- 16 files changed, 55 insertions(+), 395 deletions(-) delete mode 100644 eladmin-system/src/main/java/me/zhengjie/modules/mnt/domain/ServerAccount.java delete mode 100644 eladmin-system/src/main/java/me/zhengjie/modules/mnt/repository/ServerAccountRepository.java delete mode 100644 eladmin-system/src/main/java/me/zhengjie/modules/mnt/rest/ServerAccountController.java delete mode 100644 eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/ServerAccountService.java delete mode 100644 eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/dto/ServerAccountDTO.java delete mode 100644 eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/dto/ServerAccountQueryCriteria.java delete mode 100644 eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/impl/ServerAccountServiceImpl.java delete mode 100644 eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/mapper/ServerAccountMapper.java diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/domain/ServerAccount.java b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/domain/ServerAccount.java deleted file mode 100644 index 86d62925..00000000 --- a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/domain/ServerAccount.java +++ /dev/null @@ -1,46 +0,0 @@ -package me.zhengjie.modules.mnt.domain; - -import lombok.Data; -import cn.hutool.core.bean.BeanUtil; -import cn.hutool.core.bean.copier.CopyOptions; -import javax.persistence.*; -import java.io.Serializable; - -/** -* @author zhanghouying -* @date 2019-08-24 -*/ -@Entity -@Data -@Table(name="mnt_server_account") -public class ServerAccount implements Serializable { - - /** - * 编号 - */ - @Id - @Column(name = "id") - private String id; - - /** - * 名称 - */ - @Column(name = "name") - private String name; - - /** - * 账号 - */ - @Column(name = "account") - private String account; - - /** - * 密码 - */ - @Column(name = "password") - private String password; - - public void copy(ServerAccount source){ - BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); - } -} diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/domain/ServerDeploy.java b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/domain/ServerDeploy.java index 49a2a07f..adfc5ca1 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/domain/ServerDeploy.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/domain/ServerDeploy.java @@ -3,8 +3,11 @@ package me.zhengjie.modules.mnt.domain; import lombok.Data; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.copier.CopyOptions; +import org.hibernate.annotations.CreationTimestamp; + import javax.persistence.*; import java.io.Serializable; +import java.sql.Timestamp; /** * @author zhanghouying @@ -19,14 +22,21 @@ public class ServerDeploy implements Serializable { * 服务器IP */ @Id - @Column(name = "id") - private String id; + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; - /** - * 服务器账号 - */ - @Column(name = "account_id") - private String accountId; + private String name; + + private String ip; + + private Integer port; + + private String account; + + private String password; + + @CreationTimestamp + private Timestamp createTime; public void copy(ServerDeploy source){ BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/repository/ServerAccountRepository.java b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/repository/ServerAccountRepository.java deleted file mode 100644 index 88e96b5d..00000000 --- a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/repository/ServerAccountRepository.java +++ /dev/null @@ -1,12 +0,0 @@ -package me.zhengjie.modules.mnt.repository; - -import me.zhengjie.modules.mnt.domain.ServerAccount; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.JpaSpecificationExecutor; - -/** -* @author zhanghouying -* @date 2019-08-24 -*/ -public interface ServerAccountRepository extends JpaRepository, JpaSpecificationExecutor { -} diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/repository/ServerDeployRepository.java b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/repository/ServerDeployRepository.java index a4c3a98e..a90f9e33 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/repository/ServerDeployRepository.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/repository/ServerDeployRepository.java @@ -10,9 +10,11 @@ import org.springframework.data.jpa.repository.Query; * @author zhanghouying * @date 2019-08-24 */ -public interface ServerDeployRepository extends JpaRepository, JpaSpecificationExecutor { +public interface ServerDeployRepository extends JpaRepository, JpaSpecificationExecutor { @Modifying @Query(value = "update mnt_server set account_id = null where account_id = ?1", nativeQuery = true) void changeByAccount(String id); + + ServerDeploy findByIp(String ip); } diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/rest/ServerAccountController.java b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/rest/ServerAccountController.java deleted file mode 100644 index b6ebd255..00000000 --- a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/rest/ServerAccountController.java +++ /dev/null @@ -1,61 +0,0 @@ -package me.zhengjie.modules.mnt.rest; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import me.zhengjie.aop.log.Log; -import me.zhengjie.modules.mnt.domain.ServerAccount; -import me.zhengjie.modules.mnt.service.dto.ServerAccountQueryCriteria; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Pageable; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -/** -* @author zhanghouying -* @date 2019-08-24 -*/ -@Api(tags = "服务器账号管理") -@RestController -@RequestMapping("/api/serverAccount") -public class ServerAccountController { - - @Autowired - private me.zhengjie.modules.mnt.service.ServerAccountService ServerAccountService; - - @Log("查询ServerAccount") - @ApiOperation(value = "查询ServerAccount") - @GetMapping - @PreAuthorize("@el.check('serverAccount:list')") - public ResponseEntity getServerAccounts(ServerAccountQueryCriteria criteria, Pageable pageable){ - return new ResponseEntity(ServerAccountService.queryAll(criteria,pageable),HttpStatus.OK); - } - - @Log("新增ServerAccount") - @ApiOperation(value = "新增ServerAccount") - @PostMapping - @PreAuthorize("@el.check('serverAccount:add')") - public ResponseEntity create(@Validated @RequestBody ServerAccount resources){ - return new ResponseEntity(ServerAccountService.create(resources),HttpStatus.CREATED); - } - - @Log("修改ServerAccount") - @ApiOperation(value = "修改ServerAccount") - @PutMapping - @PreAuthorize("@el.check('serverAccount:edit')") - public ResponseEntity update(@Validated @RequestBody ServerAccount resources){ - ServerAccountService.update(resources); - return new ResponseEntity(HttpStatus.NO_CONTENT); - } - - @Log("删除ServerAccount") - @ApiOperation(value = "删除ServerAccount") - @DeleteMapping(value = "/{id}") - @PreAuthorize("@el.check('serverAccount:del')") - public ResponseEntity delete(@PathVariable String id){ - ServerAccountService.delete(id); - return new ResponseEntity(HttpStatus.OK); - } -} diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/rest/ServerDeployController.java b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/rest/ServerDeployController.java index 58400c48..a7eaee1c 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/rest/ServerDeployController.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/rest/ServerDeployController.java @@ -55,7 +55,7 @@ public class ServerDeployController { @ApiOperation(value = "删除Server") @DeleteMapping(value = "/{id:.+}") @PreAuthorize("@el.check('serverDeploy:del')") - public ResponseEntity delete(@PathVariable String id){ + public ResponseEntity delete(@PathVariable Long id){ serverDeployService.delete(id); return new ResponseEntity(HttpStatus.OK); } diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/ServerAccountService.java b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/ServerAccountService.java deleted file mode 100644 index c1b3cb96..00000000 --- a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/ServerAccountService.java +++ /dev/null @@ -1,54 +0,0 @@ -package me.zhengjie.modules.mnt.service; - -import me.zhengjie.modules.mnt.domain.ServerAccount; -import me.zhengjie.modules.mnt.service.dto.ServerAccountDTO; -import me.zhengjie.modules.mnt.service.dto.ServerAccountQueryCriteria; -import org.springframework.data.domain.Pageable; - -/** -* @author zhanghouying -* @date 2019-08-24 -*/ -public interface ServerAccountService { - - /** - * queryAll 分页 - * @param criteria - * @param pageable - * @return - */ - Object queryAll(ServerAccountQueryCriteria criteria, Pageable pageable); - - /** - * queryAll 不分页 - * @param criteria - * @return - */ - public Object queryAll(ServerAccountQueryCriteria criteria); - - /** - * findById - * @param id - * @return - */ - ServerAccountDTO findById(String id); - - /** - * create - * @param resources - * @return - */ - ServerAccountDTO create(ServerAccount resources); - - /** - * update - * @param resources - */ - void update(ServerAccount resources); - - /** - * delete - * @param id - */ - void delete(String id); -} diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/ServerDeployService.java b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/ServerDeployService.java index 68f155e2..043d6160 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/ServerDeployService.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/ServerDeployService.java @@ -31,7 +31,7 @@ public interface ServerDeployService { * @param id * @return */ - ServerDeployDTO findById(String id); + ServerDeployDTO findById(Long id); /** * create @@ -50,5 +50,7 @@ public interface ServerDeployService { * delete * @param id */ - void delete(String id); + void delete(Long id); + + ServerDeployDTO findByIp(String ip); } diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/dto/ServerAccountDTO.java b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/dto/ServerAccountDTO.java deleted file mode 100644 index 59887cf1..00000000 --- a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/dto/ServerAccountDTO.java +++ /dev/null @@ -1,33 +0,0 @@ -package me.zhengjie.modules.mnt.service.dto; - -import lombok.Data; -import java.io.Serializable; - - -/** -* @author zhanghouying -* @date 2019-08-24 -*/ -@Data -public class ServerAccountDTO implements Serializable { - - /** - * 编号 - */ - private String id; - - /** - * 名称 - */ - private String name; - - /** - * 账号 - */ - private String account; - - /** - * 密码 - */ - private String password; -} diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/dto/ServerAccountQueryCriteria.java b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/dto/ServerAccountQueryCriteria.java deleted file mode 100644 index 348f4833..00000000 --- a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/dto/ServerAccountQueryCriteria.java +++ /dev/null @@ -1,25 +0,0 @@ -package me.zhengjie.modules.mnt.service.dto; - -import lombok.Data; -import me.zhengjie.annotation.Query; - -/** -* @author zhanghouying -* @date 2019-08-24 -*/ -@Data -public class ServerAccountQueryCriteria{ - - /** - * 模糊 - */ - @Query(type = Query.Type.INNER_LIKE) - private String name; - - /** - * 模糊 - */ - @Query(type = Query.Type.INNER_LIKE) - private String account; - -} diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/dto/ServerDeployDTO.java b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/dto/ServerDeployDTO.java index a6752996..981bec76 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/dto/ServerDeployDTO.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/dto/ServerDeployDTO.java @@ -1,11 +1,8 @@ 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; +import java.sql.Timestamp; /** @@ -15,26 +12,17 @@ import java.io.Serializable; @Data public class ServerDeployDTO implements Serializable { - /** - * 服务器IP - */ - private String id; + private Long id; - /** - * 服务器账号 - */ - private String accountId; + private String name; - /** - * 账号名称 - */ - private String accountName; + private String ip; - public String getAccountName() { - if(accountId != null){ - ServerAccountService serverAccountService = SpringContextHolder.getBean(ServerAccountService.class); - return serverAccountService.findById(accountId).getName(); - } - return accountName; - } + private Integer port; + + private String account; + + private String password; + + private Timestamp createTime; } diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/dto/ServerDeployQueryCriteria.java b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/dto/ServerDeployQueryCriteria.java index c37aae2a..9c26efc7 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/dto/ServerDeployQueryCriteria.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/dto/ServerDeployQueryCriteria.java @@ -3,6 +3,9 @@ package me.zhengjie.modules.mnt.service.dto; import lombok.Data; import me.zhengjie.annotation.Query; +import java.sql.Timestamp; +import java.util.List; + /** * @author zhanghouying * @date 2019-08-24 @@ -13,7 +16,9 @@ public class ServerDeployQueryCriteria{ /** * 模糊 */ - @Query(type = Query.Type.INNER_LIKE) - private String id; + @Query(blurry = "name,ip,account") + private String blurry; + @Query(type = Query.Type.BETWEEN) + private List createTime; } diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/impl/DeployServiceImpl.java b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/impl/DeployServiceImpl.java index 1744812f..e74ce771 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/impl/DeployServiceImpl.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/impl/DeployServiceImpl.java @@ -59,13 +59,9 @@ public class DeployServiceImpl implements DeployService { @Autowired private DeployHistoryService deployHistoryService; - @Autowired - private ServerAccountService serverAccountService; - @Autowired private DatabaseService databaseService; - @Override public Object queryAll(DeployQueryCriteria criteria, Pageable pageable) { Page page = deployRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageable); @@ -243,7 +239,6 @@ public class DeployServiceImpl implements DeployService { } } - @Override public String serverStatus(Deploy resources) { String ip = resources.getIp(); @@ -264,7 +259,6 @@ public class DeployServiceImpl implements DeployService { return "执行完毕"; } - private boolean checkFile(ExecuteShellUtil executeShellUtil, AppDTO appDTO) { StringBuffer sb = new StringBuffer(); sb.append("find "); @@ -301,11 +295,8 @@ public class DeployServiceImpl implements DeployService { return "执行完毕"; } - ; - /** * 停止服务 - * * @param resources * @return */ @@ -333,8 +324,6 @@ public class DeployServiceImpl implements DeployService { return "执行完毕"; } - ; - @Override public String serverReduction(DeployHistory resources) { String deployId = resources.getDeployId(); @@ -385,34 +374,21 @@ public class DeployServiceImpl implements DeployService { } private ExecuteShellUtil getExecuteShellUtil(String ip) { - ServerDeployDTO serverDeployDTO = serverDeployService.findById(ip); + ServerDeployDTO serverDeployDTO = serverDeployService.findByIp(ip); if (serverDeployDTO == null) { sendMsg("IP对应服务器信息不存在:" + ip, MsgType.ERROR); throw new BadRequestException("IP对应服务器信息不存在:" + ip); } - String accountId = serverDeployDTO.getAccountId(); - ServerAccountDTO serverAccountDTO = serverAccountService.findById(accountId); - if (serverAccountDTO == null) { - sendMsg("IP对账号信息不存在:" + ip, MsgType.ERROR); - throw new BadRequestException("IP对账号信息不存在:" + ip); - } - return new ExecuteShellUtil(ip, serverAccountDTO.getAccount(), serverAccountDTO.getPassword()); + return new ExecuteShellUtil(ip, serverDeployDTO.getAccount(), serverDeployDTO.getPassword()); } - private ScpClientUtil getScpClientUtil(String ip) { - ServerDeployDTO serverDeployDTO = serverDeployService.findById(ip); + ServerDeployDTO serverDeployDTO = serverDeployService.findByIp(ip); if (serverDeployDTO == null) { sendMsg("IP对应服务器信息不存在:" + ip, MsgType.ERROR); throw new BadRequestException("IP对应服务器信息不存在:" + ip); } - String accountId = serverDeployDTO.getAccountId(); - ServerAccountDTO serverAccountDTO = serverAccountService.findById(accountId); - if (serverAccountDTO == null) { - sendMsg("IP对账号信息不存在:" + ip, MsgType.ERROR); - throw new BadRequestException("IP对账号信息不存在:" + ip); - } - return ScpClientUtil.getInstance(ip, 22, serverAccountDTO.getAccount(), serverAccountDTO.getPassword()); + return ScpClientUtil.getInstance(ip, serverDeployDTO.getPort(), serverDeployDTO.getAccount(), serverDeployDTO.getPassword()); } public void sendResultMsg(boolean result, StringBuilder sb) { diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/impl/ServerAccountServiceImpl.java b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/impl/ServerAccountServiceImpl.java deleted file mode 100644 index 4c549a89..00000000 --- a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/impl/ServerAccountServiceImpl.java +++ /dev/null @@ -1,82 +0,0 @@ -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; -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; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Propagation; -import org.springframework.transaction.annotation.Transactional; - -import java.util.Optional; - -/** -* @author zhanghouying -* @date 2019-08-24 -*/ -@Service -@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) -public class ServerAccountServiceImpl implements ServerAccountService { - - @Autowired - private ServerAccountRepository serverAccountRepository; - - @Autowired - private ServerDeployRepository serverDeployRepository; - - @Autowired - private ServerAccountMapper serverAccountMapper; - - @Override - public Object queryAll(ServerAccountQueryCriteria criteria, Pageable pageable){ - Page page = serverAccountRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); - return PageUtil.toPage(page.map(serverAccountMapper::toDto)); - } - - @Override - public Object queryAll(ServerAccountQueryCriteria criteria){ - return serverAccountMapper.toDto(serverAccountRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); - } - - @Override - public ServerAccountDTO findById(String id) { - Optional ServerAccount = serverAccountRepository.findById(id); - ValidationUtil.isNull(ServerAccount,"ServerAccount","id",id); - return serverAccountMapper.toDto(ServerAccount.get()); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public ServerAccountDTO create(ServerAccount resources) { - resources.setId(IdUtil.getSnowflake(0, 0).toString()); - return serverAccountMapper.toDto(serverAccountRepository.save(resources)); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void update(ServerAccount resources) { - Optional optionalServerAccount = serverAccountRepository.findById(resources.getId()); - ValidationUtil.isNull( optionalServerAccount,"ServerAccount","id",resources.getId()); - ServerAccount ServerAccount = optionalServerAccount.get(); - ServerAccount.copy(resources); - serverAccountRepository.save(ServerAccount); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void delete(String id) { - serverAccountRepository.deleteById(id); - serverDeployRepository.changeByAccount(id); - } -} diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/impl/ServerDeployServiceImpl.java b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/impl/ServerDeployServiceImpl.java index 3446fe33..b2eab771 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/impl/ServerDeployServiceImpl.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/impl/ServerDeployServiceImpl.java @@ -46,12 +46,18 @@ public class ServerDeployServiceImpl implements ServerDeployService { } @Override - public ServerDeployDTO findById(String id) { + public ServerDeployDTO findById(Long id) { Optional server = serverDeployRepository.findById(id); ValidationUtil.isNull(server,"ServerDeploy","id",id); return serverDeployMapper.toDto(server.get()); } + @Override + public ServerDeployDTO findByIp(String ip) { + ServerDeploy deploy = serverDeployRepository.findByIp(ip); + return serverDeployMapper.toDto(deploy); + } + @Override @Transactional(rollbackFor = Exception.class) public ServerDeployDTO create(ServerDeploy resources) { @@ -70,7 +76,7 @@ public class ServerDeployServiceImpl implements ServerDeployService { @Override @Transactional(rollbackFor = Exception.class) - public void delete(String id) { + public void delete(Long id) { serverDeployRepository.deleteById(id); } } diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/mapper/ServerAccountMapper.java b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/mapper/ServerAccountMapper.java deleted file mode 100644 index ece03299..00000000 --- a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/mapper/ServerAccountMapper.java +++ /dev/null @@ -1,16 +0,0 @@ -package me.zhengjie.modules.mnt.service.mapper; - -import me.zhengjie.base.BaseMapper; -import me.zhengjie.modules.mnt.domain.ServerAccount; -import me.zhengjie.modules.mnt.service.dto.ServerAccountDTO; -import org.mapstruct.Mapper; -import org.mapstruct.ReportingPolicy; - -/** -* @author zhanghouying -* @date 2019-08-24 -*/ -@Mapper(componentModel = "spring",uses = {},unmappedTargetPolicy = ReportingPolicy.IGNORE) -public interface ServerAccountMapper extends BaseMapper { - -}