package com.fjhx.supplier.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjhx.entity.supplier.SupplierProblem;
import com.fjhx.params.supplier.SupplierProblemVo;
import com.fjhx.supplier.service.SupplierProblemService;
import io.swagger.models.auth.In;
import org.springblade.core.tool.api.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 * 供应商面料问题反馈表 前端控制器
 * </p>
 *
 * @author ${author}
 * @since 2022-07-12
 */
@RestController
@RequestMapping("/supplierProblem")
public class SupplierProblemController {

    @Autowired
    private SupplierProblemService supplierProblemService;

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

    /**
     * 添加
     * @param supplierProblemVo
     * @return
     */
    @PostMapping("/add")
    public R add(@RequestBody SupplierProblemVo supplierProblemVo){
        supplierProblemService.add(supplierProblemVo);
        return R.success();
    }

    /**
     * 修改
     * @param supplierProblemVo
     * @return
     */
    @PostMapping("/edit")
    public R edit(@RequestBody SupplierProblemVo supplierProblemVo){
        supplierProblemService.edit(supplierProblemVo);
        return R.success();
    }

    /**
     * 删除
     * @param supplierProblemVo
     * @return
     */
    @PostMapping("/delete")
    public R delete(@RequestBody SupplierProblemVo supplierProblemVo){
        supplierProblemService.delete(supplierProblemVo);
        return R.success();
    }

    /**
     * 详情
     * @param id
     * @return
     */
    @GetMapping("/detail")
    public R detail(@RequestParam("id")String id){
        SupplierProblem data = supplierProblemService.detail(id);
        return R.success(data);
    }

    /**
     * 面料问题反馈统计
     * @param id
     * @return
     */
    @GetMapping("/statisticsProblem")
    public R statisticsProblem(@RequestParam("id")String id){
        Map<String, Integer> map = supplierProblemService.statisticsProblem(id);
        return R.success(map);
    }
    /**
     * 面料问题反馈统计条数
     * @param id
     * @return
     */
    @GetMapping("/statisticsProblemCount")
    public R statisticsProblemCount(@RequestParam("id")String id){
        Long count = supplierProblemService.statisticsProblemCount(id);
        return R.success(count);
    }

}

