package com.jiayue.ipfcst.console.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.SubsidiaryEquipmentInfo;
import com.jiayue.ipfcst.console.service.SubsidiaryEquipmentInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 附属设备信息接口
 *
 * @author 修唯
 * @version 3.0
 */
@RestController
@RequestMapping("subsidiaryEquipmentInfo")
@Slf4j
public class SubsidiaryEquipmentInfoController {
  final SubsidiaryEquipmentInfoService subsidiaryEquipmentInfoService;

  @Autowired
  public SubsidiaryEquipmentInfoController(SubsidiaryEquipmentInfoService subsidiaryEquipmentInfoService) {
    this.subsidiaryEquipmentInfoService = subsidiaryEquipmentInfoService;
  }

  /*
  * 查询
  * */
  @GetMapping
  public ResponseVO getALL() {
    return ResponseVO.success(subsidiaryEquipmentInfoService.getAll());
  }

  /*
  * 保存
  * */
  @PostMapping
  public ResponseVO save(@RequestBody SubsidiaryEquipmentInfo subsidiaryEquipmentInfo){
    subsidiaryEquipmentInfoService.save(subsidiaryEquipmentInfo);
    return ResponseVO.success(1);
  }

  /*
  * 更新
  * */
  @PutMapping
  public ResponseVO update(@RequestBody SubsidiaryEquipmentInfo subsidiaryEquipmentInfo){
    subsidiaryEquipmentInfoService.save(subsidiaryEquipmentInfo);
    return ResponseVO.success(1);
  }

  /*
  * 删除
  * */
  @DeleteMapping("/{id}")
  public ResponseVO delete(@PathVariable String id) throws BusinessException {
    subsidiaryEquipmentInfoService.delete(Integer.parseInt(id));
    return ResponseVO.success(1);
  }
}
