package com.fjhx.mes.controller.report;

import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjhx.mes.entity.report.dto.ReportLossesDetailsDto;
import com.fjhx.mes.entity.report.dto.ReportLossesDetailsSelectDto;
import com.fjhx.mes.entity.report.vo.ReportLossesDetailsVo;
import com.fjhx.mes.service.report.ReportLossesDetailsService;
import com.ruoyi.common.core.domain.BaseSelectDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * <p>
 * 报损管理 前端控制器
 * </p>
 *
 * @author
 * @since 2024-01-26
 */
@RestController
@RequestMapping("/reportLossesDetails")
public class ReportLossesDetailsController {

    @Autowired
    private ReportLossesDetailsService reportLossesDetailsService;

    /**
     * 报损管理分页
     */
    @PostMapping("/page")
    public Page<ReportLossesDetailsVo> page(@RequestBody ReportLossesDetailsSelectDto dto) {
        return reportLossesDetailsService.getPage(dto);
    }

    /**
     * 报损管理明细
     */
    @PostMapping("/detail")
    public ReportLossesDetailsVo detail(@RequestBody BaseSelectDto dto) {
        return reportLossesDetailsService.detail(dto.getId());
    }

    /**
     * 报损管理新增
     */
    @PostMapping("/add")
    public void add(@RequestBody ReportLossesDetailsDto reportLossesDetailsDto) {
        reportLossesDetailsService.add(reportLossesDetailsDto);
    }

    /**
     * 报损管理编辑
     */
    @PostMapping("/edit")
    public void edit(@RequestBody ReportLossesDetailsDto reportLossesDetailsDto) {
        reportLossesDetailsService.edit(reportLossesDetailsDto);
    }

    /**
     * 报损管理删除
     */
    @PostMapping("/delete")
    public void delete(@RequestBody BaseSelectDto dto) {
        reportLossesDetailsService.delete(dto.getId());
    }

    /**
     * 近n天报损统计
     */
    @PostMapping("/lossesStatistics")
    public JSONObject lossesStatistics(@RequestBody ReportLossesDetailsSelectDto dto) {
        return reportLossesDetailsService.lossesStatistics(dto);
    }

}
