package com.bonus.sgzb.base.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.common.security.utils.SecurityUtils;
import com.bonus.sgzb.base.domain.MaHouseShel;
import com.bonus.sgzb.base.service.MaHouseShelService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
* MaHouseShelController
* @Author dingjie
* @Date 2023-12-07
**/
@Api("仓库货架管理Controller")
@RestController
@RequestMapping("/houseShel")
public class MaHouseShelController extends BaseController {

    @Autowired
    private MaHouseShelService houseShelService;


    /**
     * 查询仓库货架列表
     * @param houseShel 货架信息
     * @return
     */
    @GetMapping("/list")
    public TableDataInfo list(MaHouseShel houseShel)
    {
        startPage();
        List<MaHouseShel> list = houseShelService.selectHouseShelList(houseShel);
        return getDataTable(list);
    }

    /**
     * 新增仓库货架
     */
    @PostMapping
    public AjaxResult add(@Validated @RequestBody MaHouseShel houseShel){
//        if (!houseShelService.checkHouseNameUnique(houseShel)) {
//            return error("新增仓库货架名称'" + houseShel.getShelveName() + "'失败，仓库货架名称已存在");
//        }
        houseShel.setCreateBy(SecurityUtils.getUsername());
        return toAjax(houseShelService.insertHouseShel(houseShel));
    }

}