package com.jiayue.ipfcst.controller;

import com.jiayue.ipfcst.common.core.exception.BusinessException;
import com.jiayue.ipfcst.common.core.web.vo.ResponseVO;
import com.jiayue.ipfcst.common.data.entity.CustomReportForm;
import com.jiayue.ipfcst.common.data.entity.EquipmentAttribute;
import com.jiayue.ipfcst.service.CustomReportFormService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("customReportForm")
public class CustomReportFormController {
  @Autowired
  private CustomReportFormService customReportFormService;

  @GetMapping("/findAll")
  public ResponseVO findByTimingOrRealTime(){
    List<CustomReportForm> customReportForms = customReportFormService.findAll();
    return ResponseVO.success(customReportForms);
  }

  @GetMapping("/findEqOptions")
  public ResponseVO findEqOptions() throws BusinessException {
    return ResponseVO.success(customReportFormService.findEqOptions());
  }


  @PostMapping("/save")
  public ResponseVO save(@RequestBody CustomReportForm customReportForm) {
    customReportFormService.save(customReportForm);
    return ResponseVO.success();
  }


  @GetMapping("/findEquipmentAttributeByEqType")
  public ResponseVO findEquipmentAttributeByEqType() {
    List<EquipmentAttribute> equipmentAttributes = customReportFormService.findEquipmentAttributeByEqType();
    return ResponseVO.success(equipmentAttributes);
  }

  @DeleteMapping("/{id}")
  public ResponseVO delete(@PathVariable Integer id){
    customReportFormService.deleteById(id);
    return ResponseVO.success();
  }


}
