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.MesBaseRouteProcess;
import com.hw.mes.service.IMesBaseRouteProcessService;
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-25
 */
@RestController
@RequestMapping("/baseRouteProcess")
public class MesBaseRouteProcessController extends BaseController
{
    @Autowired
    private IMesBaseRouteProcessService mesBaseRouteProcessService;

    /**
     * 查询工艺路线组成信息列表
     */
    @RequiresPermissions("mes:baseRouteProcess:list")
    @GetMapping("/list")
    public TableDataInfo list(MesBaseRouteProcess mesBaseRouteProcess)
    {
        startPage();
        List<MesBaseRouteProcess> list = mesBaseRouteProcessService.selectMesBaseRouteProcessList(mesBaseRouteProcess);
        return getDataTable(list);
    }

    /**
     * 导出工艺路线组成信息列表
     */
    @RequiresPermissions("mes:baseRouteProcess:export")
    @Log(title = "工艺路线组成信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MesBaseRouteProcess mesBaseRouteProcess)
    {
        List<MesBaseRouteProcess> list = mesBaseRouteProcessService.selectMesBaseRouteProcessList(mesBaseRouteProcess);
        ExcelUtil<MesBaseRouteProcess> util = new ExcelUtil<MesBaseRouteProcess>(MesBaseRouteProcess.class);
        util.exportExcel(response, list, "工艺路线组成信息数据");
    }

    /**
     * 获取工艺路线组成信息详细信息
     */
    @RequiresPermissions("mes:baseRouteProcess:query")
    @GetMapping(value = "/{routeProcessId}")
    public AjaxResult getInfo(@PathVariable("routeProcessId") Long routeProcessId)
    {
        return success(mesBaseRouteProcessService.selectMesBaseRouteProcessByRouteProcessId(routeProcessId));
    }

    /**
     * 新增工艺路线组成信息
     */
    @RequiresPermissions("mes:baseRouteProcess:add")
    @Log(title = "工艺路线组成信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MesBaseRouteProcess mesBaseRouteProcess)
    {
        mesBaseRouteProcess.setCreateBy(SecurityUtils.getLoginUser().getUsername());
        return toAjax(mesBaseRouteProcessService.insertMesBaseRouteProcess(mesBaseRouteProcess));
    }

    /**
     * 修改工艺路线组成信息
     */
    @RequiresPermissions("mes:baseRouteProcess:edit")
    @Log(title = "工艺路线组成信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MesBaseRouteProcess mesBaseRouteProcess)
    {
        mesBaseRouteProcess.setUpdateBy(SecurityUtils.getLoginUser().getUsername());
        return toAjax(mesBaseRouteProcessService.updateMesBaseRouteProcess(mesBaseRouteProcess));
    }

    /**
     * 删除工艺路线组成信息
     */
    @RequiresPermissions("mes:baseRouteProcess:remove")
    @Log(title = "工艺路线组成信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{routeProcessIds}")
    public AjaxResult remove(@PathVariable Long[] routeProcessIds)
    {
        return toAjax(mesBaseRouteProcessService.deleteMesBaseRouteProcessByRouteProcessIds(routeProcessIds));
    }
}
