package com.fjhx.controller.quality;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjhx.base.Condition;
import com.fjhx.entity.quality.QualityTestingDetails;
import com.fjhx.service.quality.QualityTestingDetailsService;
import com.fjhx.service.quality.QualityTestingService;
import org.springblade.core.tool.api.R;
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;

import java.util.Map;

/**
 * <p>
 * 质检 前端控制器
 * </p>
 *
 * @author ${author}
 * @since 2022-09-26
 */
@RestController
@RequestMapping("/qualityTesting")
public class QualityTestingController {

    @Autowired
    private QualityTestingService qualityTestingService;

    @Autowired
    private QualityTestingDetailsService qualityTestingDetailsService;

    @PostMapping("/page")
    public R page(@RequestBody Condition condition) {
        Page<Map<String, Object>> result = qualityTestingService.getPage(condition);
        return R.success(result);
    }

    @PostMapping("/details")
    public R details(@RequestBody Condition condition) {
        Map<String, Object> result = qualityTestingService.details(condition);
        return R.success(result);
    }

    /**
     * 提交质检记录
     */
    @PostMapping("/submit")
    public R submit(@RequestBody Condition condition) {
        qualityTestingService.submit(condition);
        return R.success();
    }

    /**
     * 质检记录统计
     */
    @PostMapping("/recordStatistics")
    public R recordStatistics(@RequestBody Condition condition) {
        Map<String, Object> result = qualityTestingService.recordStatistics(condition);
        return R.success(result);
    }

    /**
     * 质检记录分页
     */
    @PostMapping("/recordPage")
    public R recordPage(@RequestBody Condition condition) {
        Page<Map<String, Object>> result = qualityTestingService.recordPage(condition);
        return R.success(result);
    }

    /**
     * 质检记录明细统计
     */
    @PostMapping("/recordDetailStatistics")
    public R recordDetailStatistics(@RequestBody Condition condition) {
        Map<String, Object> result = qualityTestingDetailsService.recordDetailStatistics(condition);
        return R.success(result);
    }

    /**
     * 质检记录明细分页
     */
    @PostMapping("/recordDetailPage")
    public R recordDetailPage(@RequestBody Condition condition) {
        Page<QualityTestingDetails> result = qualityTestingDetailsService.recordDetailPage(condition);
        return R.success(result);
    }

}

