Merge Dev in Staging
This commit is contained in:
commit
edf2d065d1
@ -53,7 +53,7 @@
|
||||
"express": "^4.18.2",
|
||||
"fp-ts": "^2.16.1",
|
||||
"jsonwebtoken": "^9.0.0",
|
||||
"le-coffre-resources": "git@github.com:smart-chain-fr/leCoffre-resources.git#v2.86",
|
||||
"le-coffre-resources": "git@github.com:smart-chain-fr/leCoffre-resources.git#v2.88",
|
||||
"module-alias": "^2.2.2",
|
||||
"monocle-ts": "^2.3.13",
|
||||
"multer": "^1.4.5-lts.1",
|
||||
|
@ -11,6 +11,7 @@ import authHandler from "@App/middlewares/AuthHandler";
|
||||
import ruleHandler from "@App/middlewares/RulesHandler";
|
||||
import folderHandler from "@App/middlewares/OfficeMembershipHandlers/FolderHandler";
|
||||
import OfficeFolderAnchor from "le-coffre-resources/dist/Notary/OfficeFolderAnchor";
|
||||
import NotificationBuilder from "@Common/notifications/NotificationBuilder";
|
||||
|
||||
const hydrateOfficeFolderAnchor = (data: any): OfficeFolderAnchor =>
|
||||
OfficeFolderAnchor.hydrate<OfficeFolderAnchor>(
|
||||
@ -33,7 +34,12 @@ const hydrateOfficeFolderAnchor = (data: any): OfficeFolderAnchor =>
|
||||
@Controller()
|
||||
@Service()
|
||||
export default class OfficeFoldersController extends ApiController {
|
||||
constructor(private secureService: SecureService, private officeFolderAnchorsRepository: OfficeFolderAnchorsRepository, private officeFoldersService: OfficeFoldersService) {
|
||||
constructor(
|
||||
private secureService: SecureService,
|
||||
private officeFolderAnchorsRepository: OfficeFolderAnchorsRepository,
|
||||
private officeFoldersService: OfficeFoldersService,
|
||||
private notificationBuilder: NotificationBuilder,
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
||||
@ -76,7 +82,7 @@ export default class OfficeFoldersController extends ApiController {
|
||||
const sortedHashes = [...folderHashes].sort();
|
||||
const buffer = await this.secureService.download(sortedHashes);
|
||||
|
||||
response.setHeader('Content-Type', 'application/pdf');
|
||||
response.setHeader("Content-Type", "application/pdf");
|
||||
this.httpSuccess(response, buffer);
|
||||
} catch (error) {
|
||||
this.httpInternalError(response, error);
|
||||
@ -139,9 +145,7 @@ export default class OfficeFoldersController extends ApiController {
|
||||
|
||||
const officeFolderAnchor = hydrateOfficeFolderAnchor(data);
|
||||
|
||||
const newOfficeFolderAnchor = await this.officeFolderAnchorsRepository.create(
|
||||
officeFolderAnchor
|
||||
);
|
||||
const newOfficeFolderAnchor = await this.officeFolderAnchorsRepository.create(officeFolderAnchor);
|
||||
|
||||
await this.officeFoldersService.update(
|
||||
uid,
|
||||
@ -213,9 +217,12 @@ export default class OfficeFoldersController extends ApiController {
|
||||
|
||||
const updatedOfficeFolderAnchor = await this.officeFolderAnchorsRepository.update(
|
||||
officeFolderAnchorFound.uid,
|
||||
officeFolderAnchor
|
||||
officeFolderAnchor,
|
||||
);
|
||||
|
||||
if (officeFolderAnchorFound.status !== "VERIFIED_ON_CHAIN" && officeFolderAnchor.status === "VERIFIED_ON_CHAIN")
|
||||
this.notificationBuilder.sendFolderAnchoredNotification(officeFolderFound);
|
||||
|
||||
this.httpSuccess(response, updatedOfficeFolderAnchor);
|
||||
return;
|
||||
} catch (error) {
|
||||
|
@ -1,77 +0,0 @@
|
||||
import { Response, Request } from "express";
|
||||
import { Controller, Get } from "@ControllerPattern/index";
|
||||
import ApiController from "@Common/system/controller-pattern/ApiController";
|
||||
import AppointmentsService from "@Services/super-admin/AppointmentsService/AppointmentsService";
|
||||
import { Service } from "typedi";
|
||||
import { Appointment } from "le-coffre-resources/dist/SuperAdmin";
|
||||
import authHandler from "@App/middlewares/AuthHandler";
|
||||
import roleHandler from "@App/middlewares/RolesHandler";
|
||||
|
||||
@Controller()
|
||||
@Service()
|
||||
export default class AppointmentsController extends ApiController {
|
||||
constructor(private appointmentsService: AppointmentsService) {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Get all appointments
|
||||
*/
|
||||
@Get("/api/v1/super-admin/appointments", [authHandler, roleHandler])
|
||||
protected async get(req: Request, response: Response) {
|
||||
try {
|
||||
//get query
|
||||
let query;
|
||||
if (req.query["q"]) {
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
|
||||
//call service to get prisma entity
|
||||
const appointmentsEntities = await this.appointmentsService.get(query);
|
||||
|
||||
//Hydrate ressource with prisma entity
|
||||
const appointments = Appointment.hydrateArray<Appointment>(appointmentsEntities, { strategy: "excludeAll" });
|
||||
|
||||
//success
|
||||
this.httpSuccess(response, appointments);
|
||||
} catch (error) {
|
||||
this.httpInternalError(response, error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Get a specific appointment by uid
|
||||
*/
|
||||
@Get("/api/v1/super-admin/appointments/:uid", [authHandler, roleHandler])
|
||||
protected async getOneByUid(req: Request, response: Response) {
|
||||
try {
|
||||
const uid = req.params["uid"];
|
||||
if (!uid) {
|
||||
this.httpBadRequest(response, "No uid provided");
|
||||
return;
|
||||
}
|
||||
|
||||
let query;
|
||||
if (req.query["q"]) {
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
|
||||
const appointmentEntity = await this.appointmentsService.getByUid(uid, query);
|
||||
|
||||
if (!appointmentEntity) {
|
||||
this.httpNotFoundRequest(response, "appointment not found");
|
||||
return;
|
||||
}
|
||||
|
||||
//Hydrate ressource with prisma entity
|
||||
const appointment = Appointment.hydrate<Appointment>(appointmentEntity, { strategy: "excludeAll" });
|
||||
|
||||
//success
|
||||
this.httpSuccess(response, appointment);
|
||||
} catch (error) {
|
||||
this.httpInternalError(response, error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
@ -2,12 +2,10 @@ import authHandler from "@App/middlewares/AuthHandler";
|
||||
import roleHandler from "@App/middlewares/RolesHandler";
|
||||
import NotificationBuilder from "@Common/notifications/NotificationBuilder";
|
||||
import ApiController from "@Common/system/controller-pattern/ApiController";
|
||||
import { Controller, Post } from "@ControllerPattern/index";
|
||||
import { EAppointmentStatus } from "@prisma/client";
|
||||
import AppointmentService from "@Services/super-admin/AppointmentsService/AppointmentsService";
|
||||
import { Controller, Delete, Post } from "@ControllerPattern/index";
|
||||
import { EAppointmentStatus, Votes } from "@prisma/client";
|
||||
import LiveVoteService from "@Services/super-admin/LiveVoteService/LiveVoteService";
|
||||
import UsersService from "@Services/super-admin/UsersService/UsersService";
|
||||
import VotesService from "@Services/super-admin/VotesService/VotesService";
|
||||
import { validateOrReject } from "class-validator";
|
||||
import { Request, Response } from "express";
|
||||
import { Vote } from "le-coffre-resources/dist/SuperAdmin";
|
||||
@ -18,9 +16,7 @@ import { Service } from "typedi";
|
||||
export default class LiveVoteController extends ApiController {
|
||||
constructor(
|
||||
private liveVoteService: LiveVoteService,
|
||||
private votesService: VotesService,
|
||||
private usersService: UsersService,
|
||||
private appointmentService: AppointmentService,
|
||||
private notificationBuilder: NotificationBuilder,
|
||||
) {
|
||||
super();
|
||||
@ -40,7 +36,7 @@ export default class LiveVoteController extends ApiController {
|
||||
|
||||
let voteFound = [];
|
||||
if (voteEntity.appointment.uid) {
|
||||
const appointment = await this.appointmentService.getByUid(voteEntity.appointment.uid);
|
||||
const appointment = await this.liveVoteService.getAppointmentByUid(voteEntity.appointment.uid);
|
||||
if (!appointment) {
|
||||
this.httpNotFoundRequest(response, "Appointment not found");
|
||||
return;
|
||||
@ -49,11 +45,11 @@ export default class LiveVoteController extends ApiController {
|
||||
this.httpBadRequest(response, "Appointment is closed");
|
||||
return;
|
||||
}
|
||||
voteFound = await this.votesService.get({
|
||||
voteFound = await this.liveVoteService.getVotes({
|
||||
where: { AND: [{ appointment: { uid: voteEntity.appointment.uid } }, { voter: { uid: userId } }] },
|
||||
});
|
||||
} else {
|
||||
voteFound = await this.votesService.get({
|
||||
voteFound = await this.liveVoteService.getVotes({
|
||||
where: {
|
||||
AND: [
|
||||
{
|
||||
@ -96,4 +92,50 @@ export default class LiveVoteController extends ApiController {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Delete a specific vote
|
||||
*/
|
||||
@Delete("/api/v1/super-admin/live-votes/:uid", [authHandler, roleHandler])
|
||||
protected async deleteVote(req: Request, response: Response) {
|
||||
try {
|
||||
const uid = req.params["uid"];
|
||||
if (!uid) {
|
||||
this.httpBadRequest(response, "No uid provided");
|
||||
return;
|
||||
}
|
||||
|
||||
const voteFound = await this.liveVoteService.getVoteByUid(uid, {
|
||||
appointment: {
|
||||
include: { votes: true },
|
||||
},
|
||||
});
|
||||
|
||||
if (!voteFound) {
|
||||
this.httpNotFoundRequest(response, "vote not found");
|
||||
return;
|
||||
}
|
||||
|
||||
if (voteFound.voter_uid !== req.body.user.userId) {
|
||||
this.httpUnauthorized(response, "Can't delete a vote that's not yours");
|
||||
return;
|
||||
}
|
||||
|
||||
const vote = Vote.hydrate<Vote>(voteFound, { strategy: "excludeAll" });
|
||||
|
||||
//call service to get prisma entity
|
||||
const voteEntity: Votes = await this.liveVoteService.deleteVote(uid);
|
||||
|
||||
if (vote.appointment.uid && vote.appointment.votes && vote.appointment.votes.length === 1) {
|
||||
await this.liveVoteService.deleteAppointment(vote.appointment.uid);
|
||||
}
|
||||
|
||||
const voteToReturn = Vote.hydrate<Vote>(voteEntity, { strategy: "excludeAll" });
|
||||
//success
|
||||
this.httpSuccess(response, voteToReturn);
|
||||
} catch (error) {
|
||||
this.httpInternalError(response, error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,116 +0,0 @@
|
||||
import { Response, Request } from "express";
|
||||
import { Controller, Delete, Get } from "@ControllerPattern/index";
|
||||
import ApiController from "@Common/system/controller-pattern/ApiController";
|
||||
import VotesService from "@Services/super-admin/VotesService/VotesService";
|
||||
import { Service } from "typedi";
|
||||
import { Vote } from "le-coffre-resources/dist/SuperAdmin";
|
||||
import authHandler from "@App/middlewares/AuthHandler";
|
||||
import { Votes } from "@prisma/client";
|
||||
import roleHandler from "@App/middlewares/RolesHandler";
|
||||
|
||||
@Controller()
|
||||
@Service()
|
||||
export default class VotesController extends ApiController {
|
||||
constructor(private votesService: VotesService) {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Get all votes
|
||||
*/
|
||||
@Get("/api/v1/super-admin/votes", [authHandler, roleHandler])
|
||||
protected async get(req: Request, response: Response) {
|
||||
try {
|
||||
//get query
|
||||
let query;
|
||||
if (req.query["q"]) {
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
|
||||
//call service to get prisma entity
|
||||
const votesEntities = await this.votesService.get(query);
|
||||
|
||||
//Hydrate ressource with prisma entity
|
||||
const votes = Vote.hydrateArray<Vote>(votesEntities, { strategy: "excludeAll" });
|
||||
|
||||
//success
|
||||
this.httpSuccess(response, votes);
|
||||
} catch (error) {
|
||||
this.httpInternalError(response, error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Get a specific vote by uid
|
||||
*/
|
||||
@Get("/api/v1/super-admin/votes/:uid", [authHandler, roleHandler])
|
||||
protected async getOneByUid(req: Request, response: Response) {
|
||||
try {
|
||||
const uid = req.params["uid"];
|
||||
if (!uid) {
|
||||
this.httpBadRequest(response, "No uid provided");
|
||||
return;
|
||||
}
|
||||
|
||||
let query;
|
||||
if (req.query["q"]) {
|
||||
query = JSON.parse(req.query["q"] as string);
|
||||
}
|
||||
|
||||
const voteEntity = await this.votesService.getByUid(uid, query);
|
||||
|
||||
if (!voteEntity) {
|
||||
this.httpNotFoundRequest(response, "vote not found");
|
||||
return;
|
||||
}
|
||||
|
||||
//Hydrate ressource with prisma entity
|
||||
const vote = Vote.hydrate<Vote>(voteEntity, { strategy: "excludeAll" });
|
||||
|
||||
//success
|
||||
this.httpSuccess(response, vote);
|
||||
} catch (error) {
|
||||
this.httpInternalError(response, error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Delete a specific vote
|
||||
*/
|
||||
@Delete("/api/v1/super-admin/votes/:uid", [authHandler, roleHandler])
|
||||
protected async delete(req: Request, response: Response) {
|
||||
try {
|
||||
const uid = req.params["uid"];
|
||||
if (!uid) {
|
||||
this.httpBadRequest(response, "No uid provided");
|
||||
return;
|
||||
}
|
||||
|
||||
const voteFound = await this.votesService.getByUid(uid);
|
||||
|
||||
if (!voteFound) {
|
||||
this.httpNotFoundRequest(response, "vote not found");
|
||||
return;
|
||||
}
|
||||
|
||||
if (voteFound.voter_uid !== req.body.user.userId) {
|
||||
this.httpUnauthorized(response, "Can't delete a vote that's not yours");
|
||||
return;
|
||||
}
|
||||
|
||||
//call service to get prisma entity
|
||||
const votetEntity: Votes = await this.votesService.delete(uid);
|
||||
|
||||
//Hydrate ressource with prisma entity
|
||||
const vote = Vote.hydrate<Vote>(votetEntity, { strategy: "excludeAll" });
|
||||
|
||||
//success
|
||||
this.httpSuccess(response, vote);
|
||||
} catch (error) {
|
||||
this.httpInternalError(response, error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
@ -42,8 +42,6 @@ import FilesControllerCustomer from "./api/customer/FilesController";
|
||||
import DocumentsControllerCustomer from "./api/customer/DocumentsController";
|
||||
import OfficeFoldersController from "./api/customer/OfficeFoldersController";
|
||||
import OfficeFolderAnchorsController from "./api/notary/OfficeFolderAnchorsController";
|
||||
import AppointmentsController from "./api/super-admin/AppointmentsController";
|
||||
import VotesController from "./api/super-admin/VotesController";
|
||||
import LiveVoteController from "./api/super-admin/LiveVoteController";
|
||||
import DocumentControllerId360 from "./api/id360/DocumentController";
|
||||
import CustomerControllerId360 from "./api/id360/CustomerController";
|
||||
@ -54,7 +52,6 @@ import UserNotificationController from "./api/notary/UserNotificationController"
|
||||
* @description This allow to declare all controllers used in the application
|
||||
*/
|
||||
export default {
|
||||
|
||||
start: () => {
|
||||
Container.get(HomeController);
|
||||
Container.get(UsersControllerSuperAdmin);
|
||||
@ -65,8 +62,6 @@ export default {
|
||||
Container.get(DeedTypesControllerSuperAdmin);
|
||||
Container.get(DocumentsControllerSuperAdmin);
|
||||
Container.get(DocumentTypesControllerSuperAdmin);
|
||||
Container.get(AppointmentsController);
|
||||
Container.get(VotesController);
|
||||
Container.get(LiveVoteController);
|
||||
Container.get(IdNotUserController);
|
||||
Container.get(FranceConnectCustomerController);
|
||||
|
@ -243,8 +243,8 @@ export default async function main() {
|
||||
{
|
||||
address: addresses[6],
|
||||
first_name: "Jean",
|
||||
last_name: "Dubigot",
|
||||
email: "jean.dubigot@gmail.com",
|
||||
last_name: "Dubignot",
|
||||
email: "jean.dubignot@gmail.com",
|
||||
phone_number: "06 78 90 12 34",
|
||||
cell_phone_number: "06 78 90 12 34",
|
||||
birthdate: null,
|
||||
@ -664,10 +664,10 @@ export default async function main() {
|
||||
},
|
||||
{
|
||||
name: "DELETE documents",
|
||||
label: "Supprimer un document",
|
||||
label: "Supprimer un document demandé",
|
||||
created_at: new Date(),
|
||||
updated_at: new Date(),
|
||||
namespace: "super-admin",
|
||||
namespace: "notary",
|
||||
},
|
||||
{
|
||||
name: "POST customers",
|
||||
|
@ -1,53 +0,0 @@
|
||||
import BaseService from "@Services/BaseService";
|
||||
import { Service } from "typedi";
|
||||
import AppointmentsRepository from "@Repositories/AppointmentsRepository";
|
||||
import { Prisma, Appointments, EAppointmentStatus } from "@prisma/client";
|
||||
|
||||
@Service()
|
||||
export default class AppointmentService extends BaseService {
|
||||
constructor(private appointmentRepository: AppointmentsRepository) {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* @description : Get all appointments
|
||||
* @throws {Error} If appointments cannot be get
|
||||
*/
|
||||
public get(query: Prisma.AppointmentsFindManyArgs) {
|
||||
return this.appointmentRepository.findMany(query);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description : Modify a appointment
|
||||
* @throws {Error} If appointment cannot be modified
|
||||
*/
|
||||
public async update(uid: string, status: EAppointmentStatus): Promise<Appointments> {
|
||||
return this.appointmentRepository.update(uid, status);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description : Get a appointment by uid
|
||||
* @throws {Error} If appointment cannot be get by uid
|
||||
*/
|
||||
public getByUid(uid: string, query?: Prisma.AppointmentsInclude): Promise<Appointments | null> {
|
||||
return this.appointmentRepository.findOneByUid(uid, query);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description : Get a appointment by uid
|
||||
* @throws {Error} If appointment cannot be get by uid
|
||||
*/
|
||||
public getByUidWithVotes(uid: string) {
|
||||
return this.appointmentRepository.findOneByUidWithVotes(uid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description : delete a appointment by uid
|
||||
* @throws {Error} If appointment cannot be get by uid
|
||||
*/
|
||||
public delete(uid: string) {
|
||||
return this.appointmentRepository.delete(uid);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -2,16 +2,16 @@ import BaseService from "@Services/BaseService";
|
||||
import { Service } from "typedi";
|
||||
import User, { Appointment, Role, Vote } from "le-coffre-resources/dist/SuperAdmin";
|
||||
import VotesRepository from "@Repositories/VotesRepository";
|
||||
import { Appointments, EAppointmentStatus, EVote, Votes } from "@prisma/client";
|
||||
import AppointmentService from "../AppointmentsService/AppointmentsService";
|
||||
import { Appointments, EAppointmentStatus, EVote, Prisma, Votes } from "@prisma/client";
|
||||
import UsersService from "../UsersService/UsersService";
|
||||
import RolesService from "../RolesService/RolesService";
|
||||
import AppointmentsRepository from "@Repositories/AppointmentsRepository";
|
||||
|
||||
@Service()
|
||||
export default class LiveVoteService extends BaseService {
|
||||
constructor(
|
||||
private voteRepository: VotesRepository,
|
||||
private appointmentService: AppointmentService,
|
||||
private appointmentRepository: AppointmentsRepository,
|
||||
private userService: UsersService,
|
||||
private roleService: RolesService,
|
||||
) {
|
||||
@ -29,11 +29,47 @@ export default class LiveVoteService extends BaseService {
|
||||
return false;
|
||||
}
|
||||
|
||||
public getVotes(query: Prisma.VotesFindManyArgs) {
|
||||
return this.voteRepository.findMany(query);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description : Get a vote by uid
|
||||
* @throws {Error} If vote cannot be get by uid
|
||||
*/
|
||||
public getVoteByUid(uid: string, query?: Prisma.VotesInclude) {
|
||||
return this.voteRepository.findOneByUid(uid, query);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description : delete a vote by uid
|
||||
* @throws {Error} If vote cannot be get by uid
|
||||
*/
|
||||
public deleteVote(uid: string) {
|
||||
return this.voteRepository.delete(uid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description : delete an appointment by uid
|
||||
* @throws {Error} If appointment cannot be get by uid
|
||||
*/
|
||||
public deleteAppointment(uid: string) {
|
||||
return this.appointmentRepository.delete(uid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description : Get a appointment by uid
|
||||
* @throws {Error} If appointment cannot be get by uid
|
||||
*/
|
||||
public getAppointmentByUid(uid: string, query?: Prisma.AppointmentsInclude): Promise<Appointments | null> {
|
||||
return this.appointmentRepository.findOneByUid(uid, query);
|
||||
}
|
||||
|
||||
public async getAppointmentWithVotes(vote: Vote): Promise<Appointments | null> {
|
||||
if (vote.appointment.uid) {
|
||||
return this.appointmentService.getByUidWithVotes(vote.appointment.uid);
|
||||
return this.appointmentRepository.findOneByUid(vote.appointment.uid);
|
||||
}
|
||||
const appointmentByUser = await this.appointmentService.get({
|
||||
const appointmentByUser = await this.appointmentRepository.findMany({
|
||||
where: {
|
||||
AND: [
|
||||
{ user_uid: vote.appointment.targeted_user.uid },
|
||||
@ -44,13 +80,13 @@ export default class LiveVoteService extends BaseService {
|
||||
include: { votes: true },
|
||||
});
|
||||
if (appointmentByUser.length >= 1) {
|
||||
return this.appointmentService.getByUidWithVotes(appointmentByUser[0]!.uid);
|
||||
return this.appointmentRepository.findOneByUidWithVotes(appointmentByUser[0]!.uid);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private async closeVote(appointment: Appointments, vote: Votes) {
|
||||
await this.appointmentService.update(vote.appointment_uid, EAppointmentStatus.CLOSED);
|
||||
await this.appointmentRepository.update(vote.appointment_uid, EAppointmentStatus.CLOSED);
|
||||
const user = await this.userService.getByUid(appointment.user_uid, { role: true });
|
||||
const userEntity = User.hydrate<User>(user!, { strategy: "excludeAll" });
|
||||
|
||||
|
@ -1,35 +0,0 @@
|
||||
import BaseService from "@Services/BaseService";
|
||||
import { Service } from "typedi";
|
||||
import VotesRepository from "@Repositories/VotesRepository";
|
||||
import { Prisma } from "@prisma/client";
|
||||
|
||||
@Service()
|
||||
export default class VoteService extends BaseService {
|
||||
constructor(private voteRepository: VotesRepository) {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* @description : Get all votes
|
||||
* @throws {Error} If votes cannot be get
|
||||
*/
|
||||
public get(query: Prisma.VotesFindManyArgs) {
|
||||
return this.voteRepository.findMany(query);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description : Get a vote by uid
|
||||
* @throws {Error} If vote cannot be get by uid
|
||||
*/
|
||||
public getByUid(uid: string, query?: Prisma.VotesInclude) {
|
||||
return this.voteRepository.findOneByUid(uid, query);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description : delete a vote by uid
|
||||
* @throws {Error} If vote cannot be get by uid
|
||||
*/
|
||||
public delete(uid: string) {
|
||||
return this.voteRepository.delete(uid);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user