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.AfterAnalysisResult;
import com.phm.manage.service.IAfterAnalysisResultService;
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/afterAnalysisResult")
public class AfterAnalysisResultController extends BaseController {
    @Autowired
    private IAfterAnalysisResultService afterAnalysisResultService;

    /**
     * 查询维修测试控制解析后数据列表
     */
    @PreAuthorize("@ss.hasPermi('manage:afterAnalysisResult:list')")
    @GetMapping("/list")
    public TableDataInfo list(AfterAnalysisResult afterAnalysisResult) {
        startPage();
        List<AfterAnalysisResult> list = afterAnalysisResultService.selectAfterAnalysisResultList(afterAnalysisResult);
        return getDataTable(list);
    }

    /**
     * 导出维修测试控制解析后数据列表
     */
    @PreAuthorize("@ss.hasPermi('manage:afterAnalysisResult:export')")
    @Log(title = "维修测试控制解析后数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AfterAnalysisResult afterAnalysisResult) {
        List<AfterAnalysisResult> list = afterAnalysisResultService.selectAfterAnalysisResultList(afterAnalysisResult);
        ExcelUtil<AfterAnalysisResult> util = new ExcelUtil<AfterAnalysisResult>(AfterAnalysisResult.class);
        util.exportExcel(response, list, "维修测试控制解析后数据数据");
    }

    /**
     * 获取维修测试控制解析后数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:afterAnalysisResult:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(afterAnalysisResultService.selectAfterAnalysisResultById(id));
    }

    /**
     * 新增维修测试控制解析后数据
     */
    @PreAuthorize("@ss.hasPermi('manage:afterAnalysisResult:add')")
    @Log(title = "维修测试控制解析后数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AfterAnalysisResult afterAnalysisResult) {
        return toAjax(afterAnalysisResultService.insertAfterAnalysisResult(afterAnalysisResult));
    }

    /**
     * 修改维修测试控制解析后数据
     */
    @PreAuthorize("@ss.hasPermi('manage:afterAnalysisResult:edit')")
    @Log(title = "维修测试控制解析后数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AfterAnalysisResult afterAnalysisResult) {
        return toAjax(afterAnalysisResultService.updateAfterAnalysisResult(afterAnalysisResult));
    }

    /**
     * 删除维修测试控制解析后数据
     */
    @PreAuthorize("@ss.hasPermi('manage:afterAnalysisResult:remove')")
    @Log(title = "维修测试控制解析后数据", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(afterAnalysisResultService.deleteAfterAnalysisResultByIds(ids));
    }
}
