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

import net.lab1024.sa.admin.module.business.wms.inventory.itemKey.domain.form.ItemKeyAddForm;
import net.lab1024.sa.admin.module.business.wms.inventory.itemKey.domain.form.ItemKeyQueryForm;
import net.lab1024.sa.admin.module.business.wms.inventory.itemKey.domain.form.ItemKeyUpdateForm;
import net.lab1024.sa.admin.module.business.wms.inventory.itemKey.domain.vo.ItemKeyVO;
import net.lab1024.sa.admin.module.business.wms.inventory.itemKey.service.ItemKeyQueryService;
import net.lab1024.sa.admin.module.business.wms.inventory.itemKey.service.ItemKeyService;
import net.lab1024.sa.base.common.domain.ValidateList;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.PageResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
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-05 21:38:40
 * @Copyright 友仓
 */

@RestController
@Tag(name = "物料属性")
public class ItemKeyController {

    @Resource
    private ItemKeyService itemKeyService;

    @Resource
    private ItemKeyQueryService itemKeyQueryService;

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

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

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

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

    @Operation(summary = "单个删除 @author 霍锦")
    @GetMapping("/itemKey/delete/{itemKeyId}")
    @SaCheckPermission("itemKey:delete")
    public ResponseDTO<String> batchDelete(@PathVariable Long itemKeyId) {
        return itemKeyService.delete(itemKeyId);
    }
}
