package cc.iotkit.manager.controller;

import cc.iotkit.common.api.PageRequest;
import cc.iotkit.common.api.Paging;
import cc.iotkit.common.api.Request;
import cc.iotkit.common.api.Response;
import cc.iotkit.manager.config.BeanUtils;
import cc.iotkit.manager.dto.vo.FeedBackEvaluation.FeedBackEvaluationPageReqVO;
import cc.iotkit.manager.dto.vo.FeedBackEvaluation.FeedBackEvaluationRespVO;
import cc.iotkit.manager.dto.vo.FeedBackEvaluation.FeedBackEvaluationSaveReqVO;
import cc.iotkit.manager.dto.vo.FeedBackEvaluation.FeedBackEvaluationVO;
import cc.iotkit.manager.dto.vo.category.vo.DIccidRecordListSaveReqVO;
import cc.iotkit.manager.dto.vo.category.vo.DIccidRecordPageReqVO;
import cc.iotkit.manager.dto.vo.category.vo.DIccidRecordRespVO;
import cc.iotkit.manager.dto.vo.category.vo.DIccidRecordSaveReqVO;
import cc.iotkit.manager.service.DIccidRecordService;
import cc.iotkit.manager.service.FeedBackEvaluationService;
import cc.iotkit.model.FeedBackEvaluation.FeedBackEvaluationDO;
import cc.iotkit.model.iccid.DIccidRecordDO;
import cn.hutool.db.PageResult;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.hibernate.annotations.Parameter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;
import java.util.List;

import static cc.iotkit.common.api.Response.success;

@Api(tags = {"反馈意见"})
@Slf4j
@RestController
@RequestMapping("/dFeedbackEvaluation")
public class FeedBackEvaluationController {


    @Autowired
    private FeedBackEvaluationService feedBackEvaluationService;

  @PostMapping("/add")
  //@Operation(summary = "创建意见反馈评价")
  //@PreAuthorize("@ss.hasPermission('installEqu:feed-back-evaluation:create')")
  public Long createFeedBackEvaluation(@Valid @RequestBody Request<FeedBackEvaluationSaveReqVO> createReqVO) {
    return feedBackEvaluationService.createFeedBackEvaluation(createReqVO.getData());
  }

  @PostMapping("/edit")
  //@Operation(summary = "更新意见反馈评价")
 // @PreAuthorize("@ss.hasPermission('installEqu:feed-back-evaluation:update')")
  public Boolean updateFeedBackEvaluation(@Valid @RequestBody Request<FeedBackEvaluationSaveReqVO> updateReqVO) {
    feedBackEvaluationService.updateFeedBackEvaluation(updateReqVO.getData());
    return true;
  }

  @PostMapping("/delete")
  //@Operation(summary = "删除意见反馈评价")
  //@Parameter(name = "id", description = "编号", required = true)
  //@PreAuthorize("@ss.hasPermission('installEqu:feed-back-evaluation:delete')")
  public boolean deleteFeedBackEvaluation(@Validated @RequestBody Request<Long> request) {
    feedBackEvaluationService.deleteFeedBackEvaluation(request.getData());
    return true;
  }

  @PostMapping("/getDetail")
  //@Operation(summary = "获得意见反馈评价")
  //@Parameter(name = "id", description = "编号", required = true, example = "1024")
  //@PreAuthorize("@ss.hasPermission('installEqu:feed-back-evaluation:query')")
  public FeedBackEvaluationDO getFeedBackEvaluation(@Validated @RequestBody Request<Long> request) {
    FeedBackEvaluationDO feedBackEvaluation = feedBackEvaluationService.getFeedBackEvaluation(request.getData());
    return feedBackEvaluation;
  }

  @PostMapping("/list")
  //@Operation(summary = "获得意见反馈评价分页")
  //@PreAuthorize("@ss.hasPermission('installEqu:feed-back-evaluation:query')")
  public Paging<FeedBackEvaluationVO> getFeedBackEvaluationPage(@RequestBody @Validated PageRequest<FeedBackEvaluationPageReqVO> pageReqVO) {
    Paging<FeedBackEvaluationVO> pageResult = feedBackEvaluationService.getFeedBackEvaluationPage(pageReqVO);
    return pageResult;
  }

 /* @GetMapping("/export-excel")
  @Operation(summary = "导出意见反馈评价 Excel")
  @PreAuthorize("@ss.hasPermission('installEqu:feed-back-evaluation:export')")
  @ApiAccessLog(operateType = EXPORT)
  public void exportFeedBdackEvaluationExcel(@Valid FeedBackEvaluationPageReqVO pageReqVO,
                                            HttpServletResponse response) throws IOException {
    pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
    List<TbFeedBackEvaluation> list = feedBackEvaluationService.getFeedBackEvaluationPage(pageReqVO).getList();
    // 导出 Excel
    ExcelUtils.write(response, "意见反馈评价.xls", "数据", FeedBackEvaluationRespVO.class,
            BeanUtils.toBean(list, FeedBackEvaluationRespVO.class));
  }*/



}
