This commit is contained in:
lixudong 2024-06-24 12:08:09 +08:00
parent ef2d49e93d
commit 559a897896
2 changed files with 38 additions and 37 deletions

View File

@ -20,34 +20,35 @@ import {CommonFunctions} from "../../../utils/checkUtils";
export class CheckErrorCode { export class CheckErrorCode {
static errorCodeList: number[] = [201, 202, 203, 301, 401, 501, 502, 801, 901]; static errorCodeList: number[] = [201, 202, 203, 301, 401, 501, 502, 801, 901];
static isArrayNotEmpty(arr: any): boolean { static isArrayNotEmpty(arr: any): boolean {
return Array.isArray(arr) && arr.length > 0; return Array.isArray(arr) && arr.length > 0;
} }
/** /**
* arr1中的每个数字是否在数组arr2中 * arr1中的每个数字是否在数组arr2中
* @param arr1 * @param arr1
* @param arr2 * @param arr2
*/ */
static hasNumberInArray(arr1: number[], arr2: number[]): boolean { static hasNumberInArray(arr1: number[], arr2: number[]): boolean {
return arr1.every(num => arr2.includes(num)); return arr1.every(num => arr2.includes(num));
} }
static checkErrorCode(apiJsdoc: Comment.JsDocInfo): ErrorTagFormat { static checkErrorCode(apiJsdoc: Comment.JsDocInfo): ErrorTagFormat {
const checkResult: ErrorTagFormat = { const checkResult: ErrorTagFormat = {
state: true, state: true,
errorInfo: '', errorInfo: '',
}; };
const errorCodes = apiJsdoc.errorCodes.filter(number => number >= 100 && number < 1000);; const errorCodes = apiJsdoc.errorCodes.filter(number => number >= 100 && number < 1000);
if (this.isArrayNotEmpty(errorCodes)) { ;
if (!this.hasNumberInArray(errorCodes, this.errorCodeList)) { if (this.isArrayNotEmpty(errorCodes)) {
checkResult.state = false; if (!this.hasNumberInArray(errorCodes, this.errorCodeList)) {
checkResult.errorInfo = ErrorMessage.ERROR_ERROR_CODE; checkResult.state = false;
} checkResult.errorInfo = ErrorMessage.ERROR_ERROR_CODE;
} }
return checkResult;
} }
return checkResult;
}
} }

View File

@ -24,15 +24,15 @@
* @since 6 * @since 6
*/ */
export interface StartBLEScanOptions { export interface StartBLEScanOptions {
/** /**
* Initializes the connected NFC tag. * Initializes the connected NFC tag.
* *
* @throws { BusinessError } 209 - Capability not supported. * @throws { BusinessError } 209 - Capability not supported.
* @throws { BusinessError } 3200101 - Connected NFC tag running state is abnormal in service. * @throws { BusinessError } 3200101 - Connected NFC tag running state is abnormal in service.
* @syscap SystemCapability.Communication.ConnectedTag * @syscap SystemCapability.Communication.ConnectedTag
* @since 9 * @since 9
*/ */
initialize(): void; initialize(): void;
} }