package com.bonus.core.allocation.advise.controller;

import com.bonus.common.core.domain.R;
import com.bonus.core.allocation.advise.dto.EvaluateAddDTO;
import com.bonus.core.allocation.advise.model.AllocPageDecorationModel;
import com.bonus.core.allocation.advise.service.AllocPageDecorationService;
import com.bonus.core.allocation.advise.service.BasicsCanteenEvaluateService;
import com.bonus.core.allocation.constants.CanteenConstants;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.io.IOException;
import java.util.Collections;
import java.util.List;

@RestController
@RequestMapping({"/api/v1/canteen/evaluate"})
@Api("食堂档口评价控制")
public class BasicsCanteenEvaluateController {
   private static final Logger log = LoggerFactory.getLogger(BasicsCanteenEvaluateController.class);
   @Lazy
   @Autowired
   private BasicsCanteenEvaluateService basicsCanteenEvaluateService;
   @Autowired
   @Lazy
   private AllocPageDecorationService allocPageDecorationService;
//   @Autowired
//   @Lazy
//   protected ExportApi exportApi;

//   @ApiOperation("分页查询评价信息")
//   @PostMapping({"/page"})
//   @RequiresAuthentication
//   public PageVO<EvaluateQueryVO> queryEvaluateByPage(@RequestBody @Valid LeRequest<EvaluateQueryDTO> request) {
//      return this.basicsCanteenEvaluateService.queryEvaluateByPage((EvaluateQueryDTO)request.getContent());
//   }
//
//   @ApiOperation("导出查询评价信息")
//   @PostMapping({"/export/page"})
//   public void exportEvaluateByPage(@RequestBody @Valid LeRequest<EvaluateQueryDTO> request, HttpServletResponse response) throws IOException {
//      ((EvaluateQueryDTO)request.getContent()).setSize(-1L);
//      PageVO<EvaluateQueryVO> evaluateQueryVOPage = this.basicsCanteenEvaluateService.queryEvaluateByPage((EvaluateQueryDTO)request.getContent());
//      EasyExcelUtil.writeExcelByDownLoad(response, "食堂评价", EvaluateQueryVO.class, "详情", evaluateQueryVOPage.getRecords(), Collections.singletonList(new CustomLocalDateConverter()));
//   }
//
//   @ApiOperation("查询单条食堂评价详情")
//   @PostMapping({"/get-evaluate-detail"})
//   public CanteenEvaluateDetailModel getEvaluateDetail(@RequestBody LeRequest<Long> request) {
//      return this.basicsCanteenEvaluateService.getEvaluateDetail((Long)request.getContent());
//   }
//
//   @ApiOperation("分页查询食堂评价统计")
//   @PostMapping({"/page-evaluate-count"})
//   public CanteenEvaluateCountModel pageEvaluateCount(@RequestBody LeRequest<EvaluateQueryDTO> request) {
//      return this.basicsCanteenEvaluateService.pageEvaluateCount((EvaluateQueryDTO)request.getContent());
//   }

   @ApiOperation("新增食堂评价")
   @PostMapping({"/addEvaluate"})
//   @RequiresGuest
   public R<Object> addEvaluate(@RequestBody @Valid EvaluateAddDTO request) {
      this.basicsCanteenEvaluateService.addEvaluate(request);
      return R.ok();
   }

   @ApiOperation("查询食堂评价页面装修")
   @PostMapping({"/query-page-decoration"})
   public List<AllocPageDecorationModel> queryPageDecoration() {
      return this.allocPageDecorationService.queryPageDecoration(CanteenConstants.PAGE_CANTEEN_EVALUATE);
   }

//   @ApiOperation("查询食堂评价页面装修初版数据")
//   @PostMapping({"/query-init-page-first"})
//   public List<AllocPageDecorationModel> queryFirstPageDecoration(@RequestBody LeRequest<Void> request) {
//      return this.allocPageDecorationService.queryFirstPageDecoration(CanteenConstants.PAGE_CANTEEN_EVALUATE);
//   }
//
//   @ApiOperation("保存食堂评价页面装修")
//   @PostMapping({"/save-page-decoration"})
//   public void savePageDecoration(@RequestBody @Valid LeRequest<List<AllocPageDecorationModel>> request) {
//      this.allocPageDecorationService.savePageDecoration((List)request.getContent());
//   }
//
//   @ApiOperation("食堂评价异步导出")
//   @PostMapping({"/export/async"})
//   public LeResponse<Object> backStaffEmployeeExport(@RequestBody @Valid LeRequest<EvaluateQueryDTO> request) {
//      PageDTO page = (PageDTO)request.getContent();
//      EvaluateQueryDTO evaluateQueryDTO = (EvaluateQueryDTO)request.getContent();
//      this.exportApi.startExcelExportTaskByPage("评价管理", "食堂评价", EvaluateQueryVO.class, evaluateQueryDTO.getExportCols(), page, (Object)null, () -> {
//         return this.basicsCanteenEvaluateService.queryEvaluateByPage((EvaluateQueryDTO)request.getContent());
//      });
//      return LeResponse.succ();
//   }
}
