package com.bonus.sgzb.base.controller;

import com.bonus.sgzb.base.domain.WarehouseKeeper;
import com.bonus.sgzb.base.service.WarehouseKeeperService;
import com.bonus.sgzb.common.core.web.controller.BaseController;
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
import com.bonus.sgzb.common.core.web.page.TableDataInfo;
import com.bonus.sgzb.common.log.annotation.Log;
import com.bonus.sgzb.common.log.enums.BusinessType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author lsun
 */
@Api(tags = "库管员配置")
@RestController
@RequestMapping("/base/maWarehouseKeeper")
public class WarehouseKeeperController extends BaseController {
    @Autowired
    private WarehouseKeeperService warehouseKeeperService;

    /**
     * 获取库管员配置列表
     */
    @ApiOperation(value = "获取库管员配置列表")
    @GetMapping("/warehouseKeeperInfoAll")
    public TableDataInfo getWarehouseKeeperInfoAll(WarehouseKeeper bean)
    {
        startPage();
        List<WarehouseKeeper> list = warehouseKeeperService.getWarehouseKeeperInfoAll(bean);
        return getDataTable(list);
    }


    /**
     * 库管员配置-根据人员名称查询左侧列表
     * @param userName
     * @return
     */
    @ApiOperation(value = "库管员配置-根据人员名称查询左侧列表")
    @GetMapping("/getMaUserList")
    public AjaxResult getMaUserList(String userName){
        return AjaxResult.success(warehouseKeeperService.getMaUserList(userName));
    }
    @ApiOperation("库管员配置-保存")
    @Log(title = "库管员配置-保存", businessType = BusinessType.INSERT)
    @PostMapping("/addList")
    public AjaxResult add(@Validated @RequestBody WarehouseKeeper bean)
    {
        return toAjax(warehouseKeeperService.add(bean));
    }

    /**
     * 删除库管员配置
     */
    @ApiOperation(value = "库管员配置-删除")
    @PostMapping("/remove")
    public AjaxResult remove(@Validated @RequestBody WarehouseKeeper bean )
    {
        return toAjax(warehouseKeeperService.deleteByIds(bean));
    }

}
