Compare commits

...

2 Commits

Author SHA1 Message Date
唐潇凯
818c2e0198 Merge remote-tracking branch 'origin/jenkins-engin' into jenkins-engin 2025-06-03 14:14:54 +08:00
唐潇凯
a7398d265c 代码测试完成 2025-06-03 14:13:39 +08:00
8 changed files with 15 additions and 52 deletions

View File

@ -57,7 +57,7 @@ public class MachineEnvController {
return success(true); return success(true);
} }
@GetMapping("/listByMachineId") @GetMapping("/getByMachineId")
@Operation(summary = "获取机器的环境变量") @Operation(summary = "获取机器的环境变量")
public CommonResult getByMachineId( public CommonResult getByMachineId(
@RequestParam Long machineId) { @RequestParam Long machineId) {

View File

@ -34,7 +34,7 @@ public class MachineProxyController {
} }
@GetMapping("/list") @GetMapping("/list")
@Operation(summary ="获取代理") @Operation(summary ="获取代理列表")
public CommonResult list(MachineProxyDTO machineProxyDTO) { public CommonResult list(MachineProxyDTO machineProxyDTO) {
return success(machineProxyService.list(machineProxyDTO)); return success(machineProxyService.list(machineProxyDTO));
} }
@ -46,13 +46,6 @@ public class MachineProxyController {
return success(true); return success(true);
} }
@PostMapping("/receiptHeartbeat")
@Operation(summary ="接收代理心跳")
public CommonResult heartbeat(@RequestBody MachineProxyDTO machineProxyDTO) {
machineProxyService.heartbeat(machineProxyDTO);
return success(true);
}
@GetMapping("/statistics/status") @GetMapping("/statistics/status")
@Operation(summary ="获取所有代理的状态统计") @Operation(summary ="获取所有代理的状态统计")
public CommonResult getStatusStatistics() { public CommonResult getStatusStatistics() {
@ -68,7 +61,7 @@ public class MachineProxyController {
@DeleteMapping("/batch") @DeleteMapping("/batch")
@Operation(summary ="批量删除代理") @Operation(summary ="批量删除代理")
public CommonResult deleteBatch(@RequestBody List<Long> ids) { public CommonResult deleteBatch(@RequestParam List<Long> ids) {
machineProxyService.delete(ids); machineProxyService.delete(ids);
return success(true); return success(true);
} }

View File

@ -19,7 +19,7 @@ public class MachineEnvDTO extends PageDto implements Serializable {
private Long id; private Long id;
private String envKey; private String envKey;
private String envValue; private String envValue;
private Boolean sensitive; private Integer sensitive;//(1敏感0不敏感)
private String description; private String description;
private Long machineId; private Long machineId;
private Date createDate; private Date createDate;
@ -32,7 +32,7 @@ public class MachineEnvDTO extends PageDto implements Serializable {
* 获取脱敏后的环境变量值 * 获取脱敏后的环境变量值
*/ */
public String getMaskedValue() { public String getMaskedValue() {
if (!sensitive || envValue == null) { if (sensitive==1 || envValue == null) {
return envValue; return envValue;
} }
int length = envValue.length(); int length = envValue.length();

View File

@ -37,7 +37,8 @@ public class MachineEnv extends BaseEntity implements Serializable {
/** /**
* 是否敏感 * 是否敏感
*/ */
private Boolean sensitive; @TableField("`sensitive`")
private Integer sensitive;//(1敏感0不敏感)
/** /**
* 描述信息 * 描述信息
@ -45,9 +46,4 @@ public class MachineEnv extends BaseEntity implements Serializable {
private String description; private String description;
/**
* 逻辑删除标志
*/
@TableLogic
private Boolean deleted;
} }

View File

@ -61,9 +61,5 @@ public class MachineProxy extends BaseEntity implements Serializable {
private String description; private String description;
/**
* 逻辑删除标志
*/
@TableLogic
private Boolean deleted;
} }

View File

@ -21,10 +21,6 @@ public interface MachineProxyService extends IService<MachineProxy> {
*/ */
boolean updateStatus(MachineProxyDTO machineProxyDTO); boolean updateStatus(MachineProxyDTO machineProxyDTO);
/**
* 接收代理心跳
*/
boolean heartbeat(MachineProxyDTO machineProxyDTO);
/** /**
@ -37,7 +33,7 @@ public interface MachineProxyService extends IService<MachineProxy> {
/** /**
* 更新代理配置 * 更新代理配置
*/ */
boolean updateConfig(MachineProxyDTO machineProxyDTO); void updateConfig(MachineProxyDTO machineProxyDTO);

View File

@ -41,7 +41,7 @@ public class MachineEnvServiceImpl extends ServiceImpl<MachineEnvMapper, Machine
} }
// 判断是否敏感变量 // 判断是否敏感变量
boolean sensitive = isSensitive(machineEnvDTO.getEnvKey()); boolean isSensitive = isSensitive(machineEnvDTO.getEnvKey());
MachineEnv machineEnv = new MachineEnv(); MachineEnv machineEnv = new MachineEnv();
BeanUtils.copyProperties(machineEnvDTO, machineEnv); BeanUtils.copyProperties(machineEnvDTO, machineEnv);
@ -88,7 +88,7 @@ public class MachineEnvServiceImpl extends ServiceImpl<MachineEnvMapper, Machine
} }
// 是否敏感 // 是否敏感
if (machineEnvDTO.getSensitive() != null) { if (!StringUtils.isEmpty(machineEnvDTO.getSensitive())) {
queryWrapper.eq(MachineEnv::getSensitive, machineEnvDTO.getSensitive()); queryWrapper.eq(MachineEnv::getSensitive, machineEnvDTO.getSensitive());
} }

View File

@ -35,6 +35,7 @@ public class MachineProxyServiceImpl extends ServiceImpl<MachineProxyMapper, Mac
public boolean register(MachineProxyDTO machineProxyDTO) { public boolean register(MachineProxyDTO machineProxyDTO) {
// 创建代理记录 // 创建代理记录
MachineProxy proxy = new MachineProxy(); MachineProxy proxy = new MachineProxy();
BeanUtils.copyProperties(machineProxyDTO, proxy);
proxy.setProxyTypeCode(EnumUtils.getEnumByMessage(machineProxyDTO.getProxyType(), MachineProxyType.class).getCode()); proxy.setProxyTypeCode(EnumUtils.getEnumByMessage(machineProxyDTO.getProxyType(), MachineProxyType.class).getCode());
proxy.setVersion("1.0.0"); proxy.setVersion("1.0.0");
proxy.setStatusCode(MachineProxyStatus.INSTALLING.getCode()); proxy.setStatusCode(MachineProxyStatus.INSTALLING.getCode());
@ -61,25 +62,6 @@ public class MachineProxyServiceImpl extends ServiceImpl<MachineProxyMapper, Mac
return updateById(proxy); return updateById(proxy);
} }
@Override
public boolean heartbeat(MachineProxyDTO machineProxyDTO) {
// 参数校验
if (machineProxyDTO == null) {
throw new IllegalArgumentException("MachineProxyDTO对象为空");
}
// 查询代理
MachineProxy proxy = this.getById(machineProxyDTO.getId());
if (proxy == null) {
throw new IllegalArgumentException("代理不存在");
}
// 更新心跳信息
proxy.setVersion(machineProxyDTO.getVersion());
proxy.setStatusCode(EnumUtils.getEnumByMessage(machineProxyDTO.getStatus(),MachineProxyStatus.class).getCode());
return updateById(proxy);
}
@Override @Override
@ -98,7 +80,7 @@ public class MachineProxyServiceImpl extends ServiceImpl<MachineProxyMapper, Mac
} }
@Override @Override
public boolean updateConfig(MachineProxyDTO machineProxyDTO) { public void updateConfig(MachineProxyDTO machineProxyDTO) {
// 参数校验 // 参数校验
if (machineProxyDTO == null) { if (machineProxyDTO == null) {
throw new ServiceException(ServiceException.MACHINE_PROXY_DTO_NULL,"MachineProxyDTO对象为空"); throw new ServiceException(ServiceException.MACHINE_PROXY_DTO_NULL,"MachineProxyDTO对象为空");
@ -113,7 +95,7 @@ public class MachineProxyServiceImpl extends ServiceImpl<MachineProxyMapper, Mac
// 更新配置 // 更新配置
proxy.setConfig(machineProxyDTO.getConfig()); proxy.setConfig(machineProxyDTO.getConfig());
proxy.setUpdateDate(new Date()); proxy.setUpdateDate(new Date());
return updateById(proxy); updateById(proxy);
} }
@ -129,7 +111,7 @@ public class MachineProxyServiceImpl extends ServiceImpl<MachineProxyMapper, Mac
// 查询在线代理 // 查询在线代理
List<MachineProxy> onlineProxies = list(new LambdaQueryWrapper<MachineProxy>() List<MachineProxy> onlineProxies = list(new LambdaQueryWrapper<MachineProxy>()
.in(MachineProxy::getId, ids) .in(MachineProxy::getId, ids)
.eq(MachineProxy::getStatus, MachineProxyStatus.ONLINE.getCode())); .eq(MachineProxy::getStatusCode, MachineProxyStatus.ONLINE.getCode()));
if (!CollectionUtils.isEmpty(onlineProxies)) { if (!CollectionUtils.isEmpty(onlineProxies)) {
List<Long> onlineIds = onlineProxies.stream() List<Long> onlineIds = onlineProxies.stream()