use of cn.exrick.manager.pojo.TbPanelExample 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;
}
use of cn.exrick.manager.pojo.TbPanelExample 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;
}
Aggregations