package com.goldenwater.web.controller.pms;

import com.goldenwater.slgc.entity.pms.PmsReport;
import com.goldenwater.slgc.service.pms.IPmsReportService;
import com.goldenwater.common.core.controller.BaseController;
import com.goldenwater.common.core.domain.AjaxResult;
import com.goldenwater.common.core.page.TableDataInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.goldenwater.common.annotation.Log;
import com.goldenwater.common.enums.BusinessType;
import org.springframework.validation.annotation.Validated;

import java.util.List;

@RestController
@Validated
@RequestMapping("/pms/report")
public class PmsReportController extends BaseController {
    @Autowired
    private IPmsReportService pmsReportService;

    /**
     * 查询报告列表
     */
    @GetMapping("/list")
    public TableDataInfo list(PmsReport report) {
        startPage();
        List<PmsReport> list = pmsReportService.selectList(report);
        return getDataTable(list);
    }

    /**
     * 获取报告详细信息
     */
    @GetMapping("/{id}")
    public AjaxResult getInfo(@PathVariable Long id) {
        return success(pmsReportService.selectById(id));
    }

    /**
     * 新增报告
     */
    @Log(title = "报表管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PmsReport report) {
        return toAjax(pmsReportService.insert(report));
    }

    /**
     * 修改报告
     */
    @Log(title = "报表管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PmsReport report) {
        return toAjax(pmsReportService.update(report));
    }

    /**
     * 删除报告
     */
    @Log(title = "报表管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(pmsReportService.deleteByIds(ids));
    }
}
