package vip.xiaonuo.write.controller;


import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
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 vip.xiaonuo.common.pojo.CommonResult;
import vip.xiaonuo.write.entity.vo.WriteTravelPageVo;
import vip.xiaonuo.write.param.*;
import vip.xiaonuo.write.service.IWriteUnqualifiedService;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 不合格品台账 前端控制器
 * </p>
 *
 * @author author
 * @since 2025-01-02
 */
@RestController
@Api(tags = "不合格品台账")
@ApiSupport(author = "wang", order = 1)
@Validated
public class WriteUnqualifiedController {

    @Autowired
    private IWriteUnqualifiedService unqualifiedService;

    @ApiOperationSupport(order = 1)
    @ApiOperation("不合格品台账添加")
    @PostMapping("/write-unqualified/add")
    public CommonResult add(@RequestBody WriteUnqualifiedParam param) {
        unqualifiedService.add(param);
        return CommonResult.ok();
    }

    @ApiOperationSupport(order = 2)
    @ApiOperation("不合格品台账修改")
    @PostMapping("/write-unqualified/update")
    public CommonResult update(@RequestBody WriteUnqualifiedEditParam editParam) {
        unqualifiedService.update(editParam);
        return CommonResult.ok();
    }

    @ApiOperationSupport(order = 3)
    @ApiOperation("不合格品台账分页")
    @PostMapping("/write-unqualified/page")
    public CommonResult page(@RequestBody WriteUnqualifiedPageParam pageParam) {
        return unqualifiedService.page(pageParam);
    }


    @ApiOperationSupport(order = 4)
    @ApiOperation("不合格品台账删除")
    @PostMapping("/write-unqualified/delete")
    public CommonResult delete(@RequestBody Map<String,String> paramsMap) {
        unqualifiedService.delete(paramsMap);
        return CommonResult.ok();
    }
}
