diff --git a/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/service/impl/HostKeyServiceImpl.java b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/service/impl/HostKeyServiceImpl.java index 292bc537..617d3308 100644 --- a/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/service/impl/HostKeyServiceImpl.java +++ b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/service/impl/HostKeyServiceImpl.java @@ -53,6 +53,8 @@ public class HostKeyServiceImpl implements HostKeyService { HostKeyDO record = HostKeyConvert.MAPPER.to(request); // 查询数据是否冲突 this.checkHostKeyPresent(record); + // 加密 + this.encryptKey(record); String password = record.getPassword(); if (!Strings.isBlank(password)) { record.setPassword(CryptoUtils.encryptAsString(password)); @@ -78,6 +80,8 @@ public class HostKeyServiceImpl implements HostKeyService { HostKeyDO updateRecord = HostKeyConvert.MAPPER.to(request); // 查询数据是否冲突 this.checkHostKeyPresent(updateRecord); + // 加密 + this.encryptKey(updateRecord); // 设置密码 String newPassword = PasswordModifier.getEncryptNewPassword(request); updateRecord.setPassword(newPassword); @@ -97,6 +101,8 @@ public class HostKeyServiceImpl implements HostKeyService { // 查询 HostKeyDO record = hostKeyDAO.selectById(id); Valid.notNull(record, ErrorMessage.DATA_ABSENT); + // 解密秘钥 + this.decryptKey(record); // 转换 return HostKeyConvert.MAPPER.to(record); } @@ -105,6 +111,9 @@ public class HostKeyServiceImpl implements HostKeyService { public HostKeyDO getHostKey(Long id) { HostKeyDO record = hostKeyDAO.selectById(id); Valid.notNull(record, ErrorMessage.DATA_ABSENT); + // 解密秘钥 + this.decryptKey(record); + // 解密密码 String password = record.getPassword(); if (!Strings.isBlank(password)) { record.setPassword(CryptoUtils.decryptAsString(password)); @@ -206,4 +215,36 @@ public class HostKeyServiceImpl implements HostKeyService { vo.setPrivateKey(null); } + /** + * 加密 公钥 私钥 + * + * @param record record + */ + private void encryptKey(HostKeyDO record) { + String publicKey = record.getPublicKey(); + if (!Strings.isBlank(publicKey)) { + record.setPublicKey(CryptoUtils.encryptAsString(publicKey)); + } + String privateKey = record.getPrivateKey(); + if (!Strings.isBlank(privateKey)) { + record.setPrivateKey(CryptoUtils.encryptAsString(privateKey)); + } + } + + /** + * 解密 公钥 私钥 + * + * @param record record + */ + private void decryptKey(HostKeyDO record) { + String publicKey = record.getPublicKey(); + if (!Strings.isBlank(publicKey)) { + record.setPublicKey(CryptoUtils.decryptAsString(publicKey)); + } + String privateKey = record.getPrivateKey(); + if (!Strings.isBlank(privateKey)) { + record.setPrivateKey(CryptoUtils.decryptAsString(privateKey)); + } + } + } diff --git a/orion-ops-ui/src/api/asset/host.ts b/orion-ops-ui/src/api/asset/host.ts index ef182f51..9cdcf3d9 100644 --- a/orion-ops-ui/src/api/asset/host.ts +++ b/orion-ops-ui/src/api/asset/host.ts @@ -15,7 +15,7 @@ export interface HostCreateRequest { * 主机更新请求 */ export interface HostUpdateRequest extends HostCreateRequest { - id: number; + id: number | undefined; } /** @@ -54,6 +54,7 @@ export interface HostQueryResponse { */ export interface HostConfigRequest { id?: number; + hostId?: number; version?: number; status?: number; config?: string; diff --git a/orion-ops-ui/src/api/user/user.ts b/orion-ops-ui/src/api/user/user.ts index f0d79d29..4e4c8b3f 100644 --- a/orion-ops-ui/src/api/user/user.ts +++ b/orion-ops-ui/src/api/user/user.ts @@ -19,7 +19,7 @@ export interface UserCreateRequest { * 用户更新请求 */ export interface UserUpdateRequest extends UserCreateRequest { - id: number; + id: number | undefined; roleIdList?: Array; password?: string; } diff --git a/orion-ops-ui/src/components/tab-bar/index.vue b/orion-ops-ui/src/components/tab-bar/index.vue index 844e8235..dbc53947 100644 --- a/orion-ops-ui/src/components/tab-bar/index.vue +++ b/orion-ops-ui/src/components/tab-bar/index.vue @@ -53,7 +53,7 @@ !tagList.value.some((tag) => tag.fullPath === route.fullPath) ) { // 固定并且没有此 tab 则添加 - tabBarStore.addTab(routerToTag(route), route.meta?.ignoreCache as unknown as any); + tabBarStore.addTab(routerToTag(route), route.meta?.ignoreCache as unknown as boolean); } }, true); diff --git a/orion-ops-ui/src/components/tag/tag-multi-selector.vue b/orion-ops-ui/src/components/tag/tag-multi-selector.vue index 7e4fda89..c300a2d2 100644 --- a/orion-ops-ui/src/components/tag/tag-multi-selector.vue +++ b/orion-ops-ui/src/components/tag/tag-multi-selector.vue @@ -37,7 +37,7 @@ return props.modelValue; }, async set(e) { - await checkCreateTag(e as any); + await checkCreateTag(e as Array); emits('update:modelValue', e); } }); diff --git a/orion-ops-ui/src/hooks/favorite.ts b/orion-ops-ui/src/hooks/favorite.ts index ff6af06c..3032f5c0 100644 --- a/orion-ops-ui/src/hooks/favorite.ts +++ b/orion-ops-ui/src/hooks/favorite.ts @@ -3,7 +3,7 @@ import { FavoriteType, addFavorite, cancelFavorite } from '@/api/meta/favorite'; export default function useFavorite(type: FavoriteType) { const toggle = async (record: any, id: number, cancelField = 'favorite') => { - const request = { relId: id, type } as any; + const request = { relId: id, type }; const loading = Message.loading(record[cancelField] ? '取消中' : '收藏中'); try { if (record[cancelField]) { diff --git a/orion-ops-ui/src/utils/file.ts b/orion-ops-ui/src/utils/file.ts index 1929f69b..cdb52258 100644 --- a/orion-ops-ui/src/utils/file.ts +++ b/orion-ops-ui/src/utils/file.ts @@ -111,7 +111,7 @@ export function permission10toString(permission: number) { const ps = (permission + ''); let res = ''; for (let i = 0; i < ps.length; i++) { - const per = ps.charAt(i) as any; + const per = ps.charAt(i) as unknown as number; if ((per & 4) === 0) { res += '-'; } else { diff --git a/orion-ops-ui/src/views/asset/host/components/host-form-modal.vue b/orion-ops-ui/src/views/asset/host/components/host-form-modal.vue index ddd675a1..b999d35b 100644 --- a/orion-ops-ui/src/views/asset/host/components/host-form-modal.vue +++ b/orion-ops-ui/src/views/asset/host/components/host-form-modal.vue @@ -56,7 +56,7 @@ import useLoading from '@/hooks/loading'; import useVisible from '@/hooks/visible'; import formRules from '../types/form.rules'; - import { createHost, updateHost } from '@/api/asset/host'; + import { createHost, updateHost, HostUpdateRequest } from '@/api/asset/host'; import { Message } from '@arco-design/web-vue'; import TagMultiSelector from '@/components/tag/tag-multi-selector.vue'; @@ -66,7 +66,7 @@ const title = ref(); const isAddHandle = ref(true); - const defaultForm = () => { + const defaultForm = (): HostUpdateRequest & Record => { return { id: undefined, name: undefined, @@ -77,7 +77,7 @@ }; const formRef = ref(); - const formModel = reactive>(defaultForm()); + const formModel = reactive>(defaultForm()); const emits = defineEmits(['added', 'updated']); @@ -118,12 +118,12 @@ } if (isAddHandle.value) { // 新增 - await createHost(formModel as any); + await createHost(formModel); Message.success('创建成功'); emits('added'); } else { // 修改 - await updateHost(formModel as any); + await updateHost(formModel); Message.success('修改成功'); emits('updated'); } diff --git a/orion-ops-ui/src/views/user/role/components/role-form-modal.vue b/orion-ops-ui/src/views/user/role/components/role-form-modal.vue index eb55e8f8..d724f847 100644 --- a/orion-ops-ui/src/views/user/role/components/role-form-modal.vue +++ b/orion-ops-ui/src/views/user/role/components/role-form-modal.vue @@ -44,7 +44,7 @@ import useLoading from '@/hooks/loading'; import useVisible from '@/hooks/visible'; import formRules from '../types/form.rules'; - import { createRole, updateRole } from '@/api/user/role'; + import { createRole, updateRole, RoleUpdateRequest, } from '@/api/user/role'; import { Message } from '@arco-design/web-vue'; const { visible, setVisible } = useVisible(); @@ -53,7 +53,7 @@ const title = ref(); const isAddHandle = ref(true); - const defaultForm = () => { + const defaultForm = (): RoleUpdateRequest & Record => { return { id: undefined, name: undefined, @@ -62,7 +62,7 @@ }; const formRef = ref(); - const formModel = reactive>(defaultForm()); + const formModel = reactive>(defaultForm()); const emits = defineEmits(['added', 'updated']); @@ -102,12 +102,12 @@ } if (isAddHandle.value) { // 新增 - await createRole(formModel as any); + await createRole(formModel); Message.success('创建成功'); emits('added'); } else { // 修改 - await updateRole(formModel as any); + await updateRole(formModel); Message.success('修改成功'); emits('updated'); } diff --git a/orion-ops-ui/src/views/user/user/components/user-form-modal.vue b/orion-ops-ui/src/views/user/user/components/user-form-modal.vue index df9d394f..5adaf55b 100644 --- a/orion-ops-ui/src/views/user/user/components/user-form-modal.vue +++ b/orion-ops-ui/src/views/user/user/components/user-form-modal.vue @@ -58,7 +58,7 @@ import useLoading from '@/hooks/loading'; import useVisible from '@/hooks/visible'; import formRules from '../types/form.rules'; - import { createUser, updateUser } from '@/api/user/user'; + import { createUser, updateUser, UserUpdateRequest } from '@/api/user/user'; import { Message } from '@arco-design/web-vue'; import { md5 } from '@/utils'; @@ -68,7 +68,7 @@ const title = ref(); const isAddHandle = ref(true); - const defaultForm = () => { + const defaultForm = (): UserUpdateRequest & Record => { return { id: undefined, username: undefined, @@ -80,7 +80,7 @@ }; const formRef = ref(); - const formModel = reactive>(defaultForm()); + const formModel = reactive>(defaultForm()); const emits = defineEmits(['added', 'updated']); @@ -125,7 +125,7 @@ emits('added'); } else { // 修改 - await updateUser(formModel as any); + await updateUser(formModel); Message.success('修改成功'); emits('updated'); }