diff --git a/zh-cn/application-dev/reference/apis-media-library-kit/errcode-medialibrary.md b/zh-cn/application-dev/reference/apis-media-library-kit/errcode-medialibrary.md new file mode 100644 index 0000000000000000000000000000000000000000..4f0798ba3d383e930cb6b82ac85c78fd62bc1fc5 --- /dev/null +++ b/zh-cn/application-dev/reference/apis-media-library-kit/errcode-medialibrary.md @@ -0,0 +1,66 @@ +# 媒体库错误码管理 + +> **说明:** +> +> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](../errorcode-universal.md)。 + +## 23800107 context为空或者无效 + +**错误信息** + +Context is invalid. + +**错误描述** + +上下文对象不存在或者为空时,方法会返回错误码。 + +**可能原因** + +上下文对象不存在。 + +**处理步骤** + +请检查上下文对象是否可用。 + +## 23800301 系统内部错误 + +**错误信息** + +System inner fail. + +**错误描述** + +媒体库内部错误。 + +**可能原因** + +1. 数据库异常。 + +2. 文件系统异常。 + +3. IPC消息超时。 + +**处理步骤** + +清理后台,或重启设备。 + +## 23800151 场景参数校验不通过 + +**错误信息** + +Scene parameter validation failed. + +**错误描述** +参数异常。 + +**可能原因** + +1. 必选参数范围不满足要求。 + +2. 传入的记录已存在。 + +3. 传入的记录数量超过最大数量。 + +**处理步骤** + +检查参数赋值或者参数长度。 \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis-media-library-kit/js-apis-photoAccessHelper-sys.md b/zh-cn/application-dev/reference/apis-media-library-kit/js-apis-photoAccessHelper-sys.md index af9bed9b5636f19e03b10e45b513c8c55307e8bd..f7560e58f8bf006a1a2315682b374154b037d95e 100644 --- a/zh-cn/application-dev/reference/apis-media-library-kit/js-apis-photoAccessHelper-sys.md +++ b/zh-cn/application-dev/reference/apis-media-library-kit/js-apis-photoAccessHelper-sys.md @@ -8051,6 +8051,374 @@ async function example(context: Context) { } ``` +## PhotoAssetCustomRecordManager20+ + +媒体库支持图库自定义用户统计行为接口。 + +**系统接口**:此接口为系统接口。 + +**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core + +### getCustomRecordManagerInstance20+ + +static getCustomRecordManagerInstance(context: Context): PhotoAssetCustomRecordManager + +获取图库自定义用户统计行为实例。 + +**系统接口**:此接口为系统接口。 + +**系统能力**: SystemCapability.FileManagement.PhotoAccessHelper.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| --- | --- | --- | --- | +| context | [Context](../apis-ability-kit/js-apis-inner-application-context.md#context) | 是 | 传入Ability实例的上下文。 | + +**返回值:** + +| 类型 | 说明 | +| --- | --- | +| [PhotoAssetCustomRecordManager](#photoassetcustomrecordmanager20) | 用户自定义行为统计实例。 | + +**错误码:** + +以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[媒体库错误码](errcode-medialibrary.md)。 + +| 错误码ID | 错误信息 | +| --- | --- | +| 202 | Called by non-system application. | +| 23800107 | Context is invalid. | + +**示例:** + +```ts +import { common } from '@kit.AbilityKit'; +import { BusinessError } from '@kit.BasicServicesKit'; + +async example(context: Context) { + console.info('getCustomRecordManagerInstance'); + try { + let context = getContext(this); + let crManager = photoAccessHelper.PhotoAssetCustomRecordManager.getCustomRecordManagerInstance(context); + } catch(err) { + console.error(`getCustomRecordManagerInstance failed with error: ${err.code}, ${err.message}`); + } +} +``` + +### createCustomRecords20+ + +createCustomRecords(customRecords: Array<PhotoAssetCustomRecord>): Promise<void> + +新增自定义用户统计行为数据。使用Promise异步回调。 + +**系统接口**:此接口为系统接口。 + +**系统能力**: SystemCapability.FileManagement.PhotoAccessHelper.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| --- | --- | --- | --- | +| customRecords | Array<[PhotoAssetCustomRecord](#photoassetcustomrecord20)> | 是 | 新增自定义用户统计行为数据。 | + +**返回值:** + +| 类型 | 说明 | +| --- | --- | +| Promise<void> | Promise对象,无返回结果。 | + +**错误码:** + +以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[媒体库错误码](errcode-medialibrary.md)。 + +| 错误码ID | 错误信息 | +| --- | --- | +| 202 | Called by non-system application. | +| 23800151 | Parameter error. Possible causes: 1. The value range of mandatory parameters in photoAssetCustomRecord does not meet the requirements. 2. The transferred record already exists. 3. The number of transferred records exceeds 200. | +| 23800301 | System inner error. Possible causes: 1. Database corrupted; 2. The file system is abnormal; 3. The IPC request timed out. | + +**示例:** + +```ts +import { BusinessError } from '@kit.BasicServicesKit'; + +async example() { + console.info('createCustomRecords'); + let context = getContext(this); + let crManager = photoAccessHelper.PhotoAssetCustomRecordManager.getCustomRecordManagerInstance(context); + let crArray:Array = [ + {fileId:1,shareCount:1,lcdJumpCount:1} + ]; + crManager.createCustomRecords(crArray).then(() => { + console.info('createCustomRecords successful'); + }).catch((err: BusinessError) => { + console.error('createCustomRecords fail with error: ${err.code}, ${err.message}'); + }); +} +``` + +### getCustomRecords20+ + +getCustomRecords(optionCheck: FetchOptions): Promise<FetchResult<PhotoAssetCustomRecord>> + +根据检索选项获取自定义用户统计行为数据。使用Promise异步回调。 + +**系统接口**:此接口为系统接口。 + +**系统能力**: SystemCapability.FileManagement.PhotoAccessHelper.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| --- | --- | --- | --- | +| optionCheck | [FetchOptions](js-apis-photoAccessHelper.md#fetchoptions) | 是 | 检索选项。 | + +**返回值:** + +| 类型 | 说明 | +| --- | --- | +| Promise<FetchResult<[PhotoAssetCustomRecord](#photoassetcustomrecord20)>> | Promise对象,返回自定义用户统计行为数据集合。 | + +**错误码:** + +以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[媒体库错误码](errcode-medialibrary.md)。 + +| 错误码ID | 错误信息 | +| --- | --- | +| 202 | Called by non-system application. | +| 23800151 | Parameter error. Possible causes: 1. The fileter criteria or fetchColumns that are not supported by options are transferred. | +| 23800301 | System inner error. Possible causes: 1. Database corrupted; 2. The file system is abnormal; 3. The IPC request timed out. | + +**示例:** + +```ts +import { dataSharePredicates } from '@kit.ArkData'; +import { BusinessError } from '@kit.BasicServicesKit'; + +async example() { + console.info('getCustomRecords'); + let context = getContext(this); + let crManager = photoAccessHelper.PhotoAssetCustomRecordManager.getCustomRecordManagerInstance(context); + let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); + predicates.equalTo('file_id', 1); + let fetchOption: photoAccessHelper.FetchOptions = { + fetchColumns: [], + predicates: predicates + }; + crManager.getCustomRecords(fetchOption).then((fetchResult) => { + let record = fetchResult.getFirstObject(); + console.info('record file id is ' + record.fileId); + }).catch((err: BusinessError) => { + console.error('getCustomRecords fail with error: ${err.code}, ${err.message}'); + }); +} +``` + +### setCustomRecords20+ + +setCustomRecords(customRecords: Array<PhotoAssetCustomRecord>): Promise<Array<number>> + +根据自定义用户统计行为数据,更新已存在的数据库字段。使用Promise异步回调。 + +**系统接口**:此接口为系统接口。 + +**系统能力**: SystemCapability.FileManagement.PhotoAccessHelper.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| --- | --- | --- | --- | +| customRecords | Array<[PhotoAssetCustomRecord](#photoassetcustomrecord20)> | 是 | 自定义用户统计行为数据。 | + +**返回值:** + +| 类型 | 说明 | +| --- | --- | +| Promise<Array<number>> | 更新失败的自定义用户统计行为数据中的fileId。 | + +**错误码:** + +以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[媒体库错误码](errcode-medialibrary.md)。 + +| 错误码ID | 错误信息 | +| --- | --- | +| 202 | Called by non-system application. | +| 23800151 | Parameter error. Possible causes: 1. The value range of mandatory parameters in photoAssetCustomRecord does not meet the requirements. 2. The transferred record already exists. 3. The number of transferred records exceeds 200. | +| 23800301 | System inner error. Possible causes: 1. Database corrupted; 2. The file system is abnormal; 3. The IPC request timed out. | + +**示例:** + +```ts +import { BusinessError } from '@kit.BasicServicesKit'; + +async example() { + console.info('setCustomRecords'); + let context = getContext(this); + let crManager = photoAccessHelper.PhotoAssetCustomRecordManager.getCustomRecordManagerInstance(context); + let UpdateArray: Array = [ + {fileId:1,shareCount:2,lcdJumpCount:3}, + {fileId:2,shareCount:2,lcdJumpCount:3} + ]; + crManager.setCustomRecords(UpdateArray).then((failIds) => { + console.info('setCustomRecords successful'); + }).catch((err: BusinessError) => { + console.error('setCustomRecords file with err: ${err.code}, ${err.message}'); + }); +} +``` + +### removeCustomRecords20+ + +removeCustomRecords(optionCheck: FetchOptions): Promise<void> + +根据检索选项删除自定义用户统计行为数据。使用Promise异步回调。 + +**系统接口**:此接口为系统接口。 + +**系统能力**: SystemCapability.FileManagement.PhotoAccessHelper.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| --- | --- | --- | --- | +| optionCheck | [FetchOptions](js-apis-photoAccessHelper.md#fetchoptions) | 是 | 检索选项。 | + +**返回值:** + +| 类型 | 说明 | +| --- | --- | +| Promise<void> | Promise对象,无返回结果。 | + +**错误码:** + +以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[媒体库错误码](errcode-medialibrary.md)。 + +| 错误码ID | 错误信息 | +| --- | --- | +| 202 | Called by non-system application. | +| 23800151 | Parameter error. Possible causes: 1. The fileter criteria or fetchColumns that are not supported by options are transferred. | +| 23800301 | System inner error. Possible causes: 1. Database corrupted; 2. The file system is abnormal; 3. The IPC request timed out. | + +**示例:** + +```ts +import { dataSharePredicates } from '@kit.ArkData'; +import { BusinessError } from '@kit.BasicServicesKit'; + +async example() { + console.info('removeCustomRecords'); + let context = getContext(this); + let crManager = photoAccessHelper.PhotoAssetCustomRecordManager.getCustomRecordManagerInstance(context); + let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); + predicates.equalTo('file_id', 1); + let fetchOption: photoAccessHelper.FetchOptions = { + fetchColumns: [], + predicates: predicates + }; + crManager.removeCustomRecords(fetchOption).then(() => { + console.info('removeCustomRecords successful'); + }).catch((err: BusinessError) => { + console.error('removeCustomRecords fail with error: ${err.code}, ${err.message}'); + }); +} +``` + +### addShareCount20+ + +addShareCount(ids: Array<number>): Promise<Array<number>> + +根据[PhotoAssetCustomRecord](#photoassetcustomrecord20)中的fileId给数据库中对应数据的shareCount加1。使用Promise异步回调。 + +**系统接口**:此接口为系统接口。 + +**系统能力**: SystemCapability.FileManagement.PhotoAccessHelper.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| --- | --- | --- | --- | +| ids | Array<number> | 是 | [PhotoAssetCustomRecord](#photoassetcustomrecord20)中的fileId集合。 | + +**返回值:** + +| 类型 | 说明 | +| --- | --- | +| Promise<Array<number>> | 更新失败的自定义用户统计行为数据中的fileId。 | + +**错误码:** + +以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[媒体库错误码](errcode-medialibrary.md)。 + +| 错误码ID | 错误信息 | +| --- | --- | +| 202 | Called by non-system application. | +| 23800151 | Parameter error. Possible causes: 1. The ids list is empty; 2. The number of ids lists exceeds 500. | +|23800301 | System inner error. Possible causes: 1. Database corrupted; 2. The file system is abnormal; 3. The IPC request timed out. | + +```ts +import { BusinessError } from '@kit.BasicServicesKit'; + +async example() { + console.info('addShareCount'); + let context = getContext(this); + let crManager = photoAccessHelper.PhotoAssetCustomRecordManager.getCustomRecordManagerInstance(context); + let ids: Array = [1, 2]; + crManager.addShareCount(ids).then((failIds) => { + console.info('addShareCount successful'); + }).catch((err: BusinessError) => { + console.error('addShareCount fail with error: ${err.code}, ${err.message}'); + }); +} +``` + +### addLcdJumpCount20+ + +addLcdJumpCount(ids: Array<number>): Promise<Array<number>> + +根据[PhotoAssetCustomRecord](#photoassetcustomrecord20)中的fileId给数据库中对应数据的LcdJumpCount加1。使用Promise异步回调。 + +**系统能力**: SystemCapability.FileManagement.PhotoAccessHelper.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| --- | --- | --- | --- | +| ids | Array<number> | 是 | [PhotoAssetCustomRecord](#photoassetcustomrecord20)中的fileId集合。 | + +**返回值:** + +| 类型 | 说明 | +| --- | --- | +| Promise<Array<number>> | 更新失败的自定义用户统计行为数据中的fileId。 | + +**错误码:** + +以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[媒体库错误码](errcode-medialibrary.md)。 + +| 错误码ID | 错误信息 | +| --- | --- | +| 202 | Called by non-system application. | +| 23800151 | Parameter error. Possible causes: 1. The ids list is empty; 2. The number of ids lists exceeds 500. | +| 23800301 | System inner error. Possible causes: 1. Database corrupted; 2. The file system is abnormal; 3. The IPC request timed out. | + +```ts +import { BusinessError } from '@kit.BasicServicesKit'; + +async example() { + console.info('addLcdJumpCount'); + let context = getContext(this); + let crManager = photoAccessHelper.PhotoAssetCustomRecordManager.getCustomRecordManagerInstance(context); + let ids: Array = [1, 2]; + crManager.addLcdJumpCount(ids).then((failIds) => { + console.info('addLcdJumpCount successful'); + }).catch((err: BusinessError) => { + console.error('addLcdJumpCount fail with error: ${err.code}, ${err.message}'); + }); +} +``` + ## PhotoSelectOptions 图库选择选项子类,继承于BaseSelectOptions。用于拉起对应userId空间的picker。 @@ -8613,4 +8981,18 @@ async function example(context: Context) { | 名称 | 值 | 说明 | | ----- | ---- | ---- | -| COLOR_STYLE_PHOTO18+ | 12 | 推荐风格 **系统接口**:此接口为系统接口。| \ No newline at end of file +| COLOR_STYLE_PHOTO18+ | 12 | 推荐风格 **系统接口**:此接口为系统接口。| + +## PhotoAssetCustomRecord20+ + +媒体库支持图库自定义用户统计行为。 + +**系统接口**:此接口为系统接口。 + +**系统能力**:SystemCapability.FileManagement.PhotoAccessHelper.Core + +| 名称 | 类型 | 只读 | 可选 | 说明 | +| --- | --- | --- | --- | --- | +| fileId | number | 是 | 否 | 图片id,必须为大于0的整数。 | +| shareCount | number | 是 | 否 | 图片和视频被分享的次数,必须为大于0的整数。 | +| lcdJumpCount | number | 是 | 否 | 大图跳转分享等次数,必须为大于0的整数。 | \ No newline at end of file