package com.bonus.sgzb.base.controller;

import com.bonus.sgzb.base.domain.MaHouseSet;
import com.bonus.sgzb.base.service.MaHouseSetService;
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 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;

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

    @Autowired
    private MaHouseSetService maHouseSetService;


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

    /**
     * 获取仓库货架配置详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(maHouseSetService.selectMaHouseSetByHouseId(id));
    }

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

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

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

}
