refactor(backend): tweak repository name

This commit is contained in:
syuilo 2023-04-13 13:31:54 +09:00
parent 605f149235
commit 97abfd48ce
4 changed files with 14 additions and 14 deletions

View file

@ -114,8 +114,8 @@ export class UserEntityService implements OnModuleInit {
@Inject(DI.pagesRepository) @Inject(DI.pagesRepository)
private pagesRepository: PagesRepository, private pagesRepository: PagesRepository,
@Inject(DI.userMemoRepository) @Inject(DI.userMemosRepository)
private userMemoRepository: UserMemoRepository, private userMemosRepository: UserMemoRepository,
//private noteEntityService: NoteEntityService, //private noteEntityService: NoteEntityService,
//private driveFileEntityService: DriveFileEntityService, //private driveFileEntityService: DriveFileEntityService,
@ -340,7 +340,7 @@ export class UserEntityService implements OnModuleInit {
const falsy = opts.detail ? false : undefined; const falsy = opts.detail ? false : undefined;
const memo = meId == null ? null : await this.userMemoRepository.findOneBy({ const memo = meId == null ? null : await this.userMemosRepository.findOneBy({
userId: meId, userId: meId,
targetUserId: user.id, targetUserId: user.id,
}).then(row => row?.memo ?? null); }).then(row => row?.memo ?? null);

View file

@ -70,6 +70,6 @@ export const DI = {
roleAssignmentsRepository: Symbol('roleAssignmentsRepository'), roleAssignmentsRepository: Symbol('roleAssignmentsRepository'),
flashsRepository: Symbol('flashsRepository'), flashsRepository: Symbol('flashsRepository'),
flashLikesRepository: Symbol('flashLikesRepository'), flashLikesRepository: Symbol('flashLikesRepository'),
userMemoRepository: Symbol('userMemoRepository'), userMemosRepository: Symbol('userMemosRepository'),
//#endregion //#endregion
}; };

View file

@ -388,8 +388,8 @@ const $roleAssignmentsRepository: Provider = {
inject: [DI.db], inject: [DI.db],
}; };
const $userMemoRepository: Provider = { const $userMemosRepository: Provider = {
provide: DI.userMemoRepository, provide: DI.userMemosRepository,
useFactory: (db: DataSource) => db.getRepository(UserMemo), useFactory: (db: DataSource) => db.getRepository(UserMemo),
inject: [DI.db], inject: [DI.db],
}; };
@ -462,7 +462,7 @@ const $userMemoRepository: Provider = {
$roleAssignmentsRepository, $roleAssignmentsRepository,
$flashsRepository, $flashsRepository,
$flashLikesRepository, $flashLikesRepository,
$userMemoRepository, $userMemosRepository,
], ],
exports: [ exports: [
$usersRepository, $usersRepository,
@ -529,7 +529,7 @@ const $userMemoRepository: Provider = {
$roleAssignmentsRepository, $roleAssignmentsRepository,
$flashsRepository, $flashsRepository,
$flashLikesRepository, $flashLikesRepository,
$userMemoRepository, $userMemosRepository,
], ],
}) })
export class RepositoryModule {} export class RepositoryModule {}

View file

@ -39,8 +39,8 @@ export const paramDef = {
@Injectable() @Injectable()
export default class extends Endpoint<typeof meta, typeof paramDef> { export default class extends Endpoint<typeof meta, typeof paramDef> {
constructor( constructor(
@Inject(DI.userMemoRepository) @Inject(DI.userMemosRepository)
private userMemoRepository: UserMemoRepository, private userMemosRepository: UserMemoRepository,
private getterService: GetterService, private getterService: GetterService,
private idService: IdService, private idService: IdService,
) { ) {
@ -53,7 +53,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
// 引数がnullか空文字であれば、パーソナルメモを削除する // 引数がnullか空文字であれば、パーソナルメモを削除する
if (ps.memo === '' || ps.memo == null) { if (ps.memo === '' || ps.memo == null) {
await this.userMemoRepository.delete({ await this.userMemosRepository.delete({
userId: me.id, userId: me.id,
targetUserId: target.id, targetUserId: target.id,
}); });
@ -61,20 +61,20 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
} }
// 以前に作成されたパーソナルメモがあるかどうか確認 // 以前に作成されたパーソナルメモがあるかどうか確認
const previousMemo = await this.userMemoRepository.findOneBy({ const previousMemo = await this.userMemosRepository.findOneBy({
userId: me.id, userId: me.id,
targetUserId: target.id, targetUserId: target.id,
}); });
if (!previousMemo) { if (!previousMemo) {
await this.userMemoRepository.insert({ await this.userMemosRepository.insert({
id: this.idService.genId(), id: this.idService.genId(),
userId: me.id, userId: me.id,
targetUserId: target.id, targetUserId: target.id,
memo: ps.memo, memo: ps.memo,
}); });
} else { } else {
await this.userMemoRepository.update(previousMemo.id, { await this.userMemosRepository.update(previousMemo.id, {
userId: me.id, userId: me.id,
targetUserId: target.id, targetUserId: target.id,
memo: ps.memo, memo: ps.memo,