package com.pj.tb_goods_type;

import com.pj.utils.sg.AjaxJson;
import com.pj.utils.so.SoMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;



@RestController
@RequestMapping("/app/TbGoodsType/")
public class TbGoodsTypeAppController {

	@Autowired
	TbGoodsTypeService tbGoodsTypeService;

	/** 查集合 (整个表数据转化为tree结构返回) */
	@RequestMapping("getTree")
	public AjaxJson getTree() { 
		// 获取记录 
		SoMap so = SoMap.getRequestSoMap();
		List<TbGoodsType> list = tbGoodsTypeService.getList(so);
		// 转为tree结构，并返回 
		List<SoMap> listMap = SoMap.getSoMapByList(list);
		List<SoMap> listTree = SoMap.listToTree(listMap, "id", "parentId", "children");
		return AjaxJson.getSuccessData(listTree);
	}

}
