package com.ruoyi.szxc.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.szxc.domain.SzxcOffRecard;
import com.ruoyi.szxc.service.ISzxcOffRecardService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 注销登记记录Controller
 * 
 * @author hs
 * @date 2024-03-20
 */
@RestController
@RequestMapping("/szxc/offrecard")
public class SzxcOffRecardController extends BaseController
{
    @Autowired
    private ISzxcOffRecardService szxcOffRecardService;

    /**
     * 查询注销登记记录列表
     */
    @PreAuthorize("@ss.hasPermi('szxc:offrecard:list')")
    @GetMapping("/list")
    public TableDataInfo list(SzxcOffRecard szxcOffRecard)
    {
        startPage();
        List<SzxcOffRecard> list = szxcOffRecardService.selectSzxcOffRecardList(szxcOffRecard);
        return getDataTable(list);
    }

    /**
     * 导出注销登记记录列表
     */
    @PreAuthorize("@ss.hasPermi('szxc:offrecard:export')")
    @Log(title = "注销登记记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SzxcOffRecard szxcOffRecard)
    {
        List<SzxcOffRecard> list = szxcOffRecardService.selectSzxcOffRecardList(szxcOffRecard);
        ExcelUtil<SzxcOffRecard> util = new ExcelUtil<SzxcOffRecard>(SzxcOffRecard.class);
        util.exportExcel(response, list, "注销登记记录数据");
    }

    /**
     * 获取注销登记记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('szxc:offrecard:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(szxcOffRecardService.selectSzxcOffRecardById(id));
    }

    /**
     * 新增注销登记记录
     */
    @PreAuthorize("@ss.hasPermi('szxc:offrecard:add')")
    @Log(title = "注销登记记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SzxcOffRecard szxcOffRecard)
    {
        return toAjax(szxcOffRecardService.insertSzxcOffRecard(szxcOffRecard));
    }

    /**
     * 修改注销登记记录
     */
    @PreAuthorize("@ss.hasPermi('szxc:offrecard:edit')")
    @Log(title = "注销登记记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SzxcOffRecard szxcOffRecard)
    {
        return toAjax(szxcOffRecardService.updateSzxcOffRecard(szxcOffRecard));
    }

    /**
     * 删除注销登记记录
     */
    @PreAuthorize("@ss.hasPermi('szxc:offrecard:remove')")
    @Log(title = "注销登记记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(szxcOffRecardService.deleteSzxcOffRecardByIds(ids));
    }
}
