use of cn.exrick.common.exception.XmallException in project xmall by Exrick.
the class ContentServiceImpl method addPanelContent.
@Override
public int addPanelContent(TbPanelContent tbPanelContent) {
tbPanelContent.setCreated(new Date());
tbPanelContent.setUpdated(new Date());
if (tbPanelContentMapper.insert(tbPanelContent) != 1) {
throw new XmallException("添加首页板块内容失败");
}
// 同步导航栏缓存
if (tbPanelContent.getPanelId() == HEADER_PANEL_ID) {
updateNavListRedis();
}
// 同步缓存
deleteHomeRedis();
return 1;
}
use of cn.exrick.common.exception.XmallException 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("添加商品详情失败");
}
// 发送消息同步索引库
try {
sendRefreshESMessage("add", id);
} catch (Exception e) {
log.error("同步索引出错");
}
return getNormalItemById(id);
}
use of cn.exrick.common.exception.XmallException in project xmall by Exrick.
the class ThanksServiceImpl method getThanksListByPage.
@Override
public DataTablesResult getThanksListByPage(int page, int size) {
DataTablesResult result = new DataTablesResult();
TbThanksExample example = new TbThanksExample();
if (page <= 0) {
page = 1;
}
PageHelper.startPage(page, size);
List<TbThanks> list = tbThanksMapper.selectByExample(example);
if (list == null) {
throw new XmallException("获取捐赠列表失败");
}
PageInfo<TbThanks> pageInfo = new PageInfo<>(list);
for (TbThanks tbThanks : list) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String date = null;
try {
date = dateFormat.format(tbThanks.getDate());
} catch (Exception e) {
e.printStackTrace();
}
tbThanks.setTime(date);
tbThanks.setEmail(null);
}
result.setSuccess(true);
result.setRecordsTotal((int) pageInfo.getTotal());
result.setData(list);
return result;
}
use of cn.exrick.common.exception.XmallException in project xmall by Exrick.
the class ThanksServiceImpl method addThanks.
@Override
public int addThanks(TbThanks tbThanks) {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = null;
try {
date = format.parse(tbThanks.getTime());
} catch (ParseException e) {
e.printStackTrace();
}
tbThanks.setDate(date);
if (tbThanksMapper.insert(tbThanks) != 1) {
throw new XmallException("添加捐赠失败");
}
return 1;
}
use of cn.exrick.common.exception.XmallException in project xmall by Exrick.
the class ThanksServiceImpl method updateThanks.
@Override
public int updateThanks(TbThanks tbThanks) {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = null;
try {
date = format.parse(tbThanks.getTime());
} catch (ParseException e) {
e.printStackTrace();
}
tbThanks.setDate(date);
if (tbThanksMapper.updateByPrimaryKey(tbThanks) != 1) {
throw new XmallException("更新捐赠失败");
}
return 1;
}
Aggregations