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


import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.web.v2.v1.model.JsDivideCircle;
import com.ruoyi.web.v2.v1.service.IJsDivideCircleService;
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-22
 */
@RestController
@RequestMapping("/js-divide-circle")
@Api("2.0分圈登记")
public class JsDivideCircleController {

    @Autowired
    private IJsDivideCircleService divideCircleService;

    @ApiOperation("分圈登记添加")
    @PostMapping("/add")
    public AjaxResult add(@RequestBody JsDivideCircle divideCircle) {
        return divideCircleService.add(divideCircle);
    }

    @ApiOperation("分圈登记修改")
    @PostMapping("/edit")
    public AjaxResult edit(@RequestBody JsDivideCircle divideCircle) {
        return divideCircleService.edit(divideCircle);
    }

    @ApiOperation("分圈登记删除")
    @PostMapping("/delete")
    public AjaxResult delete(@RequestBody Map<String, String> paramsMap) {
        String ids = paramsMap.get("ids");

        return divideCircleService.delete(ids);
    }

    @ApiOperation("分圈登记列表")
    @PostMapping("/list")
    public AjaxResult listAll(@RequestBody Map<String, String> paramsMap) {
        String startTime = paramsMap.get("startTime");
        return divideCircleService.listAll(startTime);
    }

    @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 = "pigpenName", required = false) String pigpenName) {

        return divideCircleService.page(pageNum, pageSize, startTime, endTime, pigpenName);
    }

    @ApiOperation("分圈登记详情")
    @PostMapping("/listById")
    public AjaxResult listById(@RequestBody Map<String, String> paramsMap) {
        String id = paramsMap.get("id");
        return success(divideCircleService.getById(id));
    }

    @ApiOperation("存栏数据核查")
    @GetMapping("/review")
    public AjaxResult review() {
        return success(divideCircleService.review());
    }

    @ApiOperation("查询分圈后有效批次号列表")
    @GetMapping("/listSeries")
    public AjaxResult series() {
        return success(divideCircleService.listSeriesNo());
    }

}
