postal Code & commandHandler update
This commit is contained in:
parent
14677d2030
commit
dd72f37856
13 changed files with 70 additions and 76 deletions
|
@ -3,6 +3,7 @@ export interface CreateCommunicationCommand {
|
||||||
isSMSAlarming: boolean;
|
isSMSAlarming: boolean;
|
||||||
mobile: string;
|
mobile: string;
|
||||||
email: string;
|
email: string;
|
||||||
|
postalCode: string;
|
||||||
city: string;
|
city: string;
|
||||||
street: string;
|
street: string;
|
||||||
streetNumber: number;
|
streetNumber: number;
|
||||||
|
@ -17,6 +18,7 @@ export interface UpdateCommunicationCommand {
|
||||||
isSMSAlarming: boolean;
|
isSMSAlarming: boolean;
|
||||||
mobile: string;
|
mobile: string;
|
||||||
email: string;
|
email: string;
|
||||||
|
postalCode: string;
|
||||||
city: string;
|
city: string;
|
||||||
street: string;
|
street: string;
|
||||||
streetNumber: number;
|
streetNumber: number;
|
||||||
|
|
|
@ -25,20 +25,13 @@ export default abstract class CommunicationCommandHandler {
|
||||||
isSMSAlarming: createCommunication.isSMSAlarming,
|
isSMSAlarming: createCommunication.isSMSAlarming,
|
||||||
mobile: createCommunication.mobile,
|
mobile: createCommunication.mobile,
|
||||||
email: createCommunication.email,
|
email: createCommunication.email,
|
||||||
|
postalCode: createCommunication.postalCode,
|
||||||
city: createCommunication.city,
|
city: createCommunication.city,
|
||||||
street: createCommunication.street,
|
street: createCommunication.street,
|
||||||
streetNumber: createCommunication.streetNumber,
|
streetNumber: createCommunication.streetNumber,
|
||||||
streetNumberAddition: createCommunication.streetNumberAddition,
|
streetNumberAddition: createCommunication.streetNumberAddition,
|
||||||
member: await dataSource
|
memberId: createCommunication.memberId,
|
||||||
.getRepository(user)
|
typeId: createCommunication.typeId,
|
||||||
.createQueryBuilder("user")
|
|
||||||
.where("id = :id", { id: createCommunication.memberId })
|
|
||||||
.getOneOrFail(),
|
|
||||||
type: await dataSource
|
|
||||||
.getRepository(communicationType)
|
|
||||||
.createQueryBuilder("communication")
|
|
||||||
.where("id = :id", { id: createCommunication.typeId })
|
|
||||||
.getOneOrFail(),
|
|
||||||
})
|
})
|
||||||
.execute()
|
.execute()
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
|
@ -63,6 +56,7 @@ export default abstract class CommunicationCommandHandler {
|
||||||
isSMSAlarming: updateCommunication.isSMSAlarming,
|
isSMSAlarming: updateCommunication.isSMSAlarming,
|
||||||
mobile: updateCommunication.mobile,
|
mobile: updateCommunication.mobile,
|
||||||
email: updateCommunication.email,
|
email: updateCommunication.email,
|
||||||
|
postalCode: updateCommunication.postalCode,
|
||||||
city: updateCommunication.city,
|
city: updateCommunication.city,
|
||||||
street: updateCommunication.street,
|
street: updateCommunication.street,
|
||||||
streetNumber: updateCommunication.streetNumber,
|
streetNumber: updateCommunication.streetNumber,
|
||||||
|
@ -82,13 +76,13 @@ export default abstract class CommunicationCommandHandler {
|
||||||
* @param DeleteCommunicationCommand
|
* @param DeleteCommunicationCommand
|
||||||
* @returns {Promise<void>}
|
* @returns {Promise<void>}
|
||||||
*/
|
*/
|
||||||
static async delete(deletCommunication: DeleteCommunicationCommand): Promise<void> {
|
static async delete(deleteCommunication: DeleteCommunicationCommand): Promise<void> {
|
||||||
return await dataSource
|
return await dataSource
|
||||||
.createQueryBuilder()
|
.createQueryBuilder()
|
||||||
.delete()
|
.delete()
|
||||||
.from(communication)
|
.from(communication)
|
||||||
.where("id = :id", { id: deletCommunication.id })
|
.where("id = :id", { id: deleteCommunication.id })
|
||||||
.andWhere("memberId = :memberId", { memberId: deletCommunication.memberId })
|
.andWhere("memberId = :memberId", { memberId: deleteCommunication.memberId })
|
||||||
.execute()
|
.execute()
|
||||||
.then(() => {})
|
.then(() => {})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
|
|
|
@ -20,16 +20,8 @@ export default abstract class MemberAwardCommandHandler {
|
||||||
given: createMemberAward.given,
|
given: createMemberAward.given,
|
||||||
note: createMemberAward.note,
|
note: createMemberAward.note,
|
||||||
date: createMemberAward.date,
|
date: createMemberAward.date,
|
||||||
member: await dataSource
|
memberId: createMemberAward.memberId,
|
||||||
.getRepository(member)
|
awardId: createMemberAward.awardId,
|
||||||
.createQueryBuilder("member")
|
|
||||||
.where("id = :id", { id: createMemberAward.memberId })
|
|
||||||
.getOneOrFail(),
|
|
||||||
award: await dataSource
|
|
||||||
.getRepository(award)
|
|
||||||
.createQueryBuilder("award")
|
|
||||||
.where("id = :id", { id: createMemberAward.awardId })
|
|
||||||
.getOneOrFail(),
|
|
||||||
})
|
})
|
||||||
.execute()
|
.execute()
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
|
@ -53,11 +45,7 @@ export default abstract class MemberAwardCommandHandler {
|
||||||
given: updateMemberAward.given,
|
given: updateMemberAward.given,
|
||||||
note: updateMemberAward.note,
|
note: updateMemberAward.note,
|
||||||
date: updateMemberAward.date,
|
date: updateMemberAward.date,
|
||||||
award: await dataSource
|
award: updateMemberAward.awardId,
|
||||||
.getRepository(award)
|
|
||||||
.createQueryBuilder("award")
|
|
||||||
.where("id = :id", { id: updateMemberAward.awardId })
|
|
||||||
.getOneOrFail(),
|
|
||||||
})
|
})
|
||||||
.where("id = :id", { id: updateMemberAward.id })
|
.where("id = :id", { id: updateMemberAward.id })
|
||||||
.andWhere("memberId = :memberId", { memberId: updateMemberAward.memberId })
|
.andWhere("memberId = :memberId", { memberId: updateMemberAward.memberId })
|
||||||
|
|
|
@ -24,16 +24,8 @@ export default abstract class MemberExecutivePositionCommandHandler {
|
||||||
note: createMemberExecutivePosition.note,
|
note: createMemberExecutivePosition.note,
|
||||||
start: createMemberExecutivePosition.start,
|
start: createMemberExecutivePosition.start,
|
||||||
end: createMemberExecutivePosition.end,
|
end: createMemberExecutivePosition.end,
|
||||||
member: await dataSource
|
memberId: createMemberExecutivePosition.memberId,
|
||||||
.getRepository(member)
|
executivePositionId: createMemberExecutivePosition.executivePositionId,
|
||||||
.createQueryBuilder("member")
|
|
||||||
.where("id = :id", { id: createMemberExecutivePosition.memberId })
|
|
||||||
.getOneOrFail(),
|
|
||||||
executivePosition: await dataSource
|
|
||||||
.getRepository(executivePosition)
|
|
||||||
.createQueryBuilder("executivePosition")
|
|
||||||
.where("id = :id", { id: createMemberExecutivePosition.executivePositionId })
|
|
||||||
.getOneOrFail(),
|
|
||||||
})
|
})
|
||||||
.execute()
|
.execute()
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
|
@ -57,11 +49,7 @@ export default abstract class MemberExecutivePositionCommandHandler {
|
||||||
note: updateMemberExecutivePosition.note,
|
note: updateMemberExecutivePosition.note,
|
||||||
start: updateMemberExecutivePosition.start,
|
start: updateMemberExecutivePosition.start,
|
||||||
end: updateMemberExecutivePosition.end,
|
end: updateMemberExecutivePosition.end,
|
||||||
executivePosition: await dataSource
|
executivePositionId: updateMemberExecutivePosition.executivePositionId,
|
||||||
.getRepository(executivePosition)
|
|
||||||
.createQueryBuilder("executivePosition")
|
|
||||||
.where("id = :id", { id: updateMemberExecutivePosition.executivePositionId })
|
|
||||||
.getOneOrFail(),
|
|
||||||
})
|
})
|
||||||
.where("id = :id", { id: updateMemberExecutivePosition.id })
|
.where("id = :id", { id: updateMemberExecutivePosition.id })
|
||||||
.andWhere("memberId = :memberId", { memberId: updateMemberExecutivePosition.memberId })
|
.andWhere("memberId = :memberId", { memberId: updateMemberExecutivePosition.memberId })
|
||||||
|
|
|
@ -23,16 +23,8 @@ export default abstract class MemberQualificationCommandHandler {
|
||||||
.values({
|
.values({
|
||||||
note: createMemberQualification.note,
|
note: createMemberQualification.note,
|
||||||
start: createMemberQualification.start,
|
start: createMemberQualification.start,
|
||||||
member: await dataSource
|
memberId: createMemberQualification.memberId,
|
||||||
.getRepository(member)
|
qualificationId: createMemberQualification.qualificationId,
|
||||||
.createQueryBuilder("member")
|
|
||||||
.where("id = :id", { id: createMemberQualification.memberId })
|
|
||||||
.getOneOrFail(),
|
|
||||||
qualification: await dataSource
|
|
||||||
.getRepository(qualification)
|
|
||||||
.createQueryBuilder("qualification")
|
|
||||||
.where("id = :id", { id: createMemberQualification.qualificationId })
|
|
||||||
.getOneOrFail(),
|
|
||||||
})
|
})
|
||||||
.execute()
|
.execute()
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
|
@ -57,11 +49,7 @@ export default abstract class MemberQualificationCommandHandler {
|
||||||
start: updateMemberQualification.start,
|
start: updateMemberQualification.start,
|
||||||
end: updateMemberQualification.end,
|
end: updateMemberQualification.end,
|
||||||
terminationReason: updateMemberQualification.terminationReason,
|
terminationReason: updateMemberQualification.terminationReason,
|
||||||
qualification: await dataSource
|
qualificationId: updateMemberQualification.qualificationId,
|
||||||
.getRepository(qualification)
|
|
||||||
.createQueryBuilder("qualification")
|
|
||||||
.where("id = :id", { id: updateMemberQualification.qualificationId })
|
|
||||||
.getOneOrFail(),
|
|
||||||
})
|
})
|
||||||
.where("id = :id", { id: updateMemberQualification.id })
|
.where("id = :id", { id: updateMemberQualification.id })
|
||||||
.andWhere("memberId = :memberId", { memberId: updateMemberQualification.memberId })
|
.andWhere("memberId = :memberId", { memberId: updateMemberQualification.memberId })
|
||||||
|
|
|
@ -21,16 +21,8 @@ export default abstract class MembershipCommandHandler {
|
||||||
.into(membership)
|
.into(membership)
|
||||||
.values({
|
.values({
|
||||||
start: createMembership.start,
|
start: createMembership.start,
|
||||||
member: await dataSource
|
memberId: createMembership.memberId,
|
||||||
.getRepository(member)
|
statusId: createMembership.statusId,
|
||||||
.createQueryBuilder("member")
|
|
||||||
.where("id = :id", { id: createMembership.memberId })
|
|
||||||
.getOneOrFail(),
|
|
||||||
status: await dataSource
|
|
||||||
.getRepository(membershipStatus)
|
|
||||||
.createQueryBuilder("membershipStatus")
|
|
||||||
.where("id = :id", { id: createMembership.statusId })
|
|
||||||
.getOneOrFail(),
|
|
||||||
})
|
})
|
||||||
.execute()
|
.execute()
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
|
@ -70,11 +62,7 @@ export default abstract class MembershipCommandHandler {
|
||||||
start: updateMembership.start,
|
start: updateMembership.start,
|
||||||
end: updateMembership.end,
|
end: updateMembership.end,
|
||||||
terminationReason: updateMembership.terminationReason,
|
terminationReason: updateMembership.terminationReason,
|
||||||
status: await dataSource
|
statusId: updateMembership.statusId,
|
||||||
.getRepository(membershipStatus)
|
|
||||||
.createQueryBuilder("membershipStatus")
|
|
||||||
.where("id = :id", { id: updateMembership.statusId })
|
|
||||||
.getOneOrFail(),
|
|
||||||
})
|
})
|
||||||
.where("id = :id", { id: updateMembership.id })
|
.where("id = :id", { id: updateMembership.id })
|
||||||
.andWhere("memberId = :memberId", { memberId: updateMembership.memberId })
|
.andWhere("memberId = :memberId", { memberId: updateMembership.memberId })
|
||||||
|
|
|
@ -351,6 +351,7 @@ export async function addCommunicationToMember(req: Request, res: Response): Pro
|
||||||
const isSMSAlarming = req.body.isSMSAlarming;
|
const isSMSAlarming = req.body.isSMSAlarming;
|
||||||
const mobile = req.body.mobile;
|
const mobile = req.body.mobile;
|
||||||
const email = req.body.email;
|
const email = req.body.email;
|
||||||
|
const postalCode = req.body.postalCode;
|
||||||
const city = req.body.city;
|
const city = req.body.city;
|
||||||
const street = req.body.street;
|
const street = req.body.street;
|
||||||
const streetNumber = req.body.streetNumber;
|
const streetNumber = req.body.streetNumber;
|
||||||
|
@ -363,6 +364,7 @@ export async function addCommunicationToMember(req: Request, res: Response): Pro
|
||||||
isSMSAlarming,
|
isSMSAlarming,
|
||||||
mobile,
|
mobile,
|
||||||
email,
|
email,
|
||||||
|
postalCode,
|
||||||
city,
|
city,
|
||||||
street,
|
street,
|
||||||
streetNumber,
|
streetNumber,
|
||||||
|
@ -535,11 +537,11 @@ export async function updateCommunicationOfMember(req: Request, res: Response):
|
||||||
const isSMSAlarming = req.body.isSMSAlarming;
|
const isSMSAlarming = req.body.isSMSAlarming;
|
||||||
const mobile = req.body.mobile;
|
const mobile = req.body.mobile;
|
||||||
const email = req.body.email;
|
const email = req.body.email;
|
||||||
|
const postalCode = req.body.postalCode;
|
||||||
const city = req.body.city;
|
const city = req.body.city;
|
||||||
const street = req.body.street;
|
const street = req.body.street;
|
||||||
const streetNumber = req.body.streetNumber;
|
const streetNumber = req.body.streetNumber;
|
||||||
const streetNumberAddition = req.body.streetNumberAddition;
|
const streetNumberAddition = req.body.streetNumberAddition;
|
||||||
const typeId = req.body.typeId;
|
|
||||||
const isNewsletterMain = req.body.isNewsletterMain;
|
const isNewsletterMain = req.body.isNewsletterMain;
|
||||||
|
|
||||||
let updateCommunication: UpdateCommunicationCommand = {
|
let updateCommunication: UpdateCommunicationCommand = {
|
||||||
|
@ -548,6 +550,7 @@ export async function updateCommunicationOfMember(req: Request, res: Response):
|
||||||
isSMSAlarming,
|
isSMSAlarming,
|
||||||
mobile,
|
mobile,
|
||||||
email,
|
email,
|
||||||
|
postalCode,
|
||||||
city,
|
city,
|
||||||
street,
|
street,
|
||||||
streetNumber,
|
streetNumber,
|
||||||
|
|
|
@ -63,6 +63,7 @@ import { newsletterConfig } from "./entity/newsletterConfig";
|
||||||
import { NewsletterConfig1735207446910 } from "./migrations/1735207446910-newsletterConfig";
|
import { NewsletterConfig1735207446910 } from "./migrations/1735207446910-newsletterConfig";
|
||||||
import { TemplateMargins1735733514043 } from "./migrations/1735733514043-templateMargins";
|
import { TemplateMargins1735733514043 } from "./migrations/1735733514043-templateMargins";
|
||||||
import { InternalId1735822722235 } from "./migrations/1735822722235-internalId";
|
import { InternalId1735822722235 } from "./migrations/1735822722235-internalId";
|
||||||
|
import { PostalCode1735927918979 } from "./migrations/1735927918979-postalCode";
|
||||||
|
|
||||||
const dataSource = new DataSource({
|
const dataSource = new DataSource({
|
||||||
type: DB_TYPE as any,
|
type: DB_TYPE as any,
|
||||||
|
@ -136,6 +137,7 @@ const dataSource = new DataSource({
|
||||||
NewsletterConfig1735207446910,
|
NewsletterConfig1735207446910,
|
||||||
TemplateMargins1735733514043,
|
TemplateMargins1735733514043,
|
||||||
InternalId1735822722235,
|
InternalId1735822722235,
|
||||||
|
PostalCode1735927918979,
|
||||||
],
|
],
|
||||||
migrationsRun: true,
|
migrationsRun: true,
|
||||||
migrationsTransactionMode: "each",
|
migrationsTransactionMode: "each",
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { Column, Entity, JoinColumn, ManyToOne, PrimaryColumn } from "typeorm";
|
import { Column, Entity, ManyToOne, PrimaryColumn } from "typeorm";
|
||||||
import { member } from "./member";
|
import { member } from "./member";
|
||||||
import { communicationType } from "./communicationType";
|
import { communicationType } from "./communicationType";
|
||||||
|
|
||||||
|
@ -19,6 +19,9 @@ export class communication {
|
||||||
@Column({ type: "varchar", length: 255, nullable: true })
|
@Column({ type: "varchar", length: 255, nullable: true })
|
||||||
email: string;
|
email: string;
|
||||||
|
|
||||||
|
@Column({ type: "varchar", length: 255, nullable: true })
|
||||||
|
postalCode: string;
|
||||||
|
|
||||||
@Column({ type: "varchar", length: 255, nullable: true })
|
@Column({ type: "varchar", length: 255, nullable: true })
|
||||||
city: string;
|
city: string;
|
||||||
|
|
||||||
|
@ -31,6 +34,12 @@ export class communication {
|
||||||
@Column({ type: "varchar", length: 255, nullable: true })
|
@Column({ type: "varchar", length: 255, nullable: true })
|
||||||
streetNumberAddition: string;
|
streetNumberAddition: string;
|
||||||
|
|
||||||
|
@Column()
|
||||||
|
memberId: number;
|
||||||
|
|
||||||
|
@Column()
|
||||||
|
typeId: number;
|
||||||
|
|
||||||
@ManyToOne(() => communicationType, (communicationType) => communicationType.communications, {
|
@ManyToOne(() => communicationType, (communicationType) => communicationType.communications, {
|
||||||
nullable: false,
|
nullable: false,
|
||||||
onDelete: "RESTRICT",
|
onDelete: "RESTRICT",
|
||||||
|
|
|
@ -14,6 +14,7 @@ export default abstract class CommunicationFactory {
|
||||||
preferred: record.preferred,
|
preferred: record.preferred,
|
||||||
mobile: record.mobile,
|
mobile: record.mobile,
|
||||||
email: record.email,
|
email: record.email,
|
||||||
|
postalCode: record.postalCode,
|
||||||
city: record.city,
|
city: record.city,
|
||||||
street: record.street,
|
street: record.street,
|
||||||
streetNumber: record.streetNumber,
|
streetNumber: record.streetNumber,
|
||||||
|
|
22
src/migrations/1735927918979-postalCode.ts
Normal file
22
src/migrations/1735927918979-postalCode.ts
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
import { MigrationInterface, QueryRunner, TableColumn } from "typeorm";
|
||||||
|
|
||||||
|
export class PostalCode1735927918979 implements MigrationInterface {
|
||||||
|
name = "PostalCode1735927918979";
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.addColumn(
|
||||||
|
"communication",
|
||||||
|
new TableColumn({
|
||||||
|
name: "postalCode",
|
||||||
|
type: "varchar",
|
||||||
|
length: "255",
|
||||||
|
default: null,
|
||||||
|
isNullable: true,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.dropColumn("communication", "postalCode");
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,8 +1,16 @@
|
||||||
export type CommunicationFieldType = "mobile" | "email" | "city" | "street" | "streetNumber" | "streetNumberAddition";
|
export type CommunicationFieldType =
|
||||||
|
| "mobile"
|
||||||
|
| "email"
|
||||||
|
| "postalCode"
|
||||||
|
| "city"
|
||||||
|
| "street"
|
||||||
|
| "streetNumber"
|
||||||
|
| "streetNumberAddition";
|
||||||
|
|
||||||
export const communicationFieldTypes: Array<CommunicationFieldType> = [
|
export const communicationFieldTypes: Array<CommunicationFieldType> = [
|
||||||
"mobile",
|
"mobile",
|
||||||
"email",
|
"email",
|
||||||
|
"postalCode",
|
||||||
"city",
|
"city",
|
||||||
"street",
|
"street",
|
||||||
"streetNumber",
|
"streetNumber",
|
||||||
|
|
|
@ -5,6 +5,7 @@ export interface CommunicationViewModel {
|
||||||
preferred: boolean;
|
preferred: boolean;
|
||||||
mobile: string;
|
mobile: string;
|
||||||
email: string;
|
email: string;
|
||||||
|
postalCode: string;
|
||||||
city: string;
|
city: string;
|
||||||
street: string;
|
street: string;
|
||||||
streetNumber: number;
|
streetNumber: number;
|
||||||
|
|
Loading…
Reference in a new issue