-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
48 changed files
with
2,836 additions
and
5,974 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { MigrationInterface, QueryRunner } from "typeorm"; | ||
|
||
export class New1699180499824 implements MigrationInterface { | ||
name = 'New1699180499824' | ||
|
||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`ALTER TABLE "campaign_entity" RENAME COLUMN "campaign" TO "campaignName"`); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`ALTER TABLE "campaign_entity" RENAME COLUMN "campaignName" TO "campaign"`); | ||
} | ||
|
||
} |
14 changes: 8 additions & 6 deletions
14
src/db/migrations/1699105844419-new.ts → src/db/migrations/1699181005168-new.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,18 @@ | ||
import { MigrationInterface, QueryRunner } from "typeorm"; | ||
|
||
export class New1699105844419 implements MigrationInterface { | ||
name = 'New1699105844419' | ||
export class New1699181005168 implements MigrationInterface { | ||
name = 'New1699181005168' | ||
|
||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`ALTER TABLE "campaign_entity" ADD "campaignNumber" integer NOT NULL DEFAULT '0'`); | ||
await queryRunner.query(`ALTER TABLE "campaign_entity" ADD CONSTRAINT "UQ_77f8819f4ce0b24cffce96c2906" UNIQUE ("campaignNumber")`); | ||
await queryRunner.query(`ALTER TABLE "campaign_entity" DROP COLUMN "campaignName"`); | ||
await queryRunner.query(`ALTER TABLE "campaign_entity" ADD "campaignName" character varying NOT NULL`); | ||
await queryRunner.query(`ALTER TABLE "all_user_entity" ALTER COLUMN "monthlyEmail" SET DEFAULT true`); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`ALTER TABLE "campaign_entity" DROP CONSTRAINT "UQ_77f8819f4ce0b24cffce96c2906"`); | ||
await queryRunner.query(`ALTER TABLE "campaign_entity" DROP COLUMN "campaignNumber"`); | ||
await queryRunner.query(`ALTER TABLE "all_user_entity" ALTER COLUMN "monthlyEmail" SET DEFAULT false`); | ||
await queryRunner.query(`ALTER TABLE "campaign_entity" DROP COLUMN "campaignName"`); | ||
await queryRunner.query(`ALTER TABLE "campaign_entity" ADD "campaignName" integer NOT NULL`); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { MigrationInterface, QueryRunner } from "typeorm"; | ||
|
||
export class New1699181702531 implements MigrationInterface { | ||
name = 'New1699181702531' | ||
|
||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`ALTER TABLE "campaign_entity" RENAME COLUMN "campaignNumber" TO "campaignCode"`); | ||
await queryRunner.query(`ALTER TABLE "campaign_entity" RENAME CONSTRAINT "UQ_77f8819f4ce0b24cffce96c2906" TO "UQ_b9e68834e43af5477e94c2796ae"`); | ||
await queryRunner.query(`ALTER TABLE "campaign_entity" DROP CONSTRAINT "UQ_b9e68834e43af5477e94c2796ae"`); | ||
await queryRunner.query(`ALTER TABLE "campaign_entity" DROP COLUMN "campaignCode"`); | ||
await queryRunner.query(`ALTER TABLE "campaign_entity" ADD "campaignCode" character varying NOT NULL`); | ||
await queryRunner.query(`ALTER TABLE "campaign_entity" ADD CONSTRAINT "UQ_b9e68834e43af5477e94c2796ae" UNIQUE ("campaignCode")`); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`ALTER TABLE "campaign_entity" DROP CONSTRAINT "UQ_b9e68834e43af5477e94c2796ae"`); | ||
await queryRunner.query(`ALTER TABLE "campaign_entity" DROP COLUMN "campaignCode"`); | ||
await queryRunner.query(`ALTER TABLE "campaign_entity" ADD "campaignCode" integer NOT NULL`); | ||
await queryRunner.query(`ALTER TABLE "campaign_entity" ADD CONSTRAINT "UQ_b9e68834e43af5477e94c2796ae" UNIQUE ("campaignCode")`); | ||
await queryRunner.query(`ALTER TABLE "campaign_entity" RENAME CONSTRAINT "UQ_b9e68834e43af5477e94c2796ae" TO "UQ_77f8819f4ce0b24cffce96c2906"`); | ||
await queryRunner.query(`ALTER TABLE "campaign_entity" RENAME COLUMN "campaignCode" TO "campaignNumber"`); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { Controller, Get, Req, ForbiddenException } from '@nestjs/common'; | ||
import { ApiHeader, ApiSecurity, ApiTags } from '@nestjs/swagger'; | ||
import { FlaskUserTypesEnum } from 'src/types/interfaces/interface'; | ||
import { isAuthenticated } from 'src/utils/auth'; | ||
import { CampaignService } from './campaign.service'; | ||
|
||
@ApiTags('Campaign') | ||
@ApiSecurity('flask-access-token') | ||
@ApiHeader({ | ||
name: 'flaskId', | ||
description: 'to use cache and flask authentication', | ||
required: true, | ||
}) | ||
@Controller('campaign') | ||
export class CampaignController { | ||
constructor(private readonly campaignService: CampaignService) {} | ||
|
||
@Get('/all') | ||
getAvailableContributions(@Req() req: Request) { | ||
const panelFlaskUserId = req.headers['panelFlaskUserId']; | ||
const panelFlaskTypeId = req.headers['panelFlaskTypeId']; | ||
if ( | ||
!isAuthenticated(panelFlaskUserId, panelFlaskTypeId) || | ||
!( | ||
panelFlaskTypeId === FlaskUserTypesEnum.SUPER_ADMIN || | ||
panelFlaskTypeId === FlaskUserTypesEnum.ADMIN | ||
) | ||
) { | ||
throw new ForbiddenException(403, 'You Are not authorized'); | ||
} | ||
|
||
return this.campaignService.getCampaigns(); | ||
} | ||
} |
Oops, something went wrong.