package com.ruoyi.web.v1.controller;

import java.util.List;

import com.ruoyi.web.v1.DTO.PorkOtherProduceDTO;
import com.ruoyi.web.v1.model.request.ReqGetPorkOtherProduce;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
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.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.web.v1.model.PorkOtherProduce;
import com.ruoyi.web.v1.service.IPorkOtherProduceService;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 猪头生产记录Controller
 * 
 * @author ruoyi
 * @date 2025-03-19
 */
@Api("其他生产记录信息管理")
@RestController
@RequestMapping("/app/porkOtherProduce")
public class PorkOtherProduceController extends BaseController
{
    @Autowired
    private IPorkOtherProduceService porkOtherProduceService;

    /**
     * 查询猪头生产记录列表
     */
    @ApiOperation("查询其他生产记录列表")
    // @PreAuthorize("@ss.hasPermi('app:porkOtherProduce:list')")
    @GetMapping("/list")
    public TableDataInfo list(ReqGetPorkOtherProduce porkOtherProduce)
    {
        startPage();
        List<PorkOtherProduceDTO> list = porkOtherProduceService.selectPorkOtherProduceList(porkOtherProduce);
        return getDataTable(list);
    }


    /**
     * 获取猪头生产记录详细信息
     */
    @ApiOperation("获取猪头生产记录详细信息")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(porkOtherProduceService.selectPorkOtherProduceById(id));
    }

    /**
     * 新增猪头生产记录
     */
    @ApiOperation("新增猪头生产记录")
    // @PreAuthorize("@ss.hasPermi('app:porkOtherProduce:add')")
    @Log(title = "其他生产记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@Validated @RequestBody PorkOtherProduce porkOtherProduce)
    {
        porkOtherProduce.setCreateBy(getUsername());
        return toAjax(porkOtherProduceService.insertPorkOtherProduce(porkOtherProduce));
    }

    /**
     * 修改猪头生产记录
     */
    @ApiOperation("修改猪头生产记录")
    // @PreAuthorize("@ss.hasPermi('app:porkOtherProduce:edit')")
    @Log(title = "其他生产记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@Validated @RequestBody PorkOtherProduce porkOtherProduce)
    {
        porkOtherProduce.setUpdateBy(getUsername());
        return toAjax(porkOtherProduceService.updatePorkOtherProduce(porkOtherProduce));
    }

    /**
     * 删除猪头生产记录
     */
    @ApiOperation("删除猪头生产记录")
    // @PreAuthorize("@ss.hasPermi('app:porkOtherProduce:remove')")
    @Log(title = "其他生产记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(porkOtherProduceService.deletePorkOtherProduceByIds(ids));
    }
}
