Search in sources :

Example 1 with TbItemCat

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;
}
Also used : ItemDto(cn.exrick.manager.dto.ItemDto) TbItemCat(cn.exrick.manager.pojo.TbItemCat) TbItemDesc(cn.exrick.manager.pojo.TbItemDesc) TbItem(cn.exrick.manager.pojo.TbItem)

Example 2 with TbItemCat

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;
}
Also used : TbItemCat(cn.exrick.manager.pojo.TbItemCat) ArrayList(java.util.ArrayList) ZTreeNode(cn.exrick.common.pojo.ZTreeNode) TbItemCatExample(cn.exrick.manager.pojo.TbItemCatExample)

Example 3 with TbItemCat

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;
}
Also used : TbItemCat(cn.exrick.manager.pojo.TbItemCat) XmallException(cn.exrick.common.exception.XmallException) Date(java.util.Date)

Example 4 with TbItemCat

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;
}
Also used : TbItemCat(cn.exrick.manager.pojo.TbItemCat) XmallException(cn.exrick.common.exception.XmallException) Date(java.util.Date)

Aggregations

TbItemCat (cn.exrick.manager.pojo.TbItemCat)4 XmallException (cn.exrick.common.exception.XmallException)2 Date (java.util.Date)2 ZTreeNode (cn.exrick.common.pojo.ZTreeNode)1 ItemDto (cn.exrick.manager.dto.ItemDto)1 TbItem (cn.exrick.manager.pojo.TbItem)1 TbItemCatExample (cn.exrick.manager.pojo.TbItemCatExample)1 TbItemDesc (cn.exrick.manager.pojo.TbItemDesc)1 ArrayList (java.util.ArrayList)1