SudoSOS Back-end API / banners / BannerService
Class: BannerService ​
Service class for the banner entity,
Constructors ​
Constructor ​
ts
new BannerService(): BannerService;Returns ​
BannerService
Methods ​
asBanner() ​
ts
static asBanner(bannerReq): Banner;Creates a banner from a banner request
Parameters ​
| Parameter | Type | Description |
|---|---|---|
bannerReq | BannerRequest | banner request |
Returns ​
- a banner entity created with the banner request
asBannerResponse() ​
ts
static asBannerResponse(banner): BannerResponse;Creates a banner response from a banner
Parameters ​
| Parameter | Type | Description |
|---|---|---|
banner | Banner | banner |
Returns ​
- a banner response created with the banner
createBanner() ​
ts
static createBanner(bannerReq): Promise<Banner>;Saves a banner to the database.
Parameters ​
| Parameter | Type | Description |
|---|---|---|
bannerReq | BannerRequest | - |
Returns ​
Promise<Banner>
- saved banner
deleteBanner() ​
ts
static deleteBanner(id, fileService): Promise<Banner>;Deletes the requested banner from the database
Parameters ​
| Parameter | Type | Description |
|---|---|---|
id | number | requested banner id |
fileService | FileService | - |
Returns ​
Promise<Banner>
- deleted banner
getBanners() ​
ts
static getBanners(filters, pagination?): Promise<[Banner[], number]>;Returns all banners with options.
Parameters ​
| Parameter | Type | Description |
|---|---|---|
filters | BannerFilterParameters | The filtering parameters. |
pagination | PaginationParameters | The pagination options. |
Returns ​
Promise<[Banner[], number]>
- tuple of banners and total count
updateBanner() ​
ts
static updateBanner(id, bannerReq): Promise<Banner>;Updates and returns banner with given id.
Parameters ​
| Parameter | Type | Description |
|---|---|---|
id | number | requested banner id |
bannerReq | BannerRequest | - |
Returns ​
Promise<Banner>
- updated banner