package com.hw.mes.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.hw.common.security.utils.SecurityUtils;
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.hw.common.log.annotation.Log;
import com.hw.common.log.enums.BusinessType;
import com.hw.common.security.annotation.RequiresPermissions;
import com.hw.mes.domain.MesBaseProdlineInfo;
import com.hw.mes.service.IMesBaseProdlineInfoService;
import com.hw.common.core.web.controller.BaseController;
import com.hw.common.core.web.domain.AjaxResult;
import com.hw.common.core.utils.poi.ExcelUtil;
import com.hw.common.core.web.page.TableDataInfo;

/**
 * 产线信息Controller
 * 
 * @author Yinq
 * @date 2024-01-24
 */
@RestController
@RequestMapping("/baseProdlineInfo")
public class MesBaseProdlineInfoController extends BaseController
{
    @Autowired
    private IMesBaseProdlineInfoService mesBaseProdlineInfoService;

    /**
     * 查询产线信息列表
     */
    @RequiresPermissions("mes:baseProdlineInfo:list")
    @GetMapping("/list")
    public TableDataInfo list(MesBaseProdlineInfo mesBaseProdlineInfo)
    {
        startPage();
        List<MesBaseProdlineInfo> list = mesBaseProdlineInfoService.selectMesBaseProdlineInfoList(mesBaseProdlineInfo);
        return getDataTable(list);
    }

    /**
     * 查询产线信息下拉框列表
     */
    @GetMapping("/findProdLineList")
    public AjaxResult findProdLineList(MesBaseProdlineInfo mesBaseProdlineInfo)
    {
        List<MesBaseProdlineInfo> list = mesBaseProdlineInfoService.selectMesBaseProdlineInfoList(mesBaseProdlineInfo);
        return success(list);
    }

    /**
     * 导出产线信息列表
     */
    @RequiresPermissions("mes:baseProdlineInfo:export")
    @Log(title = "产线信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MesBaseProdlineInfo mesBaseProdlineInfo)
    {
        List<MesBaseProdlineInfo> list = mesBaseProdlineInfoService.selectMesBaseProdlineInfoList(mesBaseProdlineInfo);
        ExcelUtil<MesBaseProdlineInfo> util = new ExcelUtil<MesBaseProdlineInfo>(MesBaseProdlineInfo.class);
        util.exportExcel(response, list, "产线信息数据");
    }

    /**
     * 获取产线信息详细信息
     */
    @RequiresPermissions("mes:baseProdlineInfo:query")
    @GetMapping(value = "/{prodlineId}")
    public AjaxResult getInfo(@PathVariable("prodlineId") Long prodlineId)
    {
        return success(mesBaseProdlineInfoService.selectMesBaseProdlineInfoByProdlineId(prodlineId));
    }

    /**
     * 新增产线信息
     */
    @RequiresPermissions("mes:baseProdlineInfo:add")
    @Log(title = "产线信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MesBaseProdlineInfo mesBaseProdlineInfo)
    {
        mesBaseProdlineInfo.setCreateBy(SecurityUtils.getLoginUser().getUsername());
        return toAjax(mesBaseProdlineInfoService.insertMesBaseProdlineInfo(mesBaseProdlineInfo));
    }

    /**
     * 修改产线信息
     */
    @RequiresPermissions("mes:baseProdlineInfo:edit")
    @Log(title = "产线信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MesBaseProdlineInfo mesBaseProdlineInfo)
    {
        mesBaseProdlineInfo.setUpdateBy(SecurityUtils.getLoginUser().getUsername());
        return toAjax(mesBaseProdlineInfoService.updateMesBaseProdlineInfo(mesBaseProdlineInfo));
    }

    /**
     * 删除产线信息
     */
    @RequiresPermissions("mes:baseProdlineInfo:remove")
    @Log(title = "产线信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{prodlineIds}")
    public AjaxResult remove(@PathVariable Long[] prodlineIds)
    {
        return toAjax(mesBaseProdlineInfoService.deleteMesBaseProdlineInfoByProdlineIds(prodlineIds));
    }
}
