generated from bcgov/quickstart-openshift
-
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.
feat: CE-1035 update lead agency list in CEEB decision (#89)
- Loading branch information
1 parent
849f152
commit eba65a9
Showing
13 changed files
with
426 additions
and
34 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
type AgencyCode { | ||
agencyCode: String | ||
shortDescription: String | ||
longDescription: String | ||
displayOrder: Int | ||
activeIndicator: Boolean | ||
} | ||
|
||
type Query { | ||
agencyCodes: [AgencyCode]! | ||
} |
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,10 @@ | ||
import { Module } from "@nestjs/common"; | ||
import { AgencyCodeService } from "./agency_code.service"; | ||
import { AgencyCodeResolver } from "./agency_code.resolver"; | ||
import { PrismaModule } from "nestjs-prisma"; | ||
|
||
@Module({ | ||
imports: [PrismaModule], | ||
providers: [AgencyCodeResolver, AgencyCodeService], | ||
}) | ||
export class AgencyCodeModule {} |
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,21 @@ | ||
import { Test, TestingModule } from "@nestjs/testing"; | ||
import { AgencyCodeResolver } from "./agency_code.resolver"; | ||
import { AgencyCodeService } from "./agency_code.service"; | ||
import { PrismaModule } from "nestjs-prisma"; | ||
|
||
describe("AgencyCodeResolver", () => { | ||
let resolver: AgencyCodeResolver; | ||
|
||
beforeEach(async () => { | ||
const module: TestingModule = await Test.createTestingModule({ | ||
imports: [PrismaModule], | ||
providers: [AgencyCodeResolver, AgencyCodeService], | ||
}).compile(); | ||
|
||
resolver = module.get<AgencyCodeResolver>(AgencyCodeResolver); | ||
}); | ||
|
||
it("should be defined", () => { | ||
expect(resolver).toBeDefined(); | ||
}); | ||
}); |
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,18 @@ | ||
import { Resolver, Query, Args } from "@nestjs/graphql"; | ||
import { AgencyCodeService } from "./agency_code.service"; | ||
import { JwtRoleGuard } from "../auth/jwtrole.guard"; | ||
import { UseGuards } from "@nestjs/common"; | ||
import { Role } from "../enum/role.enum"; | ||
import { Roles } from "../auth/decorators/roles.decorator"; | ||
|
||
@UseGuards(JwtRoleGuard) | ||
@Resolver("AgencyCode") | ||
export class AgencyCodeResolver { | ||
constructor(private readonly agencyCodeService: AgencyCodeService) {} | ||
|
||
@Query("agencyCodes") | ||
@Roles(Role.COS_OFFICER, Role.CEEB) | ||
findAll() { | ||
return this.agencyCodeService.findAll(); | ||
} | ||
} |
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,20 @@ | ||
import { Test, TestingModule } from "@nestjs/testing"; | ||
import { AgencyCodeService } from "./agency_code.service"; | ||
import { PrismaModule } from "nestjs-prisma"; | ||
|
||
describe("AgencyCodeService", () => { | ||
let service: AgencyCodeService; | ||
|
||
beforeEach(async () => { | ||
const module: TestingModule = await Test.createTestingModule({ | ||
imports: [PrismaModule], | ||
providers: [AgencyCodeService], | ||
}).compile(); | ||
|
||
service = module.get<AgencyCodeService>(AgencyCodeService); | ||
}); | ||
|
||
it("should be defined", () => { | ||
expect(service).toBeDefined(); | ||
}); | ||
}); |
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,40 @@ | ||
import { Injectable } from "@nestjs/common"; | ||
import { PrismaService } from "nestjs-prisma"; | ||
import { AgencyCode } from "./entities/agency_code.entity"; | ||
|
||
@Injectable() | ||
export class AgencyCodeService { | ||
constructor(private prisma: PrismaService) {} | ||
|
||
async findAll() { | ||
const prismaAgencyCodes = await this.prisma.agency_code.findMany({ | ||
select: { | ||
agency_code: true, | ||
short_description: true, | ||
long_description: true, | ||
display_order: true, | ||
active_ind: true, | ||
}, | ||
orderBy: [{ display_order: "asc" }], | ||
}); | ||
|
||
const agencyCodes: AgencyCode[] = prismaAgencyCodes.map((prismaAgencyCodes) => ({ | ||
agencyCode: prismaAgencyCodes.agency_code, | ||
shortDescription: prismaAgencyCodes.short_description, | ||
longDescription: prismaAgencyCodes.long_description, | ||
displayOrder: prismaAgencyCodes.display_order, | ||
activeIndicator: prismaAgencyCodes.active_ind, | ||
})); | ||
|
||
return agencyCodes; | ||
} | ||
|
||
findOne(id: string) { | ||
return this.prisma.agency_code.findUnique({ | ||
where: { | ||
agency_code: id, | ||
active_ind: true, | ||
}, | ||
}); | ||
} | ||
} |
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,7 @@ | ||
export class AgencyCode { | ||
agencyCode: string; | ||
shortDescription: string; | ||
longDescription: string; | ||
displayOrder: number; | ||
activeIndicator: boolean; | ||
} |
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
Oops, something went wrong.