Search in sources :

Example 46 with XmallException

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

Example 47 with XmallException

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

Example 48 with XmallException

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;
}
Also used : PageInfo(com.github.pagehelper.PageInfo) TbThanks(cn.exrick.manager.pojo.TbThanks) DataTablesResult(cn.exrick.common.pojo.DataTablesResult) TbThanksExample(cn.exrick.manager.pojo.TbThanksExample) XmallException(cn.exrick.common.exception.XmallException) SimpleDateFormat(java.text.SimpleDateFormat) XmallException(cn.exrick.common.exception.XmallException) ParseException(java.text.ParseException)

Example 49 with XmallException

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

Example 50 with XmallException

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

Aggregations

XmallException (cn.exrick.common.exception.XmallException)52 Date (java.util.Date)26 TbMember (cn.exrick.manager.pojo.TbMember)12 DataTablesResult (cn.exrick.common.pojo.DataTablesResult)11 TbMemberExample (cn.exrick.manager.pojo.TbMemberExample)5 SimpleDateFormat (java.text.SimpleDateFormat)5 Gson (com.google.gson.Gson)4 TbItem (cn.exrick.manager.pojo.TbItem)3 TbThanksExample (cn.exrick.manager.pojo.TbThanksExample)3 PageInfo (com.github.pagehelper.PageInfo)3 ParseException (java.text.ParseException)3 ArrayList (java.util.ArrayList)3 CartProduct (cn.exrick.manager.dto.front.CartProduct)2 SearchItem (cn.exrick.manager.dto.front.SearchItem)2 TbContentCategory (cn.exrick.manager.pojo.TbContentCategory)2 TbItemCat (cn.exrick.manager.pojo.TbItemCat)2 TbItemDesc (cn.exrick.manager.pojo.TbItemDesc)2 TbPanel (cn.exrick.manager.pojo.TbPanel)2 TbThanks (cn.exrick.manager.pojo.TbThanks)2 TransportClient (org.elasticsearch.client.transport.TransportClient)2