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.ProRouteProduct;
import com.op.mes.service.IProRouteProductService;
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/routeprodproduct")
public class ProRouteProductController extends BaseController {
	@Autowired
	private IProRouteProductService proRouteProductService;

	/**
	 * 查询工艺线体关联列表
	 */
	//@RequiresPermissions("system:product:list")
	@GetMapping("/list")
	public TableDataInfo list(ProRouteProduct proRouteProduct) {
		startPage();
		List<ProRouteProduct> list = proRouteProductService.selectProRouteProductList(proRouteProduct);
		return getDataTable(list);
	}

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

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

	/**
	 * 新增工艺线体关联
	 */
	//@RequiresPermissions("system:product:add")
	@Log(title = "工艺线体关联", businessType = BusinessType.INSERT)
	@PostMapping
	public AjaxResult add(@RequestBody ProRouteProduct proRouteProduct) {
		return toAjax(proRouteProductService.insertProRouteProduct(proRouteProduct));
	}

	/**
	 * 修改工艺线体关联
	 */
	//@RequiresPermissions("system:product:edit")
	@Log(title = "工艺线体关联", businessType = BusinessType.UPDATE)
	@PutMapping
	public AjaxResult edit(@RequestBody ProRouteProduct proRouteProduct) {
		return toAjax(proRouteProductService.updateProRouteProduct(proRouteProduct));
	}

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

	/**穿梭框**/
	@GetMapping("/getList")
	public ProRouteProduct getList(ProRouteProduct proRouteProduct) {
		return  proRouteProductService.getList(proRouteProduct);
	}
}
