package com.xindazhou.vehicle.service.archive;

import com.xindazhou.vehicle.controller.admin.vehicle.vo.CategoryModelCascaderRespVO;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;

import java.util.ArrayList;
import java.util.List;

/**
 * 分类和型号级联数据 Service 实现类
 *
 * @author xindazhou
 */
@Service
@Validated
public class VehicleCategoryModelServiceImpl implements VehicleCategoryModelService {

    // TODO: 注入分类和型号的Mapper，从数据库查询
    // @Resource
    // private VehicleCategoryMapper vehicleCategoryMapper;
    // @Resource
    // private VehicleModelMapper vehicleModelMapper;

    @Override
    public List<CategoryModelCascaderRespVO> getCategoryModelCascader() {
        // TODO: 从数据库查询分类和型号数据，组装成级联结构
        // 目前返回模拟数据
        List<CategoryModelCascaderRespVO> result = new ArrayList<>();
        
        // 模拟数据 - 使用setter方法
        CategoryModelCascaderRespVO category1 = new CategoryModelCascaderRespVO();
        category1.setValue("category1");
        category1.setLabel("分类1");
        List<CategoryModelCascaderRespVO> models1 = new ArrayList<>();
        CategoryModelCascaderRespVO model1 = new CategoryModelCascaderRespVO();
        model1.setValue("model1");
        model1.setLabel("型号A");
        models1.add(model1);
        CategoryModelCascaderRespVO model2 = new CategoryModelCascaderRespVO();
        model2.setValue("model2");
        model2.setLabel("型号B");
        models1.add(model2);
        category1.setChildren(models1);
        result.add(category1);

        CategoryModelCascaderRespVO category2 = new CategoryModelCascaderRespVO();
        category2.setValue("category2");
        category2.setLabel("分类2");
        List<CategoryModelCascaderRespVO> models2 = new ArrayList<>();
        CategoryModelCascaderRespVO model3 = new CategoryModelCascaderRespVO();
        model3.setValue("model3");
        model3.setLabel("型号C");
        models2.add(model3);
        category2.setChildren(models2);
        result.add(category2);

        return result;
    }

}

