# All files / controllers dailyIssueReportController.js

0% Statements 0/15
0% Branches 0/2
0% Functions 0/3
0% Lines 0/15

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65

     /**
     * 일일 이슈 보고서 관리 컨트롤러
     *
     * 일일 이슈 보고서 CRUD API 엔드포인트 핸들러
     *
     * @author TK-FB-Project
     * @since 2025-12-11
     */

    const dailyIssueReportService = require('../services/dailyIssueReportService');
    const { asyncHandler } = require('../middlewares/errorHandler');

    /**
     * 일일 이슈 보고서 생성
     */
    const createDailyIssueReport = asyncHandler(async (req, res) => {
      // 프론트엔드에서 worker_ids 또는 worker_id로 보낼 수 있음
      const issueData = {
        ...req.body,
        worker_ids: req.body.worker_ids || req.body.worker_id
      };

      const result = await dailyIssueReportService.createDailyIssueReportService(issueData);

      res.status(201).json({
        success: true,
        data: result,
        message: result.message
      });
    });

    /**
     * 날짜별 이슈 조회
     */
    const getDailyIssuesByDate = asyncHandler(async (req, res) => {
      const { date } = req.query;
      const issues = await dailyIssueReportService.getDailyIssuesByDateService(date);

      res.json({
        success: true,
        data: issues,
        message: '이슈 보고서 조회 성공'
      });
    });

    /**
     * 이슈 보고서 삭제
     */
    const removeDailyIssue = asyncHandler(async (req, res) => {
      const { id } = req.params;
      const result = await dailyIssueReportService.removeDailyIssueService(id);

      res.json({
        success: true,
        data: result,
        message: result.message
      });
    });

    module.exports = {
      createDailyIssueReport,
      getDailyIssuesByDate,
      removeDailyIssue
    };