package com.zehong.web.controller.track;

import java.util.List;

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.zehong.common.annotation.Log;
import com.zehong.common.core.controller.BaseController;
import com.zehong.common.core.domain.AjaxResult;
import com.zehong.common.enums.BusinessType;
import com.zehong.system.domain.track.TProductDrawing;
import com.zehong.system.service.track.ITProductDrawingService;
import com.zehong.common.utils.poi.ExcelUtil;
import com.zehong.common.core.page.TableDataInfo;

/**
 * 图纸Controller
 * 
 * @author zehong
 * @date 2024-08-21
 */
@RestController
@RequestMapping("/track/drawing")
public class TProductDrawingController extends BaseController
{
    @Autowired
    private ITProductDrawingService tProductDrawingService;

    /**
     * 查询图纸列表
     */
    //@PreAuthorize("@ss.hasPermi('system:drawing:list')")
    @GetMapping("/list")
    public TableDataInfo list(TProductDrawing tProductDrawing)
    {
        startPage();
        List<TProductDrawing> list = tProductDrawingService.selectTProductDrawingList(tProductDrawing);
        return getDataTable(list);
    }

    /**
     * 导出图纸列表
     */
   // @PreAuthorize("@ss.hasPermi('system:drawing:export')")
    @Log(title = "图纸", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TProductDrawing tProductDrawing)
    {
        List<TProductDrawing> list = tProductDrawingService.selectTProductDrawingList(tProductDrawing);
        ExcelUtil<TProductDrawing> util = new ExcelUtil<TProductDrawing>(TProductDrawing.class);
        return util.exportExcel(list, "图纸数据");
    }

    /**
     * 获取图纸详细信息
     */
    //@PreAuthorize("@ss.hasPermi('system:drawing:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tProductDrawingService.selectTProductDrawingById(id));
    }

    /**
     * 新增图纸
     */
    //@PreAuthorize("@ss.hasPermi('system:drawing:add')")
    @Log(title = "图纸", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TProductDrawing tProductDrawing)
    {
        return toAjax(tProductDrawingService.insertTProductDrawing(tProductDrawing));
    }

    /**
     * 修改图纸
     */
    //@PreAuthorize("@ss.hasPermi('system:drawing:edit')")
    @Log(title = "图纸", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TProductDrawing tProductDrawing)
    {
        return toAjax(tProductDrawingService.updateTProductDrawing(tProductDrawing));
    }

    /**
     * 删除图纸
     */
    //@PreAuthorize("@ss.hasPermi('system:drawing:remove')")
    @Log(title = "图纸", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tProductDrawingService.deleteTProductDrawingByIds(ids));
    }
}
