update database error messages
This commit is contained in:
parent
f89483f878
commit
f245ff74a8
72 changed files with 325 additions and 441 deletions
|
@ -1,6 +1,7 @@
|
|||
import { dataSource } from "../../../data-source";
|
||||
import { calendar } from "../../../entity/club/calendar";
|
||||
import { calendarType } from "../../../entity/settings/calendarType";
|
||||
import DatabaseActionException from "../../../exceptions/databaseActionException";
|
||||
import InternalException from "../../../exceptions/internalException";
|
||||
import { CreateCalendarCommand, DeleteCalendarCommand, UpdateCalendarCommand } from "./calendarCommand";
|
||||
|
||||
|
@ -33,7 +34,7 @@ export default abstract class CalendarCommandHandler {
|
|||
return result.identifiers[0].id;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("Failed creating calendar", err);
|
||||
throw new DatabaseActionException("CREATE", "calendar", err);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -72,7 +73,7 @@ export default abstract class CalendarCommandHandler {
|
|||
.execute()
|
||||
.then(() => {})
|
||||
.catch((err) => {
|
||||
throw new InternalException("Failed updating award", err);
|
||||
throw new DatabaseActionException("UPDATE", "calendar", err);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -90,7 +91,7 @@ export default abstract class CalendarCommandHandler {
|
|||
.execute()
|
||||
.then(() => {})
|
||||
.catch((err) => {
|
||||
throw new InternalException("Failed deleting calendar", err);
|
||||
throw new DatabaseActionException("DELETE", "calendar", err);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { dataSource } from "../../../data-source";
|
||||
import { communication } from "../../../entity/club/member/communication";
|
||||
import DatabaseActionException from "../../../exceptions/databaseActionException";
|
||||
import InternalException from "../../../exceptions/internalException";
|
||||
import {
|
||||
CreateCommunicationCommand,
|
||||
|
@ -54,7 +55,7 @@ export default abstract class CommunicationCommandHandler {
|
|||
return insertId;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("Failed creating communication", err);
|
||||
throw new DatabaseActionException("CREATE", "communication", err);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -97,7 +98,7 @@ export default abstract class CommunicationCommandHandler {
|
|||
})
|
||||
.then(() => {})
|
||||
.catch((err) => {
|
||||
throw new InternalException("Failed updating communication", err);
|
||||
throw new DatabaseActionException("UPDATE", "communication", err);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -116,7 +117,7 @@ export default abstract class CommunicationCommandHandler {
|
|||
.execute()
|
||||
.then(() => {})
|
||||
.catch((err) => {
|
||||
throw new InternalException("Failed deleting communication", err);
|
||||
throw new DatabaseActionException("DELETE", "communication", err);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { dataSource } from "../../../data-source";
|
||||
import { memberAwards } from "../../../entity/club/member/memberAwards";
|
||||
import DatabaseActionException from "../../../exceptions/databaseActionException";
|
||||
import InternalException from "../../../exceptions/internalException";
|
||||
import { CreateMemberAwardCommand, DeleteMemberAwardCommand, UpdateMemberAwardCommand } from "./memberAwardCommand";
|
||||
|
||||
|
@ -26,7 +27,7 @@ export default abstract class MemberAwardCommandHandler {
|
|||
return result.identifiers[0].id;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("Failed creating memberAward", err);
|
||||
throw new DatabaseActionException("CREATE", "memberAward", err);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -50,7 +51,7 @@ export default abstract class MemberAwardCommandHandler {
|
|||
.execute()
|
||||
.then(() => {})
|
||||
.catch((err) => {
|
||||
throw new InternalException("Failed updating memberAward", err);
|
||||
throw new DatabaseActionException("UPDATE", "memberAward", err);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -69,7 +70,7 @@ export default abstract class MemberAwardCommandHandler {
|
|||
.execute()
|
||||
.then(() => {})
|
||||
.catch((err) => {
|
||||
throw new InternalException("Failed deleting memberAward", err);
|
||||
throw new DatabaseActionException("DELETE", "memberAward", err);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { dataSource } from "../../../data-source";
|
||||
import { communication } from "../../../entity/club/member/communication";
|
||||
import { member } from "../../../entity/club/member/member";
|
||||
import DatabaseActionException from "../../../exceptions/databaseActionException";
|
||||
import InternalException from "../../../exceptions/internalException";
|
||||
import { CreateMemberCommand, DeleteMemberCommand, UpdateMemberCommand } from "./memberCommand";
|
||||
|
||||
|
@ -28,10 +29,7 @@ export default abstract class MemberCommandHandler {
|
|||
return result.identifiers[0].id;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException(
|
||||
`Failed creating member${err.code.includes("ER_DUP_ENTRY") ? " due to duplicate entry for column" : ""}`,
|
||||
err
|
||||
);
|
||||
throw new DatabaseActionException("CREATE", "member", err);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -56,10 +54,7 @@ export default abstract class MemberCommandHandler {
|
|||
.execute()
|
||||
.then(() => {})
|
||||
.catch((err) => {
|
||||
throw new InternalException(
|
||||
`Failed updating member${err.code.includes("ER_DUP_ENTRY") ? " due to duplicate entry for column" : ""}`,
|
||||
err
|
||||
);
|
||||
throw new DatabaseActionException("UPDATE", "member", err);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -77,7 +72,7 @@ export default abstract class MemberCommandHandler {
|
|||
.execute()
|
||||
.then(() => {})
|
||||
.catch((err) => {
|
||||
throw new InternalException("Failed deleting member", err);
|
||||
throw new DatabaseActionException("DELETE", "member", err);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { dataSource } from "../../../data-source";
|
||||
import { memberExecutivePositions } from "../../../entity/club/member/memberExecutivePositions";
|
||||
import DatabaseActionException from "../../../exceptions/databaseActionException";
|
||||
import InternalException from "../../../exceptions/internalException";
|
||||
import {
|
||||
CreateMemberExecutivePositionCommand,
|
||||
|
@ -30,7 +31,7 @@ export default abstract class MemberExecutivePositionCommandHandler {
|
|||
return result.identifiers[0].id;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("Failed creating memberExecutivePosition", err);
|
||||
throw new DatabaseActionException("CREATE", "memberExecutivePosition", err);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -54,7 +55,7 @@ export default abstract class MemberExecutivePositionCommandHandler {
|
|||
.execute()
|
||||
.then(() => {})
|
||||
.catch((err) => {
|
||||
throw new InternalException("Failed updating memberExecutivePosition", err);
|
||||
throw new DatabaseActionException("UPDATE", "memberExecutivePosition", err);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -73,7 +74,7 @@ export default abstract class MemberExecutivePositionCommandHandler {
|
|||
.execute()
|
||||
.then(() => {})
|
||||
.catch((err) => {
|
||||
throw new InternalException("Failed deleting memberExecutivePosition", err);
|
||||
throw new DatabaseActionException("DELETE", "memberExecutivePosition", err);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { dataSource } from "../../../data-source";
|
||||
import { memberQualifications } from "../../../entity/club/member/memberQualifications";
|
||||
import DatabaseActionException from "../../../exceptions/databaseActionException";
|
||||
import InternalException from "../../../exceptions/internalException";
|
||||
import {
|
||||
CreateMemberQualificationCommand,
|
||||
|
@ -29,7 +30,7 @@ export default abstract class MemberQualificationCommandHandler {
|
|||
return result.identifiers[0].id;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("Failed creating memberQualification", err);
|
||||
throw new DatabaseActionException("CREATE", "memberQualification", err);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -54,7 +55,7 @@ export default abstract class MemberQualificationCommandHandler {
|
|||
.execute()
|
||||
.then(() => {})
|
||||
.catch((err) => {
|
||||
throw new InternalException("Failed updating memberQualification", err);
|
||||
throw new DatabaseActionException("UPDATE", "memberQualification", err);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -73,7 +74,7 @@ export default abstract class MemberQualificationCommandHandler {
|
|||
.execute()
|
||||
.then(() => {})
|
||||
.catch((err) => {
|
||||
throw new InternalException("Failed deleting memberQualification", err);
|
||||
throw new DatabaseActionException("DELETE", "memberQualification", err);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { dataSource } from "../../../data-source";
|
||||
import { membership } from "../../../entity/club/member/membership";
|
||||
import DatabaseActionException from "../../../exceptions/databaseActionException";
|
||||
import InternalException from "../../../exceptions/internalException";
|
||||
import { CreateMembershipCommand, DeleteMembershipCommand, UpdateMembershipCommand } from "./membershipCommand";
|
||||
|
||||
|
@ -43,7 +44,7 @@ export default abstract class MembershipCommandHandler {
|
|||
return insertId;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("Failed creating membership", err);
|
||||
throw new DatabaseActionException("CREATE", "membership", err);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -67,7 +68,7 @@ export default abstract class MembershipCommandHandler {
|
|||
.execute()
|
||||
.then(() => {})
|
||||
.catch((err) => {
|
||||
throw new InternalException("Failed updating membership", err);
|
||||
throw new DatabaseActionException("UPDATE", "membership", err);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -86,7 +87,7 @@ export default abstract class MembershipCommandHandler {
|
|||
.execute()
|
||||
.then(() => {})
|
||||
.catch((err) => {
|
||||
throw new InternalException("Failed deleting membership", err);
|
||||
throw new DatabaseActionException("DELETE", "membership", err);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { dataSource } from "../../../data-source";
|
||||
import { newsletter } from "../../../entity/club/newsletter/newsletter";
|
||||
import DatabaseActionException from "../../../exceptions/databaseActionException";
|
||||
import InternalException from "../../../exceptions/internalException";
|
||||
import { CreateNewsletterCommand, SendNewsletterCommand, SynchronizeNewsletterCommand } from "./newsletterCommand";
|
||||
|
||||
|
@ -22,7 +23,7 @@ export default abstract class NewsletterCommandHandler {
|
|||
return result.identifiers[0].id;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("Failed creating newsletter", err);
|
||||
throw new DatabaseActionException("CREATE", "newsletter", err);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -47,7 +48,7 @@ export default abstract class NewsletterCommandHandler {
|
|||
.execute()
|
||||
.then(() => {})
|
||||
.catch((err) => {
|
||||
throw new InternalException("Failed synching newsletter", err);
|
||||
throw new DatabaseActionException("SYNC", "newsletter", err);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -67,7 +68,7 @@ export default abstract class NewsletterCommandHandler {
|
|||
.execute()
|
||||
.then(() => {})
|
||||
.catch((err) => {
|
||||
throw new InternalException("Failed setting newsletter send state", err);
|
||||
throw new DatabaseActionException("SET SEND STATE", "newsletter", err);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import InternalException from "../../../exceptions/internalException";
|
|||
import NewsletterDatesService from "../../../service/club/newsletter/newsletterDatesService";
|
||||
import { NewsletterDateCommand, SynchronizeNewsletterDatesCommand } from "./newsletterDatesCommand";
|
||||
import { newsletterDates } from "../../../entity/club/newsletter/newsletterDates";
|
||||
import DatabaseActionException from "../../../exceptions/databaseActionException";
|
||||
|
||||
export default abstract class NewsletterDatesCommandHandler {
|
||||
/**
|
||||
|
@ -42,7 +43,7 @@ export default abstract class NewsletterDatesCommandHandler {
|
|||
})
|
||||
.then(() => {})
|
||||
.catch((err) => {
|
||||
throw new InternalException("Failed syncing newsletter dates", err);
|
||||
throw new DatabaseActionException("SYNC", "newsletterDates", err);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import InternalException from "../../../exceptions/internalException";
|
|||
import NewsletterRecipientsService from "../../../service/club/newsletter/newsletterRecipientsService";
|
||||
import { SynchronizeNewsletterRecipientsCommand } from "./newsletterRecipientsCommand";
|
||||
import { newsletterRecipients } from "../../../entity/club/newsletter/newsletterRecipients";
|
||||
import DatabaseActionException from "../../../exceptions/databaseActionException";
|
||||
|
||||
export default abstract class NewsletterRecipientsCommandHandler {
|
||||
/**
|
||||
|
@ -35,7 +36,7 @@ export default abstract class NewsletterRecipientsCommandHandler {
|
|||
})
|
||||
.then(() => {})
|
||||
.catch((err) => {
|
||||
throw new InternalException("Failed syncing newsletter recipients", err);
|
||||
throw new DatabaseActionException("SYNC", "newsletterRecipients", err);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { dataSource } from "../../../data-source";
|
||||
import { protocolAgenda } from "../../../entity/club/protocol/protocolAgenda";
|
||||
import DatabaseActionException from "../../../exceptions/databaseActionException";
|
||||
import InternalException from "../../../exceptions/internalException";
|
||||
import { SynchronizeProtocolAgendaCommand } from "./protocolAgendaCommand";
|
||||
|
||||
|
@ -24,7 +25,7 @@ export default abstract class ProtocolAgendaCommandHandler {
|
|||
return result.identifiers[0].id;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("Failed creating protocol", err);
|
||||
throw new DatabaseActionException("CREATE", "protocolAgenda", err);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -43,7 +44,7 @@ export default abstract class ProtocolAgendaCommandHandler {
|
|||
.execute()
|
||||
.then(() => {})
|
||||
.catch((err) => {
|
||||
throw new InternalException("Failed creating protocol", err);
|
||||
throw new DatabaseActionException("SYNC", "protocolAgenda", err);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { dataSource } from "../../../data-source";
|
||||
import { protocol } from "../../../entity/club/protocol/protocol";
|
||||
import DatabaseActionException from "../../../exceptions/databaseActionException";
|
||||
import InternalException from "../../../exceptions/internalException";
|
||||
import { CreateProtocolCommand, SynchronizeProtocolCommand } from "./protocolCommand";
|
||||
|
||||
|
@ -23,7 +24,7 @@ export default abstract class ProtocolCommandHandler {
|
|||
return result.identifiers[0].id;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("Failed creating protocol", err);
|
||||
throw new DatabaseActionException("CREATE", "protocol", err);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -47,7 +48,7 @@ export default abstract class ProtocolCommandHandler {
|
|||
.execute()
|
||||
.then(() => {})
|
||||
.catch((err) => {
|
||||
throw new InternalException("Failed creating protocol", err);
|
||||
throw new DatabaseActionException("SYNC", "protocol", err);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { dataSource } from "../../../data-source";
|
||||
import { protocolDecision } from "../../../entity/club/protocol/protocolDecision";
|
||||
import DatabaseActionException from "../../../exceptions/databaseActionException";
|
||||
import InternalException from "../../../exceptions/internalException";
|
||||
import { SynchronizeProtocolDecisionCommand } from "./protocolDecisionCommand";
|
||||
|
||||
|
@ -24,7 +25,7 @@ export default abstract class ProtocolDecisionCommandHandler {
|
|||
return result.identifiers[0].id;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("Failed creating protocol", err);
|
||||
throw new DatabaseActionException("CREATE", "protocolDecision", err);
|
||||
});
|
||||
}
|
||||
/**
|
||||
|
@ -42,7 +43,7 @@ export default abstract class ProtocolDecisionCommandHandler {
|
|||
.execute()
|
||||
.then(() => {})
|
||||
.catch((err) => {
|
||||
throw new InternalException("Failed creating protocol", err);
|
||||
throw new DatabaseActionException("SYNC", "protocolDecision", err);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import { protocolPresence } from "../../../entity/club/protocol/protocolPresence
|
|||
import InternalException from "../../../exceptions/internalException";
|
||||
import ProtocolPresenceService from "../../../service/club/protocol/protocolPrecenseService";
|
||||
import { ProtocolPresenceCommand, SynchronizeProtocolPresenceCommand } from "./protocolPresenceCommand";
|
||||
import DatabaseActionException from "../../../exceptions/databaseActionException";
|
||||
|
||||
export default abstract class ProtocolPresenceCommandHandler {
|
||||
/**
|
||||
|
@ -42,7 +43,7 @@ export default abstract class ProtocolPresenceCommandHandler {
|
|||
})
|
||||
.then(() => {})
|
||||
.catch((err) => {
|
||||
throw new InternalException("Failed saving protocol presence", err);
|
||||
throw new DatabaseActionException("SYNC", "protocolSresence", err);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { dataSource } from "../../../data-source";
|
||||
import { protocolPrintout } from "../../../entity/club/protocol/protocolPrintout";
|
||||
import DatabaseActionException from "../../../exceptions/databaseActionException";
|
||||
import InternalException from "../../../exceptions/internalException";
|
||||
import { CreateProtocolPrintoutCommand } from "./protocolPrintoutCommand";
|
||||
|
||||
|
@ -25,7 +26,7 @@ export default abstract class ProtocolPrintoutCommandHandler {
|
|||
return result.identifiers[0].id;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("Failed creating protocol", err);
|
||||
throw new DatabaseActionException("CREATE", "protocolPrintout", err);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { dataSource } from "../../../data-source";
|
||||
import { protocolVoting } from "../../../entity/club/protocol/protocolVoting";
|
||||
import DatabaseActionException from "../../../exceptions/databaseActionException";
|
||||
import InternalException from "../../../exceptions/internalException";
|
||||
import { SynchronizeProtocolVotingCommand } from "./protocolVotingCommand";
|
||||
|
||||
|
@ -24,7 +25,7 @@ export default abstract class ProtocolVotingCommandHandler {
|
|||
return result.identifiers[0].id;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("Failed creating protocol", err);
|
||||
throw new DatabaseActionException("CREATE", "protocolVoting", err);
|
||||
});
|
||||
}
|
||||
/**
|
||||
|
@ -42,7 +43,7 @@ export default abstract class ProtocolVotingCommandHandler {
|
|||
.execute()
|
||||
.then(() => {})
|
||||
.catch((err) => {
|
||||
throw new InternalException("Failed creating protocol", err);
|
||||
throw new DatabaseActionException("SYNC", "protocolVoting", err);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { dataSource } from "../data-source";
|
||||
import { refresh } from "../entity/refresh";
|
||||
import { PWA_REFRESH_EXPIRATION, REFRESH_EXPIRATION } from "../env.defaults";
|
||||
import DatabaseActionException from "../exceptions/databaseActionException";
|
||||
import InternalException from "../exceptions/internalException";
|
||||
import { StringHelper } from "../helpers/stringHelper";
|
||||
import UserService from "../service/user/userService";
|
||||
|
@ -32,7 +33,7 @@ export default abstract class RefreshCommandHandler {
|
|||
return refreshToken;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("Failed saving refresh token", err);
|
||||
throw new DatabaseActionException("CREATE", "refresh", err);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -51,7 +52,7 @@ export default abstract class RefreshCommandHandler {
|
|||
.execute()
|
||||
.then((res) => {})
|
||||
.catch((err) => {
|
||||
throw new InternalException("failed refresh removal", err);
|
||||
throw new DatabaseActionException("DELETE", "refresh", err);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -68,7 +69,7 @@ export default abstract class RefreshCommandHandler {
|
|||
.execute()
|
||||
.then((res) => {})
|
||||
.catch((err) => {
|
||||
throw new InternalException("failed expired refresh removal", err);
|
||||
throw new DatabaseActionException("DELETE", "refresh", err);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { dataSource } from "../data-source";
|
||||
import { reset } from "../entity/reset";
|
||||
import DatabaseActionException from "../exceptions/databaseActionException";
|
||||
import InternalException from "../exceptions/internalException";
|
||||
import { StringHelper } from "../helpers/stringHelper";
|
||||
import { CreateResetCommand, DeleteResetCommand } from "./resetCommand";
|
||||
|
@ -29,7 +30,7 @@ export default abstract class ResetCommandHandler {
|
|||
return token;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("Failed saving reset", err);
|
||||
throw new DatabaseActionException("CREATE", "reset", err);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -48,7 +49,7 @@ export default abstract class ResetCommandHandler {
|
|||
.execute()
|
||||
.then((res) => {})
|
||||
.catch((err) => {
|
||||
throw new InternalException("failed reset removal", err);
|
||||
throw new DatabaseActionException("DELETE", "reset", err);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { dataSource } from "../../../data-source";
|
||||
import { award } from "../../../entity/settings/award";
|
||||
import DatabaseActionException from "../../../exceptions/databaseActionException";
|
||||
import InternalException from "../../../exceptions/internalException";
|
||||
import { CreateAwardCommand, DeleteAwardCommand, UpdateAwardCommand } from "./awardCommand";
|
||||
|
||||
|
@ -22,7 +23,7 @@ export default abstract class AwardCommandHandler {
|
|||
return result.identifiers[0].id;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("Failed creating award", err);
|
||||
throw new DatabaseActionException("CREATE", "award", err);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -42,7 +43,7 @@ export default abstract class AwardCommandHandler {
|
|||
.execute()
|
||||
.then(() => {})
|
||||
.catch((err) => {
|
||||
throw new InternalException("Failed updating award", err);
|
||||
throw new DatabaseActionException("UPDATE", "award", err);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -60,10 +61,7 @@ export default abstract class AwardCommandHandler {
|
|||
.execute()
|
||||
.then(() => {})
|
||||
.catch((err) => {
|
||||
throw new InternalException(
|
||||
`Failed deleting award ${err.code.includes("ER_ROW_IS_REFERENCED") ? " due to referenced data" : ""}`,
|
||||
err
|
||||
);
|
||||
throw new DatabaseActionException("DELETE", "award", err);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { dataSource } from "../../../data-source";
|
||||
import { calendarType } from "../../../entity/settings/calendarType";
|
||||
import DatabaseActionException from "../../../exceptions/databaseActionException";
|
||||
import InternalException from "../../../exceptions/internalException";
|
||||
import { CreateCalendarTypeCommand, DeleteCalendarTypeCommand, UpdateCalendarTypeCommand } from "./calendarTypeCommand";
|
||||
|
||||
|
@ -25,7 +26,7 @@ export default abstract class CalendarTypeCommandHandler {
|
|||
return result.identifiers[0].id;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("Failed creating calendarType", err);
|
||||
throw new DatabaseActionException("CREATE", "calendarType", err);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -48,7 +49,7 @@ export default abstract class CalendarTypeCommandHandler {
|
|||
.execute()
|
||||
.then(() => {})
|
||||
.catch((err) => {
|
||||
throw new InternalException("Failed updating award", err);
|
||||
throw new DatabaseActionException("UPDATE", "calenarType", err);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -66,10 +67,7 @@ export default abstract class CalendarTypeCommandHandler {
|
|||
.execute()
|
||||
.then(() => {})
|
||||
.catch((err) => {
|
||||
throw new InternalException(
|
||||
`Failed deleting calendarType${err.code.includes("ER_ROW_IS_REFERENCED") ? " due to referenced data" : ""}`,
|
||||
err
|
||||
);
|
||||
throw new DatabaseActionException("DELETE", "calendarType", err);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { dataSource } from "../../../data-source";
|
||||
import { communicationType } from "../../../entity/settings/communicationType";
|
||||
import DatabaseActionException from "../../../exceptions/databaseActionException";
|
||||
import InternalException from "../../../exceptions/internalException";
|
||||
import {
|
||||
CreateCommunicationTypeCommand,
|
||||
|
@ -27,7 +28,7 @@ export default abstract class CommunicationTypeCommandHandler {
|
|||
return result.identifiers[0].id;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("Failed creating communicationType", err);
|
||||
throw new DatabaseActionException("CREATE", "communicationType", err);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -48,7 +49,7 @@ export default abstract class CommunicationTypeCommandHandler {
|
|||
.execute()
|
||||
.then(() => {})
|
||||
.catch((err) => {
|
||||
throw new InternalException("Failed updating communicationType", err);
|
||||
throw new DatabaseActionException("UPDATE", "communicationType", err);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -66,12 +67,7 @@ export default abstract class CommunicationTypeCommandHandler {
|
|||
.execute()
|
||||
.then(() => {})
|
||||
.catch((err) => {
|
||||
throw new InternalException(
|
||||
`Failed deleting communicationType${
|
||||
err.code.includes("ER_ROW_IS_REFERENCED") ? " due to referenced data" : ""
|
||||
}`,
|
||||
err
|
||||
);
|
||||
throw new DatabaseActionException("DELETE", "communicationType", err);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { dataSource } from "../../../data-source";
|
||||
import { executivePosition } from "../../../entity/settings/executivePosition";
|
||||
import DatabaseActionException from "../../../exceptions/databaseActionException";
|
||||
import InternalException from "../../../exceptions/internalException";
|
||||
import {
|
||||
CreateExecutivePositionCommand,
|
||||
|
@ -26,7 +27,7 @@ export default abstract class ExecutivePositionCommandHandler {
|
|||
return result.identifiers[0].id;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("Failed creating executivePosition", err);
|
||||
throw new DatabaseActionException("DELETE", "executivePosition", err);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -46,7 +47,7 @@ export default abstract class ExecutivePositionCommandHandler {
|
|||
.execute()
|
||||
.then(() => {})
|
||||
.catch((err) => {
|
||||
throw new InternalException("Failed updating executivePosition", err);
|
||||
throw new DatabaseActionException("UPDATE", "executivePosition", err);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -64,12 +65,7 @@ export default abstract class ExecutivePositionCommandHandler {
|
|||
.execute()
|
||||
.then(() => {})
|
||||
.catch((err) => {
|
||||
throw new InternalException(
|
||||
`Failed deleting executivePosition${
|
||||
err.code.includes("ER_ROW_IS_REFERENCED") ? " due to referenced data" : ""
|
||||
}`,
|
||||
err
|
||||
);
|
||||
throw new DatabaseActionException("DELETE", "executivePosition", err);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { dataSource } from "../../../data-source";
|
||||
import { membershipStatus } from "../../../entity/settings/membershipStatus";
|
||||
import DatabaseActionException from "../../../exceptions/databaseActionException";
|
||||
import InternalException from "../../../exceptions/internalException";
|
||||
import {
|
||||
CreateMembershipStatusCommand,
|
||||
|
@ -26,7 +27,7 @@ export default abstract class MembershipStatusCommandHandler {
|
|||
return result.identifiers[0].id;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("Failed creating membershipStatus", err);
|
||||
throw new DatabaseActionException("CREATING", "membershipStatus", err);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -46,7 +47,7 @@ export default abstract class MembershipStatusCommandHandler {
|
|||
.execute()
|
||||
.then(() => {})
|
||||
.catch((err) => {
|
||||
throw new InternalException("Failed updating membershipStatus", err);
|
||||
throw new DatabaseActionException("UPDATE", "membershipStatus", err);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -64,12 +65,7 @@ export default abstract class MembershipStatusCommandHandler {
|
|||
.execute()
|
||||
.then(() => {})
|
||||
.catch((err) => {
|
||||
throw new InternalException(
|
||||
`Failed deleting membershipStatus${
|
||||
err.code.includes("ER_ROW_IS_REFERENCED") ? " due to referenced data" : ""
|
||||
}`,
|
||||
err
|
||||
);
|
||||
throw new DatabaseActionException("DELETE", "membershipStatus", err);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { dataSource } from "../../../data-source";
|
||||
import { newsletterConfig } from "../../../entity/settings/newsletterConfig";
|
||||
import DatabaseActionException from "../../../exceptions/databaseActionException";
|
||||
import InternalException from "../../../exceptions/internalException";
|
||||
import { SetNewsletterConfigCommand } from "./newsletterConfigCommand";
|
||||
|
||||
|
@ -24,7 +25,7 @@ export default abstract class NewsletterConfigCommandHandler {
|
|||
return result.identifiers[0].id;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("Failed setting newsletterConfig", err);
|
||||
throw new DatabaseActionException("SET", "newsletterConfig", err);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { dataSource } from "../../../data-source";
|
||||
import { qualification } from "../../../entity/settings/qualification";
|
||||
import DatabaseActionException from "../../../exceptions/databaseActionException";
|
||||
import InternalException from "../../../exceptions/internalException";
|
||||
import {
|
||||
CreateQualificationCommand,
|
||||
|
@ -27,7 +28,7 @@ export default abstract class QualificationCommandHandler {
|
|||
return result.identifiers[0].id;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("Failed creating qualification", err);
|
||||
throw new DatabaseActionException("CREATE", "qualification", err);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -48,7 +49,7 @@ export default abstract class QualificationCommandHandler {
|
|||
.execute()
|
||||
.then(() => {})
|
||||
.catch((err) => {
|
||||
throw new InternalException("Failed updating qualification", err);
|
||||
throw new DatabaseActionException("UPDATE", "qualification", err);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -66,10 +67,7 @@ export default abstract class QualificationCommandHandler {
|
|||
.execute()
|
||||
.then(() => {})
|
||||
.catch((err) => {
|
||||
throw new InternalException(
|
||||
`Failed deleting qualification${err.code.includes("ER_ROW_IS_REFERENCED") ? " due to referenced data" : ""}`,
|
||||
err
|
||||
);
|
||||
throw new DatabaseActionException("DELETE", "qualification", err);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { dataSource } from "../../../data-source";
|
||||
import { query } from "../../../entity/settings/query";
|
||||
import DatabaseActionException from "../../../exceptions/databaseActionException";
|
||||
import InternalException from "../../../exceptions/internalException";
|
||||
import { CreateQueryStoreCommand, DeleteQueryStoreCommand, UpdateQueryStoreCommand } from "./queryStoreCommand";
|
||||
|
||||
|
@ -24,7 +25,7 @@ export default abstract class QueryStoreCommandHandler {
|
|||
return result.identifiers[0].id;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("Failed creating queryStore", err);
|
||||
throw new DatabaseActionException("CREATE", "queryStore", err);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -45,7 +46,7 @@ export default abstract class QueryStoreCommandHandler {
|
|||
.execute()
|
||||
.then(() => {})
|
||||
.catch((err) => {
|
||||
throw new InternalException("Failed updating queryStore", err);
|
||||
throw new DatabaseActionException("UPDATE", "queryStore", err);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -63,10 +64,7 @@ export default abstract class QueryStoreCommandHandler {
|
|||
.execute()
|
||||
.then(() => {})
|
||||
.catch((err) => {
|
||||
throw new InternalException(
|
||||
`Failed deleting queryStore${err.code.includes("ER_ROW_IS_REFERENCED") ? " due to referenced data" : ""}`,
|
||||
err
|
||||
);
|
||||
throw new DatabaseActionException("DELETE", "queryStore", err);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { dataSource } from "../../../data-source";
|
||||
import { salutation } from "../../../entity/settings/salutation";
|
||||
import DatabaseActionException from "../../../exceptions/databaseActionException";
|
||||
import InternalException from "../../../exceptions/internalException";
|
||||
import { CreateSalutationCommand, DeleteSalutationCommand, UpdateSalutationCommand } from "./salutationCommand";
|
||||
|
||||
|
@ -22,7 +23,7 @@ export default abstract class SalutationCommandHandler {
|
|||
return result.identifiers[0].id;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("Failed creating salutation", err);
|
||||
throw new DatabaseActionException("CREATE", "salutation", err);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -42,7 +43,7 @@ export default abstract class SalutationCommandHandler {
|
|||
.execute()
|
||||
.then(() => {})
|
||||
.catch((err) => {
|
||||
throw new InternalException("Failed updating salutation", err);
|
||||
throw new DatabaseActionException("UPDATE", "salutation", err);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -60,10 +61,7 @@ export default abstract class SalutationCommandHandler {
|
|||
.execute()
|
||||
.then(() => {})
|
||||
.catch((err) => {
|
||||
throw new InternalException(
|
||||
`Failed deleting salutation ${err.code.includes("ER_ROW_IS_REFERENCED") ? " due to referenced data" : ""}`,
|
||||
err
|
||||
);
|
||||
throw new DatabaseActionException("DELETE", "salutation", err);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { dataSource } from "../../../data-source";
|
||||
import { template } from "../../../entity/settings/template";
|
||||
import DatabaseActionException from "../../../exceptions/databaseActionException";
|
||||
import InternalException from "../../../exceptions/internalException";
|
||||
import { CreateTemplateCommand, DeleteTemplateCommand, UpdateTemplateCommand } from "./templateCommand";
|
||||
|
||||
|
@ -23,7 +24,7 @@ export default abstract class TemplateCommandHandler {
|
|||
return result.identifiers[0].id;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("Failed creating template", err);
|
||||
throw new DatabaseActionException("CREATE", "template", err);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -46,7 +47,7 @@ export default abstract class TemplateCommandHandler {
|
|||
.execute()
|
||||
.then(() => {})
|
||||
.catch((err) => {
|
||||
throw new InternalException("Failed updating template", err);
|
||||
throw new DatabaseActionException("UPDATE", "template", err);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -64,10 +65,7 @@ export default abstract class TemplateCommandHandler {
|
|||
.execute()
|
||||
.then(() => {})
|
||||
.catch((err) => {
|
||||
throw new InternalException(
|
||||
`Failed deleting template${err.code.includes("ER_ROW_IS_REFERENCED") ? " due to referenced data" : ""}`,
|
||||
err
|
||||
);
|
||||
throw new DatabaseActionException("DELETE", "template", err);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { dataSource } from "../../../data-source";
|
||||
import { templateUsage } from "../../../entity/settings/templateUsage";
|
||||
import DatabaseActionException from "../../../exceptions/databaseActionException";
|
||||
import InternalException from "../../../exceptions/internalException";
|
||||
import { UpdateTemplateUsageCommand } from "./templateUsageCommand";
|
||||
|
||||
|
@ -24,7 +25,7 @@ export default abstract class TemplateUsageCommandHandler {
|
|||
.execute()
|
||||
.then(() => {})
|
||||
.catch((err) => {
|
||||
throw new InternalException("Failed updating templateUsage", err);
|
||||
throw new DatabaseActionException("SET", "templateUsage", err);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { dataSource } from "../../../data-source";
|
||||
import { role } from "../../../entity/user/role";
|
||||
import DatabaseActionException from "../../../exceptions/databaseActionException";
|
||||
import InternalException from "../../../exceptions/internalException";
|
||||
import { CreateRoleCommand, DeleteRoleCommand, UpdateRoleCommand } from "./roleCommand";
|
||||
|
||||
|
@ -22,7 +23,7 @@ export default abstract class RoleCommandHandler {
|
|||
return result.identifiers[0].id;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("Failed creating role", err);
|
||||
throw new DatabaseActionException("CREATE", "role", err);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -42,7 +43,7 @@ export default abstract class RoleCommandHandler {
|
|||
.execute()
|
||||
.then(() => {})
|
||||
.catch((err) => {
|
||||
throw new InternalException("Failed updating role", err);
|
||||
throw new DatabaseActionException("UPDATE", "role", err);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -60,7 +61,7 @@ export default abstract class RoleCommandHandler {
|
|||
.execute()
|
||||
.then(() => {})
|
||||
.catch((err) => {
|
||||
throw new InternalException("Failed deleting role", err);
|
||||
throw new DatabaseActionException("DELETE", "role", err);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import {
|
|||
import PermissionHelper from "../../../helpers/permissionHelper";
|
||||
import RolePermissionService from "../../../service/user/rolePermissionService";
|
||||
import { PermissionString } from "../../../type/permissionTypes";
|
||||
import DatabaseActionException from "../../../exceptions/databaseActionException";
|
||||
|
||||
export default abstract class RolePermissionCommandHandler {
|
||||
/**
|
||||
|
@ -35,7 +36,7 @@ export default abstract class RolePermissionCommandHandler {
|
|||
})
|
||||
.then(() => {})
|
||||
.catch((err) => {
|
||||
throw new InternalException("Failed saving role permissions", err);
|
||||
throw new DatabaseActionException("UPDATE", "rolePermissions", err);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -71,46 +72,4 @@ export default abstract class RolePermissionCommandHandler {
|
|||
.andWhere("permission IN (:...permission)", { permission: permissions })
|
||||
.execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* @description grant permission to user
|
||||
* @param {CreateRolePermissionCommand} createPermission
|
||||
* @returns {Promise<number>}
|
||||
*/
|
||||
static async create(createPermission: CreateRolePermissionCommand): Promise<number> {
|
||||
return await dataSource
|
||||
.createQueryBuilder()
|
||||
.insert()
|
||||
.into(rolePermission)
|
||||
.values({
|
||||
permission: createPermission.permission,
|
||||
role: await RoleService.getById(createPermission.roleId),
|
||||
})
|
||||
.execute()
|
||||
.then((result) => {
|
||||
return result.identifiers[0].id;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("Failed saving role permission", err);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @description remove permission from role
|
||||
* @param {DeleteRolePermissionCommand} deletePermission
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
static async delete(deletePermission: DeleteRolePermissionCommand): Promise<any> {
|
||||
return await dataSource
|
||||
.createQueryBuilder()
|
||||
.delete()
|
||||
.from(rolePermission)
|
||||
.where("roleId = :id", { id: deletePermission.roleId })
|
||||
.andWhere("permission = :permission", { permission: deletePermission.permission })
|
||||
.execute()
|
||||
.then(() => {})
|
||||
.catch((err) => {
|
||||
throw new InternalException("failed role permission removal", err);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { dataSource } from "../../../data-source";
|
||||
import { invite } from "../../../entity/user/invite";
|
||||
import DatabaseActionException from "../../../exceptions/databaseActionException";
|
||||
import InternalException from "../../../exceptions/internalException";
|
||||
import { StringHelper } from "../../../helpers/stringHelper";
|
||||
import { CreateInviteCommand, DeleteInviteCommand } from "./inviteCommand";
|
||||
|
@ -31,7 +32,7 @@ export default abstract class InviteCommandHandler {
|
|||
return token;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("Failed saving invite", err);
|
||||
throw new DatabaseActionException("CREATE", "invite", err);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -50,7 +51,7 @@ export default abstract class InviteCommandHandler {
|
|||
.execute()
|
||||
.then((res) => {})
|
||||
.catch((err) => {
|
||||
throw new InternalException("failed invite removal", err);
|
||||
throw new DatabaseActionException("DELETE", "invite", err);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -68,7 +69,7 @@ export default abstract class InviteCommandHandler {
|
|||
.execute()
|
||||
.then((res) => {})
|
||||
.catch((err) => {
|
||||
throw new InternalException("failed invite removal", err);
|
||||
throw new DatabaseActionException("DELETE", "invite", err);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import {
|
|||
UpdateUserSecretCommand,
|
||||
} from "./userCommand";
|
||||
import UserService from "../../../service/user/userService";
|
||||
import DatabaseActionException from "../../../exceptions/databaseActionException";
|
||||
|
||||
export default abstract class UserCommandHandler {
|
||||
/**
|
||||
|
@ -36,7 +37,7 @@ export default abstract class UserCommandHandler {
|
|||
return result.identifiers[0].id;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("Failed saving user", err);
|
||||
throw new DatabaseActionException("CREATE", "user", err);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -59,7 +60,7 @@ export default abstract class UserCommandHandler {
|
|||
.execute()
|
||||
.then(() => {})
|
||||
.catch((err) => {
|
||||
throw new InternalException("Failed updating user", err);
|
||||
throw new DatabaseActionException("UPDATE", "user", err);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -79,7 +80,7 @@ export default abstract class UserCommandHandler {
|
|||
.execute()
|
||||
.then(() => {})
|
||||
.catch((err) => {
|
||||
throw new InternalException("Failed updating user secret", err);
|
||||
throw new DatabaseActionException("UPDATE", "user", err);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -105,7 +106,7 @@ export default abstract class UserCommandHandler {
|
|||
})
|
||||
.then(() => {})
|
||||
.catch((err) => {
|
||||
throw new InternalException("Failed saving user roles", err);
|
||||
throw new DatabaseActionException("UPDATE", "userRoles", err);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -145,7 +146,7 @@ export default abstract class UserCommandHandler {
|
|||
})
|
||||
.then(() => {})
|
||||
.catch((err) => {
|
||||
throw new InternalException("Failed transfering ownership", err);
|
||||
throw new DatabaseActionException("ABORT", "transfer owner", err);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -163,7 +164,7 @@ export default abstract class UserCommandHandler {
|
|||
.execute()
|
||||
.then(() => {})
|
||||
.catch((err) => {
|
||||
throw new InternalException("Failed deleting user", err);
|
||||
throw new DatabaseActionException("DELETE", "user", err);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import {
|
|||
import UserPermissionService from "../../../service/user/userPermissionService";
|
||||
import PermissionHelper from "../../../helpers/permissionHelper";
|
||||
import { PermissionString } from "../../../type/permissionTypes";
|
||||
import DatabaseActionException from "../../../exceptions/databaseActionException";
|
||||
|
||||
export default abstract class UserPermissionCommandHandler {
|
||||
/**
|
||||
|
@ -36,7 +37,7 @@ export default abstract class UserPermissionCommandHandler {
|
|||
})
|
||||
.then(() => {})
|
||||
.catch((err) => {
|
||||
throw new InternalException("Failed saving user permissions", err);
|
||||
throw new DatabaseActionException("UPDATE", "userPermissions", err);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -72,46 +73,4 @@ export default abstract class UserPermissionCommandHandler {
|
|||
.andWhere("permission IN (:...permission)", { permission: permissions })
|
||||
.execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* @description grant permission to user
|
||||
* @param {CreateUserPermissionCommand} createPermission
|
||||
* @returns {Promise<number>}
|
||||
*/
|
||||
static async create(createPermission: CreateUserPermissionCommand): Promise<number> {
|
||||
return await dataSource
|
||||
.createQueryBuilder()
|
||||
.insert()
|
||||
.into(userPermission)
|
||||
.values({
|
||||
permission: createPermission.permission,
|
||||
userId: createPermission.userId,
|
||||
})
|
||||
.execute()
|
||||
.then((result) => {
|
||||
return result.identifiers[0].id;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("Failed saving user permission", err);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @description remove permission to user
|
||||
* @param {DeleteUserPermissionCommand} deletePermission
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
static async delete(deletePermission: DeleteUserPermissionCommand): Promise<any> {
|
||||
return await dataSource
|
||||
.createQueryBuilder()
|
||||
.delete()
|
||||
.from(userPermission)
|
||||
.where("userId = :id", { id: deletePermission.userId })
|
||||
.andWhere("permission = :permission", { permission: deletePermission.permission })
|
||||
.execute()
|
||||
.then((res) => {})
|
||||
.catch((err) => {
|
||||
throw new InternalException("failed user permission removal", err);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { dataSource } from "../../../data-source";
|
||||
import { webapi } from "../../../entity/user/webapi";
|
||||
import DatabaseActionException from "../../../exceptions/databaseActionException";
|
||||
import InternalException from "../../../exceptions/internalException";
|
||||
import {
|
||||
CreateWebapiCommand,
|
||||
|
@ -29,10 +30,7 @@ export default abstract class WebapiCommandHandler {
|
|||
return result.identifiers[0].token;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException(
|
||||
`Failed creating api${err.code.includes("ER_DUP_ENTRY") ? " due to duplicate entry for column" : ""}`,
|
||||
err
|
||||
);
|
||||
throw new DatabaseActionException("CREATE", "webapi", err);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -53,10 +51,7 @@ export default abstract class WebapiCommandHandler {
|
|||
.execute()
|
||||
.then(() => {})
|
||||
.catch((err) => {
|
||||
throw new InternalException(
|
||||
`Failed updating api${err.code.includes("ER_DUP_ENTRY") ? " due to duplicate entry for column" : ""}`,
|
||||
err
|
||||
);
|
||||
throw new DatabaseActionException("UPDATE", "webapi", err);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -76,7 +71,7 @@ export default abstract class WebapiCommandHandler {
|
|||
.execute()
|
||||
.then(() => {})
|
||||
.catch((err) => {
|
||||
throw new InternalException(`Failed updating api last usage`, err);
|
||||
throw new DatabaseActionException("UPDATE", "webapi", err);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -94,7 +89,7 @@ export default abstract class WebapiCommandHandler {
|
|||
.execute()
|
||||
.then(() => {})
|
||||
.catch((err) => {
|
||||
throw new InternalException("Failed deleting api", err);
|
||||
throw new DatabaseActionException("DELETE", "webapi", err);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import {
|
|||
import PermissionHelper from "../../../helpers/permissionHelper";
|
||||
import WebapiPermissionService from "../../../service/user/webapiPermissionService";
|
||||
import { PermissionString } from "../../../type/permissionTypes";
|
||||
import DatabaseActionException from "../../../exceptions/databaseActionException";
|
||||
|
||||
export default abstract class WebapiPermissionCommandHandler {
|
||||
/**
|
||||
|
@ -38,7 +39,7 @@ export default abstract class WebapiPermissionCommandHandler {
|
|||
})
|
||||
.then(() => {})
|
||||
.catch((err) => {
|
||||
throw new InternalException("Failed saving api permissions", err);
|
||||
throw new DatabaseActionException("UPDATE", "webapiPermission", err);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -74,46 +75,4 @@ export default abstract class WebapiPermissionCommandHandler {
|
|||
.andWhere("permission IN (:...permission)", { permission: permissions })
|
||||
.execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* @description grant permission to user
|
||||
* @param {CreateWebapiPermissionCommand} createPermission
|
||||
* @returns {Promise<number>}
|
||||
*/
|
||||
static async create(createPermission: CreateWebapiPermissionCommand): Promise<number> {
|
||||
return await dataSource
|
||||
.createQueryBuilder()
|
||||
.insert()
|
||||
.into(webapiPermission)
|
||||
.values({
|
||||
permission: createPermission.permission,
|
||||
webapiId: createPermission.webapiId,
|
||||
})
|
||||
.execute()
|
||||
.then((result) => {
|
||||
return result.identifiers[0].id;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("Failed saving api permission", err);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @description remove permission from api
|
||||
* @param {DeleteWebapiPermissionCommand} deletePermission
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
static async delete(deletePermission: DeleteWebapiPermissionCommand): Promise<any> {
|
||||
return await dataSource
|
||||
.createQueryBuilder()
|
||||
.delete()
|
||||
.from(webapiPermission)
|
||||
.where("webapiId = :id", { id: deletePermission.webapiId })
|
||||
.andWhere("permission = :permission", { permission: deletePermission.permission })
|
||||
.execute()
|
||||
.then(() => {})
|
||||
.catch((err) => {
|
||||
throw new InternalException("failed api permission removal", err);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue