package com.ruoyi.project.business.controller.contract;

import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.project.business.domain.dto.TqContractLiftSnDto;
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.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.business.domain.TqContractLiftSn;
import com.ruoyi.project.business.service.ITqContractLiftSnService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 合同电梯生产令号序列号字段维护Controller
 * 
 * @author ruoyi
 * @date 2024-09-02
 */
@RestController
@RequestMapping("/business/liftSn")
public class TqContractLiftSnController extends BaseController
{
    @Resource
    private ITqContractLiftSnService tqContractLiftSnService;

    /**
     * 查询合同电梯生产令号序列号字段维护列表
     */
    // @PreAuthorize("@ss.hasPermi('system:sn:list')")
    @GetMapping("/list")
    public TableDataInfo list(TqContractLiftSnDto tqContractLiftSn)
    {
        startPage();
        List<TqContractLiftSn> list = tqContractLiftSnService.selectTqContractLiftSnList(tqContractLiftSn);
        return getDataTable(list);
    }

    /**
     * 导出合同电梯生产令号序列号字段维护列表
     */
    // @PreAuthorize("@ss.hasPermi('system:sn:export')")
    @Log(title = "合同电梯生产令号序列号字段维护", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TqContractLiftSnDto tqContractLiftSn)
    {
        List<TqContractLiftSn> list = tqContractLiftSnService.selectTqContractLiftSnList(tqContractLiftSn);
        ExcelUtil<TqContractLiftSn> util = new ExcelUtil<TqContractLiftSn>(TqContractLiftSn.class);
        util.exportExcel(response, list, "合同电梯生产令号序列号字段维护数据");
    }

    /**
     * 获取合同电梯生产令号序列号字段维护详细信息
     */
    // @PreAuthorize("@ss.hasPermi('system:sn:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tqContractLiftSnService.selectTqContractLiftSnById(id));
    }

    /**
     * 新增合同电梯生产令号序列号字段维护
     */
    // @PreAuthorize("@ss.hasPermi('system:sn:add')")
    @Log(title = "合同电梯生产令号序列号字段维护", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TqContractLiftSn tqContractLiftSn)
    {
        return toAjax(tqContractLiftSnService.insertTqContractLiftSn(tqContractLiftSn));
    }

    /**
     * 修改合同电梯生产令号序列号字段维护
     */
    // @PreAuthorize("@ss.hasPermi('system:sn:edit')")
    @Log(title = "合同电梯生产令号序列号字段维护", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TqContractLiftSn tqContractLiftSn)
    {
        return toAjax(tqContractLiftSnService.updateTqContractLiftSn(tqContractLiftSn));
    }

    /**
     * 删除合同电梯生产令号序列号字段维护
     */
    // @PreAuthorize("@ss.hasPermi('system:sn:remove')")
    @Log(title = "合同电梯生产令号序列号字段维护", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tqContractLiftSnService.deleteTqContractLiftSnByIds(ids));
    }
}
