机器管理bug修复,代码格式化
This commit is contained in:
parent
da63f37625
commit
8189a825d3
@ -1,4 +1,5 @@
|
|||||||
package cd.casic.module.machine.controller;
|
package cd.casic.module.machine.controller;
|
||||||
|
|
||||||
import cd.casic.framework.commons.pojo.CommonResult;
|
import cd.casic.framework.commons.pojo.CommonResult;
|
||||||
import cd.casic.framework.commons.pojo.PageResult;
|
import cd.casic.framework.commons.pojo.PageResult;
|
||||||
import cd.casic.framework.commons.util.object.BeanUtils;
|
import cd.casic.framework.commons.util.object.BeanUtils;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
package cd.casic.module.machine.controller;
|
package cd.casic.module.machine.controller;
|
||||||
|
|
||||||
import cd.casic.framework.commons.pojo.CommonResult;
|
import cd.casic.framework.commons.pojo.CommonResult;
|
||||||
import cd.casic.framework.commons.pojo.PageResult;
|
import cd.casic.framework.commons.pojo.PageResult;
|
||||||
import cd.casic.framework.commons.util.object.BeanUtils;
|
import cd.casic.framework.commons.util.object.BeanUtils;
|
||||||
@ -13,8 +14,9 @@ import jakarta.annotation.Resource;
|
|||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
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 java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static cd.casic.framework.commons.pojo.CommonResult.success;
|
import static cd.casic.framework.commons.pojo.CommonResult.success;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@ -45,8 +47,8 @@ public class MachineInfoController {
|
|||||||
@PutMapping("/updateStatus")
|
@PutMapping("/updateStatus")
|
||||||
@Operation(summary = "机器启用/停用")
|
@Operation(summary = "机器启用/停用")
|
||||||
// @PreAuthorize("@ss.hasPermission('ci:machineInfo:status')")
|
// @PreAuthorize("@ss.hasPermission('ci:machineInfo:status')")
|
||||||
public CommonResult<Integer> updateStatus(@RequestParam("id") Long id, @RequestParam("status") Integer status) {
|
public CommonResult<Integer> updateStatus(@Valid @RequestBody MachineInfoVO machineInfoVO) {
|
||||||
Integer newStatus = machineInfoService.updateStatus(id, status);
|
Integer newStatus = machineInfoService.updateStatus(machineInfoVO);
|
||||||
return success(newStatus);
|
return success(newStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,14 +62,6 @@ public class MachineInfoController {
|
|||||||
return success(BeanUtils.toBean(pageResult, MachineInfoVO.class));
|
return success(BeanUtils.toBean(pageResult, MachineInfoVO.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/bindingSecretKey")
|
|
||||||
@Operation(summary = "绑定密钥")
|
|
||||||
// @PreAuthorize("@ss.hasPermission('ci:machineInfo:binding')")
|
|
||||||
public CommonResult<Boolean> bindingSecretKey(@RequestParam("ids") List<Long> ids, @RequestParam("secretKeyId") Long secretKeyId) {
|
|
||||||
machineInfoService.bindingSecretKey(ids,secretKeyId);
|
|
||||||
return success(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@DeleteMapping("/delete")
|
@DeleteMapping("/delete")
|
||||||
@Operation(summary = "机器信息删除")
|
@Operation(summary = "机器信息删除")
|
||||||
// @PreAuthorize("@ss.hasPermission('ci:machineInfo:delete')")
|
// @PreAuthorize("@ss.hasPermission('ci:machineInfo:delete')")
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
package cd.casic.module.machine.controller;
|
package cd.casic.module.machine.controller;
|
||||||
|
|
||||||
import cd.casic.framework.commons.pojo.CommonResult;
|
import cd.casic.framework.commons.pojo.CommonResult;
|
||||||
import cd.casic.framework.commons.pojo.PageResult;
|
import cd.casic.framework.commons.pojo.PageResult;
|
||||||
import cd.casic.framework.commons.util.object.BeanUtils;
|
import cd.casic.framework.commons.util.object.BeanUtils;
|
||||||
@ -13,7 +14,9 @@ import jakarta.validation.Valid;
|
|||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
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 java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static cd.casic.framework.commons.pojo.CommonResult.success;
|
import static cd.casic.framework.commons.pojo.CommonResult.success;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -30,7 +33,7 @@ public class MachineProxyController {
|
|||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@Operation(summary = "注册新的机器代理")
|
@Operation(summary = "注册新的机器代理")
|
||||||
@PreAuthorize("@ss.hasPermission('ci:machineProxy:create')")
|
// @PreAuthorize("@ss.hasPermission('ci:machineProxy:create')")
|
||||||
public CommonResult<Long> createProxy(@Valid @RequestBody MachineProxyVO machineProxyVO) {
|
public CommonResult<Long> createProxy(@Valid @RequestBody MachineProxyVO machineProxyVO) {
|
||||||
Long id = machineProxyService.createProxy(machineProxyVO);
|
Long id = machineProxyService.createProxy(machineProxyVO);
|
||||||
return success(id);
|
return success(id);
|
||||||
@ -38,7 +41,7 @@ public class MachineProxyController {
|
|||||||
|
|
||||||
@PutMapping("/update")
|
@PutMapping("/update")
|
||||||
@Operation(summary = "修改代理")
|
@Operation(summary = "修改代理")
|
||||||
@PreAuthorize("@ss.hasPermission('ci:machineProxy:update')")
|
// @PreAuthorize("@ss.hasPermission('ci:machineProxy:update')")
|
||||||
public CommonResult<Boolean> updateProxy(@Valid @RequestBody MachineProxyVO machineProxyVO) {
|
public CommonResult<Boolean> updateProxy(@Valid @RequestBody MachineProxyVO machineProxyVO) {
|
||||||
machineProxyService.updateProxy(machineProxyVO);
|
machineProxyService.updateProxy(machineProxyVO);
|
||||||
return success(true);
|
return success(true);
|
||||||
@ -60,10 +63,16 @@ public class MachineProxyController {
|
|||||||
return success(machineProxyService.getAllProxyStatus());
|
return success(machineProxyService.getAllProxyStatus());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("delete")
|
||||||
|
@Operation(summary = "删除代理")
|
||||||
|
public CommonResult<Boolean> delete(@RequestParam("id") Long id) {
|
||||||
|
machineProxyService.delete(id);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
@DeleteMapping("/deleteList")
|
@DeleteMapping("/deleteList")
|
||||||
@Operation(summary = "批量删除代理")
|
@Operation(summary = "批量删除代理")
|
||||||
@PreAuthorize("@ss.hasPermission('ci:machineProxy:delete')")
|
// @PreAuthorize("@ss.hasPermission('ci:machineProxy:delete')")
|
||||||
public CommonResult<Boolean> deleteProxyList(@RequestParam String ids) {
|
public CommonResult<Boolean> deleteProxyList(@RequestParam String ids) {
|
||||||
machineProxyService.deleteProxyList(ids);
|
machineProxyService.deleteProxyList(ids);
|
||||||
return success(true);
|
return success(true);
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
package cd.casic.module.machine.controller;
|
package cd.casic.module.machine.controller;
|
||||||
|
|
||||||
import cd.casic.framework.commons.pojo.CommonResult;
|
import cd.casic.framework.commons.pojo.CommonResult;
|
||||||
import cd.casic.framework.commons.pojo.PageResult;
|
import cd.casic.framework.commons.pojo.PageResult;
|
||||||
import cd.casic.framework.commons.util.object.BeanUtils;
|
import cd.casic.framework.commons.util.object.BeanUtils;
|
||||||
@ -13,7 +14,9 @@ import jakarta.validation.Valid;
|
|||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
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 java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static cd.casic.framework.commons.pojo.CommonResult.success;
|
import static cd.casic.framework.commons.pojo.CommonResult.success;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@ -43,8 +46,8 @@ public class SecretKeyController {
|
|||||||
@PutMapping("/bindingMachine")
|
@PutMapping("/bindingMachine")
|
||||||
@Operation(summary = "绑定机器") //todo解绑机器
|
@Operation(summary = "绑定机器") //todo解绑机器
|
||||||
// @PreAuthorize("@ss.hasPermission('ci:secretKey:binding')")
|
// @PreAuthorize("@ss.hasPermission('ci:secretKey:binding')")
|
||||||
public CommonResult<Boolean> bindingMachine(@RequestParam("id") Long id, @RequestParam("machineInfoIds") List<Long> machineInfoId) {
|
public CommonResult<Boolean> bindingMachine(@Valid @RequestBody SecretKeyVO secretKeyVO) {
|
||||||
secretKeyService.bindingMachine(id, machineInfoId);
|
secretKeyService.bindingMachine(secretKeyVO);
|
||||||
return success(true);
|
return success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
package cd.casic.module.machine.controller.vo;
|
package cd.casic.module.machine.controller.vo;
|
||||||
|
|
||||||
import cd.casic.framework.commons.pojo.PageParam;
|
import cd.casic.framework.commons.pojo.PageParam;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ -40,7 +40,7 @@ public class MachineInfoVO extends PageParam {
|
|||||||
private String username;
|
private String username;
|
||||||
|
|
||||||
@Schema(description = "机器状态", example = "online,offline,maintenance")
|
@Schema(description = "机器状态", example = "online,offline,maintenance")
|
||||||
private Integer status;
|
private Integer status = -1;
|
||||||
|
|
||||||
@Schema(description = "SSH端口", example = "22")
|
@Schema(description = "SSH端口", example = "22")
|
||||||
private Integer sshPort;
|
private Integer sshPort;
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
package cd.casic.module.machine.controller.vo;
|
package cd.casic.module.machine.controller.vo;
|
||||||
|
|
||||||
import cd.casic.framework.commons.pojo.PageParam;
|
import cd.casic.framework.commons.pojo.PageParam;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
@Schema(description = "管理后台 - 机器代理信息 Response VO")
|
@Schema(description = "管理后台 - 机器代理信息 Response VO")
|
||||||
@ -21,13 +23,13 @@ public class MachineProxyVO extends PageParam {
|
|||||||
private String username;
|
private String username;
|
||||||
|
|
||||||
@Schema(description = "代理类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "HTTP")
|
@Schema(description = "代理类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "HTTP")
|
||||||
private Integer proxyType;
|
private Integer proxyType = -1;
|
||||||
|
|
||||||
@Schema(description = "版本号", example = "1.0.0")
|
@Schema(description = "版本号", example = "1.0.0")
|
||||||
private String version;
|
private String version;
|
||||||
|
|
||||||
@Schema(description = "状态(ONLINE:在线,OFFLINE:离线)", requiredMode = Schema.RequiredMode.REQUIRED, example = "ONLINE")
|
@Schema(description = "状态(ONLINE:在线,OFFLINE:离线)", requiredMode = Schema.RequiredMode.REQUIRED, example = "ONLINE")
|
||||||
private String status;
|
private int status = -1;
|
||||||
|
|
||||||
@Schema(description = "描述信息", example = "用于生产环境的代理服务器")
|
@Schema(description = "描述信息", example = "用于生产环境的代理服务器")
|
||||||
private String description;
|
private String description;
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
package cd.casic.module.machine.controller.vo;
|
package cd.casic.module.machine.controller.vo;
|
||||||
|
|
||||||
import cd.casic.framework.commons.pojo.PageParam;
|
import cd.casic.framework.commons.pojo.PageParam;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import cd.casic.module.machine.controller.vo.MachineEnvVO;
|
|||||||
import cd.casic.module.machine.dal.dataobject.MachineEnvDO;
|
import cd.casic.module.machine.dal.dataobject.MachineEnvDO;
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.factory.Mappers;
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface MachineEnvConvert {
|
public interface MachineEnvConvert {
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
package cd.casic.module.machine.dal.mysql;
|
package cd.casic.module.machine.dal.mysql;
|
||||||
|
|
||||||
import cd.casic.framework.mybatis.core.mapper.BaseMapperX;
|
import cd.casic.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
import cd.casic.module.machine.controller.vo.MachineEnvVO;
|
import cd.casic.module.machine.controller.vo.MachineEnvVO;
|
||||||
import cd.casic.module.machine.dal.dataobject.MachineEnvDO;
|
import cd.casic.module.machine.dal.dataobject.MachineEnvDO;
|
||||||
@ -14,9 +15,13 @@ import java.time.LocalDateTime;
|
|||||||
@Mapper
|
@Mapper
|
||||||
public interface MachineEnvMapper extends BaseMapperX<MachineEnvDO> {
|
public interface MachineEnvMapper extends BaseMapperX<MachineEnvDO> {
|
||||||
default PageResult<MachineEnvDO> selectPage(MachineEnvVO machineEnvVO) {
|
default PageResult<MachineEnvDO> selectPage(MachineEnvVO machineEnvVO) {
|
||||||
return selectPage(machineEnvVO,new LambdaQueryWrapperX<MachineEnvDO>()
|
LambdaQueryWrapperX<MachineEnvDO> machineEnvDOLambdaQueryWrapperX = new LambdaQueryWrapperX<MachineEnvDO>()
|
||||||
.likeIfPresent(MachineEnvDO::getEnvKey, machineEnvVO.getEnvKey())
|
.likeIfPresent(MachineEnvDO::getEnvKey, machineEnvVO.getEnvKey())
|
||||||
.likeIfPresent(MachineEnvDO::getDescription, machineEnvVO.getDescription()));
|
.likeIfPresent(MachineEnvDO::getDescription, machineEnvVO.getDescription());
|
||||||
|
if (machineEnvVO.getMachineId() != null && machineEnvVO.getMachineId() > 0) {
|
||||||
|
machineEnvDOLambdaQueryWrapperX.eqIfPresent(MachineEnvDO::getMachineId, machineEnvVO.getMachineId());
|
||||||
|
}
|
||||||
|
return selectPage(machineEnvVO, machineEnvDOLambdaQueryWrapperX);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -11,6 +11,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -20,30 +21,38 @@ public interface MachineInfoMapper extends BaseMapperX<MachineInfoDO> {
|
|||||||
default Boolean existsByTag(String tag) {
|
default Boolean existsByTag(String tag) {
|
||||||
return selectOne(new QueryWrapper<MachineInfoDO>().eq("tag", tag)) != null;
|
return selectOne(new QueryWrapper<MachineInfoDO>().eq("tag", tag)) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
default void updateStatus(Long machineInfoId, Integer status) {
|
default void updateStatus(Long machineInfoId, Integer status) {
|
||||||
UpdateWrapper<MachineInfoDO> set = new UpdateWrapper<>();
|
UpdateWrapper<MachineInfoDO> set = new UpdateWrapper<>();
|
||||||
set.eq("id", machineInfoId).set("status", status);
|
set.eq("id", machineInfoId).set("status", status);
|
||||||
this.update(null, set);
|
this.update(null, set);
|
||||||
}
|
}
|
||||||
|
|
||||||
default void bindingSecretKey(List<Long> machineInfoIds, Long secretKeyId) {
|
default void bindingSecretKey(List<Long> machineInfoIds, Long secretKeyId) {
|
||||||
LambdaUpdateWrapper<MachineInfoDO> wrapper = new LambdaUpdateWrapper<MachineInfoDO>()
|
UpdateWrapper<MachineInfoDO> wrapper = new UpdateWrapper<>();
|
||||||
.set(MachineInfoDO::getSecretKeyId, secretKeyId)
|
wrapper.in("id", machineInfoIds) // 匹配 ID 集合
|
||||||
.in(MachineInfoDO::getId, machineInfoIds);
|
.set("secret_key_id", secretKeyId); // 设置新的 status 值
|
||||||
this.update(null, wrapper);
|
this.update(null, wrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
default void unBindingSecretKey(List<Long> secretKeyId) {
|
default void unBindingSecretKey(List<Long> secretKeyId) {
|
||||||
LambdaUpdateWrapper<MachineInfoDO> wrapper = new LambdaUpdateWrapper<MachineInfoDO>()
|
LambdaUpdateWrapper<MachineInfoDO> wrapper = new LambdaUpdateWrapper<MachineInfoDO>()
|
||||||
.set(MachineInfoDO::getSecretKeyId, null)
|
.set(MachineInfoDO::getSecretKeyId, null)
|
||||||
.in(MachineInfoDO::getSecretKeyId, secretKeyId);
|
.in(MachineInfoDO::getSecretKeyId, secretKeyId);
|
||||||
this.update(null, wrapper);
|
this.update(null, wrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
default PageResult<MachineInfoDO> selectPage(MachineInfoVO machineInfoVO) {
|
default PageResult<MachineInfoDO> selectPage(MachineInfoVO machineInfoVO) {
|
||||||
return selectPage(machineInfoVO,new LambdaQueryWrapperX<MachineInfoDO>()
|
LambdaQueryWrapperX<MachineInfoDO> machineInfoDOLambdaQueryWrapperX = new LambdaQueryWrapperX<MachineInfoDO>()
|
||||||
.likeIfPresent(MachineInfoDO::getName, machineInfoVO.getName())
|
.likeIfPresent(MachineInfoDO::getName, machineInfoVO.getName())
|
||||||
.likeIfPresent(MachineInfoDO::getTag, machineInfoVO.getTag())
|
.likeIfPresent(MachineInfoDO::getTag, machineInfoVO.getTag())
|
||||||
.likeIfPresent(MachineInfoDO::getDescription, machineInfoVO.getDescription())
|
.likeIfPresent(MachineInfoDO::getDescription, machineInfoVO.getDescription())
|
||||||
.likeIfPresent(MachineInfoDO::getUsername, machineInfoVO.getUsername())
|
.likeIfPresent(MachineInfoDO::getUsername, machineInfoVO.getUsername())
|
||||||
.eqIfPresent(MachineInfoDO::getHostIp, machineInfoVO.getHostIp()));
|
.likeIfPresent(MachineInfoDO::getHostIp, machineInfoVO.getHostIp());
|
||||||
|
if (machineInfoVO.getStatus() != -1) {
|
||||||
|
machineInfoDOLambdaQueryWrapperX.eqIfPresent(MachineInfoDO::getStatus, machineInfoVO.getStatus());
|
||||||
|
}
|
||||||
|
return selectPage(machineInfoVO, machineInfoDOLambdaQueryWrapperX);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
package cd.casic.module.machine.dal.mysql;
|
package cd.casic.module.machine.dal.mysql;
|
||||||
|
|
||||||
import cd.casic.framework.commons.pojo.PageResult;
|
import cd.casic.framework.commons.pojo.PageResult;
|
||||||
import cd.casic.framework.mybatis.core.mapper.BaseMapperX;
|
import cd.casic.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
import cd.casic.framework.mybatis.core.query.LambdaQueryWrapperX;
|
import cd.casic.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
@ -12,15 +13,17 @@ import org.apache.ibatis.annotations.Mapper;
|
|||||||
@Mapper
|
@Mapper
|
||||||
public interface MachineProxyMapper extends BaseMapperX<MachineProxyDO> {
|
public interface MachineProxyMapper extends BaseMapperX<MachineProxyDO> {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
default PageResult<MachineProxyDO> selectPage(MachineProxyVO machineProxyVO) {
|
default PageResult<MachineProxyDO> selectPage(MachineProxyVO machineProxyVO) {
|
||||||
return selectPage(machineProxyVO, new LambdaQueryWrapperX<MachineProxyDO>()
|
LambdaQueryWrapperX<MachineProxyDO> machineProxyDOLambdaQueryWrapperX = new LambdaQueryWrapperX<MachineProxyDO>()
|
||||||
.eqIfPresent(MachineProxyDO::getHostIp, machineProxyVO.getHostIp())
|
.eqIfPresent(MachineProxyDO::getHostIp, machineProxyVO.getHostIp())
|
||||||
.eqIfPresent(MachineProxyDO::getProxyType, machineProxyVO.getProxyType())
|
.likeIfPresent(MachineProxyDO::getDescription, machineProxyVO.getDescription());
|
||||||
.eqIfPresent(MachineProxyDO::getStatus, machineProxyVO.getStatus())
|
if (machineProxyVO.getStatus() != -1) {
|
||||||
.likeIfPresent(MachineProxyDO::getDescription, machineProxyVO.getDescription())
|
machineProxyDOLambdaQueryWrapperX.eqIfPresent(MachineProxyDO::getStatus, machineProxyVO.getStatus());
|
||||||
);
|
}
|
||||||
|
if (machineProxyVO.getProxyType() != -1) {
|
||||||
|
machineProxyDOLambdaQueryWrapperX.eqIfPresent(MachineProxyDO::getProxyType, machineProxyVO.getProxyType());
|
||||||
|
}
|
||||||
|
return selectPage(machineProxyVO, machineProxyDOLambdaQueryWrapperX);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -5,18 +5,20 @@ import cd.casic.framework.commons.core.IntArrayValuable;
|
|||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public enum MachineInfoStatus implements IntArrayValuable {
|
public enum MachineInfoStatus implements IntArrayValuable {
|
||||||
ENABLE(1, "启用"),
|
ENABLE(1, "启用"),
|
||||||
UN_ENABLE(0, "停用");
|
UN_ENABLE(0, "停用");
|
||||||
|
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(MachineInfoStatus::getCode).toArray();
|
||||||
private final int code;
|
private final int code;
|
||||||
|
|
||||||
private final String message;
|
private final String message;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int[] array() {
|
public int[] array() {
|
||||||
return new int[0];
|
return ARRAYS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
package cd.casic.module.machine.enums;
|
package cd.casic.module.machine.enums;
|
||||||
|
|
||||||
import cd.casic.framework.commons.core.IntArrayValuable;
|
import cd.casic.framework.commons.core.IntArrayValuable;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
package cd.casic.module.machine.service;
|
package cd.casic.module.machine.service;
|
||||||
|
|
||||||
import cd.casic.framework.commons.pojo.PageResult;
|
import cd.casic.framework.commons.pojo.PageResult;
|
||||||
import cd.casic.module.machine.controller.vo.MachineEnvVO;
|
import cd.casic.module.machine.controller.vo.MachineEnvVO;
|
||||||
import cd.casic.module.machine.dal.dataobject.MachineEnvDO;
|
import cd.casic.module.machine.dal.dataobject.MachineEnvDO;
|
||||||
|
@ -4,6 +4,8 @@ import cd.casic.framework.commons.pojo.PageResult;
|
|||||||
import cd.casic.module.machine.controller.vo.MachineInfoVO;
|
import cd.casic.module.machine.controller.vo.MachineInfoVO;
|
||||||
import cd.casic.module.machine.dal.dataobject.MachineInfoDO;
|
import cd.casic.module.machine.dal.dataobject.MachineInfoDO;
|
||||||
import cd.casic.module.machine.enums.ConnectionStatus;
|
import cd.casic.module.machine.enums.ConnectionStatus;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -12,11 +14,11 @@ import java.util.Map;
|
|||||||
public interface MachineInfoService {
|
public interface MachineInfoService {
|
||||||
Long createMachine(MachineInfoVO MachineInfoVO);
|
Long createMachine(MachineInfoVO MachineInfoVO);
|
||||||
|
|
||||||
PageResult<MachineInfoDO> listMachineInfo(MachineInfoVO MachineInfoVO);
|
PageResult<MachineInfoDO> listMachineInfo(@Valid MachineInfoVO MachineInfoVO);
|
||||||
|
|
||||||
void updateMachineInfo(MachineInfoVO machineInfoVO);
|
void updateMachineInfo(@Valid MachineInfoVO machineInfoVO);
|
||||||
|
|
||||||
Integer updateStatus(Long machineInfoId, Integer status);
|
Integer updateStatus(@Valid MachineInfoVO machineInfoVO);
|
||||||
|
|
||||||
void bindingSecretKey(List<Long> machineInfoIds, Long secretKeyId);
|
void bindingSecretKey(List<Long> machineInfoIds, Long secretKeyId);
|
||||||
|
|
||||||
|
@ -3,6 +3,9 @@ package cd.casic.module.machine.service;
|
|||||||
import cd.casic.framework.commons.pojo.PageResult;
|
import cd.casic.framework.commons.pojo.PageResult;
|
||||||
import cd.casic.module.machine.controller.vo.MachineProxyVO;
|
import cd.casic.module.machine.controller.vo.MachineProxyVO;
|
||||||
import cd.casic.module.machine.dal.dataobject.MachineProxyDO;
|
import cd.casic.module.machine.dal.dataobject.MachineProxyDO;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -13,13 +16,19 @@ public interface MachineProxyService {
|
|||||||
/**
|
/**
|
||||||
* 注册新的机器代理
|
* 注册新的机器代理
|
||||||
*/
|
*/
|
||||||
Long createProxy(MachineProxyVO machineProxyVO);
|
Long createProxy(@Valid MachineProxyVO machineProxyVO);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新代理状态
|
* 更新代理状态
|
||||||
*/
|
*/
|
||||||
void updateProxy(MachineProxyVO machineProxyVO);
|
void updateProxy(@Valid MachineProxyVO machineProxyVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除代理
|
||||||
|
*
|
||||||
|
* @param
|
||||||
|
*/
|
||||||
|
void delete(Long id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取所有代理的状态统计
|
* 获取所有代理的状态统计
|
||||||
@ -29,7 +38,6 @@ public interface MachineProxyService {
|
|||||||
Map<Integer, Long> getAllProxyStatus();
|
Map<Integer, Long> getAllProxyStatus();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量删除代理
|
* 批量删除代理
|
||||||
*
|
*
|
||||||
@ -37,5 +45,5 @@ public interface MachineProxyService {
|
|||||||
*/
|
*/
|
||||||
void deleteProxyList(String proxyIds);
|
void deleteProxyList(String proxyIds);
|
||||||
|
|
||||||
PageResult<MachineProxyDO> getProxyPage(MachineProxyVO machineProxyVO);
|
PageResult<MachineProxyDO> getProxyPage(@Valid MachineProxyVO machineProxyVO);
|
||||||
}
|
}
|
||||||
|
@ -4,20 +4,18 @@ import cd.casic.framework.commons.pojo.PageResult;
|
|||||||
import cd.casic.module.machine.dal.dataobject.SecretKeyDO;
|
import cd.casic.module.machine.dal.dataobject.SecretKeyDO;
|
||||||
import cd.casic.module.machine.controller.vo.SecretKeyVO;
|
import cd.casic.module.machine.controller.vo.SecretKeyVO;
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface SecretKeyService {
|
public interface SecretKeyService {
|
||||||
Long createSecretKey(@Valid SecretKeyVO secretKeyVO) throws Exception;
|
Long createSecretKey(@Valid SecretKeyVO secretKeyVO) throws Exception;
|
||||||
|
|
||||||
void bindingMachine(Long id, List<Long> machineInfoId);
|
void bindingMachine(@Valid SecretKeyVO secretKeyVO);
|
||||||
|
|
||||||
void updateSecretKey(@Valid SecretKeyVO secretKeyVO);
|
void updateSecretKey(@Valid SecretKeyVO secretKeyVO);
|
||||||
|
|
||||||
|
|
||||||
PageResult<SecretKeyDO> getSecretKeypage(@Valid SecretKeyVO secretKeyVO);
|
PageResult<SecretKeyDO> getSecretKeypage(@Valid SecretKeyVO secretKeyVO);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void deleteSecretKeyList(List<Long> ids);
|
void deleteSecretKeyList(List<Long> ids);
|
||||||
|
|
||||||
SecretKeyVO getSecretKey(Long id);
|
SecretKeyVO getSecretKey(Long id);
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
package cd.casic.module.machine.service.impl;
|
package cd.casic.module.machine.service.impl;
|
||||||
|
|
||||||
import cd.casic.module.machine.controller.vo.MachineEnvVO;
|
import cd.casic.module.machine.controller.vo.MachineEnvVO;
|
||||||
import cd.casic.module.machine.dal.dataobject.MachineEnvDO;
|
import cd.casic.module.machine.dal.dataobject.MachineEnvDO;
|
||||||
import cd.casic.module.machine.dal.mysql.MachineEnvMapper;
|
import cd.casic.module.machine.dal.mysql.MachineEnvMapper;
|
||||||
@ -84,6 +85,7 @@ public class MachineEnvServiceImpl implements MachineEnvService {
|
|||||||
}
|
}
|
||||||
return machineEnvDO;
|
return machineEnvDO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
void validateMachineEnvAdd(MachineEnvVO machineEnvVO) {
|
void validateMachineEnvAdd(MachineEnvVO machineEnvVO) {
|
||||||
if (machineEnvVO.getEnvKey() == null || machineEnvVO.getEnvValue() == null) {
|
if (machineEnvVO.getEnvKey() == null || machineEnvVO.getEnvValue() == null) {
|
||||||
@ -92,7 +94,6 @@ public class MachineEnvServiceImpl implements MachineEnvService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 检查环境变量键是否合法
|
// 检查环境变量键是否合法
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
private void validateKey(String key) {
|
private void validateKey(String key) {
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
package cd.casic.module.machine.service.impl;
|
package cd.casic.module.machine.service.impl;
|
||||||
|
|
||||||
import cd.casic.framework.commons.pojo.PageResult;
|
import cd.casic.framework.commons.pojo.PageResult;
|
||||||
import cd.casic.module.machine.controller.vo.MachineProxyVO;
|
import cd.casic.module.machine.controller.vo.MachineProxyVO;
|
||||||
import cd.casic.module.machine.dal.dataobject.MachineProxyDO;
|
import cd.casic.module.machine.dal.dataobject.MachineProxyDO;
|
||||||
@ -13,9 +14,12 @@ import cd.casic.framework.commons.util.object.BeanUtils;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static cd.casic.framework.commons.exception.util.ServiceExceptionUtil.exception;
|
import static cd.casic.framework.commons.exception.util.ServiceExceptionUtil.exception;
|
||||||
import static cd.casic.module.machine.contants.MachineErrorCodeConstants.*;
|
import static cd.casic.module.machine.contants.MachineErrorCodeConstants.*;
|
||||||
import static com.baomidou.mybatisplus.extension.toolkit.Db.save;
|
import static com.baomidou.mybatisplus.extension.toolkit.Db.save;
|
||||||
@ -33,7 +37,8 @@ public class MachineProxyServiceImpl implements MachineProxyService {
|
|||||||
public Long createProxy(MachineProxyVO machineProxyVO) {
|
public Long createProxy(MachineProxyVO machineProxyVO) {
|
||||||
validateMachineProxyAdd(machineProxyVO);
|
validateMachineProxyAdd(machineProxyVO);
|
||||||
// 创建代理记录
|
// 创建代理记录
|
||||||
MachineProxyDO machineProxyDO = BeanUtils.toBean(machineProxyVO, MachineProxyDO.class);;
|
MachineProxyDO machineProxyDO = BeanUtils.toBean(machineProxyVO, MachineProxyDO.class);
|
||||||
|
;
|
||||||
save(machineProxyDO);
|
save(machineProxyDO);
|
||||||
return machineProxyDO.getId();
|
return machineProxyDO.getId();
|
||||||
}
|
}
|
||||||
@ -47,6 +52,19 @@ public class MachineProxyServiceImpl implements MachineProxyService {
|
|||||||
machineProxyMapper.updateById(machineProxyDO);
|
machineProxyMapper.updateById(machineProxyDO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void delete(Long id) {
|
||||||
|
MachineProxyDO machineProxyDO = validateMachineProxyExists(id);
|
||||||
|
validateMachineProxyOnline(machineProxyDO);
|
||||||
|
machineProxyMapper.deleteById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
void validateMachineProxyOnline(MachineProxyDO machineProxyDO) {
|
||||||
|
if (machineProxyDO.getStatus() == MachineProxyStatus.ONLINE.getCode()) {
|
||||||
|
throw exception(MACHINE_PROXY_IS_ONLINE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<Integer, Long> getAllProxyStatus() {
|
public Map<Integer, Long> getAllProxyStatus() {
|
||||||
@ -75,10 +93,8 @@ public class MachineProxyServiceImpl implements MachineProxyService {
|
|||||||
.filter(s -> !s.isEmpty())
|
.filter(s -> !s.isEmpty())
|
||||||
.map(Long::parseLong)
|
.map(Long::parseLong)
|
||||||
.toList();
|
.toList();
|
||||||
//检查是否存在在线的代理
|
|
||||||
validateMachineProxyOnline(machineProxyIds);
|
|
||||||
// 批量逻辑删除
|
// 批量逻辑删除
|
||||||
machineProxyMapper.deleteBatchIds(machineProxyIds);
|
machineProxyIds.forEach(this::delete);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -86,12 +102,10 @@ public class MachineProxyServiceImpl implements MachineProxyService {
|
|||||||
return machineProxyMapper.selectPage(machineProxyVO);
|
return machineProxyMapper.selectPage(machineProxyVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
MachineProxyDO validateMachineProxyExists(Long id) {
|
MachineProxyDO validateMachineProxyExists(Long id) {
|
||||||
if (id == null) {
|
if (id == null) {
|
||||||
return null;
|
throw exception(MACHINE_PROXY_NOT_EXISTS);
|
||||||
}
|
}
|
||||||
MachineProxyDO machineProxyDO = machineProxyMapper.selectById(id);
|
MachineProxyDO machineProxyDO = machineProxyMapper.selectById(id);
|
||||||
if (machineProxyDO == null) {
|
if (machineProxyDO == null) {
|
||||||
@ -100,20 +114,6 @@ public class MachineProxyServiceImpl implements MachineProxyService {
|
|||||||
return machineProxyDO;
|
return machineProxyDO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
|
||||||
void validateMachineProxyOnline(List<Long> ids) {
|
|
||||||
List<MachineProxyDO> machineProxyDOS = machineProxyMapper.selectBatchIds(ids);
|
|
||||||
List<Long>onlineId=new ArrayList<>();
|
|
||||||
machineProxyDOS.forEach(machineProxyDO->{
|
|
||||||
if (machineProxyDO.getStatus() == MachineProxyStatus.ONLINE.getCode()) {
|
|
||||||
onlineId.add(machineProxyDO.getId());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if(!onlineId.isEmpty()){
|
|
||||||
throw exception(MACHINE_PROXY_IS_ONLINE,onlineId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
void validateMachineProxyAdd(MachineProxyVO machineProxyVO) {
|
void validateMachineProxyAdd(MachineProxyVO machineProxyVO) {
|
||||||
if (machineProxyVO.getHostIp() == null) {
|
if (machineProxyVO.getHostIp() == null) {
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
package cd.casic.module.machine.service.impl;
|
package cd.casic.module.machine.service.impl;
|
||||||
|
|
||||||
import cd.casic.framework.commons.pojo.PageResult;
|
import cd.casic.framework.commons.pojo.PageResult;
|
||||||
import cd.casic.module.machine.controller.vo.SecretKeyVO;
|
import cd.casic.module.machine.controller.vo.SecretKeyVO;
|
||||||
import cd.casic.module.machine.enums.AuthenticationType;
|
import cd.casic.module.machine.enums.AuthenticationType;
|
||||||
@ -58,14 +59,15 @@ public class MachineinfoServiceImpl implements MachineInfoService {
|
|||||||
validateMachineEnvAdd(machineInfoVO);
|
validateMachineEnvAdd(machineInfoVO);
|
||||||
validateMachineTagUnique(machineInfoVO.getTag());
|
validateMachineTagUnique(machineInfoVO.getTag());
|
||||||
MachineInfoDO machineInfoDO = BeanUtils.toBean(machineInfoVO, MachineInfoDO.class);
|
MachineInfoDO machineInfoDO = BeanUtils.toBean(machineInfoVO, MachineInfoDO.class);
|
||||||
|
if (machineInfoVO.getAuthenticationType() == 2) {
|
||||||
Long secretKeyId = machineInfoDO.getSecretKeyId();
|
Long secretKeyId = machineInfoDO.getSecretKeyId();
|
||||||
SecretKeyVO secretKey = secretKeyService.getSecretKey(secretKeyId);
|
SecretKeyVO secretKey = secretKeyService.getSecretKey(secretKeyId);
|
||||||
if (secretKey == null) {
|
if (secretKey == null) {
|
||||||
throw exception(SECRET_KEY_NOT_EXISTS);
|
throw exception(SECRET_KEY_NOT_EXISTS);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
machineInfoMapper.insert(machineInfoDO);
|
machineInfoMapper.insert(machineInfoDO);
|
||||||
Long id = machineInfoDO.getId();
|
return machineInfoDO.getId();
|
||||||
return id;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -82,9 +84,9 @@ public class MachineinfoServiceImpl implements MachineInfoService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer updateStatus(Long machineInfoId, Integer status) {
|
public Integer updateStatus(MachineInfoVO machineInfoVO) {
|
||||||
machineInfoMapper.updateStatus(machineInfoId, status);
|
machineInfoMapper.updateStatus(machineInfoVO.getId(), machineInfoVO.getStatus());
|
||||||
return machineInfoMapper.selectById(machineInfoId).getStatus();
|
return machineInfoVO.getStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -93,8 +95,8 @@ public class MachineinfoServiceImpl implements MachineInfoService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void bindingSecretKey(List<Long> machineInfoId,Long secretKeyId) {
|
public void bindingSecretKey(List<Long> machineInfoIds, Long secretKeyId) {
|
||||||
machineInfoMapper.bindingSecretKey(machineInfoId,secretKeyId);
|
machineInfoMapper.bindingSecretKey(machineInfoIds, secretKeyId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -303,10 +305,10 @@ public class MachineinfoServiceImpl implements MachineInfoService {
|
|||||||
flag = false;
|
flag = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (flag) {
|
if (flag) {
|
||||||
throw exception(MACHINE_INFO_AUTHENTICATION_TYPE_NOT_EXISTS);
|
throw exception(MACHINE_INFO_AUTHENTICATION_TYPE_NOT_EXISTS);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
throw exception(MACHINE_INFO_AUTHENTICATION_TYPE_NULL);
|
throw exception(MACHINE_INFO_AUTHENTICATION_TYPE_NULL);
|
||||||
}
|
}
|
||||||
@ -335,10 +337,11 @@ public class MachineinfoServiceImpl implements MachineInfoService {
|
|||||||
throw exception(MACHINE_INFO_TAG_EXISTS);
|
throw exception(MACHINE_INFO_TAG_EXISTS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
MachineInfoDO validateMachineInfoExists(Long id) {
|
MachineInfoDO validateMachineInfoExists(Long id) {
|
||||||
if (id == null) {
|
if (id == null) {
|
||||||
return null;
|
throw exception(MACHINE_INFO_NULL);
|
||||||
}
|
}
|
||||||
MachineInfoDO machineInfoDO = machineInfoMapper.selectById(id);
|
MachineInfoDO machineInfoDO = machineInfoMapper.selectById(id);
|
||||||
if (machineInfoDO == null) {
|
if (machineInfoDO == null) {
|
||||||
@ -346,13 +349,14 @@ public class MachineinfoServiceImpl implements MachineInfoService {
|
|||||||
}
|
}
|
||||||
return machineInfoDO;
|
return machineInfoDO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
void validateMachineEnable(MachineInfoDO machineInfoDO) {
|
void validateMachineEnable(MachineInfoDO machineInfoDO) {
|
||||||
|
|
||||||
if (machineInfoDO.getStatus() == MachineInfoStatus.ENABLE.getCode()) {
|
if (machineInfoDO.getStatus() == MachineInfoStatus.ENABLE.getCode()) {
|
||||||
throw exception(MACHINE_ENABLE);
|
throw exception(MACHINE_ENABLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
void validateMachineUnEnable(MachineInfoDO machineInfoDO) {
|
void validateMachineUnEnable(MachineInfoDO machineInfoDO) {
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
package cd.casic.module.machine.service.impl;
|
package cd.casic.module.machine.service.impl;
|
||||||
|
|
||||||
import cd.casic.framework.commons.pojo.PageResult;
|
import cd.casic.framework.commons.pojo.PageResult;
|
||||||
import cd.casic.framework.commons.util.object.BeanUtils;
|
import cd.casic.framework.commons.util.object.BeanUtils;
|
||||||
import cd.casic.module.machine.controller.vo.SecretKeyVO;
|
import cd.casic.module.machine.controller.vo.SecretKeyVO;
|
||||||
@ -15,6 +16,7 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static cd.casic.framework.commons.exception.util.ServiceExceptionUtil.exception;
|
import static cd.casic.framework.commons.exception.util.ServiceExceptionUtil.exception;
|
||||||
import static cd.casic.module.machine.contants.MachineErrorCodeConstants.*;
|
import static cd.casic.module.machine.contants.MachineErrorCodeConstants.*;
|
||||||
|
|
||||||
@ -34,7 +36,6 @@ public class SecretKeyServiceImpl implements SecretKeyService {
|
|||||||
private SecretKeyMapper secretKeyMapper;
|
private SecretKeyMapper secretKeyMapper;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SecretKeyVO getSecretKey(Long id) {
|
public SecretKeyVO getSecretKey(Long id) {
|
||||||
SecretKeyDO secretKeyDO = validateSecretKeyExists(id);
|
SecretKeyDO secretKeyDO = validateSecretKeyExists(id);
|
||||||
@ -56,6 +57,7 @@ public class SecretKeyServiceImpl implements SecretKeyService {
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateSecretKey(SecretKeyVO secretKeyVO) {
|
public void updateSecretKey(SecretKeyVO secretKeyVO) {
|
||||||
SecretKeyDO secretKeyDO = validateSecretKeyExists(secretKeyVO.getId());
|
SecretKeyDO secretKeyDO = validateSecretKeyExists(secretKeyVO.getId());
|
||||||
@ -65,17 +67,16 @@ public class SecretKeyServiceImpl implements SecretKeyService {
|
|||||||
String ossPath = upLoadSecretKey(secretKeyVO.getPath());
|
String ossPath = upLoadSecretKey(secretKeyVO.getPath());
|
||||||
BeanUtils.copyProperties(secretKeyVO, secretKeyDO);
|
BeanUtils.copyProperties(secretKeyVO, secretKeyDO);
|
||||||
secretKeyDO.setPath(ossPath);
|
secretKeyDO.setPath(ossPath);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
BeanUtils.copyProperties(secretKeyVO, secretKeyDO);
|
BeanUtils.copyProperties(secretKeyVO, secretKeyDO);
|
||||||
}
|
}
|
||||||
secretKeyMapper.updateById(secretKeyDO);
|
secretKeyMapper.updateById(secretKeyDO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void bindingMachine(Long id,List<Long> machineInfoIds) {
|
public void bindingMachine(SecretKeyVO secretKeyVO) {
|
||||||
validateSecretKeyExists(id);
|
validateSecretKeyExists(secretKeyVO.getId());
|
||||||
machineInfoService.bindingSecretKey(machineInfoIds, id);
|
machineInfoService.bindingSecretKey(secretKeyVO.getMachineInfoIds(), secretKeyVO.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -145,7 +146,7 @@ public class SecretKeyServiceImpl implements SecretKeyService {
|
|||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
SecretKeyDO validateSecretKeyExists(Long id) {
|
SecretKeyDO validateSecretKeyExists(Long id) {
|
||||||
if (id == null) {
|
if (id == null) {
|
||||||
return null;
|
throw exception(SECRET_KEY_NOT_EXISTS);
|
||||||
}
|
}
|
||||||
SecretKeyDO secretKeyDO = secretKeyMapper.selectById(id);
|
SecretKeyDO secretKeyDO = secretKeyMapper.selectById(id);
|
||||||
if (secretKeyDO == null) {
|
if (secretKeyDO == null) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user