package com.bonus.sgzb.machine.controller;

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.machine.service.ITypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 工机具类型管理控制层
 */
@RestController
@RequestMapping("/type")
public class MaTypeController extends BaseController {


    @Autowired
    private ITypeService iTypeService;

    /**
     * 根据类型名称查询类型
     * @return
     */
    @GetMapping("/getMaTypeList")
    public AjaxResult getMaTypeList(String typeName){

        return AjaxResult.success(iTypeService.getMaTypeList(typeName));

    }

    /**
     * 根据左列表类型id查询右表格
     * @param typeId
     * @return
     */
    @GetMapping("/getListByMaType/{typeId}/{typeName}")
    public TableDataInfo getListByMaType(@PathVariable("typeId") Long typeId,@PathVariable("typeName") String typeName){

        if(typeId==null){
            return null;
        }
        startPage();
        return getDataTable(iTypeService.getListByMaType(typeId,typeName));
    }


}
