admin 管理员组

文章数量: 887018


2023年12月17日发(作者:html中id和class的区别)

2.3.2. Service

@Servicepublic class ItemServiceImplimplements ItemService {

@Autowiredprivate TbItemMapperitemMapper;@Autowiredprivate TbItemDescMapperitemDescMapper;@Autowiredprivate TbItemParamItemMapperitemParamItemMapper;/** * 根据id取商品信息 *

Title: getItemById

*

Description:

* @param id * @return * @throws Exception * @see rvice#getItemById() */@Overridepublic TbItem getItemById(Longid) throws Exception {TbItem tbItem = ByPrimaryKey(id);return tbItem;}

/** * 根据id取商品描述 *

Title: getItemDescById

*

Description:

* @param id * @return * @throws Exception * @see rvice#getItemDescById() */@Overridepublic TbItemDesc getItemDescById(Longid) throws Exception {TbItemDesc itemDesc = ByPrimaryKey(id);return itemDesc;}

/** * 根据商品id取规格参数 *

Title: getItemParamById

*

Description:

* @param id * @return * @throws Exception * @see rvice#getItemParamById() */@Overridepublic TbItemParamItem getItemParamById(Longid) throws Exception {TbItemParamItemExample example = new TbItemParamItemExample();Criteria criteria =Criteria();mIdEqualTo(id);List list = ByExampleWithBLOBs(example);TbItemParamItem itemParamItem = null;if (null !=null && !y()) {itemParamItem = (0);}return itemParamItem;}

}

2.3.3. Controller

private String ITEMS_ITEMDESC_URL;@Value("${ITEMS_ITEMPARAM_URL}")private String ITEMS_ITEMPARAM_URL;

@Overridepublic Item getItemById(Longid) throws Exception {// 查询商品信息String result = (REST_BASE_URL +ITEMS_ITEM_URL + id);// 转换成java对象TaotaoResult taotaoResult = ToPojo(result,);Item item =null;if (tus() == 200) {item = (Item)a();}

return item;}

@Overridepublic TbItemDesc geTbItemDescById(Longid) throws Exception {// 查询商品信息String result = (REST_BASE_URL +ITEMS_ITEMDESC_URL + id);// 转换成java对象TaotaoResult taotaoResult = ToPojo(result, );TbItemDesc itemDesc = null;if (tus() == 200) {itemDesc = (TbItemDesc) a();}

return itemDesc;}

@Overridepublic String geTbItemParamItemById(Longid) throws Exception {// 查询商品信息String result = (REST_BASE_URL +ITEMS_ITEMPARAM_URL + id);// 转换成java对象TaotaoResult taotaoResult = ToPojo(result, );String resultHtml = "";if (tus() == 200) {try {TbItemParamItem itemParamItem = (TbItemParamItem)a();//取规格参数信息String paramData = amData();//把规格参数转换成java对象List paramList = List(paramData, );//拼装htmlresultHtml ="

n" +" n";for (Map map :paramList) {resultHtml +=" n" +" n" +" n";List params = (List)("params");for (Map map2 :params) {resultHtml +=" n" +" n" +" n" +" n" ;}}resultHtml += " n" +"
"+("group")+"
"+("k")+""+("v")+"
";} catch (Exception e){


本文标签: 规格 参数 商品 对象 描述