package net.lab1024.sa.admin.module.business.wms.shipping.pickDetail.controller;

import net.lab1024.sa.admin.module.business.wms.shipping.pickDetail.domain.form.PickDetailAddForm;
import net.lab1024.sa.admin.module.business.wms.shipping.pickDetail.domain.form.PickDetailQueryForm;
import net.lab1024.sa.admin.module.business.wms.shipping.pickDetail.domain.form.PickDetailUpdateForm;
import net.lab1024.sa.admin.module.business.wms.shipping.pickDetail.domain.vo.PickDetailVO;
import net.lab1024.sa.admin.module.business.wms.shipping.pickDetail.service.PickDetailQueryService;
import net.lab1024.sa.admin.module.business.wms.shipping.pickDetail.service.PickDetailService;
import net.lab1024.sa.base.common.domain.RequestUser;
import net.lab1024.sa.base.common.domain.ValidateList;
import net.lab1024.sa.base.common.util.SmartRequestUtil;
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 2025-01-06 11:04:32
 * @Copyright 友仓
 */

@RestController
@Tag(name = "出库明细")
public class PickDetailController {

    @Resource
    private PickDetailService pickDetailService;

    @Resource
    private PickDetailQueryService pickDetailQueryService;

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

    @Operation(summary = "添加 @author 霍锦")
    @PostMapping("/pickDetail/add")
    @SaCheckPermission("pickDetail:add")
    public ResponseDTO<String> add(@RequestBody @Valid PickDetailAddForm addForm) {
        RequestUser requestUser = SmartRequestUtil.getRequestUser();
        addForm.setCreateUserId(requestUser.getUserId());
        addForm.setCreateUserName(requestUser.getUserName());
        return pickDetailService.add(addForm);
    }

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

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

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