package com.bonus.sgzb.base.controller;

import com.bonus.sgzb.base.domain.MaKeeperUser;
import com.bonus.sgzb.base.service.IMaTypeKeeperService;
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.system.api.domain.SysDept;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 库管员配置ma_type_keeper(MaTypeKeeper)表控制层
 *
 * @author makejava
 * @since 2023-11-28 15:34:00
 */
@RestController
@RequestMapping("/base/maTypeKeeper")
public class MaTypeKeeperController  extends BaseController {
    /**
     * 服务对象
     */
    @Autowired
    private IMaTypeKeeperService maTypeKeeperService;

    /**
     * 根据人员名称查询左侧列表
     * @param userName
     * @return
     */
    @GetMapping("/getMaUserList")
    public AjaxResult getMaUserList(String userName){

        return AjaxResult.success(maTypeKeeperService.getMaUserList(userName));
    }

    /**
     * 根据userId查询右侧列表
     * @param userId
     * @param typeName
     * @return
     */
    @GetMapping("/getListByMaType/{userId}/{typeName}")
    public TableDataInfo getListByMaType(@PathVariable("userId") Long userId, @PathVariable("typeName") String typeName) {

        if (userId == null) {
            return null;
        }
        startPage();
        return getDataTable(maTypeKeeperService.getListByMaType(userId, typeName));
    }

    @ApiOperation(value = "查询库管员信息")
    @PostMapping("/getMaTypeKeeper")
    public AjaxResult getMaTypeKeeper(@RequestBody String sysDept){
        List<MaKeeperUser> maTypeList = maTypeKeeperService.getMaTypeKeeper(sysDept);
        return AjaxResult.success(maTypeList);
    }

    @ApiOperation(value = "查询公司信息")
    @PostMapping("/getEnterprise")
    public AjaxResult getEnterprise(@RequestBody String sysDept){
        SysDept sysDeptRes = maTypeKeeperService.getEnterprise(sysDept);
        return AjaxResult.success(sysDeptRes);
    }
}

