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

/**
 * 设备装配记录Controller
 * 
 * @author zehong
 * @date 2024-08-28
 */
@RestController
@RequestMapping("/track/deviceMark")
public class TProductDeviceMarkController extends BaseController
{
    @Autowired
    private ITProductDeviceMarkService tProductDeviceMarkService;

    /**
     * 查询设备装配记录列表
     */
   // @PreAuthorize("@ss.hasPermi('system:mark:list')")
    @GetMapping("/list")
    public TableDataInfo list(TProductDeviceMark tProductDeviceMark)
    {
        startPage();
        List<TProductDeviceMark> list = tProductDeviceMarkService.selectTProductDeviceMarkList(tProductDeviceMark);
        return getDataTable(list);
    }

    /**
     * 导出设备装配记录列表
     */
    //@PreAuthorize("@ss.hasPermi('system:mark:export')")
    @Log(title = "设备装配记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TProductDeviceMark tProductDeviceMark)
    {
        List<TProductDeviceMark> list = tProductDeviceMarkService.selectTProductDeviceMarkList(tProductDeviceMark);
        ExcelUtil<TProductDeviceMark> util = new ExcelUtil<TProductDeviceMark>(TProductDeviceMark.class);
        return util.exportExcel(list, "设备装配记录数据");
    }

    /**
     * 获取设备装配记录详细信息
     */
    //@PreAuthorize("@ss.hasPermi('system:mark:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tProductDeviceMarkService.selectTProductDeviceMarkById(id));
    }

    /**
     * 新增设备装配记录
     */
    //@PreAuthorize("@ss.hasPermi('system:mark:add')")
    @Log(title = "设备装配记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TProductDeviceMark tProductDeviceMark)
    {
        return toAjax(tProductDeviceMarkService.insertTProductDeviceMark(tProductDeviceMark));
    }

    /**
     * 修改设备装配记录
     */
    //@PreAuthorize("@ss.hasPermi('system:mark:edit')")
    @Log(title = "设备装配记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TProductDeviceMark tProductDeviceMark)
    {
        return toAjax(tProductDeviceMarkService.updateTProductDeviceMark(tProductDeviceMark));
    }

    /**
     * 删除设备装配记录
     */
    //@PreAuthorize("@ss.hasPermi('system:mark:remove')")
    @Log(title = "设备装配记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tProductDeviceMarkService.deleteTProductDeviceMarkByIds(ids));
    }

    /**
     * 根据产品获取设备详情
     * @param deviceId 产品主键
     * @return
     */
    @GetMapping("/selectDeviceMarkInfoByDeviceId")
    public TableDataInfo selectDeviceMarkInfoByDeviceId(TProductDeviceMark mark){
        startPage();
        return getDataTable(tProductDeviceMarkService.selectDeviceMarkInfoByDeviceId(mark));
    }
}
