package com.ruoyi.project.business.controller;

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

import com.ruoyi.framework.annotation.DataUpdateCheck;
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.TiTemplates;
import com.ruoyi.project.business.service.ITiTemplatesService;
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-05-16
 */
@RestController
@RequestMapping("/business/templates")
public class TiTemplatesController extends BaseController
{
    @Autowired
    private ITiTemplatesService tiTemplatesService;

    /**
     * 查询【出图模板】列表
     */
    @GetMapping("/list")
    public TableDataInfo list(TiTemplates tiTemplates)
    {
        startPage();
        List<TiTemplates> list = tiTemplatesService.selectTiTemplatesList(tiTemplates);
        return getDataTable(list);
    }

    /**
     * 查询所有【出图模板】列表 (不分页)
     */
    @GetMapping("/listAll")
    public TableDataInfo listAll()
    {
        List<TiTemplates> list = tiTemplatesService.selectTiTemplatesList(new TiTemplates());
        return getDataTable(list);
    }

    /**
     * 导出【出图模板】列表
     */
    @Log(title = "【出图模板】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TiTemplates tiTemplates)
    {
        List<TiTemplates> list = tiTemplatesService.selectTiTemplatesList(tiTemplates);
        ExcelUtil<TiTemplates> util = new ExcelUtil<TiTemplates>(TiTemplates.class);
        util.exportExcel(response, list, "【出图模板】数据");
    }

    /**
     * 获取【出图模板】详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tiTemplatesService.selectTiTemplatesById(id));
    }

    /**
     * 新增【出图模板】
     */
    @Log(title = "【出图模板】", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TiTemplates tiTemplates)
    {
        return toAjax(tiTemplatesService.insertTiTemplates(tiTemplates));
    }

    /**
     * 修改【出图模板】
     */
    @Log(title = "【出图模板】", businessType = BusinessType.UPDATE)
    @PutMapping
    @DataUpdateCheck(key = "id", tableName = "ti_templates")
    public AjaxResult edit(@RequestBody TiTemplates tiTemplates)
    {
        return toAjax(tiTemplatesService.updateTiTemplates(tiTemplates));
    }

    /**
     * 删除【出图模板】
     */
    @Log(title = "【出图模板】", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tiTemplatesService.deleteTiTemplatesByIds(ids));
    }
}
