修改更新主机身份逻辑.

This commit is contained in:
lijiahang
2023-09-21 16:06:09 +08:00
parent b13cbd8cca
commit d236e57f85
10 changed files with 85 additions and 37 deletions

View File

@@ -7,7 +7,6 @@ import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.io.Serializable;
@@ -35,12 +34,10 @@ public class HostIdentityCreateRequest implements Serializable {
@Schema(description = "用户名")
private String username;
@NotBlank
@Size(max = 512)
@Schema(description = "用户密码")
private String password;
@NotNull
@Schema(description = "秘钥id")
private Long keyId;

View File

@@ -39,12 +39,10 @@ public class HostIdentityUpdateRequest implements UpdatePasswordAction {
@Schema(description = "用户名")
private String username;
@NotBlank
@Size(max = 512)
@Schema(description = "用户密码")
private String password;
@NotNull
@Schema(description = "秘钥id")
private Long keyId;

View File

@@ -2,6 +2,8 @@ package com.orion.ops.module.asset.service.impl;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.orion.lang.define.wrapper.DataGrid;
import com.orion.ops.framework.common.constant.Const;
import com.orion.ops.framework.common.constant.ErrorMessage;
@@ -82,7 +84,10 @@ public class HostIdentityServiceImpl implements HostIdentityService {
String newPassword = PasswordModifier.getEncryptNewPassword(request);
updateRecord.setPassword(newPassword);
// 更新
int effect = hostIdentityDAO.updateById(updateRecord);
LambdaUpdateWrapper<HostIdentityDO> wrapper = Wrappers.<HostIdentityDO>lambdaUpdate()
.set(HostIdentityDO::getKeyId, request.getKeyId())
.eq(HostIdentityDO::getId, id);
int effect = hostIdentityDAO.update(updateRecord, wrapper);
// 设置缓存
if (!record.getName().equals(updateRecord.getName())) {
RedisLists.removeJson(HostCacheKeyDefine.HOST_IDENTITY.getKey(), HostIdentityConvert.MAPPER.toCache(record));