feat: add subscription_rewards relation to customer and subscription history schemas, and update TypeScript definitions
- Introduced a new 'subscription_rewards' relation in both the customer and subscription history schemas to link them with subscription rewards. - Updated the 'expiresAt' field in the subscription schema to be required, ensuring better data integrity. - Adjusted the default value for 'maxOrdersPerMonth' in the subscription setting schema from 30 to 20, and removed unused fields to streamline the model. - Updated TypeScript definitions to reflect these changes, ensuring type safety and consistency across the application.
This commit is contained in:
parent
7436ad181b
commit
eb5bf5eee6
@ -87,6 +87,12 @@
|
||||
},
|
||||
"bannedUntil": {
|
||||
"type": "datetime"
|
||||
},
|
||||
"subscription_rewards": {
|
||||
"type": "relation",
|
||||
"relation": "oneToMany",
|
||||
"target": "api::subscription-reward.subscription-reward",
|
||||
"mappedBy": "owner"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -66,11 +66,18 @@
|
||||
"payment",
|
||||
"referral",
|
||||
"admin",
|
||||
"promo"
|
||||
"promo",
|
||||
"reward"
|
||||
]
|
||||
},
|
||||
"description": {
|
||||
"type": "text"
|
||||
},
|
||||
"subscription_rewards": {
|
||||
"type": "relation",
|
||||
"relation": "oneToMany",
|
||||
"target": "api::subscription-reward.subscription-reward",
|
||||
"mappedBy": "subscription_history"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,47 @@
|
||||
{
|
||||
"kind": "collectionType",
|
||||
"collectionName": "subscription_rewards",
|
||||
"info": {
|
||||
"singularName": "subscription-reward",
|
||||
"pluralName": "subscription-rewards",
|
||||
"displayName": "SubscriptionReward"
|
||||
},
|
||||
"options": {
|
||||
"draftAndPublish": true
|
||||
},
|
||||
"pluginOptions": {},
|
||||
"attributes": {
|
||||
"activated": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"owner": {
|
||||
"type": "relation",
|
||||
"relation": "manyToOne",
|
||||
"target": "api::customer.customer",
|
||||
"inversedBy": "subscription_rewards"
|
||||
},
|
||||
"invited": {
|
||||
"type": "relation",
|
||||
"relation": "oneToOne",
|
||||
"target": "api::customer.customer"
|
||||
},
|
||||
"days": {
|
||||
"type": "integer",
|
||||
"required": true
|
||||
},
|
||||
"expiresAt": {
|
||||
"type": "datetime",
|
||||
"required": true
|
||||
},
|
||||
"description": {
|
||||
"type": "text"
|
||||
},
|
||||
"subscription_history": {
|
||||
"type": "relation",
|
||||
"relation": "manyToOne",
|
||||
"target": "api::subscription-history.subscription-history",
|
||||
"inversedBy": "subscription_rewards"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
/**
|
||||
* subscription-reward controller
|
||||
*/
|
||||
|
||||
import { factories } from '@strapi/strapi'
|
||||
|
||||
export default factories.createCoreController('api::subscription-reward.subscription-reward');
|
||||
@ -0,0 +1,7 @@
|
||||
/**
|
||||
* subscription-reward router
|
||||
*/
|
||||
|
||||
import { factories } from '@strapi/strapi';
|
||||
|
||||
export default factories.createCoreRouter('api::subscription-reward.subscription-reward');
|
||||
@ -0,0 +1,7 @@
|
||||
/**
|
||||
* subscription-reward service
|
||||
*/
|
||||
|
||||
import { factories } from '@strapi/strapi';
|
||||
|
||||
export default factories.createCoreService('api::subscription-reward.subscription-reward');
|
||||
@ -14,14 +14,9 @@
|
||||
"maxOrdersPerMonth": {
|
||||
"type": "integer",
|
||||
"required": true,
|
||||
"default": 30
|
||||
"default": 20
|
||||
},
|
||||
"referralRewardDays": {
|
||||
"type": "integer",
|
||||
"required": true,
|
||||
"default": 3
|
||||
},
|
||||
"referralBonusDays": {
|
||||
"type": "integer",
|
||||
"required": true,
|
||||
"default": 1
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
},
|
||||
"expiresAt": {
|
||||
"type": "datetime",
|
||||
"required": false
|
||||
"required": true
|
||||
},
|
||||
"autoRenew": {
|
||||
"type": "boolean",
|
||||
|
||||
58
types/generated/contentTypes.d.ts
vendored
58
types/generated/contentTypes.d.ts
vendored
@ -461,6 +461,10 @@ export interface ApiCustomerCustomer extends Struct.CollectionTypeSchema {
|
||||
'oneToOne',
|
||||
'api::subscription.subscription'
|
||||
>;
|
||||
subscription_rewards: Schema.Attribute.Relation<
|
||||
'oneToMany',
|
||||
'api::subscription-reward.subscription-reward'
|
||||
>;
|
||||
telegramId: Schema.Attribute.BigInteger & Schema.Attribute.Unique;
|
||||
updatedAt: Schema.Attribute.DateTime;
|
||||
updatedBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> &
|
||||
@ -650,7 +654,7 @@ export interface ApiSubscriptionHistorySubscriptionHistory
|
||||
Schema.Attribute.Required;
|
||||
publishedAt: Schema.Attribute.DateTime;
|
||||
source: Schema.Attribute.Enumeration<
|
||||
['payment', 'referral', 'admin', 'promo']
|
||||
['payment', 'referral', 'admin', 'promo', 'reward']
|
||||
> &
|
||||
Schema.Attribute.Required &
|
||||
Schema.Attribute.DefaultTo<'payment'>;
|
||||
@ -661,6 +665,10 @@ export interface ApiSubscriptionHistorySubscriptionHistory
|
||||
'manyToOne',
|
||||
'api::subscription.subscription'
|
||||
>;
|
||||
subscription_rewards: Schema.Attribute.Relation<
|
||||
'oneToMany',
|
||||
'api::subscription-reward.subscription-reward'
|
||||
>;
|
||||
updatedAt: Schema.Attribute.DateTime;
|
||||
updatedBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> &
|
||||
Schema.Attribute.Private;
|
||||
@ -704,6 +712,44 @@ export interface ApiSubscriptionPriceSubscriptionPrice
|
||||
};
|
||||
}
|
||||
|
||||
export interface ApiSubscriptionRewardSubscriptionReward
|
||||
extends Struct.CollectionTypeSchema {
|
||||
collectionName: 'subscription_rewards';
|
||||
info: {
|
||||
displayName: 'SubscriptionReward';
|
||||
pluralName: 'subscription-rewards';
|
||||
singularName: 'subscription-reward';
|
||||
};
|
||||
options: {
|
||||
draftAndPublish: true;
|
||||
};
|
||||
attributes: {
|
||||
activated: Schema.Attribute.Boolean & Schema.Attribute.DefaultTo<false>;
|
||||
createdAt: Schema.Attribute.DateTime;
|
||||
createdBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> &
|
||||
Schema.Attribute.Private;
|
||||
days: Schema.Attribute.Integer & Schema.Attribute.Required;
|
||||
description: Schema.Attribute.Text;
|
||||
expiresAt: Schema.Attribute.DateTime & Schema.Attribute.Required;
|
||||
invited: Schema.Attribute.Relation<'oneToOne', 'api::customer.customer'>;
|
||||
locale: Schema.Attribute.String & Schema.Attribute.Private;
|
||||
localizations: Schema.Attribute.Relation<
|
||||
'oneToMany',
|
||||
'api::subscription-reward.subscription-reward'
|
||||
> &
|
||||
Schema.Attribute.Private;
|
||||
owner: Schema.Attribute.Relation<'manyToOne', 'api::customer.customer'>;
|
||||
publishedAt: Schema.Attribute.DateTime;
|
||||
subscription_history: Schema.Attribute.Relation<
|
||||
'manyToOne',
|
||||
'api::subscription-history.subscription-history'
|
||||
>;
|
||||
updatedAt: Schema.Attribute.DateTime;
|
||||
updatedBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> &
|
||||
Schema.Attribute.Private;
|
||||
};
|
||||
}
|
||||
|
||||
export interface ApiSubscriptionSettingSubscriptionSetting
|
||||
extends Struct.SingleTypeSchema {
|
||||
collectionName: 'subscription_settings';
|
||||
@ -727,14 +773,11 @@ export interface ApiSubscriptionSettingSubscriptionSetting
|
||||
Schema.Attribute.Private;
|
||||
maxOrdersPerMonth: Schema.Attribute.Integer &
|
||||
Schema.Attribute.Required &
|
||||
Schema.Attribute.DefaultTo<30>;
|
||||
Schema.Attribute.DefaultTo<20>;
|
||||
publishedAt: Schema.Attribute.DateTime;
|
||||
referralBonusDays: Schema.Attribute.Integer &
|
||||
Schema.Attribute.Required &
|
||||
Schema.Attribute.DefaultTo<1>;
|
||||
referralRewardDays: Schema.Attribute.Integer &
|
||||
Schema.Attribute.Required &
|
||||
Schema.Attribute.DefaultTo<3>;
|
||||
Schema.Attribute.DefaultTo<1>;
|
||||
updatedAt: Schema.Attribute.DateTime;
|
||||
updatedBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> &
|
||||
Schema.Attribute.Private;
|
||||
@ -760,7 +803,7 @@ export interface ApiSubscriptionSubscription
|
||||
createdBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> &
|
||||
Schema.Attribute.Private;
|
||||
customer: Schema.Attribute.Relation<'oneToOne', 'api::customer.customer'>;
|
||||
expiresAt: Schema.Attribute.DateTime;
|
||||
expiresAt: Schema.Attribute.DateTime & Schema.Attribute.Required;
|
||||
isActive: Schema.Attribute.Boolean &
|
||||
Schema.Attribute.Required &
|
||||
Schema.Attribute.DefaultTo<false>;
|
||||
@ -1298,6 +1341,7 @@ declare module '@strapi/strapi' {
|
||||
'api::slot.slot': ApiSlotSlot;
|
||||
'api::subscription-history.subscription-history': ApiSubscriptionHistorySubscriptionHistory;
|
||||
'api::subscription-price.subscription-price': ApiSubscriptionPriceSubscriptionPrice;
|
||||
'api::subscription-reward.subscription-reward': ApiSubscriptionRewardSubscriptionReward;
|
||||
'api::subscription-setting.subscription-setting': ApiSubscriptionSettingSubscriptionSetting;
|
||||
'api::subscription.subscription': ApiSubscriptionSubscription;
|
||||
'plugin::content-releases.release': PluginContentReleasesRelease;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user