package com.zhyc.module.frozen.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.frozen.domain.DdFs;
import com.zhyc.module.frozen.service.IDdFsService;
import com.zhyc.common.utils.poi.ExcelUtil;
import com.zhyc.common.core.page.TableDataInfo;

/**
 * 冻精库存Controller
 * 
 * @author ruoyi
 * @date 2025-11-29
 */
@RestController
@RequestMapping("/sperm/sperm")
public class DdFsController extends BaseController
{
    @Autowired
    private IDdFsService ddFsService;

    /**
     * 查询冻精库存列表
     */
    @PreAuthorize("@ss.hasPermi('frozen:sperm:list')")
    @GetMapping("/list")
    public TableDataInfo list(DdFs ddFs)
    {
        startPage();
        List<DdFs> list = ddFsService.selectDdFsList(ddFs);
        return getDataTable(list);
    }

    /**
     * 导出冻精库存列表
     */
    @PreAuthorize("@ss.hasPermi('frozen:sperm:export')")
    @Log(title = "冻精库存", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DdFs ddFs)
    {
        List<DdFs> list = ddFsService.selectDdFsList(ddFs);
        ExcelUtil<DdFs> util = new ExcelUtil<DdFs>(DdFs.class);
        util.exportExcel(response, list, "冻精库存数据");
    }

    /**
     * 获取冻精库存详细信息
     */
    @PreAuthorize("@ss.hasPermi('frozen:sperm:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(ddFsService.selectDdFsById(id));
    }

    /**
     * 新增冻精库存
     */
    @PreAuthorize("@ss.hasPermi('frozen:sperm:add')")
    @Log(title = "冻精库存", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DdFs ddFs)
    {
        return toAjax(ddFsService.insertDdFs(ddFs));
    }

    /**
     * 修改冻精库存
     */
    @PreAuthorize("@ss.hasPermi('frozen:sperm:edit')")
    @Log(title = "冻精库存", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DdFs ddFs)
    {
        return toAjax(ddFsService.updateDdFs(ddFs));
    }

    /**
     * 删除冻精库存
     */
    @PreAuthorize("@ss.hasPermi('frozen:sperm:remove')")
    @Log(title = "冻精库存", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ddFsService.deleteDdFsByIds(ids));
    }

    /**
     * 批量废弃
     */
    @PreAuthorize("@ss.hasPermi('frozen:sperm:discard')")
    @Log(title = "冻精库存", businessType = BusinessType.UPDATE)
    @PutMapping("/discard")
    public AjaxResult discard(@RequestBody List<DdFs> list) {
        return AjaxResult.success(ddFsService.discard(list));
    }
}
