package net.lab1024.sa.admin.module.business.wms.inventory.inventory.controller;

import net.lab1024.sa.admin.module.business.wms.inventory.inventory.domain.form.InventoryAddForm;
import net.lab1024.sa.admin.module.business.wms.inventory.inventory.domain.form.InventoryQueryForm;
import net.lab1024.sa.admin.module.business.wms.inventory.inventory.domain.form.InventoryUpdateForm;
import net.lab1024.sa.admin.module.business.wms.inventory.inventory.domain.vo.InventoryVO;
import net.lab1024.sa.admin.module.business.wms.inventory.inventory.service.InventoryQueryService;
import net.lab1024.sa.admin.module.business.wms.inventory.inventory.service.InventoryService;
import net.lab1024.sa.base.common.domain.ValidateList;
import net.lab1024.sa.base.module.support.operatelog.annotation.OperateLog;
import org.springframework.web.bind.annotation.*;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.PageResult;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import cn.dev33.satoken.annotation.SaCheckPermission;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;

/**
 * 库存信息 Controller
 *
 * @Author 霍锦
 * @Date 2024-12-06 17:24:53
 * @Copyright 友仓
 */

@RestController
@Tag(name = "库存信息")
@OperateLog
public class InventoryController {

    @Resource
    private InventoryService inventoryService;

    @Resource
    private InventoryQueryService inventoryQueryService;

    @Operation(summary = "分页查询 @author 霍锦")
    @PostMapping("/inventory/queryPage")
    @SaCheckPermission("inventory:query")
    public ResponseDTO<PageResult<InventoryVO>> queryPage(@RequestBody @Valid InventoryQueryForm queryForm) {
        return ResponseDTO.ok(inventoryQueryService.queryPage(queryForm));
    }

    @Operation(summary = "添加 @author 霍锦")
    @PostMapping("/inventory/add")
    @SaCheckPermission("inventory:add")
    @OperateLog
    public ResponseDTO<String> add(@RequestBody @Valid InventoryAddForm addForm) {
        return inventoryService.add(addForm);
    }

    @Operation(summary = "更新 @author 霍锦")
    @PostMapping("/inventory/update")
    @SaCheckPermission("inventory:update")
    @OperateLog
    public ResponseDTO<String> update(@RequestBody @Valid InventoryUpdateForm updateForm) {
        return inventoryService.update(updateForm);
    }

    @Operation(summary = "批量删除 @author 霍锦")
    @PostMapping("/inventory/batchDelete")
    @SaCheckPermission("inventory:batchDelete")
    @OperateLog
    public ResponseDTO<String> batchDelete(@RequestBody ValidateList<Long> idList) {
        return inventoryService.batchDelete(idList);
    }

    @Operation(summary = "单个删除 @author 霍锦")
    @GetMapping("/inventory/delete")
    @SaCheckPermission("inventory:delete")
    @OperateLog
    public ResponseDTO<String> delete(@RequestParam Long inventoryId) {
        return inventoryService.delete(inventoryId);
    }
}
