package com.aucma.report.controller;

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

import com.aucma.common.utils.DateUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.aucma.common.annotation.Log;
import com.aucma.common.core.controller.BaseController;
import com.aucma.common.core.domain.AjaxResult;
import com.aucma.common.enums.BusinessType;
import com.aucma.report.domain.ReportRepairMeasures;
import com.aucma.report.service.IReportRepairMeasuresService;
import com.aucma.common.utils.poi.ExcelUtil;
import com.aucma.common.core.page.TableDataInfo;

/**
 * 返修措施维护Controller
 *
 * @author Yinq
 * @date 2023-11-21
 */
@RestController
@RequestMapping("/report/repairMeasures" )
public class ReportRepairMeasuresController extends BaseController {
    @Autowired
    private IReportRepairMeasuresService reportRepairMeasuresService;

    /**
     * 查询返修措施维护列表
     */
    @PreAuthorize("@ss.hasPermi('report:repairMeasures:list')" )
    @GetMapping("/list" )
    public TableDataInfo list(ReportRepairMeasures reportRepairMeasures) {
        startPage();
        List<ReportRepairMeasures> list = reportRepairMeasuresService.selectReportRepairMeasuresList(reportRepairMeasures);
        return getDataTable(list);
    }

    /**
     * PDA获取返修措施
     * @param reportRepairMeasures
     * @return
     */
    @GetMapping("/getRepairMeasures" )
    public AjaxResult getRepairMeasures(ReportRepairMeasures reportRepairMeasures) {
        List<ReportRepairMeasures> list = reportRepairMeasuresService.selectReportRepairMeasuresList(reportRepairMeasures);
        return success(list);
    }


    /**
     * 导出返修措施维护列表
     */
    @PreAuthorize("@ss.hasPermi('report:repairMeasures:export')" )
    @Log(title = "返修措施维护" , businessType = BusinessType.EXPORT)
    @PostMapping("/export" )
    public void export(HttpServletResponse response, ReportRepairMeasures reportRepairMeasures) {
        List<ReportRepairMeasures> list = reportRepairMeasuresService.selectReportRepairMeasuresList(reportRepairMeasures);
        ExcelUtil<ReportRepairMeasures> util = new ExcelUtil<ReportRepairMeasures>(ReportRepairMeasures. class);
        util.exportExcel(response, list, "返修措施维护数据" );
    }

    /**
     * 获取返修措施维护详细信息
     */
    @PreAuthorize("@ss.hasPermi('report:repairMeasures:query')" )
    @GetMapping(value = "/{objId}" )
    public AjaxResult getInfo(@PathVariable("objId" ) Long objId) {
        return success(reportRepairMeasuresService.selectReportRepairMeasuresByObjId(objId));
    }

    /**
     * 新增返修措施维护
     */
    @PreAuthorize("@ss.hasPermi('report:repairMeasures:add')" )
    @Log(title = "返修措施维护" , businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ReportRepairMeasures reportRepairMeasures) {
        reportRepairMeasures.setCreatedBy(getUsername());
        reportRepairMeasures.setCreatedTime(DateUtils.getNowDate());
        return toAjax(reportRepairMeasuresService.insertReportRepairMeasures(reportRepairMeasures));
    }

    /**
     * 修改返修措施维护
     */
    @PreAuthorize("@ss.hasPermi('report:repairMeasures:edit')" )
    @Log(title = "返修措施维护" , businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ReportRepairMeasures reportRepairMeasures) {
        reportRepairMeasures.setUpdatedBy(getUsername());
        reportRepairMeasures.setUpdatedTime(DateUtils.getNowDate());
        return toAjax(reportRepairMeasuresService.updateReportRepairMeasures(reportRepairMeasures));
    }

    /**
     * 删除返修措施维护
     */
    @PreAuthorize("@ss.hasPermi('report:repairMeasures:remove')" )
    @Log(title = "返修措施维护" , businessType = BusinessType.DELETE)
    @DeleteMapping("/{objIds}" )
    public AjaxResult remove(@PathVariable Long[] objIds) {
        return toAjax(reportRepairMeasuresService.deleteReportRepairMeasuresByObjIds(objIds));
    }
}
