Search in sources :

Example 21 with XmallException

use of cn.exrick.common.exception.XmallException in project xmall by Exrick.

the class RegisterServiceImpl method register.

@Override
public int register(String userName, String userPwd) {
    TbMember tbMember = new TbMember();
    tbMember.setUsername(userName);
    if (userName.isEmpty() || userPwd.isEmpty()) {
        // 用户名密码不能为空
        return -1;
    }
    boolean result = checkData(userName, 1);
    if (!result) {
        // 该用户名已被注册
        return 0;
    }
    // MD5加密
    String md5Pass = DigestUtils.md5DigestAsHex(userPwd.getBytes());
    tbMember.setPassword(md5Pass);
    tbMember.setState(1);
    tbMember.setCreated(new Date());
    tbMember.setUpdated(new Date());
    if (tbMemberMapper.insert(tbMember) != 1) {
        throw new XmallException("注册用户失败");
    }
    return 1;
}
Also used : TbMember(cn.exrick.manager.pojo.TbMember) XmallException(cn.exrick.common.exception.XmallException) Date(java.util.Date)

Example 22 with XmallException

use of cn.exrick.common.exception.XmallException in project xmall by Exrick.

the class ItemCatServiceImpl method addItemCat.

@Override
public int addItemCat(TbItemCat tbItemCat) {
    if (tbItemCat.getParentId() == 0) {
        // 根节点
        tbItemCat.setSortOrder(0);
        tbItemCat.setStatus(1);
    } else {
        TbItemCat parent = tbItemCatMapper.selectByPrimaryKey(tbItemCat.getParentId());
        tbItemCat.setSortOrder(0);
        tbItemCat.setStatus(1);
        tbItemCat.setCreated(new Date());
        tbItemCat.setUpdated(new Date());
    }
    if (tbItemCatMapper.insert(tbItemCat) != 1) {
        throw new XmallException("添加商品分类失败");
    }
    return 1;
}
Also used : TbItemCat(cn.exrick.manager.pojo.TbItemCat) XmallException(cn.exrick.common.exception.XmallException) Date(java.util.Date)

Example 23 with XmallException

use of cn.exrick.common.exception.XmallException in project xmall by Exrick.

the class ItemCatServiceImpl method updateItemCat.

@Override
public int updateItemCat(TbItemCat tbItemCat) {
    TbItemCat old = getItemCatById(tbItemCat.getId());
    tbItemCat.setCreated(old.getCreated());
    tbItemCat.setUpdated(new Date());
    if (tbItemCatMapper.updateByPrimaryKey(tbItemCat) != 1) {
        throw new XmallException("添加商品分类失败");
    }
    return 1;
}
Also used : TbItemCat(cn.exrick.manager.pojo.TbItemCat) XmallException(cn.exrick.common.exception.XmallException) Date(java.util.Date)

Example 24 with XmallException

use of cn.exrick.common.exception.XmallException in project xmall by Exrick.

the class ItemServiceImpl method updateItem.

@Override
public TbItem updateItem(Long id, ItemDto itemDto) {
    TbItem oldTbItem = getNormalItemById(id);
    TbItem tbItem = DtoUtil.ItemDto2TbItem(itemDto);
    if (tbItem.getImage().isEmpty()) {
        tbItem.setImage(oldTbItem.getImage());
    }
    tbItem.setId(id);
    tbItem.setStatus(oldTbItem.getStatus());
    tbItem.setCreated(oldTbItem.getCreated());
    tbItem.setUpdated(new Date());
    if (tbItemMapper.updateByPrimaryKey(tbItem) != 1) {
        throw new XmallException("更新商品失败");
    }
    TbItemDesc tbItemDesc = new TbItemDesc();
    tbItemDesc.setItemId(id);
    tbItemDesc.setItemDesc(itemDto.getDetail());
    tbItemDesc.setUpdated(new Date());
    tbItemDesc.setCreated(oldTbItem.getCreated());
    if (tbItemDescMapper.updateByPrimaryKey(tbItemDesc) != 1) {
        throw new XmallException("更新商品详情失败");
    }
    // 同步缓存
    deleteProductDetRedis(id);
    // 发送消息同步索引库
    sendRefreshESMessage("add", id);
    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)

Example 25 with XmallException

use of cn.exrick.common.exception.XmallException in project xmall by Exrick.

the class MemberServiceImpl method getMemberByUsername.

@Override
public TbMember getMemberByUsername(String username) {
    List<TbMember> list;
    TbMemberExample example = new TbMemberExample();
    TbMemberExample.Criteria criteria = example.createCriteria();
    criteria.andUsernameEqualTo(username);
    try {
        list = tbMemberMapper.selectByExample(example);
    } catch (Exception e) {
        throw new XmallException("ID获取会员信息失败");
    }
    if (!list.isEmpty()) {
        list.get(0).setPassword("");
        return list.get(0);
    }
    return null;
}
Also used : TbMember(cn.exrick.manager.pojo.TbMember) TbMemberExample(cn.exrick.manager.pojo.TbMemberExample) XmallException(cn.exrick.common.exception.XmallException) XmallException(cn.exrick.common.exception.XmallException)

Aggregations

XmallException (cn.exrick.common.exception.XmallException)47 Date (java.util.Date)22 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 TbThanks (cn.exrick.manager.pojo.TbThanks)2 TransportClient (org.elasticsearch.client.transport.TransportClient)2 Settings (org.elasticsearch.common.settings.Settings)2