package com.ruoyi.system.controller;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.domain.ActSupplies;
import com.ruoyi.system.domain.ActSuppliesMaterialDetails;
import com.ruoyi.system.domain.ActSuppliesMaterialInfo;
import com.ruoyi.system.service.ActSuppliesMaterialService;
import com.ruoyi.system.service.impl.ActSuppliesServiceImpl;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author haiwe
 * @date 2024/7/8
 */
@RestController
@RequestMapping("/asmInfo")
@RequiredArgsConstructor
public class ActSuppliesMaterialController {

    private final ActSuppliesMaterialService actSuppliesMaterialService;

    @PostMapping("/save")
    public AjaxResult saveInfo(@RequestBody ActSuppliesMaterialInfo actSuppliesMaterialInfo){
        //System.out.println(actSuppliesMaterialInfo);
        List<ActSuppliesMaterialDetails> materials = actSuppliesMaterialInfo.getMaterials();

        Boolean saved = actSuppliesMaterialService.save(materials);
        if (!saved) {
            return AjaxResult.error("插入失败，请重新尝试");
        }
        return AjaxResult.success();
    }

}
