package com.ruoyi.web.controller.app; import java.util.List; import javax.servlet.http.HttpServletResponse; import com.ruoyi.app.domain.PigCategory; 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.app.domain.Pigpen; import com.ruoyi.app.service.IPigpenService; import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.core.page.TableDataInfo; /** * 待宰圈Controller * * @author coede * @date 2025-03-19 */ @RestController @RequestMapping("/app/pigpen") public class PigpenController extends BaseController { @Autowired private IPigpenService pigpenService; /** * 查询待宰圈列表 */ @PreAuthorize("@ss.hasPermi('app:pigpen:list')") @GetMapping("/list") public TableDataInfo list(Pigpen pigpen) { startPage(); List list = pigpenService.selectPigpenList(pigpen); return getDataTable(list); } /** * 导出待宰圈列表 */ @PreAuthorize("@ss.hasPermi('app:pigpen:export')") @Log(title = "待宰圈", businessType = BusinessType.EXPORT) @PostMapping("/export") public void export(HttpServletResponse response, Pigpen pigpen) { List list = pigpenService.selectPigpenList(pigpen); ExcelUtil util = new ExcelUtil(Pigpen.class); util.exportExcel(response, list, "待宰圈数据"); } /** * 获取待宰圈详细信息 */ @PreAuthorize("@ss.hasPermi('app:pigpen:query')") @GetMapping(value = "/{id}") public AjaxResult getInfo(@PathVariable("id") Long id) { return success(pigpenService.selectPigpenById(id)); } /** * 新增待宰圈 */ @PreAuthorize("@ss.hasPermi('app:pigpen:add')") @Log(title = "待宰圈", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@Validated @RequestBody Pigpen pigpen) { if (!pigpenService.checkPigpenNameUnique(pigpen)) { return error("新增待宰圈'" + pigpen.getPigpenName() + "'失败,列表中存在重复的待宰圈号"); } pigpen.setCreateBy(getUsername()); return toAjax(pigpenService.insertPigpen(pigpen)); } /** * 修改待宰圈 */ @PreAuthorize("@ss.hasPermi('app:pigpen:edit')") @Log(title = "待宰圈", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@Validated @RequestBody Pigpen pigpen) { if (!pigpenService.checkPigpenNameUnique(pigpen)) { return error("修改待宰圈'" + pigpen.getPigpenName() + "'失败,列表中存在重复的待宰圈号"); } pigpen.setUpdateBy(getUsername()); return toAjax(pigpenService.updatePigpen(pigpen)); } /** * 删除待宰圈 */ @PreAuthorize("@ss.hasPermi('app:pigpen:remove')") @Log(title = "待宰圈", businessType = BusinessType.DELETE) @DeleteMapping("/{ids}") public AjaxResult remove(@PathVariable Long[] ids) { return toAjax(pigpenService.deletePigpenByIds(ids)); } /** * 获取待宰圈选择框列表 */ @GetMapping("/optionselect") public AjaxResult optionselect() { Pigpen pigpen = new Pigpen(); List list = pigpenService.selectPigpenList(pigpen); return success(list); } }