Merged PR 625: セレクトのクエリに追跡用のIDと実行日時の情報を追加する
## 概要 [Task3288: セレクトのクエリに追跡用のIDと実行日時の情報を追加する](https://paruru.nds-tyo.co.jp:8443/tfs/ReciproCollection/fa4924a4-d079-4fab-9fb5-a9a11eb205f0/_workitems/edit/3288) - リポジトリ内でのDB操作でSelect文となる部分にコメント(追跡ID_日時)を追加しました。 - `find`, `fineOne`, `count`を対象にしています。 - コメントを追加するにあたってContextをリポジトリメソッドの引数に追加しています。 ## レビューポイント - 対応箇所の漏れはないでしょうか? - コメントのつけ方は適切でしょうか? ## UIの変更 - なし ## 動作確認状況 - ローカルで確認
This commit is contained in:
parent
934ee7f44d
commit
b8b3416795
@ -111,6 +111,7 @@ export class AccountsService {
|
|||||||
|
|
||||||
const { licenseSummary, isStorageAvailable } =
|
const { licenseSummary, isStorageAvailable } =
|
||||||
await this.accountRepository.getLicenseSummaryInfo(
|
await this.accountRepository.getLicenseSummaryInfo(
|
||||||
|
context,
|
||||||
accountId,
|
accountId,
|
||||||
currentDate,
|
currentDate,
|
||||||
expiringSoonDate,
|
expiringSoonDate,
|
||||||
@ -440,16 +441,21 @@ export class AccountsService {
|
|||||||
);
|
);
|
||||||
try {
|
try {
|
||||||
let userInfo: User;
|
let userInfo: User;
|
||||||
userInfo = await this.usersRepository.findUserByExternalId(externalId);
|
userInfo = await this.usersRepository.findUserByExternalId(
|
||||||
|
context,
|
||||||
|
externalId,
|
||||||
|
);
|
||||||
|
|
||||||
let accountInfo: Account;
|
let accountInfo: Account;
|
||||||
accountInfo = await this.accountRepository.findAccountById(
|
accountInfo = await this.accountRepository.findAccountById(
|
||||||
|
context,
|
||||||
userInfo.account_id,
|
userInfo.account_id,
|
||||||
);
|
);
|
||||||
|
|
||||||
let parentInfo: Account | undefined;
|
let parentInfo: Account | undefined;
|
||||||
if (accountInfo.parent_account_id) {
|
if (accountInfo.parent_account_id) {
|
||||||
parentInfo = await this.accountRepository.findAccountById(
|
parentInfo = await this.accountRepository.findAccountById(
|
||||||
|
context,
|
||||||
accountInfo.parent_account_id,
|
accountInfo.parent_account_id,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -505,8 +511,12 @@ export class AccountsService {
|
|||||||
|
|
||||||
// TypistGroup取得
|
// TypistGroup取得
|
||||||
try {
|
try {
|
||||||
const user = await this.usersRepository.findUserByExternalId(externalId);
|
const user = await this.usersRepository.findUserByExternalId(
|
||||||
|
context,
|
||||||
|
externalId,
|
||||||
|
);
|
||||||
const userGroups = await this.userGroupsRepository.getUserGroups(
|
const userGroups = await this.userGroupsRepository.getUserGroups(
|
||||||
|
context,
|
||||||
user.account_id,
|
user.account_id,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -543,10 +553,12 @@ export class AccountsService {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const { account_id } = await this.usersRepository.findUserByExternalId(
|
const { account_id } = await this.usersRepository.findUserByExternalId(
|
||||||
|
context,
|
||||||
externalId,
|
externalId,
|
||||||
);
|
);
|
||||||
const { name, userGroupMembers } =
|
const { name, userGroupMembers } =
|
||||||
await this.userGroupsRepository.getTypistGroup(
|
await this.userGroupsRepository.getTypistGroup(
|
||||||
|
context,
|
||||||
account_id,
|
account_id,
|
||||||
typistGroupId,
|
typistGroupId,
|
||||||
);
|
);
|
||||||
@ -602,6 +614,7 @@ export class AccountsService {
|
|||||||
// Typist取得
|
// Typist取得
|
||||||
try {
|
try {
|
||||||
const typistUsers = await this.usersRepository.findTypistUsers(
|
const typistUsers = await this.usersRepository.findTypistUsers(
|
||||||
|
context,
|
||||||
externalId,
|
externalId,
|
||||||
);
|
);
|
||||||
const externalIds = typistUsers.map((x) => x.external_id);
|
const externalIds = typistUsers.map((x) => x.external_id);
|
||||||
@ -651,6 +664,7 @@ export class AccountsService {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const { account } = await this.usersRepository.findUserByExternalId(
|
const { account } = await this.usersRepository.findUserByExternalId(
|
||||||
|
context,
|
||||||
externalId,
|
externalId,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -661,6 +675,7 @@ export class AccountsService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const authorUsers = await this.usersRepository.findAuthorUsers(
|
const authorUsers = await this.usersRepository.findAuthorUsers(
|
||||||
|
context,
|
||||||
account.id,
|
account.id,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -733,7 +748,10 @@ export class AccountsService {
|
|||||||
try {
|
try {
|
||||||
// アクセストークンからユーザーIDを取得する
|
// アクセストークンからユーザーIDを取得する
|
||||||
myAccountId = (
|
myAccountId = (
|
||||||
await this.usersRepository.findUserByExternalId(creatorUserId)
|
await this.usersRepository.findUserByExternalId(
|
||||||
|
context,
|
||||||
|
creatorUserId,
|
||||||
|
)
|
||||||
).account_id;
|
).account_id;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.logger.error(`[${context.getTrackingId()}] error=${e}`);
|
this.logger.error(`[${context.getTrackingId()}] error=${e}`);
|
||||||
@ -909,6 +927,7 @@ export class AccountsService {
|
|||||||
|
|
||||||
const getPartnerLicenseResult =
|
const getPartnerLicenseResult =
|
||||||
await this.accountRepository.getPartnerLicense(
|
await this.accountRepository.getPartnerLicense(
|
||||||
|
context,
|
||||||
accountId,
|
accountId,
|
||||||
currentDate,
|
currentDate,
|
||||||
expiringSoonDate,
|
expiringSoonDate,
|
||||||
@ -1008,6 +1027,7 @@ export class AccountsService {
|
|||||||
try {
|
try {
|
||||||
const licenseHistoryInfo =
|
const licenseHistoryInfo =
|
||||||
await this.licensesRepository.getLicenseOrderHistoryInfo(
|
await this.licensesRepository.getLicenseOrderHistoryInfo(
|
||||||
|
context,
|
||||||
accountId,
|
accountId,
|
||||||
offset,
|
offset,
|
||||||
limit,
|
limit,
|
||||||
@ -1079,9 +1099,10 @@ export class AccountsService {
|
|||||||
try {
|
try {
|
||||||
// アクセストークンからユーザーIDを取得する
|
// アクセストークンからユーザーIDを取得する
|
||||||
const myAccountId = (
|
const myAccountId = (
|
||||||
await this.usersRepository.findUserByExternalId(userId)
|
await this.usersRepository.findUserByExternalId(context, userId)
|
||||||
).account_id;
|
).account_id;
|
||||||
await this.licensesRepository.issueLicense(
|
await this.licensesRepository.issueLicense(
|
||||||
|
context,
|
||||||
orderedAccountId,
|
orderedAccountId,
|
||||||
myAccountId,
|
myAccountId,
|
||||||
tier,
|
tier,
|
||||||
@ -1127,7 +1148,9 @@ export class AccountsService {
|
|||||||
);
|
);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const dealerAccounts = await this.accountRepository.findDealerAccounts();
|
const dealerAccounts = await this.accountRepository.findDealerAccounts(
|
||||||
|
context,
|
||||||
|
);
|
||||||
|
|
||||||
const dealers: GetDealersResponse = {
|
const dealers: GetDealersResponse = {
|
||||||
dealers: dealerAccounts.map((dealerAccount): Dealer => {
|
dealers: dealerAccounts.map((dealerAccount): Dealer => {
|
||||||
@ -1177,10 +1200,12 @@ export class AccountsService {
|
|||||||
try {
|
try {
|
||||||
// 外部IDをもとにユーザー情報を取得する
|
// 外部IDをもとにユーザー情報を取得する
|
||||||
const { account_id } = await this.usersRepository.findUserByExternalId(
|
const { account_id } = await this.usersRepository.findUserByExternalId(
|
||||||
|
context,
|
||||||
externalId,
|
externalId,
|
||||||
);
|
);
|
||||||
// API実行ユーザーのアカウントIDでタイピストグループを作成し、タイピストグループとtypistIdsのユーザーを紐付ける
|
// API実行ユーザーのアカウントIDでタイピストグループを作成し、タイピストグループとtypistIdsのユーザーを紐付ける
|
||||||
await this.userGroupsRepository.createTypistGroup(
|
await this.userGroupsRepository.createTypistGroup(
|
||||||
|
context,
|
||||||
typistGroupName,
|
typistGroupName,
|
||||||
typistIds,
|
typistIds,
|
||||||
account_id,
|
account_id,
|
||||||
@ -1240,11 +1265,13 @@ export class AccountsService {
|
|||||||
try {
|
try {
|
||||||
// 外部IDをもとにユーザー情報を取得する
|
// 外部IDをもとにユーザー情報を取得する
|
||||||
const { account_id } = await this.usersRepository.findUserByExternalId(
|
const { account_id } = await this.usersRepository.findUserByExternalId(
|
||||||
|
context,
|
||||||
externalId,
|
externalId,
|
||||||
);
|
);
|
||||||
|
|
||||||
// タイピストグループと所属するタイピストを更新する
|
// タイピストグループと所属するタイピストを更新する
|
||||||
await this.userGroupsRepository.updateTypistGroup(
|
await this.userGroupsRepository.updateTypistGroup(
|
||||||
|
context,
|
||||||
account_id,
|
account_id,
|
||||||
typistGroupId,
|
typistGroupId,
|
||||||
typistGroupName,
|
typistGroupName,
|
||||||
@ -1310,7 +1337,7 @@ export class AccountsService {
|
|||||||
try {
|
try {
|
||||||
// ユーザIDからアカウントIDを取得する
|
// ユーザIDからアカウントIDを取得する
|
||||||
myAccountId = (
|
myAccountId = (
|
||||||
await this.usersRepository.findUserByExternalId(extarnalId)
|
await this.usersRepository.findUserByExternalId(context, extarnalId)
|
||||||
).account_id;
|
).account_id;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.logger.error(`[${context.getTrackingId()}] error=${e}`);
|
this.logger.error(`[${context.getTrackingId()}] error=${e}`);
|
||||||
@ -1329,6 +1356,7 @@ export class AccountsService {
|
|||||||
|
|
||||||
// 注文元アカウントIDの親世代を取得
|
// 注文元アカウントIDの親世代を取得
|
||||||
const parentAccountIds = await this.accountRepository.getHierarchyParents(
|
const parentAccountIds = await this.accountRepository.getHierarchyParents(
|
||||||
|
context,
|
||||||
orderedAccountId,
|
orderedAccountId,
|
||||||
);
|
);
|
||||||
// 自身が存在しない場合、エラー
|
// 自身が存在しない場合、エラー
|
||||||
@ -1344,7 +1372,11 @@ export class AccountsService {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
// 発行キャンセル処理
|
// 発行キャンセル処理
|
||||||
await this.accountRepository.cancelIssue(orderedAccountId, poNumber);
|
await this.accountRepository.cancelIssue(
|
||||||
|
context,
|
||||||
|
orderedAccountId,
|
||||||
|
poNumber,
|
||||||
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.logger.error(`[${context.getTrackingId()}] error=${e}`);
|
this.logger.error(`[${context.getTrackingId()}] error=${e}`);
|
||||||
switch (e.constructor) {
|
switch (e.constructor) {
|
||||||
@ -1394,11 +1426,11 @@ export class AccountsService {
|
|||||||
try {
|
try {
|
||||||
// 外部IDをもとにユーザー情報を取得する
|
// 外部IDをもとにユーザー情報を取得する
|
||||||
const { account_id: accountId } =
|
const { account_id: accountId } =
|
||||||
await this.usersRepository.findUserByExternalId(externalId);
|
await this.usersRepository.findUserByExternalId(context, externalId);
|
||||||
|
|
||||||
// ワークタイプ一覧とActiveWorktypeIDを取得する
|
// ワークタイプ一覧とActiveWorktypeIDを取得する
|
||||||
const { worktypes, active_worktype_id } =
|
const { worktypes, active_worktype_id } =
|
||||||
await this.worktypesRepository.getWorktypes(accountId);
|
await this.worktypesRepository.getWorktypes(context, accountId);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
worktypes: worktypes.map((x) => ({
|
worktypes: worktypes.map((x) => ({
|
||||||
@ -1457,9 +1489,10 @@ export class AccountsService {
|
|||||||
try {
|
try {
|
||||||
// 外部IDをもとにユーザー情報を取得する
|
// 外部IDをもとにユーザー情報を取得する
|
||||||
const { account_id: accountId } =
|
const { account_id: accountId } =
|
||||||
await this.usersRepository.findUserByExternalId(externalId);
|
await this.usersRepository.findUserByExternalId(context, externalId);
|
||||||
|
|
||||||
await this.worktypesRepository.createWorktype(
|
await this.worktypesRepository.createWorktype(
|
||||||
|
context,
|
||||||
accountId,
|
accountId,
|
||||||
worktypeId,
|
worktypeId,
|
||||||
description,
|
description,
|
||||||
@ -1527,10 +1560,11 @@ export class AccountsService {
|
|||||||
try {
|
try {
|
||||||
// 外部IDをもとにユーザー情報を取得する
|
// 外部IDをもとにユーザー情報を取得する
|
||||||
const { account_id: accountId } =
|
const { account_id: accountId } =
|
||||||
await this.usersRepository.findUserByExternalId(externalId);
|
await this.usersRepository.findUserByExternalId(context, externalId);
|
||||||
|
|
||||||
// ワークタイプを更新する
|
// ワークタイプを更新する
|
||||||
await this.worktypesRepository.updateWorktype(
|
await this.worktypesRepository.updateWorktype(
|
||||||
|
context,
|
||||||
accountId,
|
accountId,
|
||||||
id,
|
id,
|
||||||
worktypeId,
|
worktypeId,
|
||||||
@ -1593,7 +1627,7 @@ export class AccountsService {
|
|||||||
try {
|
try {
|
||||||
// 外部IDをもとにユーザー情報を取得する
|
// 外部IDをもとにユーザー情報を取得する
|
||||||
const { account, account_id: accountId } =
|
const { account, account_id: accountId } =
|
||||||
await this.usersRepository.findUserByExternalId(externalId);
|
await this.usersRepository.findUserByExternalId(context, externalId);
|
||||||
|
|
||||||
if (!account) {
|
if (!account) {
|
||||||
throw new AccountNotFoundError(
|
throw new AccountNotFoundError(
|
||||||
@ -1602,7 +1636,7 @@ export class AccountsService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ワークタイプを削除する
|
// ワークタイプを削除する
|
||||||
await this.worktypesRepository.deleteWorktype(accountId, id);
|
await this.worktypesRepository.deleteWorktype(context, accountId, id);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.logger.error(`[${context.getTrackingId()}] error=${e}`);
|
this.logger.error(`[${context.getTrackingId()}] error=${e}`);
|
||||||
if (e instanceof Error) {
|
if (e instanceof Error) {
|
||||||
@ -1669,10 +1703,11 @@ export class AccountsService {
|
|||||||
try {
|
try {
|
||||||
// 外部IDをもとにユーザー情報を取得する
|
// 外部IDをもとにユーザー情報を取得する
|
||||||
const { account_id: accountId } =
|
const { account_id: accountId } =
|
||||||
await this.usersRepository.findUserByExternalId(externalId);
|
await this.usersRepository.findUserByExternalId(context, externalId);
|
||||||
|
|
||||||
// オプションアイテム一覧を取得する
|
// オプションアイテム一覧を取得する
|
||||||
const optionItems = await this.worktypesRepository.getOptionItems(
|
const optionItems = await this.worktypesRepository.getOptionItems(
|
||||||
|
context,
|
||||||
accountId,
|
accountId,
|
||||||
id,
|
id,
|
||||||
);
|
);
|
||||||
@ -1738,10 +1773,11 @@ export class AccountsService {
|
|||||||
try {
|
try {
|
||||||
// 外部IDをもとにユーザー情報を取得する
|
// 外部IDをもとにユーザー情報を取得する
|
||||||
const { account_id: accountId } =
|
const { account_id: accountId } =
|
||||||
await this.usersRepository.findUserByExternalId(externalId);
|
await this.usersRepository.findUserByExternalId(context, externalId);
|
||||||
|
|
||||||
// オプションアイテムを更新する
|
// オプションアイテムを更新する
|
||||||
await this.worktypesRepository.updateOptionItems(
|
await this.worktypesRepository.updateOptionItems(
|
||||||
|
context,
|
||||||
accountId,
|
accountId,
|
||||||
id,
|
id,
|
||||||
// initialValueはdefaultValueTypeがDEFAULTの場合以外は空文字を設定する
|
// initialValueはdefaultValueTypeがDEFAULTの場合以外は空文字を設定する
|
||||||
@ -1804,10 +1840,14 @@ export class AccountsService {
|
|||||||
try {
|
try {
|
||||||
// 外部IDをもとにユーザー情報を取得する
|
// 外部IDをもとにユーザー情報を取得する
|
||||||
const { account_id: accountId } =
|
const { account_id: accountId } =
|
||||||
await this.usersRepository.findUserByExternalId(externalId);
|
await this.usersRepository.findUserByExternalId(context, externalId);
|
||||||
|
|
||||||
// ActiveWorktypeを更新する
|
// ActiveWorktypeを更新する
|
||||||
await this.accountRepository.updateActiveWorktypeId(accountId, id);
|
await this.accountRepository.updateActiveWorktypeId(
|
||||||
|
context,
|
||||||
|
accountId,
|
||||||
|
id,
|
||||||
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.logger.error(`[${context.getTrackingId()}] error=${e}`);
|
this.logger.error(`[${context.getTrackingId()}] error=${e}`);
|
||||||
if (e instanceof Error) {
|
if (e instanceof Error) {
|
||||||
@ -1861,9 +1901,10 @@ export class AccountsService {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const { account_id: accountId } =
|
const { account_id: accountId } =
|
||||||
await this.usersRepository.findUserByExternalId(externalId);
|
await this.usersRepository.findUserByExternalId(context, externalId);
|
||||||
|
|
||||||
const partnersRecords = await this.accountRepository.getPartners(
|
const partnersRecords = await this.accountRepository.getPartners(
|
||||||
|
context,
|
||||||
accountId,
|
accountId,
|
||||||
limit,
|
limit,
|
||||||
offset,
|
offset,
|
||||||
@ -1959,8 +2000,9 @@ export class AccountsService {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const { account_id: accountId } =
|
const { account_id: accountId } =
|
||||||
await this.usersRepository.findUserByExternalId(externalId);
|
await this.usersRepository.findUserByExternalId(context, externalId);
|
||||||
await this.accountRepository.updateAccountInfo(
|
await this.accountRepository.updateAccountInfo(
|
||||||
|
context,
|
||||||
accountId,
|
accountId,
|
||||||
tier,
|
tier,
|
||||||
delegationPermission,
|
delegationPermission,
|
||||||
@ -2019,7 +2061,7 @@ export class AccountsService {
|
|||||||
try {
|
try {
|
||||||
// パラメータとトークンから取得したアカウントIDの突き合わせ
|
// パラメータとトークンから取得したアカウントIDの突き合わせ
|
||||||
const { account_id: myAccountId } =
|
const { account_id: myAccountId } =
|
||||||
await this.usersRepository.findUserByExternalId(externalId);
|
await this.usersRepository.findUserByExternalId(context, externalId);
|
||||||
if (myAccountId !== accountId) {
|
if (myAccountId !== accountId) {
|
||||||
throw new HttpException(
|
throw new HttpException(
|
||||||
makeErrorResponse('E000108'),
|
makeErrorResponse('E000108'),
|
||||||
@ -2029,10 +2071,12 @@ export class AccountsService {
|
|||||||
|
|
||||||
// アカウント削除前に必要な情報を退避する
|
// アカウント削除前に必要な情報を退避する
|
||||||
const targetAccount = await this.accountRepository.findAccountById(
|
const targetAccount = await this.accountRepository.findAccountById(
|
||||||
|
context,
|
||||||
accountId,
|
accountId,
|
||||||
);
|
);
|
||||||
// 削除対象アカウントを削除する
|
// 削除対象アカウントを削除する
|
||||||
dbUsers = await this.accountRepository.deleteAccountAndInsertArchives(
|
dbUsers = await this.accountRepository.deleteAccountAndInsertArchives(
|
||||||
|
context,
|
||||||
accountId,
|
accountId,
|
||||||
);
|
);
|
||||||
this.logger.log(
|
this.logger.log(
|
||||||
@ -2109,6 +2153,7 @@ export class AccountsService {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const { account } = await this.usersRepository.findUserByExternalId(
|
const { account } = await this.usersRepository.findUserByExternalId(
|
||||||
|
context,
|
||||||
externalId,
|
externalId,
|
||||||
);
|
);
|
||||||
if (!account) {
|
if (!account) {
|
||||||
@ -2168,6 +2213,7 @@ export class AccountsService {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const { company_name } = await this.accountRepository.findAccountById(
|
const { company_name } = await this.accountRepository.findAccountById(
|
||||||
|
context,
|
||||||
accountId,
|
accountId,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -61,7 +61,10 @@ export class AuthService {
|
|||||||
);
|
);
|
||||||
try {
|
try {
|
||||||
// IDトークンのユーザーがDBに登録されていてメール認証が完了しているユーザーか検証
|
// IDトークンのユーザーがDBに登録されていてメール認証が完了しているユーザーか検証
|
||||||
const user = await this.usersRepository.findVerifiedUser(idToken.sub);
|
const user = await this.usersRepository.findVerifiedUser(
|
||||||
|
context,
|
||||||
|
idToken.sub,
|
||||||
|
);
|
||||||
|
|
||||||
return user !== undefined;
|
return user !== undefined;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@ -96,7 +99,10 @@ export class AuthService {
|
|||||||
|
|
||||||
// ユーザー情報とユーザーが属しているアカウント情報を取得
|
// ユーザー情報とユーザーが属しているアカウント情報を取得
|
||||||
try {
|
try {
|
||||||
const user = await this.usersRepository.findUserByExternalId(idToken.sub);
|
const user = await this.usersRepository.findUserByExternalId(
|
||||||
|
context,
|
||||||
|
idToken.sub,
|
||||||
|
);
|
||||||
if (!user.account) {
|
if (!user.account) {
|
||||||
throw new Error('Account information not found');
|
throw new Error('Account information not found');
|
||||||
}
|
}
|
||||||
@ -236,11 +242,13 @@ export class AuthService {
|
|||||||
// ユーザー情報とユーザーが属しているアカウント情報を取得
|
// ユーザー情報とユーザーが属しているアカウント情報を取得
|
||||||
try {
|
try {
|
||||||
const user = await this.usersRepository.findUserByExternalId(
|
const user = await this.usersRepository.findUserByExternalId(
|
||||||
|
context,
|
||||||
delegateUserExternalId,
|
delegateUserExternalId,
|
||||||
);
|
);
|
||||||
|
|
||||||
// 代行操作対象アカウントの管理者ユーザーを取得
|
// 代行操作対象アカウントの管理者ユーザーを取得
|
||||||
const adminUser = await this.usersRepository.findDelegateUser(
|
const adminUser = await this.usersRepository.findDelegateUser(
|
||||||
|
context,
|
||||||
user.account_id,
|
user.account_id,
|
||||||
originAccountId,
|
originAccountId,
|
||||||
);
|
);
|
||||||
@ -382,6 +390,7 @@ export class AuthService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const user = await this.usersRepository.findUserByExternalId(
|
const user = await this.usersRepository.findUserByExternalId(
|
||||||
|
context,
|
||||||
delegateUserExternalId,
|
delegateUserExternalId,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -406,6 +415,7 @@ export class AuthService {
|
|||||||
// 代行操作対象アカウントの管理者ユーザーが存在して、アカウントに対して代行操作権限があるか確認
|
// 代行操作対象アカウントの管理者ユーザーが存在して、アカウントに対して代行操作権限があるか確認
|
||||||
const delegationPermission =
|
const delegationPermission =
|
||||||
await this.usersRepository.isAllowDelegationPermission(
|
await this.usersRepository.isAllowDelegationPermission(
|
||||||
|
context,
|
||||||
user.account_id,
|
user.account_id,
|
||||||
userId,
|
userId,
|
||||||
);
|
);
|
||||||
@ -694,7 +704,10 @@ export class AuthService {
|
|||||||
acceptedDpaVersion,
|
acceptedDpaVersion,
|
||||||
latestDpaVersion,
|
latestDpaVersion,
|
||||||
tier,
|
tier,
|
||||||
} = await this.usersRepository.getAcceptedAndLatestVersion(idToken.sub);
|
} = await this.usersRepository.getAcceptedAndLatestVersion(
|
||||||
|
context,
|
||||||
|
idToken.sub,
|
||||||
|
);
|
||||||
|
|
||||||
// 第五階層はEULAとPrivacyNoticeのみ判定
|
// 第五階層はEULAとPrivacyNoticeのみ判定
|
||||||
if (tier === TIERS.TIER5) {
|
if (tier === TIERS.TIER5) {
|
||||||
|
|||||||
@ -166,7 +166,7 @@ export class FilesService {
|
|||||||
let user: User;
|
let user: User;
|
||||||
try {
|
try {
|
||||||
// ユーザー取得
|
// ユーザー取得
|
||||||
user = await this.usersRepository.findUserByExternalId(userId);
|
user = await this.usersRepository.findUserByExternalId(context, userId);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.logger.error(`[${context.getTrackingId()}] error=${e}`);
|
this.logger.error(`[${context.getTrackingId()}] error=${e}`);
|
||||||
this.logger.log(
|
this.logger.log(
|
||||||
@ -190,6 +190,7 @@ export class FilesService {
|
|||||||
// 文字起こしタスク追加(音声ファイルとオプションアイテムも同時に追加)
|
// 文字起こしタスク追加(音声ファイルとオプションアイテムも同時に追加)
|
||||||
// 追加時に末尾のJOBナンバーにインクリメントする
|
// 追加時に末尾のJOBナンバーにインクリメントする
|
||||||
task = await this.tasksRepositoryService.create(
|
task = await this.tasksRepositoryService.create(
|
||||||
|
context,
|
||||||
user.account_id,
|
user.account_id,
|
||||||
user.id,
|
user.id,
|
||||||
priority,
|
priority,
|
||||||
@ -218,6 +219,7 @@ export class FilesService {
|
|||||||
// ルーティング設定に従い、チェックアウト権限を付与する
|
// ルーティング設定に従い、チェックアウト権限を付与する
|
||||||
const { typistGroupIds, typistIds } =
|
const { typistGroupIds, typistIds } =
|
||||||
await this.tasksRepositoryService.autoRouting(
|
await this.tasksRepositoryService.autoRouting(
|
||||||
|
context,
|
||||||
task.audio_file_id,
|
task.audio_file_id,
|
||||||
user.account_id,
|
user.account_id,
|
||||||
user.author_id ?? undefined,
|
user.author_id ?? undefined,
|
||||||
@ -225,6 +227,7 @@ export class FilesService {
|
|||||||
|
|
||||||
const groupMembers =
|
const groupMembers =
|
||||||
await this.userGroupsRepositoryService.getGroupMembersFromGroupIds(
|
await this.userGroupsRepositoryService.getGroupMembersFromGroupIds(
|
||||||
|
context,
|
||||||
typistGroupIds,
|
typistGroupIds,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -284,7 +287,10 @@ export class FilesService {
|
|||||||
|
|
||||||
//DBから国情報とアカウントIDを取得する
|
//DBから国情報とアカウントIDを取得する
|
||||||
try {
|
try {
|
||||||
const user = await this.usersRepository.findUserByExternalId(externalId);
|
const user = await this.usersRepository.findUserByExternalId(
|
||||||
|
context,
|
||||||
|
externalId,
|
||||||
|
);
|
||||||
if (!user.account) {
|
if (!user.account) {
|
||||||
throw new AccountNotFoundError('account not found.');
|
throw new AccountNotFoundError('account not found.');
|
||||||
}
|
}
|
||||||
@ -299,6 +305,7 @@ export class FilesService {
|
|||||||
|
|
||||||
// ライセンスが有効でない場合、エラー
|
// ライセンスが有効でない場合、エラー
|
||||||
const { state } = await this.licensesRepository.getLicenseState(
|
const { state } = await this.licensesRepository.getLicenseState(
|
||||||
|
context,
|
||||||
user.id,
|
user.id,
|
||||||
);
|
);
|
||||||
if (state === 'expired') {
|
if (state === 'expired') {
|
||||||
@ -378,7 +385,10 @@ export class FilesService {
|
|||||||
let authorId: string | undefined;
|
let authorId: string | undefined;
|
||||||
let isAdmin: boolean;
|
let isAdmin: boolean;
|
||||||
try {
|
try {
|
||||||
const user = await this.usersRepository.findUserByExternalId(externalId);
|
const user = await this.usersRepository.findUserByExternalId(
|
||||||
|
context,
|
||||||
|
externalId,
|
||||||
|
);
|
||||||
if (!user.account) {
|
if (!user.account) {
|
||||||
throw new AccountNotFoundError('account not found.');
|
throw new AccountNotFoundError('account not found.');
|
||||||
}
|
}
|
||||||
@ -386,6 +396,7 @@ export class FilesService {
|
|||||||
if (user.account.tier === TIERS.TIER5) {
|
if (user.account.tier === TIERS.TIER5) {
|
||||||
// ライセンスが有効でない場合、エラー
|
// ライセンスが有効でない場合、エラー
|
||||||
const { state } = await this.licensesRepository.getLicenseState(
|
const { state } = await this.licensesRepository.getLicenseState(
|
||||||
|
context,
|
||||||
user.id,
|
user.id,
|
||||||
);
|
);
|
||||||
if (state === 'expired') {
|
if (state === 'expired') {
|
||||||
@ -437,6 +448,7 @@ export class FilesService {
|
|||||||
: Object.values(TASK_STATUS);
|
: Object.values(TASK_STATUS);
|
||||||
|
|
||||||
const task = await this.tasksRepository.getTaskAndAudioFile(
|
const task = await this.tasksRepository.getTaskAndAudioFile(
|
||||||
|
context,
|
||||||
audioFileId,
|
audioFileId,
|
||||||
accountId,
|
accountId,
|
||||||
status,
|
status,
|
||||||
@ -554,7 +566,10 @@ export class FilesService {
|
|||||||
let isTypist: boolean;
|
let isTypist: boolean;
|
||||||
let authorId: string | undefined;
|
let authorId: string | undefined;
|
||||||
try {
|
try {
|
||||||
const user = await this.usersRepository.findUserByExternalId(externalId);
|
const user = await this.usersRepository.findUserByExternalId(
|
||||||
|
context,
|
||||||
|
externalId,
|
||||||
|
);
|
||||||
if (!user.account) {
|
if (!user.account) {
|
||||||
throw new AccountNotFoundError('account not found.');
|
throw new AccountNotFoundError('account not found.');
|
||||||
}
|
}
|
||||||
@ -562,6 +577,7 @@ export class FilesService {
|
|||||||
if (user.account.tier === TIERS.TIER5) {
|
if (user.account.tier === TIERS.TIER5) {
|
||||||
// ライセンスが有効でない場合、エラー
|
// ライセンスが有効でない場合、エラー
|
||||||
const { state } = await this.licensesRepository.getLicenseState(
|
const { state } = await this.licensesRepository.getLicenseState(
|
||||||
|
context,
|
||||||
user.id,
|
user.id,
|
||||||
);
|
);
|
||||||
if (state === 'expired') {
|
if (state === 'expired') {
|
||||||
@ -608,6 +624,7 @@ export class FilesService {
|
|||||||
: Object.values(TASK_STATUS);
|
: Object.values(TASK_STATUS);
|
||||||
|
|
||||||
const task = await this.tasksRepository.getTaskAndAudioFile(
|
const task = await this.tasksRepository.getTaskAndAudioFile(
|
||||||
|
context,
|
||||||
audioFileId,
|
audioFileId,
|
||||||
accountId,
|
accountId,
|
||||||
status,
|
status,
|
||||||
@ -726,6 +743,7 @@ export class FilesService {
|
|||||||
);
|
);
|
||||||
try {
|
try {
|
||||||
const { account } = await this.usersRepository.findUserByExternalId(
|
const { account } = await this.usersRepository.findUserByExternalId(
|
||||||
|
context,
|
||||||
externalId,
|
externalId,
|
||||||
);
|
);
|
||||||
if (!account) {
|
if (!account) {
|
||||||
@ -788,7 +806,7 @@ export class FilesService {
|
|||||||
try {
|
try {
|
||||||
// ユーザー取得
|
// ユーザー取得
|
||||||
const { account_id: accountId } =
|
const { account_id: accountId } =
|
||||||
await this.usersRepository.findUserByExternalId(externalId);
|
await this.usersRepository.findUserByExternalId(context, externalId);
|
||||||
|
|
||||||
// URLにSASトークンがついている場合は取り除く;
|
// URLにSASトークンがついている場合は取り除く;
|
||||||
const urlObj = new URL(url);
|
const urlObj = new URL(url);
|
||||||
@ -800,6 +818,7 @@ export class FilesService {
|
|||||||
|
|
||||||
// テンプレートファイル情報をDBに登録
|
// テンプレートファイル情報をDBに登録
|
||||||
await this.templateFilesRepository.upsertTemplateFile(
|
await this.templateFilesRepository.upsertTemplateFile(
|
||||||
|
context,
|
||||||
accountId,
|
accountId,
|
||||||
fileName,
|
fileName,
|
||||||
fileUrl,
|
fileUrl,
|
||||||
|
|||||||
@ -49,7 +49,7 @@ export class LicensesService {
|
|||||||
// ユーザIDからアカウントIDを取得する
|
// ユーザIDからアカウントIDを取得する
|
||||||
try {
|
try {
|
||||||
myAccountId = (
|
myAccountId = (
|
||||||
await this.usersRepository.findUserByExternalId(externalId)
|
await this.usersRepository.findUserByExternalId(context, externalId)
|
||||||
).account_id;
|
).account_id;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.logger.error(`[${context.getTrackingId()}] error=${e}`);
|
this.logger.error(`[${context.getTrackingId()}] error=${e}`);
|
||||||
@ -70,7 +70,7 @@ export class LicensesService {
|
|||||||
// 親アカウントIDを取得
|
// 親アカウントIDを取得
|
||||||
try {
|
try {
|
||||||
parentAccountId =
|
parentAccountId =
|
||||||
(await this.accountsRepository.findAccountById(myAccountId))
|
(await this.accountsRepository.findAccountById(context, myAccountId))
|
||||||
.parent_account_id ?? undefined;
|
.parent_account_id ?? undefined;
|
||||||
// 親アカウントIDが取得できない場合はエラー
|
// 親アカウントIDが取得できない場合はエラー
|
||||||
if (parentAccountId === undefined) {
|
if (parentAccountId === undefined) {
|
||||||
@ -94,6 +94,7 @@ export class LicensesService {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
await this.licensesRepository.order(
|
await this.licensesRepository.order(
|
||||||
|
context,
|
||||||
poNumber,
|
poNumber,
|
||||||
myAccountId,
|
myAccountId,
|
||||||
parentAccountId,
|
parentAccountId,
|
||||||
@ -134,7 +135,7 @@ export class LicensesService {
|
|||||||
// ユーザIDからアカウントIDを取得する
|
// ユーザIDからアカウントIDを取得する
|
||||||
try {
|
try {
|
||||||
myAccountId = (
|
myAccountId = (
|
||||||
await this.usersRepository.findUserByExternalId(externalId)
|
await this.usersRepository.findUserByExternalId(context, externalId)
|
||||||
).account_id;
|
).account_id;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.logger.error(`[${context.getTrackingId()}] error=${e}`);
|
this.logger.error(`[${context.getTrackingId()}] error=${e}`);
|
||||||
@ -153,6 +154,7 @@ export class LicensesService {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const licenseKeys = await this.licensesRepository.createCardLicenses(
|
const licenseKeys = await this.licensesRepository.createCardLicenses(
|
||||||
|
context,
|
||||||
myAccountId,
|
myAccountId,
|
||||||
createCount,
|
createCount,
|
||||||
);
|
);
|
||||||
@ -194,7 +196,7 @@ export class LicensesService {
|
|||||||
// ユーザIDからアカウントIDを取得する
|
// ユーザIDからアカウントIDを取得する
|
||||||
try {
|
try {
|
||||||
myAccountId = (
|
myAccountId = (
|
||||||
await this.usersRepository.findUserByExternalId(externalId)
|
await this.usersRepository.findUserByExternalId(context, externalId)
|
||||||
).account_id;
|
).account_id;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.logger.error(`[${context.getTrackingId()}] error=${e}`);
|
this.logger.error(`[${context.getTrackingId()}] error=${e}`);
|
||||||
@ -215,6 +217,7 @@ export class LicensesService {
|
|||||||
// カードライセンスを取り込む
|
// カードライセンスを取り込む
|
||||||
try {
|
try {
|
||||||
await this.licensesRepository.activateCardLicense(
|
await this.licensesRepository.activateCardLicense(
|
||||||
|
context,
|
||||||
myAccountId,
|
myAccountId,
|
||||||
cardLicenseKey,
|
cardLicenseKey,
|
||||||
);
|
);
|
||||||
@ -266,11 +269,14 @@ export class LicensesService {
|
|||||||
// ユーザIDからアカウントIDを取得する
|
// ユーザIDからアカウントIDを取得する
|
||||||
try {
|
try {
|
||||||
const myAccountId = (
|
const myAccountId = (
|
||||||
await this.usersRepository.findUserByExternalId(userId)
|
await this.usersRepository.findUserByExternalId(context, userId)
|
||||||
).account_id;
|
).account_id;
|
||||||
// 割り当て可能なライセンスを取得する
|
// 割り当て可能なライセンスを取得する
|
||||||
const allocatableLicenses =
|
const allocatableLicenses =
|
||||||
await this.licensesRepository.getAllocatableLicenses(myAccountId);
|
await this.licensesRepository.getAllocatableLicenses(
|
||||||
|
context,
|
||||||
|
myAccountId,
|
||||||
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
allocatableLicenses,
|
allocatableLicenses,
|
||||||
@ -316,10 +322,10 @@ export class LicensesService {
|
|||||||
try {
|
try {
|
||||||
// ユーザIDからアカウントIDを取得する
|
// ユーザIDからアカウントIDを取得する
|
||||||
myAccountId = (
|
myAccountId = (
|
||||||
await this.usersRepository.findUserByExternalId(externalId)
|
await this.usersRepository.findUserByExternalId(context, externalId)
|
||||||
).account_id;
|
).account_id;
|
||||||
// 注文キャンセル処理
|
// 注文キャンセル処理
|
||||||
await this.licensesRepository.cancelOrder(myAccountId, poNumber);
|
await this.licensesRepository.cancelOrder(context, myAccountId, poNumber);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.logger.error(`[${context.getTrackingId()}] error=${e}`);
|
this.logger.error(`[${context.getTrackingId()}] error=${e}`);
|
||||||
switch (e.constructor) {
|
switch (e.constructor) {
|
||||||
|
|||||||
@ -34,7 +34,9 @@ export class NotificationService {
|
|||||||
// ユーザIDからアカウントIDを取得する
|
// ユーザIDからアカウントIDを取得する
|
||||||
let userId: number;
|
let userId: number;
|
||||||
try {
|
try {
|
||||||
userId = (await this.usersRepository.findUserByExternalId(externalId)).id;
|
userId = (
|
||||||
|
await this.usersRepository.findUserByExternalId(context, externalId)
|
||||||
|
).id;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.logger.error(`[${context.getTrackingId()}] error=${e}`);
|
this.logger.error(`[${context.getTrackingId()}] error=${e}`);
|
||||||
switch (e.constructor) {
|
switch (e.constructor) {
|
||||||
|
|||||||
@ -309,8 +309,9 @@ describe('TasksService', () => {
|
|||||||
const status = ['Uploaded', 'Backup'];
|
const status = ['Uploaded', 'Backup'];
|
||||||
const paramName = 'JOB_NUMBER';
|
const paramName = 'JOB_NUMBER';
|
||||||
const direction = 'ASC';
|
const direction = 'ASC';
|
||||||
|
const context = makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId');
|
||||||
const result = await service.tasksService.getTasks(
|
const result = await service.tasksService.getTasks(
|
||||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
context,
|
||||||
userId,
|
userId,
|
||||||
[USER_ROLES.AUTHOR],
|
[USER_ROLES.AUTHOR],
|
||||||
offset,
|
offset,
|
||||||
@ -360,7 +361,7 @@ describe('TasksService', () => {
|
|||||||
});
|
});
|
||||||
expect(
|
expect(
|
||||||
service.taskRepoService.getTasksFromAuthorIdAndAccountId,
|
service.taskRepoService.getTasksFromAuthorIdAndAccountId,
|
||||||
).toHaveBeenCalledWith('abcdef', 1, 0, 20, 'JOB_NUMBER', 'ASC', [
|
).toHaveBeenCalledWith(context, 'abcdef', 1, 0, 20, 'JOB_NUMBER', 'ASC', [
|
||||||
'Uploaded',
|
'Uploaded',
|
||||||
'Backup',
|
'Backup',
|
||||||
]);
|
]);
|
||||||
@ -437,8 +438,9 @@ describe('TasksService', () => {
|
|||||||
const status = ['Uploaded', 'Backup'];
|
const status = ['Uploaded', 'Backup'];
|
||||||
const paramName = 'JOB_NUMBER';
|
const paramName = 'JOB_NUMBER';
|
||||||
const direction = 'ASC';
|
const direction = 'ASC';
|
||||||
|
const context = makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId');
|
||||||
const result = await service.tasksService.getTasks(
|
const result = await service.tasksService.getTasks(
|
||||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
context,
|
||||||
userId,
|
userId,
|
||||||
[USER_ROLES.TYPIST],
|
[USER_ROLES.TYPIST],
|
||||||
offset,
|
offset,
|
||||||
@ -488,7 +490,7 @@ describe('TasksService', () => {
|
|||||||
});
|
});
|
||||||
expect(
|
expect(
|
||||||
service.taskRepoService.getTasksFromTypistRelations,
|
service.taskRepoService.getTasksFromTypistRelations,
|
||||||
).toHaveBeenCalledWith('userId', 0, 20, 'JOB_NUMBER', 'ASC', [
|
).toHaveBeenCalledWith(context, 'userId', 0, 20, 'JOB_NUMBER', 'ASC', [
|
||||||
'Uploaded',
|
'Uploaded',
|
||||||
'Backup',
|
'Backup',
|
||||||
]);
|
]);
|
||||||
|
|||||||
@ -74,10 +74,11 @@ export class TasksService {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const { account_id, author_id } =
|
const { account_id, author_id } =
|
||||||
await this.usersRepository.findUserByExternalId(userId);
|
await this.usersRepository.findUserByExternalId(context, userId);
|
||||||
|
|
||||||
if (roles.includes(ADMIN_ROLES.ADMIN)) {
|
if (roles.includes(ADMIN_ROLES.ADMIN)) {
|
||||||
const result = await this.taskRepository.getTasksFromAccountId(
|
const result = await this.taskRepository.getTasksFromAccountId(
|
||||||
|
context,
|
||||||
account_id,
|
account_id,
|
||||||
offset,
|
offset,
|
||||||
limit,
|
limit,
|
||||||
@ -104,6 +105,7 @@ export class TasksService {
|
|||||||
}
|
}
|
||||||
const result =
|
const result =
|
||||||
await this.taskRepository.getTasksFromAuthorIdAndAccountId(
|
await this.taskRepository.getTasksFromAuthorIdAndAccountId(
|
||||||
|
context,
|
||||||
author_id,
|
author_id,
|
||||||
account_id,
|
account_id,
|
||||||
offset,
|
offset,
|
||||||
@ -126,6 +128,7 @@ export class TasksService {
|
|||||||
|
|
||||||
if (roles.includes(USER_ROLES.TYPIST)) {
|
if (roles.includes(USER_ROLES.TYPIST)) {
|
||||||
const result = await this.taskRepository.getTasksFromTypistRelations(
|
const result = await this.taskRepository.getTasksFromTypistRelations(
|
||||||
|
context,
|
||||||
userId,
|
userId,
|
||||||
offset,
|
offset,
|
||||||
limit,
|
limit,
|
||||||
@ -187,10 +190,11 @@ export class TasksService {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const { account_id: accountId, id } =
|
const { account_id: accountId, id } =
|
||||||
await this.usersRepository.findUserByExternalId(externalId);
|
await this.usersRepository.findUserByExternalId(context, externalId);
|
||||||
|
|
||||||
// タスク一覧を取得する
|
// タスク一覧を取得する
|
||||||
const tasks = await this.taskRepository.getSortedTasks(
|
const tasks = await this.taskRepository.getSortedTasks(
|
||||||
|
context,
|
||||||
accountId,
|
accountId,
|
||||||
id,
|
id,
|
||||||
fileId,
|
fileId,
|
||||||
@ -268,7 +272,7 @@ export class TasksService {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const { id, account_id, author_id } =
|
const { id, account_id, author_id } =
|
||||||
await this.usersRepository.findUserByExternalId(externalId);
|
await this.usersRepository.findUserByExternalId(context, externalId);
|
||||||
|
|
||||||
if (roles.includes(USER_ROLES.AUTHOR)) {
|
if (roles.includes(USER_ROLES.AUTHOR)) {
|
||||||
// API実行者がAuthorで、AuthorIDが存在しないことは想定外のため、エラーとする
|
// API実行者がAuthorで、AuthorIDが存在しないことは想定外のため、エラーとする
|
||||||
@ -276,6 +280,7 @@ export class TasksService {
|
|||||||
throw new Error('AuthorID not found');
|
throw new Error('AuthorID not found');
|
||||||
}
|
}
|
||||||
await this.taskRepository.getTaskFromAudioFileId(
|
await this.taskRepository.getTaskFromAudioFileId(
|
||||||
|
context,
|
||||||
audioFileId,
|
audioFileId,
|
||||||
account_id,
|
account_id,
|
||||||
author_id,
|
author_id,
|
||||||
@ -284,11 +289,13 @@ export class TasksService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (roles.includes(USER_ROLES.TYPIST)) {
|
if (roles.includes(USER_ROLES.TYPIST)) {
|
||||||
return await this.taskRepository.checkout(audioFileId, account_id, id, [
|
return await this.taskRepository.checkout(
|
||||||
TASK_STATUS.UPLOADED,
|
context,
|
||||||
TASK_STATUS.PENDING,
|
audioFileId,
|
||||||
TASK_STATUS.IN_PROGRESS,
|
account_id,
|
||||||
]);
|
id,
|
||||||
|
[TASK_STATUS.UPLOADED, TASK_STATUS.PENDING, TASK_STATUS.IN_PROGRESS],
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new InvalidRoleError(`invalid roles: ${roles.join(',')}`);
|
throw new InvalidRoleError(`invalid roles: ${roles.join(',')}`);
|
||||||
@ -351,10 +358,12 @@ export class TasksService {
|
|||||||
} | params: { audioFileId: ${audioFileId}, externalId: ${externalId} };`,
|
} | params: { audioFileId: ${audioFileId}, externalId: ${externalId} };`,
|
||||||
);
|
);
|
||||||
const { id } = await this.usersRepository.findUserByExternalId(
|
const { id } = await this.usersRepository.findUserByExternalId(
|
||||||
|
context,
|
||||||
externalId,
|
externalId,
|
||||||
);
|
);
|
||||||
|
|
||||||
return await this.taskRepository.checkin(
|
return await this.taskRepository.checkin(
|
||||||
|
context,
|
||||||
audioFileId,
|
audioFileId,
|
||||||
id,
|
id,
|
||||||
TASK_STATUS.IN_PROGRESS,
|
TASK_STATUS.IN_PROGRESS,
|
||||||
@ -412,7 +421,10 @@ export class TasksService {
|
|||||||
let user: User;
|
let user: User;
|
||||||
try {
|
try {
|
||||||
// ユーザー取得
|
// ユーザー取得
|
||||||
user = await this.usersRepository.findUserByExternalId(externalId);
|
user = await this.usersRepository.findUserByExternalId(
|
||||||
|
context,
|
||||||
|
externalId,
|
||||||
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.logger.error(`[${context.getTrackingId()}] error=${e}`);
|
this.logger.error(`[${context.getTrackingId()}] error=${e}`);
|
||||||
this.logger.log(`[OUT] [${context.getTrackingId()}] ${this.cancel.name}`);
|
this.logger.log(`[OUT] [${context.getTrackingId()}] ${this.cancel.name}`);
|
||||||
@ -425,6 +437,7 @@ export class TasksService {
|
|||||||
try {
|
try {
|
||||||
// roleにAdminが含まれていれば、文字起こし担当でなくてもキャンセルできるため、ユーザーIDは指定しない
|
// roleにAdminが含まれていれば、文字起こし担当でなくてもキャンセルできるため、ユーザーIDは指定しない
|
||||||
await this.taskRepository.cancel(
|
await this.taskRepository.cancel(
|
||||||
|
context,
|
||||||
audioFileId,
|
audioFileId,
|
||||||
[TASK_STATUS.IN_PROGRESS, TASK_STATUS.PENDING],
|
[TASK_STATUS.IN_PROGRESS, TASK_STATUS.PENDING],
|
||||||
user.account_id,
|
user.account_id,
|
||||||
@ -462,6 +475,7 @@ export class TasksService {
|
|||||||
// キャンセルしたタスクに自動ルーティングを行う
|
// キャンセルしたタスクに自動ルーティングを行う
|
||||||
const { typistGroupIds, typistIds } =
|
const { typistGroupIds, typistIds } =
|
||||||
await this.taskRepository.autoRouting(
|
await this.taskRepository.autoRouting(
|
||||||
|
context,
|
||||||
audioFileId,
|
audioFileId,
|
||||||
user.account_id,
|
user.account_id,
|
||||||
user.author_id ?? undefined,
|
user.author_id ?? undefined,
|
||||||
@ -504,10 +518,12 @@ export class TasksService {
|
|||||||
} | params: { audioFileId: ${audioFileId}, externalId: ${externalId} };`,
|
} | params: { audioFileId: ${audioFileId}, externalId: ${externalId} };`,
|
||||||
);
|
);
|
||||||
const { id } = await this.usersRepository.findUserByExternalId(
|
const { id } = await this.usersRepository.findUserByExternalId(
|
||||||
|
context,
|
||||||
externalId,
|
externalId,
|
||||||
);
|
);
|
||||||
|
|
||||||
return await this.taskRepository.suspend(
|
return await this.taskRepository.suspend(
|
||||||
|
context,
|
||||||
audioFileId,
|
audioFileId,
|
||||||
id,
|
id,
|
||||||
TASK_STATUS.IN_PROGRESS,
|
TASK_STATUS.IN_PROGRESS,
|
||||||
@ -564,9 +580,9 @@ export class TasksService {
|
|||||||
} | params: { audioFileId: ${audioFileId}, externalId: ${externalId} };`,
|
} | params: { audioFileId: ${audioFileId}, externalId: ${externalId} };`,
|
||||||
);
|
);
|
||||||
const { account_id: accountId } =
|
const { account_id: accountId } =
|
||||||
await this.usersRepository.findUserByExternalId(externalId);
|
await this.usersRepository.findUserByExternalId(context, externalId);
|
||||||
|
|
||||||
await this.taskRepository.backup(accountId, audioFileId, [
|
await this.taskRepository.backup(context, accountId, audioFileId, [
|
||||||
TASK_STATUS.FINISHED,
|
TASK_STATUS.FINISHED,
|
||||||
TASK_STATUS.BACKUP,
|
TASK_STATUS.BACKUP,
|
||||||
]);
|
]);
|
||||||
@ -651,13 +667,14 @@ export class TasksService {
|
|||||||
} | params: { audioFileId: ${audioFileId}, assignees: ${assignees}, externalId: ${externalId}, role: ${role} };`,
|
} | params: { audioFileId: ${audioFileId}, assignees: ${assignees}, externalId: ${externalId}, role: ${role} };`,
|
||||||
);
|
);
|
||||||
const { author_id, account_id } =
|
const { author_id, account_id } =
|
||||||
await this.usersRepository.findUserByExternalId(externalId);
|
await this.usersRepository.findUserByExternalId(context, externalId);
|
||||||
// RoleがAuthorで、AuthorIDが存在しないことは想定外のため、エラーとする
|
// RoleがAuthorで、AuthorIDが存在しないことは想定外のため、エラーとする
|
||||||
if (role.includes(USER_ROLES.AUTHOR) && !author_id) {
|
if (role.includes(USER_ROLES.AUTHOR) && !author_id) {
|
||||||
throw new Error('AuthorID not found');
|
throw new Error('AuthorID not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.taskRepository.changeCheckoutPermission(
|
await this.taskRepository.changeCheckoutPermission(
|
||||||
|
context,
|
||||||
audioFileId,
|
audioFileId,
|
||||||
author_id ?? undefined,
|
author_id ?? undefined,
|
||||||
account_id,
|
account_id,
|
||||||
@ -737,6 +754,7 @@ export class TasksService {
|
|||||||
);
|
);
|
||||||
const groupMembers =
|
const groupMembers =
|
||||||
await this.userGroupsRepositoryService.getGroupMembersFromGroupIds(
|
await this.userGroupsRepositoryService.getGroupMembersFromGroupIds(
|
||||||
|
context,
|
||||||
typistGroupIds,
|
typistGroupIds,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -757,6 +775,7 @@ export class TasksService {
|
|||||||
|
|
||||||
// 通知内容に含む音声ファイル情報を取得
|
// 通知内容に含む音声ファイル情報を取得
|
||||||
const { file } = await this.taskRepository.getTaskAndAudioFile(
|
const { file } = await this.taskRepository.getTaskAndAudioFile(
|
||||||
|
context,
|
||||||
audioFileId,
|
audioFileId,
|
||||||
accountId,
|
accountId,
|
||||||
[TASK_STATUS.UPLOADED],
|
[TASK_STATUS.UPLOADED],
|
||||||
|
|||||||
@ -31,10 +31,10 @@ export class TemplatesService {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const { account_id: accountId } =
|
const { account_id: accountId } =
|
||||||
await this.usersRepository.findUserByExternalId(externalId);
|
await this.usersRepository.findUserByExternalId(context, externalId);
|
||||||
|
|
||||||
const templateFileRecords =
|
const templateFileRecords =
|
||||||
await this.templateFilesRepository.getTemplateFiles(accountId);
|
await this.templateFilesRepository.getTemplateFiles(context, accountId);
|
||||||
|
|
||||||
// DBから取得したテンプレートファイルのレコードをレスポンス用に整形する
|
// DBから取得したテンプレートファイルのレコードをレスポンス用に整形する
|
||||||
const resTemplates = templateFileRecords.map((templateFile) => ({
|
const resTemplates = templateFileRecords.map((templateFile) => ({
|
||||||
|
|||||||
@ -20,7 +20,7 @@ export class TermsService {
|
|||||||
);
|
);
|
||||||
try {
|
try {
|
||||||
const { eulaVersion, privacyNoticeVersion, dpaVersion } =
|
const { eulaVersion, privacyNoticeVersion, dpaVersion } =
|
||||||
await this.termsRepository.getLatestTermsInfo();
|
await this.termsRepository.getLatestTermsInfo(context);
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
documentType: TERM_TYPE.EULA,
|
documentType: TERM_TYPE.EULA,
|
||||||
|
|||||||
@ -94,6 +94,7 @@ export class UsersService {
|
|||||||
// トランザクションで取得と更新をまとめる
|
// トランザクションで取得と更新をまとめる
|
||||||
const userId = decodedToken.userId;
|
const userId = decodedToken.userId;
|
||||||
await this.usersRepository.updateUserVerifiedAndCreateTrialLicense(
|
await this.usersRepository.updateUserVerifiedAndCreateTrialLicense(
|
||||||
|
context,
|
||||||
userId,
|
userId,
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@ -167,7 +168,10 @@ export class UsersService {
|
|||||||
//DBよりアクセス者の所属するアカウントIDを取得する
|
//DBよりアクセス者の所属するアカウントIDを取得する
|
||||||
let adminUser: EntityUser;
|
let adminUser: EntityUser;
|
||||||
try {
|
try {
|
||||||
adminUser = await this.usersRepository.findUserByExternalId(externalId);
|
adminUser = await this.usersRepository.findUserByExternalId(
|
||||||
|
context,
|
||||||
|
externalId,
|
||||||
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.logger.error(`[${context.getTrackingId()}] error=${e}`);
|
this.logger.error(`[${context.getTrackingId()}] error=${e}`);
|
||||||
throw new HttpException(
|
throw new HttpException(
|
||||||
@ -183,6 +187,7 @@ export class UsersService {
|
|||||||
let isAuthorIdDuplicated = false;
|
let isAuthorIdDuplicated = false;
|
||||||
try {
|
try {
|
||||||
isAuthorIdDuplicated = await this.usersRepository.existsAuthorId(
|
isAuthorIdDuplicated = await this.usersRepository.existsAuthorId(
|
||||||
|
context,
|
||||||
accountId,
|
accountId,
|
||||||
authorId,
|
authorId,
|
||||||
);
|
);
|
||||||
@ -479,7 +484,7 @@ export class UsersService {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
// ユーザー情報からAzure AD B2CのIDを特定する
|
// ユーザー情報からAzure AD B2CのIDを特定する
|
||||||
const user = await this.usersRepository.findUserById(userId);
|
const user = await this.usersRepository.findUserById(context, userId);
|
||||||
const extarnalId = user.external_id;
|
const extarnalId = user.external_id;
|
||||||
// パスワードを変更する
|
// パスワードを変更する
|
||||||
await this.adB2cService.changePassword(
|
await this.adB2cService.changePassword(
|
||||||
@ -488,7 +493,7 @@ export class UsersService {
|
|||||||
ramdomPassword,
|
ramdomPassword,
|
||||||
);
|
);
|
||||||
// ユーザを認証済みにする
|
// ユーザを認証済みにする
|
||||||
await this.usersRepository.updateUserVerified(userId);
|
await this.usersRepository.updateUserVerified(context, userId);
|
||||||
// TODO [Task2163] ODMS側が正式にメッセージを決めるまで仮のメール内容とする
|
// TODO [Task2163] ODMS側が正式にメッセージを決めるまで仮のメール内容とする
|
||||||
const subject = 'A temporary password has been issued.';
|
const subject = 'A temporary password has been issued.';
|
||||||
const text = 'temporary password: ' + ramdomPassword;
|
const text = 'temporary password: ' + ramdomPassword;
|
||||||
@ -663,7 +668,10 @@ export class UsersService {
|
|||||||
let user: EntityUser;
|
let user: EntityUser;
|
||||||
try {
|
try {
|
||||||
// ユーザー情報を取得
|
// ユーザー情報を取得
|
||||||
user = await this.usersRepository.findUserByExternalId(externalId);
|
user = await this.usersRepository.findUserByExternalId(
|
||||||
|
context,
|
||||||
|
externalId,
|
||||||
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.logger.error(`[${context.getTrackingId()}] error=${e}`);
|
this.logger.error(`[${context.getTrackingId()}] error=${e}`);
|
||||||
|
|
||||||
@ -676,6 +684,7 @@ export class UsersService {
|
|||||||
try {
|
try {
|
||||||
// ユーザーのソート条件を更新
|
// ユーザーのソート条件を更新
|
||||||
await this.sortCriteriaRepository.updateSortCriteria(
|
await this.sortCriteriaRepository.updateSortCriteria(
|
||||||
|
context,
|
||||||
user.id,
|
user.id,
|
||||||
paramName,
|
paramName,
|
||||||
direction,
|
direction,
|
||||||
@ -712,7 +721,10 @@ export class UsersService {
|
|||||||
let user: EntityUser;
|
let user: EntityUser;
|
||||||
try {
|
try {
|
||||||
// ユーザー情報を取得
|
// ユーザー情報を取得
|
||||||
user = await this.usersRepository.findUserByExternalId(externalId);
|
user = await this.usersRepository.findUserByExternalId(
|
||||||
|
context,
|
||||||
|
externalId,
|
||||||
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.logger.error(`[${context.getTrackingId()}] error=${e}`);
|
this.logger.error(`[${context.getTrackingId()}] error=${e}`);
|
||||||
|
|
||||||
@ -725,6 +737,7 @@ export class UsersService {
|
|||||||
try {
|
try {
|
||||||
// ユーザーのソート条件を取得
|
// ユーザーのソート条件を取得
|
||||||
const sortCriteria = await this.sortCriteriaRepository.getSortCriteria(
|
const sortCriteria = await this.sortCriteriaRepository.getSortCriteria(
|
||||||
|
context,
|
||||||
user.id,
|
user.id,
|
||||||
);
|
);
|
||||||
const { direction, parameter } = sortCriteria;
|
const { direction, parameter } = sortCriteria;
|
||||||
@ -764,11 +777,14 @@ export class UsersService {
|
|||||||
} | params: { userId: ${userId} };`,
|
} | params: { userId: ${userId} };`,
|
||||||
);
|
);
|
||||||
try {
|
try {
|
||||||
const { id } = await this.usersRepository.findUserByExternalId(userId);
|
const { id } = await this.usersRepository.findUserByExternalId(
|
||||||
|
context,
|
||||||
|
userId,
|
||||||
|
);
|
||||||
|
|
||||||
// ユーザー関連情報を取得
|
// ユーザー関連情報を取得
|
||||||
const { user, authors, worktypes, activeWorktype } =
|
const { user, authors, worktypes, activeWorktype } =
|
||||||
await this.usersRepository.getUserRelations(id);
|
await this.usersRepository.getUserRelations(context, id);
|
||||||
|
|
||||||
// AuthorIDのリストを作成
|
// AuthorIDのリストを作成
|
||||||
const authorIds = authors.flatMap((author) =>
|
const authorIds = authors.flatMap((author) =>
|
||||||
@ -883,11 +899,12 @@ export class UsersService {
|
|||||||
|
|
||||||
// 実行ユーザーのアカウントIDを取得
|
// 実行ユーザーのアカウントIDを取得
|
||||||
const accountId = (
|
const accountId = (
|
||||||
await this.usersRepository.findUserByExternalId(extarnalId)
|
await this.usersRepository.findUserByExternalId(context, extarnalId)
|
||||||
).account_id;
|
).account_id;
|
||||||
|
|
||||||
// ユーザー情報を更新
|
// ユーザー情報を更新
|
||||||
await this.usersRepository.update(
|
await this.usersRepository.update(
|
||||||
|
context,
|
||||||
accountId,
|
accountId,
|
||||||
id,
|
id,
|
||||||
role,
|
role,
|
||||||
@ -961,10 +978,12 @@ export class UsersService {
|
|||||||
);
|
);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const accountId = (await this.usersRepository.findUserById(userId))
|
const accountId = (
|
||||||
.account_id;
|
await this.usersRepository.findUserById(context, userId)
|
||||||
|
).account_id;
|
||||||
|
|
||||||
await this.licensesRepository.allocateLicense(
|
await this.licensesRepository.allocateLicense(
|
||||||
|
context,
|
||||||
userId,
|
userId,
|
||||||
newLicenseId,
|
newLicenseId,
|
||||||
accountId,
|
accountId,
|
||||||
@ -1010,10 +1029,15 @@ export class UsersService {
|
|||||||
);
|
);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const accountId = (await this.usersRepository.findUserById(userId))
|
const accountId = (
|
||||||
.account_id;
|
await this.usersRepository.findUserById(context, userId)
|
||||||
|
).account_id;
|
||||||
|
|
||||||
await this.licensesRepository.deallocateLicense(userId, accountId);
|
await this.licensesRepository.deallocateLicense(
|
||||||
|
context,
|
||||||
|
userId,
|
||||||
|
accountId,
|
||||||
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.logger.error(`[${context.getTrackingId()}] error=${e}`);
|
this.logger.error(`[${context.getTrackingId()}] error=${e}`);
|
||||||
if (e instanceof Error) {
|
if (e instanceof Error) {
|
||||||
@ -1064,6 +1088,7 @@ export class UsersService {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
await this.usersRepository.updateAcceptedTermsVersion(
|
await this.usersRepository.updateAcceptedTermsVersion(
|
||||||
|
context,
|
||||||
externalId,
|
externalId,
|
||||||
eulaVersion,
|
eulaVersion,
|
||||||
privacyNoticeVersion,
|
privacyNoticeVersion,
|
||||||
@ -1115,7 +1140,7 @@ export class UsersService {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
// extarnalIdの存在チェックを行う
|
// extarnalIdの存在チェックを行う
|
||||||
await this.usersRepository.findUserByExternalId(externalId);
|
await this.usersRepository.findUserByExternalId(context, externalId);
|
||||||
// ADB2Cからユーザー名を取得する
|
// ADB2Cからユーザー名を取得する
|
||||||
const adb2cUser = await this.adB2cService.getUser(context, externalId);
|
const adb2cUser = await this.adB2cService.getUser(context, externalId);
|
||||||
return adb2cUser.displayName;
|
return adb2cUser.displayName;
|
||||||
|
|||||||
@ -41,10 +41,11 @@ export class WorkflowsService {
|
|||||||
);
|
);
|
||||||
try {
|
try {
|
||||||
const { account_id: accountId } =
|
const { account_id: accountId } =
|
||||||
await this.usersRepository.findUserByExternalId(externalId);
|
await this.usersRepository.findUserByExternalId(context, externalId);
|
||||||
|
|
||||||
// DBからワークフロー一覧を取得
|
// DBからワークフロー一覧を取得
|
||||||
const workflowRecords = await this.workflowsRepository.getWorkflows(
|
const workflowRecords = await this.workflowsRepository.getWorkflows(
|
||||||
|
context,
|
||||||
accountId,
|
accountId,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -165,9 +166,10 @@ export class WorkflowsService {
|
|||||||
);
|
);
|
||||||
try {
|
try {
|
||||||
const { account_id: accountId } =
|
const { account_id: accountId } =
|
||||||
await this.usersRepository.findUserByExternalId(externalId);
|
await this.usersRepository.findUserByExternalId(context, externalId);
|
||||||
|
|
||||||
await this.workflowsRepository.createtWorkflows(
|
await this.workflowsRepository.createtWorkflows(
|
||||||
|
context,
|
||||||
accountId,
|
accountId,
|
||||||
authorId,
|
authorId,
|
||||||
typists,
|
typists,
|
||||||
@ -253,9 +255,10 @@ export class WorkflowsService {
|
|||||||
);
|
);
|
||||||
try {
|
try {
|
||||||
const { account_id: accountId } =
|
const { account_id: accountId } =
|
||||||
await this.usersRepository.findUserByExternalId(externalId);
|
await this.usersRepository.findUserByExternalId(context, externalId);
|
||||||
|
|
||||||
await this.workflowsRepository.updatetWorkflow(
|
await this.workflowsRepository.updatetWorkflow(
|
||||||
|
context,
|
||||||
accountId,
|
accountId,
|
||||||
workflowId,
|
workflowId,
|
||||||
authorId,
|
authorId,
|
||||||
@ -336,6 +339,7 @@ export class WorkflowsService {
|
|||||||
);
|
);
|
||||||
try {
|
try {
|
||||||
const { account } = await this.usersRepository.findUserByExternalId(
|
const { account } = await this.usersRepository.findUserByExternalId(
|
||||||
|
context,
|
||||||
externalId,
|
externalId,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -345,7 +349,11 @@ export class WorkflowsService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.workflowsRepository.deleteWorkflow(account.id, workflowId);
|
await this.workflowsRepository.deleteWorkflow(
|
||||||
|
context,
|
||||||
|
account.id,
|
||||||
|
workflowId,
|
||||||
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.logger.error(`[${context.getTrackingId()}] error=${e}`);
|
this.logger.error(`[${context.getTrackingId()}] error=${e}`);
|
||||||
if (e instanceof Error) {
|
if (e instanceof Error) {
|
||||||
|
|||||||
@ -57,6 +57,7 @@ import { AudioOptionItem } from '../audio_option_items/entity/audio_option_item.
|
|||||||
import { UserGroup } from '../user_groups/entity/user_group.entity';
|
import { UserGroup } from '../user_groups/entity/user_group.entity';
|
||||||
import { UserGroupMember } from '../user_groups/entity/user_group_member.entity';
|
import { UserGroupMember } from '../user_groups/entity/user_group_member.entity';
|
||||||
import { TemplateFile } from '../template_files/entity/template_file.entity';
|
import { TemplateFile } from '../template_files/entity/template_file.entity';
|
||||||
|
import { Context } from '../../common/log';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class AccountsRepositoryService {
|
export class AccountsRepositoryService {
|
||||||
@ -211,11 +212,12 @@ export class AccountsRepositoryService {
|
|||||||
* @param id
|
* @param id
|
||||||
* @returns account
|
* @returns account
|
||||||
*/
|
*/
|
||||||
async findAccountById(id: number): Promise<Account> {
|
async findAccountById(context: Context, id: number): Promise<Account> {
|
||||||
const account = await this.dataSource.getRepository(Account).findOne({
|
const account = await this.dataSource.getRepository(Account).findOne({
|
||||||
where: {
|
where: {
|
||||||
id: id,
|
id: id,
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!account) {
|
if (!account) {
|
||||||
@ -234,6 +236,7 @@ export class AccountsRepositoryService {
|
|||||||
* @returns expiringSoonLicense
|
* @returns expiringSoonLicense
|
||||||
*/
|
*/
|
||||||
private async getExpiringSoonLicense(
|
private async getExpiringSoonLicense(
|
||||||
|
context: Context,
|
||||||
entityManager: EntityManager,
|
entityManager: EntityManager,
|
||||||
id: number,
|
id: number,
|
||||||
currentDate: Date,
|
currentDate: Date,
|
||||||
@ -248,6 +251,7 @@ export class AccountsRepositoryService {
|
|||||||
expiry_date: Between(currentDate, expiringSoonDate),
|
expiry_date: Between(currentDate, expiringSoonDate),
|
||||||
status: Not(LICENSE_ALLOCATED_STATUS.DELETED),
|
status: Not(LICENSE_ALLOCATED_STATUS.DELETED),
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
return expiringSoonLicense;
|
return expiringSoonLicense;
|
||||||
@ -262,6 +266,7 @@ export class AccountsRepositoryService {
|
|||||||
* @returns allocatableLicenseWithMargin
|
* @returns allocatableLicenseWithMargin
|
||||||
*/
|
*/
|
||||||
private async getAllocatableLicenseWithMargin(
|
private async getAllocatableLicenseWithMargin(
|
||||||
|
context: Context,
|
||||||
entityManager: EntityManager,
|
entityManager: EntityManager,
|
||||||
id: number,
|
id: number,
|
||||||
expiringSoonDate: Date,
|
expiringSoonDate: Date,
|
||||||
@ -288,6 +293,7 @@ export class AccountsRepositoryService {
|
|||||||
expiry_date: IsNull(),
|
expiry_date: IsNull(),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
return allocatableLicenseWithMargin;
|
return allocatableLicenseWithMargin;
|
||||||
@ -301,6 +307,7 @@ export class AccountsRepositoryService {
|
|||||||
* @returns licenseSummary
|
* @returns licenseSummary
|
||||||
*/
|
*/
|
||||||
async getLicenseSummaryInfo(
|
async getLicenseSummaryInfo(
|
||||||
|
context: Context,
|
||||||
id: number,
|
id: number,
|
||||||
currentDate: Date,
|
currentDate: Date,
|
||||||
expiringSoonDate: Date,
|
expiringSoonDate: Date,
|
||||||
@ -326,6 +333,7 @@ export class AccountsRepositoryService {
|
|||||||
status: Not(LICENSE_ALLOCATED_STATUS.DELETED),
|
status: Not(LICENSE_ALLOCATED_STATUS.DELETED),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
// 有効な総ライセンス数のうち、ユーザーに割り当て済みのライセンス数を取得する
|
// 有効な総ライセンス数のうち、ユーザーに割り当て済みのライセンス数を取得する
|
||||||
@ -360,6 +368,7 @@ export class AccountsRepositoryService {
|
|||||||
status: LICENSE_ALLOCATED_STATUS.REUSABLE,
|
status: LICENSE_ALLOCATED_STATUS.REUSABLE,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
// 総ライセンス数のうち、一度もユーザーに割り当てたことのないライセンス数を取得する
|
// 総ライセンス数のうち、一度もユーザーに割り当てたことのないライセンス数を取得する
|
||||||
@ -376,10 +385,12 @@ export class AccountsRepositoryService {
|
|||||||
status: LICENSE_ALLOCATED_STATUS.UNALLOCATED,
|
status: LICENSE_ALLOCATED_STATUS.UNALLOCATED,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
// 有効期限が現在日付からしきい値以内のライセンス数を取得する
|
// 有効期限が現在日付からしきい値以内のライセンス数を取得する
|
||||||
const expiringSoonLicense = await this.getExpiringSoonLicense(
|
const expiringSoonLicense = await this.getExpiringSoonLicense(
|
||||||
|
context,
|
||||||
entityManager,
|
entityManager,
|
||||||
id,
|
id,
|
||||||
currentDate,
|
currentDate,
|
||||||
@ -392,6 +403,7 @@ export class AccountsRepositoryService {
|
|||||||
from_account_id: id,
|
from_account_id: id,
|
||||||
status: LICENSE_ISSUE_STATUS.ISSUE_REQUESTING,
|
status: LICENSE_ISSUE_STATUS.ISSUE_REQUESTING,
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
// 未発行状態あるいは発行キャンセルされた注文の総ライセンス数を取得する
|
// 未発行状態あるいは発行キャンセルされた注文の総ライセンス数を取得する
|
||||||
@ -402,19 +414,22 @@ export class AccountsRepositoryService {
|
|||||||
.andWhere('license_orders.status = :status', {
|
.andWhere('license_orders.status = :status', {
|
||||||
status: LICENSE_ISSUE_STATUS.ISSUE_REQUESTING,
|
status: LICENSE_ISSUE_STATUS.ISSUE_REQUESTING,
|
||||||
})
|
})
|
||||||
|
.comment(`${context.getTrackingId()}_${new Date().toUTCString()}`)
|
||||||
.getRawOne();
|
.getRawOne();
|
||||||
const issueRequesting = parseInt(result.sum, 10) || 0;
|
const issueRequesting = parseInt(result.sum, 10) || 0;
|
||||||
|
|
||||||
// 有効期限がしきい値より未来または未設定で、割り当て可能なライセンス数の取得を行う
|
// 有効期限がしきい値より未来または未設定で、割り当て可能なライセンス数の取得を行う
|
||||||
const allocatableLicenseWithMargin =
|
const allocatableLicenseWithMargin =
|
||||||
await this.getAllocatableLicenseWithMargin(
|
await this.getAllocatableLicenseWithMargin(
|
||||||
|
context,
|
||||||
entityManager,
|
entityManager,
|
||||||
id,
|
id,
|
||||||
expiringSoonDate,
|
expiringSoonDate,
|
||||||
);
|
);
|
||||||
|
|
||||||
// アカウントのロック状態を取得する
|
// アカウントのロック状態を取得する
|
||||||
const isStorageAvailable = (await this.findAccountById(id)).locked;
|
const isStorageAvailable = (await this.findAccountById(context, id))
|
||||||
|
.locked;
|
||||||
|
|
||||||
let licenseSummary = new LicenseSummaryInfo();
|
let licenseSummary = new LicenseSummaryInfo();
|
||||||
licenseSummary = {
|
licenseSummary = {
|
||||||
@ -442,6 +457,7 @@ export class AccountsRepositoryService {
|
|||||||
* @returns issueRequesting
|
* @returns issueRequesting
|
||||||
*/
|
*/
|
||||||
private async getAccountLicenseOrderStatus(
|
private async getAccountLicenseOrderStatus(
|
||||||
|
context: Context,
|
||||||
id: number,
|
id: number,
|
||||||
currentDate: Date,
|
currentDate: Date,
|
||||||
entityManager: EntityManager,
|
entityManager: EntityManager,
|
||||||
@ -467,6 +483,7 @@ export class AccountsRepositoryService {
|
|||||||
status: Not(LICENSE_ALLOCATED_STATUS.DELETED),
|
status: Not(LICENSE_ALLOCATED_STATUS.DELETED),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
// 子アカウントからの、未発行状態あるいは発行キャンセルされた注文の総ライセンス数を取得する
|
// 子アカウントからの、未発行状態あるいは発行キャンセルされた注文の総ライセンス数を取得する
|
||||||
@ -477,6 +494,7 @@ export class AccountsRepositoryService {
|
|||||||
.andWhere('license_orders.status = :status', {
|
.andWhere('license_orders.status = :status', {
|
||||||
status: LICENSE_ISSUE_STATUS.ISSUE_REQUESTING,
|
status: LICENSE_ISSUE_STATUS.ISSUE_REQUESTING,
|
||||||
})
|
})
|
||||||
|
.comment(`${context.getTrackingId()}_${new Date().toUTCString()}`)
|
||||||
.getRawOne();
|
.getRawOne();
|
||||||
const issuedRequested = parseInt(issuedRequestedSqlResult.sum, 10) || 0;
|
const issuedRequested = parseInt(issuedRequestedSqlResult.sum, 10) || 0;
|
||||||
|
|
||||||
@ -488,6 +506,7 @@ export class AccountsRepositoryService {
|
|||||||
.andWhere('license_orders.status = :status', {
|
.andWhere('license_orders.status = :status', {
|
||||||
status: LICENSE_ISSUE_STATUS.ISSUE_REQUESTING,
|
status: LICENSE_ISSUE_STATUS.ISSUE_REQUESTING,
|
||||||
})
|
})
|
||||||
|
.comment(`${context.getTrackingId()}_${new Date().toUTCString()}`)
|
||||||
.getRawOne();
|
.getRawOne();
|
||||||
const issuedRequesting = parseInt(issuedRequestingSqlResult.sum, 10) || 0;
|
const issuedRequesting = parseInt(issuedRequestingSqlResult.sum, 10) || 0;
|
||||||
|
|
||||||
@ -508,6 +527,7 @@ export class AccountsRepositoryService {
|
|||||||
* @returns childrenPartnerLicensesFromRepository: リポジトリから取得した子アカウントのライセンス情報
|
* @returns childrenPartnerLicensesFromRepository: リポジトリから取得した子アカウントのライセンス情報
|
||||||
*/
|
*/
|
||||||
async getPartnerLicense(
|
async getPartnerLicense(
|
||||||
|
context: Context,
|
||||||
id: number,
|
id: number,
|
||||||
currentDate: Date,
|
currentDate: Date,
|
||||||
expiringSoonDate: Date,
|
expiringSoonDate: Date,
|
||||||
@ -526,6 +546,7 @@ export class AccountsRepositoryService {
|
|||||||
where: {
|
where: {
|
||||||
id: id,
|
id: id,
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
if (!ownAccount) {
|
if (!ownAccount) {
|
||||||
throw new AccountNotFoundError(`Account is Not Found.`);
|
throw new AccountNotFoundError(`Account is Not Found.`);
|
||||||
@ -533,6 +554,7 @@ export class AccountsRepositoryService {
|
|||||||
|
|
||||||
// 自アカウントのライセンス注文状況を取得する
|
// 自アカウントのライセンス注文状況を取得する
|
||||||
const ownLicenseOrderStatus = await this.getAccountLicenseOrderStatus(
|
const ownLicenseOrderStatus = await this.getAccountLicenseOrderStatus(
|
||||||
|
context,
|
||||||
id,
|
id,
|
||||||
currentDate,
|
currentDate,
|
||||||
entityManager,
|
entityManager,
|
||||||
@ -558,6 +580,7 @@ export class AccountsRepositoryService {
|
|||||||
},
|
},
|
||||||
take: limit,
|
take: limit,
|
||||||
skip: offset,
|
skip: offset,
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
// 各子アカウントのライセンス注文状況を取得する
|
// 各子アカウントのライセンス注文状況を取得する
|
||||||
@ -566,6 +589,7 @@ export class AccountsRepositoryService {
|
|||||||
for (const childAccount of childAccounts) {
|
for (const childAccount of childAccounts) {
|
||||||
// ライセンス注文状況を取得する
|
// ライセンス注文状況を取得する
|
||||||
const childLicenseOrderStatus = await this.getAccountLicenseOrderStatus(
|
const childLicenseOrderStatus = await this.getAccountLicenseOrderStatus(
|
||||||
|
context,
|
||||||
childAccount.id,
|
childAccount.id,
|
||||||
currentDate,
|
currentDate,
|
||||||
entityManager,
|
entityManager,
|
||||||
@ -576,6 +600,7 @@ export class AccountsRepositoryService {
|
|||||||
let allocatableLicenseWithMargin: number = 0;
|
let allocatableLicenseWithMargin: number = 0;
|
||||||
if (childAccount.tier === TIERS.TIER5) {
|
if (childAccount.tier === TIERS.TIER5) {
|
||||||
expiringSoonLicense = await this.getExpiringSoonLicense(
|
expiringSoonLicense = await this.getExpiringSoonLicense(
|
||||||
|
context,
|
||||||
entityManager,
|
entityManager,
|
||||||
childAccount.id,
|
childAccount.id,
|
||||||
currentDate,
|
currentDate,
|
||||||
@ -583,6 +608,7 @@ export class AccountsRepositoryService {
|
|||||||
);
|
);
|
||||||
allocatableLicenseWithMargin =
|
allocatableLicenseWithMargin =
|
||||||
await this.getAllocatableLicenseWithMargin(
|
await this.getAllocatableLicenseWithMargin(
|
||||||
|
context,
|
||||||
entityManager,
|
entityManager,
|
||||||
childAccount.id,
|
childAccount.id,
|
||||||
expiringSoonDate,
|
expiringSoonDate,
|
||||||
@ -612,6 +638,7 @@ export class AccountsRepositoryService {
|
|||||||
where: {
|
where: {
|
||||||
parent_account_id: id,
|
parent_account_id: id,
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@ -626,11 +653,12 @@ export class AccountsRepositoryService {
|
|||||||
* Dealer(Tier4)アカウント情報を取得する
|
* Dealer(Tier4)アカウント情報を取得する
|
||||||
* @returns dealer accounts
|
* @returns dealer accounts
|
||||||
*/
|
*/
|
||||||
async findDealerAccounts(): Promise<Account[]> {
|
async findDealerAccounts(context: Context): Promise<Account[]> {
|
||||||
const accounts = await this.dataSource.getRepository(Account).find({
|
const accounts = await this.dataSource.getRepository(Account).find({
|
||||||
where: {
|
where: {
|
||||||
tier: TIERS.TIER4,
|
tier: TIERS.TIER4,
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
return accounts;
|
return accounts;
|
||||||
@ -642,7 +670,10 @@ export class AccountsRepositoryService {
|
|||||||
* @param targetAccountId
|
* @param targetAccountId
|
||||||
* @returns accountIds
|
* @returns accountIds
|
||||||
*/
|
*/
|
||||||
async getHierarchyParents(targetAccountId: number): Promise<number[]> {
|
async getHierarchyParents(
|
||||||
|
context: Context,
|
||||||
|
targetAccountId: number,
|
||||||
|
): Promise<number[]> {
|
||||||
return await this.dataSource.transaction(async (entityManager) => {
|
return await this.dataSource.transaction(async (entityManager) => {
|
||||||
const accountRepository = entityManager.getRepository(Account);
|
const accountRepository = entityManager.getRepository(Account);
|
||||||
const maxTierDifference = TIERS.TIER5 - TIERS.TIER1;
|
const maxTierDifference = TIERS.TIER5 - TIERS.TIER1;
|
||||||
@ -655,6 +686,7 @@ export class AccountsRepositoryService {
|
|||||||
where: {
|
where: {
|
||||||
id: currentAccountId,
|
id: currentAccountId,
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
if (!account) {
|
if (!account) {
|
||||||
break;
|
break;
|
||||||
@ -676,7 +708,11 @@ export class AccountsRepositoryService {
|
|||||||
* @param orderedAccountId:キャンセルしたい発行の注文元アカウントID
|
* @param orderedAccountId:キャンセルしたい発行の注文元アカウントID
|
||||||
* @param poNumber:POナンバー
|
* @param poNumber:POナンバー
|
||||||
*/
|
*/
|
||||||
async cancelIssue(orderedAccountId: number, poNumber: string): Promise<void> {
|
async cancelIssue(
|
||||||
|
context: Context,
|
||||||
|
orderedAccountId: number,
|
||||||
|
poNumber: string,
|
||||||
|
): Promise<void> {
|
||||||
await this.dataSource.transaction(async (entityManager) => {
|
await this.dataSource.transaction(async (entityManager) => {
|
||||||
const orderRepo = entityManager.getRepository(LicenseOrder);
|
const orderRepo = entityManager.getRepository(LicenseOrder);
|
||||||
|
|
||||||
@ -687,6 +723,7 @@ export class AccountsRepositoryService {
|
|||||||
po_number: poNumber,
|
po_number: poNumber,
|
||||||
status: LICENSE_ISSUE_STATUS.ISSUED,
|
status: LICENSE_ISSUE_STATUS.ISSUED,
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
// キャンセル対象の発行が存在しない場合エラー
|
// キャンセル対象の発行が存在しない場合エラー
|
||||||
@ -715,6 +752,7 @@ export class AccountsRepositoryService {
|
|||||||
order_id: targetOrder.id,
|
order_id: targetOrder.id,
|
||||||
status: Not(LICENSE_ALLOCATED_STATUS.UNALLOCATED),
|
status: Not(LICENSE_ALLOCATED_STATUS.UNALLOCATED),
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
// 存在した場合エラー
|
// 存在した場合エラー
|
||||||
@ -754,6 +792,7 @@ export class AccountsRepositoryService {
|
|||||||
* @returns partners: DBから取得できるパートナー一覧情報
|
* @returns partners: DBから取得できるパートナー一覧情報
|
||||||
*/
|
*/
|
||||||
async getPartners(
|
async getPartners(
|
||||||
|
context: Context,
|
||||||
id: number,
|
id: number,
|
||||||
limit: number,
|
limit: number,
|
||||||
offset: number,
|
offset: number,
|
||||||
@ -769,6 +808,7 @@ export class AccountsRepositoryService {
|
|||||||
where: {
|
where: {
|
||||||
parent_account_id: id,
|
parent_account_id: id,
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
const partnerAccounts = await accountRepo.find({
|
const partnerAccounts = await accountRepo.find({
|
||||||
@ -780,6 +820,7 @@ export class AccountsRepositoryService {
|
|||||||
},
|
},
|
||||||
take: limit,
|
take: limit,
|
||||||
skip: offset,
|
skip: offset,
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
// ADB2Cから情報を取得するための外部ユーザIDを取得する(念のためプライマリ管理者IDが存在しない場合を考慮)
|
// ADB2Cから情報を取得するための外部ユーザIDを取得する(念のためプライマリ管理者IDが存在しない場合を考慮)
|
||||||
@ -797,6 +838,7 @@ export class AccountsRepositoryService {
|
|||||||
where: {
|
where: {
|
||||||
id: In(primaryUserIds),
|
id: In(primaryUserIds),
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
// アカウント情報とプライマリ管理者の外部ユーザIDをマージ
|
// アカウント情報とプライマリ管理者の外部ユーザIDをマージ
|
||||||
@ -836,6 +878,7 @@ export class AccountsRepositoryService {
|
|||||||
* @returns account: 一階層上のアカウント
|
* @returns account: 一階層上のアカウント
|
||||||
*/
|
*/
|
||||||
async getOneUpperTierAccount(
|
async getOneUpperTierAccount(
|
||||||
|
context: Context,
|
||||||
accountId: number,
|
accountId: number,
|
||||||
tier: number,
|
tier: number,
|
||||||
): Promise<Account | null> {
|
): Promise<Account | null> {
|
||||||
@ -846,6 +889,7 @@ export class AccountsRepositoryService {
|
|||||||
id: accountId,
|
id: accountId,
|
||||||
tier: tier - 1,
|
tier: tier - 1,
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -860,6 +904,7 @@ export class AccountsRepositoryService {
|
|||||||
* @param secondryAdminUserId
|
* @param secondryAdminUserId
|
||||||
*/
|
*/
|
||||||
async updateAccountInfo(
|
async updateAccountInfo(
|
||||||
|
context: Context,
|
||||||
myAccountId: number,
|
myAccountId: number,
|
||||||
tier: number,
|
tier: number,
|
||||||
delegationPermission: boolean,
|
delegationPermission: boolean,
|
||||||
@ -871,6 +916,7 @@ export class AccountsRepositoryService {
|
|||||||
// ディーラーアカウントが指定されている場合、存在チェックを行う
|
// ディーラーアカウントが指定されている場合、存在チェックを行う
|
||||||
if (parentAccountId) {
|
if (parentAccountId) {
|
||||||
const dealerAccount = await this.getOneUpperTierAccount(
|
const dealerAccount = await this.getOneUpperTierAccount(
|
||||||
|
context,
|
||||||
parentAccountId,
|
parentAccountId,
|
||||||
tier,
|
tier,
|
||||||
);
|
);
|
||||||
@ -891,6 +937,7 @@ export class AccountsRepositoryService {
|
|||||||
account_id: myAccountId,
|
account_id: myAccountId,
|
||||||
email_verified: true,
|
email_verified: true,
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
if (!primaryAdminUser) {
|
if (!primaryAdminUser) {
|
||||||
throw new AdminUserNotFoundError(
|
throw new AdminUserNotFoundError(
|
||||||
@ -907,6 +954,7 @@ export class AccountsRepositoryService {
|
|||||||
account_id: myAccountId,
|
account_id: myAccountId,
|
||||||
email_verified: true,
|
email_verified: true,
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
if (!secondryAdminUser) {
|
if (!secondryAdminUser) {
|
||||||
throw new AdminUserNotFoundError(
|
throw new AdminUserNotFoundError(
|
||||||
@ -935,6 +983,7 @@ export class AccountsRepositoryService {
|
|||||||
* @returns active worktype id
|
* @returns active worktype id
|
||||||
*/
|
*/
|
||||||
async updateActiveWorktypeId(
|
async updateActiveWorktypeId(
|
||||||
|
context: Context,
|
||||||
accountId: number,
|
accountId: number,
|
||||||
id?: number | undefined,
|
id?: number | undefined,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
@ -946,6 +995,7 @@ export class AccountsRepositoryService {
|
|||||||
// 自アカウント内に指定IDのワークタイプが存在するか確認
|
// 自アカウント内に指定IDのワークタイプが存在するか確認
|
||||||
const worktype = await worktypeRepo.findOne({
|
const worktype = await worktypeRepo.findOne({
|
||||||
where: { account_id: accountId, id: id },
|
where: { account_id: accountId, id: id },
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
// ワークタイプが存在しない場合はエラー
|
// ワークタイプが存在しない場合はエラー
|
||||||
@ -967,13 +1017,17 @@ export class AccountsRepositoryService {
|
|||||||
* @param accountId
|
* @param accountId
|
||||||
* @returns users 削除対象のユーザー
|
* @returns users 削除対象のユーザー
|
||||||
*/
|
*/
|
||||||
async deleteAccountAndInsertArchives(accountId: number): Promise<User[]> {
|
async deleteAccountAndInsertArchives(
|
||||||
|
context: Context,
|
||||||
|
accountId: number,
|
||||||
|
): Promise<User[]> {
|
||||||
return await this.dataSource.transaction(async (entityManager) => {
|
return await this.dataSource.transaction(async (entityManager) => {
|
||||||
// 削除対象のユーザーを退避テーブルに退避
|
// 削除対象のユーザーを退避テーブルに退避
|
||||||
const users = await this.dataSource.getRepository(User).find({
|
const users = await this.dataSource.getRepository(User).find({
|
||||||
where: {
|
where: {
|
||||||
account_id: accountId,
|
account_id: accountId,
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
const userArchiveRepo = entityManager.getRepository(UserArchive);
|
const userArchiveRepo = entityManager.getRepository(UserArchive);
|
||||||
await userArchiveRepo
|
await userArchiveRepo
|
||||||
@ -988,6 +1042,7 @@ export class AccountsRepositoryService {
|
|||||||
where: {
|
where: {
|
||||||
account_id: accountId,
|
account_id: accountId,
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
const licenseArchiveRepo = entityManager.getRepository(LicenseArchive);
|
const licenseArchiveRepo = entityManager.getRepository(LicenseArchive);
|
||||||
await licenseArchiveRepo
|
await licenseArchiveRepo
|
||||||
@ -1004,6 +1059,7 @@ export class AccountsRepositoryService {
|
|||||||
where: {
|
where: {
|
||||||
account_id: accountId,
|
account_id: accountId,
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
const licenseHistoryArchiveRepo = entityManager.getRepository(
|
const licenseHistoryArchiveRepo = entityManager.getRepository(
|
||||||
LicenseAllocationHistoryArchive,
|
LicenseAllocationHistoryArchive,
|
||||||
@ -1029,6 +1085,7 @@ export class AccountsRepositoryService {
|
|||||||
where: {
|
where: {
|
||||||
account_id: accountId,
|
account_id: accountId,
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
const cardLicenseRepo = entityManager.getRepository(CardLicense);
|
const cardLicenseRepo = entityManager.getRepository(CardLicense);
|
||||||
await cardLicenseRepo.delete({
|
await cardLicenseRepo.delete({
|
||||||
@ -1048,6 +1105,7 @@ export class AccountsRepositoryService {
|
|||||||
const worktypeRepo = entityManager.getRepository(Worktype);
|
const worktypeRepo = entityManager.getRepository(Worktype);
|
||||||
const taggerWorktypes = await worktypeRepo.find({
|
const taggerWorktypes = await worktypeRepo.find({
|
||||||
where: { account_id: accountId },
|
where: { account_id: accountId },
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
const optionItemRepo = entityManager.getRepository(OptionItem);
|
const optionItemRepo = entityManager.getRepository(OptionItem);
|
||||||
@ -1062,6 +1120,7 @@ export class AccountsRepositoryService {
|
|||||||
where: {
|
where: {
|
||||||
account_id: accountId,
|
account_id: accountId,
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
const checkoutPermissionRepo =
|
const checkoutPermissionRepo =
|
||||||
entityManager.getRepository(CheckoutPermission);
|
entityManager.getRepository(CheckoutPermission);
|
||||||
@ -1078,6 +1137,7 @@ export class AccountsRepositoryService {
|
|||||||
where: {
|
where: {
|
||||||
account_id: accountId,
|
account_id: accountId,
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
const audioOptionItemsRepo = entityManager.getRepository(AudioOptionItem);
|
const audioOptionItemsRepo = entityManager.getRepository(AudioOptionItem);
|
||||||
await audioOptionItemsRepo.delete({
|
await audioOptionItemsRepo.delete({
|
||||||
@ -1093,6 +1153,7 @@ export class AccountsRepositoryService {
|
|||||||
where: {
|
where: {
|
||||||
account_id: accountId,
|
account_id: accountId,
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
const userGroupMemberRepo = entityManager.getRepository(UserGroupMember);
|
const userGroupMemberRepo = entityManager.getRepository(UserGroupMember);
|
||||||
await userGroupMemberRepo.delete({
|
await userGroupMemberRepo.delete({
|
||||||
|
|||||||
@ -32,6 +32,7 @@ import {
|
|||||||
DateWithZeroTime,
|
DateWithZeroTime,
|
||||||
} from '../../features/licenses/types/types';
|
} from '../../features/licenses/types/types';
|
||||||
import { NewAllocatedLicenseExpirationDate } from '../../features/licenses/types/types';
|
import { NewAllocatedLicenseExpirationDate } from '../../features/licenses/types/types';
|
||||||
|
import { Context } from '../../common/log';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class LicensesRepositoryService {
|
export class LicensesRepositoryService {
|
||||||
@ -39,6 +40,7 @@ export class LicensesRepositoryService {
|
|||||||
private readonly logger = new Logger(LicensesRepositoryService.name);
|
private readonly logger = new Logger(LicensesRepositoryService.name);
|
||||||
|
|
||||||
async order(
|
async order(
|
||||||
|
context: Context,
|
||||||
poNumber: string,
|
poNumber: string,
|
||||||
fromAccountId: number,
|
fromAccountId: number,
|
||||||
toAccountId: number,
|
toAccountId: number,
|
||||||
@ -70,6 +72,7 @@ export class LicensesRepositoryService {
|
|||||||
status: LICENSE_ISSUE_STATUS.ISSUE_REQUESTING,
|
status: LICENSE_ISSUE_STATUS.ISSUE_REQUESTING,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
// 重複があった場合はエラーを返却する
|
// 重複があった場合はエラーを返却する
|
||||||
if (isPoNumberDuplicated) {
|
if (isPoNumberDuplicated) {
|
||||||
@ -92,6 +95,7 @@ export class LicensesRepositoryService {
|
|||||||
* @returns string[] カードライセンスキーの配列
|
* @returns string[] カードライセンスキーの配列
|
||||||
*/
|
*/
|
||||||
async createCardLicenses(
|
async createCardLicenses(
|
||||||
|
context: Context,
|
||||||
accountId: number,
|
accountId: number,
|
||||||
count: number,
|
count: number,
|
||||||
): Promise<string[]> {
|
): Promise<string[]> {
|
||||||
@ -139,6 +143,7 @@ export class LicensesRepositoryService {
|
|||||||
where: {
|
where: {
|
||||||
card_license_key: In(generateKeys),
|
card_license_key: In(generateKeys),
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
if (existingCardLicenses.length > 0) {
|
if (existingCardLicenses.length > 0) {
|
||||||
// 重複分を配列から削除
|
// 重複分を配列から削除
|
||||||
@ -222,6 +227,7 @@ export class LicensesRepositoryService {
|
|||||||
* @returns void
|
* @returns void
|
||||||
*/
|
*/
|
||||||
async activateCardLicense(
|
async activateCardLicense(
|
||||||
|
context: Context,
|
||||||
accountId: number,
|
accountId: number,
|
||||||
licenseKey: string,
|
licenseKey: string,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
@ -233,6 +239,7 @@ export class LicensesRepositoryService {
|
|||||||
where: {
|
where: {
|
||||||
card_license_key: licenseKey,
|
card_license_key: licenseKey,
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
// カードライセンスが存在しなければエラー
|
// カードライセンスが存在しなければエラー
|
||||||
if (!targetCardLicense) {
|
if (!targetCardLicense) {
|
||||||
@ -256,6 +263,7 @@ export class LicensesRepositoryService {
|
|||||||
where: {
|
where: {
|
||||||
id: targetCardLicense.license_id,
|
id: targetCardLicense.license_id,
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
// ライセンスが存在しなければエラー
|
// ライセンスが存在しなければエラー
|
||||||
if (!targetLicense) {
|
if (!targetLicense) {
|
||||||
@ -289,6 +297,7 @@ export class LicensesRepositoryService {
|
|||||||
* @returns licenseOrders
|
* @returns licenseOrders
|
||||||
*/
|
*/
|
||||||
async getLicenseOrderHistoryInfo(
|
async getLicenseOrderHistoryInfo(
|
||||||
|
context: Context,
|
||||||
accountId: number,
|
accountId: number,
|
||||||
offset: number,
|
offset: number,
|
||||||
limit: number,
|
limit: number,
|
||||||
@ -303,6 +312,7 @@ export class LicensesRepositoryService {
|
|||||||
where: {
|
where: {
|
||||||
from_account_id: accountId,
|
from_account_id: accountId,
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
const licenseOrders = await licenseOrder.find({
|
const licenseOrders = await licenseOrder.find({
|
||||||
where: {
|
where: {
|
||||||
@ -313,6 +323,7 @@ export class LicensesRepositoryService {
|
|||||||
},
|
},
|
||||||
take: limit,
|
take: limit,
|
||||||
skip: offset,
|
skip: offset,
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
total: total,
|
total: total,
|
||||||
@ -330,6 +341,7 @@ export class LicensesRepositoryService {
|
|||||||
* @param poNumber
|
* @param poNumber
|
||||||
*/
|
*/
|
||||||
async issueLicense(
|
async issueLicense(
|
||||||
|
context: Context,
|
||||||
orderedAccountId: number,
|
orderedAccountId: number,
|
||||||
myAccountId: number,
|
myAccountId: number,
|
||||||
tier: number,
|
tier: number,
|
||||||
@ -345,6 +357,7 @@ export class LicensesRepositoryService {
|
|||||||
from_account_id: orderedAccountId,
|
from_account_id: orderedAccountId,
|
||||||
po_number: poNumber,
|
po_number: poNumber,
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
// 注文が存在しない場合、エラー
|
// 注文が存在しない場合、エラー
|
||||||
if (!issuingOrder) {
|
if (!issuingOrder) {
|
||||||
@ -394,6 +407,7 @@ export class LicensesRepositoryService {
|
|||||||
id: 'ASC',
|
id: 'ASC',
|
||||||
},
|
},
|
||||||
take: newLicenses.length,
|
take: newLicenses.length,
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
// 登録したライセンスに対して自身のライセンスが不足していた場合、エラー
|
// 登録したライセンスに対して自身のライセンスが不足していた場合、エラー
|
||||||
@ -420,6 +434,7 @@ export class LicensesRepositoryService {
|
|||||||
* @return AllocatableLicenseInfo[]
|
* @return AllocatableLicenseInfo[]
|
||||||
*/
|
*/
|
||||||
async getAllocatableLicenses(
|
async getAllocatableLicenses(
|
||||||
|
context: Context,
|
||||||
myAccountId: number,
|
myAccountId: number,
|
||||||
): Promise<AllocatableLicenseInfo[]> {
|
): Promise<AllocatableLicenseInfo[]> {
|
||||||
const nowDate = new DateWithZeroTime();
|
const nowDate = new DateWithZeroTime();
|
||||||
@ -438,6 +453,7 @@ export class LicensesRepositoryService {
|
|||||||
'(license.expiry_date >= :nowDate OR license.expiry_date IS NULL)',
|
'(license.expiry_date >= :nowDate OR license.expiry_date IS NULL)',
|
||||||
{ nowDate },
|
{ nowDate },
|
||||||
)
|
)
|
||||||
|
.comment(`${context.getTrackingId()}_${new Date().toUTCString()}`)
|
||||||
.orderBy('license.expiry_date IS NULL', 'DESC')
|
.orderBy('license.expiry_date IS NULL', 'DESC')
|
||||||
.addOrderBy('license.expiry_date', 'DESC')
|
.addOrderBy('license.expiry_date', 'DESC')
|
||||||
.addOrderBy('license.id', 'ASC');
|
.addOrderBy('license.id', 'ASC');
|
||||||
@ -453,6 +469,7 @@ export class LicensesRepositoryService {
|
|||||||
* @param newLicenseId
|
* @param newLicenseId
|
||||||
*/
|
*/
|
||||||
async allocateLicense(
|
async allocateLicense(
|
||||||
|
context: Context,
|
||||||
userId: number,
|
userId: number,
|
||||||
newLicenseId: number,
|
newLicenseId: number,
|
||||||
accountId: number,
|
accountId: number,
|
||||||
@ -467,6 +484,7 @@ export class LicensesRepositoryService {
|
|||||||
where: {
|
where: {
|
||||||
id: newLicenseId,
|
id: newLicenseId,
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
// ライセンスが存在しない場合はエラー
|
// ライセンスが存在しない場合はエラー
|
||||||
@ -501,6 +519,7 @@ export class LicensesRepositoryService {
|
|||||||
where: {
|
where: {
|
||||||
allocated_user_id: userId,
|
allocated_user_id: userId,
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
// 既にライセンスが割り当てられているなら、割り当てを解除
|
// 既にライセンスが割り当てられているなら、割り当てを解除
|
||||||
@ -537,6 +556,7 @@ export class LicensesRepositoryService {
|
|||||||
},
|
},
|
||||||
where: { user_id: userId, is_allocated: true },
|
where: { user_id: userId, is_allocated: true },
|
||||||
order: { executed_at: 'DESC' },
|
order: { executed_at: 'DESC' },
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
let switchFromType = '';
|
let switchFromType = '';
|
||||||
@ -574,7 +594,11 @@ export class LicensesRepositoryService {
|
|||||||
* ユーザーに割り当てられているライセンスを解除する
|
* ユーザーに割り当てられているライセンスを解除する
|
||||||
* @param userId
|
* @param userId
|
||||||
*/
|
*/
|
||||||
async deallocateLicense(userId: number, accountId: number): Promise<void> {
|
async deallocateLicense(
|
||||||
|
context: Context,
|
||||||
|
userId: number,
|
||||||
|
accountId: number,
|
||||||
|
): Promise<void> {
|
||||||
await this.dataSource.transaction(async (entityManager) => {
|
await this.dataSource.transaction(async (entityManager) => {
|
||||||
const licenseRepo = entityManager.getRepository(License);
|
const licenseRepo = entityManager.getRepository(License);
|
||||||
const licenseAllocationHistoryRepo = entityManager.getRepository(
|
const licenseAllocationHistoryRepo = entityManager.getRepository(
|
||||||
@ -586,6 +610,7 @@ export class LicensesRepositoryService {
|
|||||||
allocated_user_id: userId,
|
allocated_user_id: userId,
|
||||||
status: LICENSE_ALLOCATED_STATUS.ALLOCATED,
|
status: LICENSE_ALLOCATED_STATUS.ALLOCATED,
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
// ライセンスが割り当てられていない場合はエラー
|
// ライセンスが割り当てられていない場合はエラー
|
||||||
@ -617,7 +642,11 @@ export class LicensesRepositoryService {
|
|||||||
* @param accountId
|
* @param accountId
|
||||||
* @param poNumber
|
* @param poNumber
|
||||||
*/
|
*/
|
||||||
async cancelOrder(accountId: number, poNumber: string): Promise<void> {
|
async cancelOrder(
|
||||||
|
context: Context,
|
||||||
|
accountId: number,
|
||||||
|
poNumber: string,
|
||||||
|
): Promise<void> {
|
||||||
await this.dataSource.transaction(async (entityManager) => {
|
await this.dataSource.transaction(async (entityManager) => {
|
||||||
const orderRepo = entityManager.getRepository(LicenseOrder);
|
const orderRepo = entityManager.getRepository(LicenseOrder);
|
||||||
|
|
||||||
@ -628,6 +657,7 @@ export class LicensesRepositoryService {
|
|||||||
po_number: poNumber,
|
po_number: poNumber,
|
||||||
status: LICENSE_ISSUE_STATUS.ISSUE_REQUESTING,
|
status: LICENSE_ISSUE_STATUS.ISSUE_REQUESTING,
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
// キャンセル対象の注文が存在しない場合エラー
|
// キャンセル対象の注文が存在しない場合エラー
|
||||||
@ -651,6 +681,7 @@ export class LicensesRepositoryService {
|
|||||||
* @returns Promise<{ state: 'allocated' | 'inallocated' | 'expired' }>
|
* @returns Promise<{ state: 'allocated' | 'inallocated' | 'expired' }>
|
||||||
*/
|
*/
|
||||||
async getLicenseState(
|
async getLicenseState(
|
||||||
|
context: Context,
|
||||||
userId: number,
|
userId: number,
|
||||||
): Promise<{ state: 'allocated' | 'inallocated' | 'expired' }> {
|
): Promise<{ state: 'allocated' | 'inallocated' | 'expired' }> {
|
||||||
const allocatedLicense = await this.dataSource
|
const allocatedLicense = await this.dataSource
|
||||||
@ -660,6 +691,7 @@ export class LicensesRepositoryService {
|
|||||||
allocated_user_id: userId,
|
allocated_user_id: userId,
|
||||||
status: LICENSE_ALLOCATED_STATUS.ALLOCATED,
|
status: LICENSE_ALLOCATED_STATUS.ALLOCATED,
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
// ライセンスが割り当てられていない場合は未割当状態
|
// ライセンスが割り当てられていない場合は未割当状態
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import {
|
|||||||
TaskListSortableAttribute,
|
TaskListSortableAttribute,
|
||||||
SortDirection,
|
SortDirection,
|
||||||
} from '../../common/types/sort';
|
} from '../../common/types/sort';
|
||||||
|
import { Context } from '../../common/log';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class SortCriteriaRepositoryService {
|
export class SortCriteriaRepositoryService {
|
||||||
@ -18,6 +19,7 @@ export class SortCriteriaRepositoryService {
|
|||||||
* @returns sort criteria
|
* @returns sort criteria
|
||||||
*/
|
*/
|
||||||
async updateSortCriteria(
|
async updateSortCriteria(
|
||||||
|
context: Context,
|
||||||
userId: number,
|
userId: number,
|
||||||
parameter: TaskListSortableAttribute,
|
parameter: TaskListSortableAttribute,
|
||||||
direction: SortDirection,
|
direction: SortDirection,
|
||||||
@ -31,6 +33,7 @@ export class SortCriteriaRepositoryService {
|
|||||||
where: {
|
where: {
|
||||||
user_id: userId,
|
user_id: userId,
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
// 運用上はあり得ないが、プログラム上発生しうるのでエラーとして処理
|
// 運用上はあり得ないが、プログラム上発生しうるのでエラーとして処理
|
||||||
if (!targetSortCriteria) {
|
if (!targetSortCriteria) {
|
||||||
@ -49,7 +52,10 @@ export class SortCriteriaRepositoryService {
|
|||||||
* @param userId
|
* @param userId
|
||||||
* @returns sort criteria
|
* @returns sort criteria
|
||||||
*/
|
*/
|
||||||
async getSortCriteria(userId: number): Promise<SortCriteria> {
|
async getSortCriteria(
|
||||||
|
context: Context,
|
||||||
|
userId: number,
|
||||||
|
): Promise<SortCriteria> {
|
||||||
this.logger.log(` ${this.updateSortCriteria.name}; userId:${userId}`);
|
this.logger.log(` ${this.updateSortCriteria.name}; userId:${userId}`);
|
||||||
|
|
||||||
const repo = this.dataSource.getRepository(SortCriteria);
|
const repo = this.dataSource.getRepository(SortCriteria);
|
||||||
@ -57,6 +63,7 @@ export class SortCriteriaRepositoryService {
|
|||||||
where: {
|
where: {
|
||||||
user_id: userId,
|
user_id: userId,
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
// 運用上はあり得ないが、プログラム上発生しうるのでエラーとして処理
|
// 運用上はあり得ないが、プログラム上発生しうるのでエラーとして処理
|
||||||
if (!sortCriteria) {
|
if (!sortCriteria) {
|
||||||
|
|||||||
@ -41,6 +41,7 @@ import { TaskStatus, isTaskStatus } from '../../common/types/taskStatus';
|
|||||||
import { SortCriteria } from '../sort_criteria/entity/sort_criteria.entity';
|
import { SortCriteria } from '../sort_criteria/entity/sort_criteria.entity';
|
||||||
import { Workflow } from '../workflows/entity/workflow.entity';
|
import { Workflow } from '../workflows/entity/workflow.entity';
|
||||||
import { Worktype } from '../worktypes/entity/worktype.entity';
|
import { Worktype } from '../worktypes/entity/worktype.entity';
|
||||||
|
import { Context } from '../../common/log';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class TasksRepositoryService {
|
export class TasksRepositoryService {
|
||||||
@ -54,6 +55,7 @@ export class TasksRepositoryService {
|
|||||||
* @returns task and audio file
|
* @returns task and audio file
|
||||||
*/
|
*/
|
||||||
async getTaskAndAudioFile(
|
async getTaskAndAudioFile(
|
||||||
|
context: Context,
|
||||||
audioFileId: number,
|
audioFileId: number,
|
||||||
account_id: number,
|
account_id: number,
|
||||||
status: string[],
|
status: string[],
|
||||||
@ -71,6 +73,7 @@ export class TasksRepositoryService {
|
|||||||
account_id: account_id,
|
account_id: account_id,
|
||||||
status: In(status),
|
status: In(status),
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
if (!task) {
|
if (!task) {
|
||||||
throw new TasksNotFoundError(
|
throw new TasksNotFoundError(
|
||||||
@ -103,6 +106,7 @@ export class TasksRepositoryService {
|
|||||||
* @returns task from author id
|
* @returns task from author id
|
||||||
*/
|
*/
|
||||||
async getTaskFromAudioFileId(
|
async getTaskFromAudioFileId(
|
||||||
|
context: Context,
|
||||||
audio_file_id: number,
|
audio_file_id: number,
|
||||||
account_id: number,
|
account_id: number,
|
||||||
author_id: string,
|
author_id: string,
|
||||||
@ -117,6 +121,7 @@ export class TasksRepositoryService {
|
|||||||
where: {
|
where: {
|
||||||
audio_file_id: audio_file_id,
|
audio_file_id: audio_file_id,
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
if (!task) {
|
if (!task) {
|
||||||
throw new TasksNotFoundError(
|
throw new TasksNotFoundError(
|
||||||
@ -147,6 +152,7 @@ export class TasksRepositoryService {
|
|||||||
* @returns checkout
|
* @returns checkout
|
||||||
*/
|
*/
|
||||||
async checkout(
|
async checkout(
|
||||||
|
context: Context,
|
||||||
audio_file_id: number,
|
audio_file_id: number,
|
||||||
account_id: number,
|
account_id: number,
|
||||||
user_id: number,
|
user_id: number,
|
||||||
@ -159,6 +165,7 @@ export class TasksRepositoryService {
|
|||||||
where: {
|
where: {
|
||||||
audio_file_id: audio_file_id,
|
audio_file_id: audio_file_id,
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
if (!task) {
|
if (!task) {
|
||||||
throw new TasksNotFoundError(
|
throw new TasksNotFoundError(
|
||||||
@ -173,6 +180,7 @@ export class TasksRepositoryService {
|
|||||||
status: TASK_STATUS.IN_PROGRESS,
|
status: TASK_STATUS.IN_PROGRESS,
|
||||||
typist_user_id: user_id,
|
typist_user_id: user_id,
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (tasks.length > 0) {
|
if (tasks.length > 0) {
|
||||||
@ -210,6 +218,7 @@ export class TasksRepositoryService {
|
|||||||
id: user_id,
|
id: user_id,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
// ユーザーの所属するすべてのグループIDを列挙
|
// ユーザーの所属するすべてのグループIDを列挙
|
||||||
const groupIds = groups.map((member) => member.user_group_id);
|
const groupIds = groups.map((member) => member.user_group_id);
|
||||||
@ -231,6 +240,7 @@ export class TasksRepositoryService {
|
|||||||
user_group_id: In(groupIds),
|
user_group_id: In(groupIds),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
//チェックアウト権限がなければエラー
|
//チェックアウト権限がなければエラー
|
||||||
@ -275,6 +285,7 @@ export class TasksRepositoryService {
|
|||||||
* @returns checkin
|
* @returns checkin
|
||||||
*/
|
*/
|
||||||
async checkin(
|
async checkin(
|
||||||
|
context: Context,
|
||||||
audio_file_id: number,
|
audio_file_id: number,
|
||||||
user_id: number,
|
user_id: number,
|
||||||
permittedSourceStatus: TaskStatus,
|
permittedSourceStatus: TaskStatus,
|
||||||
@ -285,6 +296,7 @@ export class TasksRepositoryService {
|
|||||||
where: {
|
where: {
|
||||||
audio_file_id: audio_file_id,
|
audio_file_id: audio_file_id,
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
if (!task) {
|
if (!task) {
|
||||||
throw new TasksNotFoundError(
|
throw new TasksNotFoundError(
|
||||||
@ -322,6 +334,7 @@ export class TasksRepositoryService {
|
|||||||
* @returns cancel
|
* @returns cancel
|
||||||
*/
|
*/
|
||||||
async cancel(
|
async cancel(
|
||||||
|
context: Context,
|
||||||
audio_file_id: number,
|
audio_file_id: number,
|
||||||
permittedSourceStatus: TaskStatus[],
|
permittedSourceStatus: TaskStatus[],
|
||||||
account_id: number,
|
account_id: number,
|
||||||
@ -333,6 +346,7 @@ export class TasksRepositoryService {
|
|||||||
where: {
|
where: {
|
||||||
audio_file_id: audio_file_id,
|
audio_file_id: audio_file_id,
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
if (!task) {
|
if (!task) {
|
||||||
throw new TasksNotFoundError(
|
throw new TasksNotFoundError(
|
||||||
@ -388,6 +402,7 @@ export class TasksRepositoryService {
|
|||||||
* @returns suspend
|
* @returns suspend
|
||||||
*/
|
*/
|
||||||
async suspend(
|
async suspend(
|
||||||
|
context: Context,
|
||||||
audio_file_id: number,
|
audio_file_id: number,
|
||||||
user_id: number,
|
user_id: number,
|
||||||
permittedSourceStatus: TaskStatus,
|
permittedSourceStatus: TaskStatus,
|
||||||
@ -398,6 +413,7 @@ export class TasksRepositoryService {
|
|||||||
where: {
|
where: {
|
||||||
audio_file_id: audio_file_id,
|
audio_file_id: audio_file_id,
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
if (!task) {
|
if (!task) {
|
||||||
throw new TasksNotFoundError(
|
throw new TasksNotFoundError(
|
||||||
@ -433,6 +449,7 @@ export class TasksRepositoryService {
|
|||||||
* @returns backup
|
* @returns backup
|
||||||
*/
|
*/
|
||||||
async backup(
|
async backup(
|
||||||
|
context: Context,
|
||||||
accountId: number,
|
accountId: number,
|
||||||
audio_file_id: number,
|
audio_file_id: number,
|
||||||
permittedSourceStatus: TaskStatus[],
|
permittedSourceStatus: TaskStatus[],
|
||||||
@ -444,6 +461,7 @@ export class TasksRepositoryService {
|
|||||||
account_id: accountId,
|
account_id: accountId,
|
||||||
audio_file_id: audio_file_id,
|
audio_file_id: audio_file_id,
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
if (!task) {
|
if (!task) {
|
||||||
throw new TasksNotFoundError(
|
throw new TasksNotFoundError(
|
||||||
@ -482,6 +500,7 @@ export class TasksRepositoryService {
|
|||||||
* @returns tasks: タスク情報 / permissions:タスクに紐づくチェックアウト権限情報 / count: offset|limitを行わなかった場合の該当タスクの合計
|
* @returns tasks: タスク情報 / permissions:タスクに紐づくチェックアウト権限情報 / count: offset|limitを行わなかった場合の該当タスクの合計
|
||||||
*/
|
*/
|
||||||
async getTasksFromAccountId(
|
async getTasksFromAccountId(
|
||||||
|
context: Context,
|
||||||
account_id: number,
|
account_id: number,
|
||||||
offset: number,
|
offset: number,
|
||||||
limit: number,
|
limit: number,
|
||||||
@ -504,6 +523,7 @@ export class TasksRepositoryService {
|
|||||||
account_id: account_id,
|
account_id: account_id,
|
||||||
status: In(status),
|
status: In(status),
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
// 条件に該当するTask一覧を取得
|
// 条件に該当するTask一覧を取得
|
||||||
@ -520,6 +540,7 @@ export class TasksRepositoryService {
|
|||||||
order: order, // 引数によってOrderに使用するパラメータを変更
|
order: order, // 引数によってOrderに使用するパラメータを変更
|
||||||
take: limit,
|
take: limit,
|
||||||
skip: offset,
|
skip: offset,
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO [Task2249] Task内にCheckoutPermissionを含める方法が上手くいかなかった(複雑になりすぎた? 原因未調査)ため、
|
// TODO [Task2249] Task内にCheckoutPermissionを含める方法が上手くいかなかった(複雑になりすぎた? 原因未調査)ため、
|
||||||
@ -535,6 +556,7 @@ export class TasksRepositoryService {
|
|||||||
where: {
|
where: {
|
||||||
task_id: In(taskIds),
|
task_id: In(taskIds),
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
return { tasks, permissions, count };
|
return { tasks, permissions, count };
|
||||||
});
|
});
|
||||||
@ -552,6 +574,7 @@ export class TasksRepositoryService {
|
|||||||
* @returns tasks: タスク情報 / permissions:タスクに紐づくチェックアウト権限情報 / count: offset|limitを行わなかった場合の該当タスクの合計
|
* @returns tasks: タスク情報 / permissions:タスクに紐づくチェックアウト権限情報 / count: offset|limitを行わなかった場合の該当タスクの合計
|
||||||
*/
|
*/
|
||||||
async getTasksFromAuthorIdAndAccountId(
|
async getTasksFromAuthorIdAndAccountId(
|
||||||
|
context: Context,
|
||||||
author_id: string,
|
author_id: string,
|
||||||
account_id: number,
|
account_id: number,
|
||||||
offset: number,
|
offset: number,
|
||||||
@ -573,6 +596,7 @@ export class TasksRepositoryService {
|
|||||||
status: In(status),
|
status: In(status),
|
||||||
file: { author_id: author_id },
|
file: { author_id: author_id },
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
const tasks = await taskRepo.find({
|
const tasks = await taskRepo.find({
|
||||||
@ -589,6 +613,7 @@ export class TasksRepositoryService {
|
|||||||
order: order, // 引数によってOrderに使用するパラメータを変更
|
order: order, // 引数によってOrderに使用するパラメータを変更
|
||||||
take: limit,
|
take: limit,
|
||||||
skip: offset,
|
skip: offset,
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
const checkoutRepo = entityManager.getRepository(CheckoutPermission);
|
const checkoutRepo = entityManager.getRepository(CheckoutPermission);
|
||||||
@ -601,6 +626,7 @@ export class TasksRepositoryService {
|
|||||||
where: {
|
where: {
|
||||||
task_id: In(taskIds),
|
task_id: In(taskIds),
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
return { tasks, permissions, count };
|
return { tasks, permissions, count };
|
||||||
});
|
});
|
||||||
@ -608,6 +634,7 @@ export class TasksRepositoryService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getTasksFromTypistRelations(
|
async getTasksFromTypistRelations(
|
||||||
|
context: Context,
|
||||||
external_user_id: string,
|
external_user_id: string,
|
||||||
offset: number,
|
offset: number,
|
||||||
limit: number,
|
limit: number,
|
||||||
@ -633,6 +660,7 @@ export class TasksRepositoryService {
|
|||||||
external_id: external_user_id,
|
external_id: external_user_id,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
// ユーザーの所属するすべてのグループIDを列挙
|
// ユーザーの所属するすべてのグループIDを列挙
|
||||||
const groupIds = groups.map((member) => member.user_group_id);
|
const groupIds = groups.map((member) => member.user_group_id);
|
||||||
@ -655,6 +683,7 @@ export class TasksRepositoryService {
|
|||||||
user_group_id: In(groupIds),
|
user_group_id: In(groupIds),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
// ユーザー本人、またはユーザーが所属するユーザーグループがチェックアウト可能なタスクIDの一覧を作成
|
// ユーザー本人、またはユーザーが所属するユーザーグループがチェックアウト可能なタスクIDの一覧を作成
|
||||||
@ -683,6 +712,7 @@ export class TasksRepositoryService {
|
|||||||
status: In(status),
|
status: In(status),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
// 条件に該当するTask一覧を取得
|
// 条件に該当するTask一覧を取得
|
||||||
@ -709,6 +739,7 @@ export class TasksRepositoryService {
|
|||||||
order: order, // 引数によってOrderに使用するパラメータを変更
|
order: order, // 引数によってOrderに使用するパラメータを変更
|
||||||
take: limit,
|
take: limit,
|
||||||
skip: offset,
|
skip: offset,
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO [Task2249] Task内にCheckoutPermissionを含める方法が上手くいかなかった(複雑になりすぎた? 原因未調査)ため、
|
// TODO [Task2249] Task内にCheckoutPermissionを含める方法が上手くいかなかった(複雑になりすぎた? 原因未調査)ため、
|
||||||
@ -722,6 +753,7 @@ export class TasksRepositoryService {
|
|||||||
where: {
|
where: {
|
||||||
task_id: In(taskIds),
|
task_id: In(taskIds),
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
return { tasks, permissions, count };
|
return { tasks, permissions, count };
|
||||||
});
|
});
|
||||||
@ -732,6 +764,7 @@ export class TasksRepositoryService {
|
|||||||
* 文字起こしタスクと音声ファイル、オプションアイテムを追加
|
* 文字起こしタスクと音声ファイル、オプションアイテムを追加
|
||||||
*/
|
*/
|
||||||
async create(
|
async create(
|
||||||
|
context: Context,
|
||||||
account_id: number,
|
account_id: number,
|
||||||
owner_user_id: number,
|
owner_user_id: number,
|
||||||
priority: string,
|
priority: string,
|
||||||
@ -786,6 +819,7 @@ export class TasksRepositoryService {
|
|||||||
const lastTask = await taskRepo.findOne({
|
const lastTask = await taskRepo.findOne({
|
||||||
where: { account_id: account_id, is_job_number_enabled: true },
|
where: { account_id: account_id, is_job_number_enabled: true },
|
||||||
order: { created_at: 'DESC', job_number: 'DESC' },
|
order: { created_at: 'DESC', job_number: 'DESC' },
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
let newJobNumber = '00000001';
|
let newJobNumber = '00000001';
|
||||||
@ -828,6 +862,7 @@ export class TasksRepositoryService {
|
|||||||
* @returns checkout permission
|
* @returns checkout permission
|
||||||
*/
|
*/
|
||||||
async changeCheckoutPermission(
|
async changeCheckoutPermission(
|
||||||
|
context: Context,
|
||||||
audio_file_id: number,
|
audio_file_id: number,
|
||||||
author_id: string | undefined,
|
author_id: string | undefined,
|
||||||
account_id: number,
|
account_id: number,
|
||||||
@ -848,6 +883,7 @@ export class TasksRepositoryService {
|
|||||||
account_id: account_id,
|
account_id: account_id,
|
||||||
deleted_at: IsNull(),
|
deleted_at: IsNull(),
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
// idはユニークであるため取得件数の一致でグループの存在を確認
|
// idはユニークであるため取得件数の一致でグループの存在を確認
|
||||||
if (userGroupIds.length !== groupRecords.length) {
|
if (userGroupIds.length !== groupRecords.length) {
|
||||||
@ -873,6 +909,7 @@ export class TasksRepositoryService {
|
|||||||
email_verified: true,
|
email_verified: true,
|
||||||
deleted_at: IsNull(),
|
deleted_at: IsNull(),
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
// idはユニークであるため取得件数の一致でユーザーの存在を確認
|
// idはユニークであるため取得件数の一致でユーザーの存在を確認
|
||||||
if (typistUserIds.length !== userRecords.length) {
|
if (typistUserIds.length !== userRecords.length) {
|
||||||
@ -897,6 +934,7 @@ export class TasksRepositoryService {
|
|||||||
: author_id,
|
: author_id,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
//タスクが存在しない or ステータスがUploadedでなければエラー
|
//タスクが存在しない or ステータスがUploadedでなければエラー
|
||||||
if (!taskRecord) {
|
if (!taskRecord) {
|
||||||
@ -935,6 +973,7 @@ export class TasksRepositoryService {
|
|||||||
* @returns sorted tasks
|
* @returns sorted tasks
|
||||||
*/
|
*/
|
||||||
async getSortedTasks(
|
async getSortedTasks(
|
||||||
|
context: Context,
|
||||||
accountId: number,
|
accountId: number,
|
||||||
userId: number,
|
userId: number,
|
||||||
audioFileId: number,
|
audioFileId: number,
|
||||||
@ -943,7 +982,10 @@ export class TasksRepositoryService {
|
|||||||
const taskRepo = entityManager.getRepository(Task);
|
const taskRepo = entityManager.getRepository(Task);
|
||||||
const sortRepo = entityManager.getRepository(SortCriteria);
|
const sortRepo = entityManager.getRepository(SortCriteria);
|
||||||
|
|
||||||
const sort = await sortRepo.findOne({ where: { user_id: userId } });
|
const sort = await sortRepo.findOne({
|
||||||
|
where: { user_id: userId },
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
|
});
|
||||||
|
|
||||||
// 運用上はあり得ないが、プログラム上発生しうるのでエラーとして処理
|
// 運用上はあり得ないが、プログラム上発生しうるのでエラーとして処理
|
||||||
if (!sort) {
|
if (!sort) {
|
||||||
@ -972,6 +1014,7 @@ export class TasksRepositoryService {
|
|||||||
TASK_STATUS.UPLOADED,
|
TASK_STATUS.UPLOADED,
|
||||||
]),
|
]),
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!targetTask) {
|
if (!targetTask) {
|
||||||
@ -995,6 +1038,7 @@ export class TasksRepositoryService {
|
|||||||
// ユーザーの所属するユーザーグループがチェックアウト可能である
|
// ユーザーの所属するユーザーグループがチェックアウト可能である
|
||||||
{ user_group_id: In(groupIds) },
|
{ user_group_id: In(groupIds) },
|
||||||
],
|
],
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
// ユーザー本人、またはユーザーが所属するユーザーグループがチェックアウト可能なタスクIDの一覧を作成
|
// ユーザー本人、またはユーザーが所属するユーザーグループがチェックアウト可能なタスクIDの一覧を作成
|
||||||
@ -1017,6 +1061,7 @@ export class TasksRepositoryService {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
order: order,
|
order: order,
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
return tasks;
|
return tasks;
|
||||||
@ -1031,6 +1076,7 @@ export class TasksRepositoryService {
|
|||||||
* @returns typistIds: タイピストIDの一覧 / typistGroupIds: タイピストグループIDの一覧
|
* @returns typistIds: タイピストIDの一覧 / typistGroupIds: タイピストグループIDの一覧
|
||||||
*/
|
*/
|
||||||
async autoRouting(
|
async autoRouting(
|
||||||
|
context: Context,
|
||||||
audioFileId: number,
|
audioFileId: number,
|
||||||
accountId: number,
|
accountId: number,
|
||||||
myAuthorId?: string, // API実行者のAuthorId
|
myAuthorId?: string, // API実行者のAuthorId
|
||||||
@ -1046,6 +1092,7 @@ export class TasksRepositoryService {
|
|||||||
id: audioFileId,
|
id: audioFileId,
|
||||||
account_id: accountId,
|
account_id: accountId,
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
if (!audioFile) {
|
if (!audioFile) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
@ -1067,6 +1114,7 @@ export class TasksRepositoryService {
|
|||||||
author_id: audioFile.author_id,
|
author_id: audioFile.author_id,
|
||||||
account_id: accountId,
|
account_id: accountId,
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
// 音声ファイル上のworktypeIdをもとにworktypeを取得
|
// 音声ファイル上のworktypeIdをもとにworktypeを取得
|
||||||
@ -1076,6 +1124,7 @@ export class TasksRepositoryService {
|
|||||||
custom_worktype_id: audioFile.work_type_id,
|
custom_worktype_id: audioFile.work_type_id,
|
||||||
account_id: accountId,
|
account_id: accountId,
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
// 音声ファイル上のworktypeIdが設定されているが、一致するworktypeが存在しない場合はエラーを出して終了
|
// 音声ファイル上のworktypeIdが設定されているが、一致するworktypeが存在しない場合はエラーを出して終了
|
||||||
@ -1096,11 +1145,13 @@ export class TasksRepositoryService {
|
|||||||
author_id: authorUser?.id ?? IsNull(), // authorUserが存在しない場合は、必ずヒットしないようにNULLを設定する
|
author_id: authorUser?.id ?? IsNull(), // authorUserが存在しない場合は、必ずヒットしないようにNULLを設定する
|
||||||
worktype_id: worktypeRecord?.id ?? IsNull(),
|
worktype_id: worktypeRecord?.id ?? IsNull(),
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Workflow(ルーティングルール)があればタスクのチェックアウト権限を設定する
|
// Workflow(ルーティングルール)があればタスクのチェックアウト権限を設定する
|
||||||
if (workflow) {
|
if (workflow) {
|
||||||
return await this.setCheckoutPermissionAndTemplate(
|
return await this.setCheckoutPermissionAndTemplate(
|
||||||
|
context,
|
||||||
workflow,
|
workflow,
|
||||||
task,
|
task,
|
||||||
accountId,
|
accountId,
|
||||||
@ -1121,6 +1172,7 @@ export class TasksRepositoryService {
|
|||||||
author_id: myAuthorId,
|
author_id: myAuthorId,
|
||||||
account_id: accountId,
|
account_id: accountId,
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
if (!myAuthorUser) {
|
if (!myAuthorUser) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
@ -1136,6 +1188,7 @@ export class TasksRepositoryService {
|
|||||||
author_id: myAuthorUser.id,
|
author_id: myAuthorUser.id,
|
||||||
worktype_id: worktypeRecord?.id ?? IsNull(),
|
worktype_id: worktypeRecord?.id ?? IsNull(),
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
// API実行者のAuthorIdと音声ファイルのWorktypeをもとにルーティングルールを取得できない場合はエラーを出して終了
|
// API実行者のAuthorIdと音声ファイルのWorktypeをもとにルーティングルールを取得できない場合はエラーを出して終了
|
||||||
@ -1147,6 +1200,7 @@ export class TasksRepositoryService {
|
|||||||
|
|
||||||
// Workflow(ルーティングルール)があればタスクのチェックアウト権限を設定する
|
// Workflow(ルーティングルール)があればタスクのチェックアウト権限を設定する
|
||||||
return await this.setCheckoutPermissionAndTemplate(
|
return await this.setCheckoutPermissionAndTemplate(
|
||||||
|
context,
|
||||||
defaultWorkflow,
|
defaultWorkflow,
|
||||||
task,
|
task,
|
||||||
accountId,
|
accountId,
|
||||||
@ -1168,6 +1222,7 @@ export class TasksRepositoryService {
|
|||||||
* @returns checkout permission
|
* @returns checkout permission
|
||||||
*/
|
*/
|
||||||
private async setCheckoutPermissionAndTemplate(
|
private async setCheckoutPermissionAndTemplate(
|
||||||
|
context: Context,
|
||||||
workflow: Workflow,
|
workflow: Workflow,
|
||||||
task: Task,
|
task: Task,
|
||||||
accountId: number,
|
accountId: number,
|
||||||
@ -1196,6 +1251,7 @@ export class TasksRepositoryService {
|
|||||||
);
|
);
|
||||||
const typistUsers = await userRepo.find({
|
const typistUsers = await userRepo.find({
|
||||||
where: { account_id: accountId, id: In(typistIds) },
|
where: { account_id: accountId, id: In(typistIds) },
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
if (typistUsers.length !== typistIds.length) {
|
if (typistUsers.length !== typistIds.length) {
|
||||||
throw new Error(`typist not found. ids: ${typistIds}`);
|
throw new Error(`typist not found. ids: ${typistIds}`);
|
||||||
@ -1208,6 +1264,7 @@ export class TasksRepositoryService {
|
|||||||
const userGroupRepo = entityManager.getRepository(UserGroup);
|
const userGroupRepo = entityManager.getRepository(UserGroup);
|
||||||
const typistGroups = await userGroupRepo.find({
|
const typistGroups = await userGroupRepo.find({
|
||||||
where: { account_id: accountId, id: In(groupIds) },
|
where: { account_id: accountId, id: In(groupIds) },
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
if (typistGroups.length !== groupIds.length) {
|
if (typistGroups.length !== groupIds.length) {
|
||||||
throw new Error(`typist group not found. ids: ${groupIds}`);
|
throw new Error(`typist group not found. ids: ${groupIds}`);
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
import { DataSource } from 'typeorm';
|
import { DataSource } from 'typeorm';
|
||||||
import { TemplateFile } from './entity/template_file.entity';
|
import { TemplateFile } from './entity/template_file.entity';
|
||||||
|
import { Context } from '../../common/log';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class TemplateFilesRepositoryService {
|
export class TemplateFilesRepositoryService {
|
||||||
@ -11,12 +12,16 @@ export class TemplateFilesRepositoryService {
|
|||||||
* @param accountId
|
* @param accountId
|
||||||
* @returns template files
|
* @returns template files
|
||||||
*/
|
*/
|
||||||
async getTemplateFiles(accountId: number): Promise<TemplateFile[]> {
|
async getTemplateFiles(
|
||||||
|
context: Context,
|
||||||
|
accountId: number,
|
||||||
|
): Promise<TemplateFile[]> {
|
||||||
return await this.dataSource.transaction(async (entityManager) => {
|
return await this.dataSource.transaction(async (entityManager) => {
|
||||||
const templateFilesRepo = entityManager.getRepository(TemplateFile);
|
const templateFilesRepo = entityManager.getRepository(TemplateFile);
|
||||||
|
|
||||||
const templates = await templateFilesRepo.find({
|
const templates = await templateFilesRepo.find({
|
||||||
where: { account_id: accountId },
|
where: { account_id: accountId },
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
return templates;
|
return templates;
|
||||||
@ -31,6 +36,7 @@ export class TemplateFilesRepositoryService {
|
|||||||
* @returns template file
|
* @returns template file
|
||||||
*/
|
*/
|
||||||
async upsertTemplateFile(
|
async upsertTemplateFile(
|
||||||
|
context: Context,
|
||||||
accountId: number,
|
accountId: number,
|
||||||
fileName: string,
|
fileName: string,
|
||||||
url: string,
|
url: string,
|
||||||
@ -41,6 +47,7 @@ export class TemplateFilesRepositoryService {
|
|||||||
// アカウント内に同名ファイルがあるか確認
|
// アカウント内に同名ファイルがあるか確認
|
||||||
const template = await templateFilesRepo.findOne({
|
const template = await templateFilesRepo.findOne({
|
||||||
where: { account_id: accountId, file_name: fileName },
|
where: { account_id: accountId, file_name: fileName },
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
// 同名ファイルは同じものとして扱うため、すでにファイルがあれば更新(更新日時の履歴を残しておきたい)
|
// 同名ファイルは同じものとして扱うため、すでにファイルがあれば更新(更新日時の履歴を残しておきたい)
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import { TermsVersion } from '../../features/terms/types/types';
|
|||||||
import { Term } from './entity/term.entity';
|
import { Term } from './entity/term.entity';
|
||||||
import { TERM_TYPE } from '../../constants';
|
import { TERM_TYPE } from '../../constants';
|
||||||
import { TermInfoNotFoundError } from '../users/errors/types';
|
import { TermInfoNotFoundError } from '../users/errors/types';
|
||||||
|
import { Context } from '../../common/log';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class TermsRepositoryService {
|
export class TermsRepositoryService {
|
||||||
@ -13,7 +14,7 @@ export class TermsRepositoryService {
|
|||||||
* 利用規約の最新バージョンを取得する
|
* 利用規約の最新バージョンを取得する
|
||||||
* @returns Term[]
|
* @returns Term[]
|
||||||
*/
|
*/
|
||||||
async getLatestTermsInfo(): Promise<TermsVersion> {
|
async getLatestTermsInfo(context: Context): Promise<TermsVersion> {
|
||||||
return await this.dataSource.transaction(async (entityManager) => {
|
return await this.dataSource.transaction(async (entityManager) => {
|
||||||
const termRepo = entityManager.getRepository(Term);
|
const termRepo = entityManager.getRepository(Term);
|
||||||
const latestEulaInfo = await termRepo.findOne({
|
const latestEulaInfo = await termRepo.findOne({
|
||||||
@ -23,6 +24,7 @@ export class TermsRepositoryService {
|
|||||||
order: {
|
order: {
|
||||||
id: 'DESC',
|
id: 'DESC',
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
const latestPrivacyNoticeInfo = await termRepo.findOne({
|
const latestPrivacyNoticeInfo = await termRepo.findOne({
|
||||||
where: {
|
where: {
|
||||||
@ -31,6 +33,7 @@ export class TermsRepositoryService {
|
|||||||
order: {
|
order: {
|
||||||
id: 'DESC',
|
id: 'DESC',
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
const latestDpaInfo = await termRepo.findOne({
|
const latestDpaInfo = await termRepo.findOne({
|
||||||
where: {
|
where: {
|
||||||
@ -39,6 +42,7 @@ export class TermsRepositoryService {
|
|||||||
order: {
|
order: {
|
||||||
id: 'DESC',
|
id: 'DESC',
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!latestEulaInfo || !latestPrivacyNoticeInfo || !latestDpaInfo) {
|
if (!latestEulaInfo || !latestPrivacyNoticeInfo || !latestDpaInfo) {
|
||||||
|
|||||||
@ -5,18 +5,23 @@ import { UserGroupMember } from './entity/user_group_member.entity';
|
|||||||
import { User } from '../users/entity/user.entity';
|
import { User } from '../users/entity/user.entity';
|
||||||
import { TypistGroupNotExistError, TypistIdInvalidError } from './errors/types';
|
import { TypistGroupNotExistError, TypistIdInvalidError } from './errors/types';
|
||||||
import { USER_ROLES } from '../../constants';
|
import { USER_ROLES } from '../../constants';
|
||||||
|
import { Context } from '../../common/log';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class UserGroupsRepositoryService {
|
export class UserGroupsRepositoryService {
|
||||||
constructor(private dataSource: DataSource) {}
|
constructor(private dataSource: DataSource) {}
|
||||||
|
|
||||||
async getUserGroups(account_id: number): Promise<UserGroup[]> {
|
async getUserGroups(
|
||||||
|
context: Context,
|
||||||
|
account_id: number,
|
||||||
|
): Promise<UserGroup[]> {
|
||||||
const value = await this.dataSource.transaction(async (entityManager) => {
|
const value = await this.dataSource.transaction(async (entityManager) => {
|
||||||
const userGroupRepo = entityManager.getRepository(UserGroup);
|
const userGroupRepo = entityManager.getRepository(UserGroup);
|
||||||
|
|
||||||
const userGroups = await userGroupRepo.find({
|
const userGroups = await userGroupRepo.find({
|
||||||
// 論理削除されていないレコードを取得
|
// 論理削除されていないレコードを取得
|
||||||
where: { account_id: account_id, deleted_at: IsNull() },
|
where: { account_id: account_id, deleted_at: IsNull() },
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
return userGroups;
|
return userGroups;
|
||||||
@ -29,6 +34,7 @@ export class UserGroupsRepositoryService {
|
|||||||
* @returns users from groups
|
* @returns users from groups
|
||||||
*/
|
*/
|
||||||
async getGroupMembersFromGroupIds(
|
async getGroupMembersFromGroupIds(
|
||||||
|
context: Context,
|
||||||
groupIds: number[],
|
groupIds: number[],
|
||||||
): Promise<UserGroupMember[]> {
|
): Promise<UserGroupMember[]> {
|
||||||
return await this.dataSource.transaction(async (entityManager) => {
|
return await this.dataSource.transaction(async (entityManager) => {
|
||||||
@ -41,6 +47,7 @@ export class UserGroupsRepositoryService {
|
|||||||
where: {
|
where: {
|
||||||
user_group_id: In(groupIds),
|
user_group_id: In(groupIds),
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
return groupMembers;
|
return groupMembers;
|
||||||
@ -54,6 +61,7 @@ export class UserGroupsRepositoryService {
|
|||||||
* @returns typist group
|
* @returns typist group
|
||||||
*/
|
*/
|
||||||
async getTypistGroup(
|
async getTypistGroup(
|
||||||
|
context: Context,
|
||||||
accountId: number,
|
accountId: number,
|
||||||
typistGroupId: number,
|
typistGroupId: number,
|
||||||
): Promise<UserGroup> {
|
): Promise<UserGroup> {
|
||||||
@ -69,6 +77,7 @@ export class UserGroupsRepositoryService {
|
|||||||
relations: {
|
relations: {
|
||||||
userGroupMembers: true,
|
userGroupMembers: true,
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!userGroup) {
|
if (!userGroup) {
|
||||||
@ -88,6 +97,7 @@ export class UserGroupsRepositoryService {
|
|||||||
* @returns createdTypistGroup
|
* @returns createdTypistGroup
|
||||||
*/
|
*/
|
||||||
async createTypistGroup(
|
async createTypistGroup(
|
||||||
|
context: Context,
|
||||||
name: string,
|
name: string,
|
||||||
typistIds: number[],
|
typistIds: number[],
|
||||||
accountId: number,
|
accountId: number,
|
||||||
@ -104,6 +114,7 @@ export class UserGroupsRepositoryService {
|
|||||||
role: USER_ROLES.TYPIST,
|
role: USER_ROLES.TYPIST,
|
||||||
email_verified: true,
|
email_verified: true,
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
if (userRecords.length !== typistIds.length) {
|
if (userRecords.length !== typistIds.length) {
|
||||||
throw new TypistIdInvalidError(
|
throw new TypistIdInvalidError(
|
||||||
@ -139,6 +150,7 @@ export class UserGroupsRepositoryService {
|
|||||||
* @returns createdTypistGroup
|
* @returns createdTypistGroup
|
||||||
*/
|
*/
|
||||||
async updateTypistGroup(
|
async updateTypistGroup(
|
||||||
|
context: Context,
|
||||||
accountId: number,
|
accountId: number,
|
||||||
typistGroupId: number,
|
typistGroupId: number,
|
||||||
typistGroupName: string,
|
typistGroupName: string,
|
||||||
@ -156,6 +168,7 @@ export class UserGroupsRepositoryService {
|
|||||||
role: USER_ROLES.TYPIST,
|
role: USER_ROLES.TYPIST,
|
||||||
email_verified: true,
|
email_verified: true,
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
if (userRecords.length !== typistIds.length) {
|
if (userRecords.length !== typistIds.length) {
|
||||||
throw new TypistIdInvalidError(
|
throw new TypistIdInvalidError(
|
||||||
@ -171,6 +184,7 @@ export class UserGroupsRepositoryService {
|
|||||||
id: typistGroupId,
|
id: typistGroupId,
|
||||||
account_id: accountId,
|
account_id: accountId,
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
if (!typistGroup) {
|
if (!typistGroup) {
|
||||||
throw new TypistGroupNotExistError(
|
throw new TypistGroupNotExistError(
|
||||||
|
|||||||
@ -99,12 +99,16 @@ export class UsersRepositoryService {
|
|||||||
return createdEntity;
|
return createdEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
async findVerifiedUser(sub: string): Promise<User | undefined> {
|
async findVerifiedUser(
|
||||||
|
context: Context,
|
||||||
|
sub: string,
|
||||||
|
): Promise<User | undefined> {
|
||||||
const user = await this.dataSource.getRepository(User).findOne({
|
const user = await this.dataSource.getRepository(User).findOne({
|
||||||
where: {
|
where: {
|
||||||
external_id: sub,
|
external_id: sub,
|
||||||
email_verified: true,
|
email_verified: true,
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!user) {
|
if (!user) {
|
||||||
@ -113,7 +117,7 @@ export class UsersRepositoryService {
|
|||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
async findUserByExternalId(sub: string): Promise<User> {
|
async findUserByExternalId(context: Context, sub: string): Promise<User> {
|
||||||
const user = await this.dataSource.getRepository(User).findOne({
|
const user = await this.dataSource.getRepository(User).findOne({
|
||||||
where: {
|
where: {
|
||||||
external_id: sub,
|
external_id: sub,
|
||||||
@ -121,6 +125,7 @@ export class UsersRepositoryService {
|
|||||||
relations: {
|
relations: {
|
||||||
account: true,
|
account: true,
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!user) {
|
if (!user) {
|
||||||
@ -129,11 +134,12 @@ export class UsersRepositoryService {
|
|||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
async findUserById(id: number): Promise<User> {
|
async findUserById(context: Context, id: number): Promise<User> {
|
||||||
const user = await this.dataSource.getRepository(User).findOne({
|
const user = await this.dataSource.getRepository(User).findOne({
|
||||||
where: {
|
where: {
|
||||||
id: id,
|
id: id,
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!user) {
|
if (!user) {
|
||||||
@ -147,7 +153,11 @@ export class UsersRepositoryService {
|
|||||||
* @param user
|
* @param user
|
||||||
* @returns 存在する:true 存在しない:false
|
* @returns 存在する:true 存在しない:false
|
||||||
*/
|
*/
|
||||||
async existsAuthorId(accountId: number, authorId: string): Promise<boolean> {
|
async existsAuthorId(
|
||||||
|
context: Context,
|
||||||
|
accountId: number,
|
||||||
|
authorId: string,
|
||||||
|
): Promise<boolean> {
|
||||||
const user = await this.dataSource.getRepository(User).findOne({
|
const user = await this.dataSource.getRepository(User).findOne({
|
||||||
where: [
|
where: [
|
||||||
{
|
{
|
||||||
@ -155,6 +165,7 @@ export class UsersRepositoryService {
|
|||||||
author_id: authorId,
|
author_id: authorId,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (user) {
|
if (user) {
|
||||||
@ -169,6 +180,7 @@ export class UsersRepositoryService {
|
|||||||
* @returns update
|
* @returns update
|
||||||
*/
|
*/
|
||||||
async update(
|
async update(
|
||||||
|
context: Context,
|
||||||
accountId: number,
|
accountId: number,
|
||||||
id: number,
|
id: number,
|
||||||
role: string,
|
role: string,
|
||||||
@ -186,6 +198,7 @@ export class UsersRepositoryService {
|
|||||||
// 変更対象のユーザーを取得
|
// 変更対象のユーザーを取得
|
||||||
const targetUser = await repo.findOne({
|
const targetUser = await repo.findOne({
|
||||||
where: { id: id, account_id: accountId },
|
where: { id: id, account_id: accountId },
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
// 運用上ユーザがいないことはあり得ないが、プログラム上発生しうるのでエラーとして処理
|
// 運用上ユーザがいないことはあり得ないが、プログラム上発生しうるのでエラーとして処理
|
||||||
@ -202,6 +215,7 @@ export class UsersRepositoryService {
|
|||||||
// ユーザーのロールがAuthorの場合はAuthorIDの重複チェックを行う
|
// ユーザーのロールがAuthorの場合はAuthorIDの重複チェックを行う
|
||||||
const authorIdDuplicatedUser = await repo.findOne({
|
const authorIdDuplicatedUser = await repo.findOne({
|
||||||
where: { account_id: accountId, id: Not(id), author_id: authorId },
|
where: { account_id: accountId, id: Not(id), author_id: authorId },
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
// 重複したAuthorIDがあった場合はエラー
|
// 重複したAuthorIDがあった場合はエラー
|
||||||
@ -257,13 +271,17 @@ export class UsersRepositoryService {
|
|||||||
* @param user
|
* @param user
|
||||||
* @returns update
|
* @returns update
|
||||||
*/
|
*/
|
||||||
async updateUserVerified(id: number): Promise<UpdateResult> {
|
async updateUserVerified(
|
||||||
|
context: Context,
|
||||||
|
id: number,
|
||||||
|
): Promise<UpdateResult> {
|
||||||
return await this.dataSource.transaction(async (entityManager) => {
|
return await this.dataSource.transaction(async (entityManager) => {
|
||||||
const repo = entityManager.getRepository(User);
|
const repo = entityManager.getRepository(User);
|
||||||
const targetUser = await repo.findOne({
|
const targetUser = await repo.findOne({
|
||||||
where: {
|
where: {
|
||||||
id: id,
|
id: id,
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
// 運用上ユーザがいないことはあり得ないが、プログラム上発生しうるのでエラーとして処理
|
// 運用上ユーザがいないことはあり得ないが、プログラム上発生しうるのでエラーとして処理
|
||||||
@ -286,7 +304,10 @@ export class UsersRepositoryService {
|
|||||||
* @param id
|
* @param id
|
||||||
* @returns user verified and create trial license
|
* @returns user verified and create trial license
|
||||||
*/
|
*/
|
||||||
async updateUserVerifiedAndCreateTrialLicense(id: number): Promise<void> {
|
async updateUserVerifiedAndCreateTrialLicense(
|
||||||
|
context: Context,
|
||||||
|
id: number,
|
||||||
|
): Promise<void> {
|
||||||
await this.dataSource.transaction(async (entityManager) => {
|
await this.dataSource.transaction(async (entityManager) => {
|
||||||
const userRepo = entityManager.getRepository(User);
|
const userRepo = entityManager.getRepository(User);
|
||||||
const targetUser = await userRepo.findOne({
|
const targetUser = await userRepo.findOne({
|
||||||
@ -296,6 +317,7 @@ export class UsersRepositoryService {
|
|||||||
where: {
|
where: {
|
||||||
id: id,
|
id: id,
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
// 運用上ユーザがいないことはあり得ないが、プログラム上発生しうるのでエラーとして処理
|
// 運用上ユーザがいないことはあり得ないが、プログラム上発生しうるのでエラーとして処理
|
||||||
@ -348,8 +370,12 @@ export class UsersRepositoryService {
|
|||||||
return await this.dataSource.transaction(async (entityManager) => {
|
return await this.dataSource.transaction(async (entityManager) => {
|
||||||
const repo = entityManager.getRepository(User);
|
const repo = entityManager.getRepository(User);
|
||||||
|
|
||||||
const accountId = (await repo.findOne({ where: { external_id } }))
|
const accountId = (
|
||||||
?.account_id;
|
await repo.findOne({
|
||||||
|
where: { external_id },
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
|
})
|
||||||
|
)?.account_id;
|
||||||
|
|
||||||
if (!accountId) {
|
if (!accountId) {
|
||||||
throw new AccountNotFoundError('Account is Not Found.');
|
throw new AccountNotFoundError('Account is Not Found.');
|
||||||
@ -363,7 +389,7 @@ export class UsersRepositoryService {
|
|||||||
license: true,
|
license: true,
|
||||||
},
|
},
|
||||||
where: { account_id: accountId },
|
where: { account_id: accountId },
|
||||||
comment: `${context.getTrackingId()}`,
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
return dbUsers;
|
return dbUsers;
|
||||||
@ -375,7 +401,7 @@ export class UsersRepositoryService {
|
|||||||
* @param sub
|
* @param sub
|
||||||
* @returns typist users
|
* @returns typist users
|
||||||
*/
|
*/
|
||||||
async findTypistUsers(sub: string): Promise<User[]> {
|
async findTypistUsers(context: Context, sub: string): Promise<User[]> {
|
||||||
return await this.dataSource.transaction(async (entityManager) => {
|
return await this.dataSource.transaction(async (entityManager) => {
|
||||||
const repo = entityManager.getRepository(User);
|
const repo = entityManager.getRepository(User);
|
||||||
|
|
||||||
@ -383,6 +409,7 @@ export class UsersRepositoryService {
|
|||||||
where: {
|
where: {
|
||||||
external_id: sub,
|
external_id: sub,
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
// 運用上ユーザがいないことはあり得ないが、プログラム上発生しうるのでエラーとして処理
|
// 運用上ユーザがいないことはあり得ないが、プログラム上発生しうるのでエラーとして処理
|
||||||
@ -397,6 +424,7 @@ export class UsersRepositoryService {
|
|||||||
email_verified: true,
|
email_verified: true,
|
||||||
deleted_at: IsNull(),
|
deleted_at: IsNull(),
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
return typists;
|
return typists;
|
||||||
@ -408,7 +436,7 @@ export class UsersRepositoryService {
|
|||||||
* @param accountId
|
* @param accountId
|
||||||
* @returns author users
|
* @returns author users
|
||||||
*/
|
*/
|
||||||
async findAuthorUsers(accountId: number): Promise<User[]> {
|
async findAuthorUsers(context: Context, accountId: number): Promise<User[]> {
|
||||||
return await this.dataSource.transaction(async (entityManager) => {
|
return await this.dataSource.transaction(async (entityManager) => {
|
||||||
const repo = entityManager.getRepository(User);
|
const repo = entityManager.getRepository(User);
|
||||||
const authors = await repo.find({
|
const authors = await repo.find({
|
||||||
@ -418,6 +446,7 @@ export class UsersRepositoryService {
|
|||||||
email_verified: true,
|
email_verified: true,
|
||||||
deleted_at: IsNull(),
|
deleted_at: IsNull(),
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
return authors;
|
return authors;
|
||||||
});
|
});
|
||||||
@ -447,6 +476,7 @@ export class UsersRepositoryService {
|
|||||||
* @returns TermsCheckInfo
|
* @returns TermsCheckInfo
|
||||||
*/
|
*/
|
||||||
async getAcceptedAndLatestVersion(
|
async getAcceptedAndLatestVersion(
|
||||||
|
context: Context,
|
||||||
externalId: string,
|
externalId: string,
|
||||||
): Promise<TermsCheckInfo> {
|
): Promise<TermsCheckInfo> {
|
||||||
return await this.dataSource.transaction(async (entityManager) => {
|
return await this.dataSource.transaction(async (entityManager) => {
|
||||||
@ -458,6 +488,7 @@ export class UsersRepositoryService {
|
|||||||
relations: {
|
relations: {
|
||||||
account: true,
|
account: true,
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!user) {
|
if (!user) {
|
||||||
@ -475,6 +506,7 @@ export class UsersRepositoryService {
|
|||||||
order: {
|
order: {
|
||||||
id: 'DESC',
|
id: 'DESC',
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
const latestPrivacyNoticeInfo = await termRepo.findOne({
|
const latestPrivacyNoticeInfo = await termRepo.findOne({
|
||||||
where: {
|
where: {
|
||||||
@ -483,6 +515,7 @@ export class UsersRepositoryService {
|
|||||||
order: {
|
order: {
|
||||||
id: 'DESC',
|
id: 'DESC',
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
const latestDpaInfo = await termRepo.findOne({
|
const latestDpaInfo = await termRepo.findOne({
|
||||||
where: {
|
where: {
|
||||||
@ -491,6 +524,7 @@ export class UsersRepositoryService {
|
|||||||
order: {
|
order: {
|
||||||
id: 'DESC',
|
id: 'DESC',
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
if (!latestEulaInfo || !latestPrivacyNoticeInfo || !latestDpaInfo) {
|
if (!latestEulaInfo || !latestPrivacyNoticeInfo || !latestDpaInfo) {
|
||||||
throw new TermInfoNotFoundError(`Terms info is not found.`);
|
throw new TermInfoNotFoundError(`Terms info is not found.`);
|
||||||
@ -518,6 +552,7 @@ export class UsersRepositoryService {
|
|||||||
* @returns update
|
* @returns update
|
||||||
*/
|
*/
|
||||||
async updateAcceptedTermsVersion(
|
async updateAcceptedTermsVersion(
|
||||||
|
context: Context,
|
||||||
externalId: string,
|
externalId: string,
|
||||||
eulaVersion: string,
|
eulaVersion: string,
|
||||||
privacyNoticeVersion: string,
|
privacyNoticeVersion: string,
|
||||||
@ -532,6 +567,7 @@ export class UsersRepositoryService {
|
|||||||
relations: {
|
relations: {
|
||||||
account: true,
|
account: true,
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!user) {
|
if (!user) {
|
||||||
@ -574,6 +610,7 @@ export class UsersRepositoryService {
|
|||||||
* @returns delegate accounts
|
* @returns delegate accounts
|
||||||
*/
|
*/
|
||||||
async findDelegateUser(
|
async findDelegateUser(
|
||||||
|
context: Context,
|
||||||
delegateAccountId: number,
|
delegateAccountId: number,
|
||||||
originAccountId: number,
|
originAccountId: number,
|
||||||
): Promise<User> {
|
): Promise<User> {
|
||||||
@ -587,6 +624,7 @@ export class UsersRepositoryService {
|
|||||||
parent_account_id: delegateAccountId,
|
parent_account_id: delegateAccountId,
|
||||||
tier: TIERS.TIER5,
|
tier: TIERS.TIER5,
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!account) {
|
if (!account) {
|
||||||
@ -619,6 +657,7 @@ export class UsersRepositoryService {
|
|||||||
relations: {
|
relations: {
|
||||||
account: true,
|
account: true,
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
// 運用上、代行操作対象アカウントの管理者ユーザーがいないことはあり得ないが、プログラム上発生しうるのでエラーとして処理
|
// 運用上、代行操作対象アカウントの管理者ユーザーがいないことはあり得ないが、プログラム上発生しうるのでエラーとして処理
|
||||||
@ -637,6 +676,7 @@ export class UsersRepositoryService {
|
|||||||
* @returns delegate accounts
|
* @returns delegate accounts
|
||||||
*/
|
*/
|
||||||
async isAllowDelegationPermission(
|
async isAllowDelegationPermission(
|
||||||
|
context: Context,
|
||||||
delegateAccountId: number,
|
delegateAccountId: number,
|
||||||
originUserExternalId: string,
|
originUserExternalId: string,
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
@ -653,6 +693,7 @@ export class UsersRepositoryService {
|
|||||||
relations: {
|
relations: {
|
||||||
account: true,
|
account: true,
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!primaryUser) {
|
if (!primaryUser) {
|
||||||
@ -677,7 +718,10 @@ export class UsersRepositoryService {
|
|||||||
* @param userId
|
* @param userId
|
||||||
* @returns user relations
|
* @returns user relations
|
||||||
*/
|
*/
|
||||||
async getUserRelations(userId: number): Promise<{
|
async getUserRelations(
|
||||||
|
context: Context,
|
||||||
|
userId: number,
|
||||||
|
): Promise<{
|
||||||
user: User;
|
user: User;
|
||||||
authors: User[];
|
authors: User[];
|
||||||
worktypes: Worktype[];
|
worktypes: Worktype[];
|
||||||
@ -689,6 +733,7 @@ export class UsersRepositoryService {
|
|||||||
const user = await userRepo.findOne({
|
const user = await userRepo.findOne({
|
||||||
where: { id: userId },
|
where: { id: userId },
|
||||||
relations: { account: true },
|
relations: { account: true },
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!user) {
|
if (!user) {
|
||||||
@ -709,6 +754,7 @@ export class UsersRepositoryService {
|
|||||||
role: USER_ROLES.AUTHOR,
|
role: USER_ROLES.AUTHOR,
|
||||||
email_verified: true,
|
email_verified: true,
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
// ユーザーの所属するアカウント内のアクティブワークタイプを取得する
|
// ユーザーの所属するアカウント内のアクティブワークタイプを取得する
|
||||||
@ -722,6 +768,7 @@ export class UsersRepositoryService {
|
|||||||
account_id: user.account_id,
|
account_id: user.account_id,
|
||||||
id: activeWorktypeId,
|
id: activeWorktypeId,
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
})) ?? undefined;
|
})) ?? undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -740,6 +787,7 @@ export class UsersRepositoryService {
|
|||||||
option_items: true,
|
option_items: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
worktypes = workflows.flatMap((workflow) =>
|
worktypes = workflows.flatMap((workflow) =>
|
||||||
|
|||||||
@ -15,6 +15,7 @@ import {
|
|||||||
AuthorIdAndWorktypeIdPairAlreadyExistsError,
|
AuthorIdAndWorktypeIdPairAlreadyExistsError,
|
||||||
WorkflowNotFoundError,
|
WorkflowNotFoundError,
|
||||||
} from './errors/types';
|
} from './errors/types';
|
||||||
|
import { Context } from '../../common/log';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class WorkflowsRepositoryService {
|
export class WorkflowsRepositoryService {
|
||||||
@ -25,7 +26,7 @@ export class WorkflowsRepositoryService {
|
|||||||
* @param externalId
|
* @param externalId
|
||||||
* @returns worktypes and active worktype id
|
* @returns worktypes and active worktype id
|
||||||
*/
|
*/
|
||||||
async getWorkflows(accountId: number): Promise<Workflow[]> {
|
async getWorkflows(context: Context, accountId: number): Promise<Workflow[]> {
|
||||||
return await this.dataSource.transaction(async (entityManager) => {
|
return await this.dataSource.transaction(async (entityManager) => {
|
||||||
const workflowRepo = entityManager.getRepository(Workflow);
|
const workflowRepo = entityManager.getRepository(Workflow);
|
||||||
|
|
||||||
@ -43,6 +44,7 @@ export class WorkflowsRepositoryService {
|
|||||||
order: {
|
order: {
|
||||||
id: 'ASC',
|
id: 'ASC',
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
return workflows;
|
return workflows;
|
||||||
@ -59,6 +61,7 @@ export class WorkflowsRepositoryService {
|
|||||||
* @returns workflows
|
* @returns workflows
|
||||||
*/
|
*/
|
||||||
async createtWorkflows(
|
async createtWorkflows(
|
||||||
|
context: Context,
|
||||||
accountId: number,
|
accountId: number,
|
||||||
authorId: number,
|
authorId: number,
|
||||||
typists: WorkflowTypist[],
|
typists: WorkflowTypist[],
|
||||||
@ -70,6 +73,7 @@ export class WorkflowsRepositoryService {
|
|||||||
const userRepo = entityManager.getRepository(User);
|
const userRepo = entityManager.getRepository(User);
|
||||||
const author = await userRepo.findOne({
|
const author = await userRepo.findOne({
|
||||||
where: { account_id: accountId, id: authorId, email_verified: true },
|
where: { account_id: accountId, id: authorId, email_verified: true },
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
if (!author) {
|
if (!author) {
|
||||||
throw new UserNotFoundError(
|
throw new UserNotFoundError(
|
||||||
@ -82,6 +86,7 @@ export class WorkflowsRepositoryService {
|
|||||||
const worktypeRepo = entityManager.getRepository(Worktype);
|
const worktypeRepo = entityManager.getRepository(Worktype);
|
||||||
const worktypes = await worktypeRepo.find({
|
const worktypes = await worktypeRepo.find({
|
||||||
where: { account_id: accountId, id: worktypeId },
|
where: { account_id: accountId, id: worktypeId },
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
if (worktypes.length === 0) {
|
if (worktypes.length === 0) {
|
||||||
throw new WorktypeIdNotFoundError(
|
throw new WorktypeIdNotFoundError(
|
||||||
@ -95,6 +100,7 @@ export class WorkflowsRepositoryService {
|
|||||||
const templateRepo = entityManager.getRepository(TemplateFile);
|
const templateRepo = entityManager.getRepository(TemplateFile);
|
||||||
const template = await templateRepo.findOne({
|
const template = await templateRepo.findOne({
|
||||||
where: { account_id: accountId, id: templateId },
|
where: { account_id: accountId, id: templateId },
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
if (!template) {
|
if (!template) {
|
||||||
throw new TemplateFileNotExistError('template not found.');
|
throw new TemplateFileNotExistError('template not found.');
|
||||||
@ -111,6 +117,7 @@ export class WorkflowsRepositoryService {
|
|||||||
id: In(typistIds),
|
id: In(typistIds),
|
||||||
email_verified: true,
|
email_verified: true,
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
if (typistUsers.length !== typistIds.length) {
|
if (typistUsers.length !== typistIds.length) {
|
||||||
throw new UserNotFoundError(
|
throw new UserNotFoundError(
|
||||||
@ -125,6 +132,7 @@ export class WorkflowsRepositoryService {
|
|||||||
const userGroupRepo = entityManager.getRepository(UserGroup);
|
const userGroupRepo = entityManager.getRepository(UserGroup);
|
||||||
const typistGroups = await userGroupRepo.find({
|
const typistGroups = await userGroupRepo.find({
|
||||||
where: { account_id: accountId, id: In(groupIds) },
|
where: { account_id: accountId, id: In(groupIds) },
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
if (typistGroups.length !== groupIds.length) {
|
if (typistGroups.length !== groupIds.length) {
|
||||||
throw new TypistGroupNotExistError(
|
throw new TypistGroupNotExistError(
|
||||||
@ -141,6 +149,7 @@ export class WorkflowsRepositoryService {
|
|||||||
author_id: authorId,
|
author_id: authorId,
|
||||||
worktype_id: worktypeId !== undefined ? worktypeId : IsNull(),
|
worktype_id: worktypeId !== undefined ? worktypeId : IsNull(),
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
if (workflow.length !== 0) {
|
if (workflow.length !== 0) {
|
||||||
throw new AuthorIdAndWorktypeIdPairAlreadyExistsError(
|
throw new AuthorIdAndWorktypeIdPairAlreadyExistsError(
|
||||||
@ -183,6 +192,7 @@ export class WorkflowsRepositoryService {
|
|||||||
* @returns workflow
|
* @returns workflow
|
||||||
*/
|
*/
|
||||||
async updatetWorkflow(
|
async updatetWorkflow(
|
||||||
|
context: Context,
|
||||||
accountId: number,
|
accountId: number,
|
||||||
workflowId: number,
|
workflowId: number,
|
||||||
authorId: number,
|
authorId: number,
|
||||||
@ -196,6 +206,7 @@ export class WorkflowsRepositoryService {
|
|||||||
// ワークフローの存在確認
|
// ワークフローの存在確認
|
||||||
const targetWorkflow = await workflowRepo.findOne({
|
const targetWorkflow = await workflowRepo.findOne({
|
||||||
where: { account_id: accountId, id: workflowId },
|
where: { account_id: accountId, id: workflowId },
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
if (!targetWorkflow) {
|
if (!targetWorkflow) {
|
||||||
throw new WorkflowNotFoundError(
|
throw new WorkflowNotFoundError(
|
||||||
@ -207,6 +218,7 @@ export class WorkflowsRepositoryService {
|
|||||||
const userRepo = entityManager.getRepository(User);
|
const userRepo = entityManager.getRepository(User);
|
||||||
const author = await userRepo.findOne({
|
const author = await userRepo.findOne({
|
||||||
where: { account_id: accountId, id: authorId, email_verified: true },
|
where: { account_id: accountId, id: authorId, email_verified: true },
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
if (!author) {
|
if (!author) {
|
||||||
throw new UserNotFoundError(
|
throw new UserNotFoundError(
|
||||||
@ -219,6 +231,7 @@ export class WorkflowsRepositoryService {
|
|||||||
const worktypeRepo = entityManager.getRepository(Worktype);
|
const worktypeRepo = entityManager.getRepository(Worktype);
|
||||||
const worktypes = await worktypeRepo.find({
|
const worktypes = await worktypeRepo.find({
|
||||||
where: { account_id: accountId, id: worktypeId },
|
where: { account_id: accountId, id: worktypeId },
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
if (worktypes.length === 0) {
|
if (worktypes.length === 0) {
|
||||||
throw new WorktypeIdNotFoundError(
|
throw new WorktypeIdNotFoundError(
|
||||||
@ -232,6 +245,7 @@ export class WorkflowsRepositoryService {
|
|||||||
const templateRepo = entityManager.getRepository(TemplateFile);
|
const templateRepo = entityManager.getRepository(TemplateFile);
|
||||||
const template = await templateRepo.findOne({
|
const template = await templateRepo.findOne({
|
||||||
where: { account_id: accountId, id: templateId },
|
where: { account_id: accountId, id: templateId },
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
if (!template) {
|
if (!template) {
|
||||||
throw new TemplateFileNotExistError(
|
throw new TemplateFileNotExistError(
|
||||||
@ -250,6 +264,7 @@ export class WorkflowsRepositoryService {
|
|||||||
id: In(typistIds),
|
id: In(typistIds),
|
||||||
email_verified: true,
|
email_verified: true,
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
if (typistUsers.length !== typistIds.length) {
|
if (typistUsers.length !== typistIds.length) {
|
||||||
throw new UserNotFoundError(
|
throw new UserNotFoundError(
|
||||||
@ -264,6 +279,7 @@ export class WorkflowsRepositoryService {
|
|||||||
const userGroupRepo = entityManager.getRepository(UserGroup);
|
const userGroupRepo = entityManager.getRepository(UserGroup);
|
||||||
const typistGroups = await userGroupRepo.find({
|
const typistGroups = await userGroupRepo.find({
|
||||||
where: { account_id: accountId, id: In(groupIds) },
|
where: { account_id: accountId, id: In(groupIds) },
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
if (typistGroups.length !== groupIds.length) {
|
if (typistGroups.length !== groupIds.length) {
|
||||||
throw new TypistGroupNotExistError(
|
throw new TypistGroupNotExistError(
|
||||||
@ -285,6 +301,7 @@ export class WorkflowsRepositoryService {
|
|||||||
author_id: authorId,
|
author_id: authorId,
|
||||||
worktype_id: worktypeId !== undefined ? worktypeId : IsNull(),
|
worktype_id: worktypeId !== undefined ? worktypeId : IsNull(),
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
if (duplicateWorkflow.length !== 0) {
|
if (duplicateWorkflow.length !== 0) {
|
||||||
throw new AuthorIdAndWorktypeIdPairAlreadyExistsError(
|
throw new AuthorIdAndWorktypeIdPairAlreadyExistsError(
|
||||||
@ -322,7 +339,11 @@ export class WorkflowsRepositoryService {
|
|||||||
* @param workflowId
|
* @param workflowId
|
||||||
* @returns workflow
|
* @returns workflow
|
||||||
*/
|
*/
|
||||||
async deleteWorkflow(accountId: number, workflowId: number): Promise<void> {
|
async deleteWorkflow(
|
||||||
|
context: Context,
|
||||||
|
accountId: number,
|
||||||
|
workflowId: number,
|
||||||
|
): Promise<void> {
|
||||||
return await this.dataSource.transaction(async (entityManager) => {
|
return await this.dataSource.transaction(async (entityManager) => {
|
||||||
const workflowRepo = entityManager.getRepository(Workflow);
|
const workflowRepo = entityManager.getRepository(Workflow);
|
||||||
const workflowTypistsRepo = entityManager.getRepository(DbWorkflowTypist);
|
const workflowTypistsRepo = entityManager.getRepository(DbWorkflowTypist);
|
||||||
@ -330,6 +351,7 @@ export class WorkflowsRepositoryService {
|
|||||||
// ワークフローの存在確認
|
// ワークフローの存在確認
|
||||||
const workflow = await workflowRepo.findOne({
|
const workflow = await workflowRepo.findOne({
|
||||||
where: { account_id: accountId, id: workflowId },
|
where: { account_id: accountId, id: workflowId },
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
if (!workflow) {
|
if (!workflow) {
|
||||||
throw new WorkflowNotFoundError(
|
throw new WorkflowNotFoundError(
|
||||||
|
|||||||
@ -17,6 +17,7 @@ import { PostWorktypeOptionItem } from '../../features/accounts/types/types';
|
|||||||
import { AccountNotFoundError } from '../accounts/errors/types';
|
import { AccountNotFoundError } from '../accounts/errors/types';
|
||||||
import { Account } from '../accounts/entity/account.entity';
|
import { Account } from '../accounts/entity/account.entity';
|
||||||
import { Workflow } from '../workflows/entity/workflow.entity';
|
import { Workflow } from '../workflows/entity/workflow.entity';
|
||||||
|
import { Context } from '../../common/log';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class WorktypesRepositoryService {
|
export class WorktypesRepositoryService {
|
||||||
@ -27,7 +28,10 @@ export class WorktypesRepositoryService {
|
|||||||
* @param externalId
|
* @param externalId
|
||||||
* @returns worktypes and active worktype id
|
* @returns worktypes and active worktype id
|
||||||
*/
|
*/
|
||||||
async getWorktypes(accountId: number): Promise<{
|
async getWorktypes(
|
||||||
|
context: Context,
|
||||||
|
accountId: number,
|
||||||
|
): Promise<{
|
||||||
worktypes: Worktype[];
|
worktypes: Worktype[];
|
||||||
active_worktype_id?: number | undefined;
|
active_worktype_id?: number | undefined;
|
||||||
}> {
|
}> {
|
||||||
@ -35,7 +39,10 @@ export class WorktypesRepositoryService {
|
|||||||
const WorktypeRepo = entityManager.getRepository(Worktype);
|
const WorktypeRepo = entityManager.getRepository(Worktype);
|
||||||
const accountRepo = entityManager.getRepository(Account);
|
const accountRepo = entityManager.getRepository(Account);
|
||||||
|
|
||||||
const account = await accountRepo.findOne({ where: { id: accountId } });
|
const account = await accountRepo.findOne({
|
||||||
|
where: { id: accountId },
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
|
});
|
||||||
|
|
||||||
// 運用上アカウントがいないことはあり得ないが、プログラム上発生しうるのでエラーとして処理
|
// 運用上アカウントがいないことはあり得ないが、プログラム上発生しうるのでエラーとして処理
|
||||||
if (!account) {
|
if (!account) {
|
||||||
@ -44,6 +51,7 @@ export class WorktypesRepositoryService {
|
|||||||
|
|
||||||
const worktypes = await WorktypeRepo.find({
|
const worktypes = await WorktypeRepo.find({
|
||||||
where: { account_id: account.id },
|
where: { account_id: account.id },
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@ -59,6 +67,7 @@ export class WorktypesRepositoryService {
|
|||||||
* @param [description]
|
* @param [description]
|
||||||
*/
|
*/
|
||||||
async createWorktype(
|
async createWorktype(
|
||||||
|
context: Context,
|
||||||
accountId: number,
|
accountId: number,
|
||||||
worktypeId: string,
|
worktypeId: string,
|
||||||
description?: string,
|
description?: string,
|
||||||
@ -69,6 +78,7 @@ export class WorktypesRepositoryService {
|
|||||||
|
|
||||||
const duplicatedWorktype = await worktypeRepo.findOne({
|
const duplicatedWorktype = await worktypeRepo.findOne({
|
||||||
where: { account_id: accountId, custom_worktype_id: worktypeId },
|
where: { account_id: accountId, custom_worktype_id: worktypeId },
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
// ワークタイプIDが重複している場合はエラー
|
// ワークタイプIDが重複している場合はエラー
|
||||||
@ -80,6 +90,7 @@ export class WorktypesRepositoryService {
|
|||||||
|
|
||||||
const worktypeCount = await worktypeRepo.count({
|
const worktypeCount = await worktypeRepo.count({
|
||||||
where: { account_id: accountId },
|
where: { account_id: accountId },
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
// ワークタイプの登録数が上限に達している場合はエラー
|
// ワークタイプの登録数が上限に達している場合はエラー
|
||||||
@ -119,6 +130,7 @@ export class WorktypesRepositoryService {
|
|||||||
* @param [description]
|
* @param [description]
|
||||||
*/
|
*/
|
||||||
async updateWorktype(
|
async updateWorktype(
|
||||||
|
context: Context,
|
||||||
accountId: number,
|
accountId: number,
|
||||||
id: number,
|
id: number,
|
||||||
worktypeId: string,
|
worktypeId: string,
|
||||||
@ -129,6 +141,7 @@ export class WorktypesRepositoryService {
|
|||||||
|
|
||||||
const worktype = await worktypeRepo.findOne({
|
const worktype = await worktypeRepo.findOne({
|
||||||
where: { account_id: accountId, id: id },
|
where: { account_id: accountId, id: id },
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
// ワークタイプが存在しない場合はエラー
|
// ワークタイプが存在しない場合はエラー
|
||||||
@ -142,6 +155,7 @@ export class WorktypesRepositoryService {
|
|||||||
custom_worktype_id: worktypeId,
|
custom_worktype_id: worktypeId,
|
||||||
id: Not(id),
|
id: Not(id),
|
||||||
},
|
},
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
// ワークタイプIDが重複している場合はエラー
|
// ワークタイプIDが重複している場合はエラー
|
||||||
@ -164,12 +178,17 @@ export class WorktypesRepositoryService {
|
|||||||
* @param id
|
* @param id
|
||||||
* @returns worktype
|
* @returns worktype
|
||||||
*/
|
*/
|
||||||
async deleteWorktype(accountId: number, id: number): Promise<void> {
|
async deleteWorktype(
|
||||||
|
context: Context,
|
||||||
|
accountId: number,
|
||||||
|
id: number,
|
||||||
|
): Promise<void> {
|
||||||
await this.dataSource.transaction(async (entityManager) => {
|
await this.dataSource.transaction(async (entityManager) => {
|
||||||
const worktypeRepo = entityManager.getRepository(Worktype);
|
const worktypeRepo = entityManager.getRepository(Worktype);
|
||||||
|
|
||||||
const worktype = await worktypeRepo.findOne({
|
const worktype = await worktypeRepo.findOne({
|
||||||
where: { account_id: accountId, id: id },
|
where: { account_id: accountId, id: id },
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
// ワークタイプが存在しない場合はエラー
|
// ワークタイプが存在しない場合はエラー
|
||||||
if (!worktype) {
|
if (!worktype) {
|
||||||
@ -180,6 +199,7 @@ export class WorktypesRepositoryService {
|
|||||||
const accountRepo = entityManager.getRepository(Account);
|
const accountRepo = entityManager.getRepository(Account);
|
||||||
const account = await accountRepo.findOne({
|
const account = await accountRepo.findOne({
|
||||||
where: { id: accountId },
|
where: { id: accountId },
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (account?.active_worktype_id === id) {
|
if (account?.active_worktype_id === id) {
|
||||||
@ -193,6 +213,7 @@ export class WorktypesRepositoryService {
|
|||||||
const workflowRepo = entityManager.getRepository(Workflow);
|
const workflowRepo = entityManager.getRepository(Workflow);
|
||||||
const workflows = await workflowRepo.find({
|
const workflows = await workflowRepo.find({
|
||||||
where: { account_id: accountId, worktype_id: id },
|
where: { account_id: accountId, worktype_id: id },
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
if (workflows.length > 0) {
|
if (workflows.length > 0) {
|
||||||
const workflowIds = workflows.map((workflow) => workflow.id);
|
const workflowIds = workflows.map((workflow) => workflow.id);
|
||||||
@ -217,6 +238,7 @@ export class WorktypesRepositoryService {
|
|||||||
* @returns option items
|
* @returns option items
|
||||||
*/
|
*/
|
||||||
async getOptionItems(
|
async getOptionItems(
|
||||||
|
context: Context,
|
||||||
accountId: number,
|
accountId: number,
|
||||||
worktypeId: number,
|
worktypeId: number,
|
||||||
): Promise<OptionItem[]> {
|
): Promise<OptionItem[]> {
|
||||||
@ -226,6 +248,7 @@ export class WorktypesRepositoryService {
|
|||||||
|
|
||||||
const worktype = await repoWorktype.findOne({
|
const worktype = await repoWorktype.findOne({
|
||||||
where: { account_id: accountId, id: worktypeId },
|
where: { account_id: accountId, id: worktypeId },
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
// ワークタイプが存在しない場合はエラー
|
// ワークタイプが存在しない場合はエラー
|
||||||
@ -237,6 +260,7 @@ export class WorktypesRepositoryService {
|
|||||||
|
|
||||||
const optionItems = await repoOptionItem.find({
|
const optionItems = await repoOptionItem.find({
|
||||||
where: { worktype_id: worktypeId },
|
where: { worktype_id: worktypeId },
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
return optionItems;
|
return optionItems;
|
||||||
@ -251,6 +275,7 @@ export class WorktypesRepositoryService {
|
|||||||
* @returns option items
|
* @returns option items
|
||||||
*/
|
*/
|
||||||
async updateOptionItems(
|
async updateOptionItems(
|
||||||
|
context: Context,
|
||||||
accountId: number,
|
accountId: number,
|
||||||
worktypeId: number,
|
worktypeId: number,
|
||||||
worktypeOptionItems: PostWorktypeOptionItem[],
|
worktypeOptionItems: PostWorktypeOptionItem[],
|
||||||
@ -261,6 +286,7 @@ export class WorktypesRepositoryService {
|
|||||||
|
|
||||||
const worktype = await worktypeRepo.findOne({
|
const worktype = await worktypeRepo.findOne({
|
||||||
where: { account_id: accountId, id: worktypeId },
|
where: { account_id: accountId, id: worktypeId },
|
||||||
|
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||||
});
|
});
|
||||||
// ワークタイプが存在しない場合はエラー
|
// ワークタイプが存在しない場合はエラー
|
||||||
if (!worktype) {
|
if (!worktype) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user