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;
}
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;
}
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;
}
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);
}
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;
}
Aggregations