Skip to content

E-commerce API Services - Auto-generated Documentation v0.0.0


E-commerce API Services - Auto-generated Documentation / NotificationApiService / NotificationTemplateApiService

Class: NotificationTemplateApiService

Defined in: NotificationApiService.ts:918

通知模板 API 服務類別

Extends

  • BaseApiService<NotificationTemplate, DbNotificationTemplate>

Constructors

Constructor

new NotificationTemplateApiService(supabase): NotificationTemplateApiService

Defined in: NotificationApiService.ts:922

Parameters

supabase

SupabaseClient

Returns

NotificationTemplateApiService

Overrides

BaseApiService< NotificationTemplate, DbNotificationTemplate >.constructor

Properties

supabase

protected supabase: SupabaseClient

Defined in: base/BaseApiService.ts:11

Inherited from

BaseApiService.supabase


tableName

protected tableName: string

Defined in: base/BaseApiService.ts:12

Inherited from

BaseApiService.tableName


viewName?

protected optional viewName: string

Defined in: base/BaseApiService.ts:13

Inherited from

BaseApiService.viewName


CATEGORY_DISPLAY_NAMES

readonly static CATEGORY_DISPLAY_NAMES: Record<NotificationCategory, string>

Defined in: NotificationApiService.ts:1385

分類顯示名稱映射

Methods

applySearch()

protected applySearch(query, _search): any

Defined in: base/BaseApiService.ts:192

應用搜尋條件(子類別可覆寫)

Parameters

query

any

string

Returns

any

Inherited from

BaseApiService.applySearch


batchUpdateTemplateStatus()

batchUpdateTemplateStatus(updates): Promise<ApiResponse<{ affectedCount: number; }>>

Defined in: NotificationApiService.ts:1074

批量更新模板狀態

Parameters

updates

object[]

Returns

Promise<ApiResponse<{ affectedCount: number; }>>


create()

create(entity): Promise<ApiResponse<NotificationTemplate<string>>>

Defined in: base/BaseApiService.ts:107

建立新資料

Parameters

entity

Partial<TEntity>

Returns

Promise<ApiResponse<NotificationTemplate<string>>>

Inherited from

BaseApiService.create


createTemplate()

createTemplate(templateData): Promise<ApiResponse<NotificationTemplate<string>>>

Defined in: NotificationApiService.ts:1227

新增通知模板

Parameters

templateData

NotificationTemplateForm

Returns

Promise<ApiResponse<NotificationTemplate<string>>>


delete()

delete(id): Promise<ApiResponse<boolean>>

Defined in: base/BaseApiService.ts:161

刪除資料

Parameters

id

string

Returns

Promise<ApiResponse<boolean>>

Inherited from

BaseApiService.delete


findById()

findById(id): Promise<ApiResponse<NotificationTemplate<string>>>

Defined in: base/BaseApiService.ts:82

根據 ID 查詢單筆資料

Parameters

id

string

Returns

Promise<ApiResponse<NotificationTemplate<string>>>

Inherited from

BaseApiService.findById


findMany()

findMany(options): Promise<ApiResponse<NotificationTemplate<string>[]>>

Defined in: base/BaseApiService.ts:24

查詢多筆資料

Parameters

options

QueryOptions = {}

Returns

Promise<ApiResponse<NotificationTemplate<string>[]>>

Inherited from

BaseApiService.findMany


getActiveTemplates()

getActiveTemplates(): Promise<ApiResponse<NotificationTemplate<string>[]>>

Defined in: NotificationApiService.ts:929

獲取活躍的通知模板

Returns

Promise<ApiResponse<NotificationTemplate<string>[]>>


getActiveTemplatesByCategory()

getActiveTemplatesByCategory(): Promise<ApiResponse<{ byCategory: Record<NotificationCategory, NotificationTemplate[]>; byType: Record<NotificationType, NotificationTemplate>; typeOptions: object[]; }>>

Defined in: NotificationApiService.ts:1106

按分類獲取活躍模板

Returns

Promise<ApiResponse<{ byCategory: Record<NotificationCategory, NotificationTemplate[]>; byType: Record<NotificationType, NotificationTemplate>; typeOptions: object[]; }>>


getAllTemplatesForAdmin()

getAllTemplatesForAdmin(): Promise<ApiPaginationResponse<NotificationTemplate<string>>>

Defined in: NotificationApiService.ts:1010

獲取所有模板(管理員使用,不過濾 is_active)

Returns

Promise<ApiPaginationResponse<NotificationTemplate<string>>>


getQueryBuilder()

protected getQueryBuilder(): QueryBuilder<DbNotificationTemplate<string>>

Defined in: base/BaseApiService.ts:184

獲取查詢建構器

Returns

QueryBuilder<DbNotificationTemplate<string>>

Inherited from

BaseApiService.getQueryBuilder


getTemplateByType()

getTemplateByType(type): Promise<ApiResponse<NotificationTemplate<string>>>

Defined in: NotificationApiService.ts:939

根據類型獲取模板

Parameters

type

NotificationType

Returns

Promise<ApiResponse<NotificationTemplate<string>>>


handleError()

protected handleError(error): ApiResponse<any>

Defined in: base/BaseApiService.ts:200

統一的錯誤處理

Parameters

error

any

Returns

ApiResponse<any>

Inherited from

BaseApiService.handleError


mapDbToEntity()

protected mapDbToEntity(dbEntity): NotificationTemplate

Defined in: NotificationApiService.ts:963

將資料庫實體轉換為前端實體 子類別必須實作此方法

Parameters

dbEntity

DbNotificationTemplate

Returns

NotificationTemplate

Overrides

BaseApiService.mapDbToEntity


mapEntityToDb()

protected mapEntityToDb(entity): Partial<DbNotificationTemplate>

Defined in: NotificationApiService.ts:986

將前端實體轉換為資料庫實體 子類別可覆寫此方法

Parameters

entity

Partial<NotificationTemplate>

Returns

Partial<DbNotificationTemplate>

Overrides

BaseApiService.mapEntityToDb


update()

update(id, updates): Promise<ApiResponse<NotificationTemplate<string>>>

Defined in: base/BaseApiService.ts:132

更新資料

Parameters

id

string

updates

Partial<TEntity>

Returns

Promise<ApiResponse<NotificationTemplate<string>>>

Inherited from

BaseApiService.update


updateTemplate()

updateTemplate(id, templateData): Promise<ApiResponse<NotificationTemplate<string>>>

Defined in: NotificationApiService.ts:1298

更新通知模板

Parameters

id

string

templateData

Partial<NotificationTemplateForm>

Returns

Promise<ApiResponse<NotificationTemplate<string>>>


updateTemplateStatus()

updateTemplateStatus(templateId, isActive): Promise<ApiResponse<NotificationTemplate<string>>>

Defined in: NotificationApiService.ts:1043

更新模板啟用狀態

Parameters

templateId

string

isActive

boolean

Returns

Promise<ApiResponse<NotificationTemplate<string>>>


validateNotificationType()

validateNotificationType(type): Promise<ApiResponse<{ errorMessage?: string; isValid: boolean; template?: NotificationTemplate<string>; }>>

Defined in: NotificationApiService.ts:1182

驗證通知類型是否有可用模板

Parameters

type

NotificationType

Returns

Promise<ApiResponse<{ errorMessage?: string; isValid: boolean; template?: NotificationTemplate<string>; }>>


getCategoryDisplayName()

static getCategoryDisplayName(category): string

Defined in: NotificationApiService.ts:1217

獲取分類的顯示名稱

Parameters

category

NotificationCategory

Returns

string