package com.ruoyi.sales.controller; import javax.servlet.http.HttpServletResponse; import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.sales.pojo.SalesLedgerProduct; import com.ruoyi.sales.service.ISalesLedgerProductService; 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.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.framework.aspectj.lang.annotation.Log; import com.ruoyi.framework.aspectj.lang.enums.BusinessType; import com.ruoyi.framework.web.controller.BaseController; import com.ruoyi.framework.web.domain.AjaxResult; import com.ruoyi.framework.web.page.TableDataInfo; import java.util.List; /** * 产品信息Controller * * @author ruoyi * @date 2025-05-08 */ @RestController @RequestMapping("/sales/product") public class SalesLedgerProductController extends BaseController { @Autowired private ISalesLedgerProductService salesLedgerProductService; /** * 查询产品信息列表 */ @GetMapping("/list") public List list(SalesLedgerProduct salesLedgerProduct) { List list = salesLedgerProductService.selectSalesLedgerProductList(salesLedgerProduct); return list; } /** * 导出产品信息列表 */ @Log(title = "产品信息", businessType = BusinessType.EXPORT) @PostMapping("/export") public void export(HttpServletResponse response, SalesLedgerProduct salesLedgerProduct) { List list = salesLedgerProductService.selectSalesLedgerProductList(salesLedgerProduct); ExcelUtil util = new ExcelUtil(SalesLedgerProduct.class); util.exportExcel(response, list, "产品信息数据"); } /** * 获取产品信息详细信息 */ @GetMapping(value = "/{id}") public AjaxResult getInfo(@PathVariable("id") Long id) { return success(salesLedgerProductService.selectSalesLedgerProductById(id)); } /** * 新增修改产品信息 */ @Log(title = "产品信息", businessType = BusinessType.INSERT) @PostMapping ("/addOrUpdateSalesLedgerProduct") public AjaxResult add(@RequestBody SalesLedgerProduct salesLedgerProduct) { return toAjax(salesLedgerProductService.addOrUpdateSalesLedgerProduct(salesLedgerProduct)); } /** * 删除产品信息 */ @Log(title = "产品信息", businessType = BusinessType.DELETE) @DeleteMapping("/delProduct") public AjaxResult remove(@RequestBody Long[] ids) { if (ids == null || ids.length == 0) { return AjaxResult.error("请传入要删除的ID"); } return toAjax(salesLedgerProductService.deleteSalesLedgerProductByIds(ids)); } }