mirror of
https://github.com/Paris-est-Ludique/intranet.git
synced 2025-09-12 14:20:08 +02:00
Move database accessors in separate files to separate them from database definitions
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
import ServiceAccessors from "./accessors"
|
||||
|
||||
export class JavGame {
|
||||
id = 0
|
||||
|
||||
@@ -50,13 +48,6 @@ export const translationJavGame: { [k in keyof JavGame]: string } = {
|
||||
bggPhoto: "bggPhoto",
|
||||
}
|
||||
|
||||
const elementName = "JavGame"
|
||||
export const elementName = "JavGame"
|
||||
|
||||
export type JavGameWithoutId = Omit<JavGame, "id">
|
||||
|
||||
const serviceAccessors = new ServiceAccessors<JavGameWithoutId, JavGame>(elementName)
|
||||
|
||||
export const javGameListGet = serviceAccessors.listGet()
|
||||
export const javGameGet = serviceAccessors.get()
|
||||
export const javGameAdd = serviceAccessors.add()
|
||||
export const javGameSet = serviceAccessors.set()
|
||||
|
9
src/services/javGamesAccessors.ts
Normal file
9
src/services/javGamesAccessors.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import ServiceAccessors from "./accessors"
|
||||
import { elementName, JavGame, JavGameWithoutId } from "./javGames"
|
||||
|
||||
const serviceAccessors = new ServiceAccessors<JavGameWithoutId, JavGame>(elementName)
|
||||
|
||||
export const javGameListGet = serviceAccessors.listGet()
|
||||
export const javGameGet = serviceAccessors.get()
|
||||
export const javGameAdd = serviceAccessors.add()
|
||||
export const javGameSet = serviceAccessors.set()
|
@@ -1,5 +1,3 @@
|
||||
import ServiceAccessors from "./accessors"
|
||||
|
||||
export class PreVolunteer {
|
||||
id = 0
|
||||
|
||||
@@ -26,18 +24,10 @@ export const translationPreVolunteer: { [k in keyof PreVolunteer]: string } = {
|
||||
comment: "commentaire",
|
||||
}
|
||||
|
||||
const elementName = "PreVolunteer"
|
||||
export const elementName = "PreVolunteer"
|
||||
|
||||
export const emailRegexp =
|
||||
/^(([^<>()[\].,;:\s@"]+(\.[^<>()[\].,;:\s@"]+)*)|(".+"))@(([^<>()[\].,;:\s@"]+\.)+[^<>()[\].,;:\s@"]{2,})$/i
|
||||
export const passwordMinLength = 4
|
||||
|
||||
export type PreVolunteerWithoutId = Omit<PreVolunteer, "id">
|
||||
|
||||
const serviceAccessors = new ServiceAccessors<PreVolunteerWithoutId, PreVolunteer>(elementName)
|
||||
|
||||
export const preVolunteerListGet = serviceAccessors.listGet()
|
||||
export const preVolunteerGet = serviceAccessors.get()
|
||||
export const preVolunteerAdd = serviceAccessors.add()
|
||||
export const preVolunteerSet = serviceAccessors.set()
|
||||
export const preVolunteerCountGet = serviceAccessors.countGet()
|
||||
|
10
src/services/preVolunteersAccessors.ts
Normal file
10
src/services/preVolunteersAccessors.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import ServiceAccessors from "./accessors"
|
||||
import { elementName, PreVolunteer, PreVolunteerWithoutId } from "./preVolunteers"
|
||||
|
||||
const serviceAccessors = new ServiceAccessors<PreVolunteerWithoutId, PreVolunteer>(elementName)
|
||||
|
||||
export const preVolunteerListGet = serviceAccessors.listGet()
|
||||
export const preVolunteerGet = serviceAccessors.get()
|
||||
export const preVolunteerAdd = serviceAccessors.add()
|
||||
export const preVolunteerSet = serviceAccessors.set()
|
||||
export const preVolunteerCountGet = serviceAccessors.countGet()
|
@@ -1,5 +1,3 @@
|
||||
import ServiceAccessors from "./accessors"
|
||||
|
||||
export class Team {
|
||||
id = 0
|
||||
|
||||
@@ -29,11 +27,6 @@ export const translationTeam: { [k in keyof Team]: string } = {
|
||||
after: "après",
|
||||
}
|
||||
|
||||
const elementName = "Team"
|
||||
export const elementName = "Team"
|
||||
|
||||
export type TeamWithoutId = Omit<Team, "id">
|
||||
|
||||
const serviceAccessors = new ServiceAccessors<TeamWithoutId, Team>(elementName)
|
||||
|
||||
export const teamListGet = serviceAccessors.listGet()
|
||||
export const teamGet = serviceAccessors.get()
|
||||
|
7
src/services/teamsAccessors.ts
Normal file
7
src/services/teamsAccessors.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import ServiceAccessors from "./accessors"
|
||||
import { Team, TeamWithoutId, elementName } from "./teams"
|
||||
|
||||
const serviceAccessors = new ServiceAccessors<TeamWithoutId, Team>(elementName)
|
||||
|
||||
export const teamListGet = serviceAccessors.listGet()
|
||||
export const teamGet = serviceAccessors.get()
|
@@ -1,5 +1,3 @@
|
||||
import ServiceAccessors from "./accessors"
|
||||
|
||||
export class Volunteer {
|
||||
id = 0
|
||||
|
||||
@@ -19,6 +17,8 @@ export class Volunteer {
|
||||
|
||||
active = ""
|
||||
|
||||
discordId = ""
|
||||
|
||||
dayWishes: string[] = []
|
||||
|
||||
dayWishesComment = ""
|
||||
@@ -56,6 +56,7 @@ export const translationVolunteer: { [k in keyof Volunteer]: string } = {
|
||||
adult: "majeur",
|
||||
privileges: "privilege",
|
||||
active: "actif",
|
||||
discordId: "discordId",
|
||||
dayWishes: "enviesJours",
|
||||
dayWishesComment: "commentaireEnviesJours",
|
||||
age: "age",
|
||||
@@ -71,7 +72,7 @@ export const translationVolunteer: { [k in keyof Volunteer]: string } = {
|
||||
acceptsNotifs: "accepteLesNotifs",
|
||||
}
|
||||
|
||||
const elementName = "Volunteer"
|
||||
export const elementName = "Volunteer"
|
||||
|
||||
export const volunteerExample: Volunteer = {
|
||||
id: 1,
|
||||
@@ -83,6 +84,7 @@ export const volunteerExample: Volunteer = {
|
||||
adult: 1,
|
||||
privileges: 0,
|
||||
active: "inconnu",
|
||||
discordId: "",
|
||||
dayWishes: [],
|
||||
dayWishesComment: "",
|
||||
age: 33,
|
||||
@@ -104,24 +106,14 @@ export const passwordMinLength = 4
|
||||
|
||||
export type VolunteerWithoutId = Omit<Volunteer, "id">
|
||||
|
||||
const serviceAccessors = new ServiceAccessors<VolunteerWithoutId, Volunteer>(elementName)
|
||||
|
||||
export const volunteerListGet = serviceAccessors.listGet()
|
||||
export const volunteerGet = serviceAccessors.get()
|
||||
export const volunteerAdd = serviceAccessors.add()
|
||||
export const volunteerSet = serviceAccessors.set()
|
||||
|
||||
export interface VolunteerLogin {
|
||||
id: number
|
||||
jwt: string
|
||||
}
|
||||
export const volunteerLogin =
|
||||
serviceAccessors.customPost<[{ email: string; password: string }]>("Login")
|
||||
|
||||
export interface VolunteerForgot {
|
||||
message: string
|
||||
}
|
||||
export const volunteerForgot = serviceAccessors.customPost<[{ email: string }]>("Forgot")
|
||||
|
||||
export interface VolunteerNotifs {
|
||||
id: Volunteer["id"]
|
||||
@@ -132,24 +124,18 @@ export interface VolunteerNotifs {
|
||||
pushNotifSubscription: Volunteer["pushNotifSubscription"]
|
||||
acceptsNotifs: Volunteer["acceptsNotifs"]
|
||||
}
|
||||
export const volunteerNotifsSet =
|
||||
serviceAccessors.securedCustomPost<[number, Partial<VolunteerNotifs>]>("NotifsSet")
|
||||
|
||||
export interface VolunteerTeamWishes {
|
||||
id: Volunteer["id"]
|
||||
teamWishes: Volunteer["teamWishes"]
|
||||
teamWishesComment: Volunteer["teamWishesComment"]
|
||||
}
|
||||
export const volunteerTeamWishesSet =
|
||||
serviceAccessors.securedCustomPost<[number, Partial<VolunteerTeamWishes>]>("TeamWishesSet")
|
||||
|
||||
export interface VolunteerDayWishes {
|
||||
id: Volunteer["id"]
|
||||
dayWishes: Volunteer["dayWishes"]
|
||||
dayWishesComment: Volunteer["dayWishesComment"]
|
||||
}
|
||||
export const volunteerDayWishesSet =
|
||||
serviceAccessors.securedCustomPost<[number, Partial<VolunteerDayWishes>]>("DayWishesSet")
|
||||
|
||||
export interface VolunteerParticipationDetails {
|
||||
id: Volunteer["id"]
|
||||
@@ -157,7 +143,3 @@ export interface VolunteerParticipationDetails {
|
||||
teeshirtSize: Volunteer["teeshirtSize"]
|
||||
food: Volunteer["food"]
|
||||
}
|
||||
export const volunteerParticipationDetailsSet =
|
||||
serviceAccessors.securedCustomPost<[number, Partial<VolunteerParticipationDetails>]>(
|
||||
"ParticipationDetailsSet"
|
||||
)
|
||||
|
36
src/services/volunteersAccessors.ts
Normal file
36
src/services/volunteersAccessors.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import ServiceAccessors from "./accessors"
|
||||
import {
|
||||
elementName,
|
||||
Volunteer,
|
||||
VolunteerDayWishes,
|
||||
VolunteerNotifs,
|
||||
VolunteerParticipationDetails,
|
||||
VolunteerTeamWishes,
|
||||
VolunteerWithoutId,
|
||||
} from "./volunteers"
|
||||
|
||||
const serviceAccessors = new ServiceAccessors<VolunteerWithoutId, Volunteer>(elementName)
|
||||
|
||||
export const volunteerListGet = serviceAccessors.listGet()
|
||||
export const volunteerGet = serviceAccessors.get()
|
||||
export const volunteerAdd = serviceAccessors.add()
|
||||
export const volunteerSet = serviceAccessors.set()
|
||||
|
||||
export const volunteerLogin =
|
||||
serviceAccessors.customPost<[{ email: string; password: string }]>("Login")
|
||||
|
||||
export const volunteerForgot = serviceAccessors.customPost<[{ email: string }]>("Forgot")
|
||||
|
||||
export const volunteerNotifsSet =
|
||||
serviceAccessors.securedCustomPost<[number, Partial<VolunteerNotifs>]>("NotifsSet")
|
||||
|
||||
export const volunteerTeamWishesSet =
|
||||
serviceAccessors.securedCustomPost<[number, Partial<VolunteerTeamWishes>]>("TeamWishesSet")
|
||||
|
||||
export const volunteerDayWishesSet =
|
||||
serviceAccessors.securedCustomPost<[number, Partial<VolunteerDayWishes>]>("DayWishesSet")
|
||||
|
||||
export const volunteerParticipationDetailsSet =
|
||||
serviceAccessors.securedCustomPost<[number, Partial<VolunteerParticipationDetails>]>(
|
||||
"ParticipationDetailsSet"
|
||||
)
|
@@ -1,5 +1,3 @@
|
||||
import ServiceAccessors from "./accessors"
|
||||
|
||||
export class Wish {
|
||||
id = 0
|
||||
|
||||
@@ -23,13 +21,6 @@ export const translationWish: { [k in keyof Wish]: string } = {
|
||||
addedDate: "dateAjout",
|
||||
}
|
||||
|
||||
const elementName = "Wish"
|
||||
export const elementName = "Wish"
|
||||
|
||||
export type WishWithoutId = Omit<Wish, "id">
|
||||
|
||||
const serviceAccessors = new ServiceAccessors<WishWithoutId, Wish>(elementName)
|
||||
|
||||
export const wishListGet = serviceAccessors.listGet()
|
||||
export const wishGet = serviceAccessors.get()
|
||||
export const wishAdd = serviceAccessors.add()
|
||||
export const wishSet = serviceAccessors.set()
|
||||
|
9
src/services/wishesAccessors.ts
Normal file
9
src/services/wishesAccessors.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import ServiceAccessors from "./accessors"
|
||||
import { elementName, Wish, WishWithoutId } from "./wishes"
|
||||
|
||||
const serviceAccessors = new ServiceAccessors<WishWithoutId, Wish>(elementName)
|
||||
|
||||
export const wishListGet = serviceAccessors.listGet()
|
||||
export const wishGet = serviceAccessors.get()
|
||||
export const wishAdd = serviceAccessors.add()
|
||||
export const wishSet = serviceAccessors.set()
|
Reference in New Issue
Block a user