package net.lab1024.sa.admin.module.business.wms.receive.asnDetail.controller;

import net.lab1024.sa.admin.module.business.wms.receive.asnDetail.domain.form.AsnDetailAddForm;
import net.lab1024.sa.admin.module.business.wms.receive.asnDetail.domain.form.AsnDetailQueryForm;
import net.lab1024.sa.admin.module.business.wms.receive.asnDetail.domain.form.AsnDetailUpdateForm;
import net.lab1024.sa.admin.module.business.wms.receive.asnDetail.domain.vo.AsnDetailVO;
import net.lab1024.sa.admin.module.business.wms.receive.asnDetail.service.AsnDetailQueryService;
import net.lab1024.sa.admin.module.business.wms.receive.asnDetail.service.AsnDetailService;
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 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 2025-03-26 15:16:28
 * @Copyright 友仓
 */

@RestController
@Tag(name = "入库明细")
public class AsnDetailController {

    @Resource
    private AsnDetailService asnDetailService;

    @Resource
    private AsnDetailQueryService asnDetailQueryService;



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

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

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

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

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