package com.hw.mes.controller;

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

import com.hw.common.security.annotation.InnerAuth;
import com.hw.common.security.utils.SecurityUtils;
import com.hw.mes.api.domain.MesBaseStationInfo;
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.service.IMesBaseStationInfoService;
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-26
 */
@RestController
@RequestMapping("/baseStationInfo")
public class MesBaseStationInfoController extends BaseController
{
    @Autowired
    private IMesBaseStationInfoService mesBaseStationInfoService;

    /**
     * 查询工位信息列表
     */
    @RequiresPermissions("mes:baseStationInfo:list")
    @GetMapping("/list")
    public TableDataInfo list(MesBaseStationInfo mesBaseStationInfo)
    {
        startPage();
        List<MesBaseStationInfo> list = mesBaseStationInfoService.selectMesBaseStationInfoList(mesBaseStationInfo);
        return getDataTable(list);
    }

    /**
     * 导出工位信息列表
     */
    @RequiresPermissions("mes:baseStationInfo:export")
    @Log(title = "工位信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MesBaseStationInfo mesBaseStationInfo)
    {
        List<MesBaseStationInfo> list = mesBaseStationInfoService.selectMesBaseStationInfoList(mesBaseStationInfo);
        ExcelUtil<MesBaseStationInfo> util = new ExcelUtil<MesBaseStationInfo>(MesBaseStationInfo.class);
        util.exportExcel(response, list, "工位信息数据");
    }

    /**
     * 获取工位信息详细信息
     */
    @RequiresPermissions("mes:baseStationInfo:query")
    @GetMapping(value = "/{stationId}")
    public AjaxResult getInfo(@PathVariable("stationId") Long stationId)
    {
        return success(mesBaseStationInfoService.selectMesBaseStationInfoByStationId(stationId));
    }

    /**
     * 新增工位信息
     */
    @RequiresPermissions("mes:baseStationInfo:add")
    @Log(title = "工位信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MesBaseStationInfo mesBaseStationInfo)
    {
        mesBaseStationInfo.setCreateBy(SecurityUtils.getLoginUser().getUsername());
        return toAjax(mesBaseStationInfoService.insertMesBaseStationInfo(mesBaseStationInfo));
    }

    /**
     * 修改工位信息
     */
    @RequiresPermissions("mes:baseStationInfo:edit")
    @Log(title = "工位信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MesBaseStationInfo mesBaseStationInfo)
    {
        mesBaseStationInfo.setUpdateBy(SecurityUtils.getLoginUser().getUsername());
        return toAjax(mesBaseStationInfoService.updateMesBaseStationInfo(mesBaseStationInfo));
    }

    /**
     * 删除工位信息
     */
    @RequiresPermissions("mes:baseStationInfo:remove")
    @Log(title = "工位信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{stationIds}")
    public AjaxResult remove(@PathVariable Long[] stationIds)
    {
        return toAjax(mesBaseStationInfoService.deleteMesBaseStationInfoByStationIds(stationIds));
    }




    /**
     * 查询工位信息列表
     */
    @InnerAuth
    @GetMapping("/getStations")
    public AjaxResult getStations(MesBaseStationInfo mesBaseStationInfo)
    {
        List<MesBaseStationInfo> list = mesBaseStationInfoService.selectMesBaseStationInfoList(mesBaseStationInfo);
        return success(list);
    }

}
