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.damain.MaHouse;
import com.bonus.sgzb.machine.damain.MaHouseSet;
import com.bonus.sgzb.machine.damain.MaMachine;
import com.bonus.sgzb.machine.service.MaHouseSetService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 仓库货架配置
 */
@RestController
@RequestMapping("/houseSet")
public class MaHouseSetController extends BaseController {

    @Autowired
    private MaHouseSetService maHouseSetService;


    /**
     * 查询仓库货架配置
     * @param maHouseSet
     * @return
     */
    @GetMapping("/getHouseSet")
    public TableDataInfo getHouseSet(MaHouseSet maHouseSet)
    {
        startPage();
        List<MaHouse> list = maHouseSetService.getHouseSetList(maHouseSet);
        return getDataTable(list);
    }

    /**
     * 新增仓库货架配置
     */
    @PostMapping
    public AjaxResult maHouseSeteAdd(@Validated @RequestBody MaHouseSet maHouseSet)
    {
        return toAjax(maHouseSetService.maHouseSetAdd(maHouseSet));
    }

    /**
     * 删除仓库货架配置
     */
    @DeleteMapping("/{houseId}")
    public AjaxResult remove(@PathVariable Long houseId)
    {
        maHouseSetService.deleteHouseSetById(houseId);
        return success();
    }
    /**
     * 修改仓库货架配置
     */
    @PutMapping
    public AjaxResult updateHouseSet(@Validated @RequestBody MaHouseSet maHouseSet)
    {

        return toAjax(maHouseSetService.updateHouseSet(maHouseSet));
    }

}
