Search in sources :

Example 1 with TbPanel

use of cn.exrick.manager.pojo.TbPanel in project xmall by Exrick.

the class PanelServiceImpl method getPanelList.

@Override
public List<ZTreeNode> getPanelList(int position, boolean showAll) {
    TbPanelExample example = new TbPanelExample();
    TbPanelExample.Criteria criteria = example.createCriteria();
    if (position == 0 && !showAll) {
        // 除去非轮播
        criteria.andTypeNotEqualTo(0);
    } else if (position == -1) {
        // 仅含轮播
        position = 0;
        criteria.andTypeEqualTo(0);
    }
    // 首页板块
    criteria.andPositionEqualTo(position);
    example.setOrderByClause("sort_order");
    List<TbPanel> panelList = tbPanelMapper.selectByExample(example);
    List<ZTreeNode> list = new ArrayList<>();
    for (TbPanel tbPanel : panelList) {
        ZTreeNode zTreeNode = DtoUtil.TbPanel2ZTreeNode(tbPanel);
        list.add(zTreeNode);
    }
    return list;
}
Also used : TbPanelExample(cn.exrick.manager.pojo.TbPanelExample) ArrayList(java.util.ArrayList) ZTreeNode(cn.exrick.common.pojo.ZTreeNode) TbPanel(cn.exrick.manager.pojo.TbPanel)

Example 2 with TbPanel

use of cn.exrick.manager.pojo.TbPanel in project xmall by Exrick.

the class PanelServiceImpl method updatePanel.

@Override
public int updatePanel(TbPanel tbPanel) {
    TbPanel old = getTbPanelById(tbPanel.getId());
    tbPanel.setUpdated(new Date());
    if (tbPanelMapper.updateByPrimaryKey(tbPanel) != 1) {
        throw new XmallException("更新板块失败");
    }
    // 同步缓存
    deleteHomeRedis();
    return 1;
}
Also used : XmallException(cn.exrick.common.exception.XmallException) TbPanel(cn.exrick.manager.pojo.TbPanel) Date(java.util.Date)

Example 3 with TbPanel

use of cn.exrick.manager.pojo.TbPanel in project xmall by Exrick.

the class PanelServiceImpl method addPanel.

@Override
public int addPanel(TbPanel tbPanel) {
    if (tbPanel.getType() == 0) {
        TbPanelExample example = new TbPanelExample();
        TbPanelExample.Criteria criteria = example.createCriteria();
        criteria.andTypeEqualTo(0);
        List<TbPanel> list = tbPanelMapper.selectByExample(example);
        if (list != null && list.size() > 0) {
            throw new XmallException("已有轮播图板块,轮播图仅能添加1个!");
        }
    }
    tbPanel.setCreated(new Date());
    tbPanel.setUpdated(new Date());
    if (tbPanelMapper.insert(tbPanel) != 1) {
        throw new XmallException("添加板块失败");
    }
    // 同步缓存
    deleteHomeRedis();
    return 1;
}
Also used : TbPanelExample(cn.exrick.manager.pojo.TbPanelExample) XmallException(cn.exrick.common.exception.XmallException) TbPanel(cn.exrick.manager.pojo.TbPanel) Date(java.util.Date)

Aggregations

TbPanel (cn.exrick.manager.pojo.TbPanel)3 XmallException (cn.exrick.common.exception.XmallException)2 TbPanelExample (cn.exrick.manager.pojo.TbPanelExample)2 Date (java.util.Date)2 ZTreeNode (cn.exrick.common.pojo.ZTreeNode)1 ArrayList (java.util.ArrayList)1