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.BaseTeamT;
import com.op.wms.service.IBaseTeamTService;
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-05
 */
@RestController
@RequestMapping("/team")
public class BaseTeamTController extends BaseController {
	@Autowired
	private IBaseTeamTService baseTeamTService;

	/**
	 * 查询班组列表
	 */
	@RequiresPermissions("wms:team:list")
	@GetMapping("/list")
	public TableDataInfo list(BaseTeamT baseTeamT) {
		startPage();
		List<BaseTeamT> list = baseTeamTService.selectBaseTeamTList(baseTeamT);
		return getDataTable(list);
	}

	/**
	 * 导出班组列表
	 */
	@RequiresPermissions("wms:team:export")
	@Log(title = "班组", businessType = BusinessType.EXPORT)
	@PostMapping("/export")
	public void export(HttpServletResponse response, BaseTeamT baseTeamT) {
		List<BaseTeamT> list = baseTeamTService.selectBaseTeamTList(baseTeamT);
		ExcelUtil<BaseTeamT> util = new ExcelUtil<BaseTeamT>(BaseTeamT.class);
		util.exportExcel(response, list, "班组数据");
	}

	/**
	 * 获取班组详细信息
	 */
	@RequiresPermissions("wms:team:query")
	@GetMapping(value = "/{teamId}")
	public AjaxResult getInfo(@PathVariable("teamId") String teamId) {
		return success(baseTeamTService.selectBaseTeamTByTeamId(teamId));
	}

	/**
	 * 新增班组
	 */
	@RequiresPermissions("wms:team:add")
	@Log(title = "班组", businessType = BusinessType.INSERT)
	@PostMapping
	public AjaxResult add(@RequestBody BaseTeamT baseTeamT) {
		return toAjax(baseTeamTService.insertBaseTeamT(baseTeamT));
	}

	/**
	 * 修改班组
	 */
	@RequiresPermissions("wms:team:edit")
	@Log(title = "班组", businessType = BusinessType.UPDATE)
	@PutMapping
	public AjaxResult edit(@RequestBody BaseTeamT baseTeamT) {
		return toAjax(baseTeamTService.updateBaseTeamT(baseTeamT));
	}

	/**
	 * 删除班组
	 */
	@RequiresPermissions("wms:team:remove")
	@Log(title = "班组", businessType = BusinessType.DELETE)
	@DeleteMapping("/{teamIds}")
	public AjaxResult remove(@PathVariable String[] teamIds) {
		return toAjax(baseTeamTService.deleteBaseTeamTByTeamIds(teamIds));
	}
}
