package com.zd.bottle.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zd.bottle.domain.BottleStorageOut;
import com.zd.bottle.service.BottleStorageOutService;
import com.zd.common.core.domain.per.PerFun;
import com.zd.common.core.domain.per.PerPrefix;
import com.zd.common.core.web.domain.ResultData;
import com.zd.common.core.web.page.TableDataInfo;
import com.zd.common.log.annotation.Log;
import com.zd.common.log.enums.BusinessType;
import com.zd.common.security.annotation.PreAuthorize;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.zd.common.core.web.controller.BaseController;
import java.util.List;

/**
 * <p>
 * 气瓶出库表 前端控制器
 * </p>
 *
 * @author hanson
 * @since 2022-09-08
 */
@RestController
@Api(tags = "【出库记录】")
@RequestMapping("/bottleStorageOut")
public class BottleStorageOutController extends BaseController<BottleStorageOut> {

    @Autowired
    private BottleStorageOutService outService;


    /**
     * 查询出库记录列表
     */
    //@PreAuthorize(hasPermi = "bottle:bottleStorageOut:list")
    @PreAuthorize(hasPermi = PerPrefix.BOTTLE_BOTTLESTORAGEOUT+ PerFun.LIST)
    @GetMapping("/list")
    @ApiOperation(value = "查询出库记录列表")
    public TableDataInfo<BottleStorageOut> list(BottleStorageOut bottleStorage) {
        List<BottleStorageOut> list = outService.list(new LambdaQueryWrapper<>(bottleStorage));
        return getDataTable(list);
    }

    /**
     * 出库修改
     * @param bottleStorage 参数实体
     * @return Boolean
     */
    @ApiOperation(value = "出库修改")
    //@PreAuthorize(hasPermi = "bottle:bottleStorageOut:edit")
    @PreAuthorize(hasPermi = PerPrefix.BOTTLE_BOTTLESTORAGEOUT+ PerFun.EDIT)
    @Log(title = "出库修改", businessType = BusinessType.UPDATE)
    @PutMapping
    public ResultData<Boolean> edit(@RequestBody BottleStorageOut bottleStorage) {
        return ResultData.result(outService.updateById(bottleStorage));
    }

    /**
     * 新增出库
     * @param bottleStorageOut 参数实体
     * @return Boolean
     */
    @ApiOperation(value = "新增出库")
    @PreAuthorize(hasPermi = PerPrefix.BOTTLE_BOTTLESTORAGEOUT+ PerFun.ADD)
    @Log(title = "新增出库", businessType = BusinessType.INSERT)
    @PostMapping
    public ResultData<Boolean> add(@RequestBody BottleStorageOut bottleStorageOut) {
        // storageId  入库表id
        // pressure 出库气压
        return ResultData.result(outService.add(bottleStorageOut));
    }
}
