Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat:ORV2-3129 - Feature flag in BE to prevent creation of applications of certain permit types #1675

Merged
merged 3 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,99 @@ VALUES
GETUTCDATE()
);

INSERT INTO
[dbo].[ORBC_FEATURE_FLAG] (
[FEATURE_ID],
[FEATURE_KEY],
[FEATURE_VALUE],
[CONCURRENCY_CONTROL_NUMBER],
[DB_CREATE_USERID],
[DB_CREATE_TIMESTAMP],
[DB_LAST_UPDATE_USERID],
[DB_LAST_UPDATE_TIMESTAMP]
)
VALUES
(
'6',
'TROS',
'ENABLED',
NULL,
N'dbo',
GETUTCDATE(),
N'dbo',
GETUTCDATE()
);

INSERT INTO
[dbo].[ORBC_FEATURE_FLAG] (
[FEATURE_ID],
[FEATURE_KEY],
[FEATURE_VALUE],
[CONCURRENCY_CONTROL_NUMBER],
[DB_CREATE_USERID],
[DB_CREATE_TIMESTAMP],
[DB_LAST_UPDATE_USERID],
[DB_LAST_UPDATE_TIMESTAMP]
)
VALUES
(
'7',
'TROW',
'ENABLED',
NULL,
N'dbo',
GETUTCDATE(),
N'dbo',
GETUTCDATE()
);

INSERT INTO
[dbo].[ORBC_FEATURE_FLAG] (
[FEATURE_ID],
[FEATURE_KEY],
[FEATURE_VALUE],
[CONCURRENCY_CONTROL_NUMBER],
[DB_CREATE_USERID],
[DB_CREATE_TIMESTAMP],
[DB_LAST_UPDATE_USERID],
[DB_LAST_UPDATE_TIMESTAMP]
)
VALUES
(
'8',
'STOS',
'ENABLED',
NULL,
N'dbo',
GETUTCDATE(),
N'dbo',
GETUTCDATE()
);


INSERT INTO
[dbo].[ORBC_FEATURE_FLAG] (
[FEATURE_ID],
[FEATURE_KEY],
[FEATURE_VALUE],
[CONCURRENCY_CONTROL_NUMBER],
[DB_CREATE_USERID],
[DB_CREATE_TIMESTAMP],
[DB_LAST_UPDATE_USERID],
[DB_LAST_UPDATE_TIMESTAMP]
)
VALUES
(
'9',
'MFP',
'ENABLED',
NULL,
N'dbo',
GETUTCDATE(),
N'dbo',
GETUTCDATE()
);

SET
IDENTITY_INSERT [dbo].[ORBC_FEATURE_FLAG] OFF
GO
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ import { ReadPermitLoaDto } from './dto/response/read-permit-loa.dto';
import { CreatePermitLoaDto } from './dto/request/create-permit-loa.dto';
import { PermitLoa } from './entities/permit-loa.entity';
import { LoaDetail } from 'src/modules/special-auth/entities/loa-detail.entity';
import { getFromCache } from '../../../common/helper/cache.helper';
import { CacheKey } from '../../../common/enum/cache-key.enum';
import { FeatureFlagValue } from '../../../common/enum/feature-flag-value.enum';

@Injectable()
export class ApplicationService {
Expand Down Expand Up @@ -123,6 +126,16 @@ export class ApplicationService {
currentUser: IUserJWT,
companyId: number,
): Promise<ReadApplicationDto> {
const permitTypeFeatureFlag = (await getFromCache(
this.cacheManager,
CacheKey.FEATURE_FLAG_TYPE,
createApplicationDto.permitType,
)) as FeatureFlagValue;
if (permitTypeFeatureFlag !== FeatureFlagValue.ENABLED) {
throwUnprocessableEntityException(
`Feature Disabled - ${createApplicationDto.permitType}`,
);
}
const id = createApplicationDto.permitId;
let fetchExistingApplication: Permit;
//If permit id exists assign it to null to create new application.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
ApiOperation,
ApiQuery,
ApiTags,
ApiUnprocessableEntityResponse,
} from '@nestjs/swagger';
import { IUserJWT } from 'src/common/interface/user-jwt.interface';
import { CreateApplicationDto } from './dto/request/create-application.dto';
Expand Down Expand Up @@ -142,6 +143,10 @@ export class CompanyApplicationController {
description: 'The Permit Application Resource',
type: ReadApplicationDto,
})
@ApiUnprocessableEntityResponse({
description: 'The Application could not be processed.',
type: ExceptionDto,
})
@Permissions({
allowedBCeIDRoles: CLIENT_USER_ROLE_LIST,
allowedIdirRoles: [
Expand Down
Loading