package com.ruoyi.web.v2.v1.controller;


import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.web.v2.v1.model.JsProduceCheck;
import com.ruoyi.web.v2.v1.service.IJsProduceCheckService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

import static com.ruoyi.common.core.domain.AjaxResult.success;

/**
 * <p>
 * v2.0生产检验检疫登记 前端控制器
 * </p>
 *
 * @author author
 * @since 2025-05-23
 */
@RestController
@RequestMapping("/js-produce-check")
@Api("2.0生产检验检疫登记")
public class JsProduceCheckController {

    @Autowired
    private IJsProduceCheckService produceCheckService;


    @ApiOperation("生产检验检疫登记添加")
    @PostMapping("/add")
    public AjaxResult add(@RequestBody JsProduceCheck produceCheck) {
        return produceCheckService.add(produceCheck);
    }

    @ApiOperation("生产检验检疫登记修改")
    @PostMapping("/edit")
    public AjaxResult edit(@RequestBody JsProduceCheck produceCheck) {
        return produceCheckService.edit(produceCheck);
    }

    @ApiOperation("生产检验检疫登记删除")
    @PostMapping("/delete")
    public AjaxResult delete(@RequestBody Map<String, String> paramsMap) {
        String ids = paramsMap.get("ids");
        return produceCheckService.delete(ids);
    }

    @ApiOperation("生产检验检疫登记列表")
    @PostMapping("/list")
    public AjaxResult listAll() {
        return produceCheckService.listAll();
    }

    @ApiOperation("生产检验检疫登记分页")
    @GetMapping("/page")
    public AjaxResult page(@RequestParam("pageNum") Integer pageNum, @RequestParam("pageSize") Integer pageSize
            , @RequestParam(value = "startTime", required = false) String startTime
            , @RequestParam(value = "endTime", required = false) String endTime
            , @RequestParam(value = "animalCertNo", required = false) String animalCertNo
            , @RequestParam(value = "animalType", required = false) String animalType) {

        return produceCheckService.page(pageNum, pageSize, startTime, endTime, animalCertNo,animalType);
    }

    @ApiOperation("生产检验检疫登记详情")
    @PostMapping("/listById")
    public AjaxResult listById(@RequestBody Map<String, String> paramsMap) {
        String id = paramsMap.get("id");
        return success(produceCheckService.getById(id));
    }
}
