Merge remote-tracking branch 'origin/master'

This commit is contained in:
yangjie 2023-08-03 18:12:17 +08:00
commit cb9d24f3d7
2 changed files with 29 additions and 7 deletions

View File

@ -1,14 +1,13 @@
import { Injectable } from '@nestjs/common';
import { AxiosResult } from 'src/utils/axios';
import { AxiosSecure } from '../utils/axios';
import {
getConfig,
secureDectyptBase64,
toBase64,
secureHeader,
} from '../utils/index';
import Base from '../utils/base';
import globalConfig from '../utils/global';
import mqttMapper from 'src/mqtt/mqtt.mapper';
import mqttMapper from '../mqtt/mqtt.mapper';
import { v4 } from 'uuid';
@Injectable()
@ -44,7 +43,7 @@ export class SecureService {
iv,
};
// 调用加密接口
const result = await AxiosResult(
const result = await AxiosSecure(
`${getConfig().secureIp}/api/v1/se/key/encrypt`,
options,
{
@ -96,7 +95,7 @@ export class SecureService {
algorithm,
iv,
};
const result = await AxiosResult(
const result = await AxiosSecure(
`${getConfig().secureIp}/api/v1/se/key/decrypt`,
options,
{

View File

@ -39,8 +39,8 @@ export async function get(url: string, config?) {
}
}
// 用于安全接口加解密
export async function AxiosResult(url: string, options: any, config?, type?) {
// 用于安全接口加解密ecure
export async function AxiosSecure(url: string, options: any, config?, type?) {
try {
// console.log(
// `发起post请求---url:${url}---options:${JSON.stringify(
@ -71,3 +71,26 @@ export async function AxiosResult(url: string, options: any, config?, type?) {
};
}
}
// 用于安全接口加解密
export async function AxiosResult(url: string, options: any, config?, type?) {
try {
// console.log(
// `发起post请求---url:${url}---options:${JSON.stringify(
// options,
// )}---config:${JSON.stringify(config)}---type:${type}`,
// );
const result: any = await axios.post(url, options, config);
if (!result?.data) {
return;
}
return result;
} catch (error) {
// console.log(error);
return {
isError: true,
respCode: error.code,
respDesc: error.response?.data?.message,
};
}
}