use of cn.exrick.manager.pojo.TbItem in project xmall by Exrick.
the class ItemServiceImpl method addItem.
@Override
public TbItem addItem(ItemDto itemDto) {
long id = IDUtil.getRandomId();
TbItem tbItem = DtoUtil.ItemDto2TbItem(itemDto);
tbItem.setId(id);
tbItem.setStatus((byte) 1);
tbItem.setCreated(new Date());
tbItem.setUpdated(new Date());
if (tbItem.getImage().isEmpty()) {
tbItem.setImage("http://ow2h3ee9w.bkt.clouddn.com/nopic.jpg");
}
if (tbItemMapper.insert(tbItem) != 1) {
throw new XmallException("添加商品失败");
}
TbItemDesc tbItemDesc = new TbItemDesc();
tbItemDesc.setItemId(id);
tbItemDesc.setItemDesc(itemDto.getDetail());
tbItemDesc.setCreated(new Date());
tbItemDesc.setUpdated(new Date());
if (tbItemDescMapper.insert(tbItemDesc) != 1) {
throw new XmallException("添加商品详情失败");
}
// 发送消息同步索引库
sendRefreshESMessage("add", id);
return getNormalItemById(id);
}
use of cn.exrick.manager.pojo.TbItem in project xmall by Exrick.
the class ItemServiceImpl method getItemList.
@Override
public DataTablesResult getItemList(int draw, int start, int length, int cid, String search, String orderCol, String orderDir) {
DataTablesResult result = new DataTablesResult();
// 分页执行查询返回结果
PageHelper.startPage(start / length + 1, length);
List<TbItem> list = tbItemMapper.selectItemByCondition(cid, "%" + search + "%", orderCol, orderDir);
PageInfo<TbItem> pageInfo = new PageInfo<>(list);
result.setRecordsFiltered((int) pageInfo.getTotal());
result.setRecordsTotal(getAllItemCount().getRecordsTotal());
result.setDraw(draw);
result.setData(list);
return result;
}
Aggregations