package com.hw.qms.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
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.hw.common.log.annotation.Log;
import com.hw.common.log.enums.BusinessType;
import com.hw.common.security.annotation.RequiresPermissions;
import com.hw.qms.domain.QmsCheckRuleProject;
import com.hw.qms.service.IQmsCheckRuleProjectService;
import com.hw.common.core.web.controller.BaseController;
import com.hw.common.core.web.domain.AjaxResult;
import com.hw.common.core.utils.poi.ExcelUtil;
import com.hw.common.core.web.page.TableDataInfo;

/**
 * 检验规则项目Controller
 * 
 * @author xins
 * @date 2024-01-23
 */
@RestController
@RequestMapping("/checkruleproject")
public class QmsCheckRuleProjectController extends BaseController
{
    @Autowired
    private IQmsCheckRuleProjectService qmsCheckRuleProjectService;

    /**
     * 查询检验规则项目列表
     */
    @RequiresPermissions("qms:checkruleproject:list")
    @GetMapping("/list")
    public TableDataInfo list(QmsCheckRuleProject qmsCheckRuleProject)
    {
        startPage();
        List<QmsCheckRuleProject> list = qmsCheckRuleProjectService.selectQmsCheckRuleProjectList(qmsCheckRuleProject);
        return getDataTable(list);
    }

    /**
     * 导出检验规则项目列表
     */
    @RequiresPermissions("qms:checkruleproject:export")
    @Log(title = "检验规则项目", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, QmsCheckRuleProject qmsCheckRuleProject)
    {
        List<QmsCheckRuleProject> list = qmsCheckRuleProjectService.selectQmsCheckRuleProjectList(qmsCheckRuleProject);
        ExcelUtil<QmsCheckRuleProject> util = new ExcelUtil<QmsCheckRuleProject>(QmsCheckRuleProject.class);
        util.exportExcel(response, list, "检验规则项目数据");
    }

    /**
     * 获取检验规则项目详细信息
     */
    @RequiresPermissions("qms:checkruleproject:query")
    @GetMapping(value = "/{checkRuleId}")
    public AjaxResult getInfo(@PathVariable("checkRuleId") Long checkRuleId)
    {
        return success(qmsCheckRuleProjectService.selectQmsCheckRuleProjectByCheckRuleId(checkRuleId));
    }

    /**
     * 新增检验规则项目
     */
    @RequiresPermissions("qms:checkruleproject:add")
    @Log(title = "检验规则项目", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody QmsCheckRuleProject qmsCheckRuleProject)
    {
        return toAjax(qmsCheckRuleProjectService.insertQmsCheckRuleProject(qmsCheckRuleProject));
    }

    /**
     * 修改检验规则项目
     */
    @RequiresPermissions("qms:checkruleproject:edit")
    @Log(title = "检验规则项目", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody QmsCheckRuleProject qmsCheckRuleProject)
    {
        return toAjax(qmsCheckRuleProjectService.updateQmsCheckRuleProject(qmsCheckRuleProject));
    }

    /**
     * 删除检验规则项目
     */
    @RequiresPermissions("qms:checkruleproject:remove")
    @Log(title = "检验规则项目", businessType = BusinessType.DELETE)
	@DeleteMapping("/{checkRuleIds}")
    public AjaxResult remove(@PathVariable Long[] checkRuleIds)
    {
        return toAjax(qmsCheckRuleProjectService.deleteQmsCheckRuleProjectByCheckRuleIds(checkRuleIds));
    }
}
