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.OdsWhiteEmbryoInventory;
import com.op.wms.service.IOdsWhiteEmbryoInventoryService;
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-06
 */
@RestController
@RequestMapping("/Inventory")
public class OdsWhiteEmbryoInventoryController extends BaseController {
	@Autowired
	private IOdsWhiteEmbryoInventoryService odsWhiteEmbryoInventoryService;

	/**
	 * 查询白胚盘点单列表
	 */
	@RequiresPermissions("wms:Inventory:list")
	@GetMapping("/list")
	public TableDataInfo list(OdsWhiteEmbryoInventory odsWhiteEmbryoInventory) {
		startPage();
		List<OdsWhiteEmbryoInventory> list = odsWhiteEmbryoInventoryService.selectOdsWhiteEmbryoInventoryList(odsWhiteEmbryoInventory);
		return getDataTable(list);
	}

	/**
	 * 导出白胚盘点单列表
	 */
	@RequiresPermissions("wms:Inventory:export")
	@Log(title = "白胚盘点单", businessType = BusinessType.EXPORT)
	@PostMapping("/export")
	public void export(HttpServletResponse response, OdsWhiteEmbryoInventory odsWhiteEmbryoInventory) {
		List<OdsWhiteEmbryoInventory> list = odsWhiteEmbryoInventoryService.selectOdsWhiteEmbryoInventoryList(odsWhiteEmbryoInventory);
		ExcelUtil<OdsWhiteEmbryoInventory> util = new ExcelUtil<OdsWhiteEmbryoInventory>(OdsWhiteEmbryoInventory.class);
		util.exportExcel(response, list, "白胚盘点单数据");
	}

	/**
	 * 获取白胚盘点单详细信息
	 */
	@RequiresPermissions("wms:Inventory:query")
	@GetMapping(value = "/{ID}")
	public AjaxResult getInfo(@PathVariable("ID") String ID) {
		return success(odsWhiteEmbryoInventoryService.selectOdsWhiteEmbryoInventoryByID(ID));
	}

	/**
	 * 新增白胚盘点单
	 */
	@RequiresPermissions("wms:Inventory:add")
	@Log(title = "白胚盘点单", businessType = BusinessType.INSERT)
	@PostMapping
	public AjaxResult add(@RequestBody OdsWhiteEmbryoInventory odsWhiteEmbryoInventory) {
		return toAjax(odsWhiteEmbryoInventoryService.insertOdsWhiteEmbryoInventory(odsWhiteEmbryoInventory));
	}

	/**
	 * 修改白胚盘点单
	 */
	@RequiresPermissions("wms:Inventory:edit")
	@Log(title = "白胚盘点单", businessType = BusinessType.UPDATE)
	@PutMapping
	public AjaxResult edit(@RequestBody OdsWhiteEmbryoInventory odsWhiteEmbryoInventory) {
		return toAjax(odsWhiteEmbryoInventoryService.updateOdsWhiteEmbryoInventory(odsWhiteEmbryoInventory));
	}

	/**
	 * 删除白胚盘点单
	 */
	@RequiresPermissions("wms:Inventory:remove")
	@Log(title = "白胚盘点单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{IDs}")
	public AjaxResult remove(@PathVariable String[] IDs) {
		return toAjax(odsWhiteEmbryoInventoryService.deleteOdsWhiteEmbryoInventoryByIDs(IDs));
	}
}
