package com.jjt.rz.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.rz.domain.TwinDeviceRz;
import com.jjt.rz.service.ITwinDeviceRzService;
import com.jjt.common.utils.poi.ExcelUtil;
import com.jjt.common.core.page.TableDataInfo;

/**
 * 染整线设备管理Controller
 *
 * @author wukai
 * @date 2025-05-21
 */
@Api(tags="染整线设备管理")
@RestController
@RequestMapping("/rz/rz")
public class TwinDeviceRzController extends BaseController{
    @Resource
    private ITwinDeviceRzService twinDeviceRzService;

    /**
     * 查询染整线设备管理列表
     */
    @ApiOperation("查询染整线设备管理列表")
    @PreAuthorize("@ss.hasPermi('rz:rz:list')")
    @GetMapping("/list")
    public TableDataInfo list(TwinDeviceRz twinDeviceRz)
    {
        startPage();
        List<TwinDeviceRz> list = twinDeviceRzService.selectTwinDeviceRzList(twinDeviceRz);
        return getDataTable(list);
    }

    /**
     * 导出染整线设备管理列表
     */
    @ApiOperation("导出染整线设备管理列表")
    @PreAuthorize("@ss.hasPermi('rz:rz:export')")
    @Log(title = "染整线设备管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TwinDeviceRz twinDeviceRz)
    {
        List<TwinDeviceRz> list = twinDeviceRzService.selectTwinDeviceRzList(twinDeviceRz);
        ExcelUtil<TwinDeviceRz> util = new ExcelUtil<TwinDeviceRz>(TwinDeviceRz.class);
        util.exportExcel(response, list, "染整线设备管理数据");
    }

    /**
     * 获取染整线设备管理详细信息
     */
    @ApiOperation("获取染整线设备管理详细信息")
    @PreAuthorize("@ss.hasPermi('rz:rz:query')")
    @GetMapping(value = "/{deviceId}")
    public AjaxResult getInfo(@PathVariable("deviceId") Long deviceId)
    {
        return success(twinDeviceRzService.selectTwinDeviceRzByDeviceId(deviceId));
    }

    /**
     * 新增染整线设备管理
     */
    @ApiOperation("新增染整线设备管理")
    @PreAuthorize("@ss.hasPermi('rz:rz:add')")
    @Log(title = "染整线设备管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TwinDeviceRz twinDeviceRz)
    {
        return toAjax(twinDeviceRzService.insertTwinDeviceRz(twinDeviceRz));
    }

    /**
     * 修改染整线设备管理
     */
    @ApiOperation("修改染整线设备管理")
    @PreAuthorize("@ss.hasPermi('rz:rz:edit')")
    @Log(title = "染整线设备管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TwinDeviceRz twinDeviceRz)
    {
        return toAjax(twinDeviceRzService.updateTwinDeviceRz(twinDeviceRz));
    }

    /**
     * 删除染整线设备管理
     */
    @ApiOperation("删除染整线设备管理")
    @PreAuthorize("@ss.hasPermi('rz:rz:remove')")
    @Log(title = "染整线设备管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{deviceIds}")
    public AjaxResult remove(@PathVariable Long[] deviceIds)
    {
        return toAjax(twinDeviceRzService.deleteTwinDeviceRzByDeviceIds(deviceIds));
    }
}
