Files
double-rack/ruoyi-cost/src/main/java/com/ruoyi/cost/controller/CostPriceController.java

105 lines
3.5 KiB
Java
Raw Normal View History

package com.ruoyi.cost.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.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.cost.domain.CostPrice;
import com.ruoyi.cost.service.ICostPriceService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
* 成本单价历史Controller
*
* @author ruoyi
* @date 2026-06-09
*/
@RestController
@RequestMapping("/cost/price")
public class CostPriceController extends BaseController
{
@Autowired
private ICostPriceService costPriceService;
/**
* 查询成本单价历史列表
*/
@PreAuthorize("@ss.hasPermi('cost:price:list')")
@GetMapping("/list")
public TableDataInfo list(CostPrice costPrice)
{
startPage();
List<CostPrice> list = costPriceService.selectCostPriceList(costPrice);
return getDataTable(list);
}
/**
* 导出成本单价历史列表
*/
@PreAuthorize("@ss.hasPermi('cost:price:export')")
@Log(title = "成本单价历史", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, CostPrice costPrice)
{
List<CostPrice> list = costPriceService.selectCostPriceList(costPrice);
ExcelUtil<CostPrice> util = new ExcelUtil<CostPrice>(CostPrice.class);
util.exportExcel(response, list, "成本单价历史数据");
}
/**
* 获取成本单价历史详细信息
*/
@PreAuthorize("@ss.hasPermi('cost:price:query')")
@GetMapping(value = "/{priceId}")
public AjaxResult getInfo(@PathVariable("priceId") Long priceId)
{
return success(costPriceService.selectCostPriceByPriceId(priceId));
}
/**
* 新增成本单价历史
*/
@PreAuthorize("@ss.hasPermi('cost:price:add')")
@Log(title = "成本单价历史", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody CostPrice costPrice)
{
return toAjax(costPriceService.insertCostPrice(costPrice));
}
/**
* 修改成本单价历史
*/
@PreAuthorize("@ss.hasPermi('cost:price:edit')")
@Log(title = "成本单价历史", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody CostPrice costPrice)
{
return toAjax(costPriceService.updateCostPrice(costPrice));
}
/**
* 删除成本单价历史
*/
@PreAuthorize("@ss.hasPermi('cost:price:remove')")
@Log(title = "成本单价历史", businessType = BusinessType.DELETE)
@DeleteMapping("/{priceIds}")
public AjaxResult remove(@PathVariable Long[] priceIds)
{
return toAjax(costPriceService.deleteCostPriceByPriceIds(priceIds));
}
}