Merge branch 'dev' into staging
This commit is contained in:
commit
d79ed14665
@ -59,7 +59,7 @@
|
||||
"file-type-checker": "^1.0.8",
|
||||
"fp-ts": "^2.16.1",
|
||||
"jsonwebtoken": "^9.0.0",
|
||||
"le-coffre-resources": "git@github.com:smart-chain-fr/leCoffre-resources.git#v2.130",
|
||||
"le-coffre-resources": "git@github.com:smart-chain-fr/leCoffre-resources.git#v2.132",
|
||||
"module-alias": "^2.2.2",
|
||||
"monocle-ts": "^2.3.13",
|
||||
"multer": "^1.4.5-lts.1",
|
||||
|
49
src/app/api/admin/RulesGroupsController.ts
Normal file
49
src/app/api/admin/RulesGroupsController.ts
Normal file
@ -0,0 +1,49 @@
|
||||
import { Controller, Get} from "@ControllerPattern/index";
|
||||
import { Response, Request } from "express";
|
||||
import ApiController from "@Common/system/controller-pattern/ApiController";
|
||||
import { Service } from "typedi";
|
||||
import { Prisma } from "@prisma/client";
|
||||
import { RulesGroup } from "le-coffre-resources/dist/Admin";
|
||||
import roleHandler from "@App/middlewares/RolesHandler";
|
||||
import authHandler from "@App/middlewares/AuthHandler";
|
||||
import RulesGroupsService from "@Services/admin/RulesGroupsService/RulesGroupsService";
|
||||
|
||||
@Controller()
|
||||
@Service()
|
||||
export default class RulesRoupsController extends ApiController {
|
||||
constructor(private rulesGroupsService: RulesGroupsService) {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Get all subscriptions
|
||||
*/
|
||||
@Get("/api/v1/admin/rules-groups", [authHandler, roleHandler] )
|
||||
protected async get(req: Request, response: Response) {
|
||||
try {
|
||||
//get query
|
||||
let query: Prisma.RulesGroupsFindManyArgs = {};
|
||||
if (req.query["q"]) {
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
if (query.where?.uid) {
|
||||
this.httpBadRequest(response, "You can't filter by uid");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//call service to get prisma entity
|
||||
const rulesGroupsEntities = await this.rulesGroupsService.get(query);
|
||||
|
||||
//Hydrate ressource with prisma entity
|
||||
const rulesGroups = RulesGroup.hydrateArray<RulesGroup>(rulesGroupsEntities, { strategy: "excludeAll" });
|
||||
|
||||
//success
|
||||
this.httpSuccess(response, rulesGroups);
|
||||
} catch (error) {
|
||||
this.httpInternalError(response, error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -52,6 +52,8 @@ import IdNotOfficeController from "./api/idnot/OfficeController";
|
||||
import SubscriptionsController from "./api/admin/SubscriptionsController";
|
||||
import StripeController from "./api/admin/StripeController";
|
||||
import StripeWebhooks from "@Common/webhooks/stripeWebhooks";
|
||||
import RulesGroupsController from "./api/admin/RulesGroupsController";
|
||||
|
||||
/**
|
||||
* @description This allow to declare all controllers used in the application
|
||||
*/
|
||||
@ -111,5 +113,6 @@ export default {
|
||||
Container.get(SubscriptionsController);
|
||||
Container.get(StripeController);
|
||||
Container.get(StripeWebhooks);
|
||||
Container.get(RulesGroupsController);
|
||||
},
|
||||
};
|
||||
|
27
src/common/repositories/RulesGroupsRepository.ts
Normal file
27
src/common/repositories/RulesGroupsRepository.ts
Normal file
@ -0,0 +1,27 @@
|
||||
import Database from "@Common/databases/database";
|
||||
import BaseRepository from "@Repositories/BaseRepository";
|
||||
import { Service } from "typedi";
|
||||
import { Prisma } from "@prisma/client";
|
||||
|
||||
@Service()
|
||||
export default class RulesGroupsRepository extends BaseRepository {
|
||||
constructor(private database: Database) {
|
||||
super();
|
||||
}
|
||||
protected get model() {
|
||||
return this.database.getClient().rulesGroups;
|
||||
}
|
||||
protected get instanceDb() {
|
||||
return this.database.getClient();
|
||||
}
|
||||
|
||||
/**
|
||||
* @description : Find many subscriptions
|
||||
*/
|
||||
public async findMany(query: Prisma.RulesGroupsFindManyArgs) {
|
||||
query.take = Math.min(query.take || this.defaultFetchRows, this.maxFetchRows);
|
||||
if (!query.include) return this.model.findMany({ ...query });
|
||||
return this.model.findMany({ ...query });
|
||||
}
|
||||
|
||||
}
|
20
src/services/admin/RulesGroupsService/RulesGroupsService.ts
Normal file
20
src/services/admin/RulesGroupsService/RulesGroupsService.ts
Normal file
@ -0,0 +1,20 @@
|
||||
import BaseService from "@Services/BaseService";
|
||||
import "reflect-metadata";
|
||||
import { Service } from "typedi";
|
||||
import { Prisma } from "@prisma/client";
|
||||
import RulesGroupsRepository from "@Repositories/RulesGroupsRepository";
|
||||
|
||||
@Service()
|
||||
export default class RulesGroupsService extends BaseService {
|
||||
constructor(private rulesGroupsRepository: RulesGroupsRepository) {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* @description : Get all subscriptions
|
||||
* @throws {Error} If subscriptions cannot be get
|
||||
*/
|
||||
public get(query: Prisma.RulesGroupsFindManyArgs) {
|
||||
return this.rulesGroupsRepository.findMany(query);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user