OMDSCloud/dictation_server/src/features/notification/notification.controller.ts
saito.k d5e5e59f8c Merged PR 128: API実装(ソート条件変更)
## 概要
[Task1835: API実装(ソート条件変更)](https://paruru.nds-tyo.co.jp:8443/tfs/ReciproCollection/fa4924a4-d079-4fab-9fb5-a9a11eb205f0/_workitems/edit/1835)

- ソート条件変更APIを実装
  - トークンからB2CのIDを取得→userテーブルからユーザー情報を取得
  - ユーザーIDでソート条件テーブルを検索→レコードを更新
- ソート条件テーブルにレコードを作成する
  - アカウント作成時の処理にソート条件レコードを作成する処理を追加
  - ユーザー追加時にも処理を追加
- テスト修正

## レビューポイント
- APIの引数をチェックする関数をControllerに配置してもよいか
- ソート条件のレコードを作成するタイミングに漏れはないか
- 実装漏れはないか

## UIの変更
- Before/Afterのスクショなど
- スクショ置き場

## 動作確認状況
- ローカルで確認

## 補足
- 相談、参考資料などがあれば
2023-06-06 08:20:21 +00:00

47 lines
1.4 KiB
TypeScript

import { Body, Controller, HttpStatus, Post, UseGuards } from '@nestjs/common';
import {
ApiResponse,
ApiOperation,
ApiBearerAuth,
ApiTags,
} from '@nestjs/swagger';
import { ErrorResponse } from '../../common/error/types/types';
import { RegisterRequest, RegisterResponse } from './types/types';
import { NotificationService } from './notification.service';
import { AuthGuard } from '../../common/guards/auth/authguards';
@ApiTags('notification')
@Controller('notification')
@ApiBearerAuth()
export class NotificationController {
constructor(private readonly notificationService: NotificationService) {}
@Post('register')
@ApiResponse({
status: HttpStatus.OK,
type: RegisterResponse,
description: '成功時のレスポンス',
})
@ApiResponse({
status: HttpStatus.BAD_REQUEST,
description: '不正なパラメータ',
type: ErrorResponse,
})
@ApiResponse({
status: HttpStatus.UNAUTHORIZED,
description: '認証エラー',
type: ErrorResponse,
})
@ApiResponse({
status: HttpStatus.INTERNAL_SERVER_ERROR,
description: '想定外のサーバーエラー',
type: ErrorResponse,
})
@ApiOperation({ operationId: 'register' })
@UseGuards(AuthGuard)
async register(@Body() body: RegisterRequest): Promise<RegisterResponse> {
const { handler, pns } = body;
await this.notificationService.register(pns, handler);
return {};
}
}