refacto GET methods with search param for office roles
This commit is contained in:
parent
3ca6a0565d
commit
b1396c713b
34
package-lock.json
generated
34
package-lock.json
generated
@ -17,7 +17,7 @@
|
|||||||
"cors": "^2.8.5",
|
"cors": "^2.8.5",
|
||||||
"express": "^4.18.2",
|
"express": "^4.18.2",
|
||||||
"jsonwebtoken": "^9.0.0",
|
"jsonwebtoken": "^9.0.0",
|
||||||
"le-coffre-resources": "git@github.com:smart-chain-fr/leCoffre-resources.git#v2.55",
|
"le-coffre-resources": "git@github.com:smart-chain-fr/leCoffre-resources.git#v2.56",
|
||||||
"module-alias": "^2.2.2",
|
"module-alias": "^2.2.2",
|
||||||
"multer": "^1.4.5-lts.1",
|
"multer": "^1.4.5-lts.1",
|
||||||
"next": "^13.1.5",
|
"next": "^13.1.5",
|
||||||
@ -1421,9 +1421,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@types/jest": {
|
"node_modules/@types/jest": {
|
||||||
"version": "29.5.2",
|
"version": "29.5.3",
|
||||||
"resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.5.2.tgz",
|
"resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.5.3.tgz",
|
||||||
"integrity": "sha512-mSoZVJF5YzGVCk+FsDxzDuH7s+SCkzrgKZzf0Z0T2WudhBUPoF6ktoTPC4R0ZoCPCV5xUvuU6ias5NvxcBcMMg==",
|
"integrity": "sha512-1Nq7YrO/vJE/FYnqYyw0FS8LdrjExSgIiHyKg7xPpn+yi8Q4huZryKnkJatN1ZRH89Kw2v33/8ZMB7DuZeSLlA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"expect": "^29.0.0",
|
"expect": "^29.0.0",
|
||||||
@ -2011,9 +2011,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/caniuse-lite": {
|
"node_modules/caniuse-lite": {
|
||||||
"version": "1.0.30001514",
|
"version": "1.0.30001515",
|
||||||
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001514.tgz",
|
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001515.tgz",
|
||||||
"integrity": "sha512-ENcIpYBmwAAOm/V2cXgM7rZUrKKaqisZl4ZAI520FIkqGXUxJjmaIssbRW5HVVR5tyV6ygTLIm15aU8LUmQSaQ==",
|
"integrity": "sha512-eEFDwUOZbE24sb+Ecsx3+OvNETqjWIdabMy52oOkIgcUtAsQifjUG9q4U9dgTHJM2mfk4uEPxc0+xuFdJ629QA==",
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"type": "opencollective",
|
"type": "opencollective",
|
||||||
@ -2421,9 +2421,9 @@
|
|||||||
"integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow=="
|
"integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow=="
|
||||||
},
|
},
|
||||||
"node_modules/electron-to-chromium": {
|
"node_modules/electron-to-chromium": {
|
||||||
"version": "1.4.454",
|
"version": "1.4.457",
|
||||||
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.454.tgz",
|
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.457.tgz",
|
||||||
"integrity": "sha512-pmf1rbAStw8UEQ0sr2cdJtWl48ZMuPD9Sto8HVQOq9vx9j2WgDEN6lYoaqFvqEHYOmGA9oRGn7LqWI9ta0YugQ==",
|
"integrity": "sha512-/g3UyNDmDd6ebeWapmAoiyy+Sy2HyJ+/X8KyvNeHfKRFfHaA2W8oF5fxD5F3tjBDcjpwo0iek6YNgxNXDBoEtA==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/emittery": {
|
"node_modules/emittery": {
|
||||||
@ -3926,7 +3926,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/le-coffre-resources": {
|
"node_modules/le-coffre-resources": {
|
||||||
"resolved": "git+ssh://git@github.com/smart-chain-fr/leCoffre-resources.git#10eab2b6bde5cd085509b8510808477caff37a1e",
|
"resolved": "git+ssh://git@github.com/smart-chain-fr/leCoffre-resources.git#7768906229ee080d84687a6bad832b8c04adb355",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"class-transformer": "^0.5.1",
|
"class-transformer": "^0.5.1",
|
||||||
@ -4497,9 +4497,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/nodemon/node_modules/semver": {
|
"node_modules/nodemon/node_modules/semver": {
|
||||||
"version": "5.7.1",
|
"version": "5.7.2",
|
||||||
"resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz",
|
"resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz",
|
||||||
"integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==",
|
"integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"bin": {
|
"bin": {
|
||||||
"semver": "bin/semver"
|
"semver": "bin/semver"
|
||||||
@ -5105,9 +5105,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/semver": {
|
"node_modules/semver": {
|
||||||
"version": "6.3.0",
|
"version": "6.3.1",
|
||||||
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz",
|
||||||
"integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==",
|
"integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"bin": {
|
"bin": {
|
||||||
"semver": "bin/semver.js"
|
"semver": "bin/semver.js"
|
||||||
|
@ -20,7 +20,7 @@ export default class OfficeRolesController extends ApiController {
|
|||||||
/**
|
/**
|
||||||
* @description Get all officeRoles
|
* @description Get all officeRoles
|
||||||
*/
|
*/
|
||||||
@Get("/api/v1/admin/officeRoles", [authHandler, ruleHandler])
|
@Get("/api/v1/admin/office-roles", [authHandler, ruleHandler])
|
||||||
protected async get(req: Request, response: Response) {
|
protected async get(req: Request, response: Response) {
|
||||||
try {
|
try {
|
||||||
//get query
|
//get query
|
||||||
@ -28,9 +28,22 @@ export default class OfficeRolesController extends ApiController {
|
|||||||
if (req.query["q"]) {
|
if (req.query["q"]) {
|
||||||
query = JSON.parse(req.query["q"] as string);
|
query = JSON.parse(req.query["q"] as string);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(req.query["search"] && typeof req.query["search"] === "string") {
|
||||||
|
const filter = req.query["search"];
|
||||||
|
query = {
|
||||||
|
where: {
|
||||||
|
name: {
|
||||||
|
contains: filter,
|
||||||
|
mode: "insensitive",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const officeId: string = req.body.user.office_Id;
|
const officeId: string = req.body.user.office_Id;
|
||||||
const officeWhereInput: Prisma.OfficesWhereInput = { uid: officeId } ;
|
const officeWhereInput: Prisma.OfficesWhereInput = { uid: officeId };
|
||||||
if(!query.where) query.where = { office: officeWhereInput};
|
if (!query.where) query.where = { office: officeWhereInput };
|
||||||
query.where.office = officeWhereInput;
|
query.where.office = officeWhereInput;
|
||||||
|
|
||||||
//call service to get prisma entity
|
//call service to get prisma entity
|
||||||
@ -132,7 +145,7 @@ export default class OfficeRolesController extends ApiController {
|
|||||||
if (req.query["q"]) {
|
if (req.query["q"]) {
|
||||||
query = JSON.parse(req.query["q"] as string);
|
query = JSON.parse(req.query["q"] as string);
|
||||||
}
|
}
|
||||||
|
|
||||||
const officeRoleEntity = await this.officeRolesService.getByUid(uid, query);
|
const officeRoleEntity = await this.officeRolesService.getByUid(uid, query);
|
||||||
|
|
||||||
if (!officeRoleEntity) {
|
if (!officeRoleEntity) {
|
||||||
|
@ -19,7 +19,7 @@ export default class OfficeRolesController extends ApiController {
|
|||||||
/**
|
/**
|
||||||
* @description Get all officeRoles
|
* @description Get all officeRoles
|
||||||
*/
|
*/
|
||||||
@Get("/api/v1/notary/officeRoles", [authHandler, ruleHandler])
|
@Get("/api/v1/notary/office-roles", [authHandler, ruleHandler])
|
||||||
protected async get(req: Request, response: Response) {
|
protected async get(req: Request, response: Response) {
|
||||||
try {
|
try {
|
||||||
//get query
|
//get query
|
||||||
|
@ -20,7 +20,7 @@ export default class OfficeRolesController extends ApiController {
|
|||||||
/**
|
/**
|
||||||
* @description Get all officeRoles
|
* @description Get all officeRoles
|
||||||
*/
|
*/
|
||||||
@Get("/api/v1/super-admin/officeRoles", [authHandler, ruleHandler])
|
@Get("/api/v1/super-admin/office-roles", [authHandler, ruleHandler])
|
||||||
protected async get(req: Request, response: Response) {
|
protected async get(req: Request, response: Response) {
|
||||||
try {
|
try {
|
||||||
//get query
|
//get query
|
||||||
@ -28,6 +28,18 @@ export default class OfficeRolesController extends ApiController {
|
|||||||
if (req.query["q"]) {
|
if (req.query["q"]) {
|
||||||
query = JSON.parse(req.query["q"] as string);
|
query = JSON.parse(req.query["q"] as string);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(req.query["search"] && typeof req.query["search"] === "string") {
|
||||||
|
const filter = req.query["search"];
|
||||||
|
query = {
|
||||||
|
where: {
|
||||||
|
name: {
|
||||||
|
contains: filter,
|
||||||
|
mode: "insensitive",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
const officeId: string = req.body.user.office_Id;
|
const officeId: string = req.body.user.office_Id;
|
||||||
const officeWhereInput: Prisma.OfficesWhereInput = { uid: officeId } ;
|
const officeWhereInput: Prisma.OfficesWhereInput = { uid: officeId } ;
|
||||||
if(!query.where) query.where = { office: officeWhereInput};
|
if(!query.where) query.where = { office: officeWhereInput};
|
||||||
|
@ -11,8 +11,8 @@ export default class OfficeRolesService extends BaseService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description : Get all officeRoles
|
* @description : Get all office roles
|
||||||
* @throws {Error} If officeRoles cannot be get
|
* @throws {Error} If office roles cannot be get
|
||||||
*/
|
*/
|
||||||
public get(query: Prisma.OfficeRolesFindManyArgs) {
|
public get(query: Prisma.OfficeRolesFindManyArgs) {
|
||||||
return this.officeRoleRepository.findMany(query);
|
return this.officeRoleRepository.findMany(query);
|
||||||
|
@ -10,8 +10,8 @@ export default class OfficeRolesService extends BaseService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description : Get all officeRoles
|
* @description : Get all office roles
|
||||||
* @throws {Error} If officeRoles cannot be get
|
* @throws {Error} If office roles cannot be get
|
||||||
*/
|
*/
|
||||||
public get(query: Prisma.OfficeRolesFindManyArgs) {
|
public get(query: Prisma.OfficeRolesFindManyArgs) {
|
||||||
return this.officeRoleRepository.findMany(query);
|
return this.officeRoleRepository.findMany(query);
|
||||||
|
@ -11,8 +11,8 @@ export default class OfficeRolesService extends BaseService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description : Get all officeRoles
|
* @description : Get all office roles
|
||||||
* @throws {Error} If officeRoles cannot be get
|
* @throws {Error} If office roles cannot be get
|
||||||
*/
|
*/
|
||||||
public get(query: Prisma.OfficeRolesFindManyArgs) {
|
public get(query: Prisma.OfficeRolesFindManyArgs) {
|
||||||
return this.officeRoleRepository.findMany(query);
|
return this.officeRoleRepository.findMany(query);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user