package com.itsol.quantrivanphong.report.issuescomment.controller;

import com.itsol.quantrivanphong.report.issue.common.WrapperResult;
import com.itsol.quantrivanphong.report.issuescomment.bussiness.IssuesCommentBussiness;
import com.itsol.quantrivanphong.report.issuescomment.dto.IssuesCommentDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class IssuesControllers {
    @Autowired
    private IssuesCommentBussiness issuesCommentBussiness;

    @GetMapping(value = "/Comment/{IssuesId}")
    public ResponseEntity getComment(@PathVariable("IssuesId") Integer issuesId){
        List<IssuesCommentDTO> listComment = issuesCommentBussiness.getListComment(issuesId);
        return ResponseEntity.ok(listComment);
    }
    @PostMapping(value = "/tao-comment")
    public ResponseEntity saveComment(@RequestBody IssuesCommentDTO issuesCommentDTO){
        WrapperResult wrapperResult = issuesCommentBussiness.createComment(issuesCommentDTO);
        return ResponseEntity.ok(wrapperResult);
    }
}
