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


import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.web.v2.v1.model.JsOtherProduce;
import com.ruoyi.web.v2.v1.service.IJsOtherProduceService;
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-26
 */
@RestController
@RequestMapping("/js-other-produce")
@Api("2.0其他产品记录")
public class JsOtherProduceController {

    @Autowired
    private IJsOtherProduceService otherProduceService;

    @ApiOperation("其他产品记录添加")
    @PostMapping("/add")
    public AjaxResult add(@RequestBody JsOtherProduce otherProduce) {
        return otherProduceService.add(otherProduce);
    }

    @ApiOperation("其他产品记录修改")
    @PostMapping("/edit")
    public AjaxResult edit(@RequestBody JsOtherProduce otherProduce) {
        return otherProduceService.edit(otherProduce);
    }

    @ApiOperation("其他产品记录删除")
    @PostMapping("/delete")
    public AjaxResult delete(@RequestBody Map<String, String> paramsMap) {
        String ids = paramsMap.get("ids");
        return otherProduceService.delete(ids);
    }

    @ApiOperation("其他产品记录列表")
    @PostMapping("/list")
    public AjaxResult listAll() {
        return otherProduceService.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 = "produceName", required = false) String produceName
            , @RequestParam(value = "animalType", required = false) String animalType
    ) {
        return otherProduceService.page(pageNum, pageSize, startTime, endTime,produceName,animalType);
    }

    @ApiOperation("其他产品记录详情")
    @PostMapping("/listById")
    public AjaxResult listById(@RequestBody Map<String, String> paramsMap) {
        String id = paramsMap.get("id");
        return success(otherProduceService.getById(id));
    }

}
