package com.yanzhu.jh.project.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.yanzhu.jh.project.domain.SurProjectStandard;
import com.yanzhu.jh.project.service.ISurProjectStandardService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 标准化管理Controller
 * 
 * @author ruoyi
 * @date 2023-09-19
 */
@RestController
@RequestMapping("/project/projectStandard")
public class SurProjectStandardController extends BaseController
{
    @Autowired
    private ISurProjectStandardService surProjectStandardService;

    /**
     * 查询标准化管理列表
     */
    @PreAuthorize("@ss.hasPermi('project:projectStandard:list')")
    @GetMapping("/list")
    public TableDataInfo list(SurProjectStandard surProjectStandard)
    {
        startPage();
        List<SurProjectStandard> list = surProjectStandardService.selectSurProjectStandardList(surProjectStandard);
        return getDataTable(list);
    }

    /**
     * 导出标准化管理列表
     */
    @PreAuthorize("@ss.hasPermi('project:projectStandard:export')")
    @Log(title = "标准化管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SurProjectStandard surProjectStandard)
    {
        List<SurProjectStandard> list = surProjectStandardService.selectSurProjectStandardList(surProjectStandard);
        ExcelUtil<SurProjectStandard> util = new ExcelUtil<SurProjectStandard>(SurProjectStandard.class);
        util.exportExcel(response, list, "标准化管理数据");
    }

    /**
     * 获取标准化管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('project:projectStandard:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(surProjectStandardService.selectSurProjectStandardById(id));
    }

    /**
     * 新增标准化管理
     */
    @PreAuthorize("@ss.hasPermi('project:projectStandard:add')")
    @Log(title = "标准化管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SurProjectStandard surProjectStandard)
    {
        return toAjax(surProjectStandardService.insertSurProjectStandards(surProjectStandard));
    }

    /**
     * 修改标准化管理
     */
    @PreAuthorize("@ss.hasPermi('project:projectStandard:edit')")
    @Log(title = "标准化管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SurProjectStandard surProjectStandard)
    {
        return toAjax(surProjectStandardService.updateSurProjectStandard(surProjectStandard));
    }

    /**
     * 删除标准化管理
     */
    @PreAuthorize("@ss.hasPermi('project:projectStandard:remove')")
    @Log(title = "标准化管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(surProjectStandardService.deleteSurProjectStandardByIds(ids));
    }
}
