fbe7230865
- Created migration to drop `type` column from `stock_keeping_units` table. - Added `Guild` model to Prisma schema. - Implemented `BusinessActivitiesQueryService` for querying business activities. - Developed `GoodsSharedService` for handling goods creation and updates. - Introduced DTOs for creating and updating stock keeping units. - Created controller and service for managing stock keeping units. - Implemented response DTOs for stock keeping units service. - Established module for stock keeping units management.
99 lines
3.4 KiB
TypeScript
99 lines
3.4 KiB
TypeScript
import translates from '@/common/constants/translates/translates'
|
|
import { translateEnumValue } from '@/common/utils/enum-translator.util'
|
|
import {
|
|
AccountStatus,
|
|
AccountType,
|
|
ApplicationPlatform,
|
|
ApplicationPublisher,
|
|
ApplicationReleaseType,
|
|
BusinessRole,
|
|
ComplexRole,
|
|
ConsumerRole,
|
|
ConsumerStatus,
|
|
ConsumerType,
|
|
CustomerType,
|
|
GoodPricingModel,
|
|
InvoiceTemplateType,
|
|
PartnerRole,
|
|
PartnerStatus,
|
|
PaymentMethodType,
|
|
POSRole,
|
|
POSStatus,
|
|
POSType,
|
|
ProviderRole,
|
|
SKUGuildType,
|
|
TspProviderRequestType,
|
|
TspProviderResponseStatus,
|
|
TspProviderType,
|
|
} from '@/generated/prisma/enums'
|
|
import { Injectable } from '@nestjs/common'
|
|
import { GoldKarat, TspProviderCustomerType } from 'common/enums/enums'
|
|
import { ResponseMapper } from 'common/response/response-mapper'
|
|
|
|
@Injectable()
|
|
export class EnumsService {
|
|
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,
|
|
}
|
|
})
|
|
}
|
|
|
|
getAllEnums() {
|
|
return {
|
|
PaymentMethodType: this.prepareData(PaymentMethodType, 'PaymentMethodType'),
|
|
GoldKarat: this.prepareData(GoldKarat, 'GoldKarat'),
|
|
AccountStatus: this.prepareData(AccountStatus, 'AccountStatus'),
|
|
POSStatus: this.prepareData(POSStatus, 'POSStatus'),
|
|
POSRole: this.prepareData(POSRole, 'POSRole'),
|
|
POSType: this.prepareData(POSType, 'POSType'),
|
|
AccountType: this.prepareData(AccountType, 'AccountType'),
|
|
PartnerRole: this.prepareData(PartnerRole, 'PartnerRole'),
|
|
BusinessRole: this.prepareData(BusinessRole, 'BusinessRole'),
|
|
ComplexRole: this.prepareData(ComplexRole, 'ComplexRole'),
|
|
ProviderRole: this.prepareData(ProviderRole, 'ProviderRole'),
|
|
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'),
|
|
TspProviderType: this.prepareData(TspProviderType, 'TspProviderType'),
|
|
ApplicationPlatform: this.prepareData(ApplicationPlatform, 'ApplicationPlatform'),
|
|
ApplicationReleaseType: this.prepareData(
|
|
ApplicationReleaseType,
|
|
'ApplicationReleaseType',
|
|
),
|
|
ApplicationPublisher: this.prepareData(
|
|
ApplicationPublisher,
|
|
'ApplicationPublisher',
|
|
),
|
|
CustomerType: this.prepareData(CustomerType, 'CustomerType'),
|
|
TspProviderResponseStatus: this.prepareData(
|
|
TspProviderResponseStatus,
|
|
'TspProviderResponseStatus',
|
|
),
|
|
TspProviderRequestType: this.prepareData(
|
|
TspProviderRequestType,
|
|
'TspProviderRequestType',
|
|
),
|
|
TspProviderCustomerType: this.prepareData(
|
|
TspProviderCustomerType,
|
|
'TspProviderCustomerType',
|
|
),
|
|
SKUGuildType: this.prepareData(SKUGuildType, 'SKUGuildType'),
|
|
InvoiceTemplateType: this.prepareData(InvoiceTemplateType, 'InvoiceTemplateType'),
|
|
}
|
|
}
|
|
|
|
getEnumValues(enumName: keyof typeof translates.enums) {
|
|
const enums = this.getAllEnums()
|
|
return ResponseMapper.list(enums[enumName] || [])
|
|
}
|
|
}
|