package com.bonus.sgzb.base.controller;

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 org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 库管员配置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));
    }

}

