Commit e4ca7afc authored by dqjdda's avatar dqjdda
Browse files

阿里巴巴代码规范

parent 6d941c09
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.ServerDeployDTO; import me.zhengjie.modules.mnt.service.dto.ServerDeployDto;
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);
} }
...@@ -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 AppDTO implements Serializable { public class AppDto implements Serializable {
/** /**
* 应用编号 * 应用编号
...@@ -26,7 +26,7 @@ public class AppDTO implements Serializable { ...@@ -26,7 +26,7 @@ public class AppDTO implements Serializable {
/** /**
* 端口 * 端口
*/ */
private int port; private Integer port;
/** /**
* 上传目录 * 上传目录
......
...@@ -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 DatabaseDTO implements Serializable { public class DatabaseDto implements Serializable {
/** /**
* id * id
......
...@@ -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 DeployDTO implements Serializable { public class DeployDto implements Serializable {
/** /**
* 部署编号 * 部署编号
*/ */
private String id; private String id;
private AppDTO app; private AppDto app;
/** /**
* 服务器 * 服务器
*/ */
private Set<ServerDeployDTO> deploys; private Set<ServerDeployDto> 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(ServerDeployDTO::getName).collect(Collectors.joining(",")); return deploys.stream().map(ServerDeployDto::getName).collect(Collectors.joining(","));
} }
return servers; return servers;
} }
......
...@@ -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 DeployHistoryDTO implements Serializable { public class DeployHistoryDto implements Serializable {
/** /**
* 编号 * 编号
......
...@@ -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 ServerDeployDTO implements Serializable { public class ServerDeployDto implements Serializable {
private Long id; private Long id;
......
...@@ -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.AppDTO; import me.zhengjie.modules.mnt.service.dto.AppDto;
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 AppDTO findById(Long id) { public AppDto 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 AppDTO create(App resources) { public AppDto create(App resources) {
return appMapper.toDto(appRepository.save(resources)); return appMapper.toDto(appRepository.save(resources));
} }
......
...@@ -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.DatabaseDTO; import me.zhengjie.modules.mnt.service.dto.DatabaseDto;
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 DatabaseDTO findById(String id) { public DatabaseDto 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 DatabaseDTO create(Database resources) { public DatabaseDto create(Database resources) {
resources.setId(IdUtil.simpleUUID()); resources.setId(IdUtil.simpleUUID());
return databaseMapper.toDto(databaseRepository.save(resources)); return databaseMapper.toDto(databaseRepository.save(resources));
} }
......
...@@ -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.DeployHistoryDTO; 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 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 DeployHistoryDTO findById(String id) { public DeployHistoryDto 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 DeployHistoryDTO create(DeployHistory resources) { public DeployHistoryDto create(DeployHistory resources) {
resources.setId(IdUtil.simpleUUID()); resources.setId(IdUtil.simpleUUID());
return deployhistoryMapper.toDto(deployhistoryRepository.save(resources)); return deployhistoryMapper.toDto(deployhistoryRepository.save(resources));
} }
......
...@@ -67,30 +67,30 @@ public class DeployServiceImpl implements DeployService { ...@@ -67,30 +67,30 @@ public class DeployServiceImpl implements DeployService {
} }
@Override @Override
public List<DeployDTO> queryAll(DeployQueryCriteria criteria) { public List<DeployDto> 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 DeployDTO findById(Long id) { public DeployDto findById(Long id) {
Deploy Deploy = deployRepository.findById(id).orElseGet(Deploy::new); Deploy deploy = deployRepository.findById(id).orElseGet(Deploy::new);
ValidationUtil.isNull(Deploy.getId(), "Deploy", "id", id); ValidationUtil.isNull(deploy.getId(), "Deploy", "id", id);
return deployMapper.toDto(Deploy); return deployMapper.toDto(deploy);
} }
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public DeployDTO create(Deploy resources) { public DeployDto 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 Deploy = deployRepository.findById(resources.getId()).orElseGet(Deploy::new); Deploy deploy = deployRepository.findById(resources.getId()).orElseGet(Deploy::new);
ValidationUtil.isNull(Deploy.getId(), "Deploy", "id", resources.getId()); ValidationUtil.isNull(deploy.getId(), "Deploy", "id", resources.getId());
Deploy.copy(resources); deploy.copy(resources);
deployRepository.save(Deploy); deployRepository.save(deploy);
} }
@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) {
DeployDTO deploy = findById(id); DeployDto deploy = findById(id);
if (deploy == null) { if (deploy == null) {
sendMsg("部署信息不存在", MsgType.ERROR); sendMsg("部署信息不存在", MsgType.ERROR);
throw new BadRequestException("部署信息不存在"); throw new BadRequestException("部署信息不存在");
} }
AppDTO app = deploy.getApp(); AppDto 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<ServerDeployDTO> deploys = deploy.getDeploys(); Set<ServerDeployDto> deploys = deploy.getDeploys();
for (ServerDeployDTO deployDTO : deploys) { for (ServerDeployDto 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, AppDTO appDTO) { private boolean checkFile(ExecuteShellUtil executeShellUtil, AppDto 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) {
ServerDeployDTO serverDeployDTO = serverDeployService.findByIp(ip); ServerDeployDto 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) {
ServerDeployDTO serverDeployDTO = serverDeployService.findByIp(ip); ServerDeployDto 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);
......
...@@ -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.ServerDeployDTO; import me.zhengjie.modules.mnt.service.dto.ServerDeployDto;
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 ServerDeployDTO findById(Long id) { public ServerDeployDto 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 ServerDeployDTO findByIp(String ip) { public ServerDeployDto 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 ServerDeployDTO create(ServerDeploy resources) { public ServerDeployDto create(ServerDeploy resources) {
return serverDeployMapper.toDto(serverDeployRepository.save(resources)); return serverDeployMapper.toDto(serverDeployRepository.save(resources));
} }
......
...@@ -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.AppDTO; import me.zhengjie.modules.mnt.service.dto.AppDto;
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<AppDTO, App> { public interface AppMapper extends BaseMapper<AppDto, App> {
} }
...@@ -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.DatabaseDTO; import me.zhengjie.modules.mnt.service.dto.DatabaseDto;
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<DatabaseDTO, Database> { public interface DatabaseMapper extends BaseMapper<DatabaseDto, Database> {
} }
...@@ -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.DeployHistoryDTO; import me.zhengjie.modules.mnt.service.dto.DeployHistoryDto;
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<DeployHistoryDTO, DeployHistory> { public interface DeployHistoryMapper extends BaseMapper<DeployHistoryDto, DeployHistory> {
} }
...@@ -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.DeployDTO; import me.zhengjie.modules.mnt.service.dto.DeployDto;
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<DeployDTO, Deploy> { public interface DeployMapper extends BaseMapper<DeployDto, Deploy> {
} }
...@@ -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.ServerDeployDTO; import me.zhengjie.modules.mnt.service.dto.ServerDeployDto;
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<ServerDeployDTO, ServerDeploy> { public interface ServerDeployMapper extends BaseMapper<ServerDeployDto, ServerDeploy> {
} }
...@@ -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;
......
...@@ -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
} }
...@@ -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 {
/** /**
* 实现服务器主动推送 * 实现服务器主动推送
*/ */
public void sendMessage(String message) throws IOException { private 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);
} }
} }
...@@ -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
......
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