2026-03-07 11:25:11 +03:30
|
|
|
import translates from '@/common/constants/translates/translates'
|
2026-04-30 16:27:46 +03:30
|
|
|
import { translateEnumValue } from '@/common/utils/enum-translator.util'
|
2026-03-07 11:25:11 +03:30
|
|
|
import {
|
|
|
|
|
AccountRole,
|
|
|
|
|
AccountStatus,
|
2026-05-01 19:43:59 +03:30
|
|
|
AccountType,
|
2026-04-30 16:27:46 +03:30
|
|
|
ApplicationPlatform,
|
|
|
|
|
ApplicationPublisher,
|
|
|
|
|
ApplicationReleaseType,
|
2026-03-07 11:25:11 +03:30
|
|
|
BusinessRole,
|
2026-05-01 19:43:59 +03:30
|
|
|
ComplexRole,
|
2026-04-11 14:47:05 +03:30
|
|
|
ConsumerRole,
|
2026-04-30 16:27:46 +03:30
|
|
|
ConsumerStatus,
|
|
|
|
|
ConsumerType,
|
|
|
|
|
CustomerType,
|
2026-03-07 11:25:11 +03:30
|
|
|
GoodPricingModel,
|
|
|
|
|
LicenseStatus,
|
|
|
|
|
LicenseType,
|
|
|
|
|
PartnerRole,
|
2026-04-30 16:27:46 +03:30
|
|
|
PartnerStatus,
|
|
|
|
|
PaymentMethodType,
|
2026-03-07 11:25:11 +03:30
|
|
|
POSRole,
|
|
|
|
|
POSStatus,
|
|
|
|
|
POSType,
|
|
|
|
|
ProviderRole,
|
2026-04-30 16:27:46 +03:30
|
|
|
ProviderStatus,
|
2026-05-01 19:43:59 +03:30
|
|
|
SKUGuildType,
|
|
|
|
|
TokenType,
|
2026-05-03 16:23:17 +03:30
|
|
|
TspProviderCustomerType,
|
|
|
|
|
TspProviderRequestType,
|
|
|
|
|
TspProviderResponseStatus,
|
|
|
|
|
TspProviderType,
|
2026-03-07 11:25:11 +03:30
|
|
|
UnitType,
|
|
|
|
|
UserStatus,
|
|
|
|
|
UserType,
|
|
|
|
|
} from '@/generated/prisma/enums'
|
2026-02-16 20:51:34 +03:30
|
|
|
import { Injectable } from '@nestjs/common'
|
2026-05-01 19:43:59 +03:30
|
|
|
import { GoldKarat } from 'common/enums/enums'
|
2026-03-07 11:25:11 +03:30
|
|
|
import { ResponseMapper } from 'common/response/response-mapper'
|
2026-02-16 20:51:34 +03:30
|
|
|
|
|
|
|
|
@Injectable()
|
|
|
|
|
export class EnumsService {
|
2026-04-30 16:27:46 +03:30
|
|
|
private prepareData(
|
|
|
|
|
items: Record<string, string>,
|
|
|
|
|
enumName: keyof typeof translates.enums,
|
|
|
|
|
) {
|
|
|
|
|
return Object.values(items).map(item => {
|
|
|
|
|
const translated = translateEnumValue(enumName, item)
|
|
|
|
|
return {
|
|
|
|
|
name: translated.translate || item,
|
|
|
|
|
value: translated.value,
|
|
|
|
|
}
|
|
|
|
|
})
|
2026-03-07 11:25:11 +03:30
|
|
|
}
|
|
|
|
|
|
2026-02-16 20:51:34 +03:30
|
|
|
getAllEnums() {
|
|
|
|
|
return {
|
2026-04-30 16:27:46 +03:30
|
|
|
PaymentMethodType: this.prepareData(PaymentMethodType, 'PaymentMethodType'),
|
|
|
|
|
GoldKarat: this.prepareData(GoldKarat, 'GoldKarat'),
|
|
|
|
|
UserStatus: this.prepareData(UserStatus, 'UserStatus'),
|
|
|
|
|
AccountRole: this.prepareData(AccountRole, 'AccountRole'),
|
|
|
|
|
AccountStatus: this.prepareData(AccountStatus, 'AccountStatus'),
|
|
|
|
|
POSStatus: this.prepareData(POSStatus, 'POSStatus'),
|
|
|
|
|
POSRole: this.prepareData(POSRole, 'POSRole'),
|
|
|
|
|
LicenseType: this.prepareData(LicenseType, 'LicenseType'),
|
|
|
|
|
LicenseStatus: this.prepareData(LicenseStatus, 'LicenseStatus'),
|
|
|
|
|
POSType: this.prepareData(POSType, 'POSType'),
|
|
|
|
|
UserType: this.prepareData(UserType, 'UserType'),
|
|
|
|
|
AccountType: this.prepareData(AccountType, 'AccountType'),
|
|
|
|
|
PartnerRole: this.prepareData(PartnerRole, 'PartnerRole'),
|
|
|
|
|
BusinessRole: this.prepareData(BusinessRole, 'BusinessRole'),
|
2026-05-01 19:43:59 +03:30
|
|
|
ComplexRole: this.prepareData(ComplexRole, 'ComplexRole'),
|
2026-04-30 16:27:46 +03:30
|
|
|
ProviderRole: this.prepareData(ProviderRole, 'ProviderRole'),
|
|
|
|
|
ProviderStatus: this.prepareData(ProviderStatus, 'ProviderStatus'),
|
|
|
|
|
TokenType: this.prepareData(TokenType, 'TokenType'),
|
|
|
|
|
UnitType: this.prepareData(UnitType, 'UnitType'),
|
|
|
|
|
GoodPricingModel: this.prepareData(GoodPricingModel, 'GoodPricingModel'),
|
|
|
|
|
ConsumerRole: this.prepareData(ConsumerRole, 'ConsumerRole'),
|
|
|
|
|
ConsumerStatus: this.prepareData(ConsumerStatus, 'ConsumerStatus'),
|
|
|
|
|
ConsumerType: this.prepareData(ConsumerType, 'ConsumerType'),
|
|
|
|
|
PartnerStatus: this.prepareData(PartnerStatus, 'PartnerStatus'),
|
2026-05-03 16:23:17 +03:30
|
|
|
TspProviderType: this.prepareData(TspProviderType, 'TspProviderType'),
|
2026-04-30 16:27:46 +03:30
|
|
|
ApplicationPlatform: this.prepareData(ApplicationPlatform, 'ApplicationPlatform'),
|
|
|
|
|
ApplicationReleaseType: this.prepareData(
|
|
|
|
|
ApplicationReleaseType,
|
|
|
|
|
'ApplicationReleaseType',
|
|
|
|
|
),
|
|
|
|
|
ApplicationPublisher: this.prepareData(
|
|
|
|
|
ApplicationPublisher,
|
|
|
|
|
'ApplicationPublisher',
|
|
|
|
|
),
|
|
|
|
|
CustomerType: this.prepareData(CustomerType, 'CustomerType'),
|
2026-05-03 16:23:17 +03:30
|
|
|
TspProviderResponseStatus: this.prepareData(
|
|
|
|
|
TspProviderResponseStatus,
|
|
|
|
|
'TspProviderResponseStatus',
|
|
|
|
|
),
|
|
|
|
|
TspProviderRequestType: this.prepareData(
|
|
|
|
|
TspProviderRequestType,
|
|
|
|
|
'TspProviderRequestType',
|
2026-04-30 16:27:46 +03:30
|
|
|
),
|
2026-05-03 16:23:17 +03:30
|
|
|
TspProviderCustomerType: this.prepareData(
|
|
|
|
|
TspProviderCustomerType,
|
|
|
|
|
'TspProviderCustomerType',
|
2026-05-01 19:43:59 +03:30
|
|
|
),
|
|
|
|
|
SKUGuildType: this.prepareData(SKUGuildType, 'SKUGuildType'),
|
2026-02-16 20:51:34 +03:30
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getEnumValues(enumName: string) {
|
|
|
|
|
const enums = this.getAllEnums()
|
|
|
|
|
return ResponseMapper.list(enums[enumName] || [])
|
|
|
|
|
}
|
|
|
|
|
}
|