use of cn.exrick.manager.pojo.TbItemCat in project xmall by Exrick.
the class ItemServiceImpl method getItemById.
@Override
public ItemDto getItemById(Long id) {
ItemDto itemDto = new ItemDto();
TbItem tbItem = tbItemMapper.selectByPrimaryKey(id);
itemDto = DtoUtil.TbItem2ItemDto(tbItem);
TbItemCat tbItemCat = tbItemCatMapper.selectByPrimaryKey(itemDto.getCid());
itemDto.setCname(tbItemCat.getName());
TbItemDesc tbItemDesc = tbItemDescMapper.selectByPrimaryKey(id);
itemDto.setDetail(tbItemDesc.getItemDesc());
return itemDto;
}
use of cn.exrick.manager.pojo.TbItemCat in project xmall by Exrick.
the class ItemCatServiceImpl method getItemCatList.
@Override
public List<ZTreeNode> getItemCatList(int parentId) {
TbItemCatExample example = new TbItemCatExample();
TbItemCatExample.Criteria criteria = example.createCriteria();
// 排序
example.setOrderByClause("sort_order");
// 条件查询
criteria.andParentIdEqualTo(new Long(parentId));
List<TbItemCat> list = tbItemCatMapper.selectByExample(example);
// 转换成ZtreeNode
List<ZTreeNode> resultList = new ArrayList<>();
for (TbItemCat tbItemCat : list) {
ZTreeNode node = DtoUtil.TbItemCat2ZTreeNode(tbItemCat);
resultList.add(node);
}
return resultList;
}
use of cn.exrick.manager.pojo.TbItemCat in project xmall by Exrick.
the class ItemCatServiceImpl method updateItemCat.
@Override
public int updateItemCat(TbItemCat tbItemCat) {
TbItemCat old = getItemCatById(tbItemCat.getId());
tbItemCat.setCreated(old.getCreated());
tbItemCat.setUpdated(new Date());
if (tbItemCatMapper.updateByPrimaryKey(tbItemCat) != 1) {
throw new XmallException("添加商品分类失败");
}
return 1;
}
use of cn.exrick.manager.pojo.TbItemCat in project xmall by Exrick.
the class ItemCatServiceImpl method addItemCat.
@Override
public int addItemCat(TbItemCat tbItemCat) {
if (tbItemCat.getParentId() == 0) {
// 根节点
tbItemCat.setSortOrder(0);
tbItemCat.setStatus(1);
} else {
TbItemCat parent = tbItemCatMapper.selectByPrimaryKey(tbItemCat.getParentId());
tbItemCat.setSortOrder(0);
tbItemCat.setStatus(1);
tbItemCat.setCreated(new Date());
tbItemCat.setUpdated(new Date());
}
if (tbItemCatMapper.insert(tbItemCat) != 1) {
throw new XmallException("添加商品分类失败");
}
return 1;
}
Aggregations