package org.dromara.erp.controller;

import lombok.RequiredArgsConstructor;
import org.dromara.common.core.domain.R;
import org.dromara.erp.domain.query.ErpModelQuery;
import org.dromara.erp.domain.vo.ErpModelVo;
import org.dromara.erp.service.IErpModelService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * ERP 型材档案控制器
 *
 * @Author: Antigravity
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/erp/model")
public class ErpModelController {

    private final IErpModelService erpModelService;

    /**
     * 查询型材列表（按父级ID分级）
     * parentRowId 为空时查询第一级（parentRowId IS NULL），非空时查询下级
     * @Author: Trae
     */
    @GetMapping("/list")
    public R<List<ErpModelVo>> list(ErpModelQuery query) {
        return R.ok(erpModelService.queryList(query));
    }

}
