Merge pull request 'patches v1.0.1' (#38) from develop into main
Reviewed-on: #38
This commit is contained in:
commit
0f7516bd3d
7 changed files with 70 additions and 43 deletions
|
@ -48,8 +48,8 @@ import {
|
||||||
UpdateCommunicationCommand,
|
UpdateCommunicationCommand,
|
||||||
} from "../../../command/club/member/communicationCommand";
|
} from "../../../command/club/member/communicationCommand";
|
||||||
import CommunicationCommandHandler from "../../../command/club/member/communicationCommandHandler";
|
import CommunicationCommandHandler from "../../../command/club/member/communicationCommandHandler";
|
||||||
import {PdfExport} from "../../../helpers/pdfExport";
|
import { PdfExport } from "../../../helpers/pdfExport";
|
||||||
import {PermissionModule} from "../../../type/permissionTypes";
|
import { PermissionModule } from "../../../type/permissionTypes";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description get all members
|
* @description get all members
|
||||||
|
@ -227,14 +227,14 @@ export async function getCommunicationByMemberAndRecord(req: Request, res: Respo
|
||||||
* @returns {Promise<*>}
|
* @returns {Promise<*>}
|
||||||
*/
|
*/
|
||||||
export async function createMemberPrintoutList(req: Request, res: Response): Promise<any> {
|
export async function createMemberPrintoutList(req: Request, res: Response): Promise<any> {
|
||||||
let members = await MemberService.getByRunningMembership()
|
let members = await MemberService.getByRunningMembership();
|
||||||
|
|
||||||
let pdf = await PdfExport.renderFile({
|
let pdf = await PdfExport.renderFile({
|
||||||
title: "Mitgliederliste",
|
title: "Mitgliederliste",
|
||||||
template: "member.list",
|
template: "member.list",
|
||||||
saveToDisk: false,
|
saveToDisk: false,
|
||||||
data: {
|
data: {
|
||||||
member: members
|
member: members,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -596,7 +596,7 @@ export async function updateCommunicationOfMember(req: Request, res: Response):
|
||||||
communicationId: recordId,
|
communicationId: recordId,
|
||||||
};
|
};
|
||||||
await MemberCommandHandler.updateNewsletter(updateNewsletter);
|
await MemberCommandHandler.updateNewsletter(updateNewsletter);
|
||||||
} else if (currentUserNewsletterMain.sendNewsletter.id == recordId) {
|
} else if (currentUserNewsletterMain.sendNewsletter?.id == recordId) {
|
||||||
await MemberCommandHandler.unsetNewsletter(memberId);
|
await MemberCommandHandler.unsetNewsletter(memberId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,6 +66,7 @@ import { PostalCode1735927918979 } from "./migrations/1735927918979-postalCode";
|
||||||
import { ProtocolAbsent1736072179716 } from "./migrations/1736072179716-protocolAbsent";
|
import { ProtocolAbsent1736072179716 } from "./migrations/1736072179716-protocolAbsent";
|
||||||
import { Memberlist1736079005086 } from "./migrations/1736079005086-memberlist";
|
import { Memberlist1736079005086 } from "./migrations/1736079005086-memberlist";
|
||||||
import { ExtendViewValues1736084198860 } from "./migrations/1736084198860-extendViewValues";
|
import { ExtendViewValues1736084198860 } from "./migrations/1736084198860-extendViewValues";
|
||||||
|
import { FinishInternalIdTransfer1736505324488 } from "./migrations/1736505324488-finishInternalIdTransfer";
|
||||||
|
|
||||||
const dataSource = new DataSource({
|
const dataSource = new DataSource({
|
||||||
type: DB_TYPE as any,
|
type: DB_TYPE as any,
|
||||||
|
@ -142,6 +143,7 @@ const dataSource = new DataSource({
|
||||||
ProtocolAbsent1736072179716,
|
ProtocolAbsent1736072179716,
|
||||||
Memberlist1736079005086,
|
Memberlist1736079005086,
|
||||||
ExtendViewValues1736084198860,
|
ExtendViewValues1736084198860,
|
||||||
|
FinishInternalIdTransfer1736505324488,
|
||||||
],
|
],
|
||||||
migrationsRun: true,
|
migrationsRun: true,
|
||||||
migrationsTransactionMode: "each",
|
migrationsTransactionMode: "each",
|
||||||
|
|
|
@ -7,12 +7,6 @@ export class membership {
|
||||||
@PrimaryColumn({ generated: "increment", type: "int" })
|
@PrimaryColumn({ generated: "increment", type: "int" })
|
||||||
id: number;
|
id: number;
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
@Column({ type: "varchar", length: 255, unique: true, nullable: true })
|
|
||||||
internalId?: string;
|
|
||||||
|
|
||||||
@Column({ type: "date" })
|
@Column({ type: "date" })
|
||||||
start: Date;
|
start: Date;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import { Request, Response } from "express";
|
import { Request, Response } from "express";
|
||||||
import { ExceptionBase } from "../exceptions/exceptionsBaseType";
|
import { ExceptionBase } from "../exceptions/exceptionsBaseType";
|
||||||
import CustomRequestException from "../exceptions/customRequestException";
|
import CustomRequestException from "../exceptions/customRequestException";
|
||||||
|
import UnauthorizedRequestException from "../exceptions/unauthorizedRequestException";
|
||||||
|
|
||||||
export default function errorHandler(err: ExceptionBase | Error, req: Request, res: Response, next: Function) {
|
export default function errorHandler(err: ExceptionBase | Error, req: Request, res: Response, next: Function) {
|
||||||
let status = 500;
|
let status = 500;
|
||||||
|
@ -11,7 +12,11 @@ export default function errorHandler(err: ExceptionBase | Error, req: Request, r
|
||||||
msg = err.message;
|
msg = err.message;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("Handler", err);
|
if (err instanceof CustomRequestException) {
|
||||||
|
console.log("Custom Handler", status, msg);
|
||||||
|
} else {
|
||||||
|
console.log("Error Handler", err);
|
||||||
|
}
|
||||||
|
|
||||||
res.status(status).send(msg);
|
res.status(status).send(msg);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,27 +18,27 @@ export class InternalId1735822722235 implements MigrationInterface {
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
let memberships = await queryRunner.manager.getRepository(membership).find();
|
// let memberships = await queryRunner.manager.getRepository(membership).find();
|
||||||
console.log(memberships);
|
// console.log(memberships);
|
||||||
let internalIds = memberships.reduce<{ [key: number]: Array<string> }>((acc, cur) => {
|
// let internalIds = memberships.reduce<{ [key: number]: Array<string> }>((acc, cur) => {
|
||||||
let memberId = cur.memberId;
|
// let memberId = cur.memberId;
|
||||||
let setIds = acc[memberId] ?? [];
|
// let setIds = acc[memberId] ?? [];
|
||||||
if (cur?.internalId) {
|
// if (cur?.internalId) {
|
||||||
setIds.push(cur.internalId);
|
// setIds.push(cur.internalId);
|
||||||
}
|
// }
|
||||||
acc[memberId] = setIds;
|
// acc[memberId] = setIds;
|
||||||
return acc;
|
// return acc;
|
||||||
}, {});
|
// }, {});
|
||||||
|
|
||||||
console.log(internalIds);
|
// console.log(internalIds);
|
||||||
for (const [id, value] of Object.entries(internalIds)) {
|
// for (const [id, value] of Object.entries(internalIds)) {
|
||||||
const ids = value.filter((v) => v != null).join(", ");
|
// const ids = value.filter((v) => v != null).join(", ");
|
||||||
if (ids) {
|
// if (ids) {
|
||||||
let m = await queryRunner.manager.getRepository(member).findOneByOrFail({ id: parseInt(id) });
|
// let m = await queryRunner.manager.getRepository(member).findOneByOrFail({ id: parseInt(id) });
|
||||||
m.internalId = ids;
|
// m.internalId = ids;
|
||||||
await queryRunner.manager.getRepository(member).save(m);
|
// await queryRunner.manager.getRepository(member).save(m);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
|
23
src/migrations/1736505324488-finishInternalIdTransfer.ts
Normal file
23
src/migrations/1736505324488-finishInternalIdTransfer.ts
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
import { MigrationInterface, QueryRunner, TableColumn } from "typeorm";
|
||||||
|
|
||||||
|
export class FinishInternalIdTransfer1736505324488 implements MigrationInterface {
|
||||||
|
name = "FinishInternalIdTransfer1736505324488";
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.dropColumn("membership", "internalId");
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.addColumn(
|
||||||
|
"membership",
|
||||||
|
new TableColumn({
|
||||||
|
name: "internalId",
|
||||||
|
type: "varchar",
|
||||||
|
length: "255",
|
||||||
|
default: null,
|
||||||
|
isNullable: true,
|
||||||
|
isUnique: true,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -120,17 +120,20 @@ export default abstract class MemberService {
|
||||||
*/
|
*/
|
||||||
static async getByRunningMembership(): Promise<Array<member>> {
|
static async getByRunningMembership(): Promise<Array<member>> {
|
||||||
return await dataSource
|
return await dataSource
|
||||||
.getRepository(member)
|
.getRepository(member)
|
||||||
.createQueryBuilder("member")
|
.createQueryBuilder("member")
|
||||||
.leftJoinAndSelect("member.memberships", "membership")
|
.leftJoinAndSelect("member.memberships", "membership")
|
||||||
.where("membership.end IS NULL")
|
.where("membership.end IS NULL")
|
||||||
.getMany()
|
.orderBy("member.lastname")
|
||||||
.then((res) => {
|
.addOrderBy("member.firstname")
|
||||||
return res;
|
.addOrderBy("member.nameaffix")
|
||||||
})
|
.getMany()
|
||||||
.catch((err) => {
|
.then((res) => {
|
||||||
throw new InternalException("member not found by id", err);
|
return res;
|
||||||
});
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
throw new InternalException("member not found by id", err);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue