<?php

namespace Scm_product\Lib;

use Dever;

class Spec
{
    # 获取当前的规格
    public function get_api()
    {
    	$id = Dever::input('id');
    	return $this->getData($id);
    }

    # 获取基本信息列表
    public function getData($info_id, $method = 'getAll')
    {
        $result = array();
    	if ($info_id) {
    		$result = Dever::db('scm_product/info_spec')->$method(array('info_id' => $info_id));
    		if ($result) {
    			foreach ($result as $k => $v) {
    				$result[$k]['child'] = Dever::db('scm_product/info_spec_value')->$method(array('info_id' => $info_id, 'spec_id' => $v['id']));
    			}
    		}
    	}
    	return $result;
    }
}