package com.bonus.sgzb.base.controller;

import com.bonus.sgzb.base.domain.MaintenanceGang;
import com.bonus.sgzb.base.service.MaintenanceGangService;
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/maintenanceGang")
public class MaintenanceGangController extends BaseController {
    @Autowired
    private MaintenanceGangService warehouseKeeperService;

    /**
     * 获取维修班配置列表
     */
    @ApiOperation(value = "获取维修班配置列表")
    @GetMapping("/maintenanceGangInfoAll")
    public TableDataInfo getMaintenanceGangInfoAll(MaintenanceGang bean)
    {
        startPage();
        List<MaintenanceGang> list = warehouseKeeperService.getMaintenanceGangInfoAll(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 MaintenanceGang bean)
    {
        return toAjax(warehouseKeeperService.add(bean));
    }

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