package com.jjt.biz.controller;

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

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
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.jjt.common.annotation.Log;
import com.jjt.common.core.controller.BaseController;
import com.jjt.common.core.domain.AjaxResult;
import com.jjt.common.enums.BusinessType;
import com.jjt.biz.domain.TwinDeviceYhj;
import com.jjt.biz.service.ITwinDeviceYhjService;
import com.jjt.common.utils.poi.ExcelUtil;
import com.jjt.common.core.page.TableDataInfo;

/**
 * 印花机设备管理Controller
 *
 * @author wukai
 * @date 2025-03-06
 */
@Api(tags="印花机设备管理")
@RestController
@RequestMapping("/biz/yhj")
public class TwinDeviceYhjController extends BaseController{
    @Resource
    private ITwinDeviceYhjService twinDeviceYhjService;

    /**
     * 查询印花机设备管理列表
     */
    @ApiOperation("查询印花机设备管理列表")
    @PreAuthorize("@ss.hasPermi('biz:yhj:list')")
    @GetMapping("/list")
    public TableDataInfo list(TwinDeviceYhj twinDeviceYhj)
    {
        startPage();
        List<TwinDeviceYhj> list = twinDeviceYhjService.selectTwinDeviceYhjList(twinDeviceYhj);
        return getDataTable(list);
    }

    /**
     * 导出印花机设备管理列表
     */
    @ApiOperation("导出印花机设备管理列表")
    @PreAuthorize("@ss.hasPermi('biz:yhj:export')")
    @Log(title = "印花机设备管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TwinDeviceYhj twinDeviceYhj)
    {
        List<TwinDeviceYhj> list = twinDeviceYhjService.selectTwinDeviceYhjList(twinDeviceYhj);
        ExcelUtil<TwinDeviceYhj> util = new ExcelUtil<TwinDeviceYhj>(TwinDeviceYhj.class);
        util.exportExcel(response, list, "印花机设备管理数据");
    }

    /**
     * 获取印花机设备管理详细信息
     */
    @ApiOperation("获取印花机设备管理详细信息")
    @PreAuthorize("@ss.hasPermi('biz:yhj:query')")
    @GetMapping(value = "/{deviceId}")
    public AjaxResult getInfo(@PathVariable("deviceId") Long deviceId)
    {
        return success(twinDeviceYhjService.selectTwinDeviceYhjByDeviceId(deviceId));
    }

    /**
     * 新增印花机设备管理
     */
    @ApiOperation("新增印花机设备管理")
    @PreAuthorize("@ss.hasPermi('biz:yhj:add')")
    @Log(title = "印花机设备管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TwinDeviceYhj twinDeviceYhj)
    {
        return toAjax(twinDeviceYhjService.insertTwinDeviceYhj(twinDeviceYhj));
    }

    /**
     * 修改印花机设备管理
     */
    @ApiOperation("修改印花机设备管理")
    @PreAuthorize("@ss.hasPermi('biz:yhj:edit')")
    @Log(title = "印花机设备管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TwinDeviceYhj twinDeviceYhj)
    {
        return toAjax(twinDeviceYhjService.updateTwinDeviceYhj(twinDeviceYhj));
    }

    /**
     * 删除印花机设备管理
     */
    @ApiOperation("删除印花机设备管理")
    @PreAuthorize("@ss.hasPermi('biz:yhj:remove')")
    @Log(title = "印花机设备管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{deviceIds}")
    public AjaxResult remove(@PathVariable Long[] deviceIds)
    {
        return toAjax(twinDeviceYhjService.deleteTwinDeviceYhjByDeviceIds(deviceIds));
    }
}
