package com.zhyc.module.dairyProducts.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zhyc.common.annotation.Log;
import com.zhyc.common.core.controller.BaseController;
import com.zhyc.common.core.domain.AjaxResult;
import com.zhyc.common.enums.BusinessType;
import com.zhyc.module.dairyProducts.domain.XzParityCorrection;
import com.zhyc.module.dairyProducts.service.IXzParityCorrectionService;
import com.zhyc.common.utils.poi.ExcelUtil;
import com.zhyc.common.core.page.TableDataInfo;

/**
 * 胎次校正Controller
 *
 * @author ruoyi
 * @date 2025-08-24
 */
@RestController
@RequestMapping("/parityCorrection/parityCorrection")
public class XzParityCorrectionController extends BaseController
{
    @Autowired
    private IXzParityCorrectionService xzParityCorrectionService;

    /**
     * 查询胎次校正列表
     */
    @PreAuthorize("@ss.hasPermi('parityCorrection:parityCorrection:list')")
    @GetMapping("/list")
    public TableDataInfo list(XzParityCorrection xzParityCorrection)
    {
        startPage();
        List<XzParityCorrection> list = xzParityCorrectionService.selectXzParityCorrectionList(xzParityCorrection);
        return getDataTable(list);
    }

    /**
     * 导出胎次校正列表
     */
    @PreAuthorize("@ss.hasPermi('parityCorrection:parityCorrection:export')")
    @Log(title = "胎次校正", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, XzParityCorrection xzParityCorrection)
    {
        List<XzParityCorrection> list = xzParityCorrectionService.selectXzParityCorrectionList(xzParityCorrection);
        ExcelUtil<XzParityCorrection> util = new ExcelUtil<XzParityCorrection>(XzParityCorrection.class);
        util.exportExcel(response, list, "胎次校正数据");
    }

    /**
     * 获取胎次校正详细信息
     */
    @PreAuthorize("@ss.hasPermi('parityCorrection:parityCorrection:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(xzParityCorrectionService.selectXzParityCorrectionById(id));
    }

    /**
     * 新增胎次校正
     */
    @PreAuthorize("@ss.hasPermi('parityCorrection:parityCorrection:add')")
    @Log(title = "胎次校正", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody XzParityCorrection xzParityCorrection)
    {
        return toAjax(xzParityCorrectionService.insertXzParityCorrection(xzParityCorrection));
    }

    /**
     * 修改胎次校正
     */
    @PreAuthorize("@ss.hasPermi('parityCorrection:parityCorrection:edit')")
    @Log(title = "胎次校正", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody XzParityCorrection xzParityCorrection)
    {
        return toAjax(xzParityCorrectionService.updateXzParityCorrection(xzParityCorrection));
    }

    /**
     * 删除胎次校正
     */
    @PreAuthorize("@ss.hasPermi('parityCorrection:parityCorrection:remove')")
    @Log(title = "胎次校正", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(xzParityCorrectionService.deleteXzParityCorrectionByIds(ids));
    }
}
