package com.ruoyi.projectCost.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.projectCost.domain.ProjectCost;
import com.ruoyi.projectCost.service.IProjectCostService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * projectCostController
 * 
 * @author ruoyi
 * @date 2023-08-14
 */
@RestController
@RequestMapping("/projectCost/projectCost")
public class ProjectCostController extends BaseController
{
    @Autowired
    private IProjectCostService projectCostService;

    /**
     * 查询projectCost列表
     */
    @PreAuthorize("@ss.hasPermi('projectCost:projectCost:list')")
    @GetMapping("/list")
    public TableDataInfo list(ProjectCost projectCost)
    {
        startPage();
        List<ProjectCost> list = projectCostService.selectProjectCostList(projectCost);
        return getDataTable(list);
    }

    /**
     * 导出projectCost列表
     */
    @PreAuthorize("@ss.hasPermi('projectCost:projectCost:export')")
    @Log(title = "projectCost", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ProjectCost projectCost)
    {
        List<ProjectCost> list = projectCostService.selectProjectCostList(projectCost);
        ExcelUtil<ProjectCost> util = new ExcelUtil<ProjectCost>(ProjectCost.class);
        util.exportExcel(response, list, "projectCost数据");
    }

    /**
     * 获取projectCost详细信息
     */
    @PreAuthorize("@ss.hasPermi('projectCost:projectCost:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(projectCostService.selectProjectCostById(id));
    }

    /**
     * 新增projectCost
     */
    @PreAuthorize("@ss.hasPermi('projectCost:projectCost:add')")
    @Log(title = "projectCost", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProjectCost projectCost)
    {
        return toAjax(projectCostService.insertProjectCost(projectCost));
    }

    /**
     * 修改projectCost
     */
    @PreAuthorize("@ss.hasPermi('projectCost:projectCost:edit')")
    @Log(title = "projectCost", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProjectCost projectCost)
    {
        return toAjax(projectCostService.updateProjectCost(projectCost));
    }

    /**
     * 删除projectCost
     */
    @PreAuthorize("@ss.hasPermi('projectCost:projectCost:remove')")
    @Log(title = "projectCost", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(projectCostService.deleteProjectCostByIds(ids));
    }
}
