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.BaseShiftsT;
import com.op.wms.service.IBaseShiftsTService;
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("/shifts")
public class BaseShiftsTController extends BaseController {
	@Autowired
	private IBaseShiftsTService baseShiftsTService;

	/**
	 * 查询班次管理列表
	 */
	@RequiresPermissions("wms:shifts:list")
	@GetMapping("/list")
	public TableDataInfo list(BaseShiftsT baseShiftsT) {
		startPage();
		List<BaseShiftsT> list = baseShiftsTService.selectBaseShiftsTList(baseShiftsT);
		return getDataTable(list);
	}

	/**
	 * 导出班次管理列表
	 */
	@RequiresPermissions("wms:shifts:export")
	@Log(title = "班次管理", businessType = BusinessType.EXPORT)
	@PostMapping("/export")
	public void export(HttpServletResponse response, BaseShiftsT baseShiftsT) {
		List<BaseShiftsT> list = baseShiftsTService.selectBaseShiftsTList(baseShiftsT);
		ExcelUtil<BaseShiftsT> util = new ExcelUtil<BaseShiftsT>(BaseShiftsT.class);
		util.exportExcel(response, list, "班次管理数据");
	}

	/**
	 * 获取班次管理详细信息
	 */
	@RequiresPermissions("wms:shifts:query")
	@GetMapping(value = "/{shiftId}")
	public AjaxResult getInfo(@PathVariable("shiftId") String shiftId) {
		return success(baseShiftsTService.selectBaseShiftsTByShiftId(shiftId));
	}

	/**
	 * 新增班次管理
	 */
	@RequiresPermissions("wms:shifts:add")
	@Log(title = "班次管理", businessType = BusinessType.INSERT)
	@PostMapping
	public AjaxResult add(@RequestBody BaseShiftsT baseShiftsT) {
		return toAjax(baseShiftsTService.insertBaseShiftsT(baseShiftsT));
	}

	/**
	 * 修改班次管理
	 */
	@RequiresPermissions("wms:shifts:edit")
	@Log(title = "班次管理", businessType = BusinessType.UPDATE)
	@PutMapping
	public AjaxResult edit(@RequestBody BaseShiftsT baseShiftsT) {
		return toAjax(baseShiftsTService.updateBaseShiftsT(baseShiftsT));
	}

	/**
	 * 删除班次管理
	 */
	@RequiresPermissions("wms:shifts:remove")
	@Log(title = "班次管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{shiftIds}")
	public AjaxResult remove(@PathVariable String[] shiftIds) {
		return toAjax(baseShiftsTService.deleteBaseShiftsTByShiftIds(shiftIds));
	}
}
