package com.phm.manage.controller;

import com.phm.common.annotation.Log;
import com.phm.common.core.controller.BaseController;
import com.phm.common.core.domain.AjaxResult;
import com.phm.common.core.page.TableDataInfo;
import com.phm.common.enums.BusinessType;
import com.phm.common.utils.poi.ExcelUtil;
import com.phm.manage.domain.GroundDiagnosisModel;
import com.phm.manage.service.IGroundDiagnosisModelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 地面诊断模型信息Controller
 *
 * @author phm
 * @date 2023-08-22
 */
@RestController
@RequestMapping("/manage/groundDiagnosisModel")
public class GroundDiagnosisModelController extends BaseController {
    @Autowired
    private IGroundDiagnosisModelService groundDiagnosisModelService;

    /**
     * 查询地面诊断模型信息列表
     */
    @PreAuthorize("@ss.hasPermi('manage:groundDiagnosisModel:list')")
    @GetMapping("/list")
    public TableDataInfo list(GroundDiagnosisModel groundDiagnosisModel) {
        startPage();
        List<GroundDiagnosisModel> list = groundDiagnosisModelService.selectGroundDiagnosisModelList(groundDiagnosisModel);
        return getDataTable(list);
    }

    /**
     * 导出地面诊断模型信息列表
     */
    @PreAuthorize("@ss.hasPermi('manage:groundDiagnosisModel:export')")
    @Log(title = "地面诊断模型信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GroundDiagnosisModel groundDiagnosisModel) {
        List<GroundDiagnosisModel> list = groundDiagnosisModelService.selectGroundDiagnosisModelList(groundDiagnosisModel);
        ExcelUtil<GroundDiagnosisModel> util = new ExcelUtil<GroundDiagnosisModel>(GroundDiagnosisModel.class);
        util.exportExcel(response, list, "地面诊断模型信息数据");
    }

    /**
     * 获取地面诊断模型信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:groundDiagnosisModel:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(groundDiagnosisModelService.selectGroundDiagnosisModelById(id));
    }

    /**
     * 新增地面诊断模型信息
     */
    @PreAuthorize("@ss.hasPermi('manage:groundDiagnosisModel:add')")
    @Log(title = "地面诊断模型信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GroundDiagnosisModel groundDiagnosisModel) {
        return toAjax(groundDiagnosisModelService.insertGroundDiagnosisModel(groundDiagnosisModel));
    }

    /**
     * 修改地面诊断模型信息
     */
    @PreAuthorize("@ss.hasPermi('manage:groundDiagnosisModel:edit')")
    @Log(title = "地面诊断模型信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GroundDiagnosisModel groundDiagnosisModel) {
        return toAjax(groundDiagnosisModelService.updateGroundDiagnosisModel(groundDiagnosisModel));
    }

    /**
     * 删除地面诊断模型信息
     */
    @PreAuthorize("@ss.hasPermi('manage:groundDiagnosisModel:remove')")
    @Log(title = "地面诊断模型信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(groundDiagnosisModelService.deleteGroundDiagnosisModelByIds(ids));
    }
}
