package com.usky.fire.controller.web;


import com.usky.common.core.bean.ApiResult;
import com.usky.common.log.annotation.Log;
import com.usky.common.log.enums.BusinessType;
import com.usky.fire.service.ReportConfigService;
import com.usky.fire.service.vo.ReportConfigVO;
import com.usky.fire.service.vo.ReportIndexVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


import java.util.List;

/**
 * <p>
 * 报告配置表 前端控制器
 * </p>
 *
 * @author han
 * @since 2023-06-27
 */
@RestController
@RequestMapping("/reportConfig")
public class ReportConfigController {

    @Autowired
    private ReportConfigService reportConfigService;

    /**
     * 报告模型查看查询
     *
     * @return
     */
    @PostMapping("/configInfo")
    public ApiResult<List<ReportConfigVO>> configInfo() {
        return ApiResult.success(reportConfigService.configInfo());
    }

    /**
     * 报告指数-查询
     *
     * @param id   主键ID
     * @return
     */
    @GetMapping("/reportIndexSelect")
    public ApiResult<List<ReportIndexVo>> reportIndexSelect(@RequestParam(value = "id") Integer id) {
        return ApiResult.success(reportConfigService.reportIndexSelect(id));
    }

    /**
     * 报告模型-删除
     *
     * @param id 主键ID
     * @return
     */
    @Log(title = "报告模型-删除", businessType = BusinessType.DELETE)
    @DeleteMapping("/delReportConfig")
    public ApiResult<Void> delReportConfig(@RequestParam(value = "id") Integer id) {
        reportConfigService.delReportConfig(id);
        return ApiResult.success();
    }

    /**
     * 报告模型-新增
     *
     * @param reportIndexVo
     * @return
     */
    @Log(title = "报告模型-新增", businessType = BusinessType.INSERT)
    @PostMapping("/addReportConfig")
    public ApiResult<Void> addReportConfig(@RequestBody ReportIndexVo reportIndexVo) {
        reportConfigService.addReportConfig(reportIndexVo);
        return ApiResult.success();
    }

    /**
     * 报告模型-修改
     *
     * @param reportIndexVo
     * @return
     */
    @Log(title = "报告模型-修改", businessType = BusinessType.UPDATE)
    @PutMapping("/updateReportConfig")
    public ApiResult<Void> updateReportConfig(@RequestBody ReportIndexVo reportIndexVo) {
        reportConfigService.updateReportConfig(reportIndexVo);
        return ApiResult.success();
    }

}

