修改更新主机身份逻辑.
This commit is contained in:
@@ -7,7 +7,6 @@ import lombok.Data;
|
|||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
import javax.validation.constraints.NotNull;
|
|
||||||
import javax.validation.constraints.Size;
|
import javax.validation.constraints.Size;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
@@ -35,12 +34,10 @@ public class HostIdentityCreateRequest implements Serializable {
|
|||||||
@Schema(description = "用户名")
|
@Schema(description = "用户名")
|
||||||
private String username;
|
private String username;
|
||||||
|
|
||||||
@NotBlank
|
|
||||||
@Size(max = 512)
|
@Size(max = 512)
|
||||||
@Schema(description = "用户密码")
|
@Schema(description = "用户密码")
|
||||||
private String password;
|
private String password;
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Schema(description = "秘钥id")
|
@Schema(description = "秘钥id")
|
||||||
private Long keyId;
|
private Long keyId;
|
||||||
|
|
||||||
|
|||||||
@@ -39,12 +39,10 @@ public class HostIdentityUpdateRequest implements UpdatePasswordAction {
|
|||||||
@Schema(description = "用户名")
|
@Schema(description = "用户名")
|
||||||
private String username;
|
private String username;
|
||||||
|
|
||||||
@NotBlank
|
|
||||||
@Size(max = 512)
|
@Size(max = 512)
|
||||||
@Schema(description = "用户密码")
|
@Schema(description = "用户密码")
|
||||||
private String password;
|
private String password;
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Schema(description = "秘钥id")
|
@Schema(description = "秘钥id")
|
||||||
private Long keyId;
|
private Long keyId;
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ package com.orion.ops.module.asset.service.impl;
|
|||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
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.lang.define.wrapper.DataGrid;
|
||||||
import com.orion.ops.framework.common.constant.Const;
|
import com.orion.ops.framework.common.constant.Const;
|
||||||
import com.orion.ops.framework.common.constant.ErrorMessage;
|
import com.orion.ops.framework.common.constant.ErrorMessage;
|
||||||
@@ -82,7 +84,10 @@ public class HostIdentityServiceImpl implements HostIdentityService {
|
|||||||
String newPassword = PasswordModifier.getEncryptNewPassword(request);
|
String newPassword = PasswordModifier.getEncryptNewPassword(request);
|
||||||
updateRecord.setPassword(newPassword);
|
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())) {
|
if (!record.getName().equals(updateRecord.getName())) {
|
||||||
RedisLists.removeJson(HostCacheKeyDefine.HOST_IDENTITY.getKey(), HostIdentityConvert.MAPPER.toCache(record));
|
RedisLists.removeJson(HostCacheKeyDefine.HOST_IDENTITY.getKey(), HostIdentityConvert.MAPPER.toCache(record));
|
||||||
|
|||||||
@@ -33,10 +33,11 @@
|
|||||||
label="用户密码"
|
label="用户密码"
|
||||||
style="justify-content: space-between;">
|
style="justify-content: space-between;">
|
||||||
<a-input-password v-model="formModel.password"
|
<a-input-password v-model="formModel.password"
|
||||||
:disabled="!formModel.useNewPassword"
|
:disabled="!isAddHandle && !formModel.useNewPassword"
|
||||||
class="password-input"
|
:class="[isAddHandle ? 'password-input-full' : 'password-input']"
|
||||||
placeholder="请输入用户密码" />
|
placeholder="请输入用户密码" />
|
||||||
<a-switch v-model="formModel.useNewPassword"
|
<a-switch v-model="formModel.useNewPassword"
|
||||||
|
v-if="!isAddHandle"
|
||||||
class="password-switch"
|
class="password-switch"
|
||||||
type="round"
|
type="round"
|
||||||
size="large"
|
size="large"
|
||||||
@@ -124,6 +125,10 @@
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (isAddHandle.value) {
|
if (isAddHandle.value) {
|
||||||
|
if (!formModel.password && !formModel.keyId) {
|
||||||
|
Message.error('创建时密码和秘钥不能同时为空');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
// 新增
|
// 新增
|
||||||
await createHostIdentity(formModel as any);
|
await createHostIdentity(formModel as any);
|
||||||
Message.success('创建成功');
|
Message.success('创建成功');
|
||||||
@@ -161,6 +166,10 @@
|
|||||||
width: 240px;
|
width: 240px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.password-input-full {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
.password-switch {
|
.password-switch {
|
||||||
margin-left: 16px;
|
margin-left: 16px;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,9 +57,31 @@
|
|||||||
@page-change="(page) => fetchTableData(page, pagination.pageSize)"
|
@page-change="(page) => fetchTableData(page, pagination.pageSize)"
|
||||||
@page-size-change="(size) => fetchTableData(pagination.current, size)"
|
@page-size-change="(size) => fetchTableData(pagination.current, size)"
|
||||||
:bordered="false">
|
:bordered="false">
|
||||||
<!-- 操作 -->
|
<!-- 用户名 -->
|
||||||
|
<template #username="{ record }">
|
||||||
|
<a-tooltip content="点击复制">
|
||||||
|
<span class="pointer span-blue" @click="copy(record.username)">
|
||||||
|
<icon-copy class="mr4" />{{ record.username }}
|
||||||
|
</span>
|
||||||
|
</a-tooltip>
|
||||||
|
</template>
|
||||||
|
<!-- 秘钥名称 -->
|
||||||
<template #keyId="{ record }">
|
<template #keyId="{ record }">
|
||||||
{{ record.keyName }}
|
<template v-if="record.keyId">
|
||||||
|
<!-- 可查看详情 -->
|
||||||
|
<a-tooltip v-if="hasAnyPermission(['asset:host-key:detail', 'asset:host-key:update'])"
|
||||||
|
content="点击查看详情">
|
||||||
|
<a-tag :checked="true"
|
||||||
|
checkable
|
||||||
|
@click="emits('openKeyView',{id: record.keyId})">
|
||||||
|
{{ record.keyName }}
|
||||||
|
</a-tag>
|
||||||
|
</a-tooltip>
|
||||||
|
<!-- 不可查看详情 -->
|
||||||
|
<a-tag v-else>
|
||||||
|
{{ record.keyName }}
|
||||||
|
</a-tag>
|
||||||
|
</template>
|
||||||
</template>
|
</template>
|
||||||
<!-- 操作 -->
|
<!-- 操作 -->
|
||||||
<template #handle="{ record }">
|
<template #handle="{ record }">
|
||||||
@@ -105,10 +127,15 @@
|
|||||||
import { getHostKeyList } from '@/api/asset/host-key';
|
import { getHostKeyList } from '@/api/asset/host-key';
|
||||||
import { useCacheStore } from '@/store';
|
import { useCacheStore } from '@/store';
|
||||||
import HostKeySelector from '@/components/asset/host-key/host-key-selector.vue';
|
import HostKeySelector from '@/components/asset/host-key/host-key-selector.vue';
|
||||||
|
import useCopy from '@/hooks/copy';
|
||||||
|
import usePermission from '@/hooks/permission';
|
||||||
|
|
||||||
|
const { copy } = useCopy();
|
||||||
|
const { hasAnyPermission } = usePermission();
|
||||||
|
|
||||||
const tableRenderData = ref<HostIdentityQueryResponse[]>();
|
const tableRenderData = ref<HostIdentityQueryResponse[]>();
|
||||||
const { loading, setLoading } = useLoading();
|
const { loading, setLoading } = useLoading();
|
||||||
const emits = defineEmits(['openAdd', 'openUpdate']);
|
const emits = defineEmits(['openAdd', 'openUpdate', 'openViewKey']);
|
||||||
|
|
||||||
const cacheStore = useCacheStore();
|
const cacheStore = useCacheStore();
|
||||||
const pagination = reactive(defaultPagination());
|
const pagination = reactive(defaultPagination());
|
||||||
|
|||||||
@@ -3,11 +3,14 @@
|
|||||||
<!-- 表格 -->
|
<!-- 表格 -->
|
||||||
<host-identity-table ref="table"
|
<host-identity-table ref="table"
|
||||||
@openAdd="() => modal.openAdd()"
|
@openAdd="() => modal.openAdd()"
|
||||||
@openUpdate="(e) => modal.openUpdate(e)" />
|
@openUpdate="(e) => modal.openUpdate(e)"
|
||||||
|
@openKeyView="(e) => keyDrawer.openView(e) " />
|
||||||
<!-- 添加修改模态框 -->
|
<!-- 添加修改模态框 -->
|
||||||
<host-identity-form-modal ref="modal"
|
<host-identity-form-modal ref="modal"
|
||||||
@added="() => table.addedCallback()"
|
@added="() => table.addedCallback()"
|
||||||
@updated="() => table.updatedCallback()" />
|
@updated="() => table.updatedCallback()" />
|
||||||
|
<!-- 添加修改模态框 -->
|
||||||
|
<host-key-form-drawer ref="keyDrawer" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -20,12 +23,14 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import HostIdentityTable from './components/host-identity-table.vue';
|
import HostIdentityTable from './components/host-identity-table.vue';
|
||||||
import HostIdentityFormModal from './components/host-identity-form-modal.vue';
|
import HostIdentityFormModal from './components/host-identity-form-modal.vue';
|
||||||
|
import HostKeyFormDrawer from '../host-key/components/host-key-form-drawer.vue';
|
||||||
|
|
||||||
import { onUnmounted, ref } from 'vue';
|
import { onUnmounted, ref } from 'vue';
|
||||||
import { useCacheStore } from '@/store';
|
import { useCacheStore } from '@/store';
|
||||||
|
|
||||||
const table = ref();
|
const table = ref();
|
||||||
const modal = ref();
|
const modal = ref();
|
||||||
|
const keyDrawer = ref();
|
||||||
|
|
||||||
// 卸载时清除 tags cache
|
// 卸载时清除 tags cache
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
|
|||||||
@@ -64,20 +64,17 @@
|
|||||||
label="密码"
|
label="密码"
|
||||||
style="justify-content: space-between;">
|
style="justify-content: space-between;">
|
||||||
<a-input-password v-model="formModel.password"
|
<a-input-password v-model="formModel.password"
|
||||||
:disabled="!formModel.useNewPassword"
|
:disabled="!isAddHandle && !formModel.useNewPassword"
|
||||||
|
:class="[isAddHandle ? 'password-input-full' : 'password-input']"
|
||||||
class="password-input"
|
class="password-input"
|
||||||
placeholder="请输入私钥密码" />
|
placeholder="请输入私钥密码" />
|
||||||
<a-switch v-model="formModel.useNewPassword"
|
<a-switch v-model="formModel.useNewPassword"
|
||||||
|
v-if="!isAddHandle"
|
||||||
class="password-switch"
|
class="password-switch"
|
||||||
type="round"
|
type="round"
|
||||||
size="large">
|
size="large"
|
||||||
<template #checked>
|
checked-text="使用新密码"
|
||||||
使用新密码
|
unchecked-text="使用原密码" />
|
||||||
</template>
|
|
||||||
<template #unchecked>
|
|
||||||
使用原密码
|
|
||||||
</template>
|
|
||||||
</a-switch>
|
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-form>
|
</a-form>
|
||||||
</a-spin>
|
</a-spin>
|
||||||
@@ -241,6 +238,10 @@
|
|||||||
width: 240px;
|
width: 240px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.password-input-full {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
.password-switch {
|
.password-switch {
|
||||||
margin-left: 16px;
|
margin-left: 16px;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,19 +78,17 @@
|
|||||||
@page-change="(page) => fetchTableData(page, pagination.pageSize)"
|
@page-change="(page) => fetchTableData(page, pagination.pageSize)"
|
||||||
@page-size-change="(size) => fetchTableData(pagination.current, size)"
|
@page-size-change="(size) => fetchTableData(pagination.current, size)"
|
||||||
:bordered="false">
|
:bordered="false">
|
||||||
<!-- 名称 -->
|
|
||||||
<template #name="{ record }">
|
|
||||||
<span class="span-blue">{{ record.name }}</span>
|
|
||||||
</template>
|
|
||||||
<!-- 编码 -->
|
<!-- 编码 -->
|
||||||
<template #code="{ record }">
|
<template #code="{ record }">
|
||||||
<a-tag>{{ record.code }}</a-tag>
|
<a-tag>{{ record.code }}</a-tag>
|
||||||
</template>
|
</template>
|
||||||
<!-- 地址 -->
|
<!-- 地址 -->
|
||||||
<template #address="{ record }">
|
<template #address="{ record }">
|
||||||
<span class="host-address" title="点击复制" @click="copy(record.address)">
|
<a-tooltip content="点击复制">
|
||||||
{{ record.address }}
|
<span class="host-address" @click="copy(record.address)">
|
||||||
</span>
|
<icon-copy class="mr4" />{{ record.address }}
|
||||||
|
</span>
|
||||||
|
</a-tooltip>
|
||||||
</template>
|
</template>
|
||||||
<!-- 标签 -->
|
<!-- 标签 -->
|
||||||
<template #tag="{ record }">
|
<template #tag="{ record }">
|
||||||
|
|||||||
@@ -84,18 +84,26 @@
|
|||||||
field="type"
|
field="type"
|
||||||
label="是否可见"
|
label="是否可见"
|
||||||
tooltip="选择隐藏后不会在菜单以及 tab 中显示 但是可以访问">
|
tooltip="选择隐藏后不会在菜单以及 tab 中显示 但是可以访问">
|
||||||
<a-radio-group type="button"
|
<a-switch type="round"
|
||||||
v-model="formModel.visible"
|
size="large"
|
||||||
:options="toOptions(MenuVisibleEnum)" />
|
v-model="formModel.visible"
|
||||||
|
:checked-text="MenuVisibleEnum.SHOW.label"
|
||||||
|
:checked-value="MenuVisibleEnum.SHOW.value"
|
||||||
|
:unchecked-text="MenuVisibleEnum.HIDE.label"
|
||||||
|
:unchecked-value="MenuVisibleEnum.HIDE.value" />
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<!-- 是否缓存 -->
|
<!-- 是否缓存 -->
|
||||||
<a-form-item v-if="formModel.type !== MenuTypeEnum.FUNCTION.value"
|
<a-form-item v-if="formModel.type !== MenuTypeEnum.FUNCTION.value"
|
||||||
field="type"
|
field="type"
|
||||||
label="是否缓存"
|
label="是否缓存"
|
||||||
tooltip="选择缓存后则会使用 keep-alive 缓存组件">
|
tooltip="选择缓存后则会使用 keep-alive 缓存组件">
|
||||||
<a-radio-group type="button"
|
<a-switch type="round"
|
||||||
v-model="formModel.cache"
|
size="large"
|
||||||
:options="toOptions(MenuCacheEnum)" />
|
v-model="formModel.cache"
|
||||||
|
:checked-text="MenuCacheEnum.ENABLED.label"
|
||||||
|
:checked-value="MenuCacheEnum.ENABLED.value"
|
||||||
|
:unchecked-text="MenuCacheEnum.DISABLED.label"
|
||||||
|
:unchecked-value="MenuCacheEnum.DISABLED.value" />
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-form>
|
</a-form>
|
||||||
</a-spin>
|
</a-spin>
|
||||||
@@ -136,7 +144,7 @@
|
|||||||
permission: undefined,
|
permission: undefined,
|
||||||
sort: undefined,
|
sort: undefined,
|
||||||
visible: MenuVisibleEnum.SHOW.value,
|
visible: MenuVisibleEnum.SHOW.value,
|
||||||
cache: MenuCacheEnum.SHOW.value,
|
cache: MenuCacheEnum.ENABLED.value,
|
||||||
icon: undefined,
|
icon: undefined,
|
||||||
path: undefined,
|
path: undefined,
|
||||||
component: undefined,
|
component: undefined,
|
||||||
|
|||||||
@@ -52,11 +52,11 @@ export const MenuVisibleEnum = {
|
|||||||
* 菜单缓存状态
|
* 菜单缓存状态
|
||||||
*/
|
*/
|
||||||
export const MenuCacheEnum = {
|
export const MenuCacheEnum = {
|
||||||
HIDE: {
|
DISABLED: {
|
||||||
value: 0,
|
value: 0,
|
||||||
label: '不缓存',
|
label: '不缓存',
|
||||||
},
|
},
|
||||||
SHOW: {
|
ENABLED: {
|
||||||
value: 1,
|
value: 1,
|
||||||
label: '缓存',
|
label: '缓存',
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user