package com.zhyc.module.base.controller;

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

import com.zhyc.module.base.service.IBasSheepService;
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.base.domain.BasSheepType;
import com.zhyc.module.base.service.IBasSheepTypeService;
import com.zhyc.common.utils.poi.ExcelUtil;
import com.zhyc.common.core.page.TableDataInfo;

/**
 * 羊只类型Controller
 * 
 * @author ruoyi
 * @date 2025-07-22
 */
@RestController
@RequestMapping("/base/base")
public class BasSheepTypeController extends BaseController
{
    @Autowired
    private IBasSheepTypeService basSheepTypeService;

    @Autowired
    private IBasSheepService basSheepService;
    /**
     * 查询羊只类型列表
     */
//    @PreAuthorize("@ss.hasPermi('base:base:list')")
    @GetMapping("/list")
    public TableDataInfo list(BasSheepType basSheepType)
    {
        startPage();
        List<BasSheepType> list = basSheepTypeService.selectBasSheepTypeList(basSheepType);
        return getDataTable(list);
    }

    /**
     * 导出羊只类型列表
     */
//    @PreAuthorize("@ss.hasPermi('base:base:export')")
    @Log(title = "羊只类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BasSheepType basSheepType)
    {
        List<BasSheepType> list = basSheepTypeService.selectBasSheepTypeList(basSheepType);
        ExcelUtil<BasSheepType> util = new ExcelUtil<BasSheepType>(BasSheepType.class);
        util.exportExcel(response, list, "羊只类型数据");
    }

    /**
     * 获取羊只类型详细信息
     */
//    @PreAuthorize("@ss.hasPermi('base:base:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(basSheepTypeService.selectBasSheepTypeById(id));
    }

    /**
     * 新增羊只类型
     */
//    @PreAuthorize("@ss.hasPermi('base:base:add')")
    @Log(title = "羊只类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BasSheepType basSheepType)
    {
        return toAjax(basSheepTypeService.insertBasSheepType(basSheepType));
    }

    /**
     * 修改羊只类型
     */
//    @PreAuthorize("@ss.hasPermi('base:base:edit')")
    @Log(title = "羊只类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BasSheepType basSheepType)
    {
        return toAjax(basSheepTypeService.updateBasSheepType(basSheepType));
    }

    /**
     * 删除羊只类型
     */
//    @PreAuthorize("@ss.hasPermi('base:base:remove')")
    @Log(title = "羊只类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(basSheepTypeService.deleteBasSheepTypeByIds(ids));
    }


}
