package com.zhyc.module.produce.breed.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.zhyc.module.produce.breed.domain.ScBreedPlan;
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.produce.breed.service.IScBreedPlanService;
import com.zhyc.common.utils.poi.ExcelUtil;
import com.zhyc.common.core.page.TableDataInfo;

/**
 * 配种计划Controller
 * 
 * @author ruoyi
 * @date 2025-07-16
 */
@RestController
@RequestMapping("/mating_plan/mating_plan")
public class ScBreedPlanController extends BaseController
{
    @Autowired
    private IScBreedPlanService scBreedPlanService;

    /**
     * 查询配种计划列表
     */
    @PreAuthorize("@ss.hasPermi('mating_plan:mating_plan:list')")
    @GetMapping("/list")
    public TableDataInfo list(ScBreedPlan scBreedPlan)
    {
        startPage();
        List<ScBreedPlan> list = scBreedPlanService.selectScBreedPlanList(scBreedPlan);
        return getDataTable(list);
    }

    /**
     * 导出配种计划列表
     */
    @PreAuthorize("@ss.hasPermi('mating_plan:mating_plan:export')")
    @Log(title = "配种计划", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ScBreedPlan scBreedPlan)
    {
        List<ScBreedPlan> list = scBreedPlanService.selectScBreedPlanList(scBreedPlan);
        ExcelUtil<ScBreedPlan> util = new ExcelUtil<ScBreedPlan>(ScBreedPlan.class);
        util.exportExcel(response, list, "配种计划数据");
    }

    /**
     * 获取配种计划详细信息
     */
    @PreAuthorize("@ss.hasPermi('mating_plan:mating_plan:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(scBreedPlanService.selectScBreedPlanById(id));
    }


    /**
     * 新增配种计划
     */
    @PreAuthorize("@ss.hasPermi('mating_plan:mating_plan:add')")
    @Log(title = "配种计划", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ScBreedPlan scBreedPlan)
    {
        return toAjax(scBreedPlanService.insertScBreedPlan(scBreedPlan));
    }

    /**
     * 修改配种计划
     */
    @PreAuthorize("@ss.hasPermi('mating_plan:mating_plan:edit')")
    @Log(title = "配种计划", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ScBreedPlan scBreedPlan)
    {
        return toAjax(scBreedPlanService.updateScBreedPlan(scBreedPlan));
    }

    /**
     * 删除配种计划
     */
    @PreAuthorize("@ss.hasPermi('mating_plan:mating_plan:remove')")
    @Log(title = "配种计划", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(scBreedPlanService.deleteScBreedPlanByIds(ids));
    }
}
