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.TProductMark;
import com.zehong.system.service.track.ITProductMarkService;
import com.zehong.common.utils.poi.ExcelUtil;
import com.zehong.common.core.page.TableDataInfo;

/**
 * 装配模板Controller
 * 
 * @author zehong
 * @date 2024-08-23
 */
@RestController
@RequestMapping("/track/mark")
public class TProductMarkController extends BaseController
{
    @Autowired
    private ITProductMarkService tProductMarkService;

    /**
     * 查询装配模板列表
     */
   // @PreAuthorize("@ss.hasPermi('system:mark:list')")
    @GetMapping("/list")
    public TableDataInfo list(TProductMark tProductMark)
    {
        startPage();
        List<TProductMark> list = tProductMarkService.selectTProductMarkList(tProductMark);
        return getDataTable(list);
    }

    @GetMapping("/markInfoList")
    public AjaxResult markInfoList(TProductMark tProductMark)
    {
        List<TProductMark> list = tProductMarkService.selectTProductMarkList(tProductMark);
        return AjaxResult.success(list);
    }

    /**
     * 导出装配模板列表
     */
    //@PreAuthorize("@ss.hasPermi('system:mark:export')")
    @Log(title = "装配模板", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TProductMark tProductMark)
    {
        List<TProductMark> list = tProductMarkService.selectTProductMarkList(tProductMark);
        ExcelUtil<TProductMark> util = new ExcelUtil<TProductMark>(TProductMark.class);
        return util.exportExcel(list, "装配模板数据");
    }

    /**
     * 获取装配模板详细信息
     */
    //@PreAuthorize("@ss.hasPermi('system:mark:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tProductMarkService.selectTProductMarkById(id));
    }

    /**
     * 新增装配模板
     */
    //@PreAuthorize("@ss.hasPermi('system:mark:add')")
    @Log(title = "装配模板", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TProductMark tProductMark)
    {
        return toAjax(tProductMarkService.insertTProductMark(tProductMark));
    }

    /**
     * 修改装配模板
     */
    //@PreAuthorize("@ss.hasPermi('system:mark:edit')")
    @Log(title = "装配模板", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TProductMark tProductMark)
    {
        return toAjax(tProductMarkService.updateTProductMark(tProductMark));
    }

    /**
     * 删除装配模板
     */
    //@PreAuthorize("@ss.hasPermi('system:mark:remove')")
    @Log(title = "装配模板", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tProductMarkService.deleteTProductMarkByIds(ids));
    }
}
