package com.op.mes.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
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.op.common.log.annotation.Log;
import com.op.common.log.enums.BusinessType;
import com.op.common.security.annotation.RequiresPermissions;
import com.op.mes.domain.ProRouteLine;
import com.op.mes.service.IProRouteLineService;
import com.op.common.core.web.controller.BaseController;
import com.op.common.core.web.domain.AjaxResult;
import com.op.common.core.utils.poi.ExcelUtil;
import com.op.common.core.web.page.TableDataInfo;

/**
 * 工艺线体关联Controller
 *
 * @author Open Platform
 * @date 2023-07-13
 */
@RestController
@RequestMapping("/pro/routeprodline")
public class ProRouteLineController extends BaseController {
	@Autowired
	private IProRouteLineService proRouteLineService;

	/**
	 * 查询工艺线体关联列表
	 */
	//@RequiresPermissions("system:line:list")
	@GetMapping("/list")
	public TableDataInfo list(ProRouteLine proRouteLine) {
		startPage();
		List<ProRouteLine> list = proRouteLineService.selectProRouteLineList(proRouteLine);
		return getDataTable(list);
	}

	/**
	 * 导出工艺线体关联列表
	 */
	//@RequiresPermissions("system:line:export")
	@Log(title = "工艺线体关联", businessType = BusinessType.EXPORT)
	@PostMapping("/export")
	public void export(HttpServletResponse response, ProRouteLine proRouteLine) {
		List<ProRouteLine> list = proRouteLineService.selectProRouteLineList(proRouteLine);
		ExcelUtil<ProRouteLine> util = new ExcelUtil<ProRouteLine>(ProRouteLine.class);
		util.exportExcel(response, list, "工艺线体关联数据");
	}

	/**
	 * 获取工艺线体关联详细信息
	 */
	//@RequiresPermissions("system:line:query")
	@GetMapping(value = "/{recordId}")
	public AjaxResult getInfo(@PathVariable("recordId") String recordId) {
		return success(proRouteLineService.selectProRouteLineByRecordId(recordId));
	}

	/**
	 * 新增工艺线体关联
	 */
	//@RequiresPermissions("system:line:add")
	@Log(title = "工艺线体关联", businessType = BusinessType.INSERT)
	@PostMapping
	public AjaxResult add(@RequestBody ProRouteLine proRouteLine) {
		return toAjax(proRouteLineService.insertProRouteLine(proRouteLine));
	}

	/**
	 * 修改工艺线体关联
	 */
	//@RequiresPermissions("system:line:edit")
	@Log(title = "工艺线体关联", businessType = BusinessType.UPDATE)
	@PutMapping
	public AjaxResult edit(@RequestBody ProRouteLine proRouteLine) {
		return toAjax(proRouteLineService.updateProRouteLine(proRouteLine));
	}

	/**
	 * 删除工艺线体关联
	 */
	//@RequiresPermissions("system:line:remove")
	@Log(title = "工艺线体关联", businessType = BusinessType.DELETE)
	@DeleteMapping("/{recordIds}")
	public AjaxResult remove(@PathVariable String[] recordIds) {
		return toAjax(proRouteLineService.deleteProRouteLineByRecordIds(recordIds));
	}

	/**穿梭框**/
	@GetMapping("/getList")
	public ProRouteLine getList(ProRouteLine proRouteLine) {
		return  proRouteLineService.getList(proRouteLine);
	}
}
