package com.op.wms.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.wms.domain.BaseBomItemsT;
import com.op.wms.service.IBaseBomItemsTService;
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;

/**
 * 物料BOM管理Controller
 * 
 * @author Open Platform
 * @date 2023-07-18
 */
@RestController
@RequestMapping("/bom")
public class BaseBomItemsTController extends BaseController {
	@Autowired
	private IBaseBomItemsTService baseBomItemsTService;

	/**
	 * 查询物料BOM管理列表
	 */
	@RequiresPermissions("wms:bom:list")
	@GetMapping("/list")
	public TableDataInfo list(BaseBomItemsT baseBomItemsT) {
		startPage();
		List<BaseBomItemsT> list = baseBomItemsTService.selectBaseBomItemsTList(baseBomItemsT);
		return getDataTable(list);
	}

	/**
	 * 导出物料BOM管理列表
	 */
	@RequiresPermissions("wms:bom:export")
	@Log(title = "物料BOM管理", businessType = BusinessType.EXPORT)
	@PostMapping("/export")
	public void export(HttpServletResponse response, BaseBomItemsT baseBomItemsT) {
		List<BaseBomItemsT> list = baseBomItemsTService.selectBaseBomItemsTList(baseBomItemsT);
		ExcelUtil<BaseBomItemsT> util = new ExcelUtil<BaseBomItemsT>(BaseBomItemsT.class);
		util.exportExcel(response, list, "物料BOM管理数据");
	}

	/**
	 * 获取物料BOM管理详细信息
	 */
	@RequiresPermissions("wms:bom:query")
	@GetMapping(value = "/{bomItemId}")
	public AjaxResult getInfo(@PathVariable("bomItemId") String bomItemId) {
		return success(baseBomItemsTService.selectBaseBomItemsTByBomItemId(bomItemId));
	}

	/**
	 * 新增物料BOM管理
	 */
	@RequiresPermissions("wms:bom:add")
	@Log(title = "物料BOM管理", businessType = BusinessType.INSERT)
	@PostMapping
	public AjaxResult add(@RequestBody BaseBomItemsT baseBomItemsT) {
		return toAjax(baseBomItemsTService.insertBaseBomItemsT(baseBomItemsT));
	}

	/**
	 * 修改物料BOM管理
	 */
	@RequiresPermissions("wms:bom:edit")
	@Log(title = "物料BOM管理", businessType = BusinessType.UPDATE)
	@PutMapping
	public AjaxResult edit(@RequestBody BaseBomItemsT baseBomItemsT) {
		return toAjax(baseBomItemsTService.updateBaseBomItemsT(baseBomItemsT));
	}

	/**
	 * 删除物料BOM管理
	 */
	@RequiresPermissions("wms:bom:remove")
	@Log(title = "物料BOM管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{bomItemIds}")
	public AjaxResult remove(@PathVariable String[] bomItemIds) {
		return toAjax(baseBomItemsTService.deleteBaseBomItemsTByBomItemIds(bomItemIds));
	}
}
