package com.bonus.material.warehouse.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.bonus.common.log.enums.OperaType;
import com.bonus.material.common.annotation.PreventRepeatSubmit;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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.bonus.common.log.annotation.SysLog;
import com.bonus.common.security.annotation.RequiresPermissions;
import com.bonus.material.warehouse.domain.WhTeamLeaseInfo;
import com.bonus.material.warehouse.service.IWhTeamLeaseInfoService;
import com.bonus.common.core.web.controller.BaseController;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.common.core.utils.poi.ExcelUtil;
import com.bonus.common.core.web.page.TableDataInfo;

/**
 * 二级库租赁信息Controller
 * 
 * @author xsheng
 * @date 2024-09-27
 */
@Api(tags = "二级库租赁信息接口")
@RestController
@RequestMapping("/wh_team_lease_info")
public class WhTeamLeaseInfoController extends BaseController
{
    @Autowired
    private IWhTeamLeaseInfoService whTeamLeaseInfoService;

    /**
     * 查询二级库租赁信息列表
     */
    @ApiOperation(value = "查询二级库租赁信息列表")
    @RequiresPermissions("warehouse:info:list")
    @GetMapping("/list")
    public TableDataInfo list(WhTeamLeaseInfo whTeamLeaseInfo)
    {
        startPage();
        List<WhTeamLeaseInfo> list = whTeamLeaseInfoService.selectWhTeamLeaseInfoList(whTeamLeaseInfo);
        return getDataTable(list);
    }

    /**
     * 导出二级库租赁信息列表
     */
    @ApiOperation(value = "导出二级库租赁信息列表")
    @PreventRepeatSubmit
    @RequiresPermissions("warehouse:info:export")
    @SysLog(title = "二级库租赁信息", businessType = OperaType.EXPORT, logType = 1,module = "仓储管理->导出二级库租赁信息")
    @PostMapping("/export")
    public void export(HttpServletResponse response, WhTeamLeaseInfo whTeamLeaseInfo)
    {
        List<WhTeamLeaseInfo> list = whTeamLeaseInfoService.selectWhTeamLeaseInfoList(whTeamLeaseInfo);
        ExcelUtil<WhTeamLeaseInfo> util = new ExcelUtil<WhTeamLeaseInfo>(WhTeamLeaseInfo.class);
        util.exportExcel(response, list, "二级库租赁信息数据");
    }

    /**
     * 获取二级库租赁信息详细信息
     */
    @ApiOperation(value = "获取二级库租赁信息详细信息")
    @RequiresPermissions("warehouse:info:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(whTeamLeaseInfoService.selectWhTeamLeaseInfoById(id));
    }

    /**
     * 新增二级库租赁信息
     */
    @ApiOperation(value = "新增二级库租赁信息")
    @PreventRepeatSubmit
    @RequiresPermissions("warehouse:info:add")
    @SysLog(title = "二级库租赁信息", businessType = OperaType.INSERT, logType = 1,module = "仓储管理->新增二级库租赁信息")
    @PostMapping
    public AjaxResult add(@RequestBody WhTeamLeaseInfo whTeamLeaseInfo)
    {
        return toAjax(whTeamLeaseInfoService.insertWhTeamLeaseInfo(whTeamLeaseInfo));
    }

    /**
     * 修改二级库租赁信息
     */
    @ApiOperation(value = "修改二级库租赁信息")
    @PreventRepeatSubmit
    @RequiresPermissions("warehouse:info:edit")
    @SysLog(title = "二级库租赁信息", businessType = OperaType.UPDATE, logType = 1,module = "仓储管理->修改二级库租赁信息")
    @PutMapping
    public AjaxResult edit(@RequestBody WhTeamLeaseInfo whTeamLeaseInfo)
    {
        return toAjax(whTeamLeaseInfoService.updateWhTeamLeaseInfo(whTeamLeaseInfo));
    }

    /**
     * 删除二级库租赁信息
     */
    @ApiOperation(value = "删除二级库租赁信息")
    @PreventRepeatSubmit
    @RequiresPermissions("warehouse:info:remove")
    @SysLog(title = "二级库租赁信息", businessType = OperaType.DELETE, logType = 1,module = "仓储管理->删除二级库租赁信息")
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(whTeamLeaseInfoService.deleteWhTeamLeaseInfoByIds(ids));
    }
}
