package com.prolog.upcloud.base.wh.operate.controller;

import com.prolog.framework.common.message.RestMessage;
import com.prolog.framework.log.aop.annotation.UserLog;
import com.prolog.upcloud.base.wh.operate.dto.LockStockDTO;
import com.prolog.upcloud.base.wh.operate.dto.UnLockStockDTO;
import com.prolog.upcloud.base.wh.operate.service.InvStockLockService;
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;

import static com.prolog.framework.common.message.RestMessage.success;

@Api(tags = "库存锁定")
@RestController
@RequestMapping("invstocklock")
@Validated
public class InvStockLockController {

    @Autowired
    private InvStockLockService invStockLockService;

    @UserLog
    @ApiOperation(value = "自动锁定定时任务")
    @GetMapping("/autoStockInfo")
    public RestMessage autoStockInfo(String enterpriseid, String warehouseid){
        invStockLockService.autoStockInfo(enterpriseid,warehouseid);
        return success("操作成功", null);
    }

    @UserLog
    @ApiOperation(value = "锁定库存")
    @PostMapping("/lockStockInfo")
    public RestMessage lockStockInfo(@RequestBody  List<LockStockDTO> dtos){
        invStockLockService.lockStockInfo(dtos);
        return success("操作成功", null);
    }

    @UserLog
    @ApiOperation(value = "解锁库存")
    @PostMapping("/unlockStockInfo")
    public RestMessage unlockStockInfo(@RequestBody  UnLockStockDTO dto){
        invStockLockService.unlockStockInfo(dto);
        return  success("操作成功", null);
    }

}
