package com.ruoyi.project.check.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.project.check.domain.TCheckLawitems;
import com.ruoyi.project.check.service.ITCheckLawitemsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 法规项Controller
 *
 * @author ruoyi
 * @date 2022-11-28
 */
@RestController
@RequestMapping("/check/lawitems")
public class TCheckLawitemsController extends BaseController
{
    @Autowired
    private ITCheckLawitemsService tCheckLawitemsService;

    /**
     * 查询法规项列表
     */
    @PreAuthorize("@ss.hasPermi('check:lawitems:list')")
    @GetMapping("/list")
    public TableDataInfo list(TCheckLawitems tCheckLawitems)
    {
        startPage();
        List<TCheckLawitems> list = tCheckLawitemsService.selectTCheckLawitemsList(tCheckLawitems);
        return getDataTable(list);
    }

    /**
     * 导出法规项列表
     */
    @PreAuthorize("@ss.hasPermi('check:lawitems:export')")
    @Log(title = "法规项导出", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TCheckLawitems tCheckLawitems)
    {
        List<TCheckLawitems> list = tCheckLawitemsService.selectTCheckLawitemsList(tCheckLawitems);
        ExcelUtil<TCheckLawitems> util = new ExcelUtil<TCheckLawitems>(TCheckLawitems.class);
        util.exportExcel(response, list, "法规项数据");
    }

    /**
     * 获取法规项详细信息
     */
    @PreAuthorize("@ss.hasPermi('check:lawitems:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tCheckLawitemsService.selectTCheckLawitemsById(id));
    }

    /**
     * 新增法规项
     */
    @PreAuthorize("@ss.hasPermi('check:lawitems:add')")
    @Log(title = "法规项新增", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TCheckLawitems tCheckLawitems)
    {
        return toAjax(tCheckLawitemsService.insertTCheckLawitems(tCheckLawitems));
    }

    /**
     * 修改法规项
     */
    @PreAuthorize("@ss.hasPermi('check:lawitems:edit')")
    @Log(title = "法规项修改", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TCheckLawitems tCheckLawitems)
    {
        return toAjax(tCheckLawitemsService.updateTCheckLawitems(tCheckLawitems));
    }

    /**
     * 删除法规项
     */
    @PreAuthorize("@ss.hasPermi('check:lawitems:remove')")
    @Log(title = "法规项删除", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tCheckLawitemsService.deleteTCheckLawitemsByIds(ids));
    }
}
