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)
private pagesRepository: PagesRepository,
@Inject(DI.userMemoRepository)
private userMemoRepository: UserMemoRepository,
@Inject(DI.userMemosRepository)
private userMemosRepository: UserMemoRepository,
//private noteEntityService: NoteEntityService,
//private driveFileEntityService: DriveFileEntityService,
@ -340,7 +340,7 @@ export class UserEntityService implements OnModuleInit {
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,
targetUserId: user.id,
}).then(row => row?.memo ?? null);

View file

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

View file

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

View file

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